mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-22 18:24:21 +01:00
fix: piping
This commit is contained in:
@@ -30,6 +30,9 @@ import { TuiEvent } from "./event"
|
|||||||
import { KVProvider, useKV } from "./context/kv"
|
import { KVProvider, useKV } from "./context/kv"
|
||||||
|
|
||||||
async function getTerminalBackgroundColor(): Promise<"dark" | "light"> {
|
async function getTerminalBackgroundColor(): Promise<"dark" | "light"> {
|
||||||
|
// can't set raw mode if not a TTY
|
||||||
|
if (!process.stdin.isTTY) return "dark"
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
let timeout: NodeJS.Timeout
|
let timeout: NodeJS.Timeout
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,12 @@ export const TuiThreadCommand = cmd({
|
|||||||
default: "127.0.0.1",
|
default: "127.0.0.1",
|
||||||
}),
|
}),
|
||||||
handler: async (args) => {
|
handler: async (args) => {
|
||||||
|
const prompt = await (async () => {
|
||||||
|
const piped = !process.stdin.isTTY ? await Bun.stdin.text() : undefined
|
||||||
|
if (!args.prompt) return piped
|
||||||
|
return piped ? piped + "\n" + args.prompt : args.prompt
|
||||||
|
})()
|
||||||
|
|
||||||
const cwd = args.project ? path.resolve(args.project) : process.cwd()
|
const cwd = args.project ? path.resolve(args.project) : process.cwd()
|
||||||
try {
|
try {
|
||||||
process.chdir(cwd)
|
process.chdir(cwd)
|
||||||
@@ -106,7 +112,7 @@ export const TuiThreadCommand = cmd({
|
|||||||
sessionID,
|
sessionID,
|
||||||
model: args.model,
|
model: args.model,
|
||||||
agent: args.agent,
|
agent: args.agent,
|
||||||
prompt: args.prompt,
|
prompt,
|
||||||
onExit: async () => {
|
onExit: async () => {
|
||||||
await client.call("shutdown", undefined)
|
await client.call("shutdown", undefined)
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user