|
1 | 1 | --- |
2 | 2 | name: pr-triage |
3 | 3 | description: >- |
4 | | - Assess open pull requests and review queue state in python-roborock, optionally syncing the local workspace with upstream/main. Use when asked what needs to be reviewed, to triage open PRs, or to sync and check the review backlog. |
| 4 | + Assess open pull requests, incoming issues, and review queue state in python-roborock, optionally syncing the local workspace with upstream/main. Use when asked what needs to be reviewed, to triage open PRs or incoming issues, or to sync and check the review backlog. |
5 | 5 | --- |
6 | 6 |
|
7 | | -# PR Triage & Review Queue Skill |
| 7 | +# PR & Issue Triage Skill |
8 | 8 |
|
9 | | -Use this skill when assessing open pull requests, checking which PRs need initial review or re-review, or syncing the workspace before starting a review session. |
| 9 | +Use this skill when assessing open pull requests, triaging incoming issues, checking which PRs need initial review or re-review, or syncing the workspace before starting a review session. |
10 | 10 |
|
11 | 11 | Once the user selects a specific PR to review, switch to the [Code Review Skill](../code-review/SKILL.md). |
12 | 12 |
|
13 | 13 | --- |
14 | 14 |
|
15 | 15 | ## Workflow |
16 | 16 |
|
17 | | -1. **Optional Workspace Sync**: |
18 | | - If the user asks to sync (e.g., "sync and check reviews") or the workspace is a clean review branch behind `upstream/main`: |
| 17 | +1. **Workspace Fetch & Optional Sync**: |
| 18 | + Always `git fetch upstream main` so local context reflects current `upstream/main`. If the user asks to sync (e.g., "sync and check reviews") or the workspace is a clean review branch behind `upstream/main`: |
19 | 19 | - Verify clean working tree (`git status --short`). Do **not** fast-forward or rebase if uncommitted local changes exist unless asked. |
20 | 20 | - Fetch remotes (`git fetch --all --prune`). |
21 | 21 | - Fast-forward the local tracking branch to `upstream/main` (or `origin/main` if `upstream` is absent): `git merge --ff-only upstream/main`. |
22 | 22 |
|
23 | | -2. **Query Open PR & Review Metadata**: |
24 | | - Identify the current GitHub user and fetch open PR state in a single `gh` pass so no per-PR polling is needed: |
| 23 | +2. **Run the Single-Pass Triage Script**: |
| 24 | + Execute [`scripts/triage.py`](scripts/triage.py) with `prs`, `issues`, or `all` depending on what the user asked to triage. Each subcommand runs a single GraphQL call (up to 100 open PRs / 50 open issues) without hitting `gh pr list` node-count limits: |
25 | 25 | ```bash |
26 | | - REVIEWER=$(gh api user --jq .login) |
27 | | - gh pr list --repo Python-roborock/python-roborock --state open --limit 30 \ |
28 | | - --json number,title,author,isDraft,createdAt,updatedAt,additions,deletions,mergeable,reviewDecision,headRefOid,reviews,commits,comments \ |
29 | | - | jq --arg me "$REVIEWER" ' |
30 | | - sort_by(.number) | reverse | .[] | .author.login as $pr_author | { |
31 | | - number, |
32 | | - title, |
33 | | - author: $pr_author, |
34 | | - isDraft, |
35 | | - mergeable, |
36 | | - size: "+\(.additions)/-\(.deletions)", |
37 | | - reviewDecision, |
38 | | - headRefOid, |
39 | | - lastCommit: (.commits | last | .committedDate), |
40 | | - myLastReview: ([.reviews[] | select(.author.login == $me)] | last | {state, submittedAt, commitOid: .commit.oid}), |
41 | | - otherLastReview: ([.reviews[] | select(.author.login != $me and .author.login != $pr_author and .author.login != "copilot-pull-request-reviewer")] | last | {author: .author.login, state, submittedAt}), |
42 | | - lastAuthorReplyAt: ( |
43 | | - [ |
44 | | - (.comments[] | select(.author.login == $pr_author) | .createdAt), |
45 | | - (.reviews[] | select(.author.login == $pr_author) | .submittedAt) |
46 | | - ] | max |
47 | | - ) |
48 | | - }' |
| 26 | + # Triage open PRs only (review buckets + suggested 5-PR batch) |
| 27 | + python3 .agents/skills/pr-triage/scripts/triage.py prs |
| 28 | + |
| 29 | + # Triage incoming open issues only (still cross-linking open PRs without dumping the PR queue) |
| 30 | + python3 .agents/skills/pr-triage/scripts/triage.py issues |
| 31 | + |
| 32 | + # Triage both open PRs and open issues in a single pass |
| 33 | + python3 .agents/skills/pr-triage/scripts/triage.py all |
49 | 34 | ``` |
50 | | - *(Note: GitHub's GraphQL `reviews` array includes `COMMENTED` entries whenever an author replies in an inline review thread, so combining `.comments[]` and `.reviews[]` filtered to `$pr_author` captures both top-level PR comments and inline review-thread replies without extra API calls.)* |
| 35 | + *(Pass `--json` if structured output is needed for custom filtering.)* |
51 | 36 |
|
52 | | -3. **Classify PRs into Actionable Buckets**: |
53 | | - Group open PRs in priority order for the reviewer (`$REVIEWER`): |
54 | | - - **1. New PRs Awaiting Initial Review**: |
55 | | - Non-draft PRs not authored by `$REVIEWER` where `myLastReview.submittedAt == null`. Flag competing/overlapping PRs targeting the same module/issue and note if another maintainer already commented/approved. |
56 | | - - **2. Re-reviews Needed (Updated Since Last Review)**: |
57 | | - Non-draft PRs not authored by `$REVIEWER` where `myLastReview.submittedAt != null` AND (`headRefOid != myLastReview.commitOid` OR `(lastAuthorReplyAt != null and lastAuthorReplyAt > myLastReview.submittedAt)`). Comparing `headRefOid != myLastReview.commitOid` catches amended, rebased, or cherry-picked commits whose `committedDate` precedes `myLastReview.submittedAt`. |
58 | | - - **3. Approved & Ready to Merge / Own PR Updates**: |
59 | | - - Non-draft PRs (authored by `$REVIEWER` or contributors) that are `APPROVED` (`reviewDecision == "APPROVED"`), `MERGEABLE`, and have no unreviewed commits since approval (`headRefOid == myLastReview.commitOid` or authored by `$REVIEWER`). |
60 | | - - Non-draft PRs authored by `$REVIEWER` with new review feedback or merge conflicts requiring action. |
61 | | - - **4. Waiting on Author / Drafts (Compact Summary)**: |
62 | | - - Non-draft PRs with `CHANGES_REQUESTED` or `COMMENTED` where `headRefOid == myLastReview.commitOid` and no new author replies (`lastAuthorReplyAt <= myLastReview.submittedAt`) have arrived. |
63 | | - - Draft PRs (`isDraft == true`), summarized compactly on 1–2 lines unless a draft has notable recent maintainer discussion. |
64 | | - - Conflicting (`mergeable == "CONFLICTING"`) or stale backlog items. |
| 37 | +3. **Verify Actionable Buckets**: |
| 38 | + The script classifies open PRs for the authenticated reviewer into four priority buckets: |
| 39 | + - **1. New PRs Awaiting Initial Review**: Non-draft contributor PRs you have not yet reviewed, annotated with file overlaps (`overlaps #...`), referenced issues, CI state (`SUCCESS`, `FAILURE`, `PENDING_APPROVAL`), and other maintainer reviews. |
| 40 | + - **2. Re-reviews Needed**: Non-draft PRs where `headRefOid != myLastReview.commitOid` (catches amended/rebased commits) or the author replied after `myLastReview.submittedAt`. |
| 41 | + - **3. Ready to Merge / Own PRs**: Approved, mergeable PRs with no unreviewed commits, plus your own open PRs (highlighting merge conflicts or unresolved Copilot/review threads). |
| 42 | + - **4. Waiting on Author & Drafts**: Compact summary of PRs awaiting contributor changes and draft PRs. |
65 | 43 |
|
66 | 44 | 4. **Present Concise Triage Report**: |
67 | 45 | - Report sync status in one line if a sync was performed (commit hash + any new release tags). |
68 | | - - List actionable PRs (`#number`, title, `@author`, `+additions/-deletions`, and why it needs attention—e.g., *opened Oct 31* or *updated Oct 22 after your Oct 17 review*). |
69 | | - - Keep "Waiting on Author / Drafts" brief so actionable reviews stand out. |
70 | | - - Ask which PR the user wants to review first. |
| 46 | + - **Always preserve clickable Markdown links** (`[#number](url)`) for every PR and issue mentioned. |
| 47 | + - Highlight high-signal relationships (e.g., competing PRs touching the same module, stacked PR series from the same author, or issues already addressed by an open PR). |
| 48 | + - Conclude with the **Suggested Next Review Batch (3–5 non-overlapping PRs)** ordered from quick green-CI wins to high-impact bugfixes, noting any PRs awaiting first-time contributor CI approval. |
0 commit comments