Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildDiffFile ¶
BuildDiffFile builds a types.DiffFile for path by diffing oldContent against newContent with a full-context, single-hunk line diff: every line of both sides appears, prefixed " " (context), "-" (removed) or "+" (added), exactly like a unified diff body without the +/-3 line windowing. analyzer.AnalyzeDiff and prompt.Builder only ever look at line prefixes, so the single full hunk is sufficient context for this engine's purposes and is far simpler to get right than minimal hunk splitting.
Types ¶
type DiffAnalyzer ¶
type DiffAnalyzer struct {
// contains filtered or unexported fields
}
DiffAnalyzer analyzes code diffs and extracts metrics
func NewDiffAnalyzer ¶
func NewDiffAnalyzer() *DiffAnalyzer
NewDiffAnalyzer creates a new diff analyzer
func (*DiffAnalyzer) AnalyzeDiff ¶
func (a *DiffAnalyzer) AnalyzeDiff(diff *types.Diff) *DiffMetrics
AnalyzeDiff analyzes a diff and extracts metrics
func (*DiffAnalyzer) ExtractChangedFunctions ¶
func (a *DiffAnalyzer) ExtractChangedFunctions(file *types.DiffFile) []string
ExtractChangedFunctions extracts function names from changed hunks
func (*DiffAnalyzer) GetComplexityScore ¶
func (a *DiffAnalyzer) GetComplexityScore(metrics *DiffMetrics) int
GetComplexityScore estimates complexity based on metrics
type DiffMetrics ¶
type DiffMetrics struct {
TotalFiles int
LinesAdded int
LinesDeleted int
FilesModified int
FilesAdded int
FilesDeleted int
TestFiles int
ConfigFiles int
LanguageBreakdown map[string]int
}
DiffMetrics contains metrics extracted from a diff
type DiffNotice ¶
DiffNotice reports a changed file that was deliberately not line-diffed. Message is already user-facing and carries the path, so a caller can print it verbatim.
This is a package-local type rather than a new field on types.Diff because pkg/types is outside this card's writable paths.
type LanguageDetector ¶
type LanguageDetector struct {
// contains filtered or unexported fields
}
LanguageDetector detects programming languages from file extensions
func NewLanguageDetector ¶
func NewLanguageDetector() *LanguageDetector
NewLanguageDetector creates a new language detector
func (*LanguageDetector) DetectLanguage ¶
func (d *LanguageDetector) DetectLanguage(filePath string) string
DetectLanguage detects the programming language from a file path
func (*LanguageDetector) GetLanguageCategory ¶
func (d *LanguageDetector) GetLanguageCategory(language string) string
GetLanguageCategory returns the category of a language
func (*LanguageDetector) IsConfigFile ¶
func (d *LanguageDetector) IsConfigFile(filePath string) bool
IsConfigFile checks if a file is a configuration file
func (*LanguageDetector) IsTestFile ¶
func (d *LanguageDetector) IsTestFile(filePath string) bool
IsTestFile checks if a file is a test file based on naming conventions
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
Repo is a read-only handle onto a local git repository.
func OpenRepo ¶
OpenRepo resolves root as a git repository. It prefers a `git` binary on PATH when one is available (see the package doc above for why); when none is available it falls back to treating root/.git as a normal working tree's git dir, or root itself as a bare repository (it has HEAD, objects and refs directly).
func (*Repo) Diff ¶
Diff computes the changed-file diff between baseRef and headRef as a types.Diff, in the same shape AnalyzeDiff and the prompt builder already consume. Unchanged files (identical blob SHA on both sides) are omitted, matching how `git diff` itself only reports files that changed. Files are returned sorted by path so the same two commits always produce byte-identical output.
A changed file that is binary, or larger than the limits in textdiff.go, is not diffed at all: it is left out of the returned types.Diff -- so no model call is ever made for it -- and reported through the returned notices instead, in the same sorted path order. That is not an error condition; callers print the notices and carry on.
func (*Repo) ResolveRef ¶
ResolveRef resolves a ref expression to a commit SHA. It understands: a raw 40-character hex SHA, "HEAD" (following one level of symbolic indirection to refs/heads/<branch>), a bare branch name under refs/heads/, and a "<ref>~N" (or "<ref>~", meaning N=1) parent-walk suffix applied to any of the above. When a `git` binary is in use, the full range of git's own revision syntax is accepted instead, since `git rev-parse` does the resolving.