Skip to content

Conversation

@konard
Copy link
Contributor

@konard konard commented Jan 10, 2026

Summary

  • Add Gemini CLI tool support similar to Claude Code CLI, Agent CLI, OpenCode CLI, Codex CLI
  • Implement both JavaScript and Rust versions for consistency with existing tools
  • Add manual E2E test workflow for testing with real Gemini CLI
  • Restructure Rust tests to separate files (like JavaScript) for better organization

Implementation Details

JavaScript (js/src/tools/gemini.mjs)

  • Model mapping for Gemini models (flash, pro, lite, 3-flash, 3-pro variants)
  • Build arguments support: prompt, model, yolo (auto-approve), sandbox, debug, checkpointing, json output
  • NDJSON output parsing for stream-json format
  • Session/conversation ID extraction
  • Usage statistics extraction (standard and Gemini-specific formats)
  • Error detection

Rust (rust/src/tools/gemini.rs)

  • Parallel implementation with JavaScript for consistency
  • GeminiBuildOptions, GeminiUsage, GeminiErrorResult structs
  • GeminiTool struct implementing the Tool trait
  • Full test coverage

E2E Testing (e2e-gemini.yml)

  • Manual workflow for testing with real Gemini CLI (free tier)
  • Configurable model selection (flash, pro, 3-flash)
  • Custom test prompts and verbose mode
  • Tests both JavaScript and Rust implementations
  • Graceful handling when API keys or Gemini CLI unavailable

