Skip to content

Plugin fails to load on OpenCode v2: default export must be an object with id and setup #30

Description

@ebysofyan

Environment

  • OpenCode: stable 2.0.x (config plugin[])
  • Plugin: opencode-chrome-devtools@1.0.4 (npm)

Problem

Adding "opencode-chrome-devtools" to plugin[] fails at load time:

level=WARN msg="failed to load plugin" id=opencode-chrome-devtools
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 default export is the legacy async factory const plugin: Plugin = async () => ({ tool: {...} }) (src/plugin.ts:33). The v2 loader requires an object: { id, setup } (or { id, effect }).

Reproduction

  1. bun add opencode-chrome-devtools
  2. opencode.json: "plugin": ["opencode-chrome-devtools"]
  3. Restart the OpenCode service
  4. Plugin load warning in the log; no browser_* tools registered

Suggested fix

Export a v2-shaped plugin while keeping the legacy factory available for older hosts:

export default {
  id: "opencode-chrome-devtools",
  setup: async (ctx) => { /* register tools via ctx.tool.transform */ },
};

Assignment

I have a working fix locally and would like to open a PR for this — please assign it to me (@ebysofyan). Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions