Skip to content

bun-compat: Bun globals + "bun" module shim pack (Bun.stringWidth, Bun.file/write, Bun.stdin.text, Bun.hash) #6560

Description

@proggeramlug

Tier 0 of Bun-app support (driver: opencode, the Bun-platform TUI target). Exhaustive first-party usage across opencode's product packages (opencode/core/tui/ui/server/client/sdk/plugin/protocol/schema/llm/codemode/session-ui, src, non-test):

API sites notes
Bun.stringWidth(str) 25 (opencode 20, tui 5) terminal cell width; east-asian-width + ANSI handling. Perry-native impl is also reusable for pi-tui (pi/kimi both bundle get-east-asian-width)
Bun.stdin.text() 2 (cli/cmd/tui.ts:60, cli/cmd/run.ts:416) read-all of piped stdin
Bun.file(path) 2 (tui) lazy file handle; only .text()/.arrayBuffer()/.exists()-class usage
Bun.write(dest, data) 2 (tui) file/stdout write
Bun.hash(str) 1 (core/src/skill/discovery.ts:113) cache-dir key via .toString(16); algorithm is wyhash — matching the algo keeps cache dirs compatible with bun-run installs, any stable hash is otherwise fine
import { pathToFileURL, fileURLToPath } from "bun" 3 (tui, opencode) identical semantics to node:url — module-level alias
import type { SystemError } from "bun" 1 type-only, erased at build

Also worth registering while in here: Bun.Glob (used in opencode build scripts, common in the ecosystem) — optional.

Notable absences in opencode's product code (verified): no Bun.serve (HTTP is effect HttpRouter.serve over @effect/platform-node → node:http), no Bun.spawn (cross-spawn/child_process), no Bun.env, no $ shell at runtime, no Workers in the TUI path. The bun:sqlite / bun:ffi / pty surfaces are tracked separately — this issue is only the cheap global shim pack.

Acceptance: a compiled app using the table above resolves every call with node-identical observable behavior; bun-suite gains coverage for each shim.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew capability or improvement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions