@torka/claude-workflows 0.2.0 → 0.3.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.
- package/bmad-workflows/bmm/workflows/4-implementation/implement-epic-with-subagents/completion-summary-implement-epic-with-subagents.md +103 -0
- package/bmad-workflows/bmm/workflows/4-implementation/implement-epic-with-subagents/steps/step-01-init.md +250 -0
- package/bmad-workflows/bmm/workflows/4-implementation/implement-epic-with-subagents/steps/step-01b-continue.md +305 -0
- package/bmad-workflows/bmm/workflows/4-implementation/implement-epic-with-subagents/steps/step-01c-new.md +434 -0
- package/bmad-workflows/bmm/workflows/4-implementation/implement-epic-with-subagents/steps/step-02-orchestrate.md +440 -0
- package/bmad-workflows/bmm/workflows/4-implementation/implement-epic-with-subagents/steps/step-03-complete.md +476 -0
- package/bmad-workflows/bmm/workflows/4-implementation/implement-epic-with-subagents/templates/epic-completion-report.md +62 -0
- package/bmad-workflows/bmm/workflows/4-implementation/implement-epic-with-subagents/validation/checklist.md +121 -0
- package/bmad-workflows/bmm/workflows/4-implementation/implement-epic-with-subagents/workflow-plan-implement-epic-with-subagents.md +758 -0
- package/bmad-workflows/bmm/workflows/4-implementation/implement-epic-with-subagents/workflow.md +101 -0
- package/bmad-workflows/bmm/workflows/4-implementation/implement-epic-with-subagents/workflow.yaml +87 -0
- package/install.js +12 -5
- package/package.json +2 -1
- package/uninstall.js +57 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
workflowName: implement-epic-with-subagents
|
|
3
|
+
creationDate: 2026-01-04
|
|
4
|
+
module: bmm
|
|
5
|
+
phase: 4-implementation
|
|
6
|
+
status: COMPLETE
|
|
7
|
+
stepsCompleted: [1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
8
|
+
reviewPassed: true
|
|
9
|
+
reviewDate: 2026-01-04
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Workflow Creation Summary
|
|
13
|
+
|
|
14
|
+
## Workflow Information
|
|
15
|
+
|
|
16
|
+
- **Name:** implement-epic-with-subagents
|
|
17
|
+
- **Module:** bmm (BMAD Method Module)
|
|
18
|
+
- **Phase:** 4-implementation
|
|
19
|
+
- **Created:** 2026-01-04
|
|
20
|
+
- **Location:** `_bmad-output/bmb-creations/workflows/implement-epic-with-subagents/`
|
|
21
|
+
- **Target Installation:** `_bmad/bmm/workflows/4-implementation/implement-epic-with-subagents/`
|
|
22
|
+
|
|
23
|
+
## Purpose
|
|
24
|
+
|
|
25
|
+
Automate entire epic execution by orchestrating sub-agents to execute all stories sequentially, with minimal human intervention.
|
|
26
|
+
|
|
27
|
+
## Generated Files
|
|
28
|
+
|
|
29
|
+
### Workflow Configuration
|
|
30
|
+
- `workflow.yaml` - Main workflow configuration
|
|
31
|
+
|
|
32
|
+
### Step Files
|
|
33
|
+
- `steps/step-01-init.md` - Epic initialization and prerequisite validation
|
|
34
|
+
- `steps/step-01b-continue.md` - Session resumption and state recovery
|
|
35
|
+
- `steps/step-02-orchestrate.md` - Main orchestration loop (story execution)
|
|
36
|
+
- `steps/step-03-complete.md` - Completion and report generation
|
|
37
|
+
|
|
38
|
+
### Templates
|
|
39
|
+
- `templates/epic-completion-report.md` - Epic completion report template
|
|
40
|
+
|
|
41
|
+
### Validation
|
|
42
|
+
- `validation/checklist.md` - Pre-execution validation checklist
|
|
43
|
+
|
|
44
|
+
## Quick Start Guide
|
|
45
|
+
|
|
46
|
+
### 1. Install the Workflow
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
cp -r _bmad-output/bmb-creations/workflows/implement-epic-with-subagents _bmad/bmm/workflows/4-implementation/
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 2. Create Required Agents
|
|
53
|
+
|
|
54
|
+
Before running, ensure these agents exist:
|
|
55
|
+
- `.claude/agents/story-prep-master.md`
|
|
56
|
+
- `.claude/agents/quality-gate-verifier.md`
|
|
57
|
+
- `.claude/agents/principal-code-reviewer.md`
|
|
58
|
+
|
|
59
|
+
### 3. Optional: Create Specialist Dev Agents
|
|
60
|
+
|
|
61
|
+
Populate `.claude/agents/vt-bmad-dev-agents/` with specialist agents for automatic agent selection based on story requirements.
|
|
62
|
+
|
|
63
|
+
### 4. Run the Workflow
|
|
64
|
+
|
|
65
|
+
The workflow will:
|
|
66
|
+
1. Load and parse the epic file
|
|
67
|
+
2. For each story: create → develop → quality gate → code review → git commit
|
|
68
|
+
3. Update sprint-status.yaml throughout
|
|
69
|
+
4. Generate completion report
|
|
70
|
+
|
|
71
|
+
## Key Features
|
|
72
|
+
|
|
73
|
+
- **Autonomous Execution:** Runs with minimal human intervention
|
|
74
|
+
- **Smart Agent Selection:** Automatically picks specialist dev agents based on story content
|
|
75
|
+
- **Quality Gate:** Independent verification via quality-gate-verifier agent
|
|
76
|
+
- **Resume Capability:** Sidecar file enables session recovery
|
|
77
|
+
- **Auto-Commit:** Git commits after each story completion
|
|
78
|
+
|
|
79
|
+
## Failure Handling
|
|
80
|
+
|
|
81
|
+
| Failure Type | Action |
|
|
82
|
+
|--------------|--------|
|
|
83
|
+
| Simple (lint, types) | Auto-retry up to 3 attempts |
|
|
84
|
+
| Moderate (test failures) | Agent attempts fix, escalate after 2 failures |
|
|
85
|
+
| Complex (architectural) | Stop immediately, escalate with context |
|
|
86
|
+
|
|
87
|
+
## Next Steps
|
|
88
|
+
|
|
89
|
+
1. **Install to bmm module** - Copy to final location
|
|
90
|
+
2. **Create quality-gate-verifier agent** - Required for quality gate phase
|
|
91
|
+
3. **Optionally create specialist agents** - For automatic agent matching
|
|
92
|
+
4. **Test with small epic** - Validate workflow before full use
|
|
93
|
+
5. **Configure Context-7 MCP** - Required for documentation access
|
|
94
|
+
|
|
95
|
+
## Dependencies
|
|
96
|
+
|
|
97
|
+
| Dependency | Status | Notes |
|
|
98
|
+
|------------|--------|-------|
|
|
99
|
+
| Context-7 MCP | Required | Must be configured |
|
|
100
|
+
| Playwright MCP | Optional | Use if available |
|
|
101
|
+
| story-prep-master | Required | Create if not exists |
|
|
102
|
+
| quality-gate-verifier | Required | Create if not exists |
|
|
103
|
+
| principal-code-reviewer | Required | Create if not exists |
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: 'step-01-init'
|
|
3
|
+
description: 'Entry router - detect context and route to appropriate initialization path'
|
|
4
|
+
|
|
5
|
+
# Path Definitions
|
|
6
|
+
workflow_path: '{project-root}/_bmad/bmm/workflows/4-implementation/implement-epic-with-subagents'
|
|
7
|
+
|
|
8
|
+
# File References
|
|
9
|
+
thisStepFile: '{workflow_path}/steps/step-01-init.md'
|
|
10
|
+
continueFile: '{workflow_path}/steps/step-01b-continue.md'
|
|
11
|
+
newSetupFile: '{workflow_path}/steps/step-01c-new.md'
|
|
12
|
+
workflowFile: '{workflow_path}/workflow.md'
|
|
13
|
+
|
|
14
|
+
# State files
|
|
15
|
+
sidecarFolder: '{output_folder}/epic-executions'
|
|
16
|
+
sprintStatus: '{implementation_artifacts}/sprint-status.yaml'
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# Step 1: Entry Router
|
|
20
|
+
|
|
21
|
+
## STEP GOAL:
|
|
22
|
+
|
|
23
|
+
To detect the execution context (worktree vs main repo), discover any existing epic execution state, and route to the appropriate next step.
|
|
24
|
+
|
|
25
|
+
## MANDATORY EXECUTION RULES (READ FIRST):
|
|
26
|
+
|
|
27
|
+
### Universal Rules:
|
|
28
|
+
|
|
29
|
+
- 🛑 NEVER skip detection steps
|
|
30
|
+
- 📖 CRITICAL: Read the complete step file before taking any action
|
|
31
|
+
- 📋 YOU ARE A ROUTER, not an executor
|
|
32
|
+
|
|
33
|
+
### Role Reinforcement:
|
|
34
|
+
|
|
35
|
+
- ✅ You are an Epic Execution Orchestrator
|
|
36
|
+
- ✅ This step ONLY detects context and routes
|
|
37
|
+
- ✅ All initialization logic is in step-01c
|
|
38
|
+
- ✅ All continuation logic is in step-01b
|
|
39
|
+
|
|
40
|
+
### Step-Specific Rules:
|
|
41
|
+
|
|
42
|
+
- 🎯 Focus ONLY on detection and routing
|
|
43
|
+
- 🚫 FORBIDDEN to start epic setup in this step
|
|
44
|
+
- 🚫 FORBIDDEN to start story execution in this step
|
|
45
|
+
- 🚪 ROUTE to appropriate step based on detection results
|
|
46
|
+
|
|
47
|
+
## DETECTION SEQUENCE:
|
|
48
|
+
|
|
49
|
+
### 1. Detect Worktree Context
|
|
50
|
+
|
|
51
|
+
Execute git commands to determine if running in a worktree:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
|
|
55
|
+
GIT_COMMON=$(git rev-parse --git-common-dir 2>/dev/null)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Interpretation:**
|
|
59
|
+
- If `$GIT_DIR` != `$GIT_COMMON` → Running in a WORKTREE
|
|
60
|
+
- If `$GIT_DIR` == `$GIT_COMMON` → Running in MAIN REPO
|
|
61
|
+
|
|
62
|
+
**Store context:**
|
|
63
|
+
```
|
|
64
|
+
is_worktree: true | false
|
|
65
|
+
current_path: $(pwd)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 2. Discover Sidecar Files
|
|
69
|
+
|
|
70
|
+
Scan for existing epic execution state files.
|
|
71
|
+
|
|
72
|
+
**IMPORTANT:** When running in a worktree, the sidecar was created in the **main repo** before session restart. You must search the main repo's sidecar folder, not just the local worktree folder.
|
|
73
|
+
|
|
74
|
+
**If running in MAIN REPO (`is_worktree` = false):**
|
|
75
|
+
```bash
|
|
76
|
+
ls -la {sidecarFolder}/epic-*-state.yaml 2>/dev/null
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**If running in WORKTREE (`is_worktree` = true):**
|
|
80
|
+
```bash
|
|
81
|
+
# Derive main repo path from git
|
|
82
|
+
MAIN_REPO_PATH=$(dirname "$(git rev-parse --git-common-dir)")
|
|
83
|
+
MAIN_SIDECAR_FOLDER="$MAIN_REPO_PATH/_bmad-output/epic-executions"
|
|
84
|
+
|
|
85
|
+
# Search main repo sidecar folder (canonical location where setup created it)
|
|
86
|
+
ls -la "$MAIN_SIDECAR_FOLDER"/epic-*-state.yaml 2>/dev/null
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Store main repo sidecar path for later use:**
|
|
90
|
+
```
|
|
91
|
+
main_sidecar_folder: "$MAIN_SIDECAR_FOLDER" # Only when is_worktree=true
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**For each sidecar found, extract:**
|
|
95
|
+
- Epic number (from filename pattern)
|
|
96
|
+
- `current_phase` value
|
|
97
|
+
- `worktree_config.worktree_path` (if present)
|
|
98
|
+
- `stories_pending` count
|
|
99
|
+
- `sidecar_path` (full path to the sidecar file)
|
|
100
|
+
|
|
101
|
+
**Build sidecar list:**
|
|
102
|
+
```
|
|
103
|
+
sidecars_found:
|
|
104
|
+
- file: "epic-2-state.yaml"
|
|
105
|
+
sidecar_path: "/main/repo/_bmad-output/epic-executions/epic-2-state.yaml"
|
|
106
|
+
epic_number: 2
|
|
107
|
+
phase: "executing"
|
|
108
|
+
worktree_path: "/path/to/worktree" | null
|
|
109
|
+
pending_stories: 5
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### 3. Route Decision
|
|
113
|
+
|
|
114
|
+
Based on detection results, determine the appropriate path:
|
|
115
|
+
|
|
116
|
+
#### Scenario A: In Worktree with Matching Sidecar
|
|
117
|
+
|
|
118
|
+
**Conditions:**
|
|
119
|
+
- `is_worktree` = true
|
|
120
|
+
- Found sidecar where `worktree_config.worktree_path` == `current_path`
|
|
121
|
+
- Sidecar has `stories_pending` > 0
|
|
122
|
+
|
|
123
|
+
**Action:** Route to `{continueFile}` with matched sidecar
|
|
124
|
+
|
|
125
|
+
**Display:**
|
|
126
|
+
```
|
|
127
|
+
Detected: Running in worktree for Epic {N}
|
|
128
|
+
Found matching execution state with {X} stories pending.
|
|
129
|
+
Sidecar location: {sidecar_path}
|
|
130
|
+
|
|
131
|
+
Routing to continuation...
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
→ Pass `sidecar_path` context for subsequent steps to use
|
|
135
|
+
→ Load, read entire file, then execute `{continueFile}`
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
#### Scenario B: In Worktree, Awaiting Session Restart
|
|
140
|
+
|
|
141
|
+
**Conditions:**
|
|
142
|
+
- `is_worktree` = true
|
|
143
|
+
- Found sidecar where `worktree_config.worktree_path` == `current_path`
|
|
144
|
+
- Sidecar has `current_phase` = "awaiting_session_restart"
|
|
145
|
+
|
|
146
|
+
**Action:** Update sidecar phase to "executing", route to orchestration
|
|
147
|
+
|
|
148
|
+
**Display:**
|
|
149
|
+
```
|
|
150
|
+
Detected: Fresh session in worktree for Epic {N}
|
|
151
|
+
Setup was completed in previous session.
|
|
152
|
+
|
|
153
|
+
Ready to begin story execution...
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
→ Update sidecar at `{sidecar_path}` (the matched sidecar's full path): `current_phase: "executing"`
|
|
157
|
+
→ Load, read entire file, then execute step-02-orchestrate.md
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
#### Scenario C: In Worktree, No Matching Sidecar
|
|
162
|
+
|
|
163
|
+
**Conditions:**
|
|
164
|
+
- `is_worktree` = true
|
|
165
|
+
- No sidecar matches `current_path`
|
|
166
|
+
|
|
167
|
+
**Action:** Error state - worktree exists but no state found
|
|
168
|
+
|
|
169
|
+
**Display:**
|
|
170
|
+
```
|
|
171
|
+
⚠️ Warning: Running in a worktree but no matching execution state found.
|
|
172
|
+
|
|
173
|
+
This worktree may have been created manually or state was lost.
|
|
174
|
+
|
|
175
|
+
Options:
|
|
176
|
+
[N] Start new epic setup (will use this worktree)
|
|
177
|
+
[X] Exit and investigate
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
- IF N: Route to `{newSetupFile}` (skip worktree creation, use current)
|
|
181
|
+
- IF X: EXIT workflow
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
#### Scenario D: In Main Repo with Pending Sidecars
|
|
186
|
+
|
|
187
|
+
**Conditions:**
|
|
188
|
+
- `is_worktree` = false
|
|
189
|
+
- Found sidecars with `stories_pending` > 0
|
|
190
|
+
|
|
191
|
+
**Action:** Show existing executions, ask user intent
|
|
192
|
+
|
|
193
|
+
**Display:**
|
|
194
|
+
```
|
|
195
|
+
Found existing epic execution(s):
|
|
196
|
+
|
|
197
|
+
Epic 2: "Auth Experience" - 5 stories pending
|
|
198
|
+
└─ Worktree: ../vt-saas-template-epic-2-auth/
|
|
199
|
+
Epic 3: "User Onboarding" - 7 stories pending (main repo)
|
|
200
|
+
|
|
201
|
+
Options:
|
|
202
|
+
[1] Continue Epic 2 (requires: cd ../vt-saas-template-epic-2-auth/)
|
|
203
|
+
[2] Continue Epic 3
|
|
204
|
+
[N] Start NEW epic execution
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
- IF number selected for worktree epic: Display cd command and exit
|
|
208
|
+
- IF number selected for main repo epic: Route to `{continueFile}`
|
|
209
|
+
- IF N: Route to `{newSetupFile}`
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
#### Scenario E: In Main Repo, No Active Sidecars
|
|
214
|
+
|
|
215
|
+
**Conditions:**
|
|
216
|
+
- `is_worktree` = false
|
|
217
|
+
- No sidecars found OR all sidecars have `current_phase` = "complete"
|
|
218
|
+
|
|
219
|
+
**Action:** Fresh start - route to new epic setup
|
|
220
|
+
|
|
221
|
+
**Display:**
|
|
222
|
+
```
|
|
223
|
+
Welcome to the Epic Execution Orchestrator!
|
|
224
|
+
|
|
225
|
+
No active epic executions found.
|
|
226
|
+
Starting new epic setup...
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
→ Load, read entire file, then execute `{newSetupFile}`
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## 🚨 SYSTEM SUCCESS/FAILURE METRICS
|
|
234
|
+
|
|
235
|
+
### ✅ SUCCESS:
|
|
236
|
+
|
|
237
|
+
- Correctly detected worktree vs main repo context
|
|
238
|
+
- Found and parsed all existing sidecar files
|
|
239
|
+
- Routed to appropriate step based on scenario
|
|
240
|
+
- User given clear options when multiple paths exist
|
|
241
|
+
|
|
242
|
+
### ❌ SYSTEM FAILURE:
|
|
243
|
+
|
|
244
|
+
- Starting epic setup directly (that's step-01c's job)
|
|
245
|
+
- Starting continuation directly (that's step-01b's job)
|
|
246
|
+
- Not detecting worktree context
|
|
247
|
+
- Not scanning for existing sidecars
|
|
248
|
+
- Making assumptions without detection
|
|
249
|
+
|
|
250
|
+
**Master Rule:** This step ONLY detects and routes. All execution logic belongs in subsequent steps.
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: 'step-01b-continue'
|
|
3
|
+
description: 'Resume epic execution from previous session using sidecar state'
|
|
4
|
+
|
|
5
|
+
# Path Definitions
|
|
6
|
+
workflow_path: '{project-root}/_bmad/bmm/workflows/4-implementation/implement-epic-with-subagents'
|
|
7
|
+
|
|
8
|
+
# File References
|
|
9
|
+
thisStepFile: '{workflow_path}/steps/step-01b-continue.md'
|
|
10
|
+
nextStepFile: '{workflow_path}/steps/step-02-orchestrate.md'
|
|
11
|
+
completionStepFile: '{workflow_path}/steps/step-03-complete.md'
|
|
12
|
+
workflowFile: '{workflow_path}/workflow.md'
|
|
13
|
+
|
|
14
|
+
# State files
|
|
15
|
+
sidecarFolder: '{output_folder}/epic-executions'
|
|
16
|
+
sprintStatus: '{implementation_artifacts}/sprint-status.yaml'
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# Step 1B: Epic Execution Continuation
|
|
20
|
+
|
|
21
|
+
## STEP GOAL:
|
|
22
|
+
|
|
23
|
+
To resume epic execution from a previous session by loading the sidecar state, determining the exact resume point (which story, which phase), and seamlessly continuing autonomous execution.
|
|
24
|
+
|
|
25
|
+
## MANDATORY EXECUTION RULES (READ FIRST):
|
|
26
|
+
|
|
27
|
+
### Universal Rules:
|
|
28
|
+
|
|
29
|
+
- 🛑 NEVER generate content without user input
|
|
30
|
+
- 📖 CRITICAL: Read the complete step file before taking any action
|
|
31
|
+
- 🔄 CRITICAL: When loading next step with 'C', ensure entire file is read
|
|
32
|
+
- 📋 YOU ARE A FACILITATOR, not a content generator
|
|
33
|
+
|
|
34
|
+
### Orchestrator-Specific Rules:
|
|
35
|
+
|
|
36
|
+
- 🛑 NEVER modify completed story results
|
|
37
|
+
- 🔄 CRITICAL: Determine exact resume point from sidecar state
|
|
38
|
+
- 📋 YOU ARE AN ORCHESTRATOR resuming execution
|
|
39
|
+
|
|
40
|
+
### Role Reinforcement:
|
|
41
|
+
|
|
42
|
+
- ✅ You are an Epic Execution Orchestrator
|
|
43
|
+
- ✅ You are resuming a previously started epic execution
|
|
44
|
+
- ✅ You maintain execution continuity without loss of progress
|
|
45
|
+
- ✅ You communicate resume status clearly
|
|
46
|
+
|
|
47
|
+
### Step-Specific Rules:
|
|
48
|
+
|
|
49
|
+
- 🎯 Focus ONLY on analyzing state and resuming
|
|
50
|
+
- 🚫 FORBIDDEN to re-execute completed stories
|
|
51
|
+
- 💬 Confirm resume point with user
|
|
52
|
+
- 🚪 DETECT if all stories are already complete
|
|
53
|
+
|
|
54
|
+
## EXECUTION PROTOCOLS:
|
|
55
|
+
|
|
56
|
+
- 🎯 Show current state analysis before resuming
|
|
57
|
+
- 💾 Update sidecar with resume timestamp
|
|
58
|
+
- 📖 Preserve all completed story data
|
|
59
|
+
- 🚫 FORBIDDEN to modify historical execution data
|
|
60
|
+
|
|
61
|
+
## CONTEXT BOUNDARIES:
|
|
62
|
+
|
|
63
|
+
- Sidecar file contains complete execution state
|
|
64
|
+
- Previous stories may be completed, in-progress, or pending
|
|
65
|
+
- Current phase indicates where to resume within a story
|
|
66
|
+
- Sprint-status.yaml reflects actual story states
|
|
67
|
+
- Worktree context affects where execution continues
|
|
68
|
+
|
|
69
|
+
## CONTINUATION SEQUENCE:
|
|
70
|
+
|
|
71
|
+
### 0. Context Awareness
|
|
72
|
+
|
|
73
|
+
**Note:** This step is routed from step-01-init which already detected:
|
|
74
|
+
- Whether we're in a worktree or main repo
|
|
75
|
+
- Which sidecar file to use (passed as `sidecar_path` context)
|
|
76
|
+
|
|
77
|
+
If `sidecar_path` was NOT specified by router (edge case):
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Detect worktree context
|
|
81
|
+
GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
|
|
82
|
+
GIT_COMMON=$(git rev-parse --git-common-dir 2>/dev/null)
|
|
83
|
+
CURRENT_PATH=$(pwd)
|
|
84
|
+
|
|
85
|
+
# Determine sidecar search location
|
|
86
|
+
if [ "$GIT_DIR" != "$GIT_COMMON" ]; then
|
|
87
|
+
# In worktree - sidecar is in main repo
|
|
88
|
+
MAIN_REPO_PATH=$(dirname "$GIT_COMMON")
|
|
89
|
+
SIDECAR_FOLDER="$MAIN_REPO_PATH/_bmad-output/epic-executions"
|
|
90
|
+
else
|
|
91
|
+
# In main repo - use local folder
|
|
92
|
+
SIDECAR_FOLDER="{sidecarFolder}"
|
|
93
|
+
fi
|
|
94
|
+
|
|
95
|
+
# Find sidecar with matching worktree_path (if in worktree)
|
|
96
|
+
# Parse each epic-*-state.yaml and match worktree_config.worktree_path == CURRENT_PATH
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Worktree-specific notes:**
|
|
100
|
+
- Sidecar files are ALWAYS created in the **main repo's** `_bmad-output/epic-executions/`
|
|
101
|
+
- When in a worktree, you must derive the main repo path to find the sidecar
|
|
102
|
+
- `worktree_config.worktree_path` in sidecar identifies which worktree it belongs to
|
|
103
|
+
|
|
104
|
+
### 1. Load Sidecar State
|
|
105
|
+
|
|
106
|
+
Read the sidecar file at the path determined above (use `sidecar_path` from router context, or derive it as shown in section 0):
|
|
107
|
+
|
|
108
|
+
Extract:
|
|
109
|
+
- `epic_execution_state.epic_file`: Path to epic being executed
|
|
110
|
+
- `epic_execution_state.epic_name`: Name of the epic
|
|
111
|
+
- `epic_execution_state.epic_number`: Epic number
|
|
112
|
+
- `epic_execution_state.current_story`: Story that was being processed (may be null)
|
|
113
|
+
- `epic_execution_state.current_phase`: Phase within story (create/dev/visual/review/commit)
|
|
114
|
+
- `epic_execution_state.stories_completed`: List of finished stories
|
|
115
|
+
- `epic_execution_state.stories_pending`: List of remaining stories
|
|
116
|
+
- `epic_execution_state.stories_skipped`: List of skipped stories
|
|
117
|
+
- `epic_execution_state.stories_failed`: List of failed stories
|
|
118
|
+
- `epic_execution_state.started_at`: Original start timestamp
|
|
119
|
+
- `epic_execution_state.last_updated`: Last activity timestamp
|
|
120
|
+
- `execution_mode.type`: "worktree" | "main"
|
|
121
|
+
- `worktree_config` (if worktree mode):
|
|
122
|
+
- `worktree_path`: Absolute path to worktree
|
|
123
|
+
- `branch_name`: Feature branch name
|
|
124
|
+
- `main_repo_path`: Path to main repository
|
|
125
|
+
|
|
126
|
+
### 2. Validate Execution Context
|
|
127
|
+
|
|
128
|
+
**If sidecar indicates worktree mode:**
|
|
129
|
+
|
|
130
|
+
Check current working directory matches expected worktree:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
EXPECTED_PATH=$(grep 'worktree_path:' sidecar.yaml | awk '{print $2}')
|
|
134
|
+
CURRENT_PATH=$(pwd)
|
|
135
|
+
|
|
136
|
+
if [ "$CURRENT_PATH" != "$EXPECTED_PATH" ]; then
|
|
137
|
+
# Wrong directory - warn user
|
|
138
|
+
fi
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**If mismatch detected:**
|
|
142
|
+
```
|
|
143
|
+
⚠️ Context Mismatch
|
|
144
|
+
|
|
145
|
+
This epic execution was configured for worktree mode:
|
|
146
|
+
Expected: {worktree_path}
|
|
147
|
+
Current: {current_path}
|
|
148
|
+
|
|
149
|
+
Options:
|
|
150
|
+
[P] Proceed anyway (may cause issues)
|
|
151
|
+
[X] Exit and navigate to correct directory
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 3. Analyze Execution State
|
|
155
|
+
|
|
156
|
+
Determine resume scenario:
|
|
157
|
+
|
|
158
|
+
**Scenario A: Mid-Story Resume**
|
|
159
|
+
If `current_story` is set and `current_phase` is not "between_stories":
|
|
160
|
+
- Resume at the specific phase of that story
|
|
161
|
+
- Example: Story 2.3 was in "dev" phase → resume dev
|
|
162
|
+
|
|
163
|
+
**Scenario B: Between Stories**
|
|
164
|
+
If `current_story` is null or phase is "between_stories":
|
|
165
|
+
- Start next story from `stories_pending[0]`
|
|
166
|
+
|
|
167
|
+
**Scenario C: All Stories Complete**
|
|
168
|
+
If `stories_pending` is empty:
|
|
169
|
+
- Route to step-03-complete for report generation and cleanup
|
|
170
|
+
|
|
171
|
+
### 4. Display Resume Summary
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
**Welcome Back!**
|
|
175
|
+
|
|
176
|
+
**Epic:** {epic_name} (Epic {epic_number})
|
|
177
|
+
**Mode:** {execution_mode.type}
|
|
178
|
+
**Started:** {started_at}
|
|
179
|
+
**Last Activity:** {last_updated}
|
|
180
|
+
|
|
181
|
+
**Location:**
|
|
182
|
+
{If worktree: "Worktree: {worktree_path}"}
|
|
183
|
+
{If main: "Main repository"}
|
|
184
|
+
|
|
185
|
+
**Progress:**
|
|
186
|
+
- ✅ Completed: {X} stories
|
|
187
|
+
- ⏸️ Skipped: {X} stories
|
|
188
|
+
- ❌ Failed: {X} stories
|
|
189
|
+
- ⏳ Pending: {X} stories
|
|
190
|
+
|
|
191
|
+
**Resume Point:**
|
|
192
|
+
{Based on scenario - describe where we'll resume}
|
|
193
|
+
|
|
194
|
+
Example outputs:
|
|
195
|
+
- 'Resuming Story 2.3 at development phase'
|
|
196
|
+
- 'Starting Story 2.4 (previous story completed)'
|
|
197
|
+
- 'All stories complete - ready to generate report'
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### 5. Validate Resume Readiness
|
|
201
|
+
|
|
202
|
+
Quick prerequisite check:
|
|
203
|
+
- Epic file still exists and readable
|
|
204
|
+
- Sprint-status.yaml accessible
|
|
205
|
+
- Required agents still available
|
|
206
|
+
- If worktree: worktree still exists and is valid
|
|
207
|
+
|
|
208
|
+
If any critical issue → report and ask user how to proceed.
|
|
209
|
+
|
|
210
|
+
### 6. Confirm Continuation Intent
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
**Ready to continue?**
|
|
214
|
+
|
|
215
|
+
Options:
|
|
216
|
+
[C] Continue from {resume point}
|
|
217
|
+
[R] Restart epic from beginning (will lose progress)
|
|
218
|
+
[S] Show detailed execution log
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### 7. Handle Menu Selection
|
|
222
|
+
|
|
223
|
+
#### IF C (Continue):
|
|
224
|
+
1. Update sidecar:
|
|
225
|
+
```yaml
|
|
226
|
+
execution_log:
|
|
227
|
+
- event: "session_resumed"
|
|
228
|
+
timestamp: "{current_timestamp}"
|
|
229
|
+
from_phase: "{current_phase}"
|
|
230
|
+
last_updated: "{current_timestamp}"
|
|
231
|
+
```
|
|
232
|
+
2. Route based on scenario:
|
|
233
|
+
- Scenario A/B → load, read entire file, then execute `{nextStepFile}`
|
|
234
|
+
- Scenario C → load, read entire file, then execute `{completionStepFile}`
|
|
235
|
+
|
|
236
|
+
#### IF R (Restart):
|
|
237
|
+
1. Confirm: "This will clear all progress. Are you sure? [Y/N]"
|
|
238
|
+
2. If Y:
|
|
239
|
+
- If worktree mode: Also ask about worktree cleanup
|
|
240
|
+
- Delete sidecar file
|
|
241
|
+
- Route to step-01-init.md (will go to step-01c for new setup)
|
|
242
|
+
3. If N: Redisplay menu
|
|
243
|
+
|
|
244
|
+
#### IF S (Show Log):
|
|
245
|
+
1. Display execution_log entries with timestamps
|
|
246
|
+
2. Show per-story details:
|
|
247
|
+
```
|
|
248
|
+
Execution Log:
|
|
249
|
+
|
|
250
|
+
[timestamp] Session started
|
|
251
|
+
[timestamp] Story 2.1 - create phase completed
|
|
252
|
+
[timestamp] Story 2.1 - dev phase completed (auth-specialist)
|
|
253
|
+
[timestamp] Story 2.1 - review approved
|
|
254
|
+
[timestamp] Story 2.1 - committed
|
|
255
|
+
[timestamp] Session interrupted
|
|
256
|
+
[timestamp] Session resumed ← current
|
|
257
|
+
```
|
|
258
|
+
3. Redisplay menu
|
|
259
|
+
|
|
260
|
+
### 8. Present MENU OPTIONS
|
|
261
|
+
|
|
262
|
+
Display: **Select an Option:** [C] Continue | [R] Restart | [S] Show Log
|
|
263
|
+
|
|
264
|
+
#### EXECUTION RULES:
|
|
265
|
+
|
|
266
|
+
- ALWAYS halt and wait for user selection
|
|
267
|
+
- Confirm restart with double-check
|
|
268
|
+
- Show execution context before continuing
|
|
269
|
+
|
|
270
|
+
#### Menu Handling Logic:
|
|
271
|
+
|
|
272
|
+
- IF C: Update sidecar with resume timestamp, then:
|
|
273
|
+
- If stories pending → load `{nextStepFile}`
|
|
274
|
+
- If all complete → load `{completionStepFile}`
|
|
275
|
+
- IF R: Confirm and handle restart
|
|
276
|
+
- IF S: Display log and redisplay menu
|
|
277
|
+
- IF Any questions: Respond and redisplay menu
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## 🚨 SYSTEM SUCCESS/FAILURE METRICS
|
|
282
|
+
|
|
283
|
+
### ✅ SUCCESS:
|
|
284
|
+
|
|
285
|
+
- Sidecar state loaded and analyzed correctly
|
|
286
|
+
- Worktree context validated (if applicable)
|
|
287
|
+
- Resume point determined accurately
|
|
288
|
+
- User confirmed continuation
|
|
289
|
+
- Proper routing to next step
|
|
290
|
+
- Resume timestamp recorded
|
|
291
|
+
|
|
292
|
+
### ❌ SYSTEM FAILURE:
|
|
293
|
+
|
|
294
|
+
- Not loading complete sidecar state
|
|
295
|
+
- Not validating worktree context
|
|
296
|
+
- Incorrect resume point determination
|
|
297
|
+
- Re-executing completed stories
|
|
298
|
+
- Not confirming with user before resuming
|
|
299
|
+
- Modifying historical execution data
|
|
300
|
+
|
|
301
|
+
**Master Rule:** Skipping steps, optimizing sequences, or not following exact instructions is FORBIDDEN and constitutes SYSTEM FAILURE.
|
|
302
|
+
|
|
303
|
+
## CRITICAL STEP COMPLETION NOTE
|
|
304
|
+
|
|
305
|
+
ONLY WHEN user selects [C] and sidecar is updated with resume info, will you then load the appropriate next step file based on execution state.
|