Conversation
added 5 commits
April 14, 2026 21:53
Add opencode as a new backend option alongside api, cli, and acp. The OpenCode backend invokes `opencode -p <prompt> --output-format text --quiet` and streams stdout using the same scanChunks splitter as the Claude CLI backend. - New file: internal/backend/opencode.go - Config: OpenCodePath field with INLINE_CLI_OPENCODE_PATH env var override - Server: "opencode" case in createBackend() switch
…-p`) The opencode CLI uses `opencode run <message>` for non-interactive mode, not `-p` which maps to `--password`. Also pass `--model` when provided.
opencode's default format writes to stderr with ANSI codes (TUI). Using `--format json` produces newline-delimited JSON events on stdout with types: step_start, text, step_finish. Parse these and extract text from "text" events. Also passes --model flag when provided and updates all tests to emit JSON events matching the real opencode output format.
Two issues caused empty responses: 1. The default model (claude-sonnet-4-20250514) was passed via --model to opencode, which uses a different provider/model format. opencode returned a JSON error event that was silently ignored. 2. Error events (type:"error") were not handled, so failures produced empty responses with no error message. Fix: stop passing --model (let opencode use its own default) and parse error events to surface meaningful error messages.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add OpenCode (
opencode) as a new backend for inline-cli, enabling users to route queries through the OpenCode CLI.internal/backend/opencode.go— implements theBackendinterface by invokingopencode run --format json <message>and parsing the newline-delimited JSON event stream from stdouttype:"text"events and surfacestype:"error"events as Go errors--modelsince opencode uses a differentprovider/modelformat)opencode_pathin TOML /INLINE_CLI_OPENCODE_PATHenv var for custom binary path"opencode"case intocreateBackend()ininternal/daemon/server.goFiles changed
internal/backend/opencode.gointernal/backend/opencode_test.gointernal/config/config.goOpenCodePathfield and env var overrideinternal/config/config_test.gointernal/daemon/server.go"opencode"case tocreateBackend()internal/daemon/server_test.goUsage
Or via environment variable:
export INLINE_CLI_BACKEND=opencodeTest plan
go build ./...passesgo test ./... -racepasses (11 backend tests + config + daemon tests)inline-cli query -p "say hi"returns response via opencode