opencode: plugin does not load on OpenCode 2.x
Summary
The OpenCode plugin does not load on OpenCode 2.x, so neither /i-have-adhd nor the always-on flag is available from a global install. The V1 plugin shape is rejected at load time, and the install instructions target V1 field names and path forms that V2 does not accept.
Environment
- opencode version: 2.0.18 (channel
latest) - OS: Windows_NT 10.0.19045 (win32 x64)
- Terminal: Unavailable: no terminal environment variables are set
- Shell: PowerShell 5.1 (spawned by the opencode server)
- Install/channel: latest
- Active plugins:
superpowers@git+https://github.com/obra/superpowers.git
Reproduction
git clone https://github.com/ayghri/i-have-adhd ~/.config/opencode/vendor/i-have-adhd- Add
"plugin": ["/absolute/path/to/i-have-adhd/.opencode/plugins/i-have-adhd.mjs"]to~/.config/opencode/opencode.jsonas INSTALL.md instructs - Start OpenCode, type
/
Expected Behavior
i-have-adhd appears in the / list, and creating ~/.config/opencode/.i-have-adhd-always makes the ruleset apply on every turn.
Actual Behavior
Three distinct failures, in the order they are hit.
1. The documented path form is rejected outright.
WARN message="configured plugin path must be a directory"
target=C:/Users/DELL/.config/opencode/vendor/i-have-adhd/.opencode/plugins/i-have-adhd.mjs2. The export shape fails validation. Exposing the plugin through ~/.config/opencode/plugins/ gets it discovered, but it will not load:
WARN message="failed to load plugin" target=".../plugins/i-have-adhd.js"
cause="Plugin must export a default definition with an id and an effect or
setup function. (cause: SchemaError(Expected object at [\"default\"]))"export default async () => ({...}) is a function; V2 requires a definition object with an id and an effect/setup function.
3. After migrating the export shape, Skill.Info rejects location. The V2 plugin docs show location, but the served schema requires path:
WARN message="disabled plugin after transform failure" plugin.id=i-have-adhd state=skill
cause="SchemaError(Missing key at [\"path\"])"Additional Context
Docs mismatches worth reporting upstream to opencode, all confirmed against 2.0.18:
| Doc says | Runtime does |
|---|---|
plugins accepts "../shared/plugin.ts" and "/absolute/path/plugin.ts" |
rejects any file path: configured plugin path must be a directory |
plugins accepts "./plugins/local" (a directory) |
accepts without error but silently never loads the plugin |
Skill.Info example uses location |
schema requires path |
The directory case is the nastiest: a valid-looking config produces no warning and no plugin, which is hard to diagnose.
A plugin-free global install does work today, and is what most users need:
mkdir -p ~/.config/opencode/skills/i-have-adhd ~/.config/opencode/commands
cp skills/i-have-adhd/SKILL.md ~/.config/opencode/skills/i-have-adhd/SKILL.md
cp .opencode/command/i-have-adhd.md ~/.config/opencode/commands/i-have-adhd.mdBoth directories are discovered natively, /i-have-adhd shows up, and the always-on flag is the only thing still missing. A one-line loader in ~/.config/opencode/plugins/ re-exporting the vendored .mjs restores the plugin (and therefore always-on) while keeping the module's __dirname inside the checkout.
A fix is in progress: the plugin is migrated to the V2 API in PR #240. Verified on 2.0.18 — the plugin loads with no warnings, and /api/command returns i-have-adhd from the plugin alone with the command file removed.
Source: ayghri/i-have-adhd