"""Render the final PR comment from check results. The comment is rendered fully up-front. Checks whose status is `NEEDS_AGENT` get `{{CHECK_CELL::}}` and `{{CHECK_DETAIL::}}` placeholders that the agent replaces before posting. To add a new check kind: extend `CheckKind` and add an entry to `_CHECK_DISPLAY` below. The agent prompt must also gain a matching instruction section, or the agent will refuse to resolve the new kind. """ from .models import CheckKind, CheckRunResult, CheckStatus, PackageChange MARKER = "" # Hidden marker carrying the PR head commit the checks ran against. The agentic # stage's gate job parses it from the previous comment to decide whether any # tracked requirement file changed since then; if not, the agent is skipped. SHA_MARKER_PREFIX = "" parts.append(f"Checked at commit `{result.head_sha[:7]}`.") return "\n\n".join([f"{markers}\n{HEADER}", *parts]) def render_comment(result: CheckRunResult) -> str: """Build the full markdown comment, including placeholder markers.""" if not result.packages: return f"{_intro(result)}\n\nNo tracked requirement changes detected. ✅" return "\n\n".join( [ f"{_intro(result)}\n\n{_summary_line(result.packages)}", _table(result.packages), *[_details_block(p) for p in result.packages], ] )