Skip to content

Add Antigravity backend via agy CLI#3

Open
fatwang2 wants to merge 3 commits into
masterfrom
agent/tom/62a92a63
Open

Add Antigravity backend via agy CLI#3
fatwang2 wants to merge 3 commits into
masterfrom
agent/tom/62a92a63

Conversation

@fatwang2
Copy link
Copy Markdown
Owner

Summary

  • New src/agents/antigravity.ts backend that drives Google's agy CLI (the Go-based replacement for Gemini CLI shipped 2026-05-19) in headless mode: agy -p <prompt> --output-format stream-json --yolo. Same structure as cursor.ts; only the event vocabulary differs (init/message/tool_use/tool_result/error/result).
  • Wired into src/config.ts (ANTIGRAVITY_PATH, ANTIGRAVITY_MODEL env vars) and registered in src/main.ts alongside the other backends.
  • Tool names from agy are mapped to Claude Code's vocabulary (read_fileRead, run_shell_commandBash, etc.) so the dispatcher's plan parser keeps working unchanged. Unknown names pass through verbatim.
  • Auth is handled by the CLI itself: first run of agy completes Google Sign-In (cached in OS keyring), or set ANTIGRAVITY_API_KEY for scripted/CI use. --yolo auto-accepts tool execution since webhook flow has no TTY.
  • Session resume mirrors the existing --resume <session_id> pattern.
  • README (EN + zh-CN) updated: prerequisites, DEFAULT_AGENT list, dedicated Antigravity section, and the agent-resume mention now lists agy --resume.

Why CLI and not the SDK

Same reasoning as Cursor — plain stdio keeps Bun out of the protocol critical path and matches the established backend pattern (claude-code and cursor are both CLI-driven). The CLI's stream-json schema is documented in the Antigravity headless reference and covers session metadata, messages, tool calls, and final result stats, which is everything the dispatcher consumes today.

Test plan

  • bun install && bun build src/main.ts — verified locally, bundles cleanly
  • Install agy locally (curl -fsSL https://antigravity.google/cli/install.sh | bash), complete Google Sign-In, run with DEFAULT_AGENT=antigravity, confirm detectAvailable() lists antigravity
  • Dispatch a Linear issue to the Antigravity agent and confirm streaming messages reach Linear and the final response activity is posted
  • Follow-up reply in the same thread resumes via agy --resume <session_id>
  • Tool-name mapping (read_file, run_shell_command, etc.) needs verification against a real agy stream-json event sample — the names in mapToolName() are best-effort since the headless reference doesn't enumerate them. Unknown names already pass through unchanged, so the mapping table is the only thing that may need tweaking after a live run.

Closes WAN-141 (Multica: db48f853-cc24-45ba-86c7-49be9576bd7e).

fatwang2 and others added 3 commits May 22, 2026 12:45
… Cursor.

Drives Google's new agy CLI (Go-based replacement for Gemini CLI shipped
2026-05-19) in headless mode: agy -p <prompt> --output-format stream-json
--yolo. Auth is handled by the CLI itself via Google Sign-In keyring or
ANTIGRAVITY_API_KEY; session resume mirrors the existing --resume flow.

Parses agy's stream-json event vocabulary (init/message/tool_use/
tool_result/error/result) and maps tool names to Claude Code's so the
dispatcher's plan parser works unchanged. Same structure as cursor.ts.

Co-authored-by: multica-agent <github@multica.ai>
agy v1.0.0 (verified via `agy --help`) does not support
`--output-format`, `--yolo`, `--resume`, or `-m`. Calling with those
flags caused `flags provided but not defined` and the process exited
with code 2.

Use the documented flags only:
  --print                         non-interactive single-prompt mode
  --dangerously-skip-permissions  auto-approve tools (no TTY)
  --conversation <id>             resume a previous conversation

`agy --print` streams the final assistant response as plain text on
stdout, so we accumulate stdout chunks and emit text AgentMessages
directly rather than parsing a stream-json schema that does not exist
yet. Surface stderr in the failure path so future flag mismatches are
visible in the dispatcher log.

Co-authored-by: multica-agent <github@multica.ai>
…rously-skip-permissions

- Implement snapshotConversationIds() and detectNewConversationId() in the Antigravity backend to recover the generated/reused conversation ID from ~/.gemini/antigravity-cli/conversations/<uuid>.pb and pass it via AgentResult.sessionId so that future follow-up turns can resume the session.
- Pin the Antigravity workspace using --add-dir pointing to the spawned process's working directory so that agy doesn't fall back to ~/.gemini/antigravity-cli/scratch and ignore the repo.
- In claude-code.ts, map the bypassPermissions permission mode to pass the --dangerously-skip-permissions CLI flag instead of --permission-mode bypassPermissions.
- Update README.md and README.zh-CN.md to document the correct agy invocation flags (--print --dangerously-skip-permissions --add-dir <cwd>), --conversation <id> for resuming, and the Claude Code bypass permissions mappings.
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.

1 participant