Skip to content

Plugin silently fails to load: @opencode-ai/plugin is only a devDependency, missing from OpenCode's npm-plugin install tree #3

Description

@NieiR

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

  1. OpenCode 1.18.30, Windows 11, Bun 1.3.14 (the resolution failure is OS-independent)
  2. Add "plugin": ["@cioffi_ai/opencode-memory@1.5.1"] to the global config and restart
  3. 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
  4. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions