agileflow 3.0.1 → 3.1.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 (69) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +8 -8
  3. package/lib/api-server.js +3 -2
  4. package/lib/feedback.js +9 -2
  5. package/lib/flag-detection.js +4 -2
  6. package/lib/git-operations.js +4 -2
  7. package/lib/lazy-require.js +59 -0
  8. package/lib/process-executor.js +24 -9
  9. package/lib/skill-loader.js +11 -3
  10. package/package.json +1 -1
  11. package/scripts/agileflow-configure.js +12 -0
  12. package/scripts/agileflow-welcome.js +146 -90
  13. package/scripts/claude-tmux.sh +42 -6
  14. package/scripts/damage-control-multi-agent.js +14 -10
  15. package/scripts/lib/bus-utils.js +3 -1
  16. package/scripts/lib/configure-detect.js +12 -9
  17. package/scripts/lib/configure-features.js +128 -7
  18. package/scripts/lib/configure-repair.js +6 -5
  19. package/scripts/lib/context-formatter.js +13 -3
  20. package/scripts/lib/damage-control-utils.js +5 -1
  21. package/scripts/lib/lifecycle-detector.js +5 -3
  22. package/scripts/lib/process-cleanup.js +8 -4
  23. package/scripts/lib/scale-detector.js +47 -8
  24. package/scripts/lib/signal-detectors.js +117 -59
  25. package/scripts/lib/task-registry.js +5 -1
  26. package/scripts/lib/team-events.js +4 -4
  27. package/scripts/messaging-bridge.js +7 -1
  28. package/scripts/ralph-loop.js +10 -8
  29. package/scripts/smart-detect.js +32 -11
  30. package/scripts/team-manager.js +86 -1
  31. package/scripts/tmux-task-name.sh +105 -0
  32. package/scripts/tmux-task-watcher.sh +344 -0
  33. package/src/core/agents/legal-analyzer-a11y.md +110 -0
  34. package/src/core/agents/legal-analyzer-ai.md +117 -0
  35. package/src/core/agents/legal-analyzer-consumer.md +108 -0
  36. package/src/core/agents/legal-analyzer-content.md +113 -0
  37. package/src/core/agents/legal-analyzer-international.md +115 -0
  38. package/src/core/agents/legal-analyzer-licensing.md +115 -0
  39. package/src/core/agents/legal-analyzer-privacy.md +108 -0
  40. package/src/core/agents/legal-analyzer-security.md +112 -0
  41. package/src/core/agents/legal-analyzer-terms.md +111 -0
  42. package/src/core/agents/legal-consensus.md +242 -0
  43. package/src/core/agents/team-lead.md +50 -13
  44. package/src/core/commands/babysit.md +75 -42
  45. package/src/core/commands/blockers.md +7 -7
  46. package/src/core/commands/configure.md +15 -61
  47. package/src/core/commands/discovery/brief.md +363 -0
  48. package/src/core/commands/discovery/new.md +395 -0
  49. package/src/core/commands/ideate/new.md +5 -5
  50. package/src/core/commands/legal/audit.md +446 -0
  51. package/src/core/commands/logic/audit.md +5 -5
  52. package/src/core/commands/review.md +7 -1
  53. package/src/core/commands/rpi.md +61 -26
  54. package/src/core/commands/sprint.md +7 -6
  55. package/src/core/commands/team/start.md +36 -7
  56. package/src/core/commands/team/stop.md +5 -2
  57. package/src/core/templates/product-brief.md +136 -0
  58. package/tools/cli/installers/ide/claude-code.js +69 -2
  59. package/src/core/agents/configuration/archival.md +0 -350
  60. package/src/core/agents/configuration/attribution.md +0 -343
  61. package/src/core/agents/configuration/ci.md +0 -1103
  62. package/src/core/agents/configuration/damage-control.md +0 -375
  63. package/src/core/agents/configuration/git-config.md +0 -537
  64. package/src/core/agents/configuration/hooks.md +0 -623
  65. package/src/core/agents/configuration/precompact.md +0 -302
  66. package/src/core/agents/configuration/status-line.md +0 -557
  67. package/src/core/agents/configuration/verify.md +0 -618
  68. package/src/core/agents/configuration-damage-control.md +0 -259
  69. package/src/core/agents/configuration-visual-e2e.md +0 -339
