Add Antigravity CLI (agy) support with automatic gemini fallback#5
Add Antigravity CLI (agy) support with automatic gemini fallback#5MorpheusZA wants to merge 1 commit into
Conversation
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>
There was a problem hiding this comment.
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.
| export function resolveBinary({ spawn = spawnSync } = {}) { | ||
| const probe = spawn("agy", ["--version"], { stdio: "ignore" }); | ||
| if (probe.status === 0) { | ||
| return "agy"; | ||
| } | ||
| return "gemini"; | ||
| } |
There was a problem hiding this comment.
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";
}| export function buildCliArgs({ | ||
| prompt, | ||
| model, | ||
| format, | ||
| binary, | ||
| warn = (msg) => process.stderr.write(msg), | ||
| }) { |
There was a problem hiding this comment.
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),
}) {|
I developed a solution in the cc-gemini-cli fork that bypasses some limitations and use cases. |
Summary
PATHand prefersagy(Antigravity CLI) when installed, falling back togeminiso existing setups keep working during the transition window.--modeland non-text--formatvalues are accepted but warn-and-dropped whenagyis the resolved binary (model selection is config-only onagy; output is text-only).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.agyis not a drop-in forgemini:geminiflagagyequivalent-p <prompt>-p <prompt>(or--prompt/--print)-m <model>~/.gemini/antigravity-cli/settings.jsonor/modelin TUI--output-format text|json|stream-jsonHow
scripts/gemini-bridge.jsresolveBinary({ spawn })that probesagy --version; returns"agy"on exit 0,"gemini"otherwise. Injectable spawn for testability.buildCliArgs({ prompt, model, format, binary, warn })with binary-aware arg building.buildGeminiArgsis preserved as a thin wrapper for backward compatibility.ensureBinaryInstallednow distinguishes between agy-missing and both-missing; install hint points at the Antigravity installer.printResolvedCommandtakes the resolved binary name so--print-commandreflects 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 withnode --test.README.md,SKILL.md,commands/gemini.md,agents/gemini-agent.md: install + auth instructions foragy(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-commandwithagyon PATH → emitsagy -p <prompt>(no extra flags)--print-commandwithagy+--model X --format json→ emits both warnings, drops both flags, resolved command isagy -p <prompt>--print-commandwithagyremoved from PATH → falls back togemini -p <prompt> --output-format textagy(left to reviewer — requires interactive setup wizard for Google Sign-In)Out of scope (deliberate)
agyflags (--add-dir,--sandbox,--print-timeout) — none are needed for the current bridge contract; can be added as a follow-up.🤖 Generated with Claude Code