devflow-kit 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.
Files changed (33) hide show
  1. package/CHANGELOG.md +129 -0
  2. package/README.md +61 -9
  3. package/dist/commands/init.d.ts.map +1 -1
  4. package/dist/commands/init.js +160 -176
  5. package/dist/commands/init.js.map +1 -1
  6. package/dist/commands/uninstall.d.ts.map +1 -1
  7. package/dist/commands/uninstall.js +73 -48
  8. package/dist/commands/uninstall.js.map +1 -1
  9. package/dist/utils/git.d.ts +11 -0
  10. package/dist/utils/git.d.ts.map +1 -0
  11. package/dist/utils/git.js +36 -0
  12. package/dist/utils/git.js.map +1 -0
  13. package/dist/utils/paths.d.ts +32 -0
  14. package/dist/utils/paths.d.ts.map +1 -0
  15. package/dist/utils/paths.js +86 -0
  16. package/dist/utils/paths.js.map +1 -0
  17. package/package.json +1 -1
  18. package/src/claude/agents/devflow/audit-architecture.md +92 -110
  19. package/src/claude/agents/devflow/audit-complexity.md +94 -130
  20. package/src/claude/agents/devflow/audit-database.md +95 -136
  21. package/src/claude/agents/devflow/audit-dependencies.md +94 -136
  22. package/src/claude/agents/devflow/audit-documentation.md +82 -323
  23. package/src/claude/agents/devflow/audit-performance.md +212 -107
  24. package/src/claude/agents/devflow/audit-security.md +201 -83
  25. package/src/claude/agents/devflow/audit-tests.md +82 -471
  26. package/src/claude/agents/devflow/audit-typescript.md +83 -311
  27. package/src/claude/agents/devflow/pull-request.md +423 -0
  28. package/src/claude/commands/devflow/code-review.md +297 -248
  29. package/src/claude/commands/devflow/plan-next-steps.md +1 -1
  30. package/src/claude/commands/devflow/plan.md +485 -0
  31. package/src/claude/commands/devflow/pull-request.md +269 -0
  32. package/src/claude/commands/devflow/resolve-comments.md +583 -0
  33. package/src/claude/scripts/statusline.sh +0 -36
