Documentation
¶
Overview ¶
Package codegraph integrates the CodeGraph code-intelligence engine (https://github.com/colbymchenry/codegraph) as a built-in MCP server. CodeGraph indexes a project into a local symbol and call graph (tree-sitter + SQLite, FTS5) and serves it over stdio MCP, giving the agent symbol search, caller / callee, and change-impact tools without the per-language setup an LSP fleet would need.
OK ships the CodeGraph bundle alongside its own executable, so Resolve finds it next to the binary; an explicit config path and a system-installed `codegraph` on PATH are honored as an override / fallback. boot injects the resolved launcher as one more stdio plugin, pinned to the project root via plugin.Spec.Dir (CodeGraph detects the project from its working directory).
Index ¶
Constants ¶
const BundleDirName = "codegraph"
BundleDirName is the directory, beside the ok executable, that the release archive unpacks the CodeGraph bundle into. Its launcher lives at <BundleDirName>/bin/codegraph, with the bundled node runtime and lib/ beside it; the launcher resolves those relative to itself, so the bundle is relocatable.
Variables ¶
This section is empty.
Functions ¶
func EnsureInit ¶
EnsureInit initializes CodeGraph for root when it has not been already, by running a bare `codegraph init` (no -i). That only creates the .codegraph/ structure — fast and independent of repo size (~100ms) — because the actual indexing is done by `serve --mcp`'s daemon in the background once connected: the MCP handshake returns in a few hundred ms and symbols fill in shortly after, with CodeGraph flagging partial results as stale meanwhile. So startup never blocks on indexing, even for a huge monorepo.
An existing .codegraph/ is left untouched — serve re-syncs it on connect and the file-watcher keeps it fresh thereafter. The init step is required because serve does NOT auto-create .codegraph/: without it, it runs in a degraded, no-index mode rather than building one.
func Resolve ¶
Resolve returns the absolute path to the CodeGraph launcher. Search order:
- override — an explicit codegraph.path from config (~ and ${VAR} expanded);
- the bundle shipped beside the ok executable (the distribution case);
- a system-installed `codegraph` on PATH.
ok is false when none resolves, in which case the caller skips the feature silently — a missing bundle just means the codegraph_* tools are unavailable.
Types ¶
type Index ¶
type SymbolKind ¶
type SymbolKind int
const ( SymbolFunction SymbolKind = iota SymbolMethod SymbolStruct SymbolInterface SymbolClass SymbolImport SymbolVariable SymbolType SymbolEnum SymbolTrait )