Skip to content

doesnt seem to work in opencode 1.18.3, models dont show up in provider list #30

Closed

Description

@joepetrakovich

authenticated fine using the opencode auth login --provider cursor after adding the stub to the config but theres no provider when you use opencode.

Do you need to manually at the models in the config? Does anyone have the actual names and IDs?

Activity

  1. kipyin commented on Jul 20, 2026

    @kipyin

    I hit the same issue on opencode 1.18.0 with plugin 0.0.9 and tracked down the root cause.

    Diagnosis

    The plugin populates models via a side effect inside the auth.loader hook (dist/index.js:54 — provider.models = buildCursorProviderModels(...)). That pattern worked on opencode 1.14.x, but opencode 1.18 split model registration into a separate provider hook on the v2 catalog. From @opencode-ai/plugin/dist/index.d.ts:167-170 (bundled in the plugin's own node_modules):

    export type ProviderHook = {
        id: string;
        models?: (provider: ProviderV2, ctx: ProviderHookContext) => Promise<Record<string, ModelV2>>;
    };

    The plugin only exports auth, never provider, so opencode's v2 catalog shows the cursor provider with an empty models field and opencode models / /models show nothing.

    Evidence

    • opencode debug v2 → cursor provider registered with api.type: "native", empty settings, no models
    • opencode providers list → cursor oauth credential present
    • opencode models cursor → Error: Provider not found: cursor
    • Running getCursorModels(token) directly in Bun (same runtime opencode uses) returns 117 models including composer-2.5-fast — discovery + auth are fine; the catalog just never sees them
    • opencode debug config shows the provider.cursor stub is parsed correctly; plugin origin resolves to ~/.cache/opencode/packages/opencode-cursor-oauth

    Suggested fix

    Return a provider hook alongside auth from CursorAuthPlugin, e.g.:

    return {
      auth: { /* existing */ },
      provider: {
        id: CURSOR_PROVIDER_ID,
        async models(provider, ctx) {
          const auth = ctx.auth;
          if (!auth || auth.type !== "oauth") return {};
          let accessToken = auth.access;
          if (!accessToken || auth.expires < Date.now()) {
            const refreshed = await refreshCursorToken(auth.refresh);
            // persist refreshed token via input.client.auth.set(...)
            accessToken = refreshed.access;
          }
          const models = await getCursorModels(accessToken);
          const port = await startProxy(/* existing token provider */, models);
          return buildCursorProviderModels(models, port);
        },
      },
    };

    This duplicates the auth-loader logic — the existing loader could probably be refactored to share a getModelsAndPort(auth) helper so both auth.loader and provider.models use the same code path.

    Reproduced on: opencode 1.18.0, opencode-cursor-oauth 0.0.9, macOS.

  2. added a commit that references this issue on Jul 25, 2026
    1fd54db
  3. ephraimduncan commented on Jul 29, 2026

    @ephraimduncan
    Owner

    Fixed in 3396152 (v0.1.0).

    Root cause was exactly what @kipyin diagnosed: opencode 1.18 builds its v2 provider catalog before auth loaders run, and auth.loader only receives a deep copy of the provider — so the provider.models = ... mutation never reached the catalog.

    The plugin now registers models through two paths:

    • a config hook that injects the cursor provider and the discovered model list into the config before the catalog is built (works even though cursor is not in models.dev, which would have made the provider hook alone a no-op — the hook loop skips providers missing from the catalog database)
    • a provider hook as suggested, for catalogs that already know the provider

    Bonus: the manual provider.cursor stub in opencode.json is no longer required — the plugin registers it automatically.

    Verified on opencode 1.18.9: opencode models cursor lists all discovered models and completions run end to end.

  4. joepetrakovich commented on Jul 30, 2026

    @joepetrakovich
    Author

    thank you!

    fwiw I did have to manually delete everything from ~/.cache/opencode/packages/opencode-cursor* because there were now two separate entries in there and opencode would crash on open.

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