Skip to content

OpenCode 2.0 stable (2.0.5+): plugin crashes — ctx.catalog missing #23

Closed

Description

@ebysofyan

Summary

The OpenCode 2 (plugin/opencode2) entry assumes ctx.catalog (transform / reload). That domain exists on OpenCode 2.0 beta, but stable OpenCode 2.0.5 / 2.0.6 exposes ctx.provider / ctx.model / ctx.integration / ctx.aisdk and does not ship ctx.catalog.

Result: loading cursor-opencode-provider/plugin/opencode2 on stable OC2 crashes during setup (ctx.catalog.transform is undefined), so Cursor auth + model picker never come up.

Volunteer: @ebysofyan — will open a PR fixing this. Maintainer: please assign this issue to ebysofyan if possible (reporter lacks triage permission to self-assign).

Environment

Item Value
OpenCode stable 2.0.5 / 2.0.6 (not beta)
Plugin entry cursor-opencode-provider/plugin/opencode2 (or symlink to dist/plugin-opencode2.js)
Config dir $OPENCODE_CONFIG_DIR (e.g. ~/.config/opencode2)
Classic OC1 unaffected (plugin / plugin/v2)

Repro

  1. Install OpenCode stable 2.0.x (not the beta build that has ctx.catalog).
  2. Point config at a dedicated dir, e.g. OPENCODE_CONFIG_DIR=~/.config/opencode2.
  3. Register the OC2 plugin entry (plugin/opencode2 or a plugins/cursor.js symlink to dist/plugin-opencode2.js).
  4. Start / restart the OpenCode 2 service and open the model picker / Cursor auth flow.

Expected

  • Plugin loads on stable OC2 without throwing.
  • Cursor provider authenticates.
  • Discovered Cursor models appear in the picker.
  • Beta hosts that do have ctx.catalog keep the existing catalog transform path.

Actual

Setup crashes when the plugin calls ctx.catalog.transform (domain absent on stable). Provider/model transforms alone do not flush models into the live picker on 2.0.5.

Root cause (investigation)

Stable OC2 plugin surface:

  • present: ctx.provider, ctx.model, ctx.integration, ctx.aisdk
  • missing: ctx.catalog

Draft mutations via ctx.provider / ctx.model transforms do not show up in list() on stable; the picker only honors models written under providers.cursor in the user config document (opencode.json / opencode.jsonc under OPENCODE_CONFIG_DIR).

Proposed fix

Keep OC1 entrypoints untouched. For OC2:

  1. Detect catalog: if typeof ctx.catalog?.transform === "function" → keep current beta ctx.catalog.transform path.
  2. Else (stable fallback): after model discovery, sync Cursor models into providers.cursor in $OPENCODE_CONFIG_DIR/opencode.json(c) (AI SDK package + model map), so auth / aisdk hooks / picker work on 2.0.5+.
  3. Add regression tests for the config-sync helper and document the stable vs beta paths in README.

Working implementation on fork; PR will reference this issue (Fixes #N).

References

Checklist for PR

  • Guard ctx.catalog (beta path unchanged when present)
  • Stable fallback: sync providers.cursor into config
  • Tests for config sync / catalog detection
  • README: stable 2.0.5+ vs beta notes
  • No behavior change for classic OpenCode 1.x plugin entries
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