anomalyco / anomalyco/opencode
Plugin API: ctx.tool.transform tools.add crashes with TypeError '_.name.replace' on undefined (beta-17498)
@neriousy is already working on this.
Since Aug 21, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Version
opencode2 v0.0.0-beta-17498 (npm @opencode-ai/cli@next, Linux x64)
Description
Plugin-registered tools via ctx.tool.transform((tools) => tools.add(...)) fail to load with an internal Effect error. The plugin id appears in /api/plugin from a bare-load generation, but every generation that calls tools.add dies during activation.
Repro
Minimal plugin in ~/.config/opencode/plugins/broken.js:
export default {
id: "broken",
setup: async (ctx) => {
await ctx.tool.transform((tools) => {
tools.add("skills.browse", {
description: "test",
input: { type: "object", properties: {}, additionalProperties: false },
execute: async () => ({ content: "ok" }),
})
})
return async () => {}
},
}
Server log:
level=WARN message="failed to load plugin" plugin.id=broken cause="Cause([Die(TypeError: undefined is not an object (evaluating '_.name.replace'))])"
Observations
- A plugin whose
setupdoes nothing exceptconsole.logloads fine, so the crash is specifically in the tool registration path. - The documented third-argument options form (
tools.add("browse", def, { namespace: "skills" })) crashes the same way. - Adding an
outputJSON Schema makes no difference; the crash also happens without it. - Same failure on two different plugin files and across watcher-triggered reloads, so it is not a race in my file editing.
- Docs at /v2/docs/build/plugins describe both call shapes; at least one of them appears broken on this beta.
Expected
tools.add(name, definition) registers a tool that is exposed to the model (and via CodeMode), or returns a validation error naming the offending field.
Environment
Linux x64, Bun runtime bundled with the CLI, plugins auto-discovered from ~/.config/opencode/plugins/.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.