Skip to content

fix: resolve Gemini CLI command name with legacy fallback#338

Merged
subsy merged 1 commit intosubsy:mainfrom
medhatgalal:codex/fix-gemini-cli-resolution
Feb 25, 2026
Merged

fix: resolve Gemini CLI command name with legacy fallback#338
subsy merged 1 commit intosubsy:mainfrom
medhatgalal:codex/fix-gemini-cli-resolution

Conversation

@medhatgalal
Copy link
Copy Markdown
Contributor

@medhatgalal medhatgalal commented Feb 25, 2026

Why this fix

Selecting gemini in setup currently validates against the canonical command string stored by plugin metadata. In this repo, gemini users were hitting a mismatch because the binary installed by Google is gemini-cli.

What changed

  • Updated Gemini plugin metadata to keep internal plugin id unchanged while correcting the canonical command:
    • defaultCommand is now gemini-cli
    • Added commandAliases: ['gemini'] for legacy compatibility
  • Added shared base resolution logic so plugins can resolve:
    • explicit configured command override first
    • canonical command
    • legacy/alternate aliases
  • Improved command-not-found messaging to include acceptable command candidates.
  • Added targeted tests covering:
    • resolves gemini-cli
    • falls back to legacy gemini
    • configured explicit command
    • clear error listing both accepted names
    • setup wizard path selecting gemini now persists agent = "gemini" correctly
  • Updated Gemini docs from gemini to gemini-cli, with legacy alias note.

Compatibility map

  • Internal agent id remains gemini (no config migration impact).
  • Canonical command for detection/execution is gemini-cli.
  • Legacy gemini binary remains supported as fallback with a warning-style behavior through candidate selection logic.

Verification

  • bun run typecheck
  • bun run build
  • bun test tests/plugins/gemini-agent.test.ts src/plugins/agents/builtin/gemini.test.ts src/setup/wizard.test.ts

Notes

  • Behavior for kiro-cli and existing Codex/Claude flows unchanged.
  • No user home config writes were used during validation; tests use isolated PATH/config paths.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for command aliases, enabling legacy fallback names for CLI tools.
    • Improved error messaging to clearly indicate which commands are expected during detection failures.
  • Documentation

    • Updated references to reflect the Gemini CLI binary is now gemini-cli, with gemini supported as a legacy alias for backwards compatibility.

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 25, 2026

@medhatgalal is attempting to deploy a commit to the plgeek Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 25, 2026

Walkthrough

Introduces a unified command resolution system for agent plugins with support for default commands and legacy command aliases. The Gemini agent is updated to use gemini-cli as the primary command while maintaining backwards compatibility with the legacy gemini alias. Command resolution is integrated into the detection and sandboxing workflows.

Changes

Cohort / File(s) Summary
Command Resolution Infrastructure
src/plugins/agents/base.ts, src/plugins/agents/types.ts
Added new ResolvedCommand type and four helper methods (getCommandCandidates, getExpectedCommandNames, resolveCommandPath, getCommandNotFoundMessage) to centralise command resolution logic. Updated detect() method to use resolveCommandPath() for consistent executable path discovery and error reporting. Added commandAliases optional property to AgentPluginMeta interface to support fallback command names.
Gemini Agent Implementation
src/plugins/agents/builtin/gemini.ts, src/plugins/agents/builtin/gemini.test.ts
Updated defaultCommand from gemini to gemini-cli and added commandAliases: ['gemini'] for legacy support. Replaced findCommandPath() with resolveCommandPath() and adjusted executable path handling throughout. Updated test metadata expectations to reflect new command naming.
Test Infrastructure
src/setup/wizard.test.ts, tests/plugins/gemini-agent.test.ts
Added mockAgentPlugins collection and updated agent registry mocks to support new command resolution metadata. Introduced extensive test scaffolding utilities for temporary directories, PATH injection, and fake command execution. Expanded test coverage with detection scenarios validating default command, legacy alias fallback, explicit custom paths, and error messaging for missing commands.
Documentation
website/content/docs/plugins/agents/gemini.mdx
Updated all references from gemini to gemini-cli binary name across command defaults, version checks, build commands, and CLI examples. Added note documenting legacy gemini alias support as a fallback option.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: implementing command resolution for the Gemini CLI with legacy fallback support.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@medhatgalal medhatgalal force-pushed the codex/fix-gemini-cli-resolution branch from 3c20879 to b9e9d61 Compare February 25, 2026 06:21
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 25, 2026

Codecov Report

❌ Patch coverage is 55.81395% with 57 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.66%. Comparing base (39b506e) to head (b9e9d61).

Files with missing lines Patch % Lines
src/plugins/agents/base.ts 50.86% 57 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #338      +/-   ##
==========================================
+ Coverage   46.60%   46.66%   +0.05%     
==========================================
  Files         103      103              
  Lines       33301    33411     +110     
==========================================
+ Hits        15520    15590      +70     
- Misses      17781    17821      +40     
Files with missing lines Coverage Δ
src/plugins/agents/builtin/gemini.ts 56.59% <100.00%> (+11.44%) ⬆️
src/plugins/agents/base.ts 37.56% <50.86%> (-1.64%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/plugins/agents/builtin/gemini.ts (1)

170-173: Build the expected-command list from metadata instead of hard-coding it.

This message can drift if aliases evolve; using the base helper keeps one source of truth.

♻️ Proposed refactor
   protected override getCommandNotFoundMessage(): string {
-    return `Gemini CLI not found in PATH. Install from: https://github.com/google-gemini/gemini-cli` +
-      ' Expected one of `gemini-cli`, `gemini` (legacy alias)';
+    return (
+      'Gemini CLI not found in PATH. Install from: https://github.com/google-gemini/gemini-cli' +
+      ` Expected one of ${this.getExpectedCommandNames()}`
+    );
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/plugins/agents/builtin/gemini.ts` around lines 170 - 173, Replace the
hard-coded command names in getCommandNotFoundMessage() with the canonical list
derived from the agent metadata/helper: call the existing helper that returns
expected commands (e.g., getExpectedCommands() or the metadata property that
lists aliases) and join that list into the message string so it remains in sync
with the single source of truth, while still including the install URL and
descriptive text.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/plugins/agents/builtin/gemini.ts`:
- Around line 170-173: Replace the hard-coded command names in
getCommandNotFoundMessage() with the canonical list derived from the agent
metadata/helper: call the existing helper that returns expected commands (e.g.,
getExpectedCommands() or the metadata property that lists aliases) and join that
list into the message string so it remains in sync with the single source of
truth, while still including the install URL and descriptive text.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39b506e and b9e9d61.

📒 Files selected for processing (7)
  • src/plugins/agents/base.ts
  • src/plugins/agents/builtin/gemini.test.ts
  • src/plugins/agents/builtin/gemini.ts
  • src/plugins/agents/types.ts
  • src/setup/wizard.test.ts
  • tests/plugins/gemini-agent.test.ts
  • website/content/docs/plugins/agents/gemini.mdx

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ralph-tui Ready Ready Preview, Comment Feb 25, 2026 1:18pm

Request Review

@subsy subsy merged commit 3e5e51d into subsy:main Feb 25, 2026
9 checks passed
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