Skip to content

feat(antigravity): add PreToolUse command-wrapping hook and installer support - #56

Merged
JayPokale merged 3 commits into
JayPokale:mainfrom
boxxxie:feat/antigravity-pretooluse-hook
Nov 26, 2026
Merged

JayPokale merged 3 commits into
JayPokale:mainfrom
boxxxie:feat/antigravity-pretooluse-hook

Conversation

@boxxxie

@boxxxie boxxxie commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • hooks/chisle-run.js: Support Antigravity (agy) PreToolUse payloads (toolCall.name === 'run_command', toolCall.args.CommandLine) and emit {"decision":"ask","overwrite":{"CommandLine":...}} for wrappable test/build/install commands, passing --state-dir <getAntigravityDir()> before -- so stats/spill files land in ~/.gemini/config even when ~/.claude exists.
  • hooks/chisle-config.js: Add getAntigravityDir() ($AGY_CONFIG_DIR or ~/.gemini/config).
  • bin/install.js: Add installAntigravity() so --only antigravity installs .agents/rules/chisle.md, copies the runner/compressor into .agents/chisle-hooks/, and safely merges a chisle PreToolUse hook into .agents/hooks.json (validating existing JSON objects before any writes); wire --stats --only antigravity to getAntigravityDir().
  • tests/test_run.js & tests/test_installer.js: Add unit/integration tests for Antigravity PreToolUse rewrites (including compound commands and --state-dir routing) and .agents/hooks.json merge/validation.

Verification

  • node --test tests/test_run.js tests/test_installer.js: 45/45 passing.

@boxxxie
boxxxie requested a review from JayPokale as a code owner November 25, 2026 01:55
@vercel

vercel Bot commented Nov 25, 2026

Copy link
Copy Markdown

@boxxxie is attempting to deploy a commit to the jaypokale35gmailcom's projects Team on Vercel.

A member of the Team first needs to authorize it.

@boxxxie
boxxxie force-pushed the feat/antigravity-pretooluse-hook branch from 3629b5c to 195646d Compare November 25, 2026 02:33

@JayPokale JayPokale left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. Bringing the command filters to Antigravity is a welcome addition, and the PR is careful: the hooks.json merge validates before writing and leaves a broken file untouched, --state-dir keeps stats out of ~/.claude, and the copied hook set is complete. It merges cleanly with current main and the full suite passes (271/271).

A few things before it can go in:

  1. Hook protocol reference. Nothing in this repo documents Antigravity's hook API, so I can't verify the payload shape (toolCall.name === 'run_command', args.CommandLine), the { "decision": "ask", "overwrite": { ... } } response, the hooks.json layout with a named chisle group, or that hooks run with .agents/ as the working directory. If any of these is off, the hook silently does nothing. Could you link Antigravity's hook documentation (and the agy version you tested with), or paste a short session log showing a wrapped npm test?

  2. Deny/ask rules. On the Claude Code path, guardedPrograms() skips any command the user has listed under permissions.deny or permissions.ask, because rewriting the command string can stop those rules from matching. The Antigravity path rewrites unconditionally. A user who denies npm install in Antigravity could have it rewritten to node …/chisle-run.js --state-dir … -- npm install, which may no longer match the deny rule; with decision: "ask" that becomes a prompt instead of a block. Please apply the same guard against Antigravity's permission configuration, or skip the rewrite when a rule could match.

  3. Prompt on every wrapped command. Returning ask keeps the permission gate, which is right, but if Antigravity matches its always-allow list against the overwritten CommandLine, users who auto-allowed npm test would be prompted on every run. Can you confirm which string Antigravity checks?

  4. Uninstall vs. install. The installer preserves sibling hooks inside hooks.chisle.PreToolUse (the echo sibling test), but uninstall deletes the whole hooks.chisle group, so those siblings would be lost. Either treat the group as Chisle-owned on both sides, or have uninstall remove only Chisle's entry.

  5. Smaller points:

    • The hook files copied into .agents/chisle-hooks/ go stale after a Chisle upgrade until the installer is rerun, and users may commit them. A note in the install output or docs would help.
    • docs/usage.md still says Antigravity receives the ruleset only; please update it, and add a CHANGELOG entry.

