Documentation
¶
Index ¶
- Constants
- func IsCopyPasteIntent(intent, diffText string) bool
- func IsEmptyIntent(intent string) bool
- func ParseDiffFromFile(path string) ([]*gitdiff.File, error)
- func ParseDiffFromGit(base, head string) ([]*gitdiff.File, error)
- func ParseDiffFromReader(r io.Reader) ([]*gitdiff.File, error)
- func ReadIntentFromFile(path string) (string, string, error)
- func ReadIntentFromPRJSON(path string) (string, string, error)
- func ReadIntentFromStdin(r io.Reader) (string, string, error)
- func RiskOrder(r RiskTag) int
- type ChangedFile
- type CollectResult
- type FileCategory
- type RiskTag
Constants ¶
const DefaultBudgetChars = 100_000
Variables ¶
This section is empty.
Functions ¶
func IsCopyPasteIntent ¶
IsCopyPasteIntent returns true if the intent is suspiciously similar to the diff.
func IsEmptyIntent ¶
IsEmptyIntent returns true if the intent text is too short to be useful.
func ParseDiffFromFile ¶
ParseDiffFromFile reads a unified diff from a file path.
func ParseDiffFromGit ¶
ParseDiffFromGit runs git diff between base and head refs and parses the result.
func ParseDiffFromReader ¶
ParseDiffFromReader reads a unified diff from an io.Reader.
func ReadIntentFromFile ¶
ReadIntentFromFile reads PR description text from a markdown file.
func ReadIntentFromPRJSON ¶
ReadIntentFromPRJSON reads title and body from gh pr view --json output.
func ReadIntentFromStdin ¶
ReadIntentFromStdin reads PR description from stdin.
Types ¶
type ChangedFile ¶
type ChangedFile struct {
Path string `json:"path"`
Category FileCategory `json:"category"`
Risk RiskTag `json:"risk"`
Added int `json:"added"`
Deleted int `json:"deleted"`
IsBinary bool `json:"is_binary"`
HunkText string `json:"hunk_text,omitempty"`
Truncated bool `json:"truncated,omitempty"`
}
ChangedFile represents a single file from the diff with classification metadata.
func FilesToChangedFiles ¶
func FilesToChangedFiles(files []*gitdiff.File) []ChangedFile
FilesToChangedFiles converts parsed gitdiff files into our ChangedFile type.
func TruncateFiles ¶
func TruncateFiles(files []ChangedFile, budget int) (included []ChangedFile, excluded []string, truncated bool)
TruncateFiles applies the diff truncation strategy: 1. Exclude generated/vendor/binary/lockfile 2. Sort remaining by risk (high risk first) 3. Truncate low-risk hunks to fit within char budget
type CollectResult ¶
type CollectResult struct {
Intent string `json:"intent"`
IntentSource string `json:"intent_source"`
Files []ChangedFile `json:"files"`
TotalAdded int `json:"total_added"`
TotalDeleted int `json:"total_deleted"`
ExcludedFiles []string `json:"excluded_files,omitempty"`
Truncated bool `json:"truncated"`
DiffChars int `json:"diff_chars"`
BudgetChars int `json:"budget_chars"`
}
CollectResult is the output of the Collect stage, ready for the Analyze stage.
type FileCategory ¶
type FileCategory string
FileCategory classifies a changed file by its role in the project.
const ( CategorySource FileCategory = "source" CategoryTest FileCategory = "test" CategoryConfig FileCategory = "config" CategoryDocs FileCategory = "docs" CategoryGenerated FileCategory = "generated" CategoryVendor FileCategory = "vendor" CategoryBinary FileCategory = "binary" CategoryLockfile FileCategory = "lockfile" )
func ClassifyFile ¶
func ClassifyFile(path string) FileCategory
ClassifyFile determines the FileCategory for a given file path.