fix(plugin): restore OpenCode 1.3 loader compatibility#81
Merged
Conversation
- Add package.json exports map with ./server and . targets
- Bump @opencode-ai/plugin and @opencode-ai/sdk to ^1.3.0 (resolves to 1.3.13)
- Update src/plugin.ts to export PluginModule { server: OpenCodeMemPlugin }
instead of bare function default export; use satisfies PluginModule
- Add tests/plugin-loader-contract.test.ts regression guard
Fixes #73: opencode-mem@2.12.1 was silently skipped by the OpenCode 1.3.x plugin
loader because dist/plugin.js exported a bare default function. The loader now
expects a PluginModule object with a server() entrypoint (readV1Plugin v1 path).
Adding exports["./server"] and the { server: Plugin } default export satisfies
the contract unambiguously.
Collaborator
Author
|
After installing the local build and fighting my own environment, I got it working and believe this PR is enough to get opencode-mem to the working state with OpenCode v1.3.x. I did encountered some errors in the testing phase but I believe they're not related and opened follow-up issue about it. This PR will require the owner or someone with previous successful operations of the plugin to check before merge. |
Owner
|
Bro you already have direct access to the repo. |
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.
Summary
Fixes #73 —
opencode-memwas silently skipped by OpenCode ≥ 1.3.8 due to a plugin entrypoint/module-shape incompatibility.Root Cause
OpenCode v1.3.x introduced a
PluginModulecontract: the plugin loader (readV1Plugin) now expects the module default export to be an object with aserverproperty —{ server: Plugin }. The previousopencode-mem@2.12.1publisheddist/plugin.jswith a bare function as the default export. The loader'sisRecord(mod.default)check returnedfalse, so it logged "No plugin targets found" and skipped the plugin entirely — without throwing an error.Additionally, OpenCode v1.3.x resolves plugins via
exports["./server"]inpackage.json. The published package had noexportsmap at all, so the loader fell back tomain— but the module shape mismatch meant it was still rejected.Consequence: Plugin hooks never fired → no memory saves, no web UI,
/memory addhad no visible effect (thoughuser-prompts.dbwas modified by the module-level constructor).Changes
package.jsonexportsmap with"."and"./server"entries; bump@opencode-ai/plugin^1.0.162→^1.3.0and@opencode-ai/sdk^1.2.26→^1.3.0src/plugin.ts{ server: OpenCodeMemPlugin } satisfies PluginModule; addimport type { PluginModule }for compile-time validation; remove stale shebangtests/plugin-loader-contract.test.ts.servercallable surface, and hook return valuesbun.lockVerification
bun run typecheck→ exit 0 (no errors)bun run build→ exit 0typeof mod.default === "object",typeof mod.default.server === "function"readV1Pluginlogic confirmsisRecord(mod.default) === true→ plugin would be loaded via v1 path (NOT skipped)Backward Compatibility
main: "dist/plugin.js"is preserved for loaders that fall back tomainOpenCodeMemPluginis preservedsrc/index.tsis unchanged — only the module entrypoint shape and dependencies were updatedPluginModule) is no longer supported by this package; the minimum required OpenCode version is 1.3.x