import type { CollectedDiff, Finding, ReviewRoundEntry } from "./types.js"; export function formatReviewMarkdown(round: ReviewRoundEntry): string { const lines: string[] = [`# Diff Review Round ${round.round}`, ""]; if (round.findings.length === 0) { lines.push("No findings recorded.", "", "Use this review result to decide whether any follow-up is needed. Do not edit files yet."); return lines.join("\n"); } lines.push("## Findings"); for (const finding of round.findings) lines.push(`- ${formatFinding(finding)}`); if (round.notes?.trim()) lines.push("", "## Notes", round.notes.trim()); lines.push("", "Use this review to propose and discuss a fix plan first. Do not edit files yet."); return lines.join("\n"); } export function makeReviewRound(round: number, diff: CollectedDiff, findings: Finding[], notes?: string): ReviewRoundEntry { return { version: 1, kind: "round", round, source: diff.source, findings, ...(notes?.trim() && { notes: notes.trim() }), diffSummary: { filesChanged: diff.files.length, additions: diff.additions, deletions: diff.deletions, skippedFiles: diff.skippedFiles, }, createdAt: new Date().toISOString(), }; } function formatFinding(finding: Finding): string { const range = finding.startLine === finding.endLine ? `${finding.startLine}` : `${finding.startLine}-${finding.endLine}`; return `[${finding.severity}][${finding.category}] ${finding.file}:${range} ${finding.side} — ${finding.comment}`; }