Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit f501501

Browse files
committed
fix: piping
1 parent c103052 commit f501501

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

packages/opencode/src/cli/cmd/tui/app.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ import { TuiEvent } from "./event"
3030
import { KVProvider, useKV } from "./context/kv"
3131

3232
async function getTerminalBackgroundColor(): Promise<"dark" | "light"> {
33+
// can't set raw mode if not a TTY
34+
if (!process.stdin.isTTY) return "dark"
35+
3336
return new Promise((resolve) => {
3437
let timeout: NodeJS.Timeout
3538

packages/opencode/src/cli/cmd/tui/thread.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ export const TuiThreadCommand = cmd({
5252
default: "127.0.0.1",
5353
}),
5454
handler: async (args) => {
55+
const prompt = await (async () => {
56+
const piped = !process.stdin.isTTY ? await Bun.stdin.text() : undefined
57+
if (!args.prompt) return piped
58+
return piped ? piped + "\n" + args.prompt : args.prompt
59+
})()
60+
5561
const cwd = args.project ? path.resolve(args.project) : process.cwd()
5662
try {
5763
process.chdir(cwd)
@@ -106,7 +112,7 @@ export const TuiThreadCommand = cmd({
106112
sessionID,
107113
model: args.model,
108114
agent: args.agent,
109-
prompt: args.prompt,
115+
prompt,
110116
onExit: async () => {
111117
await client.call("shutdown", undefined)
112118
},

0 commit comments

Comments
 (0)