diff --git a/COMMANDS.md b/COMMANDS.md index 0fec338..b3c6505 100644 --- a/COMMANDS.md +++ b/COMMANDS.md @@ -154,6 +154,8 @@ fable-agent plinius godmode "improve explanation quality" ### `factory` - `factory check` +- `factory gate ` + - `--repo ` ### `familiar` diff --git a/src/index.ts b/src/index.ts index e537f55..a3cfb4a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1426,23 +1426,47 @@ const factory = program .command("factory") .description("Factory/VPS status and deployment guards"); +async function printFactoryCheck(): Promise { + 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)); +} + 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(); - }; + await printFactoryCheck(); + }); - const [factoryStatus, deployHealth] = await Promise.all([ - getJson("http://77.42.112.29:8099/factory-status"), - getJson("http://77.42.112.29:8098/health"), - ]); +factory + .command("gate ") + .description("Run factory check plus local ZTE/repo verification gate") + .option("--repo ", "Repo path to verify", ".") + .action(async (task: string, opts: { repo?: string }) => { + const { spawnSync } = await import("node:child_process"); + await printFactoryCheck(); - console.log(formatFactoryCheck(factoryStatus, deployHealth)); + const repo = path.resolve(opts.repo ?? "."); + console.log(` ZTE Gate: ${task}`); + console.log(` Repo: ${repo}`); + console.log(``); + + const args = [process.argv[1], "fable5", "verify", task, "--repo", repo]; + const check = spawnSync(process.execPath, args, { cwd: repo, stdio: "inherit" }); + if (check.status !== 0) process.exit(check.status ?? 1); + console.log(` ✓ Factory gate passed; deploy still requires explicit token/contract.`); + console.log(``); }); // ── Fable 5 ─────────────────────────────────────────────────