openpod

An opencode plugin that spins up a dedicated virtual machine for each session to isolate agent work.
git clone https://unitehenry.com/git/openpod.git
Log | Files | Refs | README

commit 6ad34b1ebf32c5212679db228b003d56cbed4be8
parent ff5d58b78bbf16ff87d2f8689179fbf1c2c76a6e
Author: Henry Unite <unitehenry@gmail.com>
Date:   Mon, 26 Oct 2026 16:14:33 +0000

chore: log limactl stderr on failure

Diffstat:
Mprompt/handle.test.ts | 8++++----
Mprompt/handle.ts | 51++++++++++++++++++++++++++++++++++++++++++---------
2 files changed, 46 insertions(+), 13 deletions(-)

diff --git a/prompt/handle.test.ts b/prompt/handle.test.ts @@ -142,13 +142,13 @@ describe("handle", () => { "template:default", "--yes", ], - { stdio: "ignore" }, + { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }, ); // start expect(spawnSync).toHaveBeenCalledWith( "limactl", ["start", sessionId, "--yes"], - { stdio: "ignore" }, + { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }, ); }); @@ -209,7 +209,7 @@ describe("handle", () => { expect(spawnSync).toHaveBeenCalledWith( "limactl", ["start", sessionId, "--yes"], - { stdio: "ignore" }, + { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }, ); }); @@ -230,7 +230,7 @@ describe("handle", () => { expect(spawnSync).toHaveBeenCalledWith( "limactl", ["start", sessionId, "--yes"], - { stdio: "ignore" }, + { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }, ); }); diff --git a/prompt/handle.ts b/prompt/handle.ts @@ -3,6 +3,33 @@ import { spawnSync } from "node:child_process"; import * as fs from "node:fs"; import * as path from "node:path"; +/** + * Log a failed spawn with its captured stderr/stdout. The openpod log file is + * not collected on CI runners, so also write the message to stderr where the + * CI job output can see it. + */ +function logFailure( + logger: OpenpodContext["logger"], + label: string, + result: ReturnType<typeof spawnSync>, +): void { + if (result.status === 0) return; + + const stderr = typeof result.stderr === "string" ? result.stderr.trim() : ""; + const stdout = typeof result.stdout === "string" ? result.stdout.trim() : ""; + const message = [ + `${label} exited with ${result.status}`, + result.error ? `error: ${result.error.message}` : "", + stderr ? `stderr:\n${stderr}` : "", + stdout ? `stdout:\n${stdout}` : "", + ] + .filter(Boolean) + .join("\n"); + + logger.log(message, "error"); + console.error(`[openpod] ${message}`); +} + export type HandleParams = { ctx: OpenpodContext; sessionId: string; @@ -71,29 +98,35 @@ export function handle(params: HandleParams): void { "--yes", ], { - stdio: "ignore", + encoding: "utf8", + stdio: ["ignore", "pipe", "pipe"], }, ); - if (createResult.status !== 0) { - logger.log(`limactl create exited with ${createResult.status}`); - } + logFailure(logger, `limactl create ${sessionId}`, createResult); } function startLimaInstance(sessionId: string): void { logger.log(`starting lima instance ${sessionId}`); const startResult = spawnSync("limactl", ["start", sessionId, "--yes"], { - stdio: "ignore", + encoding: "utf8", + stdio: ["ignore", "pipe", "pipe"], }); - if (startResult.status !== 0) { - logger.log(`limactl start exited with ${startResult.status}`); - } + logFailure(logger, `limactl start ${sessionId}`, startResult); } function cloneProject(originUrl: string, target: string): boolean { fs.mkdirSync(openpodRoot, { recursive: true }); const result = spawnSync("git", ["clone", originUrl, target]); if (result.status !== 0) { - logger.log(`git clone failed with exit code ${result.status}`); + const stderr = result.stderr?.toString().trim(); + const message = [ + `git clone failed with exit code ${result.status}`, + stderr ? `stderr:\n${stderr}` : "", + ] + .filter(Boolean) + .join("\n"); + logger.log(message, "error"); + console.error(`[openpod] ${message}`); try { fs.rmSync(target, { recursive: true, force: true }); } catch {