(parsedResult, meta)
| 209 | } |
| 210 | |
| 211 | export function renderReviewResult(parsedResult, meta) { |
| 212 | if (!parsedResult.parsed) { |
| 213 | const lines = [ |
| 214 | `# Codex ${meta.reviewLabel}`, |
| 215 | "", |
| 216 | "Codex did not return valid structured JSON.", |
| 217 | "", |
| 218 | `- Parse error: ${parsedResult.parseError}` |
| 219 | ]; |
| 220 | |
| 221 | if (parsedResult.rawOutput) { |
| 222 | lines.push("", "Raw final message:", "", "```text", parsedResult.rawOutput, "```"); |
| 223 | } |
| 224 | |
| 225 | appendReasoningSection(lines, meta.reasoningSummary ?? parsedResult.reasoningSummary); |
| 226 | |
| 227 | return `${lines.join("\n").trimEnd()}\n`; |
| 228 | } |
| 229 | |
| 230 | const validationError = validateReviewResultShape(parsedResult.parsed); |
| 231 | if (validationError) { |
| 232 | const lines = [ |
| 233 | `# Codex ${meta.reviewLabel}`, |
| 234 | "", |
| 235 | `Target: ${meta.targetLabel}`, |
| 236 | "Codex returned JSON with an unexpected review shape.", |
| 237 | "", |
| 238 | `- Validation error: ${validationError}` |
| 239 | ]; |
| 240 | |
| 241 | if (parsedResult.rawOutput) { |
| 242 | lines.push("", "Raw final message:", "", "```text", parsedResult.rawOutput, "```"); |
| 243 | } |
| 244 | |
| 245 | appendReasoningSection(lines, meta.reasoningSummary ?? parsedResult.reasoningSummary); |
| 246 | |
| 247 | return `${lines.join("\n").trimEnd()}\n`; |
| 248 | } |
| 249 | |
| 250 | const data = normalizeReviewResultData(parsedResult.parsed); |
| 251 | const findings = [...data.findings].sort((left, right) => severityRank(left.severity) - severityRank(right.severity)); |
| 252 | const lines = [ |
| 253 | `# Codex ${meta.reviewLabel}`, |
| 254 | "", |
| 255 | `Target: ${meta.targetLabel}`, |
| 256 | `Verdict: ${data.verdict}`, |
| 257 | "", |
| 258 | data.summary, |
| 259 | "" |
| 260 | ]; |
| 261 | |
| 262 | if (findings.length === 0) { |
| 263 | lines.push("No material findings."); |
| 264 | } else { |
| 265 | lines.push("Findings:"); |
| 266 | for (const finding of findings) { |
| 267 | const lineSuffix = formatLineRange(finding); |
| 268 | lines.push(`- [${finding.severity}] ${finding.title} (${finding.file}${lineSuffix})`); |
no test coverage detected