fix: replace Bun globals with Node fs APIs for OpenCode 1.18 compatibility - #4
Open
Tony-ooo wants to merge 1 commit into
Open
fix: replace Bun globals with Node fs APIs for OpenCode 1.18 compatibility#4Tony-ooo wants to merge 1 commit into
Tony-ooo wants to merge 1 commit into
Conversation
…ility OpenCode 1.18 no longer exposes the Bun global to plugins, so Bun.file/Bun.write crash with 'ReferenceError: Bun is not defined', breaking pasted-image save/read. - vision-helper.ts: persist images via fs.access + fs.writeFile - vision.ts: read images via fs.stat + fs.readFile, derive MIME from extension
sasha240100
approved these changes
Aug 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On OpenCode 1.18.x the plugin runtime no longer exposes the global
Bunobject. Bothplugins/vision-helper.tsandtools/vision.tscallBun.file()/Bun.write(), which now throw:This crashes
experimental.chat.messages.transform(logged asprompt_async failed), so pasted images are never saved and the path hint is never injected. Non-vision models then only see the rawCannot read "image.png" (this model does not support image input)error instead of being guided to the vision tool / subagent.Fix
Replace all
Bunfile APIs with standard NodefsAPIs:plugins/vision-helper.ts:Bun.file().exists()→fs.access(),Bun.write()→fs.writeFile()tools/vision.ts:Bun.file()→fs.stat()/fs.readFile(), plus amimeType()helper to infer MIME from the file extension (replacingBun.file().type)Verification
image-readersubagent delegation path works end-to-end (verified with a pasted image).node --experimental-strip-types --check.