Skip to content

FrancyJGLisboa/agent-skills-platform / references/examples/pr-blocker-summarizer

pr-blocker-summarizer

Unverified

Summarizes open pull requests into a blockers-first standup digest. Activates when the user asks to summarize open PRs, find blocked pull requests, generate a PR standup, or triage review backlog from a PR export.

scripts/run_pipeline.py

View on GitHub
#!/usr/bin/env python3
"""Deterministic entry-point for the pr-blocker-summarizer skill.

Reads a JSON array of open PRs, classifies each as blocked or ready, and writes a
blockers-first digest. Stdlib-only.

    python3 scripts/run_pipeline.py --input prs.json --output digest.json
"""

from __future__ import annotations

import argparse
import json
import sys
from pathlib import Path

STALE_DAYS = 7


def blockers_for(pr: dict) -> list[str]:
    """Return the list of reasons a PR is blocked (empty list = not blocked)."""
    reasons: list[str] = []
    if pr.get("checks") == "failing":
        reasons.append("failing checks")
    if pr.get("review") == "changes_requested":
        reasons.append("changes requested")
    if pr.get("review") == "pending":
        reasons.append("awaiting review")
    try:
        if int(pr.get("age_days", 0)) >= STALE_DAYS:
            reasons.append(f"stale ({pr['age_days']}d)")
    except (TypeError, ValueError):
        pass
    return reasons


def summarize(prs: list[dict]) -> dict:
    """Split PRs into blocked vs. ready and build a one-line summary."""
    blocked: list[dict] = []
    ready: list[str] = []
    for pr in prs:
        title = pr.get("title", "(untitled)")
        reasons = blockers_for(pr)
        if reasons:
            blocked.append({"title": title, "reasons": reasons})
        elif pr.get("checks") == "passing" and pr.get("review") == "approved":
            ready.append(title)
    return {
        "total": len(prs),
        "blocked": blocked,
        "ready": ready,
        "summary": f"{len(prs)} open · {len(blocked)} blocked · {len(ready)} ready to merge",
    }


def run_pipeline(input_path: Path, output_path: Path) -> Path:
    """Read the PR JSON array, build the digest, write JSON. Return output path."""
    prs = json.loads(input_path.read_text(encoding="utf-8"))
    if not isinstance(prs, list):
        raise ValueError("input must be a JSON array of pull requests")
    output_path.write_text(json.dumps(summarize(prs), indent=2), encoding="utf-8")
    return output_path


def main(argv: list[str] | None = None) -> int:
    parser = argparse.ArgumentParser(description="Summarize open PRs into a digest.")
    parser.add_argument("--input", required=True, help="JSON array of PRs.")
    parser.add_argument("--output", required=True, help="Where to write digest JSON.")
    args = parser.parse_args(argv)
    try:
        run_pipeline(Path(args.input), Path(args.output))
    except (OSError, ValueError, json.JSONDecodeError) as exc:
        print(json.dumps({"error": str(exc), "error_type": "runtime"}), file=sys.stderr)
        return 1
    return 0


if __name__ == "__main__":
    raise SystemExit(main())
add-product-e2e-evalpaperclipai/paperclipAdd or extend a Paperclip full-stack runner E2E workflow, fixture, matcher, or report evidence path for local or Daytona execution.Stars: 115kUpdated Claude CodeCodexVerifiedInstall
add-runner-evalpaperclipai/paperclipAdd or extend a Paperclip Runner protocol evaluation definition, roster, assertion, or report fixture with provenance and narrow validation.Stars: 115kUpdated Claude CodeCodexVerifiedInstall
diagnose-why-work-stoppedpaperclipai/paperclipCompatibility entry point for failed, stalled, looping, or over-recovered Paperclip work. Use fix-failed-paperclip-run for the full diagnosis, regression, repair, real verification, and green-PR workflow; honor an explicitly requested diagnosis-only scope.Stars: 115kUpdated Claude CodeCodexVerifiedInstall
fix-failed-paperclip-runpaperclipai/paperclipDiagnose and fix failed, stuck, slow, or incorrectly blocked Paperclip tasks and runs. Use with a task/run URL or failure report to trace the root cause, prove a regression red then green, check second-order effects, verify the real workflow, and deliver a PR with passing checks.Stars: 115kUpdated Claude CodeCodexVerifiedInstall