Description
A plugin that exports anything besides the plugin function — a constant, an array — silently fails to load. No error, the hooks just never fire.
It's getLegacyPlugins in packages/opencode/src/plugin/index.ts: it loops over every export and throws on the first non-function one, and that error gets swallowed by the Effect.catch right below it (the one with the // TODO: make proper events for this comment).
Using the export default { id, server } format works around it, since that path skips getLegacyPlugins entirely — but the docs only show the named-export style, so it's easy to hit. A continue instead of the throw would fix it.
Plugins
No response
OpenCode version
1.16.2
Steps to reproduce
- Create a plugin that exports a constant next to the function:
export const VERSION = "1.0.0";
export const MyPlugin = async () => ({
"tool.execute.before": async () => { console.log("hook fired"); },
});
- Add it to
opencode.json: "plugin": ["file:///path/to/plugin.js"]
- Trigger any tool — the hook never fires, and there's no error anywhere.
Screenshot and/or share link
No response
Operating System
Ubuntu 26.04
Terminal
Ptyxis
Description
A plugin that exports anything besides the plugin function — a constant, an array — silently fails to load. No error, the hooks just never fire.
It's
getLegacyPluginsinpackages/opencode/src/plugin/index.ts: it loops over every export and throws on the first non-function one, and that error gets swallowed by theEffect.catchright below it (the one with the// TODO: make proper events for thiscomment).Using the
export default { id, server }format works around it, since that path skipsgetLegacyPluginsentirely — but the docs only show the named-export style, so it's easy to hit. Acontinueinstead of the throw would fix it.Plugins
No response
OpenCode version
1.16.2
Steps to reproduce
opencode.json:"plugin": ["file:///path/to/plugin.js"]Screenshot and/or share link
No response
Operating System
Ubuntu 26.04
Terminal
Ptyxis