Skip to content

OpenCode 2.0.4+: plugin dies on ctx.catalog.transform (undefined) #39

Description

@OmerFarukOruc

opencode-cursor-oauth@0.2.0 dies in server plugin setup on OpenCode 2.0.4 and 2.0.5. ctx.catalog is undefined:

TypeError: undefined is not an object (evaluating 'ctx.catalog.transform')

OpenCode marks the plugin failed. Cursor OAuth and models never register. Setup always hits ctx.catalog.transform, logged-in or not. Missing tokens and env vars are not the cause.

Environment

Item Value
OpenCode 2.0.5 (channel=latest)
Plugin opencode-cursor-oauth@0.2.0 (npm latest, published 2026-08-22)
Plugin dep @opencode-ai/plugin@0.0.0-beta-17793
Config "plugins": ["opencode-cursor-oauth@0.2.0"]
npm versions 0.0.1 … 0.2.0 — no newer release

Timeline (local logs)

0.2.0 loaded on OpenCode 2.0.3. It started throwing after the host moved to 2.0.4:

2026-09-16T15:08:55Z  cli starting  version=2.0.3  serve --service
2026-09-16T15:08:56Z  loading plugin  id=opencode-cursor-oauth@0.2.0  entrypoint=.../dist/v2.js
                      (no catalog.transform failure)

2026-09-16T15:10:02Z  cli starting  version=2.0.4  serve --service
2026-09-16T15:10:04Z  failed to load plugin  plugin.id=opencode.cursor-oauth
                      cause=Die(TypeError: undefined is not an object (evaluating 'ctx.catalog.transform'))

Fails on 2.0.5 too.

Stack (redacted)

Server plugin error
Plugin: opencode.cursor-oauth
Status: failed
Runtime: server
Source: opencode-cursor-oauth@0.2.0
Error: TypeError: undefined is not an object (evaluating 'ctx.catalog.transform')
    at <anonymous> (.../opencode-cursor-oauth/dist/v2.js:53:19)
    at Plugin.load
    at Plugin.activate
    at PluginSupervisor.activate
    at ServerProcess.start

Log line:

level=WARN message="failed to load plugin" plugin.id=opencode.cursor-oauth
cause="Cause([Die(TypeError: undefined is not an object (evaluating 'ctx.catalog.transform'))])"

Crash

Published dist/v2.js and src/v2.ts on main call the V2 beta catalog API:

await ctx.catalog.transform((draft) => {
  draft.provider.update(CURSOR_ID, (provider) => { ... })
  draft.model.update(CURSOR_ID, cursorModel.id, (model) => { ... })
})
// ...
await ctx.catalog.reload()

OpenCode plugin docs now use ctx.provider.transform / ctx.model.transform. The runtime context has no ctx.catalog.

loadCatalog() catches auth errors and returns undefined. The transform runs after that, so the crash happens with no Cursor credential.

The openai-compatible package name also moved:

  • plugin 0.2.0: @opencode-ai/ai/providers/openai-compatible
  • OpenCode 2.0 docs: @opencode/ai/providers/openai-compatible

Port

Leave OAuth on ctx.integration (that path runs). Swap the catalog block for the current provider transform:

await ctx.provider.transform((editor) => {
  const current = catalog
  if (!current) return
  editor.add({
    info: {
      ...Provider.Info.empty(Provider.ID.make("cursor")),
      integrationID: CURSOR_INTEGRATION_ID,
      name: "Cursor",
      activation: "auto",
      package: "@opencode/ai/providers/openai-compatible",
      settings: { baseURL: `http://localhost:${current.port}/v1` },
    },
    models: current.models.map((cursorModel) => ({
      ...Model.Info.default(Provider.ID.make("cursor"), Model.ID.make(cursorModel.id)),
      name: cursorModel.name,
      capabilities: { tools: true, input: ["text"], output: ["text"] },
      limit: { context: cursorModel.contextWindow, output: cursorModel.maxTokens },
      status: "active",
      enabled: true,
    })),
    sourceConnection: current.connection,
  })
})

On connection updates, call ctx.provider.reload() instead of ctx.catalog.reload().

A local 0.2.0 with that change loads on OpenCode 2.0.5. No ctx.catalog.transform TypeError.

Docs

https://opencode.ai/v2/docs/build/plugins documents ctx.provider / ctx.model. The plugin README still talks about "OpenCode V2 beta" and adding models to "the V2 catalog".

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions