fix: load the claims plugin without the @opencode/plugin import #17
Reference in New Issue
Block a user
Delete Branch "fix/claims-plugin-load"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #16.
The plugin registered as
failedwith only "Plugin failed to load". The reference (err_7dd8e193) does not appear in the server log —grepacross~/.local/share/opencode/log/finds nothing but my own command text, and there are no plugin errors at INFO level. So the log did not contain the underlying cause and could not be used to infer it.How the cause was found
The running server exposes the plugin inventory at
GET /api/plugin, which reports the real state per plugin. Controlled experiments, each a real directory the server loaded:index.jsindex.tsindex.ts@opencode/pluginindex.ts@opencode-ai/pluginThat splits the problem cleanly: TypeScript compiles, the default export shape is accepted, the directory is discovered — only a bare package specifier fails.
Supporting evidence:
@opencode/pluginis not installed anywhere resolvable; the runtime defines it internally (as@opencode/plugin/tui) for its own use.~/.config/opencode/node_modules/@opencode-ai/plugin@1.2.27is the V1 package, whose API has noPlugin.define.node:builtins resolve normally.Fix
Remove the import and export the definition object.
Plugin.defineis an identity function in the runtime (function Nl(t){return t}), so this is exactly equivalent — it is not a workaround that changes behaviour.Verified:
/api/pluginnow reportsactive, idknox.claims.The README records the constraint, since the official docs show the import and the next local plugin will hit the same wall.
Also in this PR
Experiment directories and their config entries were removed;
pluginsin~/.config/opencode/opencode.jsonis back to the singleclaimsentry.A local plugin loaded by path cannot resolve bare package specifiers, so `import { Plugin } from "@opencode/plugin"` made the plugin fail with an opaque "Plugin failed to load". Isolated by experiment: index.js, no imports -> active index.ts, no imports -> active index.ts, @opencode/plugin -> failed index.ts, @opencode-ai/plugin -> failed So it was never the TypeScript, the default export or the hook. Plugin.define is an identity function in the runtime, so exporting the definition object directly is equivalent. Registered status is now 'active'.