Skip to content

V2 plugin using @opencode-ai/plugin/rpc fails to load on 2.0.28 — TypeError: Schema.isStartsWith is not a function #55154

Closed as not planned

Description

@patrickzxk

Environment

  • opencode v2.0.28 (npm-global @opencode/cli), darwin/arm64
  • Plugin: local-directory plugin, registered via plugins: ["/path/to/local-plugin"]
  • Plugin deps: @opencode-ai/plugin 0.0.0-beta-19135, effect 4.0.0-rc.112
  • Regression: the same plugin loaded fine on v2.0.22

Summary

On 2.0.28, a V2 plugin that imports @opencode-ai/plugin/rpc fails to load with:

TypeError: Schema.isStartsWith is not a function.
(In 'Schema.isStartsWith("wrk")', 'Schema.isStartsWith' is undefined)

The throw happens at module-import time, so the plugin's setup() never runs. The plugin is simply unusable; /plugins only shows it as failed.

Where it throws

@opencode-ai/schema/dist/workspace-id.js:4 — top-level, evaluated on import:

import { Schema } from "effect";
export const WorkspaceID = Schema.String.check(Schema.isStartsWith("wrk")).pipe(...)

Import chain for the failing plugin:

plugin entry
  → @opencode-ai/plugin/rpc
  → @opencode-ai/schema/rpc
  → schema/{workspace,workspace-event,location}.js
  → workspace-id.js          ← throws here

Root cause

Schema.isStartsWith exists in effect 4.0.0-rc.112 but not in 4.0.0-rc.118 or 4.0.1:

effect version isStartsWith present in dist/
4.0.0-rc.112 yes
4.0.0-rc.118 no
4.0.1 no

But the published @opencode-ai/schema builds still call it:

@opencode-ai/schema declares effect files calling isStartsWith
0.0.0-beta-19135 4.0.0-rc.112 11
0.0.0-beta-19151 4.0.0-rc.112 11
0.0.0-beta-19271 (current beta dist-tag) 4.0.0-rc.112 11

After #54198 moved the host to Effect 4.0.1, that export is gone from the Effect instance the plugin's modules are evaluated against, so Schema.isStartsWith is undefined and the import throws.

The same split is visible at the binary level:

$ strings <v2.0.22 binary> | grep -c isStartsWith
3
$ strings <v2.0.28 binary> | grep -c isStartsWith
0

Control experiment

Two local plugins with identical dependency sets (@opencode-ai/plugin: beta, same effect), loaded side by side:

plugin imports @opencode-ai/plugin/rpc loads on 2.0.28
A yes fails
B no ok

So this is specific to the /rpc surface (which pulls the workspace schemas), not to local-directory plugins in general.

Impact

Any V2 plugin using Rpc.define from @opencode-ai/plugin/rpc cannot load on 2.0.28. There is no plugin-side workaround: every currently published @opencode-ai/schema beta still calls the removed API, and the plugin's own pinned effect is not the instance that ends up being used.

Suggested fixes (any one would unblock)

  1. Keep Schema.isStartsWith exported from the bundled Effect (a re-export shim is enough), or
  2. Stop resolving bare effect from the host for plugin-side modules, so a plugin's own pinned effect is used, or
  3. Republish @opencode-ai/schema / @opencode-ai/plugin against Effect 4.x — every current beta still pins 4.0.0-rc.112.

Raw log

level=WARN message="failed to load plugin" target=/path/to/local-plugin ref=err_e6121439
cause="Cause([Die(TypeError: Schema.isStartsWith is not a function.
(In 'Schema.isStartsWith(\"wrk\")', 'Schema.isStartsWith' is undefined))])" role=server

Caveat

I could not inspect the host's internal module resolution (it is a compiled binary), so the exact mechanism by which the host's Effect instance reaches plugin-side modules is inferred rather than proven. The version comparisons above are measured directly from the published packages and the release binaries.

