Skip to content
16 linesCodeBlameRaw
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.
4import { appendFileSync } from "node:fs";
5
6const args = process.argv.slice(2);
7appendFileSync(process.env.FAKE_G1T_LOG, `${JSON.stringify({ args, session: process.env.G1T_SESSION ?? null })}\n`);
8const exit = Number(process.env.FAKE_G1T_EXIT ?? 0);
9if (exit) process.exit(exit);
10if (args[0] === "session" && args[1] === "start") {
11 // A subagent's session has an id of its own, from its harness id.
12 const harness = args[args.indexOf("--harness-session-id") + 1] ?? "";
13 const id = args.includes("--parent") ? `ses_sub_${harness.split("/agent/")[1]}` : "ses_fake01";
14 process.stdout.write(JSON.stringify({ id, state: "active" }));
15}
16if (args[0] === "work" && args[1] === "context") process.stdout.write(`#${args[2]} The issue's title\nDefinition of done: it works.\n`);