fix(hooks): point update-graph.sh fallback build path at dist/cli.js#1980
Open
carlos-alm wants to merge 1 commit into
Conversation
The PostToolUse hook's fallback branch (used when the codegraph binary isn't on PATH) invoked node against src/cli.js, a file that has never existed in this repo. The CLI entry point is TypeScript at src/cli.ts, compiled to dist/cli.js per package.json's bin.codegraph. Since stderr is redirected to /dev/null, the branch failed silently and the graph never rebuilt for contributors without a global codegraph install. Add a regression test asserting the hook never references src/cli.js and does invoke package.json's bin.codegraph entry point.
Contributor
Greptile SummaryThis PR fixes the update-graph hook fallback path. The main changes are:
Confidence Score: 5/5This looks safe to merge after considering the fallback build-state edge case.
.claude/hooks/update-graph.sh Important Files Changed
Reviews (1): Last reviewed commit: "fix(hooks): point update-graph.sh fallba..." | Re-trigger Greptile |
| codegraph build "$PROJECT_DIR" -d "$DB_PATH" $BUILD_FLAGS 2>/dev/null && BUILD_OK=1 || true | ||
| else | ||
| node "${CLAUDE_PROJECT_DIR:-$PROJECT_DIR}/src/cli.js" build "$PROJECT_DIR" -d "$DB_PATH" $BUILD_FLAGS 2>/dev/null && BUILD_OK=1 || true | ||
| node "${CLAUDE_PROJECT_DIR:-$PROJECT_DIR}/dist/cli.js" build "$PROJECT_DIR" -d "$DB_PATH" $BUILD_FLAGS 2>/dev/null && BUILD_OK=1 || true |
Contributor
There was a problem hiding this comment.
When this hook runs in a checkout where codegraph is not on PATH and dist/cli.js has not been built yet, the fallback still exits through the silent failure path because dist/ is ignored and only created after the build step. That leaves BUILD_OK at 0, so the graph rebuild is skipped without any visible error.
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.
Summary
.claude/hooks/update-graph.sh's fallback build path (used when thecodegraphbinary isn't onPATH) invokednode .../src/cli.js, a file that has never existed in this repo — the CLI entry point is TypeScript atsrc/cli.ts, compiled todist/cli.js(seepackage.json'sbin.codegraph)./dev/null, the branch failed silently andBUILD_OKstayed0, so the graph never rebuilt after edits for contributors without a globalcodegraphinstall.dist/cli.js. Added a regression test (tests/unit/hook-fallback-build-path.test.ts) that fails ifsrc/cli.jsis ever reintroduced or if the fallback drifts frompackage.json'sbin.codegraphentry.Filed #1979 for an out-of-scope finding: the identical broken-fallback-path bug also exists in
.claude/hooks/post-git-ops.sh.Closes #1836
Test plan
npx vitest run tests/unit/hook-fallback-build-path.test.ts tests/unit/hook-extensions.test.ts— both passnpm run lint(viabiome check) on the new test file — cleancodegraph diff-impact --staged -T— no function-level impact (shell script + test file only)Stacked on #1833 (base branch
fix/issue-1833-exports-dead-export-analysis-never-counts) — only this issue's hook fix is in the diff.