agileflow 3.4.0 → 3.4.1

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 (112) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +4 -4
  3. package/package.json +1 -1
  4. package/scripts/agileflow-welcome.js +79 -0
  5. package/scripts/claude-tmux.sh +12 -36
  6. package/scripts/lib/ac-test-matcher.js +452 -0
  7. package/scripts/lib/audit-registry.js +58 -2
  8. package/scripts/lib/configure-features.js +35 -0
  9. package/scripts/lib/model-profiles.js +25 -5
  10. package/scripts/lib/quality-gates.js +163 -0
  11. package/scripts/lib/signal-detectors.js +43 -0
  12. package/scripts/lib/status-writer.js +255 -0
  13. package/scripts/lib/story-claiming.js +128 -45
  14. package/scripts/lib/task-sync.js +32 -38
  15. package/scripts/lib/tmux-audit-monitor.js +611 -0
  16. package/scripts/lib/tool-registry.yaml +241 -0
  17. package/scripts/lib/tool-shed.js +441 -0
  18. package/scripts/native-team-observer.js +219 -0
  19. package/scripts/obtain-context.js +14 -0
  20. package/scripts/ralph-loop.js +30 -5
  21. package/scripts/smart-detect.js +21 -0
  22. package/scripts/spawn-audit-sessions.js +372 -44
  23. package/scripts/team-manager.js +19 -0
  24. package/src/core/agents/a11y-analyzer-aria.md +155 -0
  25. package/src/core/agents/a11y-analyzer-forms.md +162 -0
  26. package/src/core/agents/a11y-analyzer-keyboard.md +175 -0
  27. package/src/core/agents/a11y-analyzer-semantic.md +153 -0
  28. package/src/core/agents/a11y-analyzer-visual.md +158 -0
  29. package/src/core/agents/a11y-consensus.md +248 -0
  30. package/src/core/agents/ads-consensus.md +74 -0
  31. package/src/core/agents/ads-generate.md +145 -0
  32. package/src/core/agents/ads-performance-tracker.md +197 -0
  33. package/src/core/agents/api-quality-analyzer-conventions.md +148 -0
  34. package/src/core/agents/api-quality-analyzer-docs.md +176 -0
  35. package/src/core/agents/api-quality-analyzer-errors.md +183 -0
  36. package/src/core/agents/api-quality-analyzer-pagination.md +171 -0
  37. package/src/core/agents/api-quality-analyzer-versioning.md +143 -0
  38. package/src/core/agents/api-quality-consensus.md +214 -0
  39. package/src/core/agents/arch-analyzer-circular.md +148 -0
  40. package/src/core/agents/arch-analyzer-complexity.md +171 -0
  41. package/src/core/agents/arch-analyzer-coupling.md +146 -0
  42. package/src/core/agents/arch-analyzer-layering.md +151 -0
  43. package/src/core/agents/arch-analyzer-patterns.md +162 -0
  44. package/src/core/agents/arch-consensus.md +227 -0
  45. package/src/core/commands/adr.md +1 -0
  46. package/src/core/commands/ads/generate.md +238 -0
  47. package/src/core/commands/ads/health.md +327 -0
  48. package/src/core/commands/ads/test-plan.md +317 -0
  49. package/src/core/commands/ads/track.md +288 -0
  50. package/src/core/commands/ads.md +28 -16
  51. package/src/core/commands/assign.md +1 -0
  52. package/src/core/commands/audit.md +43 -6
  53. package/src/core/commands/babysit.md +90 -6
  54. package/src/core/commands/baseline.md +1 -0
  55. package/src/core/commands/blockers.md +1 -0
  56. package/src/core/commands/board.md +1 -0
  57. package/src/core/commands/changelog.md +1 -0
  58. package/src/core/commands/choose.md +1 -0
  59. package/src/core/commands/ci.md +1 -0
  60. package/src/core/commands/code/accessibility.md +347 -0
  61. package/src/core/commands/code/api.md +297 -0
  62. package/src/core/commands/code/architecture.md +297 -0
  63. package/src/core/commands/code/completeness.md +43 -6
  64. package/src/core/commands/code/legal.md +43 -6
  65. package/src/core/commands/code/logic.md +43 -6
  66. package/src/core/commands/code/performance.md +43 -6
  67. package/src/core/commands/code/security.md +43 -6
  68. package/src/core/commands/code/test.md +43 -6
  69. package/src/core/commands/configure.md +1 -0
  70. package/src/core/commands/council.md +1 -0
  71. package/src/core/commands/deploy.md +1 -0
  72. package/src/core/commands/diagnose.md +1 -0
  73. package/src/core/commands/docs.md +1 -0
  74. package/src/core/commands/epic/edit.md +213 -0
  75. package/src/core/commands/epic.md +1 -0
  76. package/src/core/commands/export.md +238 -0
  77. package/src/core/commands/help.md +16 -1
  78. package/src/core/commands/ideate/discover.md +7 -3
  79. package/src/core/commands/ideate/features.md +65 -4
  80. package/src/core/commands/ideate/new.md +158 -124
  81. package/src/core/commands/impact.md +1 -0
  82. package/src/core/commands/learn/explain.md +118 -0
  83. package/src/core/commands/learn/glossary.md +135 -0
  84. package/src/core/commands/learn/patterns.md +138 -0
  85. package/src/core/commands/learn/tour.md +126 -0
  86. package/src/core/commands/migrate/codemods.md +151 -0
  87. package/src/core/commands/migrate/plan.md +131 -0
  88. package/src/core/commands/migrate/scan.md +114 -0
  89. package/src/core/commands/migrate/validate.md +119 -0
  90. package/src/core/commands/multi-expert.md +1 -0
  91. package/src/core/commands/pr.md +1 -0
  92. package/src/core/commands/review.md +1 -0
  93. package/src/core/commands/sprint.md +1 -0
  94. package/src/core/commands/status/undo.md +191 -0
  95. package/src/core/commands/status.md +1 -0
  96. package/src/core/commands/story/edit.md +204 -0
  97. package/src/core/commands/story/view.md +29 -7
  98. package/src/core/commands/story-validate.md +1 -0
  99. package/src/core/commands/story.md +1 -0
  100. package/src/core/commands/tdd.md +1 -0
  101. package/src/core/commands/team/start.md +10 -6
  102. package/src/core/commands/tests.md +1 -0
  103. package/src/core/commands/verify.md +27 -1
  104. package/src/core/commands/workflow.md +2 -0
  105. package/src/core/teams/backend.json +41 -0
  106. package/src/core/teams/frontend.json +41 -0
  107. package/src/core/teams/qa.json +41 -0
  108. package/src/core/teams/solo.json +35 -0
  109. package/src/core/templates/agileflow-metadata.json +5 -0
  110. package/tools/cli/commands/setup.js +85 -3
  111. package/tools/cli/commands/update.js +42 -0
  112. package/tools/cli/installers/ide/claude-code.js +68 -0
