specflow-cc 1.12.0 → 1.14.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.
- package/CHANGELOG.md +74 -0
- package/README.md +22 -8
- package/agents/impl-reviewer.md +8 -0
- package/agents/sf-spec-executor-orchestrator.md +8 -0
- package/agents/spec-auditor.md +8 -0
- package/agents/spec-creator.md +13 -2
- package/agents/spec-executor-orchestrator.md +21 -0
- package/agents/spec-executor.md +8 -0
- package/agents/spec-reviser.md +8 -0
- package/agents/spec-splitter.md +11 -1
- package/bin/install.js +20 -0
- package/bin/lib/config.cjs +91 -0
- package/bin/lib/core.cjs +120 -0
- package/bin/lib/spec.cjs +130 -0
- package/bin/lib/state.cjs +241 -0
- package/bin/lib/verify.cjs +117 -0
- package/bin/sf-tools.cjs +103 -0
- package/commands/sf/audit.md +11 -69
- package/commands/sf/autopilot.md +601 -0
- package/commands/sf/done.md +32 -71
- package/commands/sf/health.md +220 -0
- package/commands/sf/help.md +16 -0
- package/commands/sf/review.md +11 -69
- package/commands/sf/revise.md +4 -7
- package/commands/sf/run.md +11 -69
- package/commands/sf/split.md +14 -3
- package/commands/sf/validate.md +154 -0
- package/hooks/context-monitor.js +121 -0
- package/hooks/statusline.js +17 -0
- package/package.json +1 -1
|
@@ -0,0 +1,601 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sf:autopilot
|
|
3
|
+
description: Run full spec lifecycle autonomously (audit -> run -> review -> done)
|
|
4
|
+
argument-hint: "[SPEC-XXX] [--all]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Bash
|
|
9
|
+
- Glob
|
|
10
|
+
- Grep
|
|
11
|
+
- Task
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
<purpose>
|
|
15
|
+
Run the full specification lifecycle autonomously. Reads STATE.md to determine current phase, spawns appropriate agents, advances through audit -> revise -> run -> review -> fix -> done cycle without manual intervention. Includes cycle-detection safeguards to prevent infinite loops.
|
|
16
|
+
</purpose>
|
|
17
|
+
|
|
18
|
+
<context>
|
|
19
|
+
@.specflow/STATE.md
|
|
20
|
+
@.specflow/specs/SPEC-*.md
|
|
21
|
+
@.specflow/config.json
|
|
22
|
+
</context>
|
|
23
|
+
|
|
24
|
+
<workflow>
|
|
25
|
+
|
|
26
|
+
## Step 1: Verify Initialization
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
[ -d .specflow ] && echo "OK" || echo "NOT_INITIALIZED"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**If NOT_INITIALIZED:**
|
|
33
|
+
```
|
|
34
|
+
SpecFlow not initialized.
|
|
35
|
+
|
|
36
|
+
Run `/sf:init` first.
|
|
37
|
+
```
|
|
38
|
+
Exit.
|
|
39
|
+
|
|
40
|
+
## Step 2: Parse Arguments and Determine Mode
|
|
41
|
+
|
|
42
|
+
Parse the command argument to determine execution mode:
|
|
43
|
+
|
|
44
|
+
| Argument | Mode | Behavior |
|
|
45
|
+
|----------|------|----------|
|
|
46
|
+
| (none) | single | Process the active spec in STATE.md |
|
|
47
|
+
| `SPEC-XXX` | single | Set SPEC-XXX as active, then process it |
|
|
48
|
+
| `--all` | batch | Process all actionable specs in Queue order |
|
|
49
|
+
|
|
50
|
+
**If single mode:**
|
|
51
|
+
- If SPEC-XXX argument provided: update STATE.md to set it as active spec
|
|
52
|
+
- If no argument and no active spec exists: display error and exit
|
|
53
|
+
|
|
54
|
+
**If batch mode (--all):**
|
|
55
|
+
- Identify all actionable specs from Queue (any spec with status: draft, auditing, revision_requested, audited, running, review)
|
|
56
|
+
|
|
57
|
+
**Error case (single mode, no active, no argument):**
|
|
58
|
+
```
|
|
59
|
+
No active specification to process.
|
|
60
|
+
|
|
61
|
+
Provide a spec ID: `/sf:autopilot SPEC-XXX`
|
|
62
|
+
Or run on all specs: `/sf:autopilot --all`
|
|
63
|
+
```
|
|
64
|
+
Exit.
|
|
65
|
+
|
|
66
|
+
## Step 3: Set Configuration Constants
|
|
67
|
+
|
|
68
|
+
Read `.specflow/config.json` for autopilot configuration:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
[ -f .specflow/config.json ] && cat .specflow/config.json
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Parse the `"autopilot"` section if it exists:
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"autopilot": {
|
|
79
|
+
"max_audit_cycles": 3,
|
|
80
|
+
"max_fix_cycles": 3
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Configuration constants:**
|
|
86
|
+
|
|
87
|
+
| Constant | Default | Description |
|
|
88
|
+
|----------|---------|-------------|
|
|
89
|
+
| MAX_AUDIT_CYCLES | 3 | Max audit->revise iterations before halt |
|
|
90
|
+
| MAX_FIX_CYCLES | 3 | Max review->fix iterations before halt |
|
|
91
|
+
|
|
92
|
+
If config file doesn't exist or autopilot section is missing, use defaults.
|
|
93
|
+
|
|
94
|
+
## Step 4: Initialize Tracking State
|
|
95
|
+
|
|
96
|
+
Initialize per-spec tracking variables (maintained in command memory, not persisted to files):
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
audit_cycles = 0
|
|
100
|
+
fix_cycles = 0
|
|
101
|
+
specs_processed = [] (batch mode)
|
|
102
|
+
specs_failed = [] (batch mode)
|
|
103
|
+
current_spec = null
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Step 5: Main Loop (per spec)
|
|
107
|
+
|
|
108
|
+
### 5.1 Load Current Spec State
|
|
109
|
+
|
|
110
|
+
Read `.specflow/STATE.md` to get active specification.
|
|
111
|
+
Read `.specflow/specs/SPEC-XXX.md` to get frontmatter status.
|
|
112
|
+
|
|
113
|
+
### 5.2 Determine Current Phase
|
|
114
|
+
|
|
115
|
+
Based on spec status, determine the phase and action:
|
|
116
|
+
|
|
117
|
+
| Spec Status | Phase | Action |
|
|
118
|
+
|-------------|-------|--------|
|
|
119
|
+
| `draft` | audit | Spawn spec-auditor agent |
|
|
120
|
+
| `auditing` | audit | Spawn spec-auditor agent |
|
|
121
|
+
| `revision_requested` | revise | Spawn spec-reviser agent with scope "all" |
|
|
122
|
+
| `audited` | run | Spawn spec-executor or spec-executor-orchestrator agent |
|
|
123
|
+
| `running` | run | Spawn spec-executor or spec-executor-orchestrator agent |
|
|
124
|
+
| `review` | review-or-fix | Check for latest review result (see 5.3) |
|
|
125
|
+
| `needs_decomposition` | halt | Halt with decomposition message |
|
|
126
|
+
| `paused` | halt | Halt with paused message |
|
|
127
|
+
| `done` | done | Run done logic (archive, update STATE.md) |
|
|
128
|
+
|
|
129
|
+
**Halt messages:**
|
|
130
|
+
|
|
131
|
+
**If `needs_decomposition`:**
|
|
132
|
+
```
|
|
133
|
+
Spec SPEC-XXX requires decomposition.
|
|
134
|
+
|
|
135
|
+
Run `/sf:split` manually, then restart autopilot.
|
|
136
|
+
```
|
|
137
|
+
Record as failed in batch mode. Exit in single mode.
|
|
138
|
+
|
|
139
|
+
**If `paused`:**
|
|
140
|
+
```
|
|
141
|
+
Spec SPEC-XXX is paused.
|
|
142
|
+
|
|
143
|
+
Resume with `/sf:resume` first.
|
|
144
|
+
```
|
|
145
|
+
Record as failed in batch mode. Exit in single mode.
|
|
146
|
+
|
|
147
|
+
### 5.3 Review Phase Logic
|
|
148
|
+
|
|
149
|
+
When spec status is `review`, inspect the Review History section:
|
|
150
|
+
|
|
151
|
+
**If no review exists yet OR last review entry is a Fix Response:**
|
|
152
|
+
- Spawn impl-reviewer agent
|
|
153
|
+
|
|
154
|
+
**If last review entry is APPROVED:**
|
|
155
|
+
- Proceed to done phase (5.5)
|
|
156
|
+
|
|
157
|
+
**If last review entry is CHANGES_REQUESTED:**
|
|
158
|
+
- Spawn spec-executor in fix mode with scope "all"
|
|
159
|
+
|
|
160
|
+
### 5.4 Spawn Agent for Phase
|
|
161
|
+
|
|
162
|
+
Spawn the appropriate agent based on phase (see Step 6 for details).
|
|
163
|
+
|
|
164
|
+
Include `<autopilot>true</autopilot>` context tag in all Task prompts.
|
|
165
|
+
|
|
166
|
+
**Agent spawning example:**
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
Task(prompt="
|
|
170
|
+
<specification>
|
|
171
|
+
@.specflow/specs/SPEC-XXX.md
|
|
172
|
+
</specification>
|
|
173
|
+
|
|
174
|
+
<project_context>
|
|
175
|
+
@.specflow/PROJECT.md
|
|
176
|
+
</project_context>
|
|
177
|
+
|
|
178
|
+
<autopilot>true</autopilot>
|
|
179
|
+
|
|
180
|
+
Execute this specification following the spec-executor agent instructions.
|
|
181
|
+
Implement all requirements with atomic commits.
|
|
182
|
+
", subagent_type="sf-spec-executor", model="{profile_model}", description="Execute specification (autopilot mode)")
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### 5.5 After Agent Completes
|
|
186
|
+
|
|
187
|
+
1. **Re-read STATE.md and spec file** to get updated status
|
|
188
|
+
2. **Check STATE.md size and rotate if needed:**
|
|
189
|
+
- Use Read tool to read `.specflow/STATE.md` and count total lines
|
|
190
|
+
- If total lines <= 100, no action needed
|
|
191
|
+
- If total lines > 100:
|
|
192
|
+
a. Read the `## Decisions` section and extract all decision rows (lines matching `| YYYY-`)
|
|
193
|
+
b. Count decision rows. If <= 7, no rotation needed
|
|
194
|
+
c. If > 7 decisions:
|
|
195
|
+
- Identify the 5 most recent decisions (last 5 rows) -- these STAY
|
|
196
|
+
- Identify older decisions (all rows except last 5) -- these MOVE to archive
|
|
197
|
+
- Read `.specflow/DECISIONS_ARCHIVE.md` (create with template if missing)
|
|
198
|
+
- Write updated DECISIONS_ARCHIVE.md: insert old decisions after the table header row
|
|
199
|
+
- Write updated STATE.md: replace Decisions section content with only the 5 most recent decisions
|
|
200
|
+
|
|
201
|
+
3. **Increment cycle counters:**
|
|
202
|
+
- If just completed revise phase: `audit_cycles++`
|
|
203
|
+
- If just completed fix phase: `fix_cycles++`
|
|
204
|
+
|
|
205
|
+
4. **Check cycle limits:**
|
|
206
|
+
- If `audit_cycles >= MAX_AUDIT_CYCLES`: HALT with "Audit cycle limit reached (3/3)"
|
|
207
|
+
- If `fix_cycles >= MAX_FIX_CYCLES`: HALT with "Fix cycle limit reached (3/3)"
|
|
208
|
+
|
|
209
|
+
5. **Reset cycle counters when transitioning between major phases:**
|
|
210
|
+
- If spec transitions from audit/revise phase to run phase (status becomes "audited"): `audit_cycles = 0`
|
|
211
|
+
- If spec enters review/fix phase (status becomes "review"): `fix_cycles = 0`
|
|
212
|
+
|
|
213
|
+
6. **Loop back to 5.2** with the updated status
|
|
214
|
+
|
|
215
|
+
**Halt behavior when cycle limit reached:**
|
|
216
|
+
1. Leave the spec in its current state in STATE.md (do not archive, do not clear active)
|
|
217
|
+
2. Record as failed in specs_failed list with reason "Audit cycle limit (3/3)" or "Fix cycle limit (3/3)"
|
|
218
|
+
3. In batch mode: attempt next spec in queue (do not abort the entire batch)
|
|
219
|
+
4. In single mode: proceed directly to summary report (Step 9)
|
|
220
|
+
|
|
221
|
+
### 5.6 Done Phase (inline)
|
|
222
|
+
|
|
223
|
+
When spec reaches done status OR last review is APPROVED, execute the done logic inline:
|
|
224
|
+
|
|
225
|
+
1. **Create archive directory:**
|
|
226
|
+
```bash
|
|
227
|
+
mkdir -p .specflow/archive
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
2. **Update spec frontmatter:**
|
|
231
|
+
- status → "done"
|
|
232
|
+
- Add Completion section with timestamp and commit/review counts
|
|
233
|
+
|
|
234
|
+
```markdown
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Completion
|
|
238
|
+
|
|
239
|
+
**Completed:** {date} {time}
|
|
240
|
+
**Total Commits:** {count from Execution Summary}
|
|
241
|
+
**Review Cycles:** {count of Review v[N] entries}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
3. **Extract decisions:**
|
|
245
|
+
- Scan specification for technology choices mentioned in Context or Assumptions
|
|
246
|
+
- Scan for patterns established during implementation
|
|
247
|
+
- If significant decisions found, add to STATE.md Decisions table:
|
|
248
|
+
```markdown
|
|
249
|
+
| {date} | SPEC-XXX | {decision description} |
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
4. **Archive specification:**
|
|
253
|
+
```bash
|
|
254
|
+
mv .specflow/specs/SPEC-XXX.md .specflow/archive/
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
5. **Update STATE.md:**
|
|
258
|
+
- Active Specification → "none"
|
|
259
|
+
- Status → "idle"
|
|
260
|
+
- Next Step → "/sf:new or /sf:next"
|
|
261
|
+
- Remove SPEC-XXX row from Queue table
|
|
262
|
+
|
|
263
|
+
6. **Check STATE.md size and rotate** (same logic as 5.5 step 2)
|
|
264
|
+
|
|
265
|
+
7. **Create final commit:**
|
|
266
|
+
```bash
|
|
267
|
+
git add .specflow/
|
|
268
|
+
git commit -m "docs(sf): complete SPEC-XXX"
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
8. **Record completion:**
|
|
272
|
+
- In batch mode: add to specs_processed list with outcome "COMPLETED"
|
|
273
|
+
|
|
274
|
+
## Step 6: Agent Spawning Details
|
|
275
|
+
|
|
276
|
+
For each phase, determine the agent type and model profile:
|
|
277
|
+
|
|
278
|
+
| Phase | Agent | Subagent Type | Auto-Resolution |
|
|
279
|
+
|-------|-------|---------------|-----------------|
|
|
280
|
+
| audit | spec-auditor | sf-spec-auditor | N/A (no interactive prompts) |
|
|
281
|
+
| revise | spec-reviser | sf-spec-reviser | scope = "all" |
|
|
282
|
+
| run | spec-executor or spec-executor-orchestrator | sf-spec-executor / sf-spec-executor-orchestrator | Skip audit-status warning (proceed anyway) |
|
|
283
|
+
| review | impl-reviewer | sf-impl-reviewer | N/A (no interactive prompts) |
|
|
284
|
+
| fix | spec-executor (fix mode) | sf-spec-executor | scope = "all" |
|
|
285
|
+
| done | (inline logic) | N/A | Skip review/verify warnings (proceed anyway) |
|
|
286
|
+
|
|
287
|
+
### 6.1 Determine Model Profile
|
|
288
|
+
|
|
289
|
+
Check `.specflow/config.json` for model profile setting:
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
[ -f .specflow/config.json ] && cat .specflow/config.json | grep -o '"model_profile"[[:space:]]*:[[:space:]]*"[^"]*"' | cut -d'"' -f4 || echo "balanced"
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**Profile Table:**
|
|
296
|
+
|
|
297
|
+
| Profile | spec-auditor | spec-reviser | spec-executor | spec-executor-orchestrator | spec-executor-worker | impl-reviewer |
|
|
298
|
+
|---------|--------------|--------------|---------------|---------------------------|---------------------|---------------|
|
|
299
|
+
| max | opus | opus | opus | opus | opus | opus |
|
|
300
|
+
| quality | opus | sonnet | opus | opus | opus | sonnet |
|
|
301
|
+
| balanced | opus | sonnet | sonnet | sonnet | sonnet | sonnet |
|
|
302
|
+
| budget | sonnet | sonnet | sonnet | sonnet | sonnet | haiku |
|
|
303
|
+
|
|
304
|
+
### 6.2 Determine Execution Mode (run phase)
|
|
305
|
+
|
|
306
|
+
When spawning execution agent, check specification complexity:
|
|
307
|
+
|
|
308
|
+
**If `## Implementation Tasks` section exists in spec:**
|
|
309
|
+
- Count task groups (G1, G2, G3, etc.)
|
|
310
|
+
- Check for parallel opportunities (groups with no dependencies on each other)
|
|
311
|
+
- If groups > 1 AND parallelism exists → use `spec-executor-orchestrator`
|
|
312
|
+
- Otherwise → use `spec-executor`
|
|
313
|
+
|
|
314
|
+
**If no Implementation Tasks section:**
|
|
315
|
+
- Use `spec-executor`
|
|
316
|
+
|
|
317
|
+
### 6.3 Agent Prompts
|
|
318
|
+
|
|
319
|
+
**Audit phase (spec-auditor):**
|
|
320
|
+
```
|
|
321
|
+
Task(prompt="
|
|
322
|
+
<specification>
|
|
323
|
+
@.specflow/specs/SPEC-XXX.md
|
|
324
|
+
</specification>
|
|
325
|
+
|
|
326
|
+
<project_context>
|
|
327
|
+
@.specflow/PROJECT.md
|
|
328
|
+
</project_context>
|
|
329
|
+
|
|
330
|
+
<autopilot>true</autopilot>
|
|
331
|
+
|
|
332
|
+
Audit this specification following the spec-auditor agent instructions.
|
|
333
|
+
Check for completeness, clarity, feasibility, and alignment with project patterns.
|
|
334
|
+
", subagent_type="sf-spec-auditor", model="{profile_model}", description="Audit specification (autopilot mode)")
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
**Revise phase (spec-reviser):**
|
|
338
|
+
```
|
|
339
|
+
Task(prompt="
|
|
340
|
+
<specification>
|
|
341
|
+
@.specflow/specs/SPEC-XXX.md
|
|
342
|
+
</specification>
|
|
343
|
+
|
|
344
|
+
<project_context>
|
|
345
|
+
@.specflow/PROJECT.md
|
|
346
|
+
</project_context>
|
|
347
|
+
|
|
348
|
+
<autopilot>true</autopilot>
|
|
349
|
+
<scope>all</scope>
|
|
350
|
+
|
|
351
|
+
Revise this specification to address ALL audit findings.
|
|
352
|
+
Follow the spec-reviser agent instructions.
|
|
353
|
+
", subagent_type="sf-spec-reviser", model="{profile_model}", description="Revise specification (autopilot mode)")
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
**Run phase (spec-executor):**
|
|
357
|
+
```
|
|
358
|
+
Task(prompt="
|
|
359
|
+
<specification>
|
|
360
|
+
@.specflow/specs/SPEC-XXX.md
|
|
361
|
+
</specification>
|
|
362
|
+
|
|
363
|
+
<project_context>
|
|
364
|
+
@.specflow/PROJECT.md
|
|
365
|
+
</project_context>
|
|
366
|
+
|
|
367
|
+
<autopilot>true</autopilot>
|
|
368
|
+
|
|
369
|
+
Execute this specification following the spec-executor agent instructions.
|
|
370
|
+
Implement all requirements with atomic commits.
|
|
371
|
+
Proceed even if audit status is not 'audited'.
|
|
372
|
+
", subagent_type="sf-spec-executor", model="{profile_model}", description="Execute specification (autopilot mode)")
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
**Run phase (spec-executor-orchestrator):**
|
|
376
|
+
```
|
|
377
|
+
Task(prompt="
|
|
378
|
+
<specification>
|
|
379
|
+
@.specflow/specs/SPEC-XXX.md
|
|
380
|
+
</specification>
|
|
381
|
+
|
|
382
|
+
<project_context>
|
|
383
|
+
@.specflow/PROJECT.md
|
|
384
|
+
</project_context>
|
|
385
|
+
|
|
386
|
+
<autopilot>true</autopilot>
|
|
387
|
+
|
|
388
|
+
Orchestrate execution of this large specification.
|
|
389
|
+
Parse task groups from Implementation Tasks section.
|
|
390
|
+
Determine execution waves based on dependencies.
|
|
391
|
+
Spawn worker subagents in parallel where possible.
|
|
392
|
+
Proceed even if audit status is not 'audited'.
|
|
393
|
+
", subagent_type="sf-spec-executor-orchestrator", model="{profile_model}", description="Orchestrate specification execution (autopilot mode)")
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
**Review phase (impl-reviewer):**
|
|
397
|
+
```
|
|
398
|
+
Task(prompt="
|
|
399
|
+
<specification>
|
|
400
|
+
@.specflow/specs/SPEC-XXX.md
|
|
401
|
+
</specification>
|
|
402
|
+
|
|
403
|
+
<project_context>
|
|
404
|
+
@.specflow/PROJECT.md
|
|
405
|
+
</project_context>
|
|
406
|
+
|
|
407
|
+
<autopilot>true</autopilot>
|
|
408
|
+
|
|
409
|
+
Review the implementation against the specification.
|
|
410
|
+
Follow the impl-reviewer agent instructions.
|
|
411
|
+
", subagent_type="sf-impl-reviewer", model="{profile_model}", description="Review implementation (autopilot mode)")
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
**Fix phase (spec-executor):**
|
|
415
|
+
```
|
|
416
|
+
Task(prompt="
|
|
417
|
+
<specification>
|
|
418
|
+
@.specflow/specs/SPEC-XXX.md
|
|
419
|
+
</specification>
|
|
420
|
+
|
|
421
|
+
<project_context>
|
|
422
|
+
@.specflow/PROJECT.md
|
|
423
|
+
</project_context>
|
|
424
|
+
|
|
425
|
+
<autopilot>true</autopilot>
|
|
426
|
+
<mode>fix</mode>
|
|
427
|
+
<scope>all</scope>
|
|
428
|
+
|
|
429
|
+
Fix ALL issues identified in the latest review.
|
|
430
|
+
Follow the spec-executor agent instructions in fix mode.
|
|
431
|
+
", subagent_type="sf-spec-executor", model="{profile_model}", description="Fix implementation issues (autopilot mode)")
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
## Step 7: Batch Mode — Advance to Next Spec
|
|
435
|
+
|
|
436
|
+
If `--all` mode (batch execution):
|
|
437
|
+
|
|
438
|
+
1. **Record completed spec** in specs_processed list:
|
|
439
|
+
- Spec ID
|
|
440
|
+
- Title
|
|
441
|
+
- Outcome (COMPLETED or reason for failure)
|
|
442
|
+
- Audit cycles used
|
|
443
|
+
- Fix cycles used
|
|
444
|
+
|
|
445
|
+
2. **Read STATE.md Queue** for next actionable spec:
|
|
446
|
+
- First spec in Queue by Priority that has an actionable status
|
|
447
|
+
- Actionable statuses: draft, auditing, revision_requested, audited, running, review
|
|
448
|
+
|
|
449
|
+
3. **If next spec found:**
|
|
450
|
+
- Update STATE.md active spec to the next spec
|
|
451
|
+
- Reset cycle counters: `audit_cycles = 0`, `fix_cycles = 0`
|
|
452
|
+
- Loop to Step 5
|
|
453
|
+
|
|
454
|
+
4. **If no more actionable specs:**
|
|
455
|
+
- Proceed to Step 9 (summary report)
|
|
456
|
+
|
|
457
|
+
## Step 8: Handle Agent Failures
|
|
458
|
+
|
|
459
|
+
If a Task agent fails to spawn or encounters an unrecoverable error:
|
|
460
|
+
|
|
461
|
+
1. **Log the error** with full details:
|
|
462
|
+
- Phase where failure occurred
|
|
463
|
+
- Spec ID
|
|
464
|
+
- Error message from Task agent
|
|
465
|
+
|
|
466
|
+
2. **Record as failed:**
|
|
467
|
+
- Add to specs_failed list with reason: "Agent failure: [phase] - {error message}"
|
|
468
|
+
|
|
469
|
+
3. **Continue execution:**
|
|
470
|
+
- In batch mode: continue to next spec in queue (do not abort the entire batch)
|
|
471
|
+
- In single mode: proceed directly to summary report (Step 9)
|
|
472
|
+
|
|
473
|
+
4. **Leave spec in current state:**
|
|
474
|
+
- Do not archive
|
|
475
|
+
- Do not modify status
|
|
476
|
+
- Leave in `.specflow/specs/` directory
|
|
477
|
+
|
|
478
|
+
## Step 9: Display Summary Report
|
|
479
|
+
|
|
480
|
+
**IMPORTANT:** Output the following directly as formatted text, NOT wrapped in a markdown code block:
|
|
481
|
+
|
|
482
|
+
**Single mode:**
|
|
483
|
+
|
|
484
|
+
```
|
|
485
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
486
|
+
AUTOPILOT COMPLETE
|
|
487
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
488
|
+
|
|
489
|
+
**Mode:** single
|
|
490
|
+
**Spec:** SPEC-XXX
|
|
491
|
+
|
|
492
|
+
### Result
|
|
493
|
+
|
|
494
|
+
**Outcome:** {COMPLETED | HALTED}
|
|
495
|
+
**Audit Cycles:** {count}/{MAX_AUDIT_CYCLES}
|
|
496
|
+
**Fix Cycles:** {count}/{MAX_FIX_CYCLES}
|
|
497
|
+
|
|
498
|
+
{If COMPLETED:}
|
|
499
|
+
✓ Specification processed from {start_status} to done
|
|
500
|
+
- Files created: {count}
|
|
501
|
+
- Files modified: {count}
|
|
502
|
+
- Total commits: {count}
|
|
503
|
+
- Total review cycles: {count}
|
|
504
|
+
|
|
505
|
+
{If HALTED:}
|
|
506
|
+
✗ Halted at phase: {phase}
|
|
507
|
+
Reason: {reason}
|
|
508
|
+
|
|
509
|
+
---
|
|
510
|
+
|
|
511
|
+
## Next Steps
|
|
512
|
+
|
|
513
|
+
{If COMPLETED and queue has more specs:}
|
|
514
|
+
`/sf:autopilot --all` — process remaining queue
|
|
515
|
+
|
|
516
|
+
{If COMPLETED and queue is empty:}
|
|
517
|
+
All specs completed. Queue is empty.
|
|
518
|
+
|
|
519
|
+
{If HALTED:}
|
|
520
|
+
Review spec status with `/sf:status` and `/sf:show SPEC-XXX`.
|
|
521
|
+
Address the issue manually, then resume autopilot.
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
**Batch mode:**
|
|
525
|
+
|
|
526
|
+
```
|
|
527
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
528
|
+
AUTOPILOT COMPLETE
|
|
529
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
530
|
+
|
|
531
|
+
**Mode:** batch
|
|
532
|
+
**Specs Processed:** {count}
|
|
533
|
+
**Specs Completed:** {completed_count}
|
|
534
|
+
**Specs Failed:** {failed_count}
|
|
535
|
+
|
|
536
|
+
### Results
|
|
537
|
+
|
|
538
|
+
| Spec | Title | Outcome | Audit Cycles | Fix Cycles |
|
|
539
|
+
|------|-------|---------|--------------|------------|
|
|
540
|
+
{For each spec in specs_processed:}
|
|
541
|
+
| SPEC-XXX | {title} | COMPLETED | 2 | 1 |
|
|
542
|
+
|
|
543
|
+
{If any failures:}
|
|
544
|
+
### Failures
|
|
545
|
+
|
|
546
|
+
| Spec | Title | Halted At | Reason |
|
|
547
|
+
|------|-------|-----------|--------|
|
|
548
|
+
{For each spec in specs_failed:}
|
|
549
|
+
| SPEC-ZZZ | {title} | {phase} | Fix cycle limit (3/3) |
|
|
550
|
+
|
|
551
|
+
---
|
|
552
|
+
|
|
553
|
+
## Next Steps
|
|
554
|
+
|
|
555
|
+
{If all succeeded and queue empty:}
|
|
556
|
+
All specs processed successfully. Queue is empty.
|
|
557
|
+
|
|
558
|
+
{If all succeeded and queue has more:}
|
|
559
|
+
Queue has {count} remaining specs.
|
|
560
|
+
`/sf:autopilot --all` — process remaining queue
|
|
561
|
+
|
|
562
|
+
{If failures occurred:}
|
|
563
|
+
Failed specs remain in `.specflow/specs/` with their current status.
|
|
564
|
+
Review manually with `/sf:status` and `/sf:show SPEC-ZZZ`.
|
|
565
|
+
Fix issues, then resume with `/sf:autopilot --all`.
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
</workflow>
|
|
569
|
+
|
|
570
|
+
<fallback>
|
|
571
|
+
|
|
572
|
+
If Task agent spawning fails for any phase, the command handles it via Step 8 (Handle Agent Failures).
|
|
573
|
+
|
|
574
|
+
The autopilot does NOT have an inline fallback for agent logic itself — it relies on the specialized agents to execute their phases correctly.
|
|
575
|
+
|
|
576
|
+
**Agent failure handling:**
|
|
577
|
+
1. Log error details (phase, spec ID, error message)
|
|
578
|
+
2. Record spec as failed with reason "Agent failure: [phase]"
|
|
579
|
+
3. In batch mode: continue to next spec
|
|
580
|
+
4. In single mode: proceed to summary report
|
|
581
|
+
5. Leave spec in current state (do not archive or modify status)
|
|
582
|
+
|
|
583
|
+
This ensures one agent failure does not crash the entire autopilot run.
|
|
584
|
+
|
|
585
|
+
</fallback>
|
|
586
|
+
|
|
587
|
+
<success_criteria>
|
|
588
|
+
- [ ] Mode determined correctly (single vs batch)
|
|
589
|
+
- [ ] Configuration constants loaded from config.json
|
|
590
|
+
- [ ] Spec processed from current status through to "done" (single mode)
|
|
591
|
+
- [ ] All actionable specs processed (batch mode)
|
|
592
|
+
- [ ] Audit cycle limit enforced (MAX_AUDIT_CYCLES)
|
|
593
|
+
- [ ] Fix cycle limit enforced (MAX_FIX_CYCLES)
|
|
594
|
+
- [ ] Cycle counters reset when transitioning between major phases
|
|
595
|
+
- [ ] STATE.md decision rotation performed when needed
|
|
596
|
+
- [ ] Summary report displayed with accurate metrics
|
|
597
|
+
- [ ] AskUserQuestion never called by autopilot command itself
|
|
598
|
+
- [ ] STATE.md accurate at every point
|
|
599
|
+
- [ ] No infinite loops possible
|
|
600
|
+
- [ ] Agent failures handled gracefully (do not crash entire run)
|
|
601
|
+
</success_criteria>
|