| 1 | #!/usr/bin/env node |
| 2 | // A stand-in for the g1t CLI in the hook tests: writes each call to |
| 3 | // FAKE_G1T_LOG as a JSON line and answers as FAKE_G1T_* say. |
| 4 | import { appendFileSync } from "node:fs"; |
| 5 | |
| 6 | const args = process.argv.slice(2); |
| 7 | appendFileSync(process.env.FAKE_G1T_LOG, `${JSON.stringify({ args, session: process.env.G1T_SESSION ?? null })}\n`); |
| 8 | const exit = Number(process.env.FAKE_G1T_EXIT ?? 0); |
| 9 | if (exit) process.exit(exit); |
| 10 | if (args[0] === "session" && args[1] === "start") process.stdout.write(JSON.stringify({ id: "ses_fake01", state: "active" })); |
| 11 | if (args[0] === "work" && args[1] === "context") process.stdout.write(`#${args[2]} The issue's title\nDefinition of done: it works.\n`); |