Skip to content

fix(hooks): point update-graph.sh fallback build path at dist/cli.js#1980

Open
carlos-alm wants to merge 1 commit into
fix/issue-1833-exports-dead-export-analysis-never-countsfrom
fix/issue-1836-update-graph-sh-hook-fallback-build-path
Open

fix(hooks): point update-graph.sh fallback build path at dist/cli.js#1980
carlos-alm wants to merge 1 commit into
fix/issue-1833-exports-dead-export-analysis-never-countsfrom
fix/issue-1836-update-graph-sh-hook-fallback-build-path

Conversation

@carlos-alm

Copy link
Copy Markdown
Contributor

Summary

  • .claude/hooks/update-graph.sh's fallback build path (used when the codegraph binary isn't on PATH) invoked node .../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 (see package.json's bin.codegraph).
  • Because stderr is redirected to /dev/null, the branch failed silently and BUILD_OK stayed 0, so the graph never rebuilt after edits for contributors without a global codegraph install.
  • Fixed by pointing the fallback at dist/cli.js. Added a regression test (tests/unit/hook-fallback-build-path.test.ts) that fails if src/cli.js is ever reintroduced or if the fallback drifts from package.json's bin.codegraph entry.

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 pass
  • npm run lint (via biome check) on the new test file — clean
  • codegraph 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.

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.
@greptile-apps

greptile-apps Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes the update-graph hook fallback path. The main changes are:

  • update-graph.sh now invokes the compiled dist/cli.js entry point.
  • A regression test checks that the hook no longer references src/cli.js.
  • The test ties the fallback path to package.json's bin.codegraph entry.

Confidence Score: 5/5

This looks safe to merge after considering the fallback build-state edge case.

  • The changed path matches the package CLI entry point.
  • The only issue found is limited to checkouts where the compiled dist output is missing when the hook runs.

.claude/hooks/update-graph.sh

Important Files Changed

Filename Overview
.claude/hooks/update-graph.sh Changes the fallback CLI invocation from the nonexistent source JS path to the compiled CLI path.
tests/unit/hook-fallback-build-path.test.ts Adds tests that guard the hook fallback path against drifting away from the package bin entry.

Fix All in Claude Code

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Fallback Requires Built Dist

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.

Fix in Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant