Skip to content

fix: pre-build custom tools instead of naively import()ing them#13895

Open
demostanis wants to merge 1 commit intoanomalyco:devfrom
demostanis:use-bun-build-for-custom-tools
Open

fix: pre-build custom tools instead of naively import()ing them#13895
demostanis wants to merge 1 commit intoanomalyco:devfrom
demostanis:use-bun-build-for-custom-tools

Conversation

@demostanis
Copy link

@demostanis demostanis commented Feb 16, 2026

on first launch, opencode installs @opencode-ai/plugin. but without restarting opencode when it's done, the following error appears:

error: Cannot find package 'zod' from '/home/demostanis/.config/opencode/node_modules/@opencode-ai/plugin/dist/tool.js'

https://opncd.ai/share/phMT4NGN (seems buggy? my messages don't show correctly)

This is a quick vibe-coded fix with Claude Opus 4.6.

What does this PR do?

(Fixes #13887)

OpenCode installs @opencode-ai/plugin on first start to ~/.config/opencode/node_modules. However,
when having custom tools in ~/.config/opencode/tools, an error appears on the TUI:
error: Cannot find package 'zod' from '/home/demostanis/.config/opencode/node_modules/@opencode-ai/plugin/dist/tool.js'
(or similar with @opencode-ai/plugin)
A restart is needed for the error to disappear.
This is impactful on temporary systems, where ~/.config/opencode/node_modules will be frequently suppressed (my system runs on a tmpfs)

How did you verify your code works?

rm -rf /home/demostanis/.config/opencode/node_modules && rm -rf /tmp/.opencode && rm -rf /tmp/a && mkdir -p /tmp/a && cd /tmp/a && timeout 120 /tmp/tmp.ILuulrHZEC/opencode/packages/opencode/dist/opencode-linux-x64/bin/opencode run "use the python tool with a hello world program" 2>&

(to adapt)

@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@demostanis demostanis changed the title fix: pre-build custom tools instead of blindly import()ing them fix: pre-build custom tools instead of naively import()ing them Feb 16, 2026
on first launch, opencode installs @opencode-ai/plugin. but without
restarting opencode when it's done, the following error appears:

 error: Cannot find package 'zod' from '/home/demostanis/.config/opencode/node_modules/@opencode-ai/plugin/dist/tool.js'
@demostanis demostanis force-pushed the use-bun-build-for-custom-tools branch from 7e6eaf0 to a31796c Compare February 17, 2026 14:51
@demostanis demostanis force-pushed the use-bun-build-for-custom-tools branch from a31796c to 5622d15 Compare February 17, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom tools require a restart on first OpenCode start

2 participants