From 83a153bf70bb5eea7f04d03d7bc7292e34c72974 Mon Sep 17 00:00:00 2001 From: hsliuustc0106 Date: Mon, 13 Apr 2026 08:43:18 +0800 Subject: [PATCH] Fix pre-commit issues in review-pr skill Signed-off-by: hsliuustc0106 --- .claude/skills/review-pr/SKILL.md | 2 +- .../review-pr/references/diffusion-checklist.md | 6 +++--- .../review-pr/references/tests-docs-checklist.md | 1 - .claude/skills/review-pr/scripts/check_replies.sh | 12 ++++++------ .claude/skills/review-pr/scripts/select_prs.sh | 6 +++--- .../skills/review-pr/scripts/verify_line_numbers.sh | 10 +++++----- 6 files changed, 18 insertions(+), 19 deletions(-) diff --git a/.claude/skills/review-pr/SKILL.md b/.claude/skills/review-pr/SKILL.md index 1363482be..fcc4ae691 100644 --- a/.claude/skills/review-pr/SKILL.md +++ b/.claude/skills/review-pr/SKILL.md @@ -56,7 +56,7 @@ Always run the blocker scan. Under context pressure, do a shallow scan of the mo ## Core Workflow -Check whether this PR is still a draft or WIP in the PR title, if so, end the review process. +Check whether this PR is still a draft or WIP in the PR title, if so, end the review process. ### Step 0: Verify Review Gates First diff --git a/.claude/skills/review-pr/references/diffusion-checklist.md b/.claude/skills/review-pr/references/diffusion-checklist.md index bd2698008..c3c18a9ef 100644 --- a/.claude/skills/review-pr/references/diffusion-checklist.md +++ b/.claude/skills/review-pr/references/diffusion-checklist.md @@ -115,9 +115,9 @@ curl -s http://localhost:8091/v1/chat/completions \ ### Performance Measurements -**Hardware:** 1× NVIDIA A100 80GB -**Resolution:** 1024×1024 -**Steps:** 50 +**Hardware:** 1× NVIDIA A100 80GB +**Resolution:** 1024×1024 +**Steps:** 50 | Metric | Value | |--------|-------| diff --git a/.claude/skills/review-pr/references/tests-docs-checklist.md b/.claude/skills/review-pr/references/tests-docs-checklist.md index 0ec395ea0..7b94ec5ae 100644 --- a/.claude/skills/review-pr/references/tests-docs-checklist.md +++ b/.claude/skills/review-pr/references/tests-docs-checklist.md @@ -109,4 +109,3 @@ Commands: - Changes gated behind a new flag that defaults to disabled (document expected perf when enabled) **Reviewer-side verification:** For independently verifying contributor perf claims (running benchmarks yourself), see [perf-verification.md](perf-verification.md). This checklist defines what contributors must provide; that reference defines how reviewers can verify it. - diff --git a/.claude/skills/review-pr/scripts/check_replies.sh b/.claude/skills/review-pr/scripts/check_replies.sh index 02449d511..acd7d9b7e 100644 --- a/.claude/skills/review-pr/scripts/check_replies.sh +++ b/.claude/skills/review-pr/scripts/check_replies.sh @@ -39,11 +39,11 @@ for PR_NUM in $REVIEWED_PRS; do # Get all review comments on this PR COMMENTS=$(gh api "repos/${REPO}/pulls/${PR_NUM}/comments" \ --jq '[.[] | {id, user: .user.login, body: .body[:100], in_reply_to_id, created_at, path, url: .html_url}]' 2>/dev/null) - + # Find threads: reviewer's comments that got a reply, but reviewer didn't reply back # 1. Get reviewer's comment IDs REVIEWER_IDS=$(echo "$COMMENTS" | jq -r --arg r "$REVIEWER" '[.[] | select(.user == $r) | .id]') - + # 2. Find replies to reviewer's comments (from others) REPLIES=$(echo "$COMMENTS" | jq -c --arg r "$REVIEWER" --argjson rids "$REVIEWER_IDS" ' [.[] | @@ -52,24 +52,24 @@ for PR_NUM in $REVIEWED_PRS; do select([.in_reply_to_id] | inside($rids)) ] ') - + REPLY_COUNT=$(echo "$REPLIES" | jq 'length') if [ "$REPLY_COUNT" -eq 0 ]; then continue fi - + # 3. For each reply, check if reviewer replied after it echo "$REPLIES" | jq -c '.[]' | while read -r reply; do REPLY_ID=$(echo "$reply" | jq -r '.id') REPLY_DATE=$(echo "$reply" | jq -r '.created_at') REPLY_USER=$(echo "$reply" | jq -r '.user') REPLY_URL=$(echo "$reply" | jq -r '.url') - + # Check if reviewer replied after this reply FOLLOWUP=$(echo "$COMMENTS" | jq --arg r "$REVIEWER" --arg date "$REPLY_DATE" --argjson rid "$REPLY_ID" ' [.[] | select(.user == $r) | select(.in_reply_to_id == $rid) | select(.created_at > $date)] | length ') - + if [ "$FOLLOWUP" -eq 0 ]; then REPLY_BODY=$(echo "$reply" | jq -r '.body') echo "PR #${PR_NUM} | @${REPLY_USER} replied | ${REPLY_URL}" diff --git a/.claude/skills/review-pr/scripts/select_prs.sh b/.claude/skills/review-pr/scripts/select_prs.sh index 18ae67f6a..8a9b657d1 100644 --- a/.claude/skills/review-pr/scripts/select_prs.sh +++ b/.claude/skills/review-pr/scripts/select_prs.sh @@ -54,10 +54,10 @@ echo "Checking review status for $(echo "$FILTERED" | jq length) PRs..." >&2 echo "$FILTERED" | jq -c '.[]' | while read -r pr; do NUM=$(echo "$pr" | jq -r '.number') - + # Get review count REVIEW_COUNT=$(gh api "repos/${REPO}/pulls/${NUM}/reviews" --jq 'length' 2>/dev/null || echo "0") - + # Check if reviewer already reviewed if [ -n "$REVIEWER" ]; then ALREADY=$(gh api "repos/${REPO}/pulls/${NUM}/reviews" \ @@ -66,6 +66,6 @@ echo "$FILTERED" | jq -c '.[]' | while read -r pr; do continue fi fi - + echo "$pr" | jq --argjson rc "$REVIEW_COUNT" '. + {reviewCount: $rc}' done | jq -s "sort_by(.reviewCount) | .[:${LIMIT}]" diff --git a/.claude/skills/review-pr/scripts/verify_line_numbers.sh b/.claude/skills/review-pr/scripts/verify_line_numbers.sh index b7c770000..0f25cf900 100644 --- a/.claude/skills/review-pr/scripts/verify_line_numbers.sh +++ b/.claude/skills/review-pr/scripts/verify_line_numbers.sh @@ -23,16 +23,16 @@ echo "$REVIEW_JSON" | jq -c '.comments[]' | while read -r comment; do FILE=$(echo "$comment" | jq -r '.path') LINE=$(echo "$comment" | jq -r '.line') BODY=$(echo "$comment" | jq -r '.body[:60]') - + # Extract the file's diff FILE_DIFF=$(echo "$DIFF" | sed -n "/^diff --git a\/${FILE//\//\/}/,/^diff --git/p" | head -n -1) - + if [ -z "$FILE_DIFF" ]; then echo "ERROR: File not in diff: ${FILE}" >&2 ERRORS=$((ERRORS + 1)) continue fi - + # Check if the line falls within any hunk IN_HUNK=false while IFS= read -r hunk_header; do @@ -40,13 +40,13 @@ echo "$REVIEW_JSON" | jq -c '.comments[]' | while read -r comment; do NEW_START=$(echo "$hunk_header" | grep -oP '\+\K[0-9]+') NEW_COUNT=$(echo "$hunk_header" | grep -oP '\+[0-9]+,\K[0-9]+' || echo "1") NEW_END=$((NEW_START + NEW_COUNT - 1)) - + if [ "$LINE" -ge "$NEW_START" ] && [ "$LINE" -le "$NEW_END" ]; then IN_HUNK=true break fi done < <(echo "$FILE_DIFF" | grep '^@@') - + if [ "$IN_HUNK" = false ]; then echo "ERROR: Line ${LINE} in ${FILE} is outside all diff hunks" >&2 echo " Comment: ${BODY}..." >&2