Summary
OpenCode uses ~/.cache/opencode/packages/ as the installation location for npm plugins, but:
- The directory is named
cache/, which by XDG Base Directory spec means "discardable, regenerable data" — semantically wrong for installed plugin code
- The official docs still reference the OLD path
~/.cache/opencode/node_modules/, which doesn't exist on current installs
This naming/path inconsistency is confusing for users (hard to find where plugins are installed) and may also mask bugs in the plugin loader (some users report plugins being downloaded but not loaded — see cross-reference below).
Environment
Steps to Verify
ls ~/.cache/opencode/
# Expected per docs (opencode.ai/docs/plugins/):
# node_modules/ ← docs say this is where plugins go
# Actual:
# bin/ ← OpenCode CLI
# packages/ ← actual plugin install location
# skills/ ← skills cache
# models.json
ls ~/.cache/opencode/packages/
# oh-my-openagent@latest/
# opencode-pty@latest/ ← example: an npm plugin
# oh-my-openagent/ ← legacy dir (sometimes empty)
# bun.lock
# package.json
# package-lock.json
# package.json.bak-pre-pty ← auto-backup before each plugin change
The node_modules/ directory referenced in the docs does not exist on a current install.
Issues With This Design
1. XDG semantic violation
Per the XDG Base Directory Specification:
$XDG_CACHE_HOME defines the base directory relative to which user-specific non-essential data files should be stored. If $XDG_CACHE_HOME is either not set or empty, a default equal to $HOME/.cache should be used.
The directory MUST be on a local file system and not shared with any other system... The lifetime of the directory must be similar to the lifetime of the application.
XDG reserves ~/.cache/ for non-essential, regenerable data. Installed plugin code is:
- Not regenerable (depends on which plugins the user explicitly chose to install)
- Not non-essential (the user wants the plugin to keep working)
- Not transient (users expect it to persist across restarts)
Cache-cleaning tools (rm -rf ~/.cache, systemd-tmpfiles, bleachbit, etc.) may delete this directory, silently breaking all npm plugins on next OpenCode launch.
A more XDG-compliant location would be ~/.local/share/opencode/plugins/ (or ~/.config/opencode/plugins/ for both local file plugins and npm plugins, unified).
2. Docs are out of sync
The Plugins docs say:
npm plugins are installed automatically using Bun at startup. Packages and their dependencies are cached in ~/.cache/opencode/node_modules/.
But the actual directory is ~/.cache/opencode/packages/. There is no node_modules/ directory under ~/.cache/opencode/ on current installs.
3. May be related to plugin loading bugs
See shekohex/opencode-pty#39 — a user (me) added opencode-pty to the plugin array, the package was downloaded correctly to ~/.cache/opencode/packages/opencode-pty@latest/node_modules/opencode-pty/ with all dependencies hoisted, but OpenCode silently does not register the plugin (no error, no warning, no entry in the TUI plugin list, /pty commands return "no matching command").
I suspect the cache restructuring (node_modules/ → packages/) was not 100% consistent across the loader code, and some code paths still expect the old layout. While I can't reproduce this for oh-my-openagent (which works fine in the same packages/ location), the docs/loader/cache relationship deserves a fresh audit.
Suggested Actions
- Fix the docs to reference
~/.cache/opencode/packages/ (or whatever the actual location is)
- Audit the plugin loader to confirm it consistently reads from the correct path
- Consider moving plugin installs to
~/.local/share/opencode/plugins/ (XDG-compliant) — or at minimum, document clearly that ~/.cache/opencode/packages/ should NOT be cleaned by cache-cleaning tools, and provide a opencode plugin clean command for safe manual cleanup
Reproduction Case
The original opencode-pty bug is filed at shekohex/opencode-pty#39. The discovery of this docs/path inconsistency came from that investigation.
Summary
OpenCode uses
~/.cache/opencode/packages/as the installation location for npm plugins, but:cache/, which by XDG Base Directory spec means "discardable, regenerable data" — semantically wrong for installed plugin code~/.cache/opencode/node_modules/, which doesn't exist on current installsThis naming/path inconsistency is confusing for users (hard to find where plugins are installed) and may also mask bugs in the plugin loader (some users report plugins being downloaded but not loaded — see cross-reference below).
Environment
Steps to Verify
The
node_modules/directory referenced in the docs does not exist on a current install.Issues With This Design
1. XDG semantic violation
Per the XDG Base Directory Specification:
XDG reserves
~/.cache/for non-essential, regenerable data. Installed plugin code is:Cache-cleaning tools (
rm -rf ~/.cache, systemd-tmpfiles, bleachbit, etc.) may delete this directory, silently breaking all npm plugins on next OpenCode launch.A more XDG-compliant location would be
~/.local/share/opencode/plugins/(or~/.config/opencode/plugins/for both local file plugins and npm plugins, unified).2. Docs are out of sync
The Plugins docs say:
But the actual directory is
~/.cache/opencode/packages/. There is nonode_modules/directory under~/.cache/opencode/on current installs.3. May be related to plugin loading bugs
See shekohex/opencode-pty#39 — a user (me) added
opencode-ptyto the plugin array, the package was downloaded correctly to~/.cache/opencode/packages/opencode-pty@latest/node_modules/opencode-pty/with all dependencies hoisted, but OpenCode silently does not register the plugin (no error, no warning, no entry in the TUI plugin list,/ptycommands return "no matching command").I suspect the cache restructuring (
node_modules/→packages/) was not 100% consistent across the loader code, and some code paths still expect the old layout. While I can't reproduce this foroh-my-openagent(which works fine in the samepackages/location), the docs/loader/cache relationship deserves a fresh audit.Suggested Actions
~/.cache/opencode/packages/(or whatever the actual location is)~/.local/share/opencode/plugins/(XDG-compliant) — or at minimum, document clearly that~/.cache/opencode/packages/should NOT be cleaned by cache-cleaning tools, and provide aopencode plugin cleancommand for safe manual cleanupReproduction Case
The original opencode-pty bug is filed at shekohex/opencode-pty#39. The discovery of this docs/path inconsistency came from that investigation.