index

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractDefinitions

func ExtractDefinitions(project string, f SourceFile) ([]graph.Node, []graph.Edge)

ExtractDefinitions reads a file from disk and extracts its definitions.

func IsTestFile

func IsTestFile(p string) bool

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

func ProjectName(root string) string

ProjectName derives a stable project key from the repo root (matches the upstream convention of slugging the absolute path).

func ResolveCalls

func ResolveCalls(project, root string, files []SourceFile, nodes []graph.Node, changed map[string]bool) []graph.Edge

ResolveCalls emits CALLS edges. For TS/JS it delegates to scip-typescript (batch, type-checker-accurate) per tsconfig subproject and attributes each resolved reference to the function/method that encloses it (the caller). It is best-effort: a subproject whose scip run fails contributes no edges rather than failing the whole index. Go call resolution is in-process via go/packages + a CHA call graph (internal/gocalls). changed gates which CALLS scopes are re-resolved: nil re-resolves everything (a full index); otherwise only scopes present in the set run (each tsconfig dir, and "go"). Unchanged scopes' edges are reused by the caller, not recomputed here.

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.

func ResolveSimilar

func ResolveSimilar(project, root string, nodes []graph.Node) []graph.Edge

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.

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

func DetectChanges(store *graph.Store, project, root string) (Changes, error)

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.

func (Changes) Any

func (c Changes) Any() bool

Any reports whether anything changed since the last index.

func (Changes) Summary

func (c Changes) Summary() string

Summary renders the change set as the compact wire format the detect_changes tool returns: one `status<TAB>path` line per file (changed, then added, then deleted).

type Lang

type Lang string

Lang is a detected source language for a file.

const (
	LangGo  Lang = "go"
	LangTS  Lang = "ts"
	LangTSX Lang = "tsx"
	LangJS  Lang = "js"
)

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
}

Result summarizes an indexing run.

func Run

func Run(store *graph.Store, root string) (Result, error)

Run indexes root into store under a derived project name. The definitions pass runs in parallel across files (one of the cheap wins of the RAM-first design); imports + call resolution (CALLS edges) follow via ResolveImports/ResolveCalls.

type SourceFile

type SourceFile struct {
	AbsPath string
	RelPath string
	Lang    Lang
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL