|
| 1 | +from __future__ import annotations |
| 2 | + |
| 3 | +from pathlib import Path |
| 4 | + |
| 5 | +from .models import RunRecord, Task |
| 6 | + |
| 7 | + |
| 8 | +def render_review_report(task: Task, run: RunRecord, diff_text: str, stdout: str, stderr: str) -> str: |
| 9 | + checks = "\n".join( |
| 10 | + f"- {'✅' if c.get('returncode') == 0 else '❌'} `{c.get('command')}` — exit {c.get('returncode')}" |
| 11 | + for c in run.checks |
| 12 | + ) or "- No checks configured" |
| 13 | + changed_summary = "Diff captured." if diff_text.strip() else "No git diff captured." |
| 14 | + stdout_excerpt = stdout[-4000:] if stdout else "" |
| 15 | + stderr_excerpt = stderr[-4000:] if stderr else "" |
| 16 | + return f"""# AgentFlowDesk Review Report |
| 17 | +
|
| 18 | +## Task |
| 19 | +
|
| 20 | +- **ID:** `{task.id}` |
| 21 | +- **Title:** {task.title} |
| 22 | +- **Status:** {task.status} |
| 23 | +
|
| 24 | +## Run |
| 25 | +
|
| 26 | +- **Run ID:** `{run.id}` |
| 27 | +- **Agent:** `{run.agent}` |
| 28 | +- **Command:** `{run.command or '<manual / prompt only>'}` |
| 29 | +- **Started:** {run.started_at} |
| 30 | +- **Finished:** {run.finished_at or '<not finished>'} |
| 31 | +- **Status:** {run.status} |
| 32 | +
|
| 33 | +## Acceptance criteria |
| 34 | +
|
| 35 | +{chr(10).join(f'- [ ] {item}' for item in task.acceptance) or '- [ ] User review required'} |
| 36 | +
|
| 37 | +## Automated checks |
| 38 | +
|
| 39 | +{checks} |
| 40 | +
|
| 41 | +## Diff summary |
| 42 | +
|
| 43 | +{changed_summary} |
| 44 | +
|
| 45 | +Full diff path: `{run.diff_path or '<none>'}` |
| 46 | +
|
| 47 | +## Stdout excerpt |
| 48 | +
|
| 49 | +```text |
| 50 | +{stdout_excerpt} |
| 51 | +``` |
| 52 | +
|
| 53 | +## Stderr excerpt |
| 54 | +
|
| 55 | +```text |
| 56 | +{stderr_excerpt} |
| 57 | +``` |
| 58 | +
|
| 59 | +## Human review checklist |
| 60 | +
|
| 61 | +- [ ] The diff is focused on the task goal. |
| 62 | +- [ ] No unrelated files were changed. |
| 63 | +- [ ] Tests/checks are sufficient. |
| 64 | +- [ ] Documentation was updated when needed. |
| 65 | +- [ ] The task can be marked as done. |
| 66 | +""" |
0 commit comments