fix(hooks): prefer PATH gitnexus in stale hint#1958
Conversation
|
@sainiranjannallam is attempting to deploy a commit to the NexusCore Team on Vercel. A member of the Team first needs to authorize it. |
magyargergo
left a comment
There was a problem hiding this comment.
Summary
Reviewed with 7 lanes across 2 engines: GitNexus risk + test/CI, Compound Engineering (correctness, adversarial, maintainability, testing), and Codex (independent). Claude lanes share one engine; strong corroboration requires Codex + Claude agreement — here, Codex and multiple Claude lanes agree on Windows launcher policy drift.
Headline: This is a solid fix for #1938 — stale-index hints now prefer gitnexus analyze when a launcher is on PATH, with good e2e coverage and PATH isolation for the npx fallback. Before merge, align Windows launcher detection with the existing setup.ts policy (.cmd/.bat wrappers, not .ps1-only shims) and dedupe the plugin hook’s two PATH probes.
What looks good
- Pure-Node PATH scan avoids Windows
whichfailures (#1938); Unix addsX_OK. - Tests scrub ambient PATH (
pathWithoutGitNexus) and add a synthetic launcher case — fixes flake whengitnexusis on the runner PATH. - Covers CJS, plugin, and antigravity hook surfaces.
- Coordinator ran
npx vitest run test/integration/hooks-e2e.test.ts test/integration/antigravity-hook-e2e.test.ts -t "gitnexus analyze"→ 3/3 passed in the PR worktree.
Inline findings
- P2 —
.ps1-only installs treated as on-PATH (all three hook copies). - P2 — Plugin hook uses two different PATH probes for hint vs CLI spawn.
Lower priority / follow-ups
- P3: ~42 lines duplicated across
gitnexus/hooks/claude/gitnexus-hook.cjs,gitnexus/hooks/antigravity/gitnexus-antigravity-hook.cjs, andgitnexus-claude-plugin/hooks/gitnexus-hook.js— extract shared helper (same pattern ashook-lock.cjs). - P2 test gap: No e2e for PATH-on and
stats.embeddings > 0→ expect`gitnexus analyze --embeddings`(hooks-e2e.test.ts~96–129,antigravity-hook-e2e.test.ts~132–161). - P3:
pathWithoutGitNexus()usesexistsSyncwhile hooks requireisFile()+X_OK(hook-test-helpers.ts:48–57).
Refuted / not blocking
- GITNEXUS_HOOK_CLI_PATH hint mismatch: Pre-existing — stale hint was always
npx gitnexus analyzebefore this PR;resolveCliPath()already handled augment separately (gitnexus/hooks/claude/gitnexus-hook.cjs:194–208). Optional follow-up, not a regression. - UNC PATH hang: Theoretical enterprise edge case;
statSyncis wrapped in try/catch per candidate. Not reproduced; not a merge blocker.
CI / visibility
gh pr checksshows only Vercel FAILURE (authorization required — unrelated to hooks).- GitHub Actions status was not visible via the Checks API for this fork PR; treat CI green as unconfirmed from API evidence.
Hygiene
- Branch:
fix/hook-path-analyze-command— one feature commit + merge-from-main (harmless). git diff --checkand bidi control scan: clean.
Automated multi-tool digest (pr-tri-review). Verify findings before acting.
| '.cmd', | ||
| '.bat', | ||
| '.exe', | ||
| '.ps1', |
There was a problem hiding this comment.
P2 [code-read] — .ps1 is treated as a positive PATH hit, but setup.ts resolveGitnexusBin() explicitly rejects .ps1-only installs and falls back to npx (setup.test.ts:302). On Windows npm-11 layouts with only gitnexus.ps1, this hint says `gitnexus analyze` while MCP setup still uses npx.
Fix: On win32, accept .cmd|.bat|.exe only (mirror setup.ts:69); drop .ps1 from positive detection. Same block is copy-pasted at gitnexus-antigravity-hook.cjs:222 and gitnexus-claude-plugin/hooks/gitnexus-hook.js:200.
| return false; | ||
| } | ||
|
|
||
| function buildAnalyzeCommand(hadEmbeddings) { |
There was a problem hiding this comment.
P2 [code-read] — This file now has two PATH strategies: buildAnalyzeCommand uses the new fs PATH walk (L188–227), while runGitNexusCli still uses where/which + hardcoded gitnexus.cmd (L250–271). They can disagree on edge cases (PATHEXT, non-spawnable shims).
Fix: Share one launcher-resolution helper for both the stale hint and CLI spawn paths.
Fixes #1938.
Summary
gitnexus analyzein stale-index hints when a spawnablegitnexuslauncher is onPATH, including Windows launcher suffixes.npx gitnexus analyzefallback when noPATHlauncher exists.Validation
npx vitest run test/integration/hooks-e2e.test.ts test/integration/antigravity-hook-e2e.test.tsnpx tsc --noEmitnpx --yes gitnexus detect-changes