Happy to take another look once these are addressed.

@boxxxie

boxxxie commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

ok, i'll review all of these tomorrow and see how much closure i can bring to the issues you bring up.

…ons, uninstall, and docs

Addresses review comments on JayPokale#56:
- Gate Antigravity PreToolUse command wrapping on toolPermission === 'always-proceed' (or CHISLE_COMPRESS_WRAP=1) so Always-Allow rules are not broken by rewritten CommandLine strings.
- Skip rewriting programs guarded by permissions.deny or permissions.ask (command/unsandboxed rules, including * and regex:) in ~/.gemini/antigravity-cli/settings.json.
- Link Antigravity hooks and permissions documentation in hooks/chisle-run.js.
- Preserve sibling hooks inside hooks.chisle.PreToolUse on --uninstall instead of deleting the entire hooks.chisle group.
- Print a note during install that .agents/chisle-hooks/ is a local copy to refresh on Chisle upgrades, and update docs/usage.md, docs/agent-portability.md, and CHANGELOG.md.
@boxxxie

boxxxie commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review — addressed all five points in d3606a0 and f218ee0 (all 271/271 tests passing):

  1. Hook protocol reference:

    • Official docs: https://antigravity.google/docs/hooks (and https://antigravity.google/docs/permissions). Linked in hooks/chisle-run.js and docs/agent-portability.md.
    • Tested on agy 1.5.17: hooks.json top-level named groups run with the hooks.json directory (.agents/) as CWD, PreToolUse sends toolCall: { name: "run_command", args: { CommandLine } }, and { decision: "ask", overwrite: { CommandLine } } shallow-merges into toolCall.args before execution (Antigravity prepends A pre-tool hook changed the arguments of this tool call before it ran. Changed: CommandLine. to the tool result — verified live on npm test).
  2. Deny/ask rules:

    • Added readAntigravitySettings() + guardedAntigravityPrograms() in hooks/chisle-run.js reading ~/.gemini/antigravity-cli/settings.json (overridable via AGY_CLI_DIR). Any program named in permissions.deny or permissions.ask under command(...) or unsandboxed(...) is skipped (and * / regex: skips all wrapping), matching the Claude Code guard.
  3. Prompt on every wrapped command (Always Allow):

    • Confirmed from Antigravity's docs: overwrite merges before execution, so prefix-based command(npm test) allow rules won't match a rewritten node ./chisle-hooks/chisle-run.js ... -- npm test.
    • Mirrored the Claude Code bypassPermissions gate: Antigravity wrapping now only runs when toolPermission === "always-proceed" in ~/.gemini/antigravity-cli/settings.json or when CHISLE_COMPRESS_WRAP=1 is explicitly set (App/IDE users without CLI settings can opt in via CHISLE_COMPRESS_WRAP=1).
  4. Uninstall vs. install symmetry:

    • --uninstall --only antigravity now strips only the chisle-run.js hook entry from hooks.chisle.PreToolUse, preserving sibling hooks/entries and only deleting hooks.chisle / .agents/hooks.json when empty. Added tests for both sibling preservation and clean-file removal.
  5. Docs, CHANGELOG & stale hook copy note:

    • Added an install note that .agents/chisle-hooks/ is a local copy to refresh after upgrading Chisle (and safe to .gitignore).
    • Updated docs/usage.md, docs/agent-portability.md, docs/comparison.md, INSTALL.md, and CHANGELOG.md ([Unreleased]).

@JayPokale JayPokale left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, all five points are addressed: the docs link and agy 1.5.17 test, the deny/ask guard, the always-proceed gate, symmetric uninstall, and docs plus CHANGELOG. Merged with current main, the full suite passes (272/272).

@JayPokale
JayPokale merged commit cf2e0d0 into JayPokale:main Nov 26, 2026
3 of 4 checks passed
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