@yeongjaeyou/claude-code-config 0.18.2 → 0.18.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -17,138 +17,163 @@ Automatically fix and push until CodeRabbit review comments reach zero.
|
|
|
17
17
|
| Limit | Value | Purpose |
|
|
18
18
|
|-------|-------|---------|
|
|
19
19
|
| MAX_ITERATIONS | 10 | Prevent infinite loops |
|
|
20
|
-
| POLL_TIMEOUT | 300s | Wait for
|
|
20
|
+
| POLL_TIMEOUT | 300s | Wait for checks to complete |
|
|
21
21
|
| POLL_INTERVAL | 30s | Status check frequency |
|
|
22
22
|
|
|
23
|
-
## Workflow
|
|
23
|
+
## Workflow
|
|
24
24
|
|
|
25
25
|
```
|
|
26
|
-
|
|
27
|
-
│ 1. Init
|
|
28
|
-
│
|
|
29
|
-
│
|
|
30
|
-
|
|
26
|
+
┌───────────────────────────────────────────────────────────────┐
|
|
27
|
+
│ 1. Init │
|
|
28
|
+
│ ↓ │
|
|
29
|
+
│ ┌─────────────────────────────────────────────────────────┐ │
|
|
30
|
+
│ │ 2. Wait for All Checks (gh pr checks) │ │
|
|
31
|
+
│ │ ↓ │ │
|
|
32
|
+
│ │ 3. Check Unresolved Threads (GraphQL) │ │
|
|
33
|
+
│ │ ↓ │ │
|
|
34
|
+
│ │ 4. Fix, Commit, Push │ │
|
|
35
|
+
│ │ ↓ │ │
|
|
36
|
+
│ │ [loop back to 2 until resolved or max iterations] │ │
|
|
37
|
+
│ └─────────────────────────────────────────────────────────┘ │
|
|
38
|
+
│ ↓ │
|
|
39
|
+
│ 5. Output result │
|
|
40
|
+
└───────────────────────────────────────────────────────────────┘
|
|
31
41
|
```
|
|
32
42
|
|
|
33
43
|
### Step 1: Initialize
|
|
34
44
|
|
|
35
45
|
```bash
|
|
36
|
-
# Get PR info
|
|
37
46
|
PR_NUMBER=${ARGUMENTS:-$(gh pr view --json number -q .number 2>/dev/null)}
|
|
38
47
|
REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner)
|
|
39
|
-
SHA=$(gh pr view $PR_NUMBER --json commits --jq '.commits[-1].oid')
|
|
40
|
-
|
|
41
48
|
ITERATION=1
|
|
49
|
+
MAX_ITERATIONS=10
|
|
42
50
|
```
|
|
43
51
|
|
|
44
|
-
### Step 2: Wait for
|
|
52
|
+
### Step 2: Wait for All Checks
|
|
45
53
|
|
|
46
|
-
|
|
54
|
+
`gh pr checks`로 CodeRabbit과 Actions 상태를 한 번에 확인.
|
|
47
55
|
|
|
48
56
|
```bash
|
|
49
|
-
|
|
50
|
-
local
|
|
57
|
+
wait_for_all_checks() {
|
|
58
|
+
local elapsed=0
|
|
51
59
|
|
|
52
60
|
while [ $elapsed -lt 300 ]; do
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
elapsed=$((elapsed + 30))
|
|
61
|
+
CHECKS=$(gh pr checks $PR_NUMBER 2>/dev/null)
|
|
62
|
+
|
|
63
|
+
# pending/in_progress 있으면 대기
|
|
64
|
+
if echo "$CHECKS" | grep -qiE "pending|in_progress|running"; then
|
|
65
|
+
sleep 30
|
|
66
|
+
elapsed=$((elapsed + 30))
|
|
67
|
+
continue
|
|
68
|
+
fi
|
|
69
|
+
|
|
70
|
+
# fail 있으면 에러 (CodeRabbit fail은 제외 - 리뷰 코멘트가 있다는 의미)
|
|
71
|
+
if echo "$CHECKS" | grep -v "CodeRabbit" | grep -qi "fail"; then
|
|
72
|
+
return 2 # CI failed
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
return 0 # All checks completed
|
|
69
76
|
done
|
|
70
77
|
|
|
71
78
|
return 1 # Timeout
|
|
72
79
|
}
|
|
73
|
-
|
|
74
|
-
wait_for_coderabbit "$SHA" || {
|
|
75
|
-
echo "REVIEW_SKIPPED: CodeRabbit not responding within timeout"
|
|
76
|
-
exit 0
|
|
77
|
-
}
|
|
78
80
|
```
|
|
79
81
|
|
|
80
82
|
### Step 3: Check Unresolved Threads (GraphQL)
|
|
81
83
|
|
|
82
|
-
|
|
84
|
+
CodeRabbit 리뷰 코멘트 중 미해결 건수 확인. This is the ground truth.
|
|
83
85
|
|
|
84
86
|
```bash
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
87
|
+
check_unresolved_threads() {
|
|
88
|
+
RESULT=$(gh api graphql -f query='query {
|
|
89
|
+
repository(owner: "'"${REPO%/*}"'", name: "'"${REPO#*/}"'") {
|
|
90
|
+
pullRequest(number: '"$PR_NUMBER"') {
|
|
91
|
+
reviewThreads(first: 100) {
|
|
92
|
+
nodes {
|
|
93
|
+
isResolved
|
|
94
|
+
path
|
|
95
|
+
line
|
|
96
|
+
comments(first: 1) {
|
|
97
|
+
nodes {
|
|
98
|
+
author { login }
|
|
99
|
+
body
|
|
100
|
+
}
|
|
98
101
|
}
|
|
99
102
|
}
|
|
100
103
|
}
|
|
101
104
|
}
|
|
102
105
|
}
|
|
103
|
-
}
|
|
104
|
-
}'
|
|
106
|
+
}')
|
|
105
107
|
|
|
106
|
-
# Filter: unresolved + coderabbit + not nitpick
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
# Filter: unresolved + coderabbit + not nitpick
|
|
109
|
+
UNRESOLVED=$(echo "$RESULT" | jq '[.data.repository.pullRequest.reviewThreads.nodes[] |
|
|
110
|
+
select(.isResolved == false) |
|
|
111
|
+
select(.comments.nodes[0].author.login | ascii_downcase | contains("coderabbit")) |
|
|
112
|
+
select(.comments.nodes[0].body | (contains("[nitpick]") or contains("nitpick")) | not)]')
|
|
111
113
|
|
|
112
|
-
|
|
113
|
-
-f owner="${REPO%/*}" -f repo="${REPO#*/}" -F pr="$PR_NUMBER")
|
|
114
|
+
UNRESOLVED_COUNT=$(echo "$UNRESOLVED" | jq 'length')
|
|
114
115
|
|
|
115
|
-
|
|
116
|
+
# Extract comments for fixing
|
|
117
|
+
COMMENTS=$(echo "$UNRESOLVED" | jq -r '.[] |
|
|
118
|
+
"### File: \(.path):\(.line)\n\n\(.comments.nodes[0].body)\n\n---\n"')
|
|
119
|
+
}
|
|
120
|
+
```
|
|
116
121
|
|
|
117
|
-
|
|
118
|
-
echo "REVIEW_COMPLETE: all comments resolved"
|
|
119
|
-
exit 0
|
|
120
|
-
fi
|
|
122
|
+
### Step 4: Fix, Commit, Push
|
|
121
123
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
```bash
|
|
125
|
+
fix_and_push() {
|
|
126
|
+
# For each comment: analyze and fix
|
|
127
|
+
# Follow code-review.md guidelines for auto-fix vs manual
|
|
128
|
+
|
|
129
|
+
# After fixes applied:
|
|
130
|
+
if [ -z "$(git status --porcelain)" ]; then
|
|
131
|
+
return 1 # No changes made
|
|
132
|
+
fi
|
|
133
|
+
|
|
134
|
+
git add -u
|
|
135
|
+
git commit -m "fix: address CodeRabbit review (iteration $ITERATION)"
|
|
136
|
+
git push
|
|
137
|
+
}
|
|
125
138
|
```
|
|
126
139
|
|
|
127
|
-
###
|
|
140
|
+
### Main Loop
|
|
128
141
|
|
|
129
142
|
```bash
|
|
130
|
-
|
|
131
|
-
#
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
while [ $ITERATION -le $MAX_ITERATIONS ]; do
|
|
144
|
+
# Step 2: Wait for all checks
|
|
145
|
+
wait_for_all_checks
|
|
146
|
+
WAIT_RESULT=$?
|
|
147
|
+
|
|
148
|
+
if [ $WAIT_RESULT -eq 1 ]; then
|
|
149
|
+
echo "REVIEW_SKIPPED: checks not completing within timeout"
|
|
150
|
+
exit 0
|
|
151
|
+
elif [ $WAIT_RESULT -eq 2 ]; then
|
|
152
|
+
echo "REVIEW_BLOCKED: CI checks failed"
|
|
153
|
+
exit 1
|
|
154
|
+
fi
|
|
155
|
+
|
|
156
|
+
# Step 3: Check unresolved threads
|
|
157
|
+
check_unresolved_threads
|
|
158
|
+
|
|
159
|
+
if [ "$UNRESOLVED_COUNT" -eq 0 ]; then
|
|
160
|
+
echo "REVIEW_COMPLETE: all comments resolved"
|
|
161
|
+
exit 0
|
|
162
|
+
fi
|
|
163
|
+
|
|
164
|
+
# Step 4: Fix and push
|
|
165
|
+
# ... fix logic here using COMMENTS ...
|
|
166
|
+
|
|
167
|
+
fix_and_push || {
|
|
168
|
+
echo "REVIEW_COMPLETE: no changes needed"
|
|
169
|
+
exit 0
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
ITERATION=$((ITERATION + 1))
|
|
173
|
+
done
|
|
148
174
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
# Go to Step 2
|
|
175
|
+
echo "REVIEW_INCOMPLETE: max iterations ($MAX_ITERATIONS) reached, $UNRESOLVED_COUNT comments remaining"
|
|
176
|
+
exit 1
|
|
152
177
|
```
|
|
153
178
|
|
|
154
179
|
## Output Format
|
|
@@ -158,8 +183,10 @@ End with exactly one of:
|
|
|
158
183
|
| Output | Meaning |
|
|
159
184
|
|--------|---------|
|
|
160
185
|
| `REVIEW_COMPLETE: all comments resolved` | Success |
|
|
186
|
+
| `REVIEW_COMPLETE: no changes needed` | No fixes required |
|
|
161
187
|
| `REVIEW_INCOMPLETE: max iterations reached, N comments remaining` | Hit limit |
|
|
162
|
-
| `REVIEW_SKIPPED:
|
|
188
|
+
| `REVIEW_SKIPPED: checks not completing within timeout` | Timeout |
|
|
189
|
+
| `REVIEW_BLOCKED: CI checks failed` | CI failure |
|
|
163
190
|
|
|
164
191
|
## Fix Guidelines
|
|
165
192
|
|
|
@@ -175,4 +202,4 @@ Read `.claude/commands/code-review.md` for:
|
|
|
175
202
|
| PR not found | Exit with error |
|
|
176
203
|
| API rate limit | Increase interval, retry |
|
|
177
204
|
| Git push failed | Report and stop |
|
|
178
|
-
|
|
|
205
|
+
| CI checks failed | Exit with REVIEW_BLOCKED |
|