Skip to content

feat(gemini): run the Gemini provider on the Antigravity CLI over ACP - #255

Open
bbsngg wants to merge 1 commit into
mainfrom
claude/antigravity-cli
Open

bbsngg wants to merge 1 commit into
mainfrom
claude/antigravity-cli

Conversation

@bbsngg

@bbsngg bbsngg commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Google retired the Gemini CLI for individual accounts on 2026-06-18; its replacement is the Antigravity CLI (agy). This PR switches Dr. Claw's gemini provider from gemini --output-format stream-json to agy acp (Agent Client Protocol). The provider id stays gemini, so existing sessions, settings, chat UI and the Gemini API code paths are unchanged.

Why ACP rather than agy -p --output-format stream-json

Tested against agy 1.5.1:

  • Headless print mode can't ask before a tool runs. A tool event arrives only when the tool starts and finishes tens of milliseconds later, and in default / accept-edits mode every tool that needs approval is auto-denied, which ends the turn with no reply. Only --dangerously-skip-permissions worked.
  • ACP sends session/request_permission before a tool runs, so Dr. Claw can answer from its allow/deny lists or ask the user, exactly as it does for Claude. ACP also carries full tool arguments (e.g. file contents for writes), modes, models, usage, and session/load to continue a conversation.

How a turn works (server/gemini-cli.js)

  1. Start agy acp, send initialize.

  2. Open the conversation:

    • new conversations use session/new;
    • resumed ones use session/load, ignoring the history agy replays during the load;
    • if a conversation can't be loaded (e.g. an old Gemini CLI session), a new one is started with a notice.
  3. Configure the session:

    • session/set_model: Gemini API ids such as gemini-3.8-flash map to agy's gemini-3.8-flash-high; if no agy model matches, agy's default stays;
    • session/set_mode: default, accept-edits or plan. Bypass mode instead passes --dangerously-skip-permissions.
  4. Send session/prompt, stream updates to the chat, then stop the process.

  5. Answer permission requests:

    • from the allow/deny lists, using Claude-style names (Bash(git log:*), Write, …) and also the old Gemini CLI names users may have saved (run_shell_command, write_file, …);
    • otherwise by asking the user.
  6. Map session updates to the existing gemini-* chat messages:

    • text deltas and thinking;
    • tool cards: run_command → Bash, write_file → Write, edit_file → Edit, read_file → Read/LS, …;
    • plan → TodoWrite;
    • usage → token budget.

    Dr. Claw keeps writing ~/.gemini/sessions/<id>.jsonl, so history and session search keep working; agy does not document its own storage.

  7. Stop: session/cancel before the process is signalled.

Also changed

  • Finding agy: ANTIGRAVITY_CLI_PATH, then ~/.local/bin/agy (the installer default, which the desktop app's PATH often lacks), then agy on PATH.
  • Login status and models: both come from agy models, which needs a signed-in account (agy has no status command). The result is cached for a minute. Model discovery falls back to the Gemini API catalogue, then the built-in list.
  • Settings and onboarding:
    • the install hint is now the official installer (curl -fsSL https://antigravity.google/cli/install.sh | bash, PowerShell on Windows);
    • the login terminal runs agy;
    • shell resume is agy --conversation <id>;
    • labels say "Antigravity";
    • the suggested permission patterns use Claude-style names.
  • Docs: README (en/zh), FAQ and configuration docs updated; GEMINI_CLI_PATH replaced by ANTIGRAVITY_CLI_PATH.
  • Cleanup: the unused Gemini CLI stream parsing and helpers are removed (gemini-cli.js 1365 → ~770 lines).
  • Skills: they reach agy through the project's .agents/skills links. Skill folders are deliberately not passed with --add-dir: in testing, agy then ran commands and wrote files in the skills folder instead of the project.

Not in this PR

  • MCP servers are not passed to session/new yet (mcpServers: []).
  • The Gemini thinking-mode picker has no effect on agy; agy's models carry their effort level in the id (-high / -medium / -low).

Test plan

  • npx vitest run: 574 tests pass, including the new server/__tests__/antigravity-acp.test.mjs:
    • the ACP connection itself;
    • the mapping helpers;
    • a fake agy acp covering a full turn: allow-list auto-approval, deny list, session/load without history replay, bypass flag, accept-edits mode, and a clear error when agy is missing;
    • model discovery via agy models.
  • npm run typecheck
  • With the real agy 1.5.1 (signed in), ran two turns through spawnGemini in a scratch project:
    • ls and file write auto-approved from the allow list;
    • reading a skill through .agents/skills;
    • thinking, tool cards and the token budget streamed;
    • the second turn continued the conversation via session/load;
    • history written to the session file.
  • Not yet clicked through in the desktop app UI (permission prompts for tools not on the allow list are covered by the fake-agy test only).

🤖 Generated with Claude Code

Google retired the Gemini CLI for individual accounts on 2026-06-18 in
favour of the Antigravity CLI (`agy`). The `gemini` provider now drives
`agy acp` (Agent Client Protocol) instead of `gemini --output-format
stream-json`. The provider id stays `gemini`, so sessions, settings, the
chat UI and the Gemini API paths are unchanged.

- Each turn starts `agy acp`, runs initialize, then session/new (or
  session/load to continue a conversation, skipping the replayed history),
  session/set_model, session/set_mode and session/prompt.
- Permission requests arrive before a tool runs and are answered from the
  allow/deny lists (Claude-style names, plus the old Gemini CLI names users
  may have saved) or by asking the user, as for Claude. acceptEdits and plan
  map to agy's accept-edits and plan modes; bypass passes
  --dangerously-skip-permissions. Headless print mode can't ask before a
  tool runs, which is why ACP is used.
- Session updates become the existing gemini-* chat messages: text deltas,
  thinking, tool cards (run_command -> Bash, write_file -> Write,
  edit_file -> Edit, read_file -> Read, ...), plan -> TodoWrite, usage ->
  token budget. Dr. Claw keeps writing ~/.gemini/sessions/<id>.jsonl for
  history and search.
- agy is found via ANTIGRAVITY_CLI_PATH, ~/.local/bin/agy (the installer
  default, often missing from the desktop app's PATH), then PATH.
- Login status and the model list come from `agy models`, which needs a
  signed-in account (agy has no status command); the Gemini API catalogue
  is the fallback. Install hints, the login terminal command, shell resume
  (`agy --conversation <id>`), labels and docs now point at Antigravity.
- The unused Gemini CLI stream parsing and helpers are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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