Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EstimateTokens ¶
EstimateTokens returns a rough token count from byte length using the chars/4 heuristic. Backed by the shared internal/tokens helper so providers, compress, and the diff layer never drift apart. Provider-side exact tokenizers can replace this when they're cheap to call from outside the provider's process.
Types ¶
type Diff ¶
type Diff struct {
Files []FileDiff
Origin git.Origin
Args map[string]string
// contains filtered or unexported fields
}
func KeepPaths ¶ added in v0.9.0
KeepPaths narrows a Diff to only files matching the supplied allowlists. files is an exact-path allowlist (post-change Path or OldPath equality, slash-normalized). dirs is a prefix allowlist — a file is kept when its path starts with `<dir>/` for any entry (trailing slash on the input is stripped, then added by the matcher).
Both empty → no filtering (returns d unchanged). When at least one is non-empty, the union semantics apply: a file is kept if it matches ANY file OR sits under ANY dir.
Paths are compared after `filepath.ToSlash` normalization on both sides so a user passing `app\Models` on Windows still matches `app/Models/User.go` in the parsed diff.
func (Diff) AddedLines ¶
AddedLines is the count of `+` lines across all hunks in all files. O(1) — the value is computed once in Parse / Filter / KeepPaths and memoized in the struct.
func (Diff) DeletedLines ¶
DeletedLines is the count of `-` lines across all hunks in all files. Memoized like AddedLines.
func (Diff) EstimateTokens ¶
type FileDiff ¶
type FileDiff struct {
Path string
OldPath string
Mode Mode
Hunks []Hunk
Binary bool
// PathParts is Path pre-split on `/`, populated once during
// parseDiffHeader. The ignore-matcher backend takes `[]string`
// parts; without this cache every Match call would re-split.
// On a 500-file diff with two filter layers that's 1000+
// redundant allocations.
PathParts []string
// OldPathParts mirrors PathParts for renamed/deleted entries.
OldPathParts []string
}