@@ -0,0 +1,446 @@
1
+ ---
2
+ description: Multi-agent legal risk analysis with consensus voting for finding compliance gaps
3
+ argument-hint: "[file|directory] [DEPTH=quick|deep] [FOCUS=privacy|terms|a11y|licensing|consumer|security|ai|content|international|all]"
4
+ compact_context:
5
+ priority: high
6
+ preserve_rules:
7
+ - "ACTIVE COMMAND: /agileflow:legal:audit - Multi-agent legal risk analysis"
8
+ - "CRITICAL: Deploy analyzers IN PARALLEL in ONE message with multiple Task calls"
9
+ - "CRITICAL: Wait for all results before running consensus (use TaskOutput with block=true)"
10
+ - "CRITICAL: Confidence scoring: CONFIRMED (2+ agree), LIKELY (1 with evidence), INVESTIGATE (1 weak)"
11
+ - "MUST parse arguments: TARGET (file/dir), DEPTH (quick/deep), FOCUS (privacy|terms|a11y|licensing|consumer|security|ai|content|international|all)"
12
+ - "Pass consensus all analyzer outputs, let it synthesize the final report"
13
+ state_fields:
14
+ - target_path
15
+ - depth
16
+ - focus_areas
17
+ - analyzers_deployed
18
+ - findings_collected
19
+ ---
20
+
21
+ # /agileflow:legal:audit
22
+
23
+ Deploy multiple specialized legal risk analyzers in parallel to find compliance gaps, then synthesize results through consensus voting into a prioritized Legal Risk Report.
24
+
25
+ ---
26
+
27
+ ## Quick Reference
28
+
29
+ ```
30
+ /agileflow:legal:audit app/ # Analyze app directory (quick, core 5 analyzers)
31
+ /agileflow:legal:audit . DEPTH=deep # Deep analysis - all 9 analyzers
32
+ /agileflow:legal:audit src/ FOCUS=privacy,a11y # Focus on specific areas
33
+ /agileflow:legal:audit . DEPTH=deep FOCUS=all # Comprehensive full audit
34
+ /agileflow:legal:audit app/page.tsx FOCUS=ai # Check single file for AI compliance
35
+ ```
36
+
37
+ ---
38
+
39
+ ## How It Works
40
+
41
+ ```
42
+ ┌─────────────────────────────────────────────────────────────┐
43
+ │ /agileflow:legal:audit │
44
+ │ │
45
+ │ 1. Parse arguments (target, depth, focus) │
46
+ │ 2. Deploy analyzers IN PARALLEL │
47
+ │ 3. Collect all findings │
48
+ │ 4. Run consensus coordinator to validate & prioritize │
49
+ │ 5. Generate actionable Legal Risk Report │
50
+ └─────────────────────────────────────────────────────────────┘
51
+
52
+ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐
53
+ │Privacy │ │ Terms │ │ A11y │ │License │ │Consumer│
54
+ └───┬────┘ └───┬────┘ └───┬────┘ └───┬────┘ └───┬────┘
55
+ │ │ │ │ │
56
+ ┌───┴────┐ ┌───┴────┐ ┌───┴────┐ ┌───┴────┐
57
+ │Security│ │ AI │ │Content │ │ Intl │ (deep only)
58
+ └───┬────┘ └───┬────┘ └───┬────┘ └───┬────┘
59
+ │ │ │ │
60
+ └──────────┴──────────┼──────────┘
61
+
62
+ ┌─────────────────────────┐
63
+ │ Consensus Coordinator │
64
+ │ (validates, votes, │
65
+ │ generates report) │
66
+ └─────────────────────────┘
67
+ ```
68
+
69
+ ---
70
+
71
+ ## Arguments
72
+
73
+ | Argument | Values | Default | Description |
74
+ |----------|--------|---------|-------------|
75
+ | TARGET | file/directory | `.` | What to analyze |
76
+ | DEPTH | quick, deep | quick | quick = core 5 analyzers, deep = all 9 |
77
+ | FOCUS | privacy,terms,a11y,licensing,consumer,security,ai,content,international,all | all | Which analyzers to deploy |
78
+
79
+ ---
80
+
81
+ ## Step-by-Step Process
82
+
83
+ ### STEP 1: Parse Arguments
84
+
85
+ ```
86
+ TARGET = first argument or current directory
87
+ DEPTH = quick (default) or deep
88
+ FOCUS = all (default) or comma-separated list
89
+ ```
90
+
91
+ **Analyzer Selection**:
92
+
93
+ | Condition | Analyzers Deployed |
94
+ |-----------|-------------------|
95
+ | `DEPTH=quick` + `FOCUS=all` | privacy, terms, a11y, licensing, consumer (core 5) |
96
+ | `DEPTH=deep` + `FOCUS=all` | All 9 analyzers |
97
+ | `FOCUS=privacy` | legal-analyzer-privacy only |
98
+ | `FOCUS=terms` | legal-analyzer-terms only |
99
+ | `FOCUS=a11y` | legal-analyzer-a11y only |
100
+ | `FOCUS=licensing` | legal-analyzer-licensing only |
101
+ | `FOCUS=consumer` | legal-analyzer-consumer only |
102
+ | `FOCUS=security` | legal-analyzer-security only |
103
+ | `FOCUS=ai` | legal-analyzer-ai only |
104
+ | `FOCUS=content` | legal-analyzer-content only |
105
+ | `FOCUS=international` | legal-analyzer-international only |
106
+ | `FOCUS=privacy,a11y` | Comma-separated: deploy specified analyzers |
107
+
108
+ **DEPTH behavior**:
109
+ - `quick` (default): Deploy core 5 analyzers. Focus on CRITICAL/HIGH issues only.
110
+ - `deep`: Deploy all 9 analyzers. Include MEDIUM/LOW findings.
111
+
112
+ ### STEP 2: Deploy Analyzers in Parallel
113
+
114
+ **CRITICAL**: Deploy ALL selected analyzers in a SINGLE message with multiple Task calls.
115
+
116
+ **Prompt template for each analyzer**:
117
+
118
+ ```
119
+ TASK: Analyze the following code for {LEGAL_DOMAIN} compliance risks.
120
+
121
+ TARGET: {file_path or directory}
122
+ DEPTH: {quick|deep}
123
+
124
+ {For quick depth}: Focus on CRITICAL and HIGH risk issues only. Skip advisory/best-practice items.
125
+ {For deep depth}: Be comprehensive. Include MEDIUM and LOW risk findings.
126
+
127
+ Read the target files and apply your analysis methodology.
128
+
129
+ OUTPUT your findings in your standard format (FINDING-N with location, risk level, legal basis, code, explanation, remediation).
130
+
131
+ If no issues found, output: "No {LEGAL_DOMAIN} compliance issues found in {TARGET}"
132
+ ```
133
+
134
+ **Example deployment (DEPTH=quick, FOCUS=all - deploys core 5)**:
135
+
136
+ ```xml
137
+ <invoke name="Task">
138
+ <parameter name="description">Privacy compliance analysis</parameter>
139
+ <parameter name="prompt">TASK: Analyze the following code for PRIVACY & DATA PROTECTION compliance risks.
140
+ TARGET: src/
141
+ DEPTH: quick
142
+ Focus on CRITICAL and HIGH risk issues only...
143
+ ...</parameter>
144
+ <parameter name="subagent_type">legal-analyzer-privacy</parameter>
145
+ <parameter name="run_in_background">true</parameter>
146
+ </invoke>
147
+
148
+ <invoke name="Task">
149
+ <parameter name="description">Terms & legal docs analysis</parameter>
150
+ <parameter name="prompt">TASK: Analyze the following code for TERMS & LEGAL DOCUMENT compliance risks.
151
+ TARGET: src/
152
+ DEPTH: quick
153
+ ...</parameter>
154
+ <parameter name="subagent_type">legal-analyzer-terms</parameter>
155
+ <parameter name="run_in_background">true</parameter>
156
+ </invoke>
157
+
158
+ <invoke name="Task">
159
+ <parameter name="description">Accessibility compliance analysis</parameter>
160
+ <parameter name="prompt">TASK: Analyze the following code for ACCESSIBILITY compliance risks.
161
+ TARGET: src/
162
+ DEPTH: quick
163
+ ...</parameter>
164
+ <parameter name="subagent_type">legal-analyzer-a11y</parameter>
165
+ <parameter name="run_in_background">true</parameter>
166
+ </invoke>
167
+
168
+ <invoke name="Task">
169
+ <parameter name="description">License compliance analysis</parameter>
170
+ <parameter name="prompt">TASK: Analyze the following code for LICENSING & IP compliance risks.
171
+ TARGET: src/
172
+ DEPTH: quick
173
+ ...</parameter>
174
+ <parameter name="subagent_type">legal-analyzer-licensing</parameter>
175
+ <parameter name="run_in_background">true</parameter>
176
+ </invoke>
177
+
178
+ <invoke name="Task">
179
+ <parameter name="description">Consumer protection analysis</parameter>
180
+ <parameter name="prompt">TASK: Analyze the following code for CONSUMER PROTECTION compliance risks.
181
+ TARGET: src/
182
+ DEPTH: quick
183
+ ...</parameter>
184
+ <parameter name="subagent_type">legal-analyzer-consumer</parameter>
185
+ <parameter name="run_in_background">true</parameter>
186
+ </invoke>
187
+ ```
188
+
189
+ **For DEPTH=deep, also deploy**:
190
+
191
+ ```xml
192
+ <invoke name="Task">
193
+ <parameter name="description">Security legal obligations analysis</parameter>
194
+ <parameter name="prompt">TASK: Analyze the following code for SECURITY LEGAL OBLIGATION compliance risks...
195
+ ...</parameter>
196
+ <parameter name="subagent_type">legal-analyzer-security</parameter>
197
+ <parameter name="run_in_background">true</parameter>
198
+ </invoke>
199
+
200
+ <invoke name="Task">
201
+ <parameter name="description">AI compliance analysis</parameter>
202
+ <parameter name="prompt">TASK: Analyze the following code for AI & ALGORITHMIC compliance risks...
203
+ ...</parameter>
204
+ <parameter name="subagent_type">legal-analyzer-ai</parameter>
205
+ <parameter name="run_in_background">true</parameter>
206
+ </invoke>
207
+
208
+ <invoke name="Task">
209
+ <parameter name="description">Content & IP obligations analysis</parameter>
210
+ <parameter name="prompt">TASK: Analyze the following code for CONTENT MODERATION & IP OBLIGATION compliance risks...
211
+ ...</parameter>
212
+ <parameter name="subagent_type">legal-analyzer-content</parameter>
213
+ <parameter name="run_in_background">true</parameter>
214
+ </invoke>
215
+
216
+ <invoke name="Task">
217
+ <parameter name="description">International compliance analysis</parameter>
218
+ <parameter name="prompt">TASK: Analyze the following code for INTERNATIONAL COMPLIANCE risks...
219
+ ...</parameter>
220
+ <parameter name="subagent_type">legal-analyzer-international</parameter>
221
+ <parameter name="run_in_background">true</parameter>
222
+ </invoke>
223
+ ```
224
+
225
+ ### STEP 3: Collect Results
226
+
227
+ Wait for all analyzers to complete:
228
+
229
+ ```xml
230
+ <invoke name="TaskOutput">
231
+ <parameter name="task_id">{privacy_id}</parameter>
232
+ <parameter name="block">true</parameter>
233
+ </invoke>
234
+
235
+ <invoke name="TaskOutput">
236
+ <parameter name="task_id">{terms_id}</parameter>
237
+ <parameter name="block">true</parameter>
238
+ </invoke>
239
+
240
+ <!-- ... collect all results ... -->
241
+ ```
242
+
243
+ ### STEP 4: Run Consensus Coordinator
244
+
245
+ Pass all analyzer outputs to the consensus coordinator:
246
+
247
+ ```xml
248
+ <invoke name="Task">
249
+ <parameter name="description">Legal audit consensus</parameter>
250
+ <parameter name="prompt">You are the Legal Consensus Coordinator.
251
+
252
+ TARGET: {target_path}
253
+ DEPTH: {depth}
254
+
255
+ ## Analyzer Outputs
256
+
257
+ ### Privacy Analyzer Results:
258
+ {privacy_output}
259
+
260
+ ### Terms Analyzer Results:
261
+ {terms_output}
262
+
263
+ ### Accessibility Analyzer Results:
264
+ {a11y_output}
265
+
266
+ ### Licensing Analyzer Results:
267
+ {licensing_output}
268
+
269
+ ### Consumer Protection Analyzer Results:
270
+ {consumer_output}
271
+
272
+ {If deep depth, also include:}
273
+ ### Security Legal Obligations Results:
274
+ {security_output}
275
+
276
+ ### AI Compliance Results:
277
+ {ai_output}
278
+
279
+ ### Content & IP Obligations Results:
280
+ {content_output}
281
+
282
+ ### International Compliance Results:
283
+ {international_output}
284
+
285
+ ---
286
+
287
+ Follow your consensus process:
288
+ 1. Detect project type from the codebase
289
+ 2. Parse all findings into normalized structure
290
+ 3. Group related findings by location
291
+ 4. Vote on confidence (CONFIRMED if 2+ agree, LIKELY if 1 with evidence)
292
+ 5. Filter by project type relevance
293
+ 6. Generate the final Legal Risk Report
294
+ 7. Save report to docs/08-project/legal-audits/legal-audit-{YYYYMMDD}.md
295
+ </parameter>
296
+ <parameter name="subagent_type">legal-consensus</parameter>
297
+ </invoke>
298
+ ```
299
+
300
+ ### STEP 5: Present Results
301
+
302
+ After consensus completes, show the report summary and offer next steps:
303
+
304
+ ```xml
305
+ <invoke name="AskUserQuestion">
306
+ <parameter name="questions">[{
307
+ "question": "Legal audit complete: [N] findings ([critical] Critical, [high] High). [files_count] files analyzed. Project type: [type].",
308
+ "header": "Next steps",
309
+ "multiSelect": false,
310
+ "options": [
311
+ {"label": "Fix [critical] Critical issues now (Recommended)", "description": "[top_issue_summary] - [legal_basis]"},
312
+ {"label": "Create stories for all findings", "description": "Track [critical] critical + [high] high priority items in backlog"},
313
+ {"label": "Re-run with DEPTH=deep on [target]", "description": "Current was quick (5 analyzers) - deep adds Security, AI, Content, International"},
314
+ {"label": "Save report and done", "description": "Report saved to docs/08-project/legal-audits/"}
315
+ ]
316
+ }]</parameter>
317
+ </invoke>
318
+ ```
319
+
320
+ ---
321
+
322
+ ## Example Output
323
+
324
+ ```
325
+ ⚖️ Legal Audit: app/
326
+ ══════════════════════════════════════════════════════════════
327
+
328
+ Deploying 5 legal analyzers (quick mode)...
329
+ ✓ Privacy Analyzer
330
+ ✓ Terms Analyzer
331
+ ✓ Accessibility Analyzer
332
+ ✓ Licensing Analyzer
333
+ ✓ Consumer Protection Analyzer
334
+
335
+ Running consensus...
336
+ ✓ Consensus complete
337
+ ✓ Project type detected: SaaS Application
338
+
339
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
340
+ 📊 RISK SUMMARY
341
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
342
+
343
+ | Risk Level | Count |
344
+ |------------|-------|
345
+ | Critical | 2 |
346
+ | High | 3 |
347
+ | Medium | 4 |
348
+ | Low | 1 |
349
+
350
+ Total: 10 findings (3 false positives excluded)
351
+
352
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
353
+ 🚨 FIX BEFORE LAUNCH
354
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
355
+
356
+ 1. No privacy policy but collecting email [CONFIRMED by Privacy, Terms]
357
+ Location: app/page.tsx:42
358
+ Legal Basis: GDPR Article 13, CCPA
359
+ Fix: Add /privacy page and link from footer
360
+
361
+ 2. Images without alt text (12 instances) [CONFIRMED by A11y]
362
+ Location: components/*.tsx
363
+ Legal Basis: ADA Title III, WCAG 2.1 AA 1.1.1
364
+ Fix: Add descriptive alt attributes to all images
365
+
366
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
367
+ ⚠️ FIX THIS SPRINT
368
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
369
+
370
+ 3. Missing Terms of Service [LIKELY - Terms]
371
+ 4. Cookie consent banner absent [LIKELY - Privacy]
372
+ 5. GPL dependency in MIT project [LIKELY - Licensing]
373
+
374
+ [Full report saved to docs/08-project/legal-audits/legal-audit-20260214.md]
375
+ ```
376
+
377
+ ---
378
+
379
+ <!-- COMPACT_SUMMARY_START -->
380
+ ## Compact Summary
381
+
382
+ **Command**: `/agileflow:legal:audit` - Multi-agent legal risk analysis with consensus
383
+
384
+ **Quick Usage**:
385
+ ```
386
+ /agileflow:legal:audit app/ # Quick scan (core 5 analyzers)
387
+ /agileflow:legal:audit . DEPTH=deep # All 9 analyzers
388
+ /agileflow:legal:audit src/ FOCUS=privacy,a11y # Specific areas
389
+ ```
390
+
391
+ **What It Does**: Deploy legal analyzers in parallel → Each finds different compliance gaps → Consensus coordinator validates, filters by project type, prioritizes → Actionable Legal Risk Report
392
+
393
+ **Analyzers (Core 5 - quick mode)**:
394
+ - `legal-analyzer-privacy` - GDPR, CCPA, cookies, data collection
395
+ - `legal-analyzer-terms` - ToS, disclaimers, refund policies
396
+ - `legal-analyzer-a11y` - ADA, WCAG, Section 508
397
+ - `legal-analyzer-licensing` - Open source licenses, IP, attribution
398
+ - `legal-analyzer-consumer` - Dark patterns, FTC, COPPA
399
+
400
+ **Analyzers (Deep mode adds 4 more)**:
401
+ - `legal-analyzer-security` - Breach notification, PCI-DSS, encryption obligations
402
+ - `legal-analyzer-ai` - EU AI Act, algorithmic bias, AI disclosure
403
+ - `legal-analyzer-content` - DMCA, Digital Services Act, UGC moderation
404
+ - `legal-analyzer-international` - LGPD, PIPL, data localization, cross-border
405
+
406
+ **Risk Levels**:
407
+ - CRITICAL: Active lawsuit risk → Fix before launch
408
+ - HIGH: Regulatory fine risk → Fix this sprint
409
+ - MEDIUM: Best practice gap → Backlog
410
+ - LOW: Advisory improvement
411
+
412
+ **Confidence Levels**:
413
+ - CONFIRMED: 2+ analyzers agree → High priority
414
+ - LIKELY: 1 analyzer with evidence → Medium priority
415
+ - INVESTIGATE: 1 analyzer, weak evidence → Low priority
416
+
417
+ **Output**: `docs/08-project/legal-audits/legal-audit-{YYYYMMDD}.md`
418
+ <!-- COMPACT_SUMMARY_END -->
419
+
420
+ ---
421
+
422
+ ## Integration with Babysit
423
+
424
+ When `/agileflow:babysit` completes implementation, it can run a quick legal audit:
425
+
426
+ ```
427
+ 📍 Implementation complete. Running quick legal audit...
428
+
429
+ ⚖️ Legal Audit Results:
430
+ ━━━━━━━━━━━━━━━━━━━━━━
431
+ ✅ No critical legal risks found
432
+ ⚠️ 1 HIGH issue detected:
433
+ - app/page.tsx:42 - Collecting email without privacy policy link
434
+ Confidence: CONFIRMED (Privacy + Terms analyzers)
435
+
436
+ Fix before launch? [Y/n]
437
+ ```
438
+
439
+ ---
440
+
441
+ ## Related Commands
442
+
443
+ - `/agileflow:logic:audit` - Logic bug analysis (similar architecture)
444
+ - `/agileflow:review` - Code review (includes some compliance checks)
445
+ - `/agileflow:multi-expert` - General multi-expert analysis
446
+ - `/agileflow:verify` - Run tests
@@ -239,14 +239,14 @@ After consensus completes, show the report summary and offer next steps:
239
239
  ```xml
240
240
  <invoke name="AskUserQuestion">
241
241
  <parameter name="questions">[{
242
- "question": "What would you like to do with the audit results?",
242
+ "question": "Logic audit: [N] findings ([critical] CONFIRMED, [likely] LIKELY). [files_count] files analyzed.",
243
243
  "header": "Next steps",
244
244
  "multiSelect": false,
245
245
  "options": [
246
- {"label": "Fix critical issues now (Recommended)", "description": "Address P0/P1 issues immediately"},
247
- {"label": "Create stories for findings", "description": "Add to backlog as user stories"},
248
- {"label": "Run deeper analysis", "description": "Re-run with DEPTH=deep for more coverage"},
249
- {"label": "Save report and done", "description": "Keep the report, no further action"}
246
+ {"label": "Fix [critical] CONFIRMED issues now (Recommended)", "description": "[top_issue_summary] at [file:line] - [fix_hint]"},
247
+ {"label": "Create [N] stories for all findings", "description": "Track [critical] critical + [high] high priority items in backlog"},
248
+ {"label": "Re-run with DEPTH=deep on [target]", "description": "Current was quick - deep adds P2 issues and comprehensive coverage"},
249
+ {"label": "Save report and done", "description": "Report saved to docs/08-project/logic-audits/"}
250
250
  ]
251
251
  }]</parameter>
252
252
  </invoke>
@@ -641,7 +641,13 @@ Analyzing 127 lines changed across 3 files...
641
641
  Summary: 1 critical, 3 warnings, 3 good
642
642
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
643
643
 
644
- Apply auto-fixes for non-critical issues? [Y/n]
644
+ AskUserQuestion:
645
+ question: "Review: 85/100 score. 1 critical (SQL injection at :45), 3 warnings. How to proceed?"
646
+ options:
647
+ - "Fix SQL injection at line 45 first (Recommended)" → "Critical - blocks merge"
648
+ - "Auto-fix 3 style warnings" → "Safe formatting fixes only"
649
+ - "View full diff of all fixes" → "Preview 4 changes before applying"
650
+ - "Skip fixes, save report only" → "Report saved to docs/08-project/code-reviews/"
645
651
  ```
