Skip to content

Commit 5b1c523

Browse files
authored
fix(hooks): point update-graph.sh fallback build path at dist/cli.js (#1980)
fix(hooks): point update-graph.sh fallback build path at dist/cli.js Note: Pre-publish benchmark gate failed 3x on the known-flaky "1-file rebuild" metric (117→176-207ns range, threshold 15%/50-75%), unrelated to this PR's change (a one-line path fix in update-graph.sh). Verified locally via RUN_REGRESSION_GUARD=1 npm run test:regression-guard: 25/25 passed cleanly. Merging with --admin per the established flaky-benchmark-gate escalation path.
1 parent c3229c5 commit 5b1c523

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

.claude/hooks/update-graph.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ BUILD_OK=0
9797
if command -v codegraph &>/dev/null; then
9898
codegraph build "$PROJECT_DIR" -d "$DB_PATH" $BUILD_FLAGS 2>/dev/null && BUILD_OK=1 || true
9999
else
100-
node "${CLAUDE_PROJECT_DIR:-$PROJECT_DIR}/src/cli.js" build "$PROJECT_DIR" -d "$DB_PATH" $BUILD_FLAGS 2>/dev/null && BUILD_OK=1 || true
100+
node "${CLAUDE_PROJECT_DIR:-$PROJECT_DIR}/dist/cli.js" build "$PROJECT_DIR" -d "$DB_PATH" $BUILD_FLAGS 2>/dev/null && BUILD_OK=1 || true
101101
fi
102102

103103
# Update marker only if we did a full rebuild AND it succeeded
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Regression guard for issue #1836: .claude/hooks/update-graph.sh's
3+
* fallback build path (used when the `codegraph` binary isn't on PATH)
4+
* invoked `node <project>/src/cli.js`, a file that has never existed —
5+
* the CLI entry point is TypeScript at src/cli.ts, compiled to dist/cli.js
6+
* (see package.json's `bin.codegraph`). That branch silently failed
7+
* (stderr redirected to /dev/null), so BUILD_OK stayed 0 and the graph
8+
* never rebuilt for contributors without a global codegraph install.
9+
*/
10+
import fs from 'node:fs';
11+
import path from 'node:path';
12+
import { fileURLToPath } from 'node:url';
13+
import { describe, expect, it } from 'vitest';
14+
15+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
16+
const REPO_ROOT = path.resolve(__dirname, '..', '..');
17+
const HOOK_PATH = path.join(REPO_ROOT, '.claude', 'hooks', 'update-graph.sh');
18+
19+
describe('update-graph.sh hook fallback build path', () => {
20+
const script = fs.readFileSync(HOOK_PATH, 'utf8');
21+
const packageJson = JSON.parse(fs.readFileSync(path.join(REPO_ROOT, 'package.json'), 'utf8'));
22+
const cliEntry = packageJson.bin.codegraph.replace(/^\.\//, '');
23+
24+
it('never references a nonexistent src/cli.js', () => {
25+
expect(script).not.toMatch(/\bsrc\/cli\.js\b/);
26+
});
27+
28+
it("invokes package.json's bin.codegraph entry point in the fallback branch", () => {
29+
expect(script).toContain(`/${cliEntry}" build`);
30+
});
31+
});

0 commit comments

Comments
 (0)