Skip to content

fix(hooks): prefer PATH gitnexus in stale hint#1958

Open
sainiranjannallam wants to merge 2 commits into
abhigyanpatwari:mainfrom
sainiranjannallam:fix/hook-path-analyze-command
Open

fix(hooks): prefer PATH gitnexus in stale hint#1958
sainiranjannallam wants to merge 2 commits into
abhigyanpatwari:mainfrom
sainiranjannallam:fix/hook-path-analyze-command

Conversation

@sainiranjannallam
Copy link
Copy Markdown

Fixes #1938.

Summary

  • Prefer gitnexus analyze in stale-index hints when a spawnable gitnexus launcher is on PATH, including Windows launcher suffixes.
  • Preserve the existing npx gitnexus analyze fallback when no PATH launcher exists.
  • Apply the behavior to the Claude hook, Claude plugin hook, and Antigravity hook adapter.

Validation

  • npx vitest run test/integration/hooks-e2e.test.ts test/integration/antigravity-hook-e2e.test.ts
  • npx tsc --noEmit
  • npx --yes gitnexus detect-changes

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 1, 2026

@sainiranjannallam is attempting to deploy a commit to the NexusCore Team on Vercel.

A member of the Team first needs to authorize it.

@sainiranjannallam sainiranjannallam marked this pull request as ready for review June 1, 2026 06:13
Copy link
Copy Markdown
Collaborator

@magyargergo magyargergo left a comment

Choose a reason for hiding this comment

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

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 which failures (#1938); Unix adds X_OK.
  • Tests scrub ambient PATH (pathWithoutGitNexus) and add a synthetic launcher case — fixes flake when gitnexus is 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

  1. P2.ps1-only installs treated as on-PATH (all three hook copies).
  2. 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, and gitnexus-claude-plugin/hooks/gitnexus-hook.js — extract shared helper (same pattern as hook-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() uses existsSync while hooks require isFile() + 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 analyze before 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; statSync is wrapped in try/catch per candidate. Not reproduced; not a merge blocker.

CI / visibility

  • gh pr checks shows 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 --check and bidi control scan: clean.

Automated multi-tool digest (pr-tri-review). Verify findings before acting.

'.cmd',
'.bat',
'.exe',
'.ps1',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

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.

Follow-up to #1660: PostToolUse hook still hardcodes npx gitnexus in 1.6.5 — proposed fix never shipped

2 participants