Project Files
src / agents / reviewer.ts
import { completeText, extractJson } from "../llm";
import type { BuildPlan, BuildReview } from "../types";
export class Reviewer {
constructor(private readonly model: any) {}
async run(input: {
plan: BuildPlan;
snapshot: string;
}): Promise<BuildReview> {
const prompt = [
"You are the Reviewer agent for Codechecker Forge.",
"Return JSON only. No markdown, no commentary.",
"Check for correctness, entrypoint export, plugin manifest consistency, and obvious loop or safety issues.",
"",
"Plan:",
JSON.stringify(input.plan, null, 2),
"",
"Workspace snapshot:",
input.snapshot,
"",
"Return exactly this JSON shape:",
`{ "passed": true, "issues": [] }`
].join("\n");
const raw = await completeText(this.model, prompt, 2200, 0.15);
try {
const review = extractJson<BuildReview>(raw);
review.issues = Array.isArray(review.issues) ? review.issues : [];
review.passed = Boolean(review.passed) && review.issues.length === 0;
return review;
} catch {
return {
passed: false,
issues: ["Reviewer produced invalid JSON"],
};
}
}
}