Repository navigation
Description
Summary
The npm plugin (opencode-cursor-oauth, dist/v2.js) fails to load on current OpenCode V2 stable hosts (verified on @opencode/cli 2.1.3, Windows x64). The failure happens at import time, so setup() never runs and /plugins only ever shows it as failed:
level=WARN message="failed to load plugin" target=opencode-cursor-oauth role=server
cause="Cause([Die(TypeError: Schema.isStartsWith is not a function.
(In 'Schema.isStartsWith("wrk")', 'Schema.isStartsWith' is undefined))])"
(~/.local/share/opencode/log/opencode.log; the host retries and records a second identical failure under a different ref — both attempts are fatal.)
Why (root cause)
v2.tsimportsCredential, Integration, Model, Pluginfrom@opencode-ai/plugin@0.0.0-beta-17793→@opencode-ai/schema@0.0.0-beta-17793→ which declareseffect@4.0.0-rc.110.const CURSOR_INTEGRATION_ID = Integration.ID.make(CURSOR_ID)runs at module import and evaluates@opencode-ai/schema/dist/workspace-id.js, whose first statement isSchema.String.check(Schema.isStartsWith("wrk")).- The plugin's own pinned dependency tree is internally consistent: importing
@opencode-ai/schemaunder plain Node with the cachedeffect@4.0.0-rc.110succeeds (that Effect still exportsisStartsWith). - The OpenCode host, however, resolves plugin-side bare specifiers of
effect(and@opencode/plugin) to its own bundled runtime copies (@opencode/plugin'sruntime-modules.js; the host Effect 4.0.1 upgrade landed in chore: upgrade Effect to 4.0.1 anomalyco/opencode#54198, with plugin-modules-host-Effect behavior from fix(cli): give plugins the host's Effect anomalyco/opencode#53422). Ineffect@4.0.1,Schema.isStartsWithwas renamed toSchema.isStartingWith; OpenCode's own schema source uses the new name, but the published@opencode-ai/*beta packages still call the old one. - Result: every host from the Effect-4.0.1 migration onward throws at the same import (see the maintainer reproduction in V2 plugin using @opencode-ai/plugin/rpc fails to load on 2.0.28 — TypeError: Schema.isStartsWith is not a function anomalyco/opencode#55154). The plugin's
effectpin can never fix this, because the pinnedeffectis never the instance the schema modules are evaluated against.
Relation to #39
Same beta-API drift, one step upstream: #39 shows ctx.catalog.transform being undefined during setup on 2.0.4+ hosts — the stable plugin API removed the catalog domain entirely (it is now ctx.provider / ctx.model). This is the same underlying breakage of the @opencode-ai/* beta scope.
Proposed fix
Rebuild the V2 plugin against the stable @opencode/plugin API (versioned with the CLI, e.g. @opencode/plugin@2.1.4) as anomalyco/opencode#55154's triage recommends:
@opencode/pluginre-exports the host-matching@opencode/schemanamespaces (Credential,Integration,Model,Provider,Plugin), so no host/dependency skew remains.ctx.catalog.transform→ctx.provider.transformusingProvider.Info.empty(id)+ProviderEditor.add({ info, models })withModel.Info.default(providerID, id);ctx.catalog.reload()→ctx.provider.reload().integration.connection.updated→ watchcredential.updated/credential.switched(filtered bydata.integrationID).- Provider package reference
@opencode-ai/ai/providers/openai-compatible→@opencode/ai/providers/openai-compatible.
A minimal migration was implemented and validated on OpenCode 2.1.3 (Windows x64): the plugin now loads cleanly (server logs loading plugin ... entrypoint=.../server.js, no failed to load plugin afterwards); the integration method and catalog register, and Cursor is exposed OAuth + model catalog after sign-in. The full patch is in #42 — happy to split/adjust however the maintainer prefers.
Activity