aboutsummaryrefslogtreecommitdiff
path: root/src/integration/assets/antigravity_cli
diff options
context:
space:
mode:
authorLudovico Magnocavallo <ludo@qix.it>2026-08-01 18:32:47 +0200
committerGitHub <noreply@github.com>2026-08-01 19:32:47 +0300
commit679584fdd49f9dee5ad95755af65eedc7d0f455c (patch)
treeb21359553af294c2a2d57726e99029d86534cda0 /src/integration/assets/antigravity_cli
parent219e0be351436b5bf1ccf5b7c13dbf6c2cdb0986 (diff)
feat: add antigravity-cli integration (#2087)
* feat: add antigravity_cli integration harness 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. * feat: support session resume for antigravity-cli * fix: correct antigravity-cli hook config path, shape, and agent label 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 #1011 refs #1571 * fix: make antigravity-cli integration session-only 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. * fix: update antigravity session after conversation switch --------- Co-authored-by: Can Celik <ogulcancelik@gmail.com>
Diffstat (limited to 'src/integration/assets/antigravity_cli')
-rw-r--r--src/integration/assets/antigravity_cli/herdr-agent-state.ps157
-rw-r--r--src/integration/assets/antigravity_cli/herdr-agent-state.sh77
2 files changed, 134 insertions, 0 deletions
diff --git a/src/integration/assets/antigravity_cli/herdr-agent-state.ps1 b/src/integration/assets/antigravity_cli/herdr-agent-state.ps1
new file mode 100644
index 00000000..aecb42a9
--- /dev/null
+++ b/src/integration/assets/antigravity_cli/herdr-agent-state.ps1
@@ -0,0 +1,57 @@
+# installed by herdr
+# managed by herdr; reinstalling or updating the integration overwrites this file.
+# add custom hooks beside this file instead of editing it.
+# HERDR_INTEGRATION_ID=antigravity_cli
+# HERDR_INTEGRATION_VERSION=1
+
+# Session-only: this hook reports the Antigravity conversation so Herdr can
+# resume the pane. Lifecycle state comes from Herdr's screen detection.
+
+param([string]$Action = "")
+
+# Antigravity CLI expects a JSON object on stdout and this hook never injects
+# anything, so every exit path emits an empty object.
+function Exit-Hook {
+ Write-Output "{}"
+ exit 0
+}
+
+if ($Action -ne "session") { Exit-Hook }
+if ($env:HERDR_ENV -ne "1") { Exit-Hook }
+if ([string]::IsNullOrWhiteSpace($env:HERDR_PANE_ID)) { Exit-Hook }
+
+$inputText = [Console]::In.ReadToEnd()
+try {
+ $payload = if ([string]::IsNullOrWhiteSpace($inputText)) { $null } else { $inputText | ConvertFrom-Json }
+} catch {
+ Exit-Hook
+}
+
+if ($null -eq $payload) { Exit-Hook }
+
+$conversationId = if ($payload.conversationId -is [string]) { $payload.conversationId } else { $null }
+if ([string]::IsNullOrWhiteSpace($conversationId)) { Exit-Hook }
+
+$seq = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
+try {
+ $sessionArgs = @(
+ "pane",
+ "report-agent-session",
+ $env:HERDR_PANE_ID,
+ "--source",
+ "herdr:antigravity_cli",
+ "--agent",
+ "agy",
+ "--seq",
+ "$seq",
+ "--agent-session-id",
+ "$conversationId"
+ )
+ if ($payload.transcriptPath -is [string] -and -not [string]::IsNullOrWhiteSpace($payload.transcriptPath)) {
+ $sessionArgs += @("--agent-session-path", "$($payload.transcriptPath)")
+ }
+ & herdr @sessionArgs 2>$null | Out-Null
+} catch {
+}
+
+Exit-Hook
diff --git a/src/integration/assets/antigravity_cli/herdr-agent-state.sh b/src/integration/assets/antigravity_cli/herdr-agent-state.sh
new file mode 100644
index 00000000..dd3db028
--- /dev/null
+++ b/src/integration/assets/antigravity_cli/herdr-agent-state.sh
@@ -0,0 +1,77 @@
+#!/bin/sh
+# installed by herdr
+# managed by herdr; reinstalling or updating the integration overwrites this file.
+# add custom hooks beside this file instead of editing it.
+# HERDR_INTEGRATION_ID=antigravity_cli
+# HERDR_INTEGRATION_VERSION=1
+
+# Session-only: this hook reports the Antigravity conversation so Herdr can
+# resume the pane. Lifecycle state comes from Herdr's screen detection.
+
+set -eu
+
+# Antigravity CLI expects a JSON object on stdout and this hook never injects
+# anything, so every exit path emits an empty object.
+emit_and_exit() {
+ printf '{}\n'
+ exit 0
+}
+
+[ "${1:-}" = "session" ] || emit_and_exit
+[ "${HERDR_ENV:-}" = "1" ] || emit_and_exit
+[ -n "${HERDR_SOCKET_PATH:-}" ] || emit_and_exit
+[ -n "${HERDR_PANE_ID:-}" ] || emit_and_exit
+command -v python3 >/dev/null 2>&1 || emit_and_exit
+
+python3 -c '
+import json
+import os
+import socket
+import sys
+import time
+
+try:
+ payload = json.load(sys.stdin)
+except Exception:
+ raise SystemExit(0)
+
+if not isinstance(payload, dict):
+ raise SystemExit(0)
+
+def text(name):
+ value = payload.get(name)
+ return value if isinstance(value, str) and value else None
+
+session_id = text("conversationId")
+if session_id is None:
+ raise SystemExit(0)
+
+seq = time.time_ns()
+params = {
+ "pane_id": os.environ["HERDR_PANE_ID"],
+ "source": "herdr:antigravity_cli",
+ "agent": "agy",
+ "seq": seq,
+ "agent_session_id": session_id,
+}
+
+transcript_path = text("transcriptPath")
+if transcript_path is not None:
+ params["agent_session_path"] = transcript_path
+
+request = json.dumps({
+ "id": f"herdr:antigravity_cli:{seq}",
+ "method": "pane.report_agent_session",
+ "params": params,
+})
+try:
+ with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as client:
+ client.settimeout(0.5)
+ client.connect(os.environ["HERDR_SOCKET_PATH"])
+ client.sendall((request + "\n").encode())
+ client.recv(4096)
+except Exception:
+ pass
+' 2>/dev/null || true
+
+emit_and_exit