Skip to content

#1 Persistent memory for AI coding agents based on real-world benchmarks

fix(cli): capture signal kills + guard empty env paths (PR #128 followups)

Rohit Ghumare397a0857e977
diff --git a/src/cli.ts b/src/cli.ts
index bd35f26e..47991472 100644
--- a/src/cli.ts
+++ b/src/cli.ts
@@ -101,16 +101,16 @@ function whichBinary(name: string): string | null {
function fallbackIiiPaths(): string[] {
if (IS_WINDOWS) {
- const userProfile = process.env["USERPROFILE"] || "";
+ const userProfile = process.env["USERPROFILE"];
+ if (!userProfile) return [];
return [
join(userProfile, ".local", "bin", "iii.exe"),
join(userProfile, "bin", "iii.exe"),
- ].filter(Boolean);
+ ];
}
- return [
- join(process.env["HOME"] || "", ".local", "bin", "iii"),
- "/usr/local/bin/iii",
- ];
+ const home = process.env["HOME"];
+ if (!home) return ["/usr/local/bin/iii"];
+ return [join(home, ".local", "bin", "iii"), "/usr/local/bin/iii"];
}
type StartupFailure = {
@@ -146,11 +146,17 @@ function spawnEngineBackground(
stderrBytes += slice.length;
});
child.on("exit", (code, signal) => {
- if (code !== 0 && code !== null) {
+ const abnormal =
+ (code !== null && code !== 0) || (code === null && signal !== null);
+ if (abnormal) {
const stderr = Buffer.concat(stderrChunks).toString("utf-8");
startupFailure = {
kind: label.includes("Docker") ? "docker-crashed" : "engine-crashed",
- stderr: stderr.trim() || `process exited with code ${code}${signal ? ` (${signal})` : ""}`,
+ stderr:
+ stderr.trim() ||
+ (signal
+ ? `process killed by signal ${signal}`
+ : `process exited with code ${code}`),
binary: bin,
};
vlog(`engine exited early: code=${code} signal=${signal}`);