anomalyco / anomalyco/opencode

Desktop app silently fails to load plugins that import "bun:sqlite"

Open
#41,817 1 comment 0 reactions 1 assignee View on GitHub

@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_JSON warning to server.log. worktree.ts does 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, or opencode.log.
  • Root cause of the silence: load failures call publishPluginError in packages/opencode/src/plugin/index.ts, which only emits a Session.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) where bun:sqlite is native.
  • Loaded-plugin comparison: rtk.ts (type-only import, loads), graphify.js (Node builtins only, loads), worktree.ts (bun:sqlite value 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

  1. 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.
  2. Provide bun:sqlite in 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.