feat. append structured details to markdown comment in format_result_comment
This commit is contained in:
@@ -39,6 +39,9 @@ def format_result_comment(head_sha: str, result: dict, *, repo_configured: bool
|
||||
markdown_comment = result.get("markdown_comment")
|
||||
if isinstance(markdown_comment, str) and markdown_comment.strip():
|
||||
body = markdown_comment.strip()
|
||||
details = _format_structured_details(result)
|
||||
if details:
|
||||
body = f"{body}\n\n---\n\n{details}"
|
||||
if usage_note:
|
||||
body = f"{body}\n\n{usage_note}"
|
||||
if missing_config_note:
|
||||
@@ -108,3 +111,41 @@ def _format_missing_config_note(repo_configured: bool) -> str:
|
||||
if repo_configured:
|
||||
return ""
|
||||
return "> ℹ️.codex-review.yml is not configured"
|
||||
|
||||
|
||||
def _format_structured_details(result: dict) -> str:
|
||||
verdict = str(result.get("verdict", "has_issues"))
|
||||
summary = str(result.get("summary", "No summary returned."))
|
||||
confidence_raw = result.get("confidence", 0.0)
|
||||
try:
|
||||
confidence = float(confidence_raw)
|
||||
except (TypeError, ValueError):
|
||||
confidence = 0.0
|
||||
findings = result.get("findings", []) or []
|
||||
|
||||
lines = ["### Structured Findings", "", f"Verdict: `{verdict}`", f"Confidence: `{confidence:.2f}`", "", summary, ""]
|
||||
if not findings:
|
||||
lines.append("No blocking issues found.")
|
||||
return "\n".join(lines).strip()
|
||||
|
||||
lines.append("Findings:")
|
||||
for idx, finding in enumerate(findings, start=1):
|
||||
if not isinstance(finding, dict):
|
||||
lines.extend([f"{idx}. `unknown` (unknown)", " Issue", f" {finding}", " Suggestion: n/a"])
|
||||
continue
|
||||
severity = finding.get("severity", "unknown")
|
||||
file_path = finding.get("file", "unknown")
|
||||
line_start = finding.get("line_start", "?")
|
||||
line_end = finding.get("line_end", line_start)
|
||||
title = finding.get("title", "Issue")
|
||||
body = finding.get("body", "")
|
||||
suggestion = finding.get("suggestion", "")
|
||||
lines.extend(
|
||||
[
|
||||
f"{idx}. `{file_path}:{line_start}-{line_end}` ({severity})",
|
||||
f" {title}",
|
||||
f" {body}",
|
||||
f" Suggestion: {suggestion}" if suggestion else " Suggestion: n/a",
|
||||
]
|
||||
)
|
||||
return "\n".join(lines).strip()
|
||||
|
||||
Reference in New Issue
Block a user