Summary
Installed as an npm plugin ("plugin": ["@cioffi_ai/opencode-memory@1.5.1"]), the package is downloaded by OpenCode into ~/.cache/opencode/packages/@cioffi_ai/opencode-memory@1.5.1/ at startup, but it never loads: no memory_* tools are registered and nothing is logged at any level. From the user's side the plugin simply does not exist.
Root cause
package.json lists @opencode-ai/plugin only under devDependencies, while the build keeps it external:
"build": "bun build ./src/index.ts --outfile dist/index.js --target node --format esm --external \"@opencode-ai/plugin\""
so the published dist/index.js starts with:
import { tool } from "@opencode-ai/plugin";
OpenCode installs npm plugins into the per-spec cache dir with a generated package.json that contains only the plugin spec as a production dependency, and it does not alias or provide @opencode-ai/plugin for npm plugins. Module resolution from the cached entry walks up:
.../opencode-memory@1.5.1/node_modules (contains only @cioffi_ai/opencode-memory)
.../packages/node_modules (absent)
~/.cache/opencode/node_modules (absent by default)
- ...
none of which provide @opencode-ai/plugin, so the dynamic import throws:
Cannot find module '@opencode-ai/plugin' from
'C:\Users\<user>\.cache\opencode\packages\@cioffi_ai\opencode-memory@1.5.1\node_modules\@cioffi_ai\opencode-memory\dist\index.js'
OpenCode swallows the load failure silently, hence the zero-log symptom.
Reproduction
- OpenCode 1.18.30, Windows 11, Bun 1.3.14 (the resolution failure is OS-independent)
- Add
"plugin": ["@cioffi_ai/opencode-memory@1.5.1"] to the global config and restart
- The package appears under
~/.cache/opencode/packages/@cioffi_ai/opencode-memory@1.5.1/, but sessions have no memory_* tools and the log has no plugin-related entry
bun run -e 'await import("<cached dist/index.js path>")' reproduces: Cannot find module '@opencode-ai/plugin'
For contrast, the same import succeeds when @opencode-ai/plugin is present anywhere on the resolution path (e.g. installed in a sibling project), and the plugin then initializes correctly and returns all 9 tools.
Suggested fix
Either move @opencode-ai/plugin from devDependencies to dependencies (this is what other npm plugins in the ecosystem do, e.g. opencode-mem), or bundle the tool helper into dist/index.js instead of marking the package external.
Workaround for affected users
Install the plugin package on the resolution path above the OpenCode plugin cache, then restart:
cd ~/.cache/opencode && bun add @opencode-ai/plugin
Verified working: after this the plugin loads and registers memory_read, memory_write, memory_update, memory_forget, memory_clear, memory_inspect, memory_why, memory_useful, memory_irrelevant.
Environment
- opencode 1.18.30 (bundled CLI), Windows 11 x64, Bun 1.3.14
- @cioffi_ai/opencode-memory 1.5.1
Summary
Installed as an npm plugin (
"plugin": ["@cioffi_ai/opencode-memory@1.5.1"]), the package is downloaded by OpenCode into~/.cache/opencode/packages/@cioffi_ai/opencode-memory@1.5.1/at startup, but it never loads: nomemory_*tools are registered and nothing is logged at any level. From the user's side the plugin simply does not exist.Root cause
package.jsonlists@opencode-ai/pluginonly underdevDependencies, while the build keeps it external:so the published
dist/index.jsstarts with:OpenCode installs npm plugins into the per-spec cache dir with a generated
package.jsonthat contains only the plugin spec as a production dependency, and it does not alias or provide@opencode-ai/pluginfor npm plugins. Module resolution from the cached entry walks up:.../opencode-memory@1.5.1/node_modules(contains only@cioffi_ai/opencode-memory).../packages/node_modules(absent)~/.cache/opencode/node_modules(absent by default)none of which provide
@opencode-ai/plugin, so the dynamic import throws:OpenCode swallows the load failure silently, hence the zero-log symptom.
Reproduction
"plugin": ["@cioffi_ai/opencode-memory@1.5.1"]to the global config and restart~/.cache/opencode/packages/@cioffi_ai/opencode-memory@1.5.1/, but sessions have nomemory_*tools and the log has no plugin-related entrybun run -e 'await import("<cached dist/index.js path>")'reproduces:Cannot find module '@opencode-ai/plugin'For contrast, the same import succeeds when
@opencode-ai/pluginis present anywhere on the resolution path (e.g. installed in a sibling project), and the plugin then initializes correctly and returns all 9 tools.Suggested fix
Either move
@opencode-ai/pluginfromdevDependenciestodependencies(this is what other npm plugins in the ecosystem do, e.g.opencode-mem), or bundle thetoolhelper intodist/index.jsinstead of marking the package external.Workaround for affected users
Install the plugin package on the resolution path above the OpenCode plugin cache, then restart:
Verified working: after this the plugin loads and registers
memory_read,memory_write,memory_update,memory_forget,memory_clear,memory_inspect,memory_why,memory_useful,memory_irrelevant.Environment