Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t.sh
49 linesCodeBlameRaw
1// The review prompt, taken from the runner's own source so the benchmark
2// measures what production runs. crates/runner/src/review.rs holds the
3// instructions as a Rust string constant; services/runner/src/index.ts
4// (startReviewRun) puts "what the pull request is" in front of them.
5//
6// Production also appends repository instructions (AGENTS.md, CLAUDE.md,
7// .g1t/review.md); Claude Code reads CLAUDE.md from the checkout by
8// itself, as it does in a trusted production run.
9
10import { readFileSync } from "node:fs";
11import { fileURLToPath } from "node:url";
12
13const REVIEW_RS = fileURLToPath(new URL("../../crates/runner/src/review.rs", import.meta.url));
14
15/** The `INSTRUCTIONS` constant of review.rs, unescaped as rustc would. */
16export function instructionsFromRust(source = readFileSync(REVIEW_RS, "utf8")) {
17 const match = source.match(/const INSTRUCTIONS: &str = "([\s\S]*?)";\n/);
18 if (!match) throw new Error("INSTRUCTIONS not found in review.rs; update bench/reviewbench/prompt.mjs");
19 return match[1]
20 // A backslash at the end of a line continues the string and eats the
21 // next line's leading whitespace.
22 .replace(/\\\n\s*/g, "")
23 .replace(/\\"/g, '"')
24 .replace(/\\n/g, "\n")
25 .replace(/\\\\/g, "\\");
26}
27
28export { buildPrompt } from "./agent/prompt-lib.mjs";
29
30// `node prompt.mjs` writes instructions.txt for the image build, and
31// `node prompt.mjs --check` fails when it has drifted from review.rs.
32if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) {
33 const out = fileURLToPath(new URL("./agent/instructions.txt", import.meta.url));
34 const text = instructionsFromRust();
35 if (process.argv.includes("--check")) {
36 let current = "";
37 try {
38 current = readFileSync(out, "utf8");
39 } catch {}
40 if (current !== text) {
41 console.error("bench/reviewbench/agent/instructions.txt is out of date; run node bench/reviewbench/prompt.mjs");
42 process.exit(1);
43 }
44 } else {
45 const { writeFileSync } = await import("node:fs");
46 writeFileSync(out, text);
47 console.log(`wrote ${out} (${text.length} chars)`);
48 }
49}