Skip to content

feat(cli): relay agy PostToolUse under its own tool names - #1355

Merged
blafourcade merged 5 commits into
nextfrom
feat/antigravity-relays-stop-and-tool-hooks
Nov 25, 2026
Merged

blafourcade merged 5 commits into
nextfrom
feat/antigravity-relays-stop-and-tool-hooks

Conversation

@blafourcade

@blafourcade blafourcade commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

🎯 What & why

Relays Antigravity (agy) PostToolUse hooks under agy's own tool names (write_file, edit_file, run_command), so framework hook scripts fire on the tools agy actually calls. Refs #1194: its PreToolUse part moves to #1342, which adds the neutral refusal every host needs.

🛠️ How it works

  • Probed Antigravity CLI 1.5.16 (model gemini-3.8-flash-low), docs https://antigravity.google/docs/hooks, in a throwaway project and HOME. Captured payloads: scripts/__tests__/fixtures/hook-payloads/antigravity-PostToolUse.json.
  • Proven: the edit tool is edit_file (args Path, Target, Replacement), not write_file. agy reads a matcher as an anchored regular expression over the whole tool name (write_.* fired write_file only, .*_command run_command only, write_f nothing).
  • Wired: MATCHER_TOOLS in cli/src/composition/tool-profiles/antigravity.ts maps Claude names to agy names; the PostToolUse relay in cli/assets/hooks-runtime/host-antigravity.cjs; the wrapped-command merge in wrapped-command-hooks-merge.ts no longer drops a group whose matcher is mapped.
  • Stop: no translation needed. continueTurn already prints {"decision":"continue"}. The Stop block answer was observed once but not kept as a fixture, so it is not relied on.
  • Goldens moved (intended, matcher output changed): hooks-routes/antigravity/flat-translate.txt, plugin-install.txt, plugin-install-twice.txt, setup-plugins-reinstall.txt.

➕ Added since the first push

  • hostToolNames (cli/src/contexts/tools/domain/formats/host-tool-names.ts): one shared owner of the rename of plugin tool names to a host's, now used by the agy and Kimi agent tool lists and by hook matchers.
  • Matcher change, exactly: before, a plugin matcher was split on | and each piece looked up literally, so Edit.* named no tool and its group was skipped. Now hostToolNamesMatching reads it as Claude does: a matcher of only word characters and | stays a list of names (order kept); any other is a regular expression tested, unanchored, against each Claude tool name the host has a name for, and the host names it selects are emitted joined by |. An invalid expression throws at build. No shipped plugin writes a regex matcher, so no golden moved.
  • Tests first, red lines: hostToolNamesMatching is not a function (unit), and reads a matcher that is a regular expression, as Claude does expected ["patch","put|sh"]. Mutation: inverting the regex filter turns exactly the four regex tests red; the plain-name tests stay green.

🧪 How to verify

  • cd cli && pnpm exec vitest run tests/contexts/tools/hooks-runtime.integration.test.ts
  • End to end (probe, run 5): with the built CLI, Pre and Post fired for write_file, edit_file, run_command; read_file and update_steps fired nothing.
  • Gates on 3456fc549: make validate 0, pre-commit 0, cli pre-push 0 (9921 passed, 1 expected fail, 15 skipped), cli build 0, bundle 880.5 KB / 897 KB budget.

⚠️ Heads-up

Limits, stated not coded:

  • PreToolUse relay is not on this branch. Probe facts kept for it: {} denies, empty stdout runs the tool, {"decision":"allow"} runs it, {"decision":"block"} errors (unsupported hook decision: block), {"decision":"deny","reason":...} denies with the reason shown.
  • PostInvocation context injection: not probed; PostToolUse answer stays {}.
  • replace_file_content and multi_replace_file_content are documented but were never seen called; not mapped.
  • A pure wildcard regex (.*) selects only the three mapped tools, narrower than Claude's every tool.
  • A message raised at a Stop that is already a continuation (executionNum > 0) is dropped: the framework's one-continuation contract, shared by every adapter, kept.
  • Claude approve/ask/permissionDecision answers are not translated: they need the PreToolUse relay, whose neutral refuse answer no adapter has yet.
  • Delete, PowerShell, Shell and bash have no known agy tool and are dropped from a matcher.
  • Findings: docs/COMPATIBILITY.md and the host tables are not edited here; host conclusions are in the findings file for the owning PR.

🔗 Linked issue

Refs #1194

✅ I certify

  • I DO CERTIFY I READ EACH LINE OF THE PULL REQUEST BECAUSE I AM A SOFTWARE ENGINEER, NOT A AI PUPPY.

🤖 Generated with Claude Code

@blafourcade
blafourcade force-pushed the feat/antigravity-relays-stop-and-tool-hooks branch from 4181ffe to 77daa1f Compare November 25, 2026 15:29
…ss agents and hook matchers

Co-Authored-By: Claude Opus 5.5 <[email protected]>
blafourcade and others added 2 commits November 25, 2026 19:27
…ugh one shared reader

A plugin ships only plain `|` lists, so the regular expression branch and the
empty and star cases go; the reader is case-insensitive as the bridges are, and
the skipped-group warning has one builder other hosts reuse.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ys-stop-and-tool-hooks

# Conflicts:
#	scripts/__tests__/fixtures/hook-payloads/README.md
@blafourcade
blafourcade marked this pull request as ready for review November 25, 2026 19:00
@blafourcade
blafourcade requested a review from a team as a code owner November 25, 2026 19:00
@blafourcade
blafourcade merged commit 7cd868f into next Nov 25, 2026
@blafourcade
blafourcade deleted the feat/antigravity-relays-stop-and-tool-hooks branch November 25, 2026 19:00
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.

1 participant