Skip to content

feat: add OpenCode as a summary provider - #2361

Merged
peyton-alt merged 3 commits into
mainfrom
summary-gen
Sep 15, 2026
Merged

peyton-alt merged 3 commits into
mainfrom
summary-gen

Conversation

@peyton-alt

@peyton-alt peyton-alt commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

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-sol works for explain --generate and runner 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 actual runner setup --run flow 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 opencode with 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 --generate and runner tuning the same way as other summary CLIs, selectable via entire configure --summarize-provider opencode (optional --summarize-model).

The new adapter implements TextGenerator by running opencode run in an isolated temp directory with prompts on stdin, parsing JSON text events (and failing on embedded API errors even when the process exits 0). It injects a one-off agent config via OPENCODE_CONFIG_CONTENT that 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.

@peyton-alt
peyton-alt requested a review from a team as a code owner September 10, 2026 19:45
Copilot AI lite review requested due to automatic review settings September 10, 2026 19:45
Entire-Checkpoint: 01M26DK1CD43X78H24HFGQBBZT

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 TextGenerator implementation that runs opencode run --format json, parses text/error events, and wraps failures with TextGenerationError metadata.
  • Extend the isolated text-generator runner to accept environment overrides and register opencode as 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.

Comment thread cmd/entire/cli/agent/text_generator_cli.go
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>
@peyton-alt
peyton-alt merged commit 21155be into main Sep 15, 2026
16 checks passed
@peyton-alt
peyton-alt deleted the summary-gen branch September 15, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants