const fs = require("fs"); const path = require("path"); const { execSync } = require("child_process"); const statePath = path.join(process.cwd(), ".cursor", "pipeline-state.json"); function readState() { if (!fs.existsSync(statePath)) { return { implementation: "pending", review: "pending", tests: "pending" }; } return JSON.parse(fs.readFileSync(statePath, "utf8")); } function fail(msg) { process.stdout.write(JSON.stringify({ followup_message: msg })); process.exit(0); } const state = readState(); if (state.implementation !== "done") { fail("Run frontend-senior stage"); } if (state.review !== "done") { fail("Run reviewer stage"); } if (state.tests !== "done") { fail("Run unit-tests stage"); } try { execSync("npm run lint", { stdio: "pipe" }); } catch { fail("Lint failed"); } try { execSync("npm run typecheck", { stdio: "pipe" }); } catch { fail("Typecheck failed"); } try { execSync("npm run test", { stdio: "pipe" }); } catch { fail("Tests failed"); } process.exit(0);