[PR #3785] fix: support scoped npm plugins #10760

Closed
opened 2026-02-16 18:15:30 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/3785

State: closed
Merged: Yes


Scoped Plugin Bug

  • Loader currently does plugin.split("@") (packages/opencode/src/plugin/index.ts:37), so a scoped name like @promethean-os/opencode-openai-codex-auth becomes pkg === "" and version === "promethean-os/opencode-openai-codex-auth".
  • BunProc.install then records that empty package key in the cache manifest (packages/opencode/src/bun/index.ts:60-94), producing "": "promethean-os/opencode-openai-codex-auth" and never installing the real module. The follow-up import resolves to /home/err/.cache/opencode/node_modules, triggering the “Cannot find module …” error you’re seeing.
  • Parse plugin strings from the rightmost @ (or use npm-package-arg) so scoped packages stay intact, e.g. const at = plugin.lastIndexOf("@"); const pkg = at > 0 ? plugin.slice(0, at) : plugin; const version = at > 0 ? plugin.slice(at + 1) : "latest";.
  • After patching, clear ~/.cache/opencode and restart so the dependency file is regenerated with the correct scoped package key.
    Next step: adjust the loader parsing logic and rebuild; rerun with the scoped plugin to confirm it resolves.

closes: #3392

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/3785 **State:** closed **Merged:** Yes --- Scoped Plugin Bug - Loader currently does plugin.split("@") (packages/opencode/src/plugin/index.ts:37), so a scoped name like @promethean-os/opencode-openai-codex-auth becomes pkg === "" and version === "promethean-os/opencode-openai-codex-auth". - BunProc.install then records that empty package key in the cache manifest (packages/opencode/src/bun/index.ts:60-94), producing "": "promethean-os/opencode-openai-codex-auth" and never installing the real module. The follow-up import resolves to /home/err/.cache/opencode/node_modules, triggering the “Cannot find module …” error you’re seeing. - Parse plugin strings from the rightmost @ (or use npm-package-arg) so scoped packages stay intact, e.g. const at = plugin.lastIndexOf("@"); const pkg = at > 0 ? plugin.slice(0, at) : plugin; const version = at > 0 ? plugin.slice(at + 1) : "latest";. - After patching, clear ~/.cache/opencode and restart so the dependency file is regenerated with the correct scoped package key. Next step: adjust the loader parsing logic and rebuild; rerun with the scoped plugin to confirm it resolves. closes: #3392
yindo added the pull-request label 2026-02-16 18:15:30 -05:00
yindo closed this issue 2026-02-16 18:15:30 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10760