diff --git a/.agents/skills/fix-ready-prs/SKILL.md b/.agents/skills/fix-ready-prs/SKILL.md new file mode 100644 index 0000000000..3e7d6cd7c6 --- /dev/null +++ b/.agents/skills/fix-ready-prs/SKILL.md @@ -0,0 +1,170 @@ +--- +name: fix-ready-prs +description: Inspect every open non-draft PR for CI failures and unresolved Cursor Bugbot findings, then fix them on the existing PR branches. Use when asked to check active PRs, triage ready PRs, fix CI, or address Bugbot comments. +metadata: + internal: true +--- + +# Fix Ready PRs + +Work through every **open, non-draft** pull request. Fix CI failures and +unresolved Bugbot findings on the existing PR branch. Do not open a new PR for +an existing one. + +Drafts are out of scope unless the user names them. + +## 1. Inventory + +```bash +gh pr list --state open --limit 200 \ + --json number,title,isDraft,headRefName,headRepositoryOwner,isCrossRepository,url,mergeStateStatus +``` + +Keep only `isDraft == false`. Record number, branch, URL, and whether the head +is a fork (`isCrossRepository`). + +## 2. Collect failures + +For each ready PR, gather **current-head** CI and **unresolved** Bugbot threads. +Do not treat an in-progress check as green. + +### CI + +```bash +gh pr checks +gh pr view --json statusCheckRollup,headRefOid +``` + +Treat as a failure when a required or repo workflow check is `FAILURE`, +`TIMED_OUT`, `ACTION_REQUIRED`, or `CANCELLED` on the current head and has not +been superseded by a newer run. + +Ignore: + +- `SKIPPED` / `NEUTRAL` +- Netlify header/pages/redirect checks and canceled deploy previews +- Mintlify Deployment skips +- macOS/Windows/iOS jobs that this repo skips on pull requests + +If a failing job has logs, pull them: + +```bash +gh run view --log-failed +``` + +If checks are still `IN_PROGRESS` / `pending`, wait until they finish or fail +before declaring the PR clean. Re-poll rather than guessing. + +### Bugbot + +Use review threads, not only the Bugbot check conclusion. A green Bugbot check +can still leave unresolved comments, and an older finding may already be +fixed. + +GitHub returns `reviewThreads` oldest-first with no unresolved-only filter. +Page until `hasNextPage` is false. Do not stop at the first 50 threads. + +```bash +after="" +while :; do + if [ -n "$after" ]; then + page=$(gh api graphql -f query="$THREADS_QUERY" -F n= -F after="$after") + else + page=$(gh api graphql -f query="$THREADS_QUERY" -F n=) + fi + echo "$page" | jq '.data.repository.pullRequest.reviewThreads.nodes[]' + has_next=$(echo "$page" | jq -r '.data.repository.pullRequest.reviewThreads.pageInfo.hasNextPage') + after=$(echo "$page" | jq -r '.data.repository.pullRequest.reviewThreads.pageInfo.endCursor') + [ "$has_next" = true ] || break +done +``` + +`$THREADS_QUERY` is: + +```graphql +query($n: Int!, $after: String) { + repository(owner: "fastrepl", name: "anarlog") { + pullRequest(number: $n) { + reviewThreads(first: 50, after: $after) { + pageInfo { hasNextPage endCursor } + nodes { + isResolved + isOutdated + comments(first: 5) { + nodes { author { login } path line body } + } + } + } + } + } +} +``` + +Fix a thread when: + +- the author is `cursor` / `cursor[bot]` +- `isResolved` is false +- the comment is a Bugbot finding (`