Skip to content

Add Antigravity CLI (agy) support with automatic gemini fallback#5

Open
MorpheusZA wants to merge 1 commit into
thepushkarp:mainfrom
MorpheusZA:antigravity-cli-migration
Open

Add Antigravity CLI (agy) support with automatic gemini fallback#5
MorpheusZA wants to merge 1 commit into
thepushkarp:mainfrom
MorpheusZA:antigravity-cli-migration

Conversation

@MorpheusZA
Copy link
Copy Markdown

Summary

  • Bridge now probes PATH and prefers agy (Antigravity CLI) when installed, falling back to gemini so existing setups keep working during the transition window.
  • --model and non-text --format values are accepted but warn-and-dropped when agy is the resolved binary (model selection is config-only on agy; output is text-only).
  • Docs and troubleshooting updated for the dual-binary world. Plugin name, slash command, and skill name unchanged to avoid breaking downstream references.

Why

Google announced on 2026-05-19 that consumer Gemini CLI tiers shut down 2026-06-18 and are replaced by Antigravity CLI (binary agy). See the announcement. Without this patch the plugin breaks on that date for anyone on free / Google AI Pro / Ultra / Code Assist for individuals tiers.

agy is not a drop-in for gemini:

gemini flag agy equivalent
-p <prompt> -p <prompt> (or --prompt/--print)
-m <model> removed — set in ~/.gemini/antigravity-cli/settings.json or /model in TUI
--output-format text|json|stream-json removed — always text

How

  • scripts/gemini-bridge.js
    • New resolveBinary({ spawn }) that probes agy --version; returns "agy" on exit 0, "gemini" otherwise. Injectable spawn for testability.
    • New buildCliArgs({ prompt, model, format, binary, warn }) with binary-aware arg building. buildGeminiArgs is preserved as a thin wrapper for backward compatibility.
    • ensureBinaryInstalled now distinguishes between agy-missing and both-missing; install hint points at the Antigravity installer.
    • printResolvedCommand takes the resolved binary name so --print-command reflects reality.
  • tests/gemini-bridge.test.js: 4 new tests (agy arg-building, agy silent-when-clean, resolveBinary prefer-agy, resolveBinary fallback). All 9 tests pass with node --test.
  • README.md, SKILL.md, commands/gemini.md, agents/gemini-agent.md: install + auth instructions for agy (with the legacy gemini section kept until 2026-06-18); troubleshooting tables updated.

Test plan

  • npm test (node --test) — 9/9 pass (5 original + 4 new)
  • --print-command with agy on PATH → emits agy -p <prompt> (no extra flags)
  • --print-command with agy + --model X --format json → emits both warnings, drops both flags, resolved command is agy -p <prompt>
  • --print-command with agy removed from PATH → falls back to gemini -p <prompt> --output-format text
  • End-to-end run against authenticated agy (left to reviewer — requires interactive setup wizard for Google Sign-In)

Out of scope (deliberate)

  • Renaming the plugin, slash command, or skill to "antigravity-*" — breaks downstream references; better as a separate decision once the dust settles on Google's branding.
  • Passthrough for new agy flags (--add-dir, --sandbox, --print-timeout) — none are needed for the current bridge contract; can be added as a follow-up.

🤖 Generated with Claude Code

Google is retiring the consumer Gemini CLI on 2026-06-18 and replacing
it with Antigravity CLI (binary: agy). agy is not a drop-in: it accepts
-p like gemini, but removes -m / --output-format (model selection moves
to config or the TUI; output is always text).

The bridge now probes PATH and prefers agy when available, falling back
to gemini during the transition window. --model and non-text --format
values are accepted but warn-and-dropped on agy.

- scripts/gemini-bridge.js: new resolveBinary() probe; buildCliArgs()
  with binary-aware flag handling; updated ENOENT hint to point at the
  agy installer first.
- tests/gemini-bridge.test.js: 4 new tests covering both binaries.
- README.md / SKILL.md / commands/gemini.md / agents/gemini-agent.md:
  install + auth instructions for agy, legacy gemini section retained,
  troubleshooting tables updated.

References:
https://developers.googleblog.com/an-important-update-transitioning-gemini-cli-to-antigravity-cli

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request transitions the repository's shared Gemini bridge to support the new Antigravity CLI (agy), Google's successor to the Gemini CLI. The bridge now probes the system PATH to prefer agy when available, falling back to gemini as a legacy transition aid. Documentation, agent instructions, commands, and tests have been updated to reflect this transition, including warnings for unsupported flags like --model and --format when using agy. The review feedback recommends making the binary resolution more robust by wrapping the process spawn in a try-catch block to handle potential system errors, and defaulting the format parameter to "text" to prevent passing "undefined" as a string argument to the legacy CLI.

Comment thread scripts/gemini-bridge.js
Comment on lines +372 to +378
export function resolveBinary({ spawn = spawnSync } = {}) {
const probe = spawn("agy", ["--version"], { stdio: "ignore" });
if (probe.status === 0) {
return "agy";
}
return "gemini";
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Spawning a child process can throw an error (e.g., due to system limits, permission issues, or invalid environments). Additionally, if the spawn function returns null or undefined (such as in certain test mock setups), accessing probe.status directly will throw a TypeError. Wrapping the probe in a try-catch block and checking if probe is truthy ensures robust defensive programming.

export function resolveBinary({ spawn = spawnSync } = {}) {
  try {
    const probe = spawn("agy", ["--version"], { stdio: "ignore" });
    if (probe && probe.status === 0) {
      return "agy";
    }
  } catch {
    // Fall back to gemini if spawning fails or throws
  }
  return "gemini";
}

Comment thread scripts/gemini-bridge.js
Comment on lines +380 to +386
export function buildCliArgs({
prompt,
model,
format,
binary,
warn = (msg) => process.stderr.write(msg),
}) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

If format is not provided (or is undefined) by external callers of buildCliArgs or the exported buildGeminiArgs, args.push("--output-format", format) will append undefined to the arguments array. When spawned, this passes "undefined" as a string argument to the CLI, causing it to fail. Defaulting format to "text" in the destructuring signature prevents this issue and makes the API more robust.

export function buildCliArgs({
  prompt,
  model,
  format = "text",
  binary,
  warn = (msg) => process.stderr.write(msg),
}) {

@AllanHarlen
Copy link
Copy Markdown

I developed a solution in the cc-gemini-cli fork that bypasses some limitations and use cases.
https://github.com/AllanHarlen/cc-antigravity-plugin

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.

2 participants