Documentation
¶
Index ¶
- Constants
- func ExtractDefinitions(project string, f SourceFile) ([]graph.Node, []graph.Edge)
- func IsTestFile(p string) bool
- func ProjectName(root string) string
- func ResolveImports(project string, files []SourceFile) []graph.Edge
- func ResolveSimilar(project, root string, nodes []graph.Node) []graph.Edge
- type Changes
- type Lang
- type Result
- type ScipReport
- type SourceFile
Constants ¶
const BuildingSuffix = ".building"
BuildingSuffix is the suffix RunAtomic uses for in-progress index files.
Variables ¶
This section is empty.
Functions ¶
func ExtractDefinitions ¶
ExtractDefinitions reads a file from disk and extracts its definitions.
func IsTestFile ¶
IsTestFile reports whether a repo-relative path is a test file, by the naming conventions of the supported stacks (Go `_test.go`, JS/TS `.test.`/`.spec.`, and `__tests__` dirs). Exported so the query layer can exclude test functions from the dead-code hint — they're invoked by the test runner, not by code.
func ProjectName ¶
ProjectName derives a stable project key from the repo root (matches the upstream convention of slugging the absolute path).
func ResolveImports ¶
func ResolveImports(project string, files []SourceFile) []graph.Edge
ResolveImports reads the files and emits IMPORTS edges. It is the disk-reading wrapper around resolveImports. Prefer resolveImportsStreaming during indexing — it holds one file at a time instead of the whole codebase.
func ResolveSimilar ¶
ResolveSimilar emits SIMILAR_TO edges between near-clone functions/methods. It reads each file once, tokenizes every function body, and runs the MinHash + LSH pass (internal/similar). Cross-file by nature, so it always runs on the full node set. Prefer resolveSimilarFromSpans during indexing — reuses CALLS spans and keeps only MinHash signatures in RAM, not tokenized bodies for every function.
Types ¶
type Changes ¶
type Changes struct {
Changed []string // indexed, but content hash differs now
Added []string // on disk, absent from the index
Deleted []string // in the index, gone from disk
}
Changes is the set of files that differ from the indexed snapshot.
func DetectChanges ¶
DetectChanges compares the source files currently under root against the per-file content hashes recorded at the last index (Store.FileHashes). It is the basis for skipping a re-index when nothing changed, and later for re-resolving only the scopes whose files moved. A never-indexed project reports every file as Added.
type Result ¶
type Result struct {
Project string
Files int
Nodes int
EdgesKept int
EdgesDropped int
Reused bool // nothing changed since the last index; the pipeline was skipped
ScipScopes int
ScipPeakRSS uint64
ScipHeapCapMB int
}
Result summarizes an indexing run.
func Run ¶
Run indexes root into an already-open store (tests/temp dirs). Prefer RunAtomic for CLI/MCP so a failed re-index does not wipe the previous graph.
func RunAtomic ¶ added in v0.2.0
RunAtomic builds into dbPath+BuildingSuffix and renames on success, leaving the previous graph at dbPath intact when indexing fails. Do not run `codegraph index` on the same repo while an MCP server is auto-indexing it — both use this path and can race on the store file.
type ScipReport ¶ added in v0.2.0
ScipReport summarizes scip-typescript resource use across all TS scopes in one index run. PeakRSS is the max child RSS observed (Linux/WSL); zero elsewhere.
type SourceFile ¶
SourceFile is a discovered file worth indexing.
func Discover ¶
func Discover(root string) ([]SourceFile, error)
Discover walks root and returns indexable source files. It honors directory hard-ignores plus the repo's .gitignore and .cbmignore — so a repo's vendored deps and build artifacts (e.g. a Go module cache under tmp/) don't flood the graph. Common-case ignore semantics only: directory/name patterns, globs, and root-anchored paths; negation (`!`) and nested .gitignore files are not honored.