Skip to content

feat: add Gemini-CLI provider support #6044

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

roomote[bot]
Copy link

@roomote roomote bot commented Jul 22, 2025

Implements #6043 - Adds support for using Google Gemini models through the Gemini CLI, providing free access to Gemini Pro via Google Code Assist.

Summary

This PR adds a new provider that interfaces with the Gemini CLI tool, allowing users to access Google Gemini models including the free tier through Google Code Assist.

Changes

  • New Provider Implementation: Added GeminiCliHandler class that interfaces with the gemini CLI command
  • OAuth Authentication: Handles browser-based OAuth flow for first-time users
  • Telemetry Collection: Implements token usage tracking by parsing CLI stderr output
  • UI Configuration: Added settings UI component for configuring project ID (for paid accounts)
  • Type Definitions: Added proper TypeScript types and model configurations
  • Test Coverage: Comprehensive unit tests for all provider functionality

Features

  • ✅ Support for all Gemini models (Flash, Pro, Experimental)
  • ✅ Free tier access through Google Code Assist
  • ✅ Paid tier support with project ID configuration
  • ✅ Automatic OAuth authentication handling
  • ✅ Token usage tracking and cost calculation
  • ✅ Image support in messages

Testing

  • All new tests pass successfully
  • Existing test suite remains green
  • Type checking passes
  • Linting passes

Usage

  1. Install the Gemini CLI: npm install -g @google/generative-ai-cli
  2. Select "Gemini-CLI" as your provider in Roo-Code settings
  3. On first use, you will be prompted to authenticate in your browser
  4. For paid accounts, optionally configure your Google Cloud project ID

Fixes #6043


Important

Adds GeminiCliHandler to support Google Gemini models via CLI with OAuth, telemetry, and UI configuration.

  • New Provider:
    • Adds GeminiCliHandler in gemini-cli.ts to interface with gemini CLI.
    • Supports all Gemini models (Flash, Pro, Experimental) with free tier access via Google Code Assist.
    • Handles OAuth authentication and token usage tracking.
  • UI and Configuration:
    • Adds GeminiCli component in GeminiCli.tsx for UI settings.
    • Updates ApiOptions.tsx and constants.ts to include Gemini CLI provider.
  • Testing and Types:
    • Comprehensive tests in gemini-cli.spec.ts for provider functionality.
    • Adds TypeScript types for models in gemini-cli.ts.

This description was created by Ellipsis for 41d96f1. You can customize this summary. It will automatically update as commits are pushed.

- Add GeminiCliHandler class to interface with gemini CLI tool
- Implement OAuth authentication flow handling
- Add telemetry collection for token usage tracking
- Create UI component for provider configuration
- Add comprehensive test coverage for the provider
- Support both free and paid (project ID) usage modes

Fixes #6043
@roomote roomote bot requested review from mrubens, cte and jr as code owners July 22, 2025 04:12
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. enhancement New feature or request labels Jul 22, 2025
@@ -0,0 +1,311 @@
import { spawn, ChildProcess } from "child_process"
import { Anthropic } from "@anthropic-ai/sdk"
import * as vscode from "vscode"
Copy link

Choose a reason for hiding this comment

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

Remove unused import 'vscode' as it isn’t used in this provider.

Suggested change
import * as vscode from "vscode"

This comment was generated because it violated a code review rule: irule_Vw7dJWzvznOJagxS.

if (needsAuth) {
yield {
type: "text",
text: "Please authenticate with Google in your browser. Once authenticated, please retry your request.",
Copy link

Choose a reason for hiding this comment

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

Internationalize user-facing authentication message instead of hardcoding plain text.

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

const usage = this.currentRequestId ? this.telemetryCollector.get(this.currentRequestId) : undefined

resolve({ text, usage })
} catch (error) {
Copy link

Choose a reason for hiding this comment

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

Consider logging the error caught during JSON parsing to aid debugging instead of silently falling back.

This comment was generated because it violated a code review rule: irule_PTI8rjtnhwrWq6jS.

return (
<>
<div className="text-sm text-vscode-descriptionForeground">
Use Google Gemini models through the Gemini CLI, which provides free access to Gemini Pro through Google
Copy link

Choose a reason for hiding this comment

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

Wrap user-facing texts in translation functions to support internationalization.

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 22, 2025
@fridaystreet
Copy link

@hannesrudolph so what happens with this? It;'s just going to implement it itself? So you don't want my PR?

@roomote roomote bot mentioned this pull request Jul 22, 2025
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
Status: Triage
Development

Successfully merging this pull request may close these issues.

Add Gemini-CLI provider
3 participants