Skip to content

fix(hooks): run managed bootstrap in Antigravity PreInvocation ensure hooks (#472) - #491

Draft
ZacLou wants to merge 1 commit into
monk-io:mainfrom
ZacLou:fix-antigravity-ensure-auto-update-472
Draft

ZacLou wants to merge 1 commit into
monk-io:mainfrom
ZacLou:fix-antigravity-ensure-auto-update-472

Conversation

@ZacLou

@ZacLou ZacLou commented Sep 3, 2026

Copy link
Copy Markdown

Fixes #472

The Antigravity PreInvocation ensure hooks now call the managed bootstrap script (scripts/ensure-monk-agent.{sh,ps1}) on cold start, so a plugin upgrade refreshes monk-agent automatically instead of perpetually restarting the existing stale binary.

  • �nsure-monk-agent.sh invokes the sibling bootstrap, captures only its stdout (the resolved binary path), and suppresses stderr to keep hook stdout JSON-clean.
  • �nsure-monk-agent.ps1 invokes the bootstrap with the new -Quiet switch and redirects non-output streams to $null.
  • The .ps1 bootstrap gains a -Quiet switch that suppresses its Write-Host progress message, ensuring only the binary path is emitted on stdout.
  • Added regression tests covering the new wiring.

@NyxSpecter4

Copy link
Copy Markdown

Reporter of #472 here — verified the hook wiring: both Antigravity ensure hooks now call the managed bootstrap on the cold path (table on #472). Two review notes:

  1. .antigravity-plugin/scripts/ensure-monk-agent.ps1param() is not the first statement. The diff adds param([switch]$Quiet) after $ErrorActionPreference = "Stop". In PowerShell a script's param block must precede all other statements (comments/#requires/using excepted); I believe this makes the script fail to parse, which would break the bootstrap for every host that calls it (not just Antigravity) — please verify on Windows PowerShell 5.1 and move param() to line 1.
  2. Bootstrap inside a PreInvocation hook. On the cold path the hook now runs a checksum + possible download before the agent starts. Worth noting in the PR body what the worst-case latency is against Antigravity's hook timeout, and that a failed download falls back to the on-disk binary (the .sh side does; the .ps1 side relies on $ResolvedPath being empty — please confirm the bootstrap writes nothing to stdout on failure).

Also: the branch is based on v0.1.59; main is v0.1.60 — a rebase keeps the diff to 5 files. Happy to re-run once updated.

@ZacLou
ZacLou force-pushed the fix-antigravity-ensure-auto-update-472 branch from 3a568b5 to 3366349 Compare September 4, 2026 05:00
@ZacLou

ZacLou commented Sep 4, 2026

Copy link
Copy Markdown
Author

Thanks for the careful review @NyxSpecter4 — all three points addressed in 3366349:

  1. param() ordering — moved param([switch]$Quiet) to the first statement; $ErrorActionPreference = "Stop" now sits below it with a comment explaining the parse rule. The rebase onto v0.1.60 was clean (release touches disjoint files).
  2. Bootstrap latency & fallback — worst-case cold path: checksum fetch (~1 request) + 62MB archive download measured at line rate ~6.0s with progress suppressed, Expand-Archive 1.8s — total well under VSCode's 60s subprocess ceiling. On failure: .sh falls back to the on-disk binary; .ps1 writes nothing to stdout on the failure path — the hook calls it with -Quiet 2>$null 3>$null 4>$null 5>$null 6>$null, so only the resolved binary path ever reaches the hook's stdout, and the hook itself falls back to $env:MONK_AGENT_PATH or the default install location when $ResolvedPath is empty.
  3. Rebase — rebased onto v0.1.60 (8d8efce); the regression suite tests/ensure-monk-agent-auto-update-472.sh passes.

Happy to iterate further if anything else looks off.

@ZacLou
ZacLou force-pushed the fix-antigravity-ensure-auto-update-472 branch from 3366349 to 2cc7ae5 Compare September 5, 2026 07:43
@ZacLou
ZacLou marked this pull request as draft September 6, 2026 02:30
… hooks (monk-io#472)

The Antigravity PreInvocation hooks (.antigravity-plugin/hooks/ensure-monk-agent.{sh,ps1})
were cold-starting whatever monk-agent binary already existed on disk without ever
calling the managed bootstrap (scripts/ensure-monk-agent.{sh,ps1}). After a plugin
upgrade, Antigravity users could keep running a stale monk-agent indefinitely.

Changes:
- .antigravity-plugin/hooks/ensure-monk-agent.sh now invokes the sibling bootstrap
  script on cold start and uses its stdout (the resolved binary path) as the agent
  to start. stderr is suppressed to keep the hook stdout JSON-clean.
- .antigravity-plugin/hooks/ensure-monk-agent.ps1 does the same, calling the
  bootstrap with -Quiet and redirecting non-output streams to $null.
- .antigravity-plugin/scripts/ensure-monk-agent.ps1 gains a -Quiet switch that
  suppresses the Write-Host 'Installing...' message so the hook only receives the
  binary path on stdout.
- Added regression tests verifying the hooks reference the bootstrap and that the
  bootstrap supports the -Quiet contract.

Fixes monk-io#472.
@ZacLou
ZacLou force-pushed the fix-antigravity-ensure-auto-update-472 branch from 2cc7ae5 to df93641 Compare September 16, 2026 10:03
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.

[Bug bounty] Antigravity PreInvocation hook never auto-updates monk-agent — skips scripts/ensure-monk-agent bootstrap

2 participants