Skip to content

fix: opencode plugin loading, native binding self-heal, variants, plan mode#8

Merged
justin-carper merged 5 commits into
mainfrom
fix/opencode-integration
Jun 10, 2026
Merged

fix: opencode plugin loading, native binding self-heal, variants, plan mode#8
justin-carper merged 5 commits into
mainfrom
fix/opencode-integration

Conversation

@justin-carper

Copy link
Copy Markdown
Collaborator

What

Five fixes from live testing against opencode 1.16.2:

  • fix: add ./server export so opencode loads plugin — opencode resolves a plugin entrypoint only from exports["./server"] or main; neither existed, so the package installed but registered zero hooks (no provider, no models). README install spec corrected to the bare package name.
  • fix: self-heal missing sqlite3 native binding — opencode installs plugins with bun, which skips sqlite3's install script; @cursor/sdk's eager require("sqlite3") then crashes ("Could not locate the bindings file"). The plugin now detects the missing binding before SDK load and runs sqlite3's own prebuild-install -r napi under the system Node. One attempt per process, never throws, logs a manual fix on failure.
  • fix(stream): close text part when reasoning resumes — interleaved text → reasoning → text appended the final answer into the first text part, rendering it above the thinking blocks. Text parts now close when reasoning starts; each resume gets a fresh text-N part.
  • feat(models): seed thinking variants in config models map — opencode silently discards the provider.models() hook for providers outside its models.dev catalog, so variants must ride on the config-seeded models. Variant naming reworked against the real catalog: boolean params collapse to a single param-named variant (no more literal true/false), enum params key by bare value, and the plan variant is gone (plan is opencode's agent).
  • feat(plugin): map plan agent to Cursor plan modechat.params fires post-variant-merge, so the agent default never clobbers an explicit mode.

Testing

  • 121 tests pass (21 new), tsc --noEmit clean, tsup build clean.
  • Empirically verified end-to-end against opencode 1.16.2: provider registration, live model catalog, chat with native tool calls (Node sidecar), variant picker, plan-agent mapping, and stream part ordering.
  • sqlite3 repair verified against a real broken bun-installed tree.

opencode resolves a plugin's entrypoint only from exports["./server"]
or main; neither existed, so the package installed but registered no
hooks and the cursor provider never appeared. Keep ./plugin for
back-compat and correct the README install spec (bare package name).
opencode installs plugin packages with bun, which skips sqlite3's
install script, so @cursor/sdk's eager require("sqlite3") crashes with
"Could not locate the bindings file". Before loading the SDK (in-process
or sidecar), detect the missing binding and run sqlite3's own
prebuild-install -r napi under the system Node. One attempt per
process; failures log a manual fix and never throw.
Hosts position a part where it starts; appending later deltas to one
long-lived text part rendered the final answer above the thinking
blocks that preceded it. Close the open text part when reasoning
begins and start a fresh text-N part for each resume.
opencode discards the provider.models() hook for providers outside its
models.dev catalog, so config-seeded models are the only channel for
variants — toOpencodeModels now includes them.

Rename variants against the real catalog shapes: boolean params
(thinking=[false,true]) collapse to one param-named variant instead of
literal true/false; enum params (effort, reasoning) key by bare value
with id-prefix only on collision. Drop the plan variant — plan is
opencode's plan agent, mapped via chat.params.
chat.params fires after opencode merges the selected variant, so the
agent-based default only applies when no explicit mode was chosen.
@justin-carper justin-carper merged commit 2e98307 into main Jun 10, 2026
6 checks passed
@justin-carper justin-carper deleted the fix/opencode-integration branch June 10, 2026 22:51
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