Skip to content

[Bug]: Plugin silently fails to load — missing transitive dep 'tiktoken' (3.1.13) #575

Description

@licat2023

Summary

On a fresh install, the plugin silently fails to load: no /dcp or /dcp-compress commands, no compress tool, no prune notifications, and no debug logs are ever written even with "debug": true. The root cause is a missing transitive dependency tiktoken in the installed plugin tree, which makes importing the plugin entry throw before any of DCP's code runs.

Environment

  • OS: Windows 11
  • opencode: 1.17.9 (reproduced in both the Electron Desktop app and the terminal TUI)
  • DCP: @tarquinen/opencode-dcp@latest → resolved to 3.1.13
  • Installed via: opencode plugin @tarquinen/opencode-dcp@latest --global

Root cause

The package's runtime dependency chain is:

@tarquinen/opencode-dcp
  └─ @anthropic-ai/tokenizer@0.0.4
       └─ tiktoken@^1.0.10   ← NOT installed

opencode installs DCP into its plugin cache at
~/.cache/opencode/packages/@tarquinen/opencode-dcp@latest/node_modules.
That tree contains @anthropic-ai/tokenizer but tiktoken is missing entirely (no directory anywhere under it). Because @anthropic-ai/tokenizer/dist/cjs/index.js does require("tiktoken/lite"), importing the plugin entry throws:

Cannot find module 'tiktoken/lite' from
'...\.cache\opencode\packages\@tarquinen\opencode-dcp@latest\node_modules\@anthropic-ai\tokenizer\dist\cjs\index.js'

opencode catches this and silently drops the plugin — nothing is surfaced to the user, which is why it looks like the install "did nothing" (commands absent, no logs even with debug on).

Reproduction

  1. Install on a clean machine: opencode plugin @tarquinen/opencode-dcp@latest --global, restart opencode.
  2. Observe /dcp is not available and ~/.config/opencode/logs/dcp/ is never created (even with "debug": true in dcp.jsonc).
  3. Confirm the broken import directly:
bun -e "await import('file:///<HOME>/.cache/opencode/packages/@tarquinen/opencode-dcp@latest/node_modules/@tarquinen/opencode-dcp/dist/index.js').then(m=>console.log('OK')).catch(e=>console.log('IMPORT ERROR:',e.message))"
# IMPORT ERROR: Cannot find module 'tiktoken/lite' from '...@anthropic-ai/tokenizer/dist/cjs/index.js'

Workaround (confirmed fix)

Manually installing the missing transitive dep into the plugin cache resolves it; after restart /dcp + /dcp-compress appear and debug logs are written:

npm install tiktoken@^1.0.10 --no-save --prefix "$HOME\.cache\opencode\packages\@tarquinen\opencode-dcp@latest"

After the patch the same import returns OK.

Suggested fix

tiktoken is currently only a transitive dependency, and opencode's installer is not pulling it. Two options inside DCP's control:

  1. (preferred, minimal) Promote tiktoken to a direct dependency in package.json. Direct deps are installed reliably by opencode's installer; the failing one here was a child of @anthropic-ai/tokenizer.
  2. Bundle @anthropic-ai/tokenizer via tsup noExternal (the same approach already used for jsonc-parser). Note tiktoken ships a .wasm, so this path needs wasm asset handling.

This is the same class of "plugin silently fails to load" regression seen in #432, #507, and #511, all of which were addressed by bundling more into the tsup output (PR #499). This time the trigger is the un-installed tiktoken transitive dep specifically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions