Repository navigation
feat: add OpenCode as a summary provider - #2361
Conversation
Entire-Checkpoint: 01M26DK1CD43X78H24HFGQBBZT
There was a problem hiding this comment.
🟡 Changes recommended
Environment override handling in RunIsolatedTextGeneratorCLI does not actually guarantee override precedence (can leave duplicate keys), which can prevent critical overrides like OPENCODE_CONFIG_CONTENT from taking effect.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adds OpenCode as a supported summary-generation provider so it can be selected via entire configure --summarize-provider opencode (optionally --summarize-model ...) and used by explain --generate and runner setup --run. It integrates OpenCode by running opencode run in an isolated temp directory, sending prompts via stdin, parsing JSON event output, and preserving user provider/model config (including JSONC) while enforcing a restricted agent config (no tools, sharing disabled).
Changes:
- Add an OpenCode
TextGeneratorimplementation that runsopencode run --format json, parsestext/errorevents, and wraps failures withTextGenerationErrormetadata. - Extend the isolated text-generator runner to accept environment overrides and register
opencodeas a summary-capable binary. - Update configuration/help text and add unit coverage validating selection, settings persistence, and runner tuning integration.
File summaries
| File | Description |
|---|---|
| go.mod | Adds github.com/tailscale/hujson dependency for JSONC-compatible OpenCode config merging. |
| go.sum | Records checksums for the new hujson dependency. |
| cmd/entire/cli/setup.go | Updates --summarize-provider help text to include opencode. |
| cmd/entire/cli/setup_test.go | Adjusts invalid-provider test now that opencode is a valid summarize provider. |
| cmd/entire/cli/opencode_summary_test.go | Adds an end-to-end-ish unit test covering configure + provider selection + runner tuning using OpenCode. |
| cmd/entire/cli/explain_summary_provider.go | Updates “no providers available” error text to include opencode. |
| cmd/entire/cli/agent/text_generator_cli.go | Adds env override support to the isolated CLI runner and registers opencode as a summary binary. |
| cmd/entire/cli/agent/text_generator_cli_test.go | Adds a test asserting env overrides apply and GIT_* variables are stripped. |
| cmd/entire/cli/agent/opencode/opencode.go | Adds injectable CommandRunner to OpenCode agent for testing text generation. |
| cmd/entire/cli/agent/opencode/generate.go | Implements OpenCode summary generation via opencode run + JSON event parsing + restricted config injection. |
| cmd/entire/cli/agent/opencode/generate_test.go | Adds unit tests for OpenCode text generation, output parsing, config merging (incl. JSONC), and cancellation behavior. |
Review details
- Files reviewed: 10/11 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
8a3ee75 to
daa1e29
Compare
Resolve conflicts in explain_summary_provider.go (keep main's comment on why binary names are spelled out, keep this branch's message that lists opencode) and go.mod (take main's layout; `go mod tidy` re-adds hujson at the same pinned version). Follow-ups from main's summary-provider guard rails now that opencode can generate text: - TestSummaryCapableProviderNames_MatchesTheBuiltInAgents expects opencode - README lists opencode as an accepted provider and drops it from the "cannot generate summaries" note - doctor's help text and the real-registry doctor test use factoryai-droid as the incapable example instead of opencode - a shared openCodeBinary constant replaces three "opencode" literals (goconst) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Picks up dbaa7e7, which fixes TestRunStatus_CheckpointPushDisabledDestinations on main. The branch's previous merge landed on e8780c3 (#2342), the exact main commit that broke that test, so the PR's CI was red for a failure it did not introduce. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
https://entire.io/gh/entireio/cli/trails/1298
OpenCode is supported for session tracking but cannot currently generate summaries or tailor runners. Add it to the existing summary-provider selection and validation so
entire configure --summarize-provider opencode --summarize-model openai/gpt-5.6-solworks forexplain --generateandrunner setup --run. Omitting the model uses OpenCode's default; Pi and the existing picker are unchanged.The adapter sends prompts through stdin, parses OpenCode JSON events (including API errors emitted with exit code zero), and runs with a temporary directory and a dedicated agent that denies tools and disables sharing. Existing provider/auth/model configuration is retained, including JSONC inline configuration.
Validation: affected unit tests and independent review passed. Live calls through OpenCode with ChatGPT (
openai/gpt-5.6-sol) passed both the real summary parser and the actualrunner setup --runflow in an isolated fixture repository, including a saved runner and preserved placeholders. Pre-push lint passed. The complete unit/integration race suite passed in a space-free verification checkout; canary validation is delegated to CI at the author’s request.Note
Medium Risk
Spawns external
opencodewith merged user config for summaries; subprocess and config parsing bugs could affect explain/runner flows, but scope is isolated from git hooks and repo mutation.Overview
OpenCode can now power
explain --generateand runner tuning the same way as other summary CLIs, selectable viaentire configure --summarize-provider opencode(optional--summarize-model).The new adapter implements
TextGeneratorby runningopencode runin an isolated temp directory with prompts on stdin, parsing JSONtextevents (and failing on embedded API errors even when the process exits 0). It injects a one-off agent config viaOPENCODE_CONFIG_CONTENTthat denies tools and disables sharing while preserving the user’s provider/model settings (including JSONC), and extends the shared isolated CLI helper with optional environment overrides.Reviewed by Cursor Bugbot for commit 8a3ee75. Configure here.