Documentation
¶
Overview ¶
Package cli provides the Cobra command tree for the codegraph binary. Each verb lives in its own file; this file contains shared UI helpers.
Index ¶
- func NewRootCmd() *cobra.Command
- type CalleesResult
- type CallersResult
- type FileInfo
- type GraphQuerier
- type ImpactResult
- type IndexInfo
- type PendingChanges
- type SearchOptions
- type StatusResult
- type StoreQuerier
- func (q *StoreQuerier) Callees(symbol string) (*CalleesResult, error)
- func (q *StoreQuerier) Callers(symbol string) (*CallersResult, error)
- func (q *StoreQuerier) Files() ([]FileInfo, error)
- func (q *StoreQuerier) Impact(symbol string, depth int) (*ImpactResult, error)
- func (q *StoreQuerier) SearchNodes(rawQuery string, opts SearchOptions) ([]model.SearchResult, error)
- func (q *StoreQuerier) Status(projectPath string) (*StatusResult, error)
- type SymbolRef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRootCmd ¶
NewRootCmd builds and returns the root Cobra command with all sub-commands attached. It does NOT call Execute() — the caller does.
Types ¶
type CalleesResult ¶
type CalleesResult struct {
Symbol string `json:"symbol"`
Callees []SymbolRef `json:"callees"`
Note string `json:"note,omitempty"`
}
CalleesResult is the JSON payload for `codegrapher callees <symbol>`.
type CallersResult ¶
type CallersResult struct {
Symbol string `json:"symbol"`
Callers []SymbolRef `json:"callers"`
Note string `json:"note,omitempty"`
}
CallersResult is the JSON payload for `codegrapher callers <symbol>`.
type FileInfo ¶
type FileInfo struct {
Path string `json:"path"`
Language model.Language `json:"language"`
NodeCount int `json:"nodeCount"`
Size int64 `json:"size"`
}
FileInfo is one entry in the `files` JSON array.
type GraphQuerier ¶
type GraphQuerier interface {
// SearchNodes runs the symbol-search pipeline and returns scored results.
SearchNodes(rawQuery string, opts SearchOptions) ([]model.SearchResult, error)
// Callers returns the set of symbols that call the given symbol name.
Callers(symbol string) (*CallersResult, error)
// Callees returns the set of symbols that the given symbol name calls.
Callees(symbol string) (*CalleesResult, error)
// Impact returns the blast-radius for the given symbol name.
Impact(symbol string, depth int) (*ImpactResult, error)
// Status returns index statistics.
Status(projectPath string) (*StatusResult, error)
// Files returns the list of indexed files.
Files() ([]FileInfo, error)
}
GraphQuerier is the narrow read-only interface the CLI needs from the query layer. Implement it against the real query package; use mockQuerier in tests.
func NewStoreQuerier ¶
func NewStoreQuerier(stores ...*store.Store) GraphQuerier
NewStoreQuerier wraps one or more *store.Store as a GraphQuerier. With a single store it behaves identically to the original single-store wrapper.
type ImpactResult ¶
type ImpactResult struct {
Symbol string `json:"symbol"`
Depth int `json:"depth"`
NodeCount int `json:"nodeCount"`
EdgeCount int `json:"edgeCount"`
Affected []SymbolRef `json:"affected"`
Note string `json:"note,omitempty"`
}
ImpactResult is the JSON payload for `codegrapher impact <symbol>`.
type IndexInfo ¶
type IndexInfo struct {
BuiltWithVersion string `json:"builtWithVersion"`
BuiltWithExtractionVersion int `json:"builtWithExtractionVersion"`
CurrentExtractionVersion int `json:"currentExtractionVersion"`
ReindexRecommended bool `json:"reindexRecommended"`
}
IndexInfo mirrors the `index` block of the status payload.
type PendingChanges ¶
type PendingChanges struct {
Added int `json:"added"`
Modified int `json:"modified"`
Removed int `json:"removed"`
}
PendingChanges mirrors the pendingChanges field in the status payload.
type SearchOptions ¶
type SearchOptions struct {
Limit int
Offset int
Kinds []model.NodeKind
Languages []model.Language
}
SearchOptions controls result set size and filtering.
type StatusResult ¶
type StatusResult struct {
Initialized bool `json:"initialized"`
Version string `json:"version"`
ProjectPath string `json:"projectPath"`
IndexPath string `json:"indexPath"`
LastIndexed string `json:"lastIndexed"`
FileCount int `json:"fileCount"`
NodeCount int `json:"nodeCount"`
EdgeCount int `json:"edgeCount"`
DBSizeBytes int64 `json:"dbSizeBytes"`
Backend string `json:"backend"`
JournalMode string `json:"journalMode"`
NodesByKind map[model.NodeKind]int `json:"nodesByKind"`
Languages []string `json:"languages"`
PendingChanges PendingChanges `json:"pendingChanges"`
WorktreeMismatch any `json:"worktreeMismatch"`
Index IndexInfo `json:"index"`
}
StatusResult is the JSON payload for `codegrapher status`.
type StoreQuerier ¶
type StoreQuerier struct {
// contains filtered or unexported fields
}
StoreQuerier implements GraphQuerier by fanning each operation out across a slice of per-scope stores and merging the results in Go. The data model is one SQLite DB per (language, version) scope; every underlying query func is single-scope, so whole-repo answers come from running each query per store and merging — mirroring mcp.MultiBackend.
For a single store, every method delegates to behavior byte-identical to the previous single-store StoreQuerier.
Tests use mockQuerier instead.
func (*StoreQuerier) Callees ¶
func (q *StoreQuerier) Callees(symbol string) (*CalleesResult, error)
func (*StoreQuerier) Callers ¶
func (q *StoreQuerier) Callers(symbol string) (*CallersResult, error)
func (*StoreQuerier) Files ¶
func (q *StoreQuerier) Files() ([]FileInfo, error)
func (*StoreQuerier) Impact ¶
func (q *StoreQuerier) Impact(symbol string, depth int) (*ImpactResult, error)
func (*StoreQuerier) SearchNodes ¶
func (q *StoreQuerier) SearchNodes(rawQuery string, opts SearchOptions) ([]model.SearchResult, error)
func (*StoreQuerier) Status ¶
func (q *StoreQuerier) Status(projectPath string) (*StatusResult, error)
type SymbolRef ¶
type SymbolRef struct {
Name string `json:"name"`
Kind model.NodeKind `json:"kind"`
FilePath string `json:"filePath"`
StartLine int `json:"startLine"`
}
SymbolRef is the shape used in callers/callees/affected arrays. Matches the `callers`/`callees` array element shape in the golden JSON.