docs(skills/github-triage): fix Phase 1 JSON parsing and large repo handling
This commit is contained in:
@@ -79,47 +79,65 @@ Pass `REPO`, `REPORT_DIR`, and `COMMIT_SHA` to every subagent.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Phase 1: Fetch All Open Items
|
---
|
||||||
|
|
||||||
<fetch>
|
## Phase 1: Fetch All Open Items (CORRECTED)
|
||||||
Paginate if 500 results returned.
|
|
||||||
|
**IMPORTANT:** `body` and `comments` fields may contain control characters that break jq parsing. Fetch basic metadata first, then fetch full details per-item in subagents.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
ISSUES=$(gh issue list --repo $REPO --state open --limit 500 \
|
# Step 1: Fetch basic metadata (without body/comments to avoid JSON parsing issues)
|
||||||
--json number,title,state,createdAt,updatedAt,labels,author,body,comments)
|
ISSUES_LIST=$(gh issue list --repo $REPO --state open --limit 500 \
|
||||||
ISSUE_LEN=$(echo "$ISSUES" | jq length)
|
--json number,title,labels,author,createdAt)
|
||||||
if [ "$ISSUE_LEN" -eq 500 ]; then
|
ISSUE_COUNT=$(echo "$ISSUES_LIST" | jq length)
|
||||||
LAST_DATE=$(echo "$ISSUES" | jq -r '.[-1].createdAt')
|
|
||||||
|
# Paginate if needed
|
||||||
|
if [ "$ISSUE_COUNT" -eq 500 ]; then
|
||||||
|
LAST_DATE=$(echo "$ISSUES_LIST" | jq -r '.[-1].createdAt')
|
||||||
while true; do
|
while true; do
|
||||||
PAGE=$(gh issue list --repo $REPO --state open --limit 500 \
|
PAGE=$(gh issue list --repo $REPO --state open --limit 500 \
|
||||||
--search "created:<$LAST_DATE" \
|
--search "created:<$LAST_DATE" \
|
||||||
--json number,title,state,createdAt,updatedAt,labels,author,body,comments)
|
--json number,title,labels,author,createdAt)
|
||||||
PAGE_LEN=$(echo "$PAGE" | jq length)
|
PAGE_COUNT=$(echo "$PAGE" | jq length)
|
||||||
[ "$PAGE_LEN" -eq 0 ] && break
|
[ "$PAGE_COUNT" -eq 0 ] && break
|
||||||
ISSUES=$(echo "[$ISSUES, $PAGE]" | jq -s 'add | unique_by(.number)')
|
ISSUES_LIST=$(echo "$ISSUES_LIST" "$PAGE" | jq -s '.[0] + .[1] | unique_by(.number)')
|
||||||
[ "$PAGE_LEN" -lt 500 ] && break
|
ISSUE_COUNT=$(echo "$ISSUES_LIST" | jq length)
|
||||||
|
[ "$PAGE_COUNT" -lt 500 ] && break
|
||||||
LAST_DATE=$(echo "$PAGE" | jq -r '.[-1].createdAt')
|
LAST_DATE=$(echo "$PAGE" | jq -r '.[-1].createdAt')
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PRS=$(gh pr list --repo $REPO --state open --limit 500 \
|
# Same for PRs
|
||||||
--json number,title,state,createdAt,updatedAt,labels,author,body,headRefName,baseRefName,isDraft,mergeable,reviewDecision,statusCheckRollup)
|
PRS_LIST=$(gh pr list --repo $REPO --state open --limit 500 \
|
||||||
PR_LEN=$(echo "$PRS" | jq length)
|
--json number,title,labels,author,headRefName,baseRefName,isDraft,createdAt)
|
||||||
if [ "$PR_LEN" -eq 500 ]; then
|
PR_COUNT=$(echo "$PRS_LIST" | jq length)
|
||||||
LAST_DATE=$(echo "$PRS" | jq -r '.[-1].createdAt')
|
|
||||||
|
if [ "$PR_COUNT" -eq 500 ]; then
|
||||||
|
LAST_DATE=$(echo "$PRS_LIST" | jq -r '.[-1].createdAt')
|
||||||
while true; do
|
while true; do
|
||||||
PAGE=$(gh pr list --repo $REPO --state open --limit 500 \
|
PAGE=$(gh pr list --repo $REPO --state open --limit 500 \
|
||||||
--search "created:<$LAST_DATE" \
|
--search "created:<$LAST_DATE" \
|
||||||
--json number,title,state,createdAt,updatedAt,labels,author,body,headRefName,baseRefName,isDraft,mergeable,reviewDecision,statusCheckRollup)
|
--json number,title,labels,author,headRefName,baseRefName,isDraft,createdAt)
|
||||||
PAGE_LEN=$(echo "$PAGE" | jq length)
|
PAGE_COUNT=$(echo "$PAGE" | jq length)
|
||||||
[ "$PAGE_LEN" -eq 0 ] && break
|
[ "$PAGE_COUNT" -eq 0 ] && break
|
||||||
PRS=$(echo "[$PRS, $PAGE]" | jq -s 'add | unique_by(.number)')
|
PRS_LIST=$(echo "$PRS_LIST" "$PAGE" | jq -s '.[0] + .[1] | unique_by(.number)')
|
||||||
[ "$PAGE_LEN" -lt 500 ] && break
|
PR_COUNT=$(echo "$PRS_LIST" | jq length)
|
||||||
|
[ "$PAGE_COUNT" -lt 500 ] && break
|
||||||
LAST_DATE=$(echo "$PAGE" | jq -r '.[-1].createdAt')
|
LAST_DATE=$(echo "$PAGE" | jq -r '.[-1].createdAt')
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Total issues: $ISSUE_COUNT, Total PRs: $PR_COUNT"
|
||||||
```
|
```
|
||||||
</fetch>
|
|
||||||
|
**LARGE REPOSITORY HANDLING:**
|
||||||
|
If total items exceeds 50, you MUST process ALL items. Use the pagination code above to fetch every single open issue and PR.
|
||||||
|
**DO NOT** sample or limit to 50 items - process the entire backlog.
|
||||||
|
|
||||||
|
Example: If there are 500 open issues, spawn 500 subagents. If there are 1000 open PRs, spawn 1000 subagents.
|
||||||
|
|
||||||
|
**Note:** Background task system will queue excess tasks automatically.
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user