@@ -0,0 +1,583 @@
1
+ ---
2
+ allowed-tools: AskUserQuestion, TodoWrite, Read, Write, Edit, Bash, Grep, Glob
3
+ description: Systematically address PR review comments with implementation and resolution tracking
4
+ ---
5
+
6
+ ## Your task
7
+
8
+ Fetch PR review comments, triage them with the user, implement requested changes, and respond to reviewers. This command orchestrates the entire PR feedback resolution workflow.
9
+
10
+ **Philosophy**: PR comments are collaboration opportunities. Address them systematically, honestly, and completely.
11
+
12
+ ---
13
+
14
+ ## Step 1: Detect PR Context
15
+
16
+ Find the PR associated with the current branch:
17
+
18
+ ```bash
19
+ echo "=== DETECTING PR CONTEXT ==="
20
+
21
+ # Get current branch
22
+ CURRENT_BRANCH=$(git branch --show-current)
23
+ if [ -z "$CURRENT_BRANCH" ]; then
24
+ echo "❌ Not on a branch (detached HEAD)"
25
+ exit 1
26
+ fi
27
+
28
+ # Check if arguments provided (PR number)
29
+ if [ -n "$ARGUMENTS" ]; then
30
+ # Strip non-numeric characters
31
+ PR_NUMBER=$(echo "$ARGUMENTS" | sed 's/[^0-9]//g')
32
+
33
+ if [ -z "$PR_NUMBER" ]; then
34
+ echo "❌ Invalid PR number: $ARGUMENTS"
35
+ exit 1
36
+ fi
37
+
38
+ echo "Using specified PR: #$PR_NUMBER"
39
+ else
40
+ # Auto-detect PR for current branch
41
+ PR_NUMBER=$(gh pr list --head "$CURRENT_BRANCH" --json number --jq '.[0].number' 2>/dev/null || echo "")
42
+
43
+ if [ -z "$PR_NUMBER" ]; then
44
+ echo "❌ No PR found for branch: $CURRENT_BRANCH"
45
+ echo " Create PR first: /pull-request"
46
+ echo " Or specify PR number: /resolve-comments <number>"
47
+ exit 1
48
+ fi
49
+
50
+ echo "Auto-detected PR #$PR_NUMBER for branch: $CURRENT_BRANCH"
51
+ fi
52
+
53
+ # Get PR details
54
+ PR_TITLE=$(gh pr view $PR_NUMBER --json title --jq '.title' 2>/dev/null || echo "Unknown")
55
+ PR_URL=$(gh pr view $PR_NUMBER --json url --jq '.url' 2>/dev/null || echo "")
56
+ PR_STATE=$(gh pr view $PR_NUMBER --json state --jq '.state' 2>/dev/null || echo "UNKNOWN")
57
+
58
+ echo ""
59
+ echo "PR #$PR_NUMBER: $PR_TITLE"
60
+ echo "Status: $PR_STATE"
61
+ echo "URL: $PR_URL"
62
+ echo ""
63
+ ```
64
+
65
+ ### Step 2: Fetch and Parse Comments
66
+
67
+ Get all review comments for this PR:
68
+
69
+ ```bash
70
+ echo "=== FETCHING PR COMMENTS ==="
71
+
72
+ # Fetch comments using gh API
73
+ # Note: This gets review comments (code-level) and issue comments (general)
74
+ gh pr view $PR_NUMBER --json comments,reviews --json body > /tmp/pr_comments_$PR_NUMBER.json
75
+
76
+ # Count comments
77
+ REVIEW_COUNT=$(cat /tmp/pr_comments_$PR_NUMBER.json | jq -r '.reviews | length')
78
+ COMMENT_COUNT=$(cat /tmp/pr_comments_$PR_NUMBER.json | jq -r '.comments | length')
79
+
80
+ echo "Review comments: $REVIEW_COUNT"
81
+ echo "General comments: $COMMENT_COUNT"
82
+ echo ""
83
+
84
+ if [ "$REVIEW_COUNT" -eq 0 ] && [ "$COMMENT_COUNT" -eq 0 ]; then
85
+ echo "✅ No comments to resolve!"
86
+ exit 0
87
+ fi
88
+ ```
89
+
90
+ Parse the comments and extract relevant information:
91
+ - Author
92
+ - Body/content
93
+ - File path (for code comments)
94
+ - Line number (for code comments)
95
+ - Comment type (change request, question, nitpick, approval)
96
+ - Comment ID (for responding)
97
+
98
+ **IMPORTANT**: Use `Read` tool to parse the JSON file at `/tmp/pr_comments_$PR_NUMBER.json` and extract structured comment data.
99
+
100
+ ### Step 3: Display Comments Grouped by Category
101
+
102
+ Present comments organized by type and file:
103
+
104
+ ```markdown
105
+ 💬 PR COMMENTS FOR #${PR_NUMBER}
106
+
107
+ ## 📝 Code Change Requests (${count})
108
+ ${For each code change request:}
109
+
110
+ **Comment ${N}** by @${author} on ${file}:${line}
111
+ > ${comment body}
112
+
113
+ **Context:**
114
+ ```${language}
115
+ ${code snippet from file around line}
116
+ ```
117
+
118
+ ---
119
+
120
+ ## ❓ Questions (${count})
121
+ ${For each question:}
122
+
123
+ **Comment ${N}** by @${author}
124
+ > ${question text}
125
+
126
+ ---
127
+
128
+ ## 🔧 Nitpicks / Style (${count})
129
+ ${For each nitpick:}
130
+
131
+ **Comment ${N}** by @${author} on ${file}:${line}
132
+ > ${nitpick text}
133
+
134
+ ---
135
+
136
+ ## ✅ Approvals / Positive Feedback (${count})
137
+ ${For each approval:}
138
+
139
+ **Comment ${N}** by @${author}
140
+ > ${feedback text}
141
+
142
+ ---
143
+
144
+ **Total: ${total_count} comments**
145
+ ```
146
+
147
+ ### Step 4: Triage Comments with User
148
+
149
+ Use `AskUserQuestion` to let user decide which comments to address:
150
+
151
+ **Question 1: Select comments to address**
152
+ ```
153
+ header: "Address comments"
154
+ question: "Which comments do you want to address in this session?"
155
+ multiSelect: true
156
+ options: [
157
+ {
158
+ label: "Comment 1: [summary]",
159
+ description: "@author: [first 80 chars of comment]"
160
+ },
161
+ {
162
+ label: "Comment 2: [summary]",
163
+ description: "@author: [first 80 chars of comment]"
164
+ },
165
+ ...
166
+ ]
167
+ ```
168
+
169
+ **Question 2: Batch similar comments?**
170
+ ```
171
+ header: "Batch comments"
172
+ question: "Any comments that should be addressed together (e.g., similar changes)?"
173
+ multiSelect: true
174
+ options: [List selected comments from Q1]
175
+ ```
176
+
177
+ Save selected comments to todo list using `TodoWrite`:
178
+
179
+ ```json
180
+ [
181
+ {
182
+ "content": "Address Comment 1: [summary] in file:line",
183
+ "status": "pending",
184
+ "activeForm": "Addressing Comment 1"
185
+ },
186
+ {
187
+ "content": "Address Comment 2: [summary] in file:line",
188
+ "status": "pending",
189
+ "activeForm": "Addressing Comment 2"
190
+ }
191
+ ]
192
+ ```
193
+
194
+ Present triage summary:
195
+
196
+ ```markdown
197
+ 🎯 COMMENT RESOLUTION PLAN
198
+
199
+ ### Selected for this session (${count}):
200
+ - Comment ${N}: ${summary}
201
+ - Comment ${N}: ${summary}
202
+
203
+ ### Deferred for later (${count}):
204
+ - Comment ${N}: ${summary}
205
+
206
+ ### Batched together:
207
+ - Comments ${N1}, ${N2}: ${summary}
208
+
209
+ Total todos created: ${count}
210
+ ```
211
+
212
+ ---
213
+
214
+ ## Step 5: Resolve Comments Iteratively
215
+
216
+ For each selected comment (or batch), follow this process:
217
+
218
+ ### 5.1 Display Comment Context
219
+
220
+ ```markdown
221
+ ---
222
+ 🔍 RESOLVING COMMENT ${N}/${total}
223
+ ---
224
+
225
+ **From:** @${author}
226
+ **File:** ${file}:${line} (if applicable)
227
+ **Type:** ${change_request|question|nitpick}
228
+
229
+ **Comment:**
230
+ > ${full comment body}
231
+
232
+ **Current Code:**
233
+ ```${language}
234
+ ${code context from file}
235
+ ```
236
+ ```
237
+
238
+ ### 5.2 Analyze What's Needed
239
+
240
+ Use `Grep` and `Read` tools to understand:
241
+ - What files need to change
242
+ - What the current implementation looks like
243
+ - What the reviewer is asking for
244
+
245
+ **Ask for clarification if ambiguous:**
246
+ ```
247
+ header: "Clarification"
248
+ question: "Comment ${N} asks for '${summary}'. How should we proceed?"
249
+ multiSelect: false
250
+ options: [
251
+ {label: "Approach 1", description: "..."},
252
+ {label: "Approach 2", description: "..."},
253
+ {label: "Ask reviewer for clarification", description: "Post reply requesting more details"}
254
+ ]
255
+ ```
256
+
257
+ ### 5.3 Implement the Change
258
+
259
+ Use `Edit` or `Write` tools to make the requested changes:
260
+
261
+ 1. **Read the relevant file(s)**
262
+ 2. **Make the change** following the reviewer's request
263
+ 3. **Verify the change** by reading back
264
+
265
+ ```markdown
266
+ ✏️ IMPLEMENTING CHANGE
267
+
268
+ Modifying: ${file}
269
+
270
+ Change: ${description}
271
+
272
+ Files modified:
273
+ - ${file1}
274
+ - ${file2}
275
+ ```
276
+
277
+ ### 5.4 Prompt for Reply Message
278
+
279
+ Use `AskUserQuestion` to get reply message:
280
+
281
+ ```
282
+ header: "Reply"
283
+ question: "What should we reply to @${author} for Comment ${N}?"
284
+ multiSelect: false
285
+ options: [
286
+ {
287
+ label: "Use suggested reply",
288
+ description: "${generated reply based on what was changed}"
289
+ },
290
+ {
291
+ label: "Custom reply",
292
+ description: "You'll write the reply manually"
293
+ },
294
+ {
295
+ label: "Skip reply for now",
296
+ description: "Implement change but don't reply yet"
297
+ }
298
+ ]
299
+ ```
300
+
301
+ **If "Custom reply" selected**, prompt for custom message:
302
+ ```
303
+ Please provide your reply message for @${author}:
304
+ ```
305
+
306
+ **If "Use suggested reply"**, generate appropriate response:
307
+
308
+ **For change requests:**
309
+ ```
310
+ ✅ Done! I've ${what was changed}.
311
+
312
+ Changes made:
313
+ - ${file1}: ${change description}
314
+ - ${file2}: ${change description}
315
+
316
+ ${Additional notes if relevant}
317
+ ```
318
+
319
+ **For questions:**
320
+ ```
321
+ ${Answer to the question}
322
+
323
+ ${Code example or explanation if relevant}
324
+ ```
325
+
326
+ **For nitpicks:**
327
+ ```
328
+ ✅ Fixed in ${commit or "latest changes"}
329
+ ```
330
+
331
+ ### 5.5 Post Reply and Mark Complete
332
+
333
+ ```bash
334
+ # Post the reply
335
+ gh pr comment $PR_NUMBER --body "${REPLY_MESSAGE}"
336
+
337
+ echo "✅ Reply posted"
338
+ ```
339
+
340
+ Update todo list to mark this comment as completed:
341
+
342
+ ```
343
+ TodoWrite: Mark comment ${N} as "completed"
344
+ ```
345
+
346
+ ```markdown
347
+ ✅ COMMENT ${N} RESOLVED
348
+
349
+ - Changed: ${files}
350
+ - Reply: "${reply_summary}"
351
+ - Status: Resolved
352
+ ```
353
+
354
+ ---
355
+
356
+ ## Step 6: Handle Deferred Comments
357
+
358
+ For comments not addressed in this session:
359
+
360
+ ```markdown
361
+ ⏸️ DEFERRED COMMENTS (${count})
362
+
363
+ These comments were not addressed in this session:
364
+
365
+ ${For each deferred comment:}
366
+ **Comment ${N}** by @${author}
367
+ - Reason: ${user_selected or "not selected"}
368
+ - Suggestion: ${how to handle later}
369
+
370
+ ---
371
+
372
+ 💡 To address these later, run:
373
+ /resolve-comments ${PR_NUMBER}
374
+ ```
375
+
376
+ ---
377
+
378
+ ## Step 7: Create Commit for Changes
379
+
380
+ After all selected comments are addressed, ask about committing:
381
+
382
+ ```
383
+ header: "Commit changes"
384
+ question: "Create commit for PR feedback changes?"
385
+ multiSelect: false
386
+ options: [
387
+ {
388
+ label: "Yes - create commit now",
389
+ description: "Commit all changes with generated message"
390
+ },
391
+ {
392
+ label: "No - I'll commit manually",
393
+ description: "Leave changes uncommitted for review"
394
+ }
395
+ ]
396
+ ```
397
+
398
+ **If "Yes"**, create commit:
399
+
400
+ ```bash
401
+ # Stage all changes
402
+ git add -A
403
+
404
+ # Create commit with feedback reference
405
+ git commit -m "$(cat <<'EOF'
406
+ fix: address PR #${PR_NUMBER} review comments
407
+
408
+ Resolved comments from @${reviewers}:
409
+ - ${comment_summary_1}
410
+ - ${comment_summary_2}
411
+ - ${comment_summary_3}
412
+
413
+ 🤖 Generated with [Claude Code](https://claude.com/claude-code)
414
+
415
+ Co-Authored-By: Claude <noreply@anthropic.com>
416
+ EOF
417
+ )"
418
+
419
+ # Push to remote
420
+ git push
421
+ ```
422
+
423
+ ---
424
+
425
+ ## Step 8: Provide Session Summary
426
+
427
+ Present comprehensive summary:
428
+
429
+ ```markdown
430
+ ## ✅ COMMENT RESOLUTION SESSION COMPLETE
431
+
432
+ ### PR #${PR_NUMBER}: ${title}
433
+
434
+ ### 📊 Session Stats
435
+ - Comments addressed: ${count}
436
+ - Comments deferred: ${count}
437
+ - Files modified: ${count}
438
+ - Replies posted: ${count}
439
+
440
+ ### ✅ Resolved Comments
441
+ ${For each resolved:}
442
+ - Comment ${N}: ${summary}
443
+ - Files: ${files}
444
+ - Reply: ${reply_summary}
445
+
446
+ ### ⏸️ Deferred Comments (${count})
447
+ ${For each deferred:}
448
+ - Comment ${N}: ${summary} - ${reason}
449
+
450
+ ### 📝 Changes Made
451
+ **Files Modified:**
452
+ ${List all modified files}
453
+
454
+ **Commits Created:**
455
+ ${List commits if any}
456
+
457
+ ### 🔗 PR Status
458
+ - URL: ${PR_URL}
459
+ - Remaining comments: ${count}
460
+ - Next action: ${suggestion}
461
+
462
+ ---
463
+
464
+ 💡 **Next Steps:**
465
+
466
+ ${If all comments resolved:}
467
+ ✅ All comments resolved! Request re-review:
468
+ gh pr review ${PR_NUMBER} --comment -b "All feedback addressed, ready for re-review"
469
+
470
+ ${If comments remain:}
471
+ ⏳ ${count} comments still pending:
472
+ - Review deferred comments above
473
+ - Run /resolve-comments ${PR_NUMBER} when ready
474
+
475
+ ${If changes need testing:}
476
+ 🧪 Test your changes:
477
+ ${testing suggestions}
478
+ ```
479
+
480
+ ---
481
+
482
+ ## Special Cases
483
+
484
+ ### Handling "Out of Scope" Comments
485
+
486
+ If a comment asks for something out of scope:
487
+
488
+ ```
489
+ Reply:
490
+ "Thanks for the suggestion! I think this is out of scope for this PR, which focuses on ${pr_focus}. I've created #${new_issue} to track this separately."
491
+ ```
492
+
493
+ **Prompt user to create issue** or handle it appropriately.
494
+
495
+ ### Handling Conflicting Comments
496
+
497
+ If multiple reviewers have conflicting requests:
498
+
499
+ ```markdown
500
+ ⚠️ CONFLICTING FEEDBACK DETECTED
501
+
502
+ **Comment ${N1}** by @${author1}:
503
+ > ${request1}
504
+
505
+ **Comment ${N2}** by @${author2}:
506
+ > ${request2}
507
+
508
+ These requests conflict. How should we proceed?
509
+ ```
510
+
511
+ Use `AskUserQuestion` to decide:
512
+ ```
513
+ options: [
514
+ {label: "Follow @${author1}'s approach", description: "..."},
515
+ {label: "Follow @${author2}'s approach", description: "..."},
516
+ {label: "Ask for clarification", description: "Post comment to both reviewers"},
517
+ {label: "Defer for discussion", description: "Skip both for now"}
518
+ ]
519
+ ```
520
+
521
+ ### Handling Questions Without Changes
522
+
523
+ For comments that are just questions (no code changes needed):
524
+
525
+ 1. **Answer the question** in reply
526
+ 2. **No files modified**
527
+ 3. **Mark as resolved** after posting answer
528
+
529
+ ---
530
+
531
+ ## Usage Examples
532
+
533
+ ### Basic Usage
534
+ ```bash
535
+ # Resolve comments for current branch's PR
536
+ /resolve-comments
537
+
538
+ # Resolve comments for specific PR
539
+ /resolve-comments 123
540
+
541
+ # Show comments only (no implementation)
542
+ /resolve-comments --list
543
+ ```
544
+
545
+ ### When to Use
546
+
547
+ **✅ Use /resolve-comments when:**
548
+ - PR has review feedback to address
549
+ - You want systematic comment resolution
550
+ - You want to track which comments were addressed
551
+ - You want help generating appropriate replies
552
+
553
+ **💡 Pro Tips:**
554
+ - Address quick wins first (nitpicks, simple changes)
555
+ - Batch similar comments together
556
+ - Test changes after each batch
557
+ - Commit incrementally, not all at once
558
+ - Be honest in replies about limitations
559
+
560
+ **⚠️ Before using:**
561
+ - Pull latest changes: `git pull origin $(git branch --show-current)`
562
+ - Ensure working tree is clean or stash changes
563
+ - Review all comments first to understand scope
564
+
565
+ ---
566
+
567
+ ## Integration with Workflow
568
+
569
+ **After /pull-request:**
570
+ ```
571
+ 1. Team reviews PR
572
+ 2. Feedback comes in
573
+ 3. /resolve-comments ← systematically address feedback
574
+ 4. Reviewers re-review
575
+ 5. Repeat until approved
576
+ 6. Merge!
577
+ ```
578
+
579
+ **Integration Points:**
580
+ - After feedback: `/resolve-comments` (this command)
581
+ - Before pushing changes: `/code-review` (optional)
582
+ - After changes: `/commit` (if manual commit preferred)
583
+ - After addressing all: Request re-review via `gh pr review`
@@ -33,48 +33,12 @@ else
33
33
  fi
