···11+package diff
22+33+import "io"
44+55+// DiffViewKind enumerates the supported diff views.
66+type DiffViewKind int
77+88+const (
99+ ViewUnified DiffViewKind = iota
1010+ ViewSplit
1111+ ViewHunk
1212+ ViewInline
1313+ ViewRich
1414+ ViewSource
1515+)
1616+1717+// String returns a human-readable name for the view kind.
1818+func (k DiffViewKind) String() string {
1919+ switch k {
2020+ case ViewUnified:
2121+ return "Unified"
2222+ case ViewSplit:
2323+ return "Split"
2424+ case ViewHunk:
2525+ return "Hunk"
2626+ case ViewInline:
2727+ return "Inline"
2828+ case ViewRich:
2929+ return "Rich"
3030+ case ViewSource:
3131+ return "Source"
3232+ default:
3333+ return "Unknown"
3434+ }
3535+}
3636+3737+// DiffResult holds the output of a diff tool.
3838+type DiffResult struct {
3939+ // Content is the rendered diff output (text, ANSI, HTML, etc.)
4040+ Content string
4141+4242+ // View is the kind of view used to render the diff.
4343+ View DiffViewKind
4444+4545+ // Metadata like file paths, commit hashes, timestamps (optional).
4646+ // You may extend as needed.
4747+ OldPath string
4848+ NewPath string
4949+ FromHash string
5050+ ToHash string
5151+}
5252+5353+// DiffTool is the interface for generating diffs between two versions.
5454+type DiffTool interface {
5555+ // Diff takes two blobs (old and new versions) and returns a DiffResult.
5656+ // The reader parameters may be full file contents or other abstraction.
5757+ // The viewKind parameter selects which view implementation (Unified/Split/...).
5858+ Diff(oldContent io.Reader, newContent io.Reader, viewKind DiffViewKind) (DiffResult, error)
5959+}
6060+6161+// UnifiedDiff implements unified view (single linear view with additions & deletions).
6262+type UnifiedDiff struct{}
6363+6464+// SplitDiff implements side-by-side view (old on left, new on right).
6565+type SplitDiff struct{}
6666+6767+// HunkDiff focuses on changed blocks, minimal context.
6868+type HunkDiff struct{}
6969+7070+// InlineDiff renders changes inline in full file flow.
7171+type InlineDiff struct{}
7272+7373+// RichDiff renders changes for formatted preview (for example, markdown or html previews).
7474+type RichDiff struct{}
7575+7676+// SourceDiff simply returns raw diff data or patch format without special formatting.
7777+type SourceDiff struct{}
+88
internal/gitlog/gitlog.go
···11+package gitlog
22+33+import (
44+ "fmt"
55+ "time"
66+77+ "github.com/go-git/go-git/v6"
88+)
99+1010+// CommitKind represents the kind of commit according to Conventional Commits.
1111+type CommitKind int
1212+1313+const (
1414+ CommitTypeUnknown CommitKind = iota
1515+ CommitTypeFeat
1616+ CommitTypeFix
1717+ CommitTypeDocs
1818+ CommitTypeStyle
1919+ CommitTypeRefactor
2020+ CommitTypePerf
2121+ CommitTypeTest
2222+ CommitTypeBuild
2323+ CommitTypeCI
2424+ CommitTypeChore
2525+ CommitTypeRevert
2626+)
2727+2828+// String returns the string representation of the CommitType.
2929+func (kind CommitKind) String() string {
3030+ switch kind {
3131+ case CommitTypeFeat:
3232+ return "feat"
3333+ case CommitTypeFix:
3434+ return "fix"
3535+ case CommitTypeDocs:
3636+ return "docs"
3737+ case CommitTypeStyle:
3838+ return "style"
3939+ case CommitTypeRefactor:
4040+ return "refactor"
4141+ case CommitTypePerf:
4242+ return "perf"
4343+ case CommitTypeTest:
4444+ return "test"
4545+ case CommitTypeBuild:
4646+ return "build"
4747+ case CommitTypeCI:
4848+ return "ci"
4949+ case CommitTypeChore:
5050+ return "chore"
5151+ case CommitTypeRevert:
5252+ return "revert"
5353+ default:
5454+ return "unknown"
5555+ }
5656+}
5757+5858+func Log() { fmt.Println(git.GitDirName) }
5959+6060+type CommitMeta struct {
6161+ Type string // feat, fix, docs, etc.
6262+ Scope string // optional
6363+ Description string
6464+ Breaking bool
6565+ Body string
6666+ Footers map[string]string
6767+}
6868+6969+// CommitParser defines parsing of raw commit message strings into structured metadata.
7070+type CommitParser interface {
7171+ // Parse takes a commit hash, subject line, body (including footers)
7272+ // and the commit date, and returns a structured [CommitMeta]
7373+ Parse(hash, subject, body string, date time.Time) (CommitMeta, error)
7474+7575+ // IsValidType returns true if the given [CommitKind] is recognised / allowed by your tooling.
7676+ IsValidType(kind CommitKind) bool
7777+7878+ // Categorize returns the category (e.g., "Added", "Fixed", "Changed") for the given CommitMeta.
7979+ Categorize(meta CommitMeta) string
8080+}
8181+8282+// DefaultParser implements [CommitParser] and parses single
8383+// or multi-line commits into one or more [CommitMeta]
8484+type DefaultParser struct{}
8585+8686+// ConventionalParser implements [CommitParser] and parses
8787+// conventional commits into one or more [CommitMeta]
8888+type ConventionalParser struct{}