Skip to content

Latest commit

 

History

History
70 lines (54 loc) · 4.25 KB

File metadata and controls

70 lines (54 loc) · 4.25 KB

PRD: Migrating Auto-Code from Claude to Gemini CLI

1. Executive Summary

This document outlines the requirements and implementation plan for migrating the auto-code platform's primary LLM provider from Anthropic's Claude to Google's Gemini, utilizing the gemini-cli framework. The goal is to decouple the system from the specific claude-agent-sdk and introduce a provider-agnostic architecture that treats Gemini as a first-class citizen, matching the existing ecosystem features (MCP support, efficient context management, and CLI-based tools).

2. Problem Statement

The current auto-code backend is tightly coupled to the claude-agent-sdk, making it difficult to switch providers or leverage alternative LLMs like Gemini or Codex. client.py directly imports and instantiates ClaudeSDKClient, and the frontend settings are hardcoded for Claude models (Opus, Sonnet, Haiku). This vendor lock-in limits cost optimization, model choice, and platform flexibility.

3. Goals & Objectives

  • Complete Migration: Fully remove claude-agent-sdk and all Claude-specific code.
  • Integrate Gemini CLI: Implement a robust adapter for gemini-cli content generation and chat.
  • Maintain Parity: Ensure critical features like MCP (Model Context Protocol) support remain functional with Gemini.
  • Update UI: Reflect the new provider options in the frontend settings.

4. Technical Architecture

4.1. The Abstract Agent Client

We will introduce a protocol AgentClient in apps/backend/core/clients/base.py that defines the contract for all AI agents.

class AgentClient(Protocol):
    async def query(self, prompt: str) -> Any: ...
    async def receive_response(self) -> AsyncGenerator[AgentMessage, None]: ...

4.2. Gemini Adapter (GeminiHub)

A new client implementation apps/backend/core/clients/gemini.py which will wrap gemini-cli subprocess calls if preferred for specific features.

  • Key Dependencies: gemini-cli (CLI)
  • Authentication: OAuth (handled via login)
  • Context Window: Leverage Gemini 3.0 Pro preview and 3 flash preview's 1M context window for superior whole-project analysis.

4.3. Client Factory Refactor

Refactor apps/backend/core/client.py:

  • New: Reads settings.agentFramework (or similar config).
    • Returns GeminiClient (default and only option).

5. Implementation Plan

Phase 1: Backend Infrastructure (Backend)

  1. Define Protocol: Create core/clients/base.py.
  2. Create Adapter: Implement core/clients/gemini.py using gemini-cli.
  3. Update Factory: Modify create_client in core/client.py to support the change.
  4. CLI Updates: Update insights_runner.py and simple_client.py to use the factory instead of direct imports.

Phase 2: Frontend & Configuration (Frontend)

  1. Update Constants: Modify shared/constants/models.ts:
    • Add gemini-3.0-pro, gemini-3.0-flash to AVAILABLE_MODELS.
    • Add Gemini to THINKING_LEVELS (using Gemini's reasoning capabilities if available, or mapping "thinking" to "detailed prompting").
  2. Settings UI: Update GeneralSettings.tsx:
    • Use "Gemini" as the Agent Framework dropdown.
    • Add input field for GOOGLE_API_KEY / or performing login.

Phase 3: Validation & Migration

  1. Unit Tests: Verify GeminiClient adheres to the AgentClient protocol.
  2. Integration Tests: Run the insights_runner.py with the --model gemini-3.0-pro flag to verify chat works.
  3. Documentation: specific instructions in QUICK_START_GEMINI.md.

6. functional Requirements

  • System Prompt: support injecting GEMINI.md (renamed to AGENT.md or similar) content into Gemini's system instruction.
  • MCP Support: The Gemini adapter MUST support tool calling. We will translate internal MCP tool definitions into Gemini's tools schema (Function Declarations) or use the OOTB capabilities of Gemini.

7. Success Metrics

  • Users can switch to Gemini 3.0 Pro in settings.
  • Insights Chat returns valid answers about the codebase using Gemini.
  • Legacy Claude functionality is completely removed and replaced.

8. References