Documentation
¶
Index ¶
- func BuildGraph(workDir string, parsers []Parser) (*ImportGraph, []*FileInfo, error)
- func IsExported(name string, language string) bool
- type FileInfo
- type FuncSignature
- type GoParser
- type ImportGraph
- func (g *ImportGraph) AddNode(path string, imports []string, language string)
- func (g *ImportGraph) AllPaths() []string
- func (g *ImportGraph) Downstream(path string, depth int) []string
- func (g *ImportGraph) HasNode(path string) bool
- func (g *ImportGraph) Neighbors(path string) (imports []string, importedBy []string)
- func (g *ImportGraph) NodeCount() int
- func (g *ImportGraph) Upstream(path string, depth int) []string
- type ImportInfo
- type Indexer
- func (idx *Indexer) Build(ctx context.Context) error
- func (idx *Indexer) BuiltAt() time.Time
- func (idx *Indexer) Define(symbol string) []SymbolLocation
- func (idx *Indexer) Downstream(path string, depth int) []string
- func (idx *Indexer) FileCount() int
- func (idx *Indexer) FileSymbols(path string) []SymbolInfo
- func (idx *Indexer) FormatContext(targetFiles []string, description string, topN int, maxBytes int) string
- func (idx *Indexer) IsBuilt() bool
- func (idx *Indexer) Neighbors(path string) (imports []string, importedBy []string)
- func (idx *Indexer) ProjectSummary(maxBytes int) string
- func (idx *Indexer) RelevantFiles(targetFiles []string, description string, topN int) []ScoredFile
- func (idx *Indexer) SymbolCount() int
- func (idx *Indexer) SymbolsMatching(query string) []string
- func (idx *Indexer) Upstream(path string, depth int) []string
- type Node
- type Parser
- type PythonParser
- type RelevanceScorer
- type RustParser
- type ScoredFile
- type SymbolIndex
- func (idx *SymbolIndex) AddFile(info *FileInfo)
- func (idx *SymbolIndex) AllSymbols() []string
- func (idx *SymbolIndex) Define(name string) []SymbolLocation
- func (idx *SymbolIndex) DefineInFile(name, file string) *SymbolLocation
- func (idx *SymbolIndex) FileCount() int
- func (idx *SymbolIndex) FileSymbols(path string) []SymbolInfo
- func (idx *SymbolIndex) FindFuncs(name string) []SymbolLocation
- func (idx *SymbolIndex) FindTypes(name string) []SymbolLocation
- func (idx *SymbolIndex) SymbolCount() int
- func (idx *SymbolIndex) SymbolsMatching(query string) []string
- type SymbolInfo
- type SymbolLocation
- type TypeInfo
- type TypeScriptParser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildGraph ¶
func BuildGraph(workDir string, parsers []Parser) (*ImportGraph, []*FileInfo, error)
BuildGraph parses all source files in workDir and builds the import graph. It resolves local imports to relative file paths where possible.
func IsExported ¶
IsExported reports whether a symbol name is exported in its language. For Go: starts with uppercase. For others: heuristic based on leading underscore.
Types ¶
type FileInfo ¶
type FileInfo struct {
Path string
Language string
Imports []ImportInfo
Exports []SymbolInfo
Funcs []FuncSignature
Types []TypeInfo
}
FileInfo is the parsed representation of a single source file.
type FuncSignature ¶
type FuncSignature struct {
Name string
Receiver string // non-empty for methods (e.g. "*Engine")
Params string // parameter list as display string
Returns string // return type(s) as display string
Exported bool
}
FuncSignature represents a function or method signature.
type GoParser ¶
type GoParser struct{}
GoParser uses Go's standard go/ast package for full-fidelity parsing.
type ImportGraph ¶
type ImportGraph struct {
// contains filtered or unexported fields
}
ImportGraph is a directed dependency graph between source files.
func NewImportGraph ¶
func NewImportGraph() *ImportGraph
NewImportGraph creates an empty import graph.
func (*ImportGraph) AddNode ¶
func (g *ImportGraph) AddNode(path string, imports []string, language string)
AddNode adds a file to the graph with its imports. All paths must be relative to the working directory. If the node already exists as a stub (from a reverse edge), it is updated.
func (*ImportGraph) AllPaths ¶
func (g *ImportGraph) AllPaths() []string
AllPaths returns all file paths in the graph, sorted.
func (*ImportGraph) Downstream ¶
func (g *ImportGraph) Downstream(path string, depth int) []string
Downstream returns all files that depend on `path`, up to `depth` levels. depth=1 returns direct importers only. depth=0 means unlimited.
func (*ImportGraph) HasNode ¶
func (g *ImportGraph) HasNode(path string) bool
HasNode reports whether the graph contains a node for the given path.
func (*ImportGraph) Neighbors ¶
func (g *ImportGraph) Neighbors(path string) (imports []string, importedBy []string)
Neighbors returns direct imports and direct importers of a file.
func (*ImportGraph) NodeCount ¶
func (g *ImportGraph) NodeCount() int
NodeCount returns the number of nodes in the graph.
type ImportInfo ¶
type ImportInfo struct {
Path string // raw import path (e.g. "fmt", "./utils", "github.com/foo/bar")
ResolvedTo string // resolved local file path (populated during graph build)
}
ImportInfo represents a single import declaration in a source file.
type Indexer ¶
type Indexer struct {
// contains filtered or unexported fields
}
Indexer provides a unified API for codebase intelligence: parsing, import graph traversal, symbol lookup, and relevance scoring.
func NewIndexer ¶
NewIndexer creates a new codebase indexer for the given working directory. The indexer is lazy — call Build() before using query methods.
func (*Indexer) Build ¶
Build parses all source files in the working directory and builds the import graph, symbol index, and relevance scorer.
func (*Indexer) Define ¶
func (idx *Indexer) Define(symbol string) []SymbolLocation
Define returns where a symbol is defined.
func (*Indexer) Downstream ¶
Downstream returns files that depend on the given path, up to depth levels.
func (*Indexer) FileSymbols ¶
func (idx *Indexer) FileSymbols(path string) []SymbolInfo
FileSymbols returns all symbols defined in a file.
func (*Indexer) FormatContext ¶
func (idx *Indexer) FormatContext(targetFiles []string, description string, topN int, maxBytes int) string
FormatContext generates an LLM-ready text summary of relevant codebase intelligence for a set of target files and a task description. The output is capped at maxBytes.
func (*Indexer) ProjectSummary ¶
ProjectSummary returns a high-level summary of the project structure suitable for the plan phase context.
func (*Indexer) RelevantFiles ¶
func (idx *Indexer) RelevantFiles(targetFiles []string, description string, topN int) []ScoredFile
RelevantFiles returns the top-N files most relevant to a task described by target files and a text description.
func (*Indexer) SymbolCount ¶
SymbolCount returns the number of unique symbols.
func (*Indexer) SymbolsMatching ¶
SymbolsMatching returns symbols whose names contain the query substring.
type Node ¶
type Node struct {
Path string
Imports []string // files this file imports (direct edges)
ImportedBy []string // files that import this file (reverse edges)
Language string
// contains filtered or unexported fields
}
Node represents a single file in the import graph.
type Parser ¶
type Parser interface {
Language() string
CanParse(path string) bool
Parse(path string, content []byte) (*FileInfo, error)
}
Parser extracts structured information from a source file.
func AllParsers ¶
func AllParsers() []Parser
AllParsers returns the default set of language parsers.
func ParserForFile ¶
ParserForFile returns the first parser that can handle the given file, or nil.
type PythonParser ¶
type PythonParser struct{}
PythonParser extracts imports, classes, and functions from Python files.
func (*PythonParser) CanParse ¶
func (p *PythonParser) CanParse(path string) bool
func (*PythonParser) Language ¶
func (p *PythonParser) Language() string
type RelevanceScorer ¶
type RelevanceScorer struct {
// contains filtered or unexported fields
}
RelevanceScorer ranks files by how relevant they are to a given task.
func NewRelevanceScorer ¶
func NewRelevanceScorer(graph *ImportGraph, index *SymbolIndex) *RelevanceScorer
NewRelevanceScorer creates a scorer backed by the given graph and index.
func (*RelevanceScorer) Score ¶
func (s *RelevanceScorer) Score(targetFiles []string, taskDescription string, topN int) []ScoredFile
Score computes relevance scores for all files relative to a set of target files and a task description. Returns the top-N files sorted by score.
type RustParser ¶
type RustParser struct{}
RustParser extracts use statements, pub items, and type definitions from Rust files.
func (*RustParser) CanParse ¶
func (p *RustParser) CanParse(path string) bool
func (*RustParser) Language ¶
func (p *RustParser) Language() string
type ScoredFile ¶
ScoredFile represents a file ranked by relevance to a task.
type SymbolIndex ¶
type SymbolIndex struct {
// contains filtered or unexported fields
}
SymbolIndex maps symbol names to their definitions and files to their symbols.
func BuildIndex ¶
func BuildIndex(files []*FileInfo) *SymbolIndex
BuildIndex creates a symbol index from a list of parsed file infos.
func NewSymbolIndex ¶
func NewSymbolIndex() *SymbolIndex
NewSymbolIndex creates an empty symbol index.
func (*SymbolIndex) AddFile ¶
func (idx *SymbolIndex) AddFile(info *FileInfo)
AddFile indexes all symbols from a parsed file.
func (*SymbolIndex) AllSymbols ¶
func (idx *SymbolIndex) AllSymbols() []string
AllSymbols returns all unique symbol names in the index.
func (*SymbolIndex) Define ¶
func (idx *SymbolIndex) Define(name string) []SymbolLocation
Define returns all locations where a symbol is defined.
func (*SymbolIndex) DefineInFile ¶
func (idx *SymbolIndex) DefineInFile(name, file string) *SymbolLocation
DefineInFile returns the definition of a symbol in a specific file, or nil.
func (*SymbolIndex) FileCount ¶
func (idx *SymbolIndex) FileCount() int
FileCount returns the number of indexed files.
func (*SymbolIndex) FileSymbols ¶
func (idx *SymbolIndex) FileSymbols(path string) []SymbolInfo
FileSymbols returns all symbols defined in a file.
func (*SymbolIndex) FindFuncs ¶
func (idx *SymbolIndex) FindFuncs(name string) []SymbolLocation
FindFuncs returns all function definitions matching the name.
func (*SymbolIndex) FindTypes ¶
func (idx *SymbolIndex) FindTypes(name string) []SymbolLocation
FindTypes returns all type/struct/interface/class/enum definitions matching the name.
func (*SymbolIndex) SymbolCount ¶
func (idx *SymbolIndex) SymbolCount() int
SymbolCount returns the number of unique symbols.
func (*SymbolIndex) SymbolsMatching ¶
func (idx *SymbolIndex) SymbolsMatching(query string) []string
SymbolsMatching returns symbols whose names contain the given substring (case-insensitive).
type SymbolInfo ¶
type SymbolInfo struct {
Name string
Kind string // "func", "type", "interface", "const", "var", "class", "enum", "trait"
Exported bool
}
SymbolInfo represents a named symbol exported or defined in a file.
type SymbolLocation ¶
type SymbolLocation struct {
File string
Kind string // "func", "type", "interface", "class", "struct", "const", "var"
}
SymbolLocation identifies where a symbol is defined.
type TypeInfo ¶
type TypeInfo struct {
Name string
Kind string // "struct", "interface", "type", "class", "enum", "trait"
Fields []string
Methods []string
}
TypeInfo represents a struct, interface, class, or enum definition.
type TypeScriptParser ¶
type TypeScriptParser struct{}
TypeScriptParser extracts imports, exports, functions, and types from TypeScript and JavaScript files using regex patterns.
func (*TypeScriptParser) CanParse ¶
func (p *TypeScriptParser) CanParse(path string) bool
func (*TypeScriptParser) Language ¶
func (p *TypeScriptParser) Language() string