feat(setup): implement antigravity integration setup and hook adapter…#1730
Conversation
|
@NilotpalK is attempting to deploy a commit to the NexusCore Team on Vercel. A member of the Team first needs to authorize it. |
CI Report✅ All checks passed Pipeline Status
Test Results
✅ All 9847 tests passed 3 test(s) skipped — expand for details
Code CoverageTests
📋 View full run · Generated by CI |
The MCP entry assertion expected `npx` directly, but on Windows `getMcpEntry()` wraps it as `cmd /c npx ...`, which broke the Windows runner. Pin platform to darwin in beforeEach so the existing assertion is deterministic, restore the descriptor in afterEach, and add a parity test for the win32 cmd-wrapper shape.
|
Claude finished @magyargergo's task in 5m 28s —— View job PR #1730 Production-Readiness ReviewReviewer persona: Senior GitNexus maintainer + Expert Antigravity setup engineer + LLM/tooling engineer Todo List
1. Review bar for this PRDoD.md is absent from the repo. The bar used is GUARDRAILS.md + CONTRIBUTING.md:
2. Problem being solvedIssue #79 requests Google Antigravity support in 3. Current PR state
4. Merge status and mergeabilityCI is failing. The PR is NOT mergeable in its current state. From
Commit 5. Repository history considered
6. Branch hygiene assessmentClean. Three topical commits, all files relate to Antigravity setup. No merge-from-main commit. No formatting sweeps or unrelated changes. 7. Understanding of the change
8. FindingsFinding 1: Windows CI still failing after Finding 2: await fs.copyFile(
path.join(pluginHooksPath, 'win-rm-list-json.ps1'),
path.join(destHooksDir, 'win-rm-list-json.ps1'),
);The Antigravity setup ( Finding 3: Finding 4: Finding 5: Finding 6: Summary output includes hooks entries in "MCP configured for:" This conflates "MCP servers configured" with "hooks configured" and is confusing for users. Note: this is a pre-existing issue for Claude Code hooks, not introduced by this PR. Antigravity simply joins the same pool. Finding 7: Finding 8: Installed skills contain Claude-specific guidance Finding 9: README manual Antigravity section does not include hooks.json snippet 9. PR-specific assessment sectionsLane A — MCP setup Lane B — JSON Hooks setup Lane C — Hook adapter correctness Lane D — LLM context quality Lane E — Skills Lane F — Docs Lane G — Cross-platform and packaging Lane H — Existing integrations regression 10. Back-and-forth avoided by verifying
11. Open questions (unavoidable — require Antigravity documentation)
These three questions correspond to Findings 3, 4, and 5 respectively and must be answered with evidence from Antigravity documentation before this PR can merge. 12. Final verdictnot production-ready The PR has correct structural foundations — the adapter logic, index discovery, idempotency guards, worktree support, and corrupt-file safety are all well-implemented. However, five blocking issues prevent merge:
Items 3–5 require Antigravity documentation verification. Item 2 is a concrete code fix. Item 1 requires diagnosing and fixing the Windows test failure. |
…ws CI Rebase the Antigravity integration on the canonical Gemini CLI hooks contract (https://geminicli.com/docs/hooks/reference/), which is the documented schema Antigravity 2.0 inherits: - Hook adapter: replace PreToolUse/PostToolUse with the single AfterTool event. BeforeTool has no documented context-injection channel in the Gemini contract, so augmentation runs in AfterTool where hookSpecificOutput.additionalContext is the documented way to append text to the tool result the agent reads. Stale-index hints land in the same channel (so the agent sees them) and are mirrored to stderr for terminal users. Tool-name matcher updated to Gemini CLI snake_case (search_file_content|glob|run_shell_command). - Setup: write hooks to ~/.gemini/settings.json under canonical hooks.AfterTool[] (replaces the ad-hoc hooks.json top-level group). Polite-neighbor merge preserves existing user hooks. Also copy win-rm-list-json.ps1 alongside hook-db-lock-probe.cjs so the Windows MCP server ownership probe doesn't silently fail open. - Tests: 17 regression tests covering MCP write, win32 shape, hook schema, polite-neighbor merge, idempotency, adapter context emission, stale-index hint, and skill layout. - README: footnote documenting the AfterTool design choice and a link to the Gemini CLI hooks reference. Windows CI fix: installSkillsTo previously used glob('*.md') + glob('*/SKILL.md'), which returned zero matches under the Windows runner's temp paths (8.3 short-name like RUNNER~1). Replace with fs.readdir + dirent type checks — same behavior, no path quirks. This fixes the only failing Windows job on the PR.
|
Claude finished @magyargergo's task in 7m 22s —— View job PR #1730 Production-Readiness Review (Three-Lens)Reviewer persona: Senior GitNexus CLI/MCP reviewer · Senior Gemini CLI hooks reviewer · Senior Antigravity integration reviewer Todo List
Review bar for this PRDoD.md is absent. Bar applied: GUARDRAILS.md + CONTRIBUTING.md.
Problem being solvedIssue #79 requests Google Antigravity editor support in Current PR state
Merge status and mergeabilityCI Gate: failing. However, the root cause is a transient infrastructure failure. From run
The failure log shows Repository history considered
Branch hygiene assessmentMessy, but functionally clean. The branch has 10+ merge-from-main commits. The final diff is exactly 6 expected files — no unrelated churn. CONTRIBUTING.md doesn't mandate a clean linear history, so this is a style issue, not a blocker. A squash before merge is recommended to reduce noise. Understanding of the change
FindingsFinding 1:
Finding 2:
Finding 3: Stale block comment at
Finding 4:
Finding 5:
Finding 6:
Finding 7:
Finding 8:
Finding 9: No bidi/hidden Unicode in changed files
PR-specific assessment sectionsAntigravity setup paths and config schema Gemini/Antigravity hook contract Hook adapter runtime behavior Cross-platform/package install behavior Existing editor regression risk Tests and CI Docs/user-facing claims Branch hygiene Back-and-forth avoided by verifying
Open questions (genuinely unavoidable)
Final verdictnot production-ready Two blockers prevent merge. Finding 1 ( |
|
@NilotpalK Can you please address claude's findings? |
Addresses the production-readiness review findings on PR abhigyanpatwari#1730: - F1 (blocker): add windowsHide:true to all four spawnSync sites in the Antigravity hook adapter (findCanonicalRepoRoot, runGitNexusCli's two branches, buildStaleIndexHint) so they don't flash console windows on Windows. Matches the fix abhigyanpatwari#1794 already on main for the Claude hook. - F2 (blocker): update gitnexus/README.md editor table to say AfterTool and link the Gemini CLI hooks reference. The published README had drifted to the pre-c1872b4 PreToolUse + PostToolUse schema. - F3: rewrite the stale ~/.gemini block comment in setup.ts. It still described the old hooks.json + gitnexus group + grep_search design. - F4: remove grep_search dead code from extractPattern and its doc comment. The registered matcher is search_file_content|glob|run_shell_command, so grep_search would never be invoked. - F5: annotate timeout:10000 with a ms-unit comment noting Gemini CLI uses milliseconds (Claude Code uses seconds). - F6: add the GITNEXUS_DEBUG branch to extractAugmentContext for parity with the Claude adapter, so suppressed augment stderr is recoverable. - F7: stageAdapter test helper now copies win-rm-list-json.ps1 alongside the .cjs helpers, so the adapter's Windows lock-probe path isn't a silent fail-open in child-process smoke tests.
|
btw, could you please add some integration tests to this setup and also update the |
…rm matrix Adds end-to-end coverage on top of the unit-level tests, per maintainer request: - test/integration/setup-antigravity.test.ts (10 tests): exercises the real setupCommand() against a temp HOME with ~/.gemini/antigravity/ present. Verifies mcp_config.json shape, ~/.gemini/settings.json AfterTool entry, adapter + helpers + win-rm-list-json.ps1 copy, baked-in cliPath rewrite (issue abhigyanpatwari#108 regression class), skill layout, polite-neighbor merge against existing user hooks, idempotency, skip-when-absent, corrupt-file safety, and key preservation. - test/integration/antigravity-hook-e2e.test.ts (19 tests): runs the full install-then-execute flow — invokes setupCommand to lay down the adapter + helpers, then spawns the INSTALLED adapter as a real child process against a temp git repo + .gitnexus/. The source adapter cannot be spawned directly (it requires sibling .cjs helpers that only live in hooks/claude/); install-then-spawn mirrors the production codepath. Covers staleness detection across all five git mutation types, --embeddings propagation, polite skip on toolResponse.error / exit_code !== 0, augment crash-free behavior, cwd validation, corrupted/missing meta.json, unknown event names, empty stdin, and the no-.gitnexus deep-nested case. - scripts/cross-platform-tests.ts: registers all three antigravity test files (unit in PLATFORM_LOGIC, two integration files in SPAWN_CLI) so Windows and macOS CI exercise them on every run.
…ercion, glob filter
- Delete mergeGeminiSettingsHooks (verbatim copy of mergeHooksJsonc),
replace call site with the original
- Unify geminiHasGitnexusHook into hasGitnexusHook with commandFragment
parameter; delete the duplicate
- Guard against silent adapter-copy failure: verify the adapter file
exists before registering the AfterTool hook entry in settings.json;
surface helper copy errors instead of swallowing
- Fix toolSucceeded type coercion: use Number() so string exit_code
values from Gemini CLI are handled correctly
- Align glob tool extractPattern with Claude adapter's restrictive
regex filter (/[*\/]([a-zA-Z][a-zA-Z0-9_-]{2,})/)
- Remove bounds-only toBeGreaterThan(0) assertion (DoD §2.7)
- Add antigravity adapter to HOOK_FILES windowsHide regression list
# Conflicts: # gitnexus/scripts/cross-platform-tests.ts
✨ PR AutofixFound fixable formatting / unused-import issues across 26 changed lines. Comment |
|
/autofix |
|
✅ Applied autofix and pushed a commit. (apply run) |
|
Thanks @NilotpalK ! |
…DEBUG The antigravity AfterTool handler mirrored the stale-index hint to stderr unconditionally on a normal (non-error) success path — the last ungated stderr write of the class issue abhigyanpatwari#1913 targets, and a divergence from the claude hook, which never mirrors this hint to stderr. Gate the stderr mirror behind isDebugEnabled(). The hint still reaches the agent via additionalContext (stdout JSON) — parts.push(hint) stays unconditional — so there is no functional loss; only the by-default terminal mirror moves behind GITNEXUS_DEBUG=1. This knowingly changes the abhigyanpatwari#1730 terminal-mirror behavior in favor of strict-runner cleanliness and parity with the claude adapter. Split the e2e assertion into a default-silent test (hint in additionalContext, absent from stderr) and a GITNEXUS_DEBUG=1 test (hint mirrored to stderr). Refs abhigyanpatwari#1913 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…#1913) (#2134) * fix(hooks): silence MCP-owned-DB augment skip for strict hook runners The PreToolUse augment-skip path wrote `[GitNexus] augment skipped: MCP server owns DB` to stderr unconditionally on a normal (non-error) skip. Strict hook runners that validate hook output (e.g. Codex `PreToolUse`) treat that as noisy / "invalid pre-tool-use JSON output". Gate the diagnostic behind GITNEXUS_DEBUG via a shared `isDebugEnabled()` helper, so normal skips are silent by default (empty stdout AND stderr, exit 0) and the reason stays recoverable with `GITNEXUS_DEBUG=1`. Applied consistently to all three hand-maintained hook copies (claude, antigravity, claude-plugin). Tests: - Unit (claude CJS + plugin): assert default-silent and debug-on behavior for the MCP-owned-DB skip and for the fail-closed (lsof ETIMEDOUT) skip that routes through the same gated line; the owner-detection tests run with GITNEXUS_DEBUG=1 so the skip discriminator stays observable. - e2e (antigravity): the antigravity adapter shares the identical gated skip but only runs from its install dir, so cover it through the install pipeline with a faked DB-owner probe (strict empty-stdout/stderr + debug-on). Promote the fake-probe helpers (createHookToolDir / hookEnv, plus a module-private writeExecutable) into shared hook-test-helpers so unit + e2e reuse them. Fixes #1913 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(hooks): unify GITNEXUS_DEBUG gating in main() catch handlers The main() catch-handler in all three hook copies still gated its crash log on truthy `if (process.env.GITNEXUS_DEBUG)`, while the skip diagnostic the #1913 fix added is gated on the strict `isDebugEnabled()` helper (=== '1' || === 'true'). That split meant GITNEXUS_DEBUG=0 or =false suppressed the skip line yet still enabled crash logging — two conflicting contract signals in the same file. Switch the three catch handlers to isDebugEnabled() so GITNEXUS_DEBUG has one strict meaning everywhere: exactly '1' or 'true' enables all diagnostics; everything else (incl. '0', 'false', empty, unset) is silent. Add boundary tests asserting the MCP-owner skip stays silent with GITNEXUS_DEBUG='0' and 'false' (CJS + Plugin), pinning the strict contract. Refs #1913 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(hooks): gate antigravity stale-index hint stderr behind GITNEXUS_DEBUG The antigravity AfterTool handler mirrored the stale-index hint to stderr unconditionally on a normal (non-error) success path — the last ungated stderr write of the class issue #1913 targets, and a divergence from the claude hook, which never mirrors this hint to stderr. Gate the stderr mirror behind isDebugEnabled(). The hint still reaches the agent via additionalContext (stdout JSON) — parts.push(hint) stays unconditional — so there is no functional loss; only the by-default terminal mirror moves behind GITNEXUS_DEBUG=1. This knowingly changes the #1730 terminal-mirror behavior in favor of strict-runner cleanliness and parity with the claude adapter. Split the e2e assertion into a default-silent test (hint in additionalContext, absent from stderr) and a GITNEXUS_DEBUG=1 test (hint mirrored to stderr). Refs #1913 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * docs(hooks): document GITNEXUS_DEBUG=1 for hook diagnostics GITNEXUS_DEBUG was documented only in the cursor integration README, so the diagnostic escape hatch for the Claude Code / Antigravity hooks was undiscoverable. Operators hitting a silent hook skip (MCP server owns the DB, fail-closed probe timeout, or an already-current index) had no documented way to surface the reason. Add a Troubleshooting subsection explaining that the hooks stay silent on normal skip paths for strict runners, that GITNEXUS_DEBUG=1 surfaces the reason on stderr, and that only '1'/'true' enable diagnostics (stdout JSON the agent consumes is unaffected). Refs #1913 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test(hooks): update setup-antigravity unit test for gated stale-index hint U2 (7995e92) gated the antigravity stale-index hint stderr mirror behind GITNEXUS_DEBUG, but a second test — setup-antigravity.test.ts's "AfterTool emits stale-index hint" — also asserted the hint on stderr by default and was missed (it lives outside the two files validated locally; the full CI matrix caught it). Update it to the U2 contract: assert the hint via additionalContext with stderr silent by default, plus a GITNEXUS_DEBUG=1 run asserting the terminal mirror reappears. Refs #1913 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
Adds Antigravity (Google) to the list of editors
gitnexus setupconfigures automatically. Closes the gapraised in #79.
When
~/.gemini/antigravityexists, setup now writes:~/.gemini/antigravity/mcp_config.json(stdio entry, same shape as the Cursor/Claude Codeconfigs).
~/.gemini/config/hooks.jsonunder a top-levelgitnexusgroup, withPreToolUse(
grep_search|run_command) andPostToolUse(run_command) entries per the Antigravity JSON Hooksdocs.
~/.gemini/config/hooks/gitnexus/gitnexus-antigravity-hook.cjs(plushook-lock.cjsandhook-db-lock-probe.cjsreused from the Claude adapter).~/.gemini/antigravity/skills/<name>/SKILL.mdper the Antigravity skillscodelab.
The adapter mirrors the Claude Code hook but respects Antigravity's contract differences:
grep_search,run_command) instead of Pascal-case (Grep,Glob,Bash).PostToolUsestdout must be{}— stale-index hints go to stderr rather than viahookSpecificOutput.additionalContext.PreToolUsesurfaces graph context to the agent via{ decision: "allow", reason: "..." }so the toolstill runs.
Setup is idempotent: re-running detects existing
gitnexushook entries and skips duplicates. Corrupt configfiles are left untouched (same safety policy as the other editor adapters).
Files changed
gitnexus/hooks/antigravity/gitnexus-antigravity-hook.cjs— new adapter.gitnexus/src/cli/setup.ts—setupAntigravity(),installAntigravityHooks(),installAntigravitySkills(),mergeAntigravityHooksJsonc(), wired intosetupCommand.gitnexus/src/cli/index.ts— updatedsetupcommand description.gitnexus/test/unit/setup-antigravity.test.ts— 14 new tests.README.md,gitnexus/README.md— Antigravity row in editor support table + manual MCP snippet.Test plan
cd gitnexus && npx vitest run test/unit/setup-antigravity.test.ts— 14 passing locally.cd gitnexus && npx vitest run test/unit/setup.test.ts test/unit/setup-codex.test.ts test/unit/setup-jsonc.test.ts test/unit/hooks.test.ts test/unit/cursor-hook.test.ts test/unit/setup-antigravity.test.ts— 238 passing locally (no regressions).cd gitnexus && npx tsc --noEmit— clean.gitnexus setupand verifymcp_config.json,hooks.json,hook adapter files, and
skills/directory are all written.gitnexus setupand confirm hook entries are not duplicated.grep_searchfrom Antigravity and confirm graph context surfaces; rungit commitand confirm a stale-index hint appears on stderr after the index drifts.Refs #79