646
652
 
647
653
  ### Success - Clean Review
@@ -392,7 +392,7 @@ Reading plan: `.claude/plans/[slug].md`
392
392
  Running tests to verify step 1...
393
393
  ```
394
394
 
395
- 4. **Complete implementation**:
395
+ 4. **Complete implementation** with smart AskUserQuestion:
396
396
  ```markdown
397
397
  ---
398
398
 
@@ -404,13 +404,23 @@ All [N] steps executed successfully.
404
404
  - [X] files modified
405
405
  - [Y] tests added/updated
406
406
  - [Z] tests passing
407
+ ```
407
408
 
408
- ### Next Actions
409
- - [ ] Run full test suite: `npm test`
410
- - [ ] Create PR: `/agileflow:pr-template`
411
- - [ ] Update story status: `/agileflow:status STORY=US-#### STATUS=in-review`
412
-
413
- ---
409
+ Then present smart next steps:
410
+ ```xml
411
+ <invoke name="AskUserQuestion">
412
+ <parameter name="questions">[{
413
+ "question": "Implementation complete: [N] steps done, [X] files modified, [Z] tests passing. What next?",
414
+ "header": "Next step",
415
+ "multiSelect": false,
416
+ "options": [
417
+ {"label": "Run full test suite (Recommended)", "description": "Verify all [Z] tests still pass after [X] file changes"},
418
+ {"label": "🔍 Run logic audit on [X] modified files", "description": "5 analyzers check for edge cases, race conditions, type bugs"},
419
+ {"label": "Create PR with /agileflow:pr", "description": "[X] files changed across [N] implementation steps"},
420
+ {"label": "Pause here", "description": "Implementation saved, tests can be run later"}
421
+ ]
422
+ }]</parameter>
423
+ </invoke>
414
424
  ```
415
425
 
416
426
  ### Step 4: Monitor Context Health
@@ -423,18 +433,22 @@ Throughout execution, monitor for signs of context degradation:
423
433
  - Heavy tool output (JSON, logs)
424
434
  - Repetitive or generic responses
425
435
 
426
- **If detected, warn**:
427
- ```markdown
428
- ⚠️ **Context Health Warning**
436
+ **If detected, use smart AskUserQuestion**:
429
437
 
430
- This conversation has grown significantly. We may be approaching the "dumb zone" where agent quality degrades.
431
-
432
- **Current phase**: [phase]
433
- **Recommendation**: [Complete phase and start fresh / Save progress and compact]
434
-
435
- Would you like to:
436
- 1. Complete current phase and save artifact now
437
- 2. Continue (understanding quality may degrade)
438
+ ```xml
439
+ <invoke name="AskUserQuestion">
440
+ <parameter name="questions">[{
441
+ "question": "⚠️ Context at ~[utilization]% ([phase] phase). [files_read] files read, [tool_calls] tool calls. Save progress?",
442
+ "header": "Context health",
443
+ "multiSelect": false,
444
+ "options": [
445
+ {"label": "Save [phase] artifact and start fresh (Recommended)", "description": "New conversation starts in smart zone (<40%). Artifact preserves all understanding."},
446
+ {"label": "Compact context and continue", "description": "Reduce utilization but may lose some nuance"},
447
+ {"label": "Continue without saving", "description": "⚠️ Quality may degrade - currently at [utilization]%"},
448
+ {"label": "Pause here", "description": "Progress saved to [artifact_path]"}
449
+ ]
450
+ }]</parameter>
451
+ </invoke>
438
452
  ```
439
453
 
440
454
  ---
@@ -525,7 +539,13 @@ Research Summary:
525
539
  - Patterns: Use existing middleware structure
526
540
  - Risks: Token storage, refresh logic
527
541
 
528
- Ready for planning phase? [Y/n]
542
+ AskUserQuestion:
543
+ question: "Research complete: 4 findings, 2 risks identified. Ready for planning phase?"
544
+ options:
545
+ - "Start planning in new conversation (Recommended)" → "Fresh context with research artifact compressed"
546
+ - "Continue planning in this conversation" → "Context at ~35% - still in smart zone"
547
+ - "Refine research first" → "4 findings may need deeper investigation"
548
+ - "Pause here" → "Research saved to docs/10-research/"
529
549
 
530
550
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
531
551
  Phase 2: PLAN
@@ -542,7 +562,13 @@ Files to modify: 4
542
562
  New files: 2
543
563
  Estimated complexity: Medium
544
564
 
545
- Approve plan and proceed to implement? [Y/n]
565
+ AskUserQuestion:
566
+ question: "Plan ready: 5 steps, 6 files, ~medium complexity. Approve and proceed?"
567
+ options:
568
+ - "Approve - start implementing in new conversation (Recommended)" → "Fresh context with plan artifact"
569
+ - "Approve - implement in this conversation" → "Context at ~50% - proceed with caution"
570
+ - "Revise step 3 (update login endpoint)" → "Adjust plan before implementing"
571
+ - "Pause here" → "Plan saved to .claude/plans/"
546
572
 
547
573
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
548
574
  Phase 3: IMPLEMENT
@@ -555,6 +581,14 @@ Implementing...
555
581
  ✓ Added 12 tests (all passing)
556
582
 
557
583
  🎉 Implementation complete!
584
+
585
+ AskUserQuestion:
586
+ question: "Implementation complete: 5 steps, 4 files modified, 12 tests passing. What next?"
587
+ options:
588
+ - "Run full test suite (Recommended)" → "Verify all 12 tests pass"
589
+ - "🔍 Run logic audit on 4 modified files" → "5 analyzers check for edge cases"
590
+ - "Create PR" → "4 files changed across 5 steps"
591
+ - "Pause here" → "Implementation saved"
558
592
  ```
559
593
 
560
594
  ### Success - Phase Transition
@@ -567,12 +601,13 @@ Current: RESEARCH → Next: PLAN
567
601
 
568
602
  ⚠️ Context Health: 65% (approaching threshold)
569
603
 
570
- Before transitioning:
571
- 1. Document key findings
572
- 2. Save research notes
573
- 3. Plan is LEVERAGE - quality > speed now
574
-
575
- Proceed with transition? [Y/n]
604
+ AskUserQuestion:
605
+ question: "Context at 65% - approaching dumb zone. Save artifact and transition?"
606
+ options:
607
+ - "Save artifact and start new conversation (Recommended)" → "Fresh context in smart zone (<40%)"
608
+ - "Continue in this conversation" → "⚠️ Quality may degrade past 70%"
609
+ - "Compact context first" → "Reduce utilization, then continue"
610
+ - "Pause here" → "Progress saved, resume later"
576
611
  ```
577
612
 
578
613
  ### Error - Wrong Phase
@@ -95,17 +95,18 @@ TaskCreate/TaskUpdate:
95
95
  </invoke>
96
96
  ```
97
97
 
98
- AskUserQuestion:
98
+ AskUserQuestion (use actual counts and data from analysis):
99
99
  ```xml
100
100
  <invoke name="AskUserQuestion">
101
101
  <parameter name="questions">[{
102
- "question": "Commit this sprint plan: 5 stories, 8.5 days?",
103
- "header": "Confirm Sprint Commitment",
102
+ "question": "Sprint [ID]: [N] stories, [X]d estimated ([Y]% of [Z]d capacity). [Risk level]. Commit?",
103
+ "header": "Sprint",
104
104
  "multiSelect": false,
105
105
  "options": [
106
- {"label": "Yes, commit plan", "description": "Update status.json and create milestone"},
107
- {"label": "No, adjust", "description": "Modify story selection"},
108
- {"label": "Cancel", "description": "Exit without changes"}
106
+ {"label": "Commit sprint plan (Recommended)", "description": "[N] stories across [agents] - [epic summary]. Starts today, ends [date]"},
107
+ {"label": "Adjust story selection", "description": "Currently at [Y]% capacity - add/remove stories before committing"},
108
+ {"label": "View dependency risks first", "description": "[risk_count] risks detected: [top risk summary]"},
109
+ {"label": "Cancel", "description": "Exit without changes to status.json"}
109
110
  ]
110
111
  }]</parameter>
111
112
  </invoke>