Review file (#7)

The reviewer writes its review to a file whose first line is the verdict, instead of relying on a narration-free final message. Sonnet put `Yes` after three paragraphs of narration on memona #936 (review 595), which the fail-closed verdict posted as a plain comment.

Reviewed-on: #7
Co-authored-by: Danny Kim <temeddix@gmail.com>
Co-committed-by: Danny Kim <temeddix@gmail.com>
This commit was merged in pull request #7.
This commit is contained in:
2026-09-13 16:54:54 +00:00
committed by temeddix
parent a2bc4c9541
commit 0d109ebec8
2 changed files with 23 additions and 19 deletions
+11 -5
View File
@@ -59,9 +59,11 @@ async function postComment(body: string): Promise<void> {
});
}
// A pull request event is a review request, so the response becomes a review.
// Its first line is the verdict; anything unexpected only comments, never
// approves.
// A pull request event is a review request, so the review is posted instead
// of the response. It comes through a file, because a final chat message picks
// up narration while a file's first line is written on purpose. That line is
// the verdict; anything unexpected only comments, never approves.
const REVIEW_PATH = `${await Deno.makeTempDir()}/review.md`;
const VERDICTS: Record<string, string> = {
Yes: "APPROVED",
No: "REQUEST_CHANGES",
@@ -70,9 +72,12 @@ const VERDICTS: Record<string, string> = {
async function postResult(body: string): Promise<void> {
if (EVENT !== "pull_request") return postComment(body);
const [verdict] = body.split("\n", 1);
const review = await Deno.readTextFile(REVIEW_PATH).catch(() => {
throw new Error(`no review was written to ${REVIEW_PATH}`);
});
const [verdict] = review.split("\n", 1);
await gitea(REVIEWER_TOKEN, `repos/${REPO}/pulls/${INDEX}/reviews`, {
body: stripAnsi(body),
body: stripAnsi(review),
event: VERDICTS[verdict.trim()] ?? "COMMENT",
});
}
@@ -118,6 +123,7 @@ async function renderPrompt(): Promise<string> {
GITEA_API_URL: API,
GITEA_REPOSITORY: REPO,
ISSUE_INDEX: INDEX,
REVIEW_PATH,
};
const template = await Deno.readTextFile(
new URL("prompt.md", import.meta.url),