opencode initial run

This commit is contained in:
Shawn Morreau
2025-12-05 16:34:53 -05:00
parent 04c64d4794
commit 06fdedb8c5
6 changed files with 500 additions and 6 deletions
+4 -3
View File
@@ -7,6 +7,7 @@ export interface SpawnOptions {
input?: string;
timeout?: number;
cwd?: string;
stdio?: ("pipe" | "ignore" | "inherit")[];
onStdout?: (chunk: string) => void;
onStderr?: (chunk: string) => void;
}
@@ -22,7 +23,7 @@ export interface SpawnResult {
* Spawn a subprocess with streaming callbacks and buffered results
*/
export async function spawn(options: SpawnOptions): Promise<SpawnResult> {
const { cmd, args, env, input, timeout, cwd, onStdout, onStderr } = options;
const { cmd, args, env, input, timeout, cwd, stdio, onStdout, onStderr } = options;
const startTime = Date.now();
let stdoutBuffer = "";
@@ -35,7 +36,7 @@ export async function spawn(options: SpawnOptions): Promise<SpawnResult> {
PATH: process.env.PATH || "",
HOME: process.env.HOME || "",
},
stdio: ["pipe", "pipe", "pipe"],
stdio: stdio || ["pipe", "pipe", "pipe"],
cwd: cwd || process.cwd(),
});
@@ -106,7 +107,7 @@ export async function spawn(options: SpawnOptions): Promise<SpawnResult> {
});
});
if (input && child.stdin) {
if (input && child.stdin && stdio?.[0] !== "ignore") {
child.stdin.write(input);
child.stdin.end();
}