fix(opencode): adopt v1 default export to fix Plugin export error#1447
Closed
pratyush618 wants to merge 2 commits intoobra:mainfrom
Closed
fix(opencode): adopt v1 default export to fix Plugin export error#1447pratyush618 wants to merge 2 commits intoobra:mainfrom
pratyush618 wants to merge 2 commits intoobra:mainfrom
Conversation
Resolves #1444 — OpenCode 1.14.30's plugin loader checks mod.default first via readV1Plugin. Without a default export, loading fell through to the legacy iteration path which throws 'Plugin export is not a function' in some environments. Exposing { id, server } via default takes the deterministic v1 path.
Now that the v1 default export is the canonical entrypoint, the named export is unused (no callers in repo) and would double-invoke the plugin under any pure-legacy loader path.
Owner
|
What I read from this PR is that you made the change blind and have not tested it. I am unable to reproduce the original problem. I'm going to close this PR for now. If you can prove that you reproduced the user's problem, please feel free to reopen it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem are you trying to solve?
Issue #1444: A user (lxg07254698) on OpenCode 1.14.30 cannot install Superpowers via the documented one-liner. With
{ "plugin": ["superpowers@git+https://github.com/obra/superpowers.git"] }OpenCode rejects the plugin at startup:
The plugin never registers — no skills, no bootstrap, no hooks.
Root cause is the export shape in
.opencode/plugins/superpowers.js. OpenCode's plugin loader (packages/opencode/src/plugin/index.ts+shared.tsin sst/opencode v1.14.30) tries two paths in order:Our plugin had no default export and one named export (`export const SuperpowersPlugin`). It happened to load via the legacy path on Node/Bun on Linux locally, but the legacy iteration is the brittle path — any non-function export added later silently breaks the plugin, and the affected user's environment is hitting that throw today.
What does this PR change?
Converts `.opencode/plugins/superpowers.js` to OpenCode's documented v1 plugin shape: a single `export default { id: "superpowers", server }`. The plugin function body and returned hooks (`config`, `experimental.chat.messages.transform`) are unchanged — only the export shape moves.
Is this change appropriate for the core library?
Yes. `.opencode/plugins/superpowers.js` is the core OpenCode harness entrypoint that ships with Superpowers. The fix benefits every OpenCode user installing Superpowers via the documented method. It is not project-specific, not a third-party integration, not a new skill.
What alternatives did you consider?
The chosen approach is the only one that puts the plugin on the deterministic v1 path with a stable id and zero runtime overhead.
Does this PR contain multiple unrelated changes?
No. One file, one logical change, split into two commits per the contributor's commit hygiene preference: (1) add the v1 default export alongside the named export so v1.14.30 starts working immediately, (2) drop the now-unused named export. The intermediate commit is independently safe — v1 detection picks the default and the legacy path is never entered.
Existing PRs
`gh search` for "Plugin export is not a function", "OpenCode plugin export", and "plugin failed to load" against this repo returned only #1444 itself plus unrelated work (OpenCode docs cleanups #305, #608, #847, #890; Windows path bug #1242; `config` hook silently ignored #1087; bootstrap caching #1232). None modify the plugin's export shape.
Environment tested
I do not have an OpenCode 1.14.30 install here to run end-to-end against the issue reporter's exact setup. The verification I ran instead replays the loader's exact `readV1Plugin` + `getLegacyPlugins` logic from `sst/opencode@v1.14.30` against the modified plugin module, on both Node 22 and Bun 1.3.11.
Evaluation
This is a loader-level export-shape fix, not a behavior or skill change, so traditional eval sessions don't apply. The "before/after" is binary: the plugin either loads or throws `TypeError`. Verification:
```
v1 detected: true { id: "superpowers", server: "function" }
legacy fallback also OK: 1 plugin(s)
```
Rigor