Skip to content

fix: avoid Bun file IO in morph_edit#30

Open
fengjikui wants to merge 1 commit into
morphllm:mainfrom
fengjikui:codex/avoid-bun-file-io
Open

fix: avoid Bun file IO in morph_edit#30
fengjikui wants to merge 1 commit into
morphllm:mainfrom
fengjikui:codex/avoid-bun-file-io

Conversation

@fengjikui

Copy link
Copy Markdown

Summary

Fixes #29.

morph_edit now uses Node fs/promises for local file reads and writes instead of Bun.file / Bun.write. This keeps the Morph SDK calls, tool names, WarpGrep tools, and compaction hooks unchanged while allowing the plugin to run in OpenCode Desktop / Node-style plugin runtimes that do not expose a global Bun object.

Root cause

The plugin is built as a JavaScript package for OpenCode, but the morph_edit implementation directly referenced Bun runtime globals for file IO. In OpenCode Desktop, the plugin can execute in an Electron/Node environment where Bun is not defined, so morph_edit could fail before reaching the Morph API.

Changes

  • Replace Bun.file(...).text() with readFile(..., "utf8").
  • Replace Bun.write(...) with writeFile(..., "utf8").
  • Preserve the existing missing-file behavior for complete new-file content vs. lazy-marker edits.
  • Add a regression test that keeps morph_edit file IO from reintroducing Bun.file / Bun.write.

Validation

  • bun test index.test.ts -t 'morph_edit'
  • bun test
  • bun run typecheck
  • bun run build
  • bun run ci
  • npm pack --dry-run
  • git diff --check

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.

morph_edit uses Bun.file/Bun.write but OpenCode Desktop plugin runtime may not expose global Bun

1 participant