agent: implement issue #3 - Enhancement: 检查现有的代码框架,确认是否需要优化

This commit is contained in:
2026-05-06 16:13:24 +08:00
parent ee7300e31f
commit 19de4634bc
4 changed files with 90 additions and 18 deletions

View File

@@ -86,11 +86,13 @@ def render_pr_body(issue: IssueRecord, implementation_report: str) -> str:
def parse_review_report(raw: str) -> ReviewReport:
verdict_match = re.search(r"(?im)^\s*(?:##\s*)?Verdict\s*:?\s*`?([A-Z_]+)`?", raw)
verdict_match = re.search(r"(?im)^\s*(?:[-*]\s*)?(?:##\s*)?Verdict\s*:?\s*`?([A-Z_]+)`?", raw)
verdict = verdict_match.group(1) if verdict_match else "NEEDS_HUMAN_DECISION"
if verdict not in VALID_VERDICTS:
verdict = "NEEDS_HUMAN_DECISION"
suggested = extract_section(raw, "Suggested PR Comment").strip()
if not suggested:
suggested = extract_inline_field(raw, "Suggested PR Comment").strip()
if not suggested:
suggested = raw.strip()
return ReviewReport(verdict=verdict, raw=raw, suggested_pr_comment=suggested)
@@ -104,6 +106,12 @@ def extract_section(raw: str, title: str) -> str:
return match.group("body") if match else ""
def extract_inline_field(raw: str, title: str) -> str:
pattern = re.compile(rf"(?im)^\s*(?:[-*]\s*)?{re.escape(title)}\s*:\s*(?P<body>.+?)\s*$")
match = pattern.search(raw)
return match.group("body") if match else ""
def render_human_review_summary(review: ReviewReport) -> str:
return f"""## 代理评审摘要