anomalyco / anomalyco/opencode
Desktop app silently fails to load plugins that import "bun:sqlite"
@Hona is already working on this.
Since Aug 11, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Summary
The OpenCode desktop app (1.18.15) loads plugins inside an Electron utilityProcess (Node runtime). The CLI is a Bun binary. The Node plugin host has a Bun-compatible shim for the $ shell but no bun:sqlite module — so any plugin with a runtime bun: import fails to load, and the failure is completely silent.
Repro
~/.opencode/opencode.json:
{ "plugin": [".opencode/plugins/worktree.ts"] }
worktree.ts imports ./worktree/state, and worktree/state.ts:11 does import { Database } from "bun:sqlite" (value import).
Restart the desktop app. The plugin entry appears in the plugins list (the count increments), but its tools never register and no error is visible.
Evidence
- Every successfully imported plugin emits a
MODULE_TYPELESS_PACKAGE_JSONwarning toserver.log.worktree.tsdoes not — its module graph is never evaluated (verified in~/.config/ai.opencode.desktop/logs/<ts>/server.log). - No plugin error in
server.log,renderer.log,main.log, oropencode.log. - Root cause of the silence: load failures call
publishPluginErrorinpackages/opencode/src/plugin/index.ts, which only emits aSession.Event.Error. The desktop renderer does not consume that event, so nothing is shown or logged. - The same plugin works under the CLI (
~/.opencode/bin/opencode, Bun) wherebun:sqliteis native. - Loaded-plugin comparison:
rtk.ts(type-only import, loads),graphify.js(Node builtins only, loads),worktree.ts(bun:sqlitevalue import, does not).
Impact
Any bun:sqlite-based plugin — e.g. the kdco/worktree OCX plugin — cannot run in the desktop app. Node 20 (Electron 30) has no node:sqlite either.
Suggested fixes
- Surface load failures (bug): log the error (stderr / server log) and/or surface it in the desktop UI so users see why a plugin did not load. Today it is invisible.
- Provide
bun:sqlitein the Node host: a shim implementing the API subset plugins use (new Database(path),exec,prepare().get/all/run,close, PRAGMA) backed by sql.js/WASM, or run plugins under a bundled Bun runtime.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.