Documentation
¶
Overview ¶
Package query is the read side of the index: symbol search, lookups and graph traversals used by the MCP tools. All methods are safe for concurrent use (SQLite handles reader concurrency).
Index ¶
- type CodeMatch
- type EdgeFilter
- type EdgeHit
- type Engine
- func (e *Engine) Callees(fqn string, limit int, f EdgeFilter) ([]EdgeHit, error)
- func (e *Engine) Callers(fqn string, limit int, f EdgeFilter) ([]EdgeHit, error)
- func (e *Engine) FileOutline(path string) ([]SymbolHit, error)
- func (e *Engine) GetSymbol(fqn string) ([]SymbolHit, error)
- func (e *Engine) GraphNotice(fqn string) string
- func (e *Engine) Hierarchy(fqn string) (ancestors, descendants []Relative, err error)
- func (e *Engine) Impact(fqn string, maxDepth, perLevel int) (levels []ImpactLevel, testFiles []string, truncated bool, err error)
- func (e *Engine) Members(containerFQN string) ([]SymbolHit, error)
- func (e *Engine) ProjectMap(limit int) (ProjectMap, error)
- func (e *Engine) References(fqn string, limit int, f EdgeFilter) ([]EdgeHit, error)
- func (e *Engine) ReferencesCount(fqn string) (int, error)
- func (e *Engine) SearchCode(pattern string, isRegex bool, pathPrefix string, limit int) ([]CodeMatch, bool, error)
- func (e *Engine) SearchSymbols(q, kind, name, pathPrefix string, limit, offset int) (hits []SymbolHit, total int, err error)
- func (e *Engine) Source(h SymbolHit, offset, maxLines int) (string, error)
- func (e *Engine) SymbolsByNames(names []string, limit int) ([]SymbolHit, error)
- func (e *Engine) TestFilesReferencing(fqns []string, limit int) ([]string, error)
- type ImpactCaller
- type ImpactLevel
- type ProjectMap
- type Relative
- type SymbolHit
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CodeMatch ¶ added in v0.1.10
type CodeMatch struct {
File string `json:"file"`
Line int `json:"line"`
Text string `json:"text"`
}
CodeMatch is one line-level hit of a full-text code search.
type EdgeFilter ¶ added in v0.1.8
type EdgeFilter struct {
PathPrefix string // root-relative path prefix, e.g. "api/src/"
ExcludeTests bool
}
EdgeFilter narrows call-graph results by file location.
type EdgeHit ¶
type EdgeHit struct {
From string `json:"from"` // "" = file-level code
Kind string `json:"kind"`
To string `json:"to"`
File string `json:"file"`
Line int `json:"line"`
Resolved bool `json:"resolved"` // false = heuristic match
Source string `json:"source,omitempty"` // "ast" | "phpstan" | "go-types" | ...
}
EdgeHit is one reference/call-graph result row.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) Callers ¶
Callers returns call edges into a callable. For methods, the class hierarchy is taken into account: calls recorded against an ancestor or descendant receiver with the same method name are included (marked unresolved), since the static receiver type in the source is often a supertype of the class that defines the method.
func (*Engine) FileOutline ¶
FileOutline lists all symbols declared in a file.
func (*Engine) GetSymbol ¶
GetSymbol returns all declarations matching an FQN. When the given name has no exact match, it is retried as a suffix (short names like "UserService" or "UserService::run()" work).
func (*Engine) GraphNotice ¶ added in v0.1.16
GraphNotice warns when a PHP symbol's call graph cannot see container and interface calls, or when the imported graph was built at another commit. Other languages return an empty string.
func (*Engine) Hierarchy ¶
Hierarchy returns supertypes and subtypes of a class-like symbol, each transitively closed.
func (*Engine) Impact ¶ added in v0.1.9
func (e *Engine) Impact(fqn string, maxDepth, perLevel int) (levels []ImpactLevel, testFiles []string, truncated bool, err error)
Impact walks the caller graph up to maxDepth levels (callers, then callers of callers, ...) and separates test locations — an approximation of the blast radius of changing the symbol. Direct to_fqn matches only; hierarchy-widened calls are not followed, so treat the result as a lower bound.
func (*Engine) ProjectMap ¶ added in v0.1.16
func (e *Engine) ProjectMap(limit int) (ProjectMap, error)
ProjectMap scans non-vendor files for route, command and SQL lines. limit caps each list. The result is a text scan.
func (*Engine) References ¶
References returns all edges pointing at the symbol (any kind). Names that re-export it through a barrel are included; the reexport edges themselves are not.
func (*Engine) ReferencesCount ¶ added in v0.1.9
ReferencesCount counts all edges pointing at a symbol.
func (*Engine) SearchCode ¶ added in v0.1.10
func (e *Engine) SearchCode(pattern string, isRegex bool, pathPrefix string, limit int) ([]CodeMatch, bool, error)
SearchCode scans the contents of indexed project files (non-vendor) for a literal substring or regex — the complement to SearchSymbols for things that live in string literals (metric ids, SQL aliases, config keys). Literal search is case-insensitive.
func (*Engine) SearchSymbols ¶
func (e *Engine) SearchSymbols(q, kind, name, pathPrefix string, limit, offset int) (hits []SymbolHit, total int, err error)
SearchSymbols runs a full-text search over names, FQNs and docs. kind optionally narrows to one symbol kind, name to an exact symbol name. total is the number of matches regardless of limit/offset.
func (*Engine) Source ¶
Source reads a window of the declaration's source text: offset lines below the declaration start, at most maxLines lines. The truncation marker tells the caller which offset fetches the next window, so long bodies are pageable.
func (*Engine) SymbolsByNames ¶ added in v0.1.9
SymbolsByNames returns project (non-vendor, non-test) symbols whose short name exactly matches any of names. Used by the prompt hook, so it must stay cheap: one indexed IN query.
func (*Engine) TestFilesReferencing ¶ added in v0.1.10
TestFilesReferencing lists test files that hold any edge pointing at one of the given FQNs — the fallback signal for impact when no call edges originate from tests (test code sits outside the type-inference pass and mocks defeat AST resolution).
type ImpactCaller ¶ added in v0.1.9
type ImpactCaller struct {
FQN string `json:"fqn"`
File string `json:"file"`
Line int `json:"line"`
}
ImpactCaller is one symbol reached while walking the caller graph.
type ImpactLevel ¶ added in v0.1.9
type ImpactLevel struct {
Depth int `json:"depth"`
Callers []ImpactCaller `json:"callers"`
}
ImpactLevel groups callers by their distance from the changed symbol.
type ProjectMap ¶ added in v0.1.16
type ProjectMap struct {
Routes []CodeMatch `json:"routes"`
Commands []CodeMatch `json:"commands"`
SQL []CodeMatch `json:"sql"`
}
ProjectMap is a short list of routes, commands and SQL strings written in source. It does not execute PHP.
type Relative ¶
type Relative struct {
FQN string `json:"fqn"`
Kind string `json:"kind"` // edge kind linking it to the queried class
}
Relative is one hierarchy neighbor.
type SymbolHit ¶
type SymbolHit struct {
FQN string `json:"fqn"`
Kind string `json:"kind"`
File string `json:"file"`
Line int `json:"line"`
EndLine int `json:"endLine,omitempty"`
Signature string `json:"signature,omitempty"`
Doc string `json:"doc,omitempty"`
Vendor bool `json:"vendor,omitempty"`
}
SymbolHit is one search / lookup result row.