Test Structure Improvements

  • Moved all Rust tests from embedded #[cfg(test)] modules to separate files in rust/tests/:
    • claude_tests.rs (20 tests)
    • gemini_tests.rs (25 tests)
    • agent_tests.rs (18 tests)
    • codex_tests.rs (15 tests)
    • opencode_tests.rs (13 tests)
    • tools_tests.rs (12 tests)
    • streaming_tests.rs (17 tests)
    • lib_tests.rs (10 tests)
  • This matches the JavaScript test structure in js/test/*.test.mjs

Model Mappings

Alias Full Model ID
flash gemini-2.5-flash
pro gemini-2.5-pro
lite gemini-2.5-flash-lite
3-flash gemini-3-flash-preview
3-pro gemini-3-pro-preview

Tool Features

Feature Support
JSON output ✅ (stream-json)
JSON input
System prompt ❌ (combined with user prompt)
Resume ✅ (via /chat resume)
Yolo mode ✅ (--yolo)
Sandbox ✅ (--sandbox)
Checkpointing ✅ (--checkpointing)
Debug ✅ (-d)

Test Plan

  • JavaScript tests pass (117 tests)
  • Rust tests pass (173 tests total: 43 unit + 130 integration)
  • Rust tests moved to separate files matching JS structure
  • ESLint passes (only pre-existing warnings)
  • Rust Clippy passes
  • Rust fmt check passes
  • Code duplication check passes
  • Prettier format check passes
  • Manual E2E workflow added for real CLI testing

E2E Testing Instructions

To run E2E tests with Gemini CLI:

  1. Add GEMINI_API_KEY or GOOGLE_API_KEY to repository secrets
  2. Go to Actions → "E2E Gemini CLI Test" workflow
  3. Click "Run workflow" and configure:
    • Model: flash (default), pro, or 3-flash
    • Test prompt: Custom prompt or use default
    • Enable/disable JS and Rust tests
    • Verbose mode for detailed output

Fixes #13

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #13
@konard konard self-assigned this Jan 10, 2026
- Add JavaScript Gemini tool implementation (js/src/tools/gemini.mjs)
  - Support for model mapping (flash, pro, 3-flash variants)
  - Build arguments with prompt, model, yolo, sandbox, debug, checkpointing, json output
  - NDJSON output parsing
  - Session/conversation ID extraction
  - Usage statistics extraction (standard and Gemini-specific formats)
  - Error detection

- Add Rust Gemini tool implementation (rust/src/tools/gemini.rs)
  - Parallel implementation with JS for consistency
  - GeminiBuildOptions, GeminiUsage, GeminiErrorResult structs
  - Full test coverage

- Update tool indexes to include gemini tool
- Add comprehensive tests for all Gemini functionality

Fixes #13

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@konard konard changed the title [WIP] Add Gemini CLI support Add Gemini CLI support Jan 10, 2026
@konard konard marked this pull request as ready for review January 10, 2026 16:13
@konard
Copy link
Contributor Author

konard commented Jan 10, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $5.920670 USD
  • Calculated by Anthropic: $4.680545 USD
  • Difference: $-1.240126 (-20.95%)
    📎 Log file uploaded as GitHub Gist (826KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Contributor Author

konard commented Jan 10, 2026

We should also check if link-assistant/hive-mind#559 has any useful ideas for that implementation.

Double check we do unit test everything we, can and it is executed in CI/CD. Also please add support for manual e2e tests (meaning it should be separate manually executed CI workflow) using free plan of Gemini CLI.

@konard konard marked this pull request as draft January 10, 2026 20:43
@konard
Copy link
Contributor Author

konard commented Jan 10, 2026

🤖 AI Work Session Started

Starting automated work session at 2026-01-10T20:43:20.253Z

The PR has been converted to draft mode while work is in progress.

This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback.

- Add new GitHub Actions workflow for manual E2E testing of Gemini CLI
  - Supports multiple model options (flash, pro, 3-flash)
  - Configurable test prompt and verbose mode
  - Tests both JavaScript and Rust implementations
  - Gracefully handles missing API keys or Gemini CLI
  - Generates test summary in workflow output

- Update model mappings for Gemini CLI:
  - Add 'lite' alias for gemini-2.5-flash-lite model
  - Add '3-pro' alias for gemini-3-pro-preview model
  - Update '3-flash' to use gemini-3-flash-preview (correct naming)
  - Add comments organizing models by generation

- Update tests for new model mappings

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@konard konard marked this pull request as ready for review January 10, 2026 20:52
@konard
Copy link
Contributor Author

konard commented Jan 10, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $5.562301 USD
  • Calculated by Anthropic: $3.613695 USD
  • Difference: $-1.948606 (-35.03%)
    📎 Log file uploaded as GitHub Gist (852KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Contributor Author

konard commented Jan 15, 2026

Both JavaScript and Rust versions must be implemented, have all the same tess. Make sure all our tests in Rust are in separate files, not mixed with code, like we do in JavaScript.

Also ensure all changes are correct, consistent and fully meet original requirements.

@konard konard marked this pull request as draft January 15, 2026 14:19
@konard
Copy link
Contributor Author

konard commented Jan 15, 2026

🤖 AI Work Session Started

Starting automated work session at 2026-01-15T14:19:44.788Z

The PR has been converted to draft mode while work is in progress.

This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback.

konard and others added 2 commits January 15, 2026 15:28
- Create rust/tests/ directory with separate test files:
  - claude_tests.rs (20 tests)
  - gemini_tests.rs (25 tests)
  - agent_tests.rs (18 tests)
  - codex_tests.rs (15 tests)
  - opencode_tests.rs (13 tests)
  - tools_tests.rs (12 tests)
  - streaming_tests.rs (17 tests)
  - lib_tests.rs (10 tests)
- Remove embedded #[cfg(test)] mod tests from source files
- All 173 Rust tests pass, matching JavaScript test structure
- Follows the same pattern as js/test/*.test.mjs files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@konard konard marked this pull request as ready for review January 15, 2026 14:57
@konard
Copy link
Contributor Author

konard commented Jan 15, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $7.139815 USD
  • Calculated by Anthropic: $5.617173 USD
  • Difference: $-1.522641 (-21.33%)
    📎 Log file uploaded as Gist (1113KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard konard merged commit ac40b85 into main Jan 17, 2026
44 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.

Add Gemini CLI support

2 participants