@@ -0,0 +1,131 @@
1
+ ---
2
+ description: Generate step-by-step migration roadmap with risk assessment, rollback strategy, and execution order from scan results
3
+ argument-hint: "[scan-report|package-name] [SCOPE=full|incremental]"
4
+ ---
5
+
6
+ # /agileflow:migrate:plan
7
+
8
+ Generate a detailed migration plan with step-by-step execution order, risk assessment, rollback strategies, and dependency mapping from scan results or specific upgrade targets.
9
+
10
+ ---
11
+
12
+ ## Quick Reference
13
+
14
+ ```
15
+ /agileflow:migrate:plan # Plan from latest scan report
16
+ /agileflow:migrate:plan react # Plan React upgrade specifically
17
+ /agileflow:migrate:plan next@15 # Plan Next.js 15 migration
18
+ /agileflow:migrate:plan . SCOPE=incremental # Incremental migration (phase by phase)
19
+ /agileflow:migrate:plan typescript@5.5 # Plan TypeScript upgrade
20
+ ```
21
+
22
+ ---
23
+
24
+ ## How It Works
25
+
26
+ 1. **Read scan results** or analyze specific upgrade target
27
+ 2. **Map dependencies** between migration steps
28
+ 3. **Assess risk** for each step (data loss, downtime, breaking changes)
29
+ 4. **Design rollback** strategy for each step
30
+ 5. **Order execution** by dependency and risk (safest first)
31
+ 6. **Estimate effort** per step
32
+
33
+ ---
34
+
35
+ ## Step-by-Step Process
36
+
37
+ ### STEP 1: Parse Arguments
38
+
39
+ ```
40
+ TARGET = scan report path, package name, or package@version
41
+ SCOPE = full (all at once) or incremental (phased)
42
+ ```
43
+
44
+ ### STEP 2: Research Migration Path
45
+
46
+ Delegate to `agileflow-research` agent:
47
+ - Read official migration guides for the target upgrade
48
+ - Find known issues and workarounds
49
+ - Check community experience (GitHub issues, blog posts)
50
+ - Identify breaking changes between current and target versions
51
+
52
+ ### STEP 3: Map Dependencies
53
+
54
+ Build a dependency graph of migration steps:
55
+ - Which steps must happen before others
56
+ - Which steps can run in parallel
57
+ - Which steps affect shared code
58
+
59
+ ### STEP 4: Assess Risk
60
+
61
+ For each migration step:
62
+
63
+ | Risk Level | Criteria |
64
+ |------------|----------|
65
+ | **High** | Data migration, schema changes, auth changes |
66
+ | **Medium** | API changes, dependency swaps, config changes |
67
+ | **Low** | Syntax updates, import changes, type updates |
68
+
69
+ ### STEP 5: Generate Migration Plan
70
+
71
+ ```markdown
72
+ # Migration Plan: {Target}
73
+
74
+ **Generated**: {date}
75
+ **Current State**: {current versions/patterns}
76
+ **Target State**: {target versions/patterns}
77
+ **Estimated Effort**: {total estimate}
78
+ **Risk Level**: {overall risk}
79
+
80
+ ## Pre-Migration Checklist
81
+ - [ ] Full test suite passing
82
+ - [ ] Database backup created
83
+ - [ ] Feature flags for gradual rollout
84
+ - [ ] Rollback procedure documented
85
+
86
+ ## Phase 1: {Name} (Risk: Low)
87
+ ### Step 1.1: {Action}
88
+ - **What**: {specific change}
89
+ - **Files affected**: {list}
90
+ - **Risk**: {description}
91
+ - **Rollback**: {how to undo}
92
+ - **Verification**: {how to confirm success}
93
+
94
+ ### Step 1.2: {Action}
95
+ ...
96
+
97
+ ## Phase 2: {Name} (Risk: Medium)
98
+ ...
99
+
100
+ ## Phase 3: {Name} (Risk: High)
101
+ ...
102
+
103
+ ## Post-Migration Verification
104
+ - [ ] All tests passing
105
+ - [ ] No deprecated API warnings
106
+ - [ ] Performance benchmarks stable
107
+ - [ ] Monitoring shows no regressions
108
+ ```
109
+
110
+ Save to `docs/08-project/migrations/plan-{target}-{YYYYMMDD}.md`
111
+
112
+ ### STEP 6: Offer Next Steps
113
+
114
+ ```
115
+ Migration plan generated: [N] phases, [M] steps. Estimated effort: [estimate].
116
+
117
+ Options:
118
+ - Generate codemods for Phase 1 (Recommended)
119
+ - Create stories from migration steps
120
+ - Review plan in detail
121
+ - Save plan and done
122
+ ```
123
+
124
+ ---
125
+
126
+ ## Related Commands
127
+
128
+ - `/agileflow:migrate:scan` - Detect migration opportunities
129
+ - `/agileflow:migrate:codemods` - Generate AST-based codemods
130
+ - `/agileflow:migrate:validate` - Post-migration verification
131
+ - `/agileflow:research:ask` - Deep research on specific migration topics
@@ -0,0 +1,114 @@
1
+ ---
2
+ description: Detect deprecated APIs, outdated patterns, breaking dependency changes, and migration opportunities in your codebase
3
+ argument-hint: "[file|directory] [FOCUS=deps|patterns|apis|all]"
4
+ ---
5
+
6
+ # /agileflow:migrate:scan
7
+
8
+ Scan the codebase for migration opportunities - deprecated APIs, outdated patterns, breaking dependency changes, and version-specific issues that need attention.
9
+
10
+ ---
11
+
12
+ ## Quick Reference
13
+
14
+ ```
15
+ /agileflow:migrate:scan # Scan entire project
16
+ /agileflow:migrate:scan src/ # Scan specific directory
17
+ /agileflow:migrate:scan . FOCUS=deps # Focus on dependency changes only
18
+ /agileflow:migrate:scan . FOCUS=patterns # Focus on outdated code patterns
19
+ /agileflow:migrate:scan . FOCUS=apis # Focus on deprecated API usage
20
+ ```
21
+
22
+ ---
23
+
24
+ ## How It Works
25
+
26
+ 1. **Dependency analysis**: Check package.json for outdated deps, breaking version jumps, deprecated packages
27
+ 2. **Pattern detection**: Find outdated coding patterns (old React class components, CommonJS in ESM projects, etc.)
28
+ 3. **API deprecation**: Find usage of deprecated APIs (Node.js, browser, framework-specific)
29
+ 4. **Version incompatibility**: Detect code that won't work with newer versions of dependencies
30
+ 5. **Migration urgency**: Score each finding by urgency (security fix, breaking change, deprecation timeline)
31
+
32
+ ---
33
+
34
+ ## Step-by-Step Process
35
+
36
+ ### STEP 1: Parse Arguments
37
+
38
+ ```
39
+ TARGET = first argument or current directory
40
+ FOCUS = all (default) or deps|patterns|apis
41
+ ```
42
+
43
+ ### STEP 2: Analyze Dependencies
44
+
45
+ Use the `agileflow-devops` agent to:
46
+ - Run `npm outdated` or equivalent
47
+ - Check for deprecated packages (`npm info <pkg> deprecated`)
48
+ - Identify major version jumps with breaking changes
49
+ - Check for known vulnerabilities (`npm audit`)
50
+
51
+ ### STEP 3: Scan for Outdated Patterns
52
+
53
+ Use the `agileflow-refactor` agent to find:
54
+ - Deprecated framework patterns (React class components, Vue Options API in Vue 3+, etc.)
55
+ - Old module systems (CommonJS `require()` in ESM projects)
56
+ - Deprecated Node.js APIs (`fs.exists`, `url.parse`, `new Buffer()`)
57
+ - Old test patterns (enzyme vs testing-library)
58
+ - Legacy build tool configurations
59
+
60
+ ### STEP 4: Detect Deprecated API Usage
61
+
62
+ Use the `agileflow-research` agent to:
63
+ - Check framework changelogs for deprecated features
64
+ - Find deprecated browser APIs (e.g., `document.write`, synchronous XHR)
65
+ - Identify Node.js deprecated APIs by version
66
+
67
+ ### STEP 5: Generate Scan Report
68
+
69
+ Output a prioritized list of migration opportunities:
70
+
71
+ ```markdown
72
+ # Migration Scan Report
73
+
74
+ **Generated**: {date}
75
+ **Target**: {directory}
76
+ **Total Opportunities**: {N}
77
+
78
+ ## Critical (Security/Breaking)
79
+ | Package/Pattern | Current | Target | Risk | Effort |
80
+ |-----------------|---------|--------|------|--------|
81
+ | {name} | {version} | {version} | {desc} | {est} |
82
+
83
+ ## High Priority (Deprecation Deadline)
84
+ ...
85
+
86
+ ## Medium Priority (Tech Debt)
87
+ ...
88
+
89
+ ## Low Priority (Improvements)
90
+ ...
91
+ ```
92
+
93
+ Save to `docs/08-project/migrations/scan-{YYYYMMDD}.md`
94
+
95
+ ### STEP 6: Offer Next Steps
96
+
97
+ ```
98
+ Scan complete: [N] migration opportunities found ([critical] critical, [high] high priority).
99
+
100
+ Options:
101
+ - Generate migration plan for critical items (Recommended)
102
+ - Create stories for all findings
103
+ - Re-scan with different focus
104
+ - Save report and done
105
+ ```
106
+
107
+ ---
108
+
109
+ ## Related Commands
110
+
111
+ - `/agileflow:migrate:plan` - Generate step-by-step migration roadmap
112
+ - `/agileflow:migrate:codemods` - Generate AST-based codemods
113
+ - `/agileflow:migrate:validate` - Post-migration verification
114
+ - `/agileflow:packages` - Dependency management
@@ -0,0 +1,119 @@
1
+ ---
2
+ description: Post-migration verification - run tests, check for deprecated usage, validate types, and confirm migration completeness
3
+ argument-hint: "[migration-plan|package-name] [--strict]"
4
+ ---
5
+
6
+ # /agileflow:migrate:validate
7
+
8
+ Run comprehensive post-migration verification to confirm the migration was successful - tests pass, no deprecated APIs remain, types check, and no regressions introduced.
9
+
10
+ ---
11
+
12
+ ## Quick Reference
13
+
14
+ ```
15
+ /agileflow:migrate:validate # Validate latest migration
16
+ /agileflow:migrate:validate react # Validate React migration
17
+ /agileflow:migrate:validate next@15 # Validate Next.js 15 migration
18
+ /agileflow:migrate:validate . --strict # Strict mode - zero warnings
19
+ ```
20
+
21
+ ---
22
+
23
+ ## How It Works
24
+
25
+ 1. **Run test suite** - Full test run to catch regressions
26
+ 2. **Re-scan for deprecated usage** - Verify no deprecated APIs remain
27
+ 3. **Type check** - Run TypeScript/type checker for type errors
28
+ 4. **Lint check** - Run linter for new issues
29
+ 5. **Build check** - Verify production build succeeds
30
+ 6. **Generate validation report** - Pass/fail with details
31
+
32
+ ---
33
+
34
+ ## Step-by-Step Process
35
+
36
+ ### STEP 1: Parse Arguments
37
+
38
+ ```
39
+ TARGET = migration plan path, package name, or current directory
40
+ STRICT = --strict flag (zero warnings tolerance)
41
+ ```
42
+
43
+ ### STEP 2: Run Validation Checks
44
+
45
+ Execute all checks and collect results:
46
+
47
+ | Check | Command | Pass Criteria |
48
+ |-------|---------|--------------|
49
+ | Tests | `npm test` | All passing |
50
+ | Type check | `npx tsc --noEmit` | No errors |
51
+ | Lint | `npm run lint` | No errors (warnings OK unless strict) |
52
+ | Build | `npm run build` | Exits 0 |
53
+ | Deprecated scan | Re-run `/agileflow:migrate:scan` | No critical findings |
54
+
55
+ ### STEP 3: Compare Before/After
56
+
57
+ If a migration plan exists, compare:
58
+ - Test count: same or more (not fewer)
59
+ - Build size: within 10% (flag large increases)
60
+ - Type errors: zero new errors
61
+ - Deprecated usage: reduced to zero for migrated items
62
+
63
+ ### STEP 4: Generate Validation Report
64
+
65
+ ```markdown
66
+ # Migration Validation Report
67
+
68
+ **Generated**: {date}
69
+ **Migration**: {target}
70
+ **Status**: {PASS | PARTIAL | FAIL}
71
+
72
+ ## Check Results
73
+
74
+ | Check | Status | Details |
75
+ |-------|--------|---------|
76
+ | Tests | {pass/fail} | {N} passing, {M} failing |
77
+ | Types | {pass/fail} | {N} errors |
78
+ | Lint | {pass/fail} | {N} errors, {M} warnings |
79
+ | Build | {pass/fail} | Build size: {N} |
80
+ | Deprecated scan | {pass/fail} | {N} remaining items |
81
+
82
+ ## Failures (if any)
83
+
84
+ ### Test Failures
85
+ {list of failing tests with details}
86
+
87
+ ### Type Errors
88
+ {list of new type errors}
89
+
90
+ ### Remaining Deprecated Usage
91
+ {list of deprecated items still in codebase}
92
+
93
+ ## Verdict
94
+
95
+ {Overall assessment and recommended next steps}
96
+ ```
97
+
98
+ Save to `docs/08-project/migrations/validation-{YYYYMMDD}.md`
99
+
100
+ ### STEP 5: Offer Next Steps
101
+
102
+ ```
103
+ Migration validation: [STATUS]. [N]/[M] checks passed.
104
+
105
+ Options:
106
+ - Fix failing tests (Recommended)
107
+ - Fix remaining deprecated usage
108
+ - Accept partial migration and create stories for remaining work
109
+ - Mark migration as complete
110
+ ```
111
+
112
+ ---
113
+
114
+ ## Related Commands
115
+
116
+ - `/agileflow:migrate:scan` - Detect migration opportunities
117
+ - `/agileflow:migrate:plan` - Generate migration roadmap
118
+ - `/agileflow:migrate:codemods` - Generate AST-based codemods
119
+ - `/agileflow:verify` - Run project tests
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  description: Deploy multiple domain experts on the same problem for higher confidence
3
+ phase: planning
3
4
  argument-hint: "<question>"
