fix(opencode): support the OpenCode 2 CLI and plugin API - #2397
Open
aryasaatvik wants to merge 4 commits into
Open
fix(opencode): support the OpenCode 2 CLI and plugin API#2397aryasaatvik wants to merge 4 commits into
aryasaatvik wants to merge 4 commits into
Conversation
OpenCode 2 moved session export/import under `session` and changed the export schema (messages carry a type plus typed content instead of info/parts). Entire only ran `opencode export`, which OpenCode 2 answers with a help page and exit 0, so no transcript was ever cached. Try the OpenCode 2 command first and validate the output before accepting it, falling back to the v1 command. Normalize both export shapes to the v1 model the readers use, and keep chunking/reassembly byte-preserving so the stored raw transcript stays importable. Teach the condensed transcript path the v2 shape.
The generated plugin used OpenCode 1's server-hook export, which OpenCode 2 rejects with PluginModule.LoadError. Emit a V2 plugin definition (id + setup) instead: session hooks replace the system-transform hook, the event subscription replaces the event map, and session-end moves to plugin unload. The SDK import is type-only so the loader does not resolve project node_modules. Drops OpenCode 1 plugin support.
Extract the repeated "text"/"tool" content-part literals into constants so golangci-lint's goconst passes. Entire-Checkpoint: 01M2B6RF3CPRJFRGH3081SQ0PW
Preserve a classified export error through the v1 fallback so a missing session still reports "was not found" instead of the generic invalid-output message. Accept OpenCode 2's "opencode v2.0.2" version output and skip the OpenCode 1 plugin-dep seeding on major 2, where the V2 plugin API comes from the binary. Import the SDK types from the public @opencode/plugin entry rather than the internal promise/plugin subpath. Entire-Checkpoint: 01M2B7PXTQDXJNCP96Z1Q9YTEB
aryasaatvik
marked this pull request as ready for review
September 12, 2026 16:43
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
OpenCode 2 is GA and incompatible with Entire's OpenCode integration in two places, so no transcript was ever captured: the generated plugin used the OpenCode 1 server-hook export (rejected with
PluginModule.LoadError), and the CLI ranopencode export, which OpenCode 2 answers with a help page and exit 0. This makes the integration target OpenCode 2 end to end.Changes
id+setup): session hooks replaceexperimental.chat.system.transform, the event subscription replaces the event map, andsession-endmoves to plugin unload. The SDK types are imported type-only from the public@opencode/pluginentry, so the loader never resolves projectnode_modules. Drops OpenCode 1 plugin support.opencode session export/session import(OpenCode 2), validate the export before accepting it, and fall back toopencode export/import(OpenCode 1). A classified failure from the OpenCode 2 attempt (e.g. "Session not found") is preserved rather than overwritten by the fallback's invalid output.info/partsvstype/contentplus a message-leveltext) to the v1 model for reads, and keep chunking/reassembly byte-preserving so the stored raw transcript stays importable byopencode session import.opencode v2.0.2version output, and skip the OpenCode 1 plugin-dependency seeding on major ≥ 2, where the V2 API is provided by the binary.Flow
Review notes
opencode session export(messages, prompts, modified files, tokens) and an end-to-end hook run in a scratch repo that wrote a 2 MB.entire/tmp/<id>.json.