Repository navigation
Conversation
Zed's Antigravity ACP host runs hook commands with shlex.split +
create_subprocess_exec, so argv[0] must be a real executable. The
installed command starts with the shell builtin `if`, so the spawn
fails with ENOENT and ACP reads a hook that never started as a deny
on every tool call.
Wrap the existing snippet in `/bin/sh -c` instead of rewriting it to
the `env ... /bin/sh <script>` form suggested on the issue: that form
is spawnable but drops the `if [ -f/-r/-x ]` guard and with it the
`{"decision":"ask"}` fallback from stablyai#2426, trading one deny-everything
bug for another.
wrapPosixHookCommand itself is unchanged, so the other POSIX hosts
keep their current output byte-for-byte.
Fixes stablyai#16087
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe change adds and re-exports Merge Risk: ⚪ Minimal · up to This localized change makes Antigravity POSIX hook commands directly spawnable while preserving existing guarded behavior, including the missing-script fallback. No actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/agent-hooks/posix-hook-exec-command.test-fixture.ts (1)
1-4: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueShorten the fixture comments.
Keep each comment to one concise statement of the non-obvious test constraint.
As per coding guidelines, comments must be concise, non-obvious, and brief; prefer one line.
Proposed simplification
-// Why: Zed's Antigravity ACP host runs hook commands with `shlex.split` + `create_subprocess_exec`, -// so the installed string is tokenized and then exec'd directly — no shell. This mirrors that -// tokenizer (POSIX mode: no expansion inside single quotes, backslash escapes outside them) so tests -// can exercise the exec path instead of the `/bin/sh -c` path they would otherwise take. +// Emulate ACP POSIX tokenization for direct-exec tests. ... -// Why: POSIX Antigravity commands are handed to `/bin/sh -c` so they stay exec-spawnable (`#16087`); -// assertions about the shell snippet itself read the payload back out instead of matching its escaping. +// Extract the shell payload from an exec-wrapped hook command.Also applies to: 47-48
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 3f917567-140c-425c-b2b6-daf947ed7a12
📒 Files selected for processing (6)
src/main/agent-hooks/installer-utils.tssrc/main/agent-hooks/posix-hook-command.tssrc/main/agent-hooks/posix-hook-exec-command.test-fixture.tssrc/main/agent-hooks/remote-hook-service-installers.test.tssrc/main/antigravity/hook-service.test.tssrc/main/antigravity/hook-service.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
A fixture that silently accepts an unbalanced quote or a dangling backslash would let a broken quoting change pass as green. Real shlex raises on both, so this one does too, with regression cases for each. Also shortens the fixture comments per the repo's guideline.
|
Good catch on the malformed-input case — taken in You're right that it matters here rather than being hypothetical: the fixture exists to prove the wrapper's quoting survives tokenization, so a version that silently guesses at an unbalanced quote would let a broken escaping change pass as green. That is the exact failure mode this PR already guards against elsewhere — one of the pre-existing assertions I had to unwrap was a
Also shortened the fixture comments per the guideline. |
|
Validated end to end at Environment:
Method:
So the PR closes the end-to-end gap for both the normal and stale-entry/missing-script cases on macOS + Zed ACP. I restored my original config and test files afterward. |
|
@jrignacio Thank you — this closes the one gap I flagged in the PR description ("I do not have a Zed + Antigravity ACP setup"), and it closes it more thoroughly than I could have. Two things about your method are worth calling out for anyone reading this later:
So as of Nothing outstanding on my end — happy to rebase or split this up if that makes review easier. |
|
@nwparker — gentle nudge on this one when you have a moment. It's small (+170/−13), still mergeable, and has been validated end to end by @jrignacio on a real Zed 1.16.1 + |
|
Verified the wrapper from exact head ELI5: a program launcher cannot execute the shell keyword
Before/after evidence, rendered in a hidden Orca terminal: This confirms the launch contract and escaping, not successful Zed/ACP tool execution. The installed agy CLI has no advertised ACP subcommand and still fails model generation with HTTP 401. Actual Zed integration, Linux/SSH and Windows validation remain outstanding. The existing PR remains the focused implementation; no duplicate PR or issue closure from this check. Rebase note: current |
|
The verified approach is now carried onto current code in draft #21635 (stacked on #21634), with credit to this PR. It preserves the newer 41 focused tests, node typecheck, changed-code quality, and pre-commit lint passed. Updated before/after evidence is attached there. Actual Zed/ACP end-to-end recovery and Linux/SSH/Windows execution remain unverified, so both issue closure and merge readiness are still pending. |
|
Thanks @nwparker for carrying this onto current code in #21635 and crediting this PR. I checked the new diff: it keeps the explicit shell launch and missing-script gate response, preserves the newer requiredEnvVar guard, and adds direct-exec coverage alongside the local and remote installer assertions. I’m closing this older PR so review can focus on #21635. The Zed/ACP validation on this PR was for 73a5cc6; the new head still needs its own integration validation as noted there. |

