Custom tool crashing opencode on MacOS Silicon homebrew #2022

Closed
opened 2026-02-16 17:33:46 -05:00 by yindo · 4 comments
Owner

Originally created by @renanliberato on GitHub (Oct 9, 2025).

Originally assigned to: @rekram1-node on GitHub.

when I add the custom tool from this website example (link), when I try to start "opencode" interactive CLI it crashes with this error: tool is not defined stack=ReferenceError: tool is not defined

It seems it's not finding the opencode TS module.

May it be because I installed opencode via homebrew and not npm/bun?

Originally created by @renanliberato on GitHub (Oct 9, 2025). Originally assigned to: @rekram1-node on GitHub. when I add the custom tool from [this website example (link)](https://opencode.ai/docs/plugins/#custom-tools), when I try to start "opencode" interactive CLI it crashes with this error: `tool is not defined stack=ReferenceError: tool is not defined` It seems it's not finding the opencode TS module. May it be because I installed opencode via homebrew and not npm/bun?
yindo closed this issue 2026-02-16 17:33:46 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Oct 9, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #3001: "@opencode-ai/plugin" error when creating custom tools - similar issue with custom tools and missing dependencies when installed via different methods
  • #2802: Allow running custom tools without external dependencies - discusses issues with custom tools requiring external dependencies like @opencode-ai/plugin or zod
  • #2768: Support for using additional npm packages in custom tools - mentions crashes when adding dependencies under .opencode/tool/

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Oct 9, 2025): This issue might be a duplicate of existing issues. Please check: - #3001: "@opencode-ai/plugin" error when creating custom tools - similar issue with custom tools and missing dependencies when installed via different methods - #2802: Allow running custom tools without external dependencies - discusses issues with custom tools requiring external dependencies like @opencode-ai/plugin or zod - #2768: Support for using additional npm packages in custom tools - mentions crashes when adding dependencies under .opencode/tool/ Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Oct 9, 2025):

@renanliberato I will fix docs, try this instead:

import { type Plugin, tool } from "@opencode-ai/plugin"

export const CustomToolsPlugin: Plugin = async (ctx) => {
  return {
    tool: {
      mytool: tool({
        description: "This is a custom tool",
        args: {
          foo: tool.schema.string(),
        },
        async execute(args, ctx) {
          return `Hello ${args.foo}!`
        },
      }),
    },
  }
}
@rekram1-node commented on GitHub (Oct 9, 2025): @renanliberato I will fix docs, try this instead: ``` import { type Plugin, tool } from "@opencode-ai/plugin" export const CustomToolsPlugin: Plugin = async (ctx) => { return { tool: { mytool: tool({ description: "This is a custom tool", args: { foo: tool.schema.string(), }, async execute(args, ctx) { return `Hello ${args.foo}!` }, }), }, } } ```
Author
Owner

@rekram1-node commented on GitHub (Oct 9, 2025):

Also make sure you have this dep installed: "@opencode-ai/plugin"

it can be in the .opencode/ directory or in .opencode/plugin

soon opencode will automatically resolve the deps for you, but until then...

@rekram1-node commented on GitHub (Oct 9, 2025): Also make sure you have this dep installed: "@opencode-ai/plugin" it can be in the .opencode/ directory or in .opencode/plugin soon opencode will automatically resolve the deps for you, but until then...
Author
Owner

@renanliberato commented on GitHub (Oct 10, 2025):

Also make sure you have this dep installed: "@opencode-ai/plugin"

it can be in the .opencode/ directory or in .opencode/plugin

soon opencode will automatically resolve the deps for you, but until then...

I definitely didn't do it, opssss. Thanks!

@renanliberato commented on GitHub (Oct 10, 2025): > Also make sure you have this dep installed: "@opencode-ai/plugin" > > it can be in the .opencode/ directory or in .opencode/plugin > > soon opencode will automatically resolve the deps for you, but until then... I definitely didn't do it, opssss. Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2022