@torka/claude-workflows 0.4.0 → 0.6.0
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.
- package/commands/github-pr-resolve.md +231 -335
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: '
|
|
2
|
+
description: 'Autonomously process, fix, and merge all open PRs with minimal user interaction'
|
|
3
3
|
---
|
|
4
4
|
|
|
5
5
|
IT IS CRITICAL THAT YOU FOLLOW THIS WORKFLOW EXACTLY.
|
|
@@ -16,431 +16,327 @@ Before any operations, verify the environment is safe:
|
|
|
16
16
|
|
|
17
17
|
3. **Detect default branch**: Run `gh repo view --json defaultBranchRef -q .defaultBranchRef.name`. Fallback to `main` if this fails.
|
|
18
18
|
|
|
19
|
-
4. **
|
|
19
|
+
4. **Detect repository merge strategy**:
|
|
20
|
+
- Run: `gh repo view --json squashMergeAllowed,mergeCommitAllowed,rebaseMergeAllowed`
|
|
21
|
+
- Determine preferred strategy in order: squash > merge > rebase
|
|
22
|
+
- Store for use in Phase 4 merge commands
|
|
23
|
+
- Default to `--squash` if detection fails
|
|
24
|
+
|
|
25
|
+
5. **Record current branch and worktree**:
|
|
20
26
|
- Run `git branch --show-current` to get current branch name
|
|
21
27
|
- **If empty (detached HEAD)**: Run `git rev-parse HEAD` to save the commit SHA instead
|
|
22
28
|
- Run `git rev-parse --show-toplevel` to record the current worktree path
|
|
23
|
-
- Track whether we started in detached HEAD state for Phase 5 restoration
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
- Parse the output to build a map: `{ branch_name -> worktree_path }`
|
|
27
|
-
- For each branch, record if it's checked out in a worktree and where
|
|
30
|
+
6. **Build worktree inventory**: Run `git worktree list --porcelain` to detect all worktrees.
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
- If output is non-empty, WARN the user
|
|
31
|
-
- Note: We only block if we need to checkout branches later for review comment fixes
|
|
32
|
+
7. **Check for uncommitted changes**: Run `git status --porcelain`.
|
|
33
|
+
- If output is non-empty, WARN the user but continue
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
8. **Initialize tracking**:
|
|
36
|
+
- Create counters: merged=0, skipped=0, failed=0, auto_fixed=0
|
|
37
|
+
- Create lists: merged_prs[], skipped_prs[], failed_prs[]
|
|
36
38
|
|
|
37
39
|
If gh authentication fails, STOP and clearly explain what the user needs to do.
|
|
38
40
|
|
|
39
41
|
---
|
|
40
42
|
|
|
41
|
-
## Phase 1: PR Discovery &
|
|
42
|
-
|
|
43
|
-
Gather comprehensive information about all open PRs:
|
|
43
|
+
## Phase 1: PR Discovery & Batch Planning
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
**Goal**: Assess all PRs and start batch processing immediately.
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
1. **Fetch all open PRs**:
|
|
48
|
+
```bash
|
|
49
|
+
gh pr list --state open --json number,title,headRefName,baseRefName,statusCheckRollup,reviewDecision,isDraft,url,author,mergeStateStatus,mergeable,state
|
|
50
|
+
```
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
2. **For each PR, categorize**:
|
|
53
53
|
|
|
54
|
-
| Category |
|
|
55
|
-
|
|
56
|
-
| Ready to Merge | CI passed,
|
|
57
|
-
|
|
|
58
|
-
| CI
|
|
59
|
-
| CI Failed |
|
|
60
|
-
|
|
|
61
|
-
| Conflicts |
|
|
54
|
+
| Category | Detection | Auto-Action |
|
|
55
|
+
|----------|-----------|-------------|
|
|
56
|
+
| Ready to Merge | CI passed, mergeable=true | Merge immediately |
|
|
57
|
+
| CI Pending | statusCheckRollup has IN_PROGRESS | Wait and poll |
|
|
58
|
+
| CI Failed - Lint | Failed with lint/format errors | Auto-fix |
|
|
59
|
+
| CI Failed - Other | Tests/types/build failed | Skip with log |
|
|
60
|
+
| Behind Main | mergeStateStatus=BEHIND | Update branch, wait for CI |
|
|
61
|
+
| Conflicts | mergeable=CONFLICTING | Skip, warn user |
|
|
62
|
+
| Draft | isDraft=true | Skip |
|
|
63
|
+
| Already Merged | state=MERGED | Log and skip |
|
|
62
64
|
|
|
63
|
-
|
|
65
|
+
3. **Present summary** (informational only, no blocking):
|
|
64
66
|
```
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
| # | Title |
|
|
68
|
-
|
|
69
|
-
| 42 |
|
|
70
|
-
|
|
|
71
|
-
|
|
|
72
|
-
|
|
|
67
|
+
Processing X open PRs...
|
|
68
|
+
|
|
69
|
+
| # | Title | Author | Status | Action |
|
|
70
|
+
|---|-------|--------|--------|--------|
|
|
71
|
+
| 42 | bump cross-env | dependabot | CI Passed | Will merge |
|
|
72
|
+
| 35 | bump sharp | dependabot | CI Pending | Will wait |
|
|
73
|
+
| 32 | bump linting | dependabot | CI Failed | Will auto-fix |
|
|
74
|
+
| 28 | new feature | user | Draft | Will skip |
|
|
75
|
+
| 25 | refactor auth | user | Conflicts | Will skip |
|
|
73
76
|
```
|
|
74
77
|
|
|
75
|
-
|
|
76
|
-
-
|
|
77
|
-
-
|
|
78
|
-
-
|
|
78
|
+
4. **Check for blockers** - ONLY pause if:
|
|
79
|
+
- There are PRs with merge conflicts (warn user which ones will be skipped)
|
|
80
|
+
- There are draft PRs (inform user they will be skipped)
|
|
81
|
+
- All PRs have non-auto-fixable failures
|
|
82
|
+
|
|
83
|
+
Otherwise, proceed automatically.
|
|
84
|
+
|
|
85
|
+
5. **Sort PRs by priority**:
|
|
86
|
+
1. Infrastructure PRs first (CI/workflow changes)
|
|
87
|
+
2. PRs with passing CI
|
|
88
|
+
3. PRs with pending CI
|
|
89
|
+
4. PRs needing fixes
|
|
79
90
|
|
|
80
91
|
---
|
|
81
92
|
|
|
82
93
|
## Phase 2: Review Comments Handling
|
|
83
94
|
|
|
84
|
-
|
|
95
|
+
**Note**: This phase only runs if PRs have pending review comments. For batch processing of simple dependency bumps, this phase is typically skipped.
|
|
85
96
|
|
|
86
|
-
|
|
97
|
+
For PRs with `reviewDecision: CHANGES_REQUESTED`:
|
|
87
98
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
99
|
+
1. Fetch review comments
|
|
100
|
+
2. If all comments are trivial (typos, formatting, docstrings) - auto-fix
|
|
101
|
+
3. If comments require logic changes - skip PR and inform user
|
|
102
|
+
4. Push fixes without asking for confirmation
|
|
91
103
|
|
|
92
|
-
|
|
104
|
+
---
|
|
93
105
|
|
|
94
|
-
|
|
106
|
+
## Phase 3: CI Loop (Autonomous)
|
|
95
107
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
| Add type annotation | Yes | "Add type for this parameter" |
|
|
101
|
-
| Fix typo | Yes | "Typo: 'recieve' -> 'receive'" |
|
|
102
|
-
| Logic change | No - guided | "This should handle the null case" |
|
|
103
|
-
| Refactor request | No - guided | "Extract this into a separate function" |
|
|
104
|
-
| Question/clarification | No - guided | "Why is this needed?" |
|
|
105
|
-
| Approval/praise | Skip | "LGTM", "Nice work" |
|
|
108
|
+
**Configuration:**
|
|
109
|
+
- Polling interval: 30 seconds
|
|
110
|
+
- Max wait per PR: 10 minutes
|
|
111
|
+
- Max fix attempts: 2 per PR
|
|
106
112
|
|
|
107
|
-
|
|
113
|
+
**For each PR, process in a loop:**
|
|
108
114
|
|
|
109
|
-
|
|
115
|
+
### Step 1: Check Current State
|
|
116
|
+
```bash
|
|
117
|
+
gh pr view <number> --json state,statusCheckRollup,mergeStateStatus,mergeable
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
- If `state=MERGED`: Log `[X/N] PR #<number> - Already merged`, continue to next
|
|
121
|
+
- If `state=CLOSED`: Log and skip
|
|
122
|
+
|
|
123
|
+
### Step 2: Handle Branch Behind Main
|
|
110
124
|
|
|
125
|
+
If `mergeStateStatus=BEHIND`:
|
|
111
126
|
```
|
|
112
|
-
|
|
113
|
-
Review status: Changes Requested
|
|
114
|
-
Reviewer: @reviewer-name
|
|
115
|
-
|
|
116
|
-
Comments: 5 total
|
|
117
|
-
- 3 auto-addressable (add docstring, rename var, fix typo)
|
|
118
|
-
- 2 need guidance (logic change, refactor request)
|
|
119
|
-
|
|
120
|
-
Options:
|
|
121
|
-
1. Auto-address 3 simple comments (Recommended)
|
|
122
|
-
2. Guide me through all 5 comments
|
|
123
|
-
3. View all comments first
|
|
124
|
-
4. Skip this PR
|
|
127
|
+
-> Updating branch to latest main...
|
|
125
128
|
```
|
|
129
|
+
```bash
|
|
130
|
+
gh api repos/{owner}/{repo}/pulls/{number}/update-branch -X PUT
|
|
131
|
+
```
|
|
132
|
+
Then wait 30s and re-check CI.
|
|
126
133
|
|
|
127
|
-
### Step
|
|
128
|
-
|
|
129
|
-
If user chooses auto-address:
|
|
134
|
+
### Step 3: Wait for CI
|
|
130
135
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
136
|
+
While CI is pending and elapsed < 10 minutes:
|
|
137
|
+
```
|
|
138
|
+
-> Waiting for CI... (Xs)
|
|
139
|
+
```
|
|
140
|
+
- Sleep 30 seconds
|
|
141
|
+
- Re-check status
|
|
134
142
|
|
|
135
|
-
|
|
136
|
-
- Read the file at the specified path
|
|
137
|
-
- Identify the exact location (line number from review comment)
|
|
138
|
-
- Make the change based on the comment type:
|
|
139
|
-
- **Add comment/docstring**: Generate appropriate documentation
|
|
140
|
-
- **Rename**: Use find/replace for the identifier
|
|
141
|
-
- **Add type annotation**: Infer or use suggested type
|
|
142
|
-
- **Fix typo**: Apply the correction
|
|
143
|
-
- Show diff to user: "Change X to Y in file.ts:42"
|
|
144
|
-
- Ask: "Apply this change?" / "Skip" / "Edit manually"
|
|
143
|
+
### Step 4: Handle CI Results
|
|
145
144
|
|
|
146
|
-
|
|
147
|
-
- Show consolidated diff
|
|
148
|
-
- Ask for confirmation before committing
|
|
149
|
-
- Commit: `git commit -am "fix: address review comments"`
|
|
150
|
-
- Push: `git push`
|
|
145
|
+
**If CI passes**: Proceed to Phase 4 (merge)
|
|
151
146
|
|
|
152
|
-
|
|
147
|
+
**If CI fails**:
|
|
148
|
+
1. Get failure logs:
|
|
149
|
+
```bash
|
|
150
|
+
gh run list --branch <branch> --status failure --limit 1 --json databaseId -q '.[0].databaseId'
|
|
151
|
+
gh run view <id> --log-failed 2>&1 | head -100
|
|
152
|
+
```
|
|
153
153
|
|
|
154
|
-
|
|
154
|
+
2. Analyze failure type:
|
|
155
155
|
|
|
156
|
-
|
|
157
|
-
1. Display the comment with full context:
|
|
156
|
+
**Lint/Formatting errors** (auto-fixable):
|
|
158
157
|
```
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
Reviewer: @reviewer-name
|
|
162
|
-
Comment: "This should handle the null case - what happens if user is undefined?"
|
|
163
|
-
|
|
164
|
-
Current code:
|
|
165
|
-
40 | const user = getUser(id);
|
|
166
|
-
41 | return user.name; // <- reviewer's concern
|
|
167
|
-
42 | }
|
|
158
|
+
X CI failed (lint errors)
|
|
159
|
+
-> Auto-fixing lint errors...
|
|
168
160
|
```
|
|
169
|
-
|
|
170
|
-
|
|
161
|
+
- Checkout branch (handle worktree)
|
|
162
|
+
- Run `npm install && npm run lint -- --fix`
|
|
163
|
+
- If changes exist:
|
|
164
|
+
```bash
|
|
165
|
+
git add -A
|
|
166
|
+
git commit -m "fix: auto-fix lint errors"
|
|
167
|
+
git push
|
|
168
|
+
```
|
|
169
|
+
- Wait for CI to re-run
|
|
170
|
+
- Decrement retry counter
|
|
171
|
+
- If this is the 2nd consecutive failure with same error: skip PR
|
|
172
|
+
|
|
173
|
+
**Type errors / Test failures / Build errors** (NOT auto-fixable):
|
|
171
174
|
```
|
|
172
|
-
|
|
173
|
-
1. Show me the file (I'll make the fix)
|
|
174
|
-
2. Suggest a fix (Claude will propose code)
|
|
175
|
-
3. Mark as resolved with reply
|
|
176
|
-
4. Skip for now
|
|
175
|
+
X CI failed (type errors) - skipping
|
|
177
176
|
```
|
|
177
|
+
- Add to skipped_prs with reason
|
|
178
|
+
- Continue to next PR immediately
|
|
178
179
|
|
|
179
|
-
|
|
180
|
-
-
|
|
181
|
-
-
|
|
182
|
-
- Show diff and ask for confirmation
|
|
183
|
-
- Apply if accepted
|
|
184
|
-
|
|
185
|
-
4. **If "Mark as resolved with reply"**:
|
|
186
|
-
- Ask user for reply text
|
|
187
|
-
- Post reply: `gh api repos/{owner}/{repo}/pulls/{number}/comments/{comment_id}/replies -f body="<reply>"`
|
|
180
|
+
**Secrets unavailable** (Dependabot):
|
|
181
|
+
- Try updating branch first (may get new CI workflow)
|
|
182
|
+
- If still fails after update: skip with note
|
|
188
183
|
|
|
189
|
-
### Step
|
|
184
|
+
### Step 5: Timeout Handling
|
|
190
185
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
- NEVER auto-address comments that involve logic changes
|
|
198
|
-
- ALWAYS show diff before committing auto-addressed changes
|
|
199
|
-
- ALWAYS confirm before pushing
|
|
200
|
-
- Track which comments were addressed vs skipped for summary
|
|
201
|
-
- NEVER modify code that the comment doesn't directly reference
|
|
186
|
+
If 10 minutes elapsed and CI still pending:
|
|
187
|
+
```
|
|
188
|
+
! CI timed out after 10 minutes - skipping
|
|
189
|
+
```
|
|
190
|
+
- Add to skipped_prs
|
|
191
|
+
- Continue to next PR
|
|
202
192
|
|
|
203
193
|
---
|
|
204
194
|
|
|
205
|
-
## Phase
|
|
206
|
-
|
|
207
|
-
For each open PR that needs CI verification:
|
|
208
|
-
|
|
209
|
-
**Configuration:**
|
|
210
|
-
- Max 3 fix attempts per PR
|
|
211
|
-
- Max 5 minute wait per CI run
|
|
212
|
-
- 30 second polling interval
|
|
213
|
-
|
|
214
|
-
**Process:**
|
|
215
|
-
|
|
216
|
-
1. **Check CI status**: `gh pr view <pr-number> --json statusCheckRollup`
|
|
217
|
-
|
|
218
|
-
2. **If CI is running**:
|
|
219
|
-
- Display: "Waiting for CI on PR #<number>... (attempt X/3, Xs elapsed)"
|
|
220
|
-
- Wait 30 seconds
|
|
221
|
-
- Re-check (up to 5 minutes total)
|
|
222
|
-
|
|
223
|
-
3. **If CI passes**: Mark PR as ready for merge, proceed to Phase 4
|
|
224
|
-
|
|
225
|
-
4. **If CI fails**:
|
|
226
|
-
- Fetch and display the failure output
|
|
227
|
-
- Categorize the failure:
|
|
228
|
-
- **Lint/Formatting errors**: Offer to run `npm run lint -- --fix` automatically
|
|
229
|
-
- **Type errors**: Show errors, ask user: "Skip this PR", "I'll fix manually"
|
|
230
|
-
- **Test failures**: Show test output, ask user: "Skip this PR", "I'll fix manually"
|
|
231
|
-
- **Build errors**: Show error, ask user: "Skip this PR", "I'll fix manually"
|
|
232
|
-
- If auto-fix chosen (lint only):
|
|
233
|
-
- Checkout branch (handle worktree if needed)
|
|
234
|
-
- Run the fix command
|
|
235
|
-
- Show the diff to user
|
|
236
|
-
- Ask for confirmation before committing
|
|
237
|
-
- Commit with message: "fix: auto-fix lint errors"
|
|
238
|
-
- Push and decrement retry counter
|
|
239
|
-
- If manual fix chosen:
|
|
240
|
-
- Inform user and pause for this PR
|
|
241
|
-
- Ask: "Continue with other PRs?" or "Wait for manual fix?"
|
|
242
|
-
|
|
243
|
-
5. **If max retries exceeded**:
|
|
244
|
-
- Ask user: "Skip this PR", "Abort workflow", or "I'll fix manually"
|
|
245
|
-
- Handle accordingly
|
|
246
|
-
|
|
247
|
-
**IMPORTANT**: NEVER auto-fix test failures or type errors. Only lint/formatting issues are safe to auto-fix.
|
|
195
|
+
## Phase 4: Merge (No Confirmation Needed)
|
|
248
196
|
|
|
249
|
-
|
|
197
|
+
For each PR that passed CI:
|
|
250
198
|
|
|
251
|
-
|
|
199
|
+
### Pre-merge Verification
|
|
200
|
+
```bash
|
|
201
|
+
gh pr view <number> --json state,mergeStateStatus,mergeable
|
|
202
|
+
```
|
|
252
203
|
|
|
253
|
-
|
|
204
|
+
- If `state=MERGED`: Log and continue (already merged)
|
|
205
|
+
- If `mergeable=CONFLICTING`: Skip (conflicts appeared)
|
|
254
206
|
|
|
255
|
-
###
|
|
207
|
+
### Execute Merge
|
|
256
208
|
|
|
257
|
-
|
|
258
|
-
|
|
209
|
+
```bash
|
|
210
|
+
gh pr merge <number> --squash --delete-branch
|
|
211
|
+
```
|
|
259
212
|
|
|
260
|
-
|
|
213
|
+
(Use detected strategy from Phase 0: --squash, --merge, or --rebase)
|
|
261
214
|
|
|
262
|
-
**
|
|
263
|
-
-
|
|
264
|
-
-
|
|
265
|
-
|
|
266
|
-
- If the API call fails (e.g., merge conflicts), inform user and offer to skip
|
|
267
|
-
- Wait for CI to re-run after update
|
|
268
|
-
- Re-check merge state
|
|
215
|
+
**Handle results:**
|
|
216
|
+
- Success: Log `Merged`, increment counter
|
|
217
|
+
- "Already merged" error: Log as success, continue
|
|
218
|
+
- Other error: Log error, add to failed_prs, continue to next PR
|
|
269
219
|
|
|
270
|
-
|
|
220
|
+
**Output format:**
|
|
221
|
+
```
|
|
222
|
+
[1/8] PR #42 "bump cross-env"
|
|
223
|
+
-> CI passed -> merged
|
|
271
224
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
- Ask user: "Skip this PR" or "I'll resolve conflicts manually"
|
|
276
|
-
- If manual resolution, wait for user confirmation then re-check
|
|
225
|
+
[2/8] PR #35 "bump sharp"
|
|
226
|
+
-> Waiting for CI... (45s)
|
|
227
|
+
-> CI passed -> merged
|
|
277
228
|
|
|
278
|
-
|
|
229
|
+
[3/8] PR #32 "bump linting group"
|
|
230
|
+
X CI failed (lint errors)
|
|
231
|
+
-> Auto-fixing lint errors...
|
|
232
|
+
-> Pushed fix, waiting for CI... (30s)
|
|
233
|
+
-> CI passed -> merged
|
|
279
234
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
Ready to merge:
|
|
283
|
-
PR #42: "Add user authentication" (feature-auth -> main)
|
|
235
|
+
[4/8] PR #28 "new feature"
|
|
236
|
+
- Skipped (draft PR)
|
|
284
237
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
238
|
+
[5/8] PR #25 "refactor auth"
|
|
239
|
+
- Skipped (merge conflicts)
|
|
240
|
+
```
|
|
288
241
|
|
|
289
|
-
|
|
290
|
-
```
|
|
291
|
-
- Run `gh pr merge <pr-number> --delete-branch`
|
|
292
|
-
- This respects the repository's merge strategy settings
|
|
293
|
-
- The `--delete-branch` flag removes the remote branch after merge
|
|
242
|
+
---
|
|
294
243
|
|
|
295
|
-
|
|
244
|
+
## Phase 5: Cleanup & Summary (Automatic)
|
|
296
245
|
|
|
297
|
-
-
|
|
298
|
-
- Ask user how to proceed
|
|
246
|
+
### Step 1: Auto-cleanup (no prompts)
|
|
299
247
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
248
|
+
1. Prune remote refs:
|
|
249
|
+
```bash
|
|
250
|
+
git fetch --prune
|
|
251
|
+
```
|
|
303
252
|
|
|
304
|
-
|
|
253
|
+
2. For each merged PR's branch, delete local if exists:
|
|
254
|
+
```bash
|
|
255
|
+
git branch -d <branch> 2>/dev/null || true
|
|
256
|
+
```
|
|
305
257
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
Worktree at '<path>' is now on merged branch '<branch>'.
|
|
258
|
+
3. Prune worktrees:
|
|
259
|
+
```bash
|
|
260
|
+
git worktree prune
|
|
261
|
+
```
|
|
311
262
|
|
|
312
|
-
|
|
313
|
-
1. Remove worktree (Recommended)
|
|
314
|
-
2. Keep worktree (switch to <default-branch>)
|
|
315
|
-
```
|
|
316
|
-
- If remove: `git worktree remove <path>`
|
|
317
|
-
- If keep: `git -C <path> checkout <default-branch>`
|
|
263
|
+
### Step 2: Return to original context
|
|
318
264
|
|
|
319
|
-
|
|
265
|
+
- If original branch exists: `git checkout <original-branch>`
|
|
266
|
+
- If it was merged: checkout default branch
|
|
267
|
+
- If was detached HEAD: `git checkout <original-sha>`
|
|
320
268
|
|
|
321
|
-
|
|
322
|
-
- Delete local branch if it exists: `git branch -d <branch>`
|
|
323
|
-
- Skip if branch is checked out in a remaining worktree
|
|
269
|
+
### Step 3: Display Final Summary
|
|
324
270
|
|
|
325
|
-
|
|
271
|
+
```
|
|
272
|
+
=====================================================
|
|
273
|
+
PR Resolution Complete
|
|
274
|
+
=====================================================
|
|
326
275
|
|
|
327
|
-
|
|
328
|
-
|
|
276
|
+
RESULTS:
|
|
277
|
+
Merged: X PRs
|
|
278
|
+
- #42 "bump cross-env"
|
|
279
|
+
- #35 "bump sharp"
|
|
280
|
+
- #32 "bump linting group" (auto-fixed lint)
|
|
329
281
|
|
|
330
|
-
|
|
282
|
+
Skipped: X PRs
|
|
283
|
+
- #28 "new feature" (draft)
|
|
284
|
+
- #25 "refactor auth" (merge conflicts)
|
|
331
285
|
|
|
332
|
-
|
|
333
|
-
-
|
|
334
|
-
- If the original branch was merged and deleted, inform user: "Your original branch '<branch>' was merged. You are now on '<default-branch>'."
|
|
286
|
+
Failed: X PRs
|
|
287
|
+
- #20 "breaking change" (type errors - needs manual fix)
|
|
335
288
|
|
|
336
|
-
|
|
289
|
+
AUTO-FIXES APPLIED:
|
|
290
|
+
- X lint errors fixed automatically
|
|
337
291
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
=====================================================
|
|
292
|
+
REMAINING WORK:
|
|
293
|
+
- PR #25 has merge conflicts at: src/auth.ts
|
|
294
|
+
- PR #20 needs manual fix for type errors
|
|
342
295
|
|
|
343
|
-
PRs PROCESSED:
|
|
344
|
-
✓ Merged X PRs
|
|
345
|
-
- PR #42: "Add user authentication"
|
|
346
|
-
- PR #43: "Fix login bug"
|
|
347
|
-
○ Skipped X PRs (CI failed / conflicts)
|
|
348
|
-
- PR #45: "Refactor" (merge conflicts)
|
|
349
|
-
|
|
350
|
-
REVIEW COMMENTS:
|
|
351
|
-
✓ Auto-addressed X comments
|
|
352
|
-
✓ Manually resolved X comments
|
|
353
|
-
○ Skipped X comments
|
|
354
|
-
|
|
355
|
-
CI FIXES:
|
|
356
|
-
✓ Auto-fixed X lint issues
|
|
357
|
-
○ X PRs need manual fixes
|
|
358
|
-
|
|
359
|
-
CLEANUP:
|
|
360
|
-
✓ Deleted X remote branches
|
|
361
|
-
✓ Deleted X local branches
|
|
362
|
-
✓ Removed X worktrees
|
|
363
|
-
|
|
364
|
-
CURRENT STATE:
|
|
365
|
-
Branch: <current-branch>
|
|
366
|
-
Worktree: <current-worktree-path>
|
|
367
|
-
|
|
368
|
-
REMAINING OPEN PRs:
|
|
369
|
-
- PR #45: "Refactor" - merge conflicts, needs manual resolution
|
|
370
|
-
- PR #46: "Draft feature" - draft, skipped
|
|
371
|
-
|
|
372
|
-
WARNINGS (if any):
|
|
373
|
-
- PR #45 has merge conflicts at src/auth/login.ts
|
|
374
296
|
=====================================================
|
|
375
297
|
```
|
|
376
298
|
|
|
377
299
|
</workflow>
|
|
378
300
|
|
|
379
|
-
##
|
|
380
|
-
|
|
381
|
-
If the workflow fails at any point, display:
|
|
382
|
-
|
|
383
|
-
1. **Operations completed successfully** (from the operation log)
|
|
384
|
-
2. **The operation that failed** and the error message
|
|
385
|
-
3. **Current repository state**:
|
|
386
|
-
- Current branch: `git branch --show-current`
|
|
387
|
-
- Uncommitted changes: `git status --porcelain`
|
|
388
|
-
- Any in-progress operations: check for rebase/merge/cherry-pick
|
|
301
|
+
## Safety Rules
|
|
389
302
|
|
|
390
|
-
|
|
303
|
+
### ALWAYS Auto-fix
|
|
304
|
+
- Lint errors (`npm run lint -- --fix`)
|
|
305
|
+
- Formatting errors
|
|
391
306
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
307
|
+
### NEVER Auto-fix
|
|
308
|
+
- Type errors (TypeScript)
|
|
309
|
+
- Test failures
|
|
310
|
+
- Build errors
|
|
311
|
+
- Logic changes in review comments
|
|
397
312
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
- Push: `git push`
|
|
313
|
+
### Branch Safety
|
|
314
|
+
- NEVER use force push
|
|
315
|
+
- ALWAYS preserve user's starting context
|
|
316
|
+
- ALWAYS use detected merge strategy
|
|
403
317
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
318
|
+
### Timing
|
|
319
|
+
- 30 second polling interval
|
|
320
|
+
- 10 minute max wait per PR
|
|
321
|
+
- 2 max fix attempts before skipping
|
|
408
322
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
323
|
+
### Error Handling
|
|
324
|
+
- "Already merged" is a success, not an error
|
|
325
|
+
- Continue to next PR on any error
|
|
326
|
+
- Log all failures for summary
|
|
327
|
+
- Never block on a single PR failure
|
|
413
328
|
|
|
414
|
-
|
|
415
|
-
- Local branch may be deleted but remote still exists (or vice versa)
|
|
416
|
-
- Check: `git branch -a | grep <branch>`
|
|
417
|
-
- Manual cleanup if needed
|
|
329
|
+
---
|
|
418
330
|
|
|
419
|
-
|
|
331
|
+
## Error Recovery
|
|
420
332
|
|
|
421
|
-
|
|
333
|
+
If the workflow fails at any point:
|
|
422
334
|
|
|
423
|
-
|
|
335
|
+
1. **Show completed operations**
|
|
336
|
+
2. **Show current state**: `git branch --show-current`, `git status --porcelain`
|
|
337
|
+
3. **Re-run is safe**: The workflow is idempotent - merged PRs show as "Already merged"
|
|
424
338
|
|
|
425
|
-
|
|
426
|
-
-
|
|
427
|
-
-
|
|
428
|
-
-
|
|
429
|
-
- ALWAYS respect retry limits
|
|
430
|
-
|
|
431
|
-
### Review Comment Safety Rules
|
|
432
|
-
- NEVER auto-address comments that involve logic changes
|
|
433
|
-
- ALWAYS show diff before committing changes
|
|
434
|
-
- ALWAYS confirm before pushing
|
|
435
|
-
- NEVER modify code that the comment doesn't directly reference
|
|
436
|
-
- ALWAYS track which comments were addressed for summary
|
|
437
|
-
|
|
438
|
-
### Branch Safety Rules
|
|
439
|
-
- NEVER use force push (`--force` or `-f`)
|
|
440
|
-
- ALWAYS preserve the user's working context (return to original branch)
|
|
441
|
-
|
|
442
|
-
### Worktree Safety Rules
|
|
443
|
-
- NEVER remove a worktree with uncommitted changes without explicit user confirmation
|
|
444
|
-
- ALWAYS check worktree status before operations
|
|
445
|
-
- ALWAYS run `git worktree prune` after removing worktrees
|
|
446
|
-
- ALWAYS use `git -C <path>` for operations in linked worktrees
|
|
339
|
+
**Common issues:**
|
|
340
|
+
- "Already merged" - Normal, PR was auto-merged externally
|
|
341
|
+
- CI timeout - Re-run later or check GitHub Actions
|
|
342
|
+
- Merge conflicts - Resolve manually, then re-run
|