From 4b19e7f5183fcd09dc1e908c9c13be5240808320 Mon Sep 17 00:00:00 2001 From: artale Date: Mon, 15 Jun 2026 17:43:09 +0200 Subject: [PATCH] feat: add factory status check --- COMMANDS.md | 5 +++++ src/fable5/factory-status.test.ts | 14 ++++++++++++++ src/fable5/factory-status.ts | 32 +++++++++++++++++++++++++++++++ src/index.ts | 25 ++++++++++++++++++++++++ 4 files changed, 76 insertions(+) create mode 100644 src/fable5/factory-status.test.ts create mode 100644 src/fable5/factory-status.ts diff --git a/COMMANDS.md b/COMMANDS.md index 611e760..0fec338 100644 --- a/COMMANDS.md +++ b/COMMANDS.md @@ -36,6 +36,7 @@ fable-agent plinius godmode "improve explanation quality" | `demo` | Demo mode | | `learned` | Summaries of learned material | | `familiar` | Note capture and health graph | +| `factory` | Factory/VPS status and deployment guards | | `pai-pi` | PI integration mode | | `daemon` | Long-running mode queue/monitor | | `fable5` | Upgraded execution stack | @@ -150,6 +151,10 @@ fable-agent plinius godmode "improve explanation quality" - `learned` - `-v, --verbose` +### `factory` + +- `factory check` + ### `familiar` - `familiar capture ` diff --git a/src/fable5/factory-status.test.ts b/src/fable5/factory-status.test.ts new file mode 100644 index 0000000..7582f84 --- /dev/null +++ b/src/fable5/factory-status.test.ts @@ -0,0 +1,14 @@ +import { describe, expect, it } from "vitest"; +import { formatFactoryCheck } from "./factory-status.js"; + +describe("factory check formatting", () => { + it("prints live counts from response data", () => { + const out = formatFactoryCheck( + { status: "ok", phase: 4, containers: 24, agents: 6, infra: 14, monitoring: 5, skills: 63 }, + { status: "ok", service: "deploy-webhook", phase: 4 }, + ); + + expect(out).toContain("Containers: 24"); + expect(out).toContain("Deploy webhook: ok (deploy-webhook)"); + }); +}); diff --git a/src/fable5/factory-status.ts b/src/fable5/factory-status.ts new file mode 100644 index 0000000..30a1f69 --- /dev/null +++ b/src/fable5/factory-status.ts @@ -0,0 +1,32 @@ +export interface FactoryStatus { + status?: string; + phase?: number; + containers?: number; + agents?: number; + infra?: number; + monitoring?: number; + skills?: number; +} + +export interface DeployHealth { + status?: string; + service?: string; + phase?: number; +} + +export function formatFactoryCheck(factory: FactoryStatus, deploy: DeployHealth): string { + return [ + "", + " Factory Check", + " ─────────────────────────────", + ` Factory: ${factory.status ?? "unknown"}`, + ` Phase: ${factory.phase ?? "unknown"}`, + ` Containers: ${factory.containers ?? "unknown"}`, + ` Agents: ${factory.agents ?? "unknown"}`, + ` Infra: ${factory.infra ?? "unknown"}`, + ` Monitoring: ${factory.monitoring ?? "unknown"}`, + ` Skills: ${factory.skills ?? "unknown"}`, + ` Deploy webhook: ${deploy.status ?? "unknown"}${deploy.service ? ` (${deploy.service})` : ""}`, + "", + ].join("\n"); +} diff --git a/src/index.ts b/src/index.ts index 02ca116..e537f55 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1420,6 +1420,31 @@ daemon console.log(` Queue: ${stats.queued} pending, ${stats.completed} completed\n`); }); +// ── Factory ───────────────────────────────────────────────── + +const factory = program + .command("factory") + .description("Factory/VPS status and deployment guards"); + +factory + .command("check") + .description("Check factory status and deploy-webhook health") + .action(async () => { + const { formatFactoryCheck } = await import("./fable5/factory-status.js"); + const getJson = async (url: string) => { + const res = await fetch(url); + if (!res.ok) throw new Error(url + " returned " + res.status); + return res.json(); + }; + + const [factoryStatus, deployHealth] = await Promise.all([ + getJson("http://77.42.112.29:8099/factory-status"), + getJson("http://77.42.112.29:8098/health"), + ]); + + console.log(formatFactoryCheck(factoryStatus, deployHealth)); + }); + // ── Fable 5 ───────────────────────────────────────────────── const fable = program