Summary
In OpenCode Desktop 1.17.12, the Morph OpenCode plugin morph_edit tool can fail with Bun is not defined because the plugin implementation reads/writes files through global Bun.file / Bun.write.
A minimal local compatibility patch replacing only that file I/O with Node fs/promises (readFile / writeFile) fixed the Desktop active-workflow smoke test while preserving the Morph SDK calls, tool names, WarpGrep tools, and compaction hooks.
Environment
- OpenCode Desktop: 1.17.12
- OpenCode CLI after alignment: 1.17.12
- Node: v24.16.0
- Plugin:
@morphllm/opencode-morph-plugin@2.0.16
- Shell did not have a user-installed
bun binary on PATH, but installing Bun alone is not expected to inject a global Bun into an Electron/Node plugin process.
Reproduction
- Configure a valid
MORPH_API_KEY for OpenCode Desktop.
- Restart OpenCode Desktop.
- Run
morph_edit against an existing scratch file.
Observed error before patch:
Error reading file ...: Bun is not defined
Expected
morph_edit should work in OpenCode Desktop plugin runtimes that do not expose a global Bun, or the plugin/runtime requirement should be documented clearly.
Minimal fix tested locally
Replace the direct Bun file I/O calls in morph_edit with portable Node APIs:
import { readFile, writeFile } from "node:fs/promises";
originalCode = await readFile(filepath, "utf8");
await writeFile(filepath, normalizedCodeEdit, "utf8");
await writeFile(filepath, mergedCode, "utf8");
After this contained change was loaded as a local OpenCode plugin, Desktop active-workflow smoke tests passed for:
- existing-file
morph_edit edit
- missing target file creation without lazy markers
- missing target file with lazy markers returning the expected safe error
- local WarpGrep
- public repo WarpGrep against
vercel/next.js
/morph compact slash-command interception
No Bun is not defined errors occurred after the patch.
Notes
This report is only about the OpenCode plugin Desktop compatibility surface. Generic Morph SDK/API usage is not the issue.
Summary
In OpenCode Desktop 1.17.12, the Morph OpenCode plugin
morph_edittool can fail withBun is not definedbecause the plugin implementation reads/writes files through globalBun.file/Bun.write.A minimal local compatibility patch replacing only that file I/O with Node
fs/promises(readFile/writeFile) fixed the Desktop active-workflow smoke test while preserving the Morph SDK calls, tool names, WarpGrep tools, and compaction hooks.Environment
@morphllm/opencode-morph-plugin@2.0.16bunbinary on PATH, but installing Bun alone is not expected to inject a globalBuninto an Electron/Node plugin process.Reproduction
MORPH_API_KEYfor OpenCode Desktop.morph_editagainst an existing scratch file.Observed error before patch:
Expected
morph_editshould work in OpenCode Desktop plugin runtimes that do not expose a globalBun, or the plugin/runtime requirement should be documented clearly.Minimal fix tested locally
Replace the direct Bun file I/O calls in
morph_editwith portable Node APIs:After this contained change was loaded as a local OpenCode plugin, Desktop active-workflow smoke tests passed for:
morph_editeditvercel/next.js/morph compactslash-command interceptionNo
Bun is not definederrors occurred after the patch.Notes
This report is only about the OpenCode plugin Desktop compatibility surface. Generic Morph SDK/API usage is not the issue.