From ae5c9ed3dd7a393e540643f3ecc79b9dea793ecc Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Thu, 5 Mar 2026 22:04:20 -0500 Subject: [PATCH] refactor: replace Bun.stdin.text with Node.js stream reading --- packages/opencode/src/cli/cmd/run.ts | 9 ++++++++- packages/opencode/src/cli/cmd/tui/thread.ts | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/opencode/src/cli/cmd/run.ts b/packages/opencode/src/cli/cmd/run.ts index 61bc609bb..be546beff 100644 --- a/packages/opencode/src/cli/cmd/run.ts +++ b/packages/opencode/src/cli/cmd/run.ts @@ -337,7 +337,14 @@ export const RunCommand = cmd({ } } - if (!process.stdin.isTTY) message += "\n" + (await Bun.stdin.text()) + if (!process.stdin.isTTY) { + const stdinText = await new Promise((resolve) => { + const chunks: Buffer[] = [] + process.stdin.on("data", (chunk) => chunks.push(chunk)) + process.stdin.on("end", () => resolve(Buffer.concat(chunks).toString("utf-8"))) + }) + message += "\n" + stdinText + } if (message.trim().length === 0 && !args.command) { UI.error("You must provide a message or a command") diff --git a/packages/opencode/src/cli/cmd/tui/thread.ts b/packages/opencode/src/cli/cmd/tui/thread.ts index f53cc3925..cca96dd8c 100644 --- a/packages/opencode/src/cli/cmd/tui/thread.ts +++ b/packages/opencode/src/cli/cmd/tui/thread.ts @@ -53,7 +53,13 @@ async function target() { } async function input(value?: string) { - const piped = process.stdin.isTTY ? undefined : await Bun.stdin.text() + const piped = process.stdin.isTTY + ? undefined + : await new Promise((resolve) => { + const chunks: Buffer[] = [] + process.stdin.on("data", (chunk) => chunks.push(chunk)) + process.stdin.on("end", () => resolve(Buffer.concat(chunks).toString("utf-8"))) + }) if (!value) return piped if (!piped) return value return piped + "\n" + value