opencode-hashline icon indicating copy to clipboard operation
opencode-hashline copied to clipboard

Plugin fails to load on OpenCode 2.x: default export must be a definition object (id + setup), not a function

Open mhenke opened this issue 1 month ago • 0 comments

Summary

@angdrew/opencode-hashline-plugin 1.6.6 fails to load on OpenCode 2.x. The v2 plugin loader requires the module's default export to be a definition object containing id plus an effect or setup function. The package currently exports an async function (the OpenCode 1.x Plugin signature), so v2 rejects the module at load time and the plugin never registers.

The plugin loads and works fine on OpenCode 1.x — this is purely the v2 module-format contract.

Environment

  • opencode: 2.0.28 (also expected on all 2.0.x)
  • OS: Linux x86-64
  • Config: "plugin": ["@angdrew/opencode-hashline-plugin"] (global ~/.config/opencode/opencode.json)

Error

From ~/.local/share/opencode/log/opencode.log:

level=WARN message="failed to load plugin" target=@angdrew/opencode-hashline-plugin
cause="PluginModule.LoadError: Plugin must export a default definition with an id and an
effect or setup function. (cause: SchemaError(Expected object at [\"default\"]))"

The TUI surfaces it as a plugins failed toast listing @angdrew/opencode-hashline-plugin.

Suggested fix

Ship a dual-shape default export (same pattern other plugins use for 1.x + 2.x compatibility):

export default {
  id: "hashline",
  server: hashlinePlugin, // existing v1 hooks factory — still called by OpenCode 1.x
  setup(ctx) {
    // v2 registration:
    //   ctx.tool.transform(draft => ...)          — tool.description hints (was "tool.definition")
    //   ctx.tool.hook("execute.before", handler)  — hashline ref -> native edit translation
    //   ctx.tool.hook("execute.after", handler)   — read annotation / cache invalidation
    //   ctx.session.hook("context", handler)      — system-instruction injection
  },
}

The v1 hook set maps cleanly onto those v2 domains, so a compatibility shim inside the package should be enough. Happy to test a pre-release on 2.0.28.

mhenke avatar Oct 13 '26 20:10 mhenke