Clean first-run message when the repo isn't codegraph-indexed yet - #21
Merged
Conversation
…boarding) On an unindexed repo, `codegraph query` exits NON-ZERO with "CodeGraph not initialized" on stderr, so execFile threw before parseCodegraphOutput could see the text — a first-time user got the confusing wrapper: codeshot: Command failed: codegraph query ... CodeGraph not initialized ... runCodegraph now catches that non-zero exit, recognizes the message via matchNotInitialized, and prints the exact fix (naming the repo path): codeshot: codegraph has no index for '<path>' yet — build one first with 'codegraph init <path>', then rerun. ... It re-throws any other codegraph failure so a genuine error isn't misreported as a missing index. Sibling of the existing matchSymbolNotFound handling; covers both symbol and --architecture mode via the shared runCodegraph choke point. Deliberately does NOT auto-install codegraph or auto-run 'codegraph init': installing software or building a heavy, persistent index is codegraph's call, not a diagram tool's — the same detect-and-instruct stance as requireOnPath. - render/callgraph.js: matchNotInitialized, argRepoPath, exitNotInitialized; runCodegraph handles the non-zero-exit path - test/run.js: unit tests + a guarded CLI test against a real unindexed tmp repo - USAGE.md: troubleshooting entry - .runechoguardignore: add MAX_CODEGRAPH_BUFFER (const reference misread as a bare call by the guard once the refactor touched its line)
…t initialized' race) Splitting 'codegraph init' and 'codegraph query' across two GitHub Actions steps intermittently failed the diagrams job with 'not initialized': the step boundary kills codegraph's process group before the freshly built on-disk db is finalized, so a later step's fresh query process sees no index (while the same-step status does). Root-caused by reading codegraph's isInitialized() — it checks for a finalized .codegraph/codegraph.db, absent when the build process is killed early. Fix: run init + readiness-probe + --check in one shell step, retrying a real query until the index answers, with CODEGRAPH_NO_WATCHDOG=1 so a throttled runner doesn't trip the liveness watchdog mid-index. Not caused by this branch's code change (master hits the same race; my error-handling change only made the failure message clean instead of a raw 'Command failed').
…"not initialized" The prior commit checked for codegraph's "CodeGraph not initialized" message in parseCodegraphOutput's STDOUT. But codeshot's --architecture enumerate query (`codegraph query -- ''`) returns every indexed node's content — and this file's own source contains that exact phrase in a comment describing the message. So codeshot read its own indexed source back and falsely reported a well-indexed repo as uninitialized. It only surfaced in CI, which indexes the branch's real code; master lacked the phrase, and local runs used a symlinked master index. Fix: match "not initialized" ONLY on stderr with a non-zero exit (runCodegraph's catch) — never on successful stdout. Removed the stdout scan; narrowed the catch to err.stderr. Added a regression test (a JSON response mentioning the phrase must parse, not error). Reverted the CI-hardening commit — it chased a wrong "cross- step race" hypothesis; ci.yml is back to master's version.
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
The sharpest new-user papercut: point codeshot at a repo that codegraph has never indexed, and you got a confusing raw wrapper —
Now codeshot recognizes that state and hands back the exact fix:
This is the sibling of the existing
matchSymbolNotFoundclean-message handling, and it closes the #1 adoption-friction gap vs rivals that parse source directly (madge/pyan/go-callvis need no index).The subtlety (found by running it, not reasoning)
The naive fix — check the message in
parseCodegraphOutput— doesn't work: an unindexed repo makescodegraph queryexit non-zero, soexecFilethrows before any stdout is parsed. The clean message has to be caught at the throw path inrunCodegraph, which recognizes the not-initialized text (matchNotInitialized) and re-throws anything else so a genuine codegraph failure isn't misreported as a missing index. Covers both symbol and--architecturemode via the shared choke point.Explicitly not doing
No auto-install of codegraph, no auto-
codegraph init. Installing software / building a heavy persistent index is codegraph's call, not a diagram tool's — same detect-and-instruct stance as the existingrequireOnPath. (An opt-in--initflag is a possible future candidate, never implicit.)Verified
matchNotInitialized/argRepoPath, plus a guarded CLI test that runs the real binary against a fresh unindexed tmp dir and asserts the clean message (not the raw error).