ELI5
Orca writes its Antigravity status hook into
~/.gemini/config/hooks.jsonas a little shell snippet that starts withif. Zed's Antigravity ACP host doesn't run hooks through a shell — it splits the string and execs the first word.ifis a shell builtin, not a program, so the spawn fails, and ACP treats a hook that failed to start as a deny on every tool call. This hands the same snippet to/bin/sh -cso the first word is a real executable.What Changed
wrapPosixHookCommandForExec()insrc/main/agent-hooks/posix-hook-command.ts— wraps the existingwrapPosixHookCommand()output in/bin/sh -c '…'.src/main/antigravity/hook-service.tsuses it forgetPosixManagedCommand(covers both the local and the SSH-remote install paths).wrapPosixHookCommand()itself is unchanged. The other callers (codex, cursor, droid, gemini, grok, copilot, devin) keep their current output byte-for-byte.Why
create_subprocess_exec+shlex.splitmeans argv[0] must be a real executable. Windows already has this contract —wrapWindowsCmdHookCommandcarries the comment "Codex/Antigravity/Devin spawn the hook as argv[0], not via cmd.exe, so it must be one spawnable token (#8430)". POSIX never got the twin.The issue suggests emitting
/usr/bin/env ORCA_ANTIGRAVITY_EVENT=… /bin/sh <script>instead. That is spawnable, but it drops theif [ -f/-r/-x ]guard — and with it theprintf '{"decision":"ask"}'fallback that #2426 added. With the guard gone, a swept~/.orcagives exit 127 and empty stdout, which Antigravity reads as a deny: the same bug in a new shape. Wrapping instead of rewriting keeps both properties.Scope is deliberately narrow: only the Antigravity installer changes. Whether the other POSIX hosts want the same argv[0] contract is a separate question I raised on the issue and left for maintainers.
Linked Issue
Fixes #16087
Visual Proof
N/A— no UI or interaction surface; the change is the command string written intohooks.json.Testing
Three tests in
src/main/antigravity/hook-service.test.ts. Note that every pre-existing POSIX test here runs the command viaspawnSync('/bin/sh', ['-c', cmd])— the path that already worked — so none of them could catch this. The new ones tokenize the command and exec argv[0], mirroring the ACP host:installs a PreToolUse command that is spawnable as argv[0] without a shell— asserts argv[0] is notif, then execs and expects{"decision":"ask"}. Reverting the fix fails it withexpected 'if' not to be 'if'.keeps answering the PreToolUse gate over exec when the managed script is missing— deletes~/.orca/agent-hooksfirst, pinning that fixing [Bug]: POSIX orca-status PreToolUse hook is not argv[0]-spawnable; Zed Antigravity ACP denies all tools #16087 does not regress [Bug]: Can not use antigravity cli in orac (ssh) #2426.tokenizes single-quote escapes the way a POSIX shlex does— pins the test tokenizer itself on the'\''sequence the wrapper emits.Cross-checked the escaping with Python's
shlex(the tokenizer the issue names): the current string splits to argv[0]'if'; the new one splits to exactly['/bin/sh', '-c', <snippet>]with the snippet byte-identical after unquoting, and exec returns rc 0 with{"decision":"ask"}.Also updated two pre-existing assertions that matched the raw command string: they now unwrap the
/bin/sh -cpayload before asserting, so they keep testing the snippet rather than the escaping. That includes thenot.toContain('{"decision"')check on PostToolUse — left as-is it would have passed even if a decision leaked in.remote-hook-service-installers.test.tscovers the SSH-remote install path, which sharesgetPosixManagedCommandand therefore gets the same wrapping.Platforms: macOS (node 24).
pnpm typecheck,pnpm build, and theagent-hooks/antigravity/ codex hook suites (127 passed, 6 skipped) pass locally.pnpm lintin full did not complete on my machine — the linter process was killed (terminated abnormally, possibly out of memory), which looks like a local resource limit rather than anything in this diff. What did run clean:oxlintandoxfmt --checkoversrc/main/agent-hooks/andsrc/main/antigravity/(125 files), plus the pre-commit hook'soxlint+ react-doctor +oxfmtover the six changed files. Please let CI cover the remainingpnpm lintsteps.Windows paths are untouched (
getManagedCommandstill returnswrapWindowsCmdHookCommandonwin32, and the Windows assertions in the same test file are unchanged).I do not have a Zed + Antigravity ACP setup, so I have not verified the end-to-end tool-call recovery myself. @jrignacio, who reported the issue, offered to validate it end to end on macOS including the missing-script case.
AI Disclosure
Written with Claude Opus 5 (Claude Code). Root cause, the rejected
envalternative, and the escaping were verified by hand against the source and by executing the generated commands; the tests were run locally.Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
quotePosixShellString, and the outer layer escapes the whole snippet the same way./bin/sh, which is required by POSIX to exist.getPosixManagedCommandis also the remote install path (hook-service.ts), so remotehooks.jsongets the same spawnable form — the ACP host reads it identically.agy) now runsh -c 'sh -c …'— one extra process per hook event, same semantics. Stale entries from older versions are replaced by the existing PreToolUse replacement logic, which the pre-existing test still covers.shper hook invocation on the Antigravity path only.Checklist
N/Awith reasonpnpm typecheck,pnpm test, andpnpm buildpass locally;pnpm lintran clean over the touched directories but the full chain OOM'd locally — see Testing