g1t/bench/reviewbench/prompt.mjs
Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Research: shipping CSS, and a ReviewBench harness for g1t's reviewer | 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), workspace memory and the context hub. Benchmark repos | |
| 8 | // have none of g1t's memory, so only the repository files apply; Claude | |
| 9 | // Code reads CLAUDE.md from the checkout by itself, as it does in a | |
| 10 | // trusted production run. | |
| 11 | ||
| 12 | import { readFileSync } from "node:fs"; | |
| 13 | import { fileURLToPath } from "node:url"; | |
| 14 | ||
| 15 | const REVIEW_RS = fileURLToPath(new URL("../../crates/runner/src/review.rs", import.meta.url)); | |
| 16 | ||
| 17 | /** The `INSTRUCTIONS` constant of review.rs, unescaped as rustc would. */ | |
| 18 | export function instructionsFromRust(source = readFileSync(REVIEW_RS, "utf8")) { | |
| 19 | const match = source.match(/const INSTRUCTIONS: &str = "([\s\S]*?)";\n/); | |
| 20 | if (!match) throw new Error("INSTRUCTIONS not found in review.rs; update bench/reviewbench/prompt.mjs"); | |
| 21 | return match[1] | |
| 22 | // A backslash at the end of a line continues the string and eats the | |
| 23 | // next line's leading whitespace. | |
| 24 | .replace(/\\\n\s*/g, "") | |
| 25 | .replace(/\\"/g, '"') | |
| 26 | .replace(/\\n/g, "\n") | |
| 27 | .replace(/\\\\/g, "\\"); | |
| 28 | } | |
| 29 | ||
| 30 | export { buildPrompt } from "./agent/prompt-lib.mjs"; | |
| 31 | ||
| 32 | // `node prompt.mjs` writes instructions.txt for the image build, and | |
| 33 | // `node prompt.mjs --check` fails when it has drifted from review.rs. | |
| 34 | if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) { | |
| 35 | const out = fileURLToPath(new URL("./agent/instructions.txt", import.meta.url)); | |
| 36 | const text = instructionsFromRust(); | |
| 37 | if (process.argv.includes("--check")) { | |
| 38 | let current = ""; | |
| 39 | try { | |
| 40 | current = readFileSync(out, "utf8"); | |
| 41 | } catch {} | |
| 42 | if (current !== text) { | |
| 43 | console.error("bench/reviewbench/agent/instructions.txt is out of date; run node bench/reviewbench/prompt.mjs"); | |
| 44 | process.exit(1); | |
| 45 | } | |
| 46 | } else { | |
| 47 | const { writeFileSync } = await import("node:fs"); | |
| 48 | writeFileSync(out, text); | |
| 49 | console.log(`wrote ${out} (${text.length} chars)`); | |
| 50 | } | |
| 51 | } |