Skip to content

feat: add Gemini CLI backend support#4

Merged
CCALITA merged 4 commits intomainfrom
feat/gemini-backend
Apr 15, 2026
Merged

feat: add Gemini CLI backend support#4
CCALITA merged 4 commits intomainfrom
feat/gemini-backend

Conversation

@CCALITA
Copy link
Copy Markdown
Owner

@CCALITA CCALITA commented Apr 14, 2026

Summary

Add Gemini CLI (gemini) as a new backend for inline-cli, enabling users to route queries through the Google Gemini CLI.

  • New internal/backend/gemini.go — implements the Backend interface by invoking gemini -p <prompt> -o text and streaming plain text stdout
  • Lazy binary resolution (resolves PATH on each query, not at construction)
  • Does not pass --model — lets gemini use its own configured default
  • Captures stderr on failure to surface meaningful error messages instead of generic "exit status 1"
  • Conversation history is prepended to the prompt for multi-turn context
  • Config: gemini_path in TOML / INLINE_CLI_GEMINI_PATH env var for custom binary path
  • Wired "gemini" case into createBackend() in internal/daemon/server.go

Files changed

File Change
internal/backend/gemini.go New backend implementation with stderr capture
internal/backend/gemini_test.go 9 tests: constructor, PATH resolution, query, history, error handling with/without stderr
internal/config/config.go Added GeminiPath field and env var override
internal/daemon/server.go Added "gemini" case to createBackend()

Usage

# ~/.inline-cli/config.toml
backend = "gemini"
# gemini_path = "/custom/path/to/gemini"  # optional

Or via environment variable:

export INLINE_CLI_BACKEND=gemini

Test plan

  • go build ./... passes
  • go test ./... -race passes (9 backend tests)
  • Verified correct CLI flags: gemini -p <prompt> -o text
  • Does not pass invalid model string to gemini
  • Stderr captured and surfaced in error messages

fanxiyao.3 added 4 commits April 14, 2026 22:10
Add Google Gemini CLI as a new backend option for inline-cli.
The gemini backend follows the same lazy-resolution pattern as the
existing CLIBackend, invoking `gemini -p <prompt>` and streaming
stdout chunks for real-time output.

Changes:
- internal/backend/gemini.go: new GeminiBackend implementation
- internal/config/config.go: add GeminiPath config field and
  INLINE_CLI_GEMINI_PATH env var override
- internal/daemon/server.go: wire "gemini" case in createBackend()
The gemini CLI needs -o text to ensure plain text on stdout. Also skip
passing --model since the inline-cli default (claude-sonnet) is invalid
for gemini. Add 8 tests covering construction, resolution, query,
history, and error handling.
Instead of showing a generic "exit status 1", capture stderr and
surface the first line in the error message (e.g. the actual API
error from gemini). Falls back to the generic message if stderr
is empty.
Keep both gemini and opencode backend entries in config and server.
@CCALITA CCALITA merged commit 9293ee5 into main Apr 15, 2026
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.

1 participant