opencode icon indicating copy to clipboard operation
opencode copied to clipboard

allow running custom tools without external dependencies

Open kynnyhsap opened this issue 2 months ago • 6 comments

problem

impossible to run custom tools from local .opencode/tool/mytool.ts folder because you either rquired to use tool.schema from @opencode-ai/plugin or z from zod

use case

running opencode form local configuraion in .opencode/ without node_modules installed there with zod or opencode plugin sdk

solution

please allow us to use json schema for args along side with zod

export default {
  description: "",

  args: {
    arg1: { type: 'string' },
  },

  async execute(args, _context) { }
};

v0.11.8

Image Image

kynnyhsap avatar Sep 26 '25 15:09 kynnyhsap

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

  • #2718: Support metadata and output format in custom tools - discusses enhancements to custom tools functionality

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

github-actions[bot] avatar Sep 26 '25 15:09 github-actions[bot]

@kynnyhsap soon I think opencode will be resolving these dependencies automatically for you (just btw) so u wouldn't have to create a node_modules

rekram1-node avatar Sep 26 '25 21:09 rekram1-node

Hello, I also am encountering this issue:

error: Cannot find module '@opencode-ai/plugin' from '/home/[redacted]/dot-config/opencode/tool/list-agents.ts'

Is it still mandatory to actively create a node_modules folder everywhere we run opencode if we want custom tools to work?

dehidehidehi avatar Nov 21 '25 20:11 dehidehidehi

We automatically install the dep, but ig it is failing for u? and is there no node_modules for it?

rekram1-node avatar Nov 21 '25 20:11 rekram1-node

I cannot reproduce the issue, I guess we are all good; Looking at the file logs produced by opencode helps knowing where the package is installed

INFO  2025-11-21T21:23:13 +9ms service=bun cmd=["/home/dehi/.opencode/bin/opencode","add","@opencode-ai/[email protected]","--exact"] cwd=/home/dehi/.config/opencode running
INFO  2025-11-21T21:23:13 +15ms service=bun code=0 stdout=bun add v1.3.3 (274e01c7)
installed @opencode-ai/[email protected]

dehidehidehi avatar Nov 21 '25 21:11 dehidehidehi

We automatically install the dep, but ig it is failing for u? and is there no node_modules for it?

I submitted a pull request to fix this issue: https://github.com/sst/opencode/pull/5797

HelloGGX avatar Dec 19 '25 15:12 HelloGGX