import { spawnSafe } from "@uncaged/nerve-workflow-utils"; import { formatSpawnFailure } from "./spawn-utils.js"; export async function runTestCommand( nerveRoot: string, command: string, ): Promise<{ ok: boolean; stdoutPreview: string; stderrPreview: string; reason: string | null; }> { const result = await spawnSafe("bash", ["-lc", command], { cwd: nerveRoot, env: null, timeoutMs: 300_000, }); if (result.ok) { return { ok: true, stdoutPreview: result.value.stdout.slice(0, 600), stderrPreview: result.value.stderr.slice(0, 400), reason: null, }; } return { ok: false, stdoutPreview: (result.error.kind === "spawn_failed" ? "" : result.error.stdout).slice(0, 600), stderrPreview: (result.error.kind === "spawn_failed" ? result.error.message : result.error.stderr).slice(0, 400), reason: formatSpawnFailure(result.error), }; }