Skip to content

fix(antigravity): migrate stale PreToolUse / PreInvocation hooks in place - #5670

Merged
thedotmack merged 1 commit into
thedotmack:mainfrom
0xABCD01:fix/5665-stale-pretooluse-heal
Nov 10, 2026
Merged

thedotmack merged 1 commit into
thedotmack:mainfrom
0xABCD01:fix/5665-stale-pretooluse-heal

Conversation

@0xABCD01

Copy link
Copy Markdown
Contributor

Part of #5665 (the stale-hook half; the PostInvocation half is covered by #5667, so this PR is scoped to the hook migration only).

Problem

A pre-#5085 install left a PreToolUse entry (and possibly a pre-#4911 PreInvocation → context entry) in ~/.gemini/config/hooks.json. #5085 removed the { decision: 'allow' } response, so the current adapter answers the stale entry with {}, which has no decision field, and agy denies the call. After an in-place upgrade from 14.x to 15.x this denies every tool call. The entries were only cleaned up when the user happened to re-run install --ide antigravity.

Fix

  • findStaleAntigravityHooks detects a non-empty PreToolUse or a PreInvocation handler routing to context on the claude-mem named hook.
  • healStaleAntigravityHooksConfig rewrites hooks.json in place with the same merge install performs (mergeHooksIntoConfig over the canonical config), falling back to deleting just the stale entries when the worker path can't be resolved. It never throws, writes only when a stale entry is present, and leaves a corrupt file untouched.
  • worker-service runs the heal on antigravity-cli hook invocations and on worker startup — the stale entries point at that binary, so the first run after an in-place upgrade repairs the file. The heal is kept out of the lean hook bundle on purpose (src/cli imports no installer modules).

Tests

  • tests/integrations/antigravity-stale-hook-heal.test.ts: stale detection, in-place migration preserving other hooks, idempotence, current file byte-identical, missing/corrupt file handling. 8 tests, all passing.
  • The installer and worker suites pass and root tsc --noEmit is clean (verified on the full two-part branch; this PR is the hook-migration commit only, and its test file passes standalone against main).

Note: the plugin/ bundles are not regenerated in this PR; they rebuild with the release build.

…lace (thedotmack#5665)

An in-place upgrade from a pre-thedotmack#5085 install leaves a PreToolUse entry in
~/.gemini/config/hooks.json. agy keeps firing it before every tool call,
the current adapter answers {} with no decision field, and agy denies
every call until the user re-runs install.

Add findStaleAntigravityHooks + healStaleAntigravityHooksConfig to the
Antigravity installer: when a stale PreToolUse or a PreInvocation ->
context entry is present, the file is migrated in place with the same
merge install performs (surgical strip fallback when the worker path
cannot be resolved). Best-effort: never throws, writes only when stale,
leaves a corrupt file untouched. worker-service runs the heal on
antigravity-cli hook invocations and on worker startup.
@thedotmack
thedotmack merged commit ebe9759 into thedotmack:main Nov 10, 2026
9 checks passed
@thedotmack

Copy link
Copy Markdown
Owner

Merged, thank you @0xABCD01! Antigravity users who upgraded in place from an older install no longer get every tool call denied: the next agy hook run (or worker start) migrates the leftover PreToolUse / PreInvocation → context entries in ~/.gemini/config/hooks.json with the same merge the installer uses, leaves other hooks alone, and never touches a corrupt file. The tests covering migration, idempotence and the corrupt/missing cases made this quick to verify.

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.

2 participants