feat: add antigravity-cli integration - #2087
Conversation
Register the `antigravity_cli` target, resolve its configuration directory to `~/.gemini/antigravity-cli/`, wire target actions, and add lifecycle hook scripts for Unix and Windows.
…ty-cli-integration # Conflicts: # docs/next/website/src/content/docs/configuration.mdx
…ty-cli-integration
…o/herdr into feature/antigravity-cli-integration
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds Antigravity CLI as a supported Herdr integration. The change covers schemas, CLI registration, hook lifecycle management, agent-state reporting, session restoration, tests, and documentation. ChangesAntigravity CLI support
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant AntigravityCLI
participant HerdrAgentStateHook
participant HerdrServer
AntigravityCLI->>HerdrAgentStateHook: Invoke lifecycle hook with JSON input
HerdrAgentStateHook->>HerdrServer: Report conversation ID and agent state
HerdrServer-->>HerdrAgentStateHook: Return pane update result
HerdrServer->>AntigravityCLI: Resume with agy --conversation <id>
Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Hi @ludoo, thanks for your interest in contributing! Herdr automatically admits focused bug fixes from contributors who are not maintainers when the title uses Contributors who are not maintainers may submit only focused bug fixes. If this pull request fixes a bug, rename it to use a conventional Feature requests, behavior changes, and other proposals belong in GitHub Discussions and require maintainer approval before a pull request. If this gate classified the pull request incorrectly, reply and tag a maintainer listed in Patch size: 15 changed files, 606 changed lines. See https://github.com/herdrdev/herdr/blob/master/CONTRIBUTING.md for the contribution policy. |
|
@ogulcancelik This adds integration support for antigravity-cli, discussed in #1011 and #1571. Could you grant a scope override to reopen? |
Greptile SummaryAdds Antigravity CLI as an official session-restore integration.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the previously reported config-directory behavior is now an intentional, documented prerequisite with a regression test confirming that installation rejects rather than creates a missing directory.
|
| Filename | Overview |
|---|---|
| src/integration/targets.rs | Implements Antigravity hook installation, configuration updates, and uninstall cleanup; the previously questioned missing-directory behavior is now documented and tested as an intentional prerequisite. |
| src/integration/env.rs | Resolves the Antigravity customization directory from ANTIGRAVITY_CLI_CONFIG_DIR or ~/.gemini/config. |
| src/integration/assets/antigravity_cli/herdr-agent-state.sh | Adds the Unix hook that reports Antigravity conversation identity without claiming lifecycle authority. |
| src/integration/assets/antigravity_cli/herdr-agent-state.ps1 | Adds the equivalent Windows PowerShell conversation-reporting hook. |
| src/agent_resume.rs | Adds official Antigravity session-reference validation and resume planning through agy --conversation. |
| src/integration/tests.rs | Covers installation, replacement of stale owned configuration, missing-directory rejection, and uninstall behavior. |
Reviews (10): Last reviewed commit: "fix: update antigravity session after co..." | Re-trigger Greptile
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
src/integration/mod.rs (1)
199-208: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse target-specific
#[cfg]items for the hook assets.These constants encode platform-specific behavior but use runtime-style
cfg!(windows)selection. Define separate#[cfg(windows)]and#[cfg(not(windows))]constants instead.Proposed refactor
-const ANTIGRAVITY_CLI_HOOK_INSTALL_NAME: &str = if cfg!(windows) { +#[cfg(windows)] +const ANTIGRAVITY_CLI_HOOK_INSTALL_NAME: &str = { "herdr-agent-state.ps1" -} else { +}; +#[cfg(not(windows))] +const ANTIGRAVITY_CLI_HOOK_INSTALL_NAME: &str = { "herdr-agent-state.sh" }; -const ANTIGRAVITY_CLI_HOOK_ASSET: &str = if cfg!(windows) { + +#[cfg(windows)] +const ANTIGRAVITY_CLI_HOOK_ASSET: &str = include_str!("assets/antigravity_cli/herdr-agent-state.ps1") -} else { +; +#[cfg(not(windows))] +const ANTIGRAVITY_CLI_HOOK_ASSET: &str = include_str!("assets/antigravity_cli/herdr-agent-state.sh") -}; +;As per coding guidelines, platform-specific Rust code must be compile-gated with target-specific
#[cfg(...)].Source: Coding guidelines
src/integration/assets/antigravity_cli/herdr-agent-state.ps1 (1)
59-90: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRename
$argsto avoid shadowing PowerShell's automatic variable.Static analysis flags reuse of the automatic
$argsvariable at three call sites;$sessionArgsabove already uses a distinct name for the same purpose.🛠️ Proposed rename
if ($Action -eq "release") { - $args = @( + $reportArgs = @( "pane", "release-agent", $env:HERDR_PANE_ID, "--source", "herdr:antigravity_cli", "--agent", "antigravity-cli", "--seq", "$seq" ) - & herdr `@args` 2>$null | Out-Null + & herdr `@reportArgs` 2>$null | Out-Null } else { - $args = @( + $reportArgs = @( "pane", "report-agent", $env:HERDR_PANE_ID, "--source", "herdr:antigravity_cli", "--agent", "antigravity-cli", "--state", $Action, "--seq", "$seq" ) if (-not [string]::IsNullOrWhiteSpace($conversationId)) { - $args += @("--agent-session-id", "$conversationId") + $reportArgs += @("--agent-session-id", "$conversationId") } - & herdr `@args` 2>$null | Out-Null + & herdr `@reportArgs` 2>$null | Out-Null }Source: Linters/SAST tools
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6fc78bea-c8fa-4d98-bff4-a286dfb66023
📒 Files selected for processing (15)
docs/next/api/herdr-api.schema.jsondocs/next/website/src/content/docs/integrations.mdxdocs/next/website/src/content/docs/session-state.mdxsrc/agent_resume.rssrc/api/schema/integrations.rssrc/cli/integration.rssrc/integration/actions.rssrc/integration/assets/antigravity_cli/herdr-agent-state.ps1src/integration/assets/antigravity_cli/herdr-agent-state.shsrc/integration/env.rssrc/integration/mod.rssrc/integration/registry.rssrc/integration/targets.rssrc/integration/tests.rssrc/integration/types.rs
Antigravity CLI reads global customizations from ~/.gemini/config, keys hooks.json by hook name, and only accepts the matcher/hooks wrapper for the tool events. The previous install wrote event arrays at the top level of ~/.gemini/antigravity-cli/hooks.json, which agy never reads and would reject anyway, so no Herdr hook ever ran. Session reports were dropped for a third reason: the hooks reported the agent as antigravity-cli, but the server normalizes that to the canonical label agy before matching, so is_official_agent_source never matched and agy --conversation resume was unreachable. - Resolve the config dir to ~/.gemini/config - Nest Herdr entries under a Herdr-owned "herdr" block that install rewrites and uninstall removes, leaving other named hooks untouched - Emit grouped entries for PreToolUse/PostToolUse and flat handler lists for PreInvocation/PostInvocation/Stop - Report the canonical agy label from both hook assets and match it in agent_resume - Compile-gate the hook asset constants and stop shadowing $args in the PowerShell hook - Document the real directory, that it must already exist, and the named-block behavior refs herdrdev#1011 refs herdrdev#1571
|
Pushed f71ca5e, which addresses every review comment and two further bugs found while verifying them. Rather than take the review findings on trust, I drove a real Review comments
On the last one, the suggested diff wrapped the splat in backticks ( Bugs not raised in review1. Confirmed against the file this PR had actually installed on my machine: 2. The reported agent label could never match. The hooks reported VerificationEnd-to-end against a throwaway Herdr session running this build: agy now loads the hooks (
|
|
thanks for adding this. i don’t think antigravity should report lifecycle state yet. full lifecycle authority requires complete coverage like kimi code and opencode, including working, idle, blocked, interruption/escape, and process/session termination transitions. these hooks have no blocked transition, and interruption paths can miss could we keep this integration session-only for now and continue using antigravity’s screen manifest for lifecycle state? |
|
thanks — agreed on all three points, changed in worth adding one thing: antigravity only exposes the integration is now session-only:
resume is unchanged: verified live against antigravity cli 1.1.8:
side effect worth noting: the hook previously ran on five event types including one caveat — the i left |
16fd196 to
0e24da0
Compare
antigravity cli cannot express lifecycle safely: there is no blocked event, postinvocation is skipped on interruption, and stop fires at the end of a turn rather than on process exit, which left stale state and released authority at the wrong time. report only the conversation on preinvocation and let screen detection own agent state. resume via `agy --conversation <id>` is unchanged.
0e24da0 to
007cbe8
Compare
Register antigravity-cli as a Herdr integration target.
herdr-agent-state.ps1 to ~/.gemini/antigravity-cli/hooks/ and
manage entries in hooks.json
agy --conversation <id>when theintegration reports a conversation ID
via ANTIGRAVITY_CLI_CONFIG_DIR)
refs #1011
refs #1571