fix(opencode): use PluginModule export for opencode 1.18.x compatibility#603
Closed
LeoNardo-LB wants to merge 1 commit into
Closed
fix(opencode): use PluginModule export for opencode 1.18.x compatibility#603LeoNardo-LB wants to merge 1 commit into
LeoNardo-LB wants to merge 1 commit into
Conversation
opencode 1.18.x rejects `{ Evolver, default: Evolver }` with
"Plugin export is not a function". Switch to PluginModule format
`{ id, server }` which is the official opencode plugin shape.
Also update verify() to recognize the new format alongside the legacy ones.
Author
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.
Problem
evolver setup-hooks --platform=opencodegenerates a plugin file whose export shape is rejected by opencode 1.18.x at load time:The generated file currently ends with:
Under Bun (opencode's runtime), the whole
module.exportsobject is treated as the default export, so opencode receives{ Evolver }rather than a function and bails out. The plugin is silently skipped —evolver setup-hooks --platform=opencode --verifystill passes because it uses Node'srequire()which seesEvolveras a named export. This means the two disagree, and users only find out when they checkopencode debug config.Reproduction
Tested on:
@evomap/evolver1.92.1 (npm)Fix
opencode 1.18.x accepts either a bare function as the default export or a PluginModule object of shape
{ id, server }. This PR switches to the PluginModule form, which is what the official opencode plugin docs use (opencode.ai/docs/plugins).The second change updates
verify()to recognise the new shape. Without it, the existingmod.Evolver || mod.defaultlookup would returnundefinedon the patched export and--verifywould falsely report[FAIL] plugin_loadable:Verification
Applied the patch locally and ran the full flow end-to-end:
opencode --print-logs --log-level INFO debug config→ 0 ERROR / WARN entries (previouslyfailed to load plugin)evolver setup-hooks --platform=opencode --verify→ all 5 checks[OK]superpowers,context-mode,opencode-vision,opencode-goal-plugin) unaffectedRelated
loading pluginINFO log was present). Looks like opencode 1.18.x tightened plugin validation, which surfaces this latent issue.Note
Low Risk
Small export-shape change in the opencode adapter only; no auth, data, or core runtime logic changes.
Overview
Fixes opencode 1.18.x rejecting the generated evolver plugin with "Plugin export is not a function" under Bun, while
evolver setup-hooks --platform=opencode --verifycould still pass under Node.The generated
evolver.jsnow uses the documented PluginModule export ({ id: "evolver", server: Evolver }) instead of{ Evolver }plus adefaultassignment.verify()resolves the plugin factory viamod.serverfirst (thenEvolver/default) so--verifymatches what opencode loads.Reviewed by Cursor Bugbot for commit 7b9b773. Bugbot is set up for automated code reviews on this repo. Configure here.