4
5
  compact_context:
5
6
  priority: high
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  description: Generate pull request description from story
3
+ phase: pre-pr
3
4
  argument-hint: "STORY=<US-ID> [TITLE=<text>] [TEST_EVIDENCE=<text>]"
4
5
  compact_context:
5
6
  priority: high
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  description: AI-powered code review with quality suggestions
3
+ phase: post-impl
3
4
  argument-hint: "[BRANCH=<name>] [BASE=<branch>] [FOCUS=all|security|performance|style]"
4
5
  compact_context:
5
6
  priority: critical
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  description: Data-driven sprint planning with velocity forecasting
3
+ phase: pre-story
3
4
  argument-hint: "[SPRINT=<id>] [DURATION=<number>] [AGENTS=<list>] [MODE=suggest|commit] [FOCUS_EPIC=<EP-ID>]"
4
5
  model: haiku
5
6
  compact_context:
@@ -0,0 +1,191 @@
1
+ ---
2
+ description: Undo the last status change for a story (rollback)
3
+ argument-hint: "STORY=<US-ID>"
4
+ compact_context:
5
+ priority: high
6
+ preserve_rules:
7
+ - "ACTIVE COMMAND: /agileflow:status:undo - Rollback story status to previous value"
8
+ - "{{RULES:json_operations}}"
9
+ - "{{RULES:user_confirmation}}"
10
+ - "{{RULES:file_preview}}"
11
+ - "MUST read bus/log.jsonl to find the last status change"
12
+ - "MUST show current vs previous status as diff"
13
+ - "MUST confirm with AskUserQuestion before applying"
14
+ - "MUST log revert event to bus/log.jsonl with type=status-reverted"
15
+ state_fields:
16
+ - story_id
17
+ - current_status
18
+ - previous_status
19
+ ---
20
+
21
+ # /agileflow:status:undo
22
+
23
+ Undo the last status change for a story by reading the bus event log to find the previous status.
24
+
25
+ ---
26
+
27
+ ## STEP 0: Gather Context
28
+
29
+ ```bash
30
+ node .agileflow/scripts/obtain-context.js status:undo
31
+ ```
32
+
33
+ ---
34
+
35
+ <!-- COMPACT_SUMMARY_START -->
36
+ ## Compact Summary
37
+
38
+ **Command**: `/agileflow:status:undo STORY=<US-ID>`
39
+ **Purpose**: Rollback a story's status to its previous value using bus log history
40
+
41
+ ### Flow
42
+ 1. Parse STORY parameter (required)
43
+ 2. Read bus/log.jsonl to find status change history for the story
44
+ 3. Read current status from status.json
45
+ 4. Show diff: current status vs previous status
46
+ 5. Confirm via AskUserQuestion
47
+ 6. Apply rollback to status.json
48
+ 7. Log status-reverted event to bus/log.jsonl
49
+
50
+ ### Critical Rules
51
+ - **Bus log sourced**: Previous status comes from bus/log.jsonl history
52
+ - **Diff preview**: Show current vs previous before applying
53
+ - **Confirmation**: Never write without user approval
54
+ - **Bus logging**: Append status-reverted event after rollback
55
+ - **No history = no undo**: If no previous status event found, inform user
56
+ <!-- COMPACT_SUMMARY_END -->
57
+
58
+ ---
59
+
60
+ ## Arguments
61
+
62
+ | Argument | Required | Description |
63
+ |----------|----------|-------------|
64
+ | STORY | Yes | Story ID to revert (e.g., US-0042) |
65
+
66
+ ---
67
+
68
+ ## IMMEDIATE ACTIONS
69
+
70
+ ### Step 1: Validate Input
71
+
72
+ If STORY not provided, list recently changed stories from bus log.
73
+
74
+ ### Step 2: Find Previous Status
75
+
76
+ Read `docs/09-agents/bus/log.jsonl` and find status change events for the given story. Look for events with:
77
+ - `type: "status"` and matching `story` field
78
+ - `type: "assign"` (initial creation = "ready")
79
+ - `type: "status-reverted"` (previous undos)
80
+
81
+ Parse the log in reverse chronological order to find:
82
+ 1. **Current status event** (most recent)
83
+ 2. **Previous status event** (the one before that)
84
+
85
+ If only one status event exists (the initial creation), inform the user:
86
+ ```
87
+ No previous status found for US-0042.
88
+ Current status "ready" is the original status from story creation.
89
+ Nothing to undo.
90
+ ```
91
+
92
+ ### Step 3: Read Current State
93
+
94
+ Read story from `docs/09-agents/status.json` to confirm the current status matches what the bus log says.
95
+
96
+ ### Step 4: Show Diff Preview
97
+
98
+ ```markdown
99
+ ## Status Undo: US-0042
100
+
101
+ | | Status |
102
+ |---|--------|
103
+ | Current | in_progress |
104
+ | Revert to | ready |
105
+
106
+ Based on bus event from 2026-03-01T14:30:00Z:
107
+ "Story US-0042 status changed to in_progress"
108
+ ```
109
+
110
+ ### Step 5: Confirm Rollback
111
+
112
+ ```xml
113
+ <invoke name="AskUserQuestion">
114
+ <parameter name="questions">[{
115
+ "question": "Revert US-0042 from 'in_progress' back to 'ready'?",
116
+ "header": "Confirm undo",
117
+ "multiSelect": false,
118
+ "options": [
119
+ {"label": "Yes, revert status (Recommended)", "description": "Change status from in_progress back to ready"},
120
+ {"label": "No, cancel", "description": "Keep current status"}
121
+ ]
122
+ }]</parameter>
123
+ </invoke>
124
+ ```
125
+
126
+ ### Step 6: Apply Rollback
127
+
128
+ On confirmation:
129
+
130
+ 1. **Update status.json** using Edit tool:
131
+ - Set story status to the previous value
132
+ - Update the `updated` timestamp
133
+
134
+ 2. **Validate JSON**:
135
+ ```bash
136
+ node -e "JSON.parse(require('fs').readFileSync('docs/09-agents/status.json','utf8')); console.log('valid')"
137
+ ```
138
+
139
+ 3. **Append to bus/log.jsonl**:
140
+ ```json
141
+ {"ts":"<ISO>","type":"status-reverted","from":"USER","story":"<STORY>","from_status":"<current>","to_status":"<previous>","text":"Status reverted from <current> to <previous>"}
142
+ ```
143
+
144
+ ### Step 7: Confirm Success
145
+
146
+ ```
147
+ US-0042 status reverted: in_progress -> ready
148
+ ```
149
+
150
+ ---
151
+
152
+ ## Edge Cases
153
+
154
+ | Scenario | Behavior |
155
+ |----------|----------|
156
+ | No status events in bus log | Check status.json only, inform "no history available" |
157
+ | Story not found | Error: "Story {ID} not found in status.json" |
158
+ | Current status doesn't match bus log | Warn user, show both, ask which to revert to |
159
+ | Multiple rapid changes | Revert to the immediately previous status only |
160
+
161
+ ---
162
+
163
+ ## Example Usage
164
+
165
+ ```bash
166
+ # Undo last status change
167
+ /agileflow:status:undo STORY=US-0042
168
+
169
+ # Typical flow: accidentally marked done, want to go back
170
+ # Before: done -> After: in_progress
171
+ ```
172
+
173
+ ---
174
+
175
+ ## Rules
176
+
177
+ - **Always preview**: Show current vs previous status before applying
178
+ - **Always confirm**: Use AskUserQuestion before writes
179
+ - **Always log**: Append status-reverted event to bus/log.jsonl
180
+ - **Always validate**: Check JSON integrity after write
181
+ - **One level**: Only undo one status change at a time (run again for more)
182
+ - **Bus log is source of truth**: Previous status comes from event history
183
+
184
+ ---
185
+
186
+ ## Related Commands
187
+
188
+ - `/agileflow:status` - Update story status
189
+ - `/agileflow:story:view` - View story details
190
+ - `/agileflow:story:edit` - Edit story fields
191
+ - `/agileflow:board` - View kanban board
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  description: Update story status and progress
3
+ phase: pre-story
3
4
  argument-hint: "STORY=<US-ID> STATUS=<status> [SUMMARY=<text>] [PR=<url>] [TO=<agent-id>]"
4
5
  compact_context:
5
6
  priority: high