Documentation
¶
Overview ¶
Package grep implements a generic, language-agnostic TOON-emitting search across a project tree, built on the same walker + matcher + enclosing infrastructure as this toolkit's other structural tools. Useful when the AI needs any substring or regex hit (class names, SQL fragments, magic strings) surfaced in a token-cheap, structured form.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultIgnoreDirs = []string{
"vendor", "node_modules", "var", ".git", ".idea", ".vscode",
".svn", ".hg", "dist", "build", "target", "__pycache__",
}
DefaultIgnoreDirs are the directories every project's grep should skip by default (heavy, machine-managed). Extra entries can be added via Options.ExtraIgnore. Exported so `sf code`'s directory expansion walks the same tree grep does, rather than drifting with a second copy.
Functions ¶
Types ¶
type Options ¶
type Options struct {
Root string
Patterns []string
Format string // "toon" | "md" | "json"
CaseSensitive bool
WordBound bool
Regex bool
Exts []string // file extensions to include (".php" etc.); empty = all
ExtraIgnore []string // extra directory names to skip in addition to defaults
MaxPerPattern int // 0 = unlimited
}
type PatternResult ¶
type Result ¶
type Result struct {
Patterns []*PatternResult `json:"patterns"`
Empty []string `json:"empty,omitempty"`
Skipped int `json:"skipped,omitempty"` // files skipped: binary or over-long lines
}
func Scan ¶ added in v0.11.0
Scan runs the search and returns the structured result without rendering or logging anything — the building block a caller that wants to post-process hits (group them by layer, feed another tool) uses instead of Run, which renders and writes telemetry. It shares the same unexported scan Run drives, so the two never drift.