Documentation
¶
Overview ¶
Package discovery handles code unit discovery and indexing.
Index ¶
- func ChangedFiles(root, ref1, ref2 string) ([]string, error)
- func DeduplicateFileLevel(units []domain.Unit) []domain.Unit
- func DetectedAdapters(langs []LanguageInfo) []string
- func FilterByPaths(units []domain.Unit, paths []string) []domain.Unit
- func FilterChanged(units []domain.Unit, changedFiles []string) []domain.Unit
- func Merge(lists ...UnitList) []domain.Unit
- func Scanners() map[string]Scanner
- type AnalysisAdapter
- type DiffResult
- type GenericScanner
- type GoAdapter
- type Index
- type LanguageInfo
- type MovedFile
- type Scanner
- type TSAdapter
- type UnitList
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChangedFiles ¶
ChangedFiles returns files changed between two git refs (or working tree if ref2 is empty).
func DeduplicateFileLevel ¶
DeduplicateFileLevel removes file-level units when symbol-level units exist for the same file from a language adapter.
func DetectedAdapters ¶
func DetectedAdapters(langs []LanguageInfo) []string
DetectedAdapters returns the unique adapter names needed for detected languages.
func FilterByPaths ¶
FilterByPaths returns units whose paths match any of the given path prefixes.
func FilterChanged ¶
FilterChanged returns only units whose paths appear in the changed files list.
func Merge ¶
Merge combines multiple unit lists, deduplicating by UnitID string. When duplicate IDs exist, the more specific type wins (function > file).
func Scanners ¶ added in v0.2.0
Scanners returns a registry mapping adapter names to Scanner implementations. Use this for polymorphic dispatch instead of switch statements on adapter names. GenericScanner is excluded because it requires config params and always runs unconditionally.
Languages with a registered analysis.Analyzer get tree-sitter-backed discovery (full AST, symbol-level units). Languages without fall back to regex or file-level.
Types ¶
type AnalysisAdapter ¶ added in v0.11.0
type AnalysisAdapter struct {
// contains filtered or unexported fields
}
AnalysisAdapter discovers code units using the analysis.Analyzer interface. This replaces language-specific regex adapters with tree-sitter-backed discovery.
func NewAnalysisAdapter ¶ added in v0.11.0
func NewAnalysisAdapter(lang string, extensions []string) *AnalysisAdapter
NewAnalysisAdapter creates a discovery adapter backed by an Analyzer.
type DiffResult ¶
DiffResult represents changes between two index snapshots.
func Diff ¶
func Diff(old, new_ *Index) DiffResult
Diff computes the difference between an old and new index.
type GenericScanner ¶
type GenericScanner struct {
// contains filtered or unexported fields
}
GenericScanner discovers all files as file-level units.
func NewGenericScanner ¶
func NewGenericScanner(include, exclude []string) *GenericScanner
NewGenericScanner creates a scanner with include/exclude patterns.
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index holds a snapshot of discovered code units.
type LanguageInfo ¶
type LanguageInfo struct {
Name string // "go", "typescript", "python", etc.
FileCount int
HasConfig bool // go.mod, package.json, pyproject.toml, etc.
Adapter string // "go", "ts", "generic"
}
LanguageInfo describes a detected language in a repository.
func DetectLanguages ¶
func DetectLanguages(root string) []LanguageInfo
DetectLanguages walks a directory and detects programming languages present.
type MovedFile ¶
MovedFile represents a file rename detected by git.
func DetectMoves ¶
DetectMoves identifies likely file renames between old and new unit lists. Uses git's rename detection when available, falls back to symbol matching.
type Scanner ¶
type Scanner interface {
// Scan discovers all code units under the given root directory.
Scan(root string) ([]domain.Unit, error)
}
Scanner discovers certifiable code units in a repository.
type TSAdapter ¶
type TSAdapter struct{}
TSAdapter discovers TypeScript symbols using regex patterns.
func NewTSAdapter ¶
func NewTSAdapter() *TSAdapter
NewTSAdapter creates a new TypeScript discovery adapter.