feat(codegraph): per-workspace CodeGraph indexing for agent sessions #47
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/codegraph"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds CodeGraph (
@colbymchenry/codegraph) support so theclaudeagent inside worker sessions gets thecodegraph_exploreMCP tool, backed by a pre-built code-knowledge-graph (tree-sitter → SQLite). The agent can query call paths / impact instead of grep/read loops. Agent-tool only — no operator-facing UI beyond an opt-out toggle.Architecture: build the graph once at workspace creation (synchronous, post-clone in the entrypoint), then copy the seed
.codegraph/into each new worktree atcreateSession. Each session's owncodegraph serve --mcpwatcher then tracks its branch; its startup reconciliation re-parses only drifted files, so a copy that lags/workspace's HEAD self-corrects on session launch. Per-workspace opt-out, default on.Changes
worker/Dockerfile— bake@colbymchenry/codegraphinto the base image.worker/entrypoint.sh— gated, idempotent CodeGraph block: exclude.codegraph/via common-dirinfo/exclude, register the stdio MCP server in the per-worker~/.claude.json(same seam as forgejo-mcp), andcodegraph init /workspaceonce (guarded by[ ! -d .codegraph ]). Placed beforetmux new-sessionso the seed is ready before any session exists. Covered byworker/codegraph-entrypoint.test.sh.createSession(sessions/service.ts) — copy the seed into each new worktree (clearing the staledaemon.pid/daemon.sockthatcp -rdrags along), best-effort with debug logging.sessions/codegraph.ts— pure helpersbuildCodegraphSeedCommand+codegraphEnvEntry(unit-tested).workers.codegraph_enabled(INTEGER NOT NULL DEFAULT 1).spawnWorker— persist the column, injectCODEGRAPH_ENABLEDenv, expose inWorkerDTO.NewWorker.svelte— "Index codebase with CodeGraph" checkbox (default on) threads the flag end-to-end.AGENTS.md— new fact #19 +CODEGRAPH_ENABLEDenv-var row.DB-copy safety (relative paths, daemon keyed by absolute root, startup reconciliation) was confirmed against codegraph source; rationale is captured in
docs/superpowers/specs/2026-06-26-codegraph-support-design.md.Test Plan
pnpm test— 565/565 pass (incl. migration 0013 + codegraph helper tests)pnpm exec tsc --noEmit— cleanpnpm exec svelte-check --threshold error— 0 errorssh worker/codegraph-entrypoint.test.sh— 3/3 cases (enabled+fresh, disabled, enabled+already-indexed) + no regression in other worker shell testsdocker build --target base worker/builds andcodegraph --versionruns in the imagecodegraph init /workspace,cp -rinto a worktree, clear daemon lock, confirmcodegraph statusreports a populated index resolving correctly (validates relative-path portability live)https://claude.ai/code/session_01DPMvaAf6Ay8ZtLpCRyCe8F
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.