feat: Google Antigravity hook integration (resolves #1975)#2025
Open
thelok1s wants to merge 4 commits into
Open
feat: Google Antigravity hook integration (resolves #1975)#2025thelok1s wants to merge 4 commits into
thelok1s wants to merge 4 commits into
Conversation
Includes: PreToolUse hook runner mapping run_command/CommandLine, hooks.json configuration scaffolding, and stable compiler workaround for floor_char_boundary.
Author
There was a problem hiding this comment.
Pull request overview
Adds first-class PreToolUse hook support for the Google Antigravity CLI (“agy”), enabling RTK to intercept run_command tool calls and rewrite commands via the existing hook engine.
Changes:
- Adds a new
rtk hook antigravitysubcommand and Antigravity agent targeting/dispatch wiring. - Implements Antigravity hook installation/uninstallation, including patching
hooks.json(local.agents/hooks.jsonand global~/.gemini/config/hooks.json) and generating a rules file for local projects. - Extends hook detection/telemetry and replaces
str::floor_char_boundaryusage with a stable-compatible helper.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main.rs | Adds hook antigravity, routes init/uninstall correctly, and adds CLI parsing tests. |
| src/hooks/init.rs | Implements Antigravity init/uninstall behavior, hooks.json patching, and tests. |
| src/hooks/hook_cmd.rs | Adds native Antigravity PreToolUse hook processor + tests. |
| src/hooks/hook_check.rs | Updates integration detection tests to include Antigravity hooks.json. |
| src/hooks/constants.rs | Adds Antigravity hook command + directory constants. |
| src/core/telemetry.rs | Detects Antigravity hook installs for telemetry + updates tests. |
| src/cmds/system/pipe_cmd.rs | Replaces floor_char_boundary call with a local stable helper. |
| src/cmds/system/json_cmd.rs | Replaces floor_char_boundary call with a local stable helper. |
Comment on lines
+1900
to
+1906
| let initial_len = pre_tool_use.len(); | ||
| pre_tool_use.retain(|entry| { | ||
| entry | ||
| .get("command") | ||
| .and_then(|c| c.as_str()) | ||
| .is_some_and(|cmd| cmd != ANTIGRAVITY_HOOK_COMMAND) | ||
| }); |
Comment on lines
+276
to
+285
| fn floor_char_boundary(s: &str, index: usize) -> usize { | ||
| if index >= s.len() { | ||
| return s.len(); | ||
| } | ||
| let mut idx = index; | ||
| while idx > 0 && !s.is_char_boundary(idx) { | ||
| idx -= 1; | ||
| } | ||
| idx | ||
| } |
Comment on lines
+245
to
+254
| fn floor_char_boundary(s: &str, index: usize) -> usize { | ||
| if index >= s.len() { | ||
| return s.len(); | ||
| } | ||
| let mut idx = index; | ||
| while idx > 0 && !s.is_char_boundary(idx) { | ||
| idx -= 1; | ||
| } | ||
| idx | ||
| } |
Comment on lines
338
to
+381
| /// Initialize for Gemini CLI instead of Claude Code | ||
| #[arg(long)] | ||
| gemini: bool, | ||
|
|
||
| /// Target agent to install hooks for (default: claude) | ||
| #[arg(long, value_enum)] | ||
| agent: Option<AgentTarget>, | ||
|
|
||
| /// Show current configuration | ||
| #[arg(long)] | ||
| show: bool, | ||
|
|
||
| /// Inject full instructions into CLAUDE.md (legacy mode) | ||
| #[arg(long = "claude-md", group = "mode")] | ||
| claude_md: bool, | ||
|
|
||
| /// Hook only, no RTK.md | ||
| #[arg(long = "hook-only", group = "mode")] | ||
| hook_only: bool, | ||
|
|
||
| /// Auto-patch settings.json without prompting | ||
| #[arg(long = "auto-patch", group = "patch")] | ||
| auto_patch: bool, | ||
|
|
||
| /// Skip settings.json patching (print manual instructions) | ||
| #[arg(long = "no-patch", group = "patch")] | ||
| no_patch: bool, | ||
|
|
||
| /// Remove RTK artifacts for the selected assistant mode | ||
| #[arg(long)] | ||
| uninstall: bool, | ||
|
|
||
| /// Target Codex CLI (uses AGENTS.md + RTK.md, no Claude hook patching) | ||
| #[arg(long)] | ||
| codex: bool, | ||
|
|
||
| /// Install GitHub Copilot integration (VS Code + CLI) | ||
| #[arg(long)] | ||
| copilot: bool, | ||
|
|
||
| /// Target Google Antigravity CLI (agy) | ||
| #[arg(long)] | ||
| antigravity: bool, | ||
|
|
Comment on lines
1377
to
+1394
| global: bool, | ||
| gemini: bool, | ||
| codex: bool, | ||
| antigravity_cli: bool, | ||
| ctx: hooks::init::InitContext, | ||
| uninstall_hermes: UninstallHermes, | ||
| uninstall_standard: UninstallStandard, | ||
| ) -> Result<()> | ||
| where | ||
| UninstallHermes: FnOnce(hooks::init::InitContext) -> Result<()>, | ||
| UninstallStandard: FnOnce(bool, bool, bool, bool, hooks::init::InitContext) -> Result<()>, | ||
| UninstallStandard: FnOnce(bool, bool, bool, bool, bool, bool, hooks::init::InitContext) -> Result<()>, | ||
| { | ||
| if agent == Some(AgentTarget::Hermes) { | ||
| uninstall_hermes(ctx) | ||
| } else { | ||
| let cursor = agent == Some(AgentTarget::Cursor); | ||
| uninstall_standard(global, gemini, codex, cursor, ctx) | ||
| let antigravity_ide = agent == Some(AgentTarget::Antigravity); | ||
| uninstall_standard(global, gemini, codex, cursor, antigravity_cli, antigravity_ide, ctx) |
Comment on lines
604
to
612
| pub fn uninstall( | ||
| global: bool, | ||
| gemini: bool, | ||
| codex: bool, | ||
| cursor: bool, | ||
| antigravity_cli: bool, | ||
| antigravity_ide: bool, | ||
| ctx: InitContext, | ||
| ) -> Result<()> { |
0483718 to
d9099a8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Implements programmatic JSON-based PreToolUse hook support for the Google Antigravity CLI (agy) to intercept run_command/CommandLine tool calls.
Key changes:
All 1921 tests pass, clippy has no warnings, and code formatting is correct.