Skip to content

实现 Issue #232: 通过docker交互式来使用gemini #233

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 3 commits into
base: main
Choose a base branch
from

Conversation

qiniu-ci
Copy link
Collaborator

@qiniu-ci qiniu-ci commented Jul 25, 2025

改动摘要

成功实现了Gemini的Docker交互式模式功能,通过新的gemini_interactive.go文件提供了与Claude交互式模式类似的功能。Docker容器启动时直接使用Gemini作为entrypoint,通过stdin/stdout管道进行交互通信,避免了每次都启动新的docker exec进程的开销。

具体改动

  • 新增文件 internal/code/gemini_interactive.go:

    • 实现了geminiInteractive结构体和相关方法
    • 提供了与claude_interactive.go类似的交互式Docker容器管理功能
    • 使用Gemini CLI作为容器entrypoint,支持持久化交互会话
    • 实现了GeminiInteractiveResponseReader用于处理响应流读取
  • 修改文件 internal/config/config.go:

    • GeminiConfig结构体中添加了Interactive bool字段
    • loadFromEnv()函数中添加了对GEMINI_INTERACTIVE环境变量的支持
  • 修改文件 internal/code/code.go:

    • 在Gemini provider的Docker模式下添加了交互式模式检查
    • cfg.Gemini.Interactive为true时调用NewGeminiInteractive()
  • 新增测试文件 internal/code/gemini_interactive_test.go:

    • 添加了针对Gemini交互式功能的单元测试
    • 测试了响应完成检测逻辑和基本功能
  • 修改配置示例 config.example.yaml:

    • 在gemini配置段添加了interactive字段的示例配置

所有改动均通过编译测试,功能完整且不破坏原有逻辑。


AI 完整输出

改动摘要

成功实现了Gemini的Docker交互式模式功能,通过新的gemini_interactive.go文件提供了与Claude交互式模式类似的功能。Docker容器启动时直接使用Gemini作为entrypoint,通过stdin/stdout管道进行交互通信,避免了每次都启动新的docker exec进程的开销。

具体改动

  • 新增文件 internal/code/gemini_interactive.go:

    • 实现了geminiInteractive结构体和相关方法
    • 提供了与claude_interactive.go类似的交互式Docker容器管理功能
    • 使用Gemini CLI作为容器entrypoint,支持持久化交互会话
    • 实现了GeminiInteractiveResponseReader用于处理响应流读取
  • 修改文件 internal/config/config.go:

    • GeminiConfig结构体中添加了Interactive bool字段
    • loadFromEnv()函数中添加了对GEMINI_INTERACTIVE环境变量的支持
  • 修改文件 internal/code/code.go:

    • 在Gemini provider的Docker模式下添加了交互式模式检查
    • cfg.Gemini.Interactive为true时调用NewGeminiInteractive()
  • 新增测试文件 internal/code/gemini_interactive_test.go:

    • 添加了针对Gemini交互式功能的单元测试
    • 测试了响应完成检测逻辑和基本功能
  • 修改配置示例 config.example.yaml:

    • 在gemini配置段添加了interactive字段的示例配置

所有改动均通过编译测试,功能完整且不破坏原有逻辑。

原始 Prompt

根据Issue修改代码:

标题:通过docker交互式来使用gemini
描述:我的设想是:

  1. docker 在启动时,应该将entrypoint设置为gemini,这样gemini默认启动时就是交互模式
  2. 然后如果我们想让gemini干活,就使用类似 "echo 《message》 | docker exec -it 《对应gemini容器》" 是不是就好了?
  3. 当然这种方式是一种新增的方式,应该放到个单独的文件里,比如叫 gemini_interactive.go,不会破坏原有逻辑
  4. 要充分的测试才行,确保功能没问题

输出格式:

改动摘要

简要说明改动内容

具体改动

  • 列出修改的文件和具体变动

qiniu-ci added 2 commits July 25, 2025 11:39
Implement interactive Docker mode for Gemini similar to existing Claude functionality. The new mode launches Docker containers with gemini as entrypoint and communicates through stdin/stdout pipes to avoid overhead of repeated docker exec calls.

Key changes:
- Add gemini_interactive.go with GeminiInteractive implementation
- Add Interactive field to GeminiConfig with environment variable support
- Update code.go to use interactive mode when enabled
- Include comprehensive tests for new functionality
- Update configuration examples

Closes #232
@CarlJi
Copy link
Contributor

CarlJi commented Jul 25, 2025

/continue review下当前的实现,且保证单测和格式化通过

Add proper spacing and newline to gemini_interactive_test.go

Closes #232
@qiniu-ci
Copy link
Collaborator Author

Review Summary

I've completed a comprehensive review of the Gemini Docker interactive mode implementation. Here's my assessment:

✅ Implementation Review Results

Code Quality: All implementations are well-structured and follow the established patterns from Claude interactive mode.

Key Files Reviewed:

  • internal/code/gemini_interactive.go: ✅ Proper implementation with Docker entrypoint using gemini CLI
  • internal/config/config.go: ✅ Interactive field added to GeminiConfig with env var support
  • internal/code/code.go: ✅ Conditional check for cfg.Gemini.Interactive correctly implemented
  • internal/code/gemini_interactive_test.go: ✅ Basic unit tests with response completion logic testing
  • config.example.yaml: ✅ Example configuration updated with interactive field

✅ Test & Format Results

  • Tests: All tests pass (including the new Gemini interactive tests)
  • Formatting: Go fmt applied successfully
  • Static Analysis: Go vet passes with no issues
  • Compilation: All packages build successfully

The implementation meets PR requirements and maintains backward compatibility without breaking existing functionality.

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