fix(codegraph): index-db check + safe Gemini fileName cleanup (Tier-3, stacked on #1)#2
Merged
itsarvinddev merged 2 commits intoJun 7, 2026
Conversation
…gitignore .codegraph/ Three fixes grounded in a real first-run setup, where the codegraph_* MCP tools silently failed to load after following the policy verbatim: 1. Recommend `codegraph install -y` everywhere (codegraph-policy.md + codegraph-session-check.sh). A bare `codegraph install` opens an interactive agent-picker prompt that has no TTY in an agent context and hangs session startup. 2. Add a post-restart verification step to the policy + hook message. The CLI installer links the binary into ~/.local/bin, which is often not on the PATH a GUI-launched agent inherits, so the MCP server registered as the bare command "codegraph" fails to spawn silently. Guidance: verify the tools loaded, and if not, add ~/.local/bin to PATH or re-register the MCP entry's command with the absolute binary path. 3. Auto-gitignore .codegraph/ on project installs (mirrors the existing primer_gitignore). `codegraph init -i` writes a per-machine index that must not be committed on a team-shared project install. Regenerated agent-primer.sh via make-portable.sh; added a smoke assertion. All 62 smoke checks pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ngling Gemini fileName refs Tier-3 polish, follow-up to the non-interactive/PATH/gitignore fixes. 1. codegraph-session-check.sh: treat a project as initialized only when .codegraph/ actually contains an index db (*.db), not merely the dir. An aborted/half-finished `codegraph init` leaves a bare .codegraph/ dir that previously made once-mode go silent on a broken index. The check stays a pure filesystem test (no per-session `codegraph status`), preserving once-mode's fast no-op; deep corruption stays status/--always's job. This aligns the hook with the policy's 'indexed = .codegraph/ exists AND status succeeds'. 2. uninstall.sh: reverse install's Gemini context.fileName additions, but ONLY for entries whose instruction file no longer exists after uninstall (a dangling reference). A GEMINI.md/AGENTS.md the user still has is left referenced, so config they rely on is never removed. (Previously uninstall left every fileName entry.) AGENTS.md is pruned in project scope only; globally that entry means 'read each project's AGENTS.md', which the global install does not own. Regenerated agent-primer.sh; added smoke coverage (half-built index nudges; dangling refs pruned; a surviving file's ref kept). 69 smoke checks pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Tier-3 polish, the follow-up to #1. Two small, well-tested hardening fixes.
1. Hook treats a bare
.codegraph/dir as "set up" → check for the index dbcodegraph-session-check.shdecided a project was indexed purely from.codegraph/existing. Butcodegraph init -ican leave a bare.codegraph/dir if it's interrupted (and the policy itself defines indexed as ".codegraph/ exists andcodegraph statussucceeds"). On that half-built state the default once-mode goes silent on a broken index.Fix:
index_initialized()now requires.codegraph/and at least one*.dbinside it. Deliberately a filesystem check, notcodegraph status— running status every session is exactly the cost once-mode removes; deep corruption staysstatus/--always's job. Closes the policy/hook gap cheaply.2. Uninstall leaves dangling Gemini
context.fileNameentries → prune them safelyInstall adds
AGENTS.md/GEMINI.mdto Gemini'scontext.fileName; uninstall left them all (the code comment called it "harmless, user may rely on it"). The safe middle ground: prune an entry only when its instruction file no longer exists after uninstall (a dangling reference). AGEMINI.md/AGENTS.mdthe user still has is left referenced — so we never remove config they rely on, which was the original concern.AGENTS.mdis pruned in project scope only; globally that entry means "read each project's AGENTS.md", which the global install doesn't own.This intentionally changes a previously-deliberate behavior — if you'd rather keep "leave everything", drop commit 2 and I'll happily land #1's spirit only.
Testing
agent-primer.shviamake-portable.sh(bundle-drift check green).tests/smoke.sh: 69 passed, 0 failed. New coverage: half-built.codegraph/(no db) nudges init; danglingGEMINI.md/AGENTS.mdpruned on uninstall; a surviving file's ref is kept (the safety guarantee).🤖 Generated with Claude Code