Skip to content

feat: Google Antigravity hook integration (resolves #1975)#2025

Open
thelok1s wants to merge 4 commits into
rtk-ai:developfrom
thelok1s:feature/issue-1975-antigravity-hook
Open

feat: Google Antigravity hook integration (resolves #1975)#2025
thelok1s wants to merge 4 commits into
rtk-ai:developfrom
thelok1s:feature/issue-1975-antigravity-hook

Conversation

@thelok1s
Copy link
Copy Markdown

Implements programmatic JSON-based PreToolUse hook support for the Google Antigravity CLI (agy) to intercept run_command/CommandLine tool calls.

Key changes:

  • Constants and AgentTarget mappings for Antigravity in constants.rs and main.rs
  • PreToolUse runner hook implementation in hook_cmd.rs
  • Workspace-scoped and global hooks.json patching and rules file generation in init.rs
  • Detection and diagnostics logic in hook_check.rs
  • Telemetry target mapping in telemetry.rs
  • Custom stable floor_char_boundary implementation in json_cmd.rs and pipe_cmd.rs to allow compiling on stable Rust compilers.

All 1921 tests pass, clippy has no warnings, and code formatting is correct.

Includes: PreToolUse hook runner mapping run_command/CommandLine, hooks.json configuration scaffolding, and stable compiler workaround for floor_char_boundary.
Copilot AI review requested due to automatic review settings May 21, 2026 20:55
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 21, 2026

CLA assistant check
All committers have signed the CLA.

@thelok1s
Copy link
Copy Markdown
Author

I used the Antigravity to make rtk optimise the Antigravity
image

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 antigravity subcommand and Antigravity agent targeting/dispatch wiring.
  • Implements Antigravity hook installation/uninstallation, including patching hooks.json (local .agents/hooks.json and global ~/.gemini/config/hooks.json) and generating a rules file for local projects.
  • Extends hook detection/telemetry and replaces str::floor_char_boundary usage 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 thread src/hooks/init.rs
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 thread src/cmds/system/json_cmd.rs Outdated
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 thread src/cmds/system/pipe_cmd.rs Outdated
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
}
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Comment thread src/main.rs
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 thread src/main.rs
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 thread src/hooks/init.rs
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<()> {
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.

3 participants