34
34
  fi
35
35
 
36
- # Get system CPU and memory usage
37
- get_cpu_usage() {
38
- # Try multiple methods for cross-platform compatibility
39
- if command -v top &> /dev/null; then
40
- # Linux/macOS with top
41
- top -bn1 2>/dev/null | grep -i "cpu" | head -1 | awk '{print $2}' | sed 's/%us,//' | sed 's/id,//' || echo "0"
42
- elif command -v ps &> /dev/null; then
43
- # Fallback: average CPU of all processes
44
- ps -A -o %cpu | awk '{s+=$1} END {printf "%.0f", s}'
45
- else
46
- echo "0"
47
- fi
48
- }
49
-
50
- get_memory_usage() {
51
- # Try multiple methods for cross-platform compatibility
52
- if command -v free &> /dev/null; then
53
- # Linux with free
54
- free | grep Mem | awk '{printf "%.0f", ($3/$2)*100}'
55
- elif command -v vm_stat &> /dev/null; then
56
- # macOS with vm_stat
57
- vm_stat | awk '/Pages active/ {active=$3} /Pages wired/ {wired=$4} /Pages free/ {free=$3} END {printf "%.0f", ((active+wired)/(active+wired+free))*100}' | sed 's/\.//'
58
- else
59
- echo "0"
60
- fi
61
- }
62
-
63
- CPU_USAGE=$(get_cpu_usage)
64
- MEMORY_USAGE=$(get_memory_usage)
65
-
66
36
  # Build status line with colors
67
37
  STATUS_LINE="\033[1;34m$DIR_NAME\033[0m$GIT_INFO"
68
38
 
69
39
  # Add model name
70
40
  STATUS_LINE="$STATUS_LINE \033[1;36m$MODEL\033[0m"
71
41
 
72
- # Add CPU usage
73
- STATUS_LINE="$STATUS_LINE \033[1;35mcpu:${CPU_USAGE}%\033[0m"
74
-
75
- # Add memory usage
76
- STATUS_LINE="$STATUS_LINE \033[1;33mmem:${MEMORY_USAGE}%\033[0m"
77
-
78
42
  # Add large context warning if needed
79
43
  if [ "$EXCEEDS_200K" = "true" ]; then
80
44
  STATUS_LINE="$STATUS_LINE \033[1;91m⚠️large\033[0m"