Skip to content

[Bug]: Plugin silently fails to load — runtime value-import of @opencode-ai/plugin unresolved in plugin cache #585

Description

@jwhandy3

Bug Description

On opencode 1.17.14, DCP 3.1.14 silently fails to load: no compress tool, no /dcp panel, and no debug logs are written even with "debug": true. ~/.config/opencode/logs/dcp/context/ gets no new session entries.
Root cause: the compiled entry dist/index.js does a runtime value import import { tool } from "@opencode-ai/plugin"; (2 occurrences). opencode installs DCP into ~/.cache/opencode/packages/@tarquinen/opencode-dcp@latest/node_modules/, where only @opencode-ai/sdk exists under @opencode-ai/ — @opencode-ai/plugin is missing (it's only a peer/dev dependency, so opencode's installer never provides it). ESM imports are hoisted, so the unresolved import throws before any DCP code runs; opencode's loader catches it in its dynamic-import try/catch and drops the plugin with nothing surfaced. Regressed after opencode's namespaced-hook plugin refactor (~2026-06-22) stopped making @opencode-ai/plugin resolvable from the plugin cache. Plugins that reference the SDK with import type only are unaffected (type imports are erased at runtime).
Reproduction:
node --input-type=module -e "import('file://$HOME/.cache/opencode/packages/@tarquinen/opencode-dcp@latest/node_modules/@tarquinen/opencode-dcp/dist/index.js').then(()=>console.log('OK')).catch(e=>console.log('ERR:',e.message))"

ERR: Cannot find package '@opencode-ai/plugin'

Confirmed workaround:
npm install @opencode-ai/plugin@1.15.5 --prefix "$HOME/.cache/opencode/packages/@tarquinen/opencode-dcp@latest"
After restart: DCP initialized logs and the compress tool appear. Suggested fix: bundle tool via tsup noExternal: ["@opencode-ai/plugin"], or promote @opencode-ai/plugin to a direct dependency.

Expected Behavior

DCP loads, writes DCP initialized to the daily log, and registers the compress tool — without the user having to manually install @opencode-ai/plugin into the plugin cache.

Debug Context Logs

During the failure, no context log JSON is produced at all — that's the symptom (import throws before DCP runs). Evidence instead comes from the daily log gap and the reproduction. Paste this:
{
  "note": "No context log generated while broken — the module throws on import before DCP executes.",
  "daily_log_evidence": [
    "~/.config/opencode/logs/dcp/daily/2026-06-17.log: last line = 'DCP initialized' (then nothing for ~19 days across multiple restarts)",
    "After installing @opencode-ai/plugin into the cache, 2026-07-06.log immediately shows: 'DCP initialized', 'Cached model context limit | limit=1000000', 'Recorded compression start', 'Marked 44 duplicate tool calls for pruning', 'Saved session state to disk | totalTokensSaved=202237'"
  ],
  "import_repro": "ERR: Cannot find package '@opencode-ai/plugin'"
}
(Optional: to attach a real post-fix context log, grab the newest file under ~/.config/opencode/logs/dcp/context/<session>/<timestamp>.json.)

Tool Call Details

N/A — the compress tool was never registered because the plugin never loaded. No tool call was possible until the workaround was applied.

DCP Version

3.1.14

Opencode Version

1.17.14

Model

Claude Sonnet 4

Additional Context

Same class of silent-load-failure as #575 (missing tiktoken). The distinguishing factor here is a value import of @opencode-ai/plugin (vs. import type), which only breaks post the opencode plugin-loader refactor. opencode fork: github.com/anomalyco/opencode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions