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
@@ -13,7 +13,7 @@ compact_context:
13
13
  - "STUCK DETECTION: If same error 2+ times, suggest /agileflow:research:ask with detailed prompt"
14
14
  - "PLAN FILE CONTEXT: BEFORE ExitPlanMode, EDIT plan file to add babysit rules header at TOP - rules survive context clear"
15
15
  - "STORY CLAIMING: claim after selection, release after completion, check others before suggesting"
16
- - "LOGIC AUDIT: After implementation, offer '🔍 Run logic audit' option via AskUserQuestion (not automatic)"
16
+ - "LOGIC AUDIT: ALWAYS suggest '🔍 Run logic audit' after ANY implementation (plan or direct) - it's a standard post-impl step, not optional"
17
17
  state_fields:
18
18
  - current_story
19
19
  - current_epic
@@ -382,8 +382,9 @@ If you end your response without calling AskUserQuestion, you have violated thes
382
382
  |-------|-------------------|-----|
383
383
  | After context gathering | The most impactful ready story | Based on epic progress, blockers, dependencies |
384
384
  | After plan approval | "Start implementing now" | Don't ask permission, suggest action |
385
- | After code is written | "Run tests to verify (Recommended)" | Always verify before committing |
386
- | After tests pass | "Commit and continue to next story" | Keep momentum |
385
+ | After code is written | "Run tests to verify (Recommended)" + logic audit option | Always verify before committing |
386
+ | After tests pass | "🔍 Run logic audit (Recommended)" or "Commit" | Logic audit catches what tests miss |
387
+ | After logic audit | "Commit: '[type]: [summary]' (Recommended)" | All checks done, ready to commit |
387
388
  | After error | "Try [specific alternative approach]" | Don't just say "fix it" |
388
389
  | After expert returns | "Review and apply changes" or "Run tests" | Based on expert output quality |
389
390
 
@@ -421,7 +422,7 @@ If you end your response without calling AskUserQuestion, you have violated thes
421
422
  | User gave detailed instructions | Skip plan mode, follow them |
422
423
  | Everything else | **USE PLAN MODE** |
423
424
 
424
- **Plan mode flow:** EnterPlanMode → Explore with Glob/Grep/Read → Design approach → ExitPlanMode → Implement
425
+ **Plan mode flow:** EnterPlanMode → Explore with Glob/Grep/Read → Design approach → Add smart babysit header to plan → ExitPlanMode → Implement → Smart AskUserQuestion (with logic audit)
425
426
 
426
427
  ---
427
428
 
@@ -512,17 +513,21 @@ if(ready.length)console.log('🔔 Validators ready:',ready.map(t=>t.id).join(','
512
513
  ## ⚠️ MANDATORY IMPLEMENTATION RULES (from /babysit)
513
514
 
514
515
  These rules MUST be followed during implementation:
515
- 1. **ALWAYS end your final response with AskUserQuestion tool** offering next steps
516
+ 1. **ALWAYS end your final response with SMART AskUserQuestion tool** - specific, contextual options with (Recommended) label
516
517
  2. **Use EnterPlanMode** if any NEW non-trivial tasks arise during implementation
517
518
  3. **Delegate complex work** to domain experts via Task tool
518
519
  4. **Track progress** with TaskCreate/TaskUpdate for multi-step work
519
520
 
520
- After implementation completes, you MUST call AskUserQuestion with options like:
521
- - "Run tests to verify"
522
- - "🔍 Run logic audit" (for complex code - uses /agileflow:logic:audit)
523
- - "Continue to next task"
524
- - "Review changes"
525
- - "Pause here"
521
+ **Smart AskUserQuestion format** (NEVER generic - always contextual):
522
+ - Options must reference specific files, test commands, story IDs, and change counts
523
+ - Always mark the best next step with "(Recommended)"
524
+ - Include descriptions with concrete context (e.g., "3 files changed in scripts/")
525
+
526
+ After implementation completes, you MUST call AskUserQuestion. **ALWAYS include logic audit**:
527
+ - "Run `npm test` in packages/cli/ (Recommended)" + description with file count
528
+ - "🔍 Run logic audit on [N] modified files" + "5 analyzers check for edge cases, race conditions, type bugs"
529
+ - "Commit: '[type]: [summary]'" + "All tests pass, ready to commit"
530
+ - "Pause here" + "Changes saved, not committed"
526
531
 
527
532
  ---
528
533
  ```
@@ -534,7 +539,7 @@ After implementation completes, you MUST call AskUserQuestion with options like:
534
539
  # Plan: Add User Profile Feature
535
540
 
536
541
  ## ⚠️ MANDATORY IMPLEMENTATION RULES (from /babysit)
537
- [rules as above]
542
+ [rules as above - with SMART AskUserQuestion and logic audit]
538
543
 
539
544
  ---
540
545
 
@@ -594,22 +599,22 @@ After implementation completes, you MUST call AskUserQuestion with options like:
594
599
  13. Delegate to experts based on scope
595
600
  14. Collect results if async (TaskOutput)
596
601
  15. Verify tests pass
597
- 16. AskUserQuestion with specific test results: "All tests pass - commit changes? (Recommended)"
602
+ 16. **ALWAYS offer logic audit** via smart AskUserQuestion with specific file counts and test results
598
603
 
599
604
  **Phase 4: Completion**
600
- 15. Update status.json (mark story done)
601
- 16. **RELEASE THE STORY claim:**
605
+ 17. Update status.json (mark story done)
606
+ 18. **RELEASE THE STORY claim:**
602
607
  ```bash
603
608
  node .agileflow/scripts/lib/story-claiming.js release <story-id>
604
609
  ```
605
- 17. Present next steps via AskUserQuestion **(including Logic Audit option)**
610
+ 19. Present next steps via smart AskUserQuestion
606
611
 
607
- **Post-Implementation Options** (offer via AskUserQuestion):
608
- - "Run tests to verify" - Standard verification
609
- - "🔍 Run logic audit" - Multi-agent analysis for logic bugs (recommended for complex code)
610
- - "Continue to next story" - Move on
611
- - "Review changes" - Manual review
612
- - "Pause here" - Stop for now
612
+ **Post-Implementation Options** (ALWAYS offer via smart AskUserQuestion):
613
+ - "Run tests to verify (Recommended)" - with specific test command and file count
614
+ - "🔍 Run logic audit on N modified files" - **ALWAYS include this** - 5 analyzers check edge cases, race conditions, type bugs
615
+ - "Commit: '[type]: [summary]'" - with specific commit message suggestion
616
+ - "Continue to next story" - with story ID and epic progress
617
+ - "Pause here" - with summary of what's saved/uncommitted
613
618
 
614
619
  ---
615
620
 
@@ -673,19 +678,37 @@ Present top 3-5 via AskUserQuestion, always include "Other" option.
673
678
 
674
679
  ### LOGIC AUDIT INTEGRATION
675
680
 
676
- After completing an implementation, offer logic audit as an **optional quality check**:
681
+ **ALWAYS suggest logic audit after ANY implementation** - whether from a plan, direct coding, or expert delegation. This is a standard post-implementation step, not optional.
677
682
 
683
+ **Smart AskUserQuestion after implementation:**
678
684
  ```xml
679
685
  <invoke name="AskUserQuestion">
680
686
  <parameter name="questions">[{
681
- "question": "Implementation complete. What would you like to do?",
687
+ "question": "Implementation complete (3 files changed, 85 lines added). What's next?",
682
688
  "header": "Next step",
683
689
  "multiSelect": false,
684
690
  "options": [
685
- {"label": "Run tests (Recommended)", "description": "Verify with test suite"},
686
- {"label": "🔍 Run logic audit", "description": "Multi-agent analysis for edge cases, race conditions, type bugs"},
687
- {"label": "Continue to next story", "description": "Move on without additional checks"},
688
- {"label": "Pause here", "description": "Stop for now"}
691
+ {"label": "Run npm test in packages/cli/ (Recommended)", "description": "3 files changed in scripts/ - verify before committing"},
692
+ {"label": "🔍 Run logic audit on 3 modified files", "description": "5 analyzers check for edge cases, race conditions, type bugs - catches issues tests miss"},
693
+ {"label": "Commit: 'feat: add session tracking'", "description": "Skip verification - only if changes are trivial"},
694
+ {"label": "Pause here", "description": "Changes saved, not committed"}
695
+ ]
696
+ }]</parameter>
697
+ </invoke>
698
+ ```
699
+
700
+ **After tests pass, suggest logic audit again if not yet run:**
701
+ ```xml
702
+ <invoke name="AskUserQuestion">
703
+ <parameter name="questions">[{
704
+ "question": "All 4373 tests pass. Ready to finalize?",
705
+ "header": "Next step",
706
+ "multiSelect": false,
707
+ "options": [
708
+ {"label": "🔍 Run logic audit on 3 modified files (Recommended)", "description": "5 analyzers catch edge cases tests miss - quick check before commit"},
709
+ {"label": "Commit: 'feat: add session tracking'", "description": "All tests pass, skip logic audit"},
710
+ {"label": "Continue to US-0044", "description": "EP-0018 is 85% done - 2 stories left"},
711
+ {"label": "Pause here", "description": "Tests pass, changes not committed"}
689
712
  ]
690
713
  }]</parameter>
691
714
  </invoke>
@@ -696,19 +719,25 @@ After completing an implementation, offer logic audit as an **optional quality c
696
719
  2. Run: `/agileflow:logic:audit <modified-files> DEPTH=quick`
697
720
  3. Review findings with user
698
721
  4. Offer to fix any P0/P1 issues immediately
699
- 5. Then present next steps again
722
+ 5. Then present next steps again with smart AskUserQuestion
700
723
 
701
724
  ---
702
725
 
703
726
  ### SMART ASKUSERQUESTION EXAMPLES
704
727
 
705
728
  After implementation:
706
- - "Run `npm test` in packages/cli/ (Recommended)" + "3 files changed, verify before commit"
707
- - "🔍 Run logic audit on modified files" + "5 analyzers check for edge cases"
729
+ - "Run `npm test` in packages/cli/ (Recommended)" + "3 files changed in scripts/ - verify before committing"
730
+ - "🔍 Run logic audit on 3 modified files" + "5 analyzers check edge cases, race conditions, type bugs"
731
+ - "Pause here" + "Changes saved, not committed"
708
732
 
709
- After tests pass:
710
- - "Commit: 'fix: resolve tmux socket path' (Recommended)" + "All tests pass"
711
- - "Review diff before committing" + "14 files touched"
733
+ After tests pass (logic audit NOT yet run):
734
+ - "🔍 Run logic audit on 3 modified files (Recommended)" + "Quick check catches what tests miss - edge cases, race conditions"
735
+ - "Commit: 'fix: resolve tmux socket path'" + "All 4373 tests pass, skip audit"
736
+ - "Continue to US-0044" + "EP-0018 is 85% done"
737
+
738
+ After tests pass (logic audit already done):
739
+ - "Commit: 'fix: resolve tmux socket path' (Recommended)" + "All tests pass, logic audit clean"
740
+ - "Review diff before committing" + "14 files touched across 3 directories"
712
741
 
713
742
  After error:
714
743
  - "Try alternative: use execFileSync instead (Recommended)" + "Current approach has shell injection risk"
@@ -726,14 +755,14 @@ After error:
726
755
  - Delegate complex work to experts
727
756
  - If stuck 2+ times → research prompt
728
757
  - Use state narration markers (📍🔀🔄⚠️✅) for visibility
758
+ - **LOGIC AUDIT - ALWAYS SUGGEST**: After ANY implementation (plan or direct), ALWAYS include "🔍 Run logic audit" as an option. After tests pass but before commit, make it (Recommended).
729
759
  - **PLAN FILE CONTEXT - CRITICAL:**
730
- BEFORE ExitPlanMode, EDIT the plan file to add babysit rules header at TOP
760
+ BEFORE ExitPlanMode, EDIT the plan file to add babysit rules header at TOP (with smart AskUserQuestion format and logic audit)
731
761
  This ensures rules survive "Clear context and bypass permissions"
732
762
  - **STORY CLAIMING - CRITICAL:**
733
763
  1. BEFORE suggesting: `node .agileflow/scripts/lib/story-claiming.js others` → exclude 🔒
734
764
  2. AFTER user selects: `node .agileflow/scripts/lib/story-claiming.js claim <id>`
735
765
  3. WHEN done: `node .agileflow/scripts/lib/story-claiming.js release <id>`
736
-
737
766
  ---
738
767
 
739
768
  ## 🛑 FINAL ACTION REQUIRED - DO NOT SKIP
@@ -1175,12 +1204,16 @@ When stuck detection triggers:
1175
1204
  ## ⚠️ MANDATORY IMPLEMENTATION RULES (from /babysit)
1176
1205
 
1177
1206
  These rules MUST be followed during implementation:
1178
- 1. ALWAYS end your final response with AskUserQuestion tool
1179
- 2. Use EnterPlanMode if new non-trivial tasks arise
1180
- 3. Delegate complex work to domain experts
1181
- 4. Track progress with TaskCreate/TaskUpdate
1182
-
1183
- After implementation, call AskUserQuestion with next step options.
1207
+ 1. **ALWAYS end with SMART AskUserQuestion** - specific options with (Recommended), contextual descriptions, file counts
1208
+ 2. **Use EnterPlanMode** if new non-trivial tasks arise
1209
+ 3. **Delegate complex work** to domain experts via Task tool
1210
+ 4. **Track progress** with TaskCreate/TaskUpdate for multi-step work
1211
+
1212
+ After implementation, ALWAYS call AskUserQuestion with:
1213
+ - "Run tests (Recommended)" with specific command and file count
1214
+ - "🔍 Run logic audit on N modified files" - ALWAYS include this
1215
+ - "Commit: '[type]: [summary]'" with suggested message
1216
+ - "Pause here" with save state summary
1184
1217
 
1185
1218
  ---
1186
1219
  ```
@@ -156,18 +156,18 @@ DETAILED=true # Show extended details (dependencies, ADRs, research)
156
156
 
157
157
  ## Confirmation & Integration
158
158
 
159
- After displaying blockers:
159
+ After displaying blockers (use actual counts and data from analysis):
160
160
  ```xml
161
161
  <invoke name="AskUserQuestion">
162
162
  <parameter name="questions">[{
163
- "question": "What would you like to do?",
164
- "header": "Blocker Actions",
163
+ "question": "[N] blockers found ([critical] critical, [stale] stale >14d). What next?",
164
+ "header": "Resolve",
165
165
  "multiSelect": false,
166
166
  "options": [
167
- {"label": "Update blocker status", "description": "Mark blocker as resolved"},
168
- {"label": "Create unblocking story", "description": "Create story to unblock"},
169
- {"label": "View ADR details", "description": "See related architecture decisions"},
170
- {"label": "Escalate blocker", "description": "Escalate for decision"}
167
+ {"label": "Resolve [top_blocker_id]: [reason] (Recommended)", "description": "[category] blocker, [age] days old - [resolution_hint]"},
168
+ {"label": "Create unblocking story for [blocker_id]", "description": "[blocker_summary] - needs [effort] to unblock [N] downstream stories"},
169
+ {"label": "View [N] related ADRs/research", "description": "Found [adr_count] ADRs and [research_count] research notes matching blockers"},
170
+ {"label": "Done - report only", "description": "[N] blockers documented, no action needed now"}
171
171
  ]
172
172
  }]</parameter>
173
173
  </invoke>
@@ -436,40 +436,25 @@ Then present options:
436
436
  ```
437
437
 
438
438
  Map selection to value:
439
- | Selection | defaultStartupMode value |
440
- |-----------|--------------------------|
439
+ | Selection | Mode value |
440
+ |-----------|------------|
441
441
  | Normal | `normal` |
442
442
  | Skip permissions | `skip-permissions` |
443
443
  | Accept edits only | `accept-edits` |
444
444
  | Don't start Claude | `no-claude` |
445
445
 
446
- Update the metadata file AND configure the CLI flags:
447
-
448
- 1. Update `docs/00-meta/agileflow-metadata.json`:
449
- - Find: `"defaultStartupMode": "..."`
450
- - Replace with: `"defaultStartupMode": "{selected_value}"`
451
-
452
- 2. **Also run** the configure script to set Claude Code's permission mode:
446
+ Run the configure script with `--startup-mode` to set BOTH metadata AND `.claude/settings.json` atomically:
453
447
  ```bash
454
- node .agileflow/scripts/agileflow-configure.js --enable=claudeflags --flags="{cli_flag}"
455
- ```
456
-
457
- Where `{cli_flag}` is:
458
- - `skip-permissions` → `--dangerously-skip-permissions` (sets `permissions.defaultMode = "bypassPermissions"`)
459
- - `accept-edits` → `--permission-mode acceptEdits` (sets `permissions.defaultMode = "acceptEdits"`)
460
- - `normal` → (disable claudeflags instead: `--disable=claudeflags`, removes `defaultMode`)
461
-
462
- Display confirmation:
448
+ node .agileflow/scripts/agileflow-configure.js --startup-mode={mode_value}
463
449
  ```
464
- ✅ Default session startup mode set to: {selected_value}
465
450
 
466
- What was configured:
467
- .claude/settings.json: permissions.defaultMode = "{defaultMode}"
468
- Metadata: defaultStartupMode = "{selected_value}"
469
- AgileFlow commands (af, /session:new) will also use this mode
451
+ This single command handles everything:
452
+ - Sets `permissions.defaultMode` in `.claude/settings.json` (for skip-permissions/accept-edits)
453
+ - Removes `permissions.defaultMode` from `.claude/settings.json` (for normal/no-claude)
454
+ - Updates `defaultStartupMode` in `docs/00-meta/agileflow-metadata.json`
455
+ - Updates the `claudeFlags` feature metadata
470
456
 
471
- ⚠️ Restart Claude Code for the new permission mode to take effect.
472
- ```
457
+ **IMPORTANT**: Do NOT manually edit metadata or settings.json for startup mode. Always use `--startup-mode=` to ensure both files stay in sync.
473
458
 
474
459
  **If user selected "Skip permissions" or "Accept edits only"**, offer shell alias:
475
460
 
@@ -636,23 +621,12 @@ Then re-ask the enable/disable question.
636
621
  </invoke>
637
622
  ```
638
623
 
639
- Spawn the appropriate configuration agent:
640
-
641
- ```javascript
642
- // Visual E2E
643
- Task({ subagent_type: "configuration-visual-e2e", description: "Configure Visual E2E", prompt: "..." })
624
+ Handle each selection directly:
644
625
 
645
- // Damage Control
646
- Task({ subagent_type: "configuration-damage-control", description: "Configure Damage Control", prompt: "..." })
647
-
648
- // CI/CD
649
- Task({ subagent_type: "configuration-ci", description: "Configure CI/CD", prompt: "..." })
650
-
651
- // Quality Gates - configure TeammateIdle and TaskCompleted hooks
652
- // Writes gate config to agileflow-metadata.json under quality_gates key
653
- // Options: enable/disable tests, lint, types gates per hook
654
- // Sets thresholds for coverage gates
655
- ```
626
+ - **Visual E2E**: `node .agileflow/scripts/agileflow-configure.js --enable=visuale2e`
627
+ - **Damage Control**: `node .agileflow/scripts/agileflow-configure.js --enable=damagecontrol`
628
+ - **CI/CD**: `node .agileflow/scripts/agileflow-configure.js --enable=ci`
629
+ - **Quality Gates**: Update `docs/00-meta/agileflow-metadata.json` under the `quality_gates` key with enable/disable for tests, lint, types gates per hook and coverage thresholds
656
630
 
657
631
  ---
658
632
 
@@ -984,26 +958,6 @@ The script updates `docs/00-meta/agileflow-metadata.json`:
984
958
  }
985
959
  ```
986
960
 
987
- ## Complex Features (Spawn Agents)
988
-
989
- For features needing extra user input, spawn specialized agents:
990
-
991
- ```javascript
992
- // CI/CD - needs provider and commands
993
- Task({
994
- subagent_type: "agileflow-configuration:ci",
995
- description: "Configure CI/CD",
996
- prompt: "Set up CI/CD workflow. Ask for provider (GitHub Actions, GitLab CI, CircleCI) and commands."
997
- })
998
-
999
- // Git config - needs remote URL
1000
- Task({
1001
- subagent_type: "agileflow-configuration:git-config",
1002
- description: "Configure git",
1003
- prompt: "Set up git remote. Ask for URL."
1004
- })
1005
- ```
1006
-
1007
961
  ## Rules
1008
962
 
1009
963
  1. **Always show detection first** - User sees current state before changes