Activity

  1. opencode-agent commented on Oct 13, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed report. I can reproduce this on 2.0.28, and it still happens on the latest dev (1015cb67d).

    Steps: a local-directory plugin depending on @opencode-ai/[email protected] and [email protected], registered via plugins: ["/abs/path"]. On load, the server logs failed to load plugin … TypeError: Schema.isStartsWith is not a function. The script below reproduces it.

    What I found:

    • The host gives plugin modules its own effect (4.0.1), and that includes nested dependencies like @opencode-ai/schema. That part of your guess is right.
    • Effect renamed Schema.isStartsWith to Schema.isStartingWith, and OpenCode's own schema source already uses the new name. The @opencode-ai/* beta packages on npm are an older package scope and haven't been updated.
    • With beta-19135, importing only @opencode-ai/plugin/rpc loaded fine for me. It failed once something led to workspace-id.js, e.g. importing Plugin/Location from the package root. So the exact chain may depend on what your plugin imports.

    Workaround: the current package for V2 plugins is @opencode/plugin (version 2.0.28, same as the CLI). I rewrote the same plugin against it (Plugin and Location from @opencode/plugin, Rpc from @opencode/plugin/rpc), and it loads and runs setup on 2.0.28. Switching your dependency should unblock you.

    Maintainers will decide how to handle plugins that still use the old @opencode-ai/* packages. Related: #53422 (plugins receive the host's Effect) and #54198 (Effect 4.0.1 upgrade).

    Reproduction script (repro.sh)
    #!/usr/bin/env bash
    # Repro for #55154: load a local V2 plugin built on @opencode-ai/plugin beta + effect rc.112.
    # Usage: OPENCODE="opencode" bash repro.sh   (OPENCODE may be any command that runs the CLI)
    set -u
    OPENCODE=${OPENCODE:-opencode}
    R=/workspace/repro
    mkdir -p $R/pluginA $R/proj
    cd $R/pluginA
    cat > package.json <<'J'
    {"name":"plugin-a","type":"module","main":"index.ts","dependencies":{"@opencode-ai/plugin":"0.0.0-beta-19135","effect":"4.0.0-rc.112"}}
    J
    cat > index.ts <<'J'
    import { Plugin, Location } from "@opencode-ai/plugin"
    import { Rpc } from "@opencode-ai/plugin/rpc"
    import { Schema } from "effect"
    export default Plugin.define({
      id: "repro-a",
      setup: async () => {
        console.error("[repro-a] setup ran", typeof Rpc, typeof Location, "isStartsWith:", typeof (Schema as any).isStartsWith)
      },
    })
    J
    bun install >/dev/null 2>&1
    cd $R/proj; git init -q 2>/dev/null
    echo '{ "plugins": ["/workspace/repro/pluginA"] }' > opencode.json
    export HOME=/tmp/rhome-$$ XDG_DATA_HOME=/tmp/rhome-$$/d XDG_CONFIG_HOME=/tmp/rhome-$$/c XDG_STATE_HOME=/tmp/rhome-$$/s XDG_CACHE_HOME=/tmp/rhome-$$/ca OPENCODE_PASSWORD=pw
    mkdir -p $HOME
    PORT=$((4700 + RANDOM % 200))
    $OPENCODE serve --port $PORT --print-logs > /tmp/repro-serve.log 2>&1 &
    PID=$!
    sleep 8
    $OPENCODE api --server http://127.0.0.1:$PORT GET /api/plugin >/dev/null 2>&1
    sleep 10
    $OPENCODE api --server http://127.0.0.1:$PORT GET /api/plugin 2>/dev/null | grep -o '{"id":"/workspace[^}]*}[^}]*}[^}]*}' 
    kill $PID 2>/dev/null; pkill -P $PID 2>/dev/null
    grep -E "repro-a|failed to load plugin|isStart" /tmp/repro-serve.log | cut -c1-500

    Run it: bash repro.sh

  2. rekram1-node commented on Oct 15, 2026

    @rekram1-node
    Member

    The opencode-ai/plugin beta versions had an older version of effect, recommend using the stable v2 plugin versions instead

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions