Files
mozempkandCopilot d56f058b1d feat: initial commit of ralph-runtime
Governed app-lifecycle primitives for agentic loops: supervised serve
(hold-open, reaped) and one-shot smoke (HTTP + console verdict).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-10 08:59:48 +02:00

48 lines
1.4 KiB
JavaScript
Executable File

#!/usr/bin/env node
import { resolve } from "node:path";
import { serveStart, serveStop, serveStatus } from "./serve.mjs";
import { smoke } from "./smoke.mjs";
function parse(argv) {
const rest = [];
let root = process.cwd();
let httpOnly = false;
for (let i = 0; i < argv.length; i++) {
const a = argv[i];
if (a === "--root") root = resolve(argv[++i]);
else if (a === "--http-only") httpOnly = true;
else rest.push(a);
}
return { cmd: rest[0], sub: rest[1], root, httpOnly };
}
async function main() {
const { cmd, sub, root, httpOnly } = parse(process.argv.slice(2));
let r;
switch (cmd) {
case "serve":
if (sub === "start") r = await serveStart(root);
else if (sub === "stop") r = await serveStop(root);
else if (sub === "status") r = await serveStatus(root);
else r = { ok: false, text: "usage: ralph-runtime serve start|stop|status" };
break;
case "smoke":
r = await smoke(root, { httpOnly });
break;
default:
r = {
ok: true,
text: `ralph-runtime — governed app lifecycle
serve start|stop|status [--root DIR] Supervised hold-open server (exploration; reaped on session end)
smoke [--http-only] [--root DIR] One-shot build→launch→HTTP+console verdict→teardown (exit 1 on FAIL)`,
};
}
console.log(r.text);
process.exit(r.ok ? 0 : 1);
}
main().catch((e) => {
console.error("ralph-runtime error:", e?.stack ?? e);
process.exit(2);
});