planflow-ai 1.3.5 → 1.4.3
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/.claude/commands/brainstorm.md +6 -14
- package/.claude/commands/create-contract.md +6 -38
- package/.claude/commands/create-plan.md +18 -38
- package/.claude/commands/discovery-plan.md +19 -49
- package/.claude/commands/execute-plan.md +116 -77
- package/.claude/commands/flow.md +27 -2
- package/.claude/commands/heartbeat.md +12 -14
- package/.claude/commands/learn.md +20 -80
- package/.claude/commands/note.md +6 -23
- package/.claude/commands/resume-work.md +261 -0
- package/.claude/commands/review-code.md +19 -51
- package/.claude/commands/review-pr.md +21 -57
- package/.claude/commands/setup.md +8 -56
- package/.claude/commands/write-tests.md +7 -41
- package/.claude/resources/core/atomic-commits.md +380 -0
- package/.claude/resources/core/autopilot-mode.md +3 -2
- package/.claude/resources/core/compaction-guide.md +15 -1
- package/.claude/resources/core/heartbeat.md +129 -1
- package/.claude/resources/core/per-task-verification.md +362 -0
- package/.claude/resources/core/phase-isolation.md +237 -4
- package/.claude/resources/core/session-scratchpad.md +1 -0
- package/.claude/resources/core/shared-context.md +110 -0
- package/.claude/resources/core/wave-execution.md +407 -0
- package/.claude/resources/patterns/plans-patterns.md +56 -0
- package/.claude/resources/patterns/plans-templates.md +152 -0
- package/.claude/resources/skills/create-plan-skill.md +71 -5
- package/.claude/resources/skills/execute-plan-skill.md +420 -14
- package/.claude/resources/skills/resume-work-skill.md +159 -0
- package/README.md +154 -96
- package/dist/cli/commands/brain.d.ts +20 -0
- package/dist/cli/commands/brain.d.ts.map +1 -0
- package/dist/cli/commands/brain.js +127 -0
- package/dist/cli/commands/brain.js.map +1 -0
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +10 -1
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/state-query.d.ts +13 -0
- package/dist/cli/commands/state-query.d.ts.map +1 -0
- package/dist/cli/commands/state-query.js +32 -0
- package/dist/cli/commands/state-query.js.map +1 -0
- package/dist/cli/commands/state.d.ts +12 -0
- package/dist/cli/commands/state.d.ts.map +1 -0
- package/dist/cli/commands/state.js +47 -0
- package/dist/cli/commands/state.js.map +1 -0
- package/dist/cli/daemon/desktop-notifier.d.ts +16 -0
- package/dist/cli/daemon/desktop-notifier.d.ts.map +1 -0
- package/dist/cli/daemon/desktop-notifier.js +53 -0
- package/dist/cli/daemon/desktop-notifier.js.map +1 -0
- package/dist/cli/daemon/event-writer.d.ts +22 -0
- package/dist/cli/daemon/event-writer.d.ts.map +1 -0
- package/dist/cli/daemon/event-writer.js +76 -0
- package/dist/cli/daemon/event-writer.js.map +1 -0
- package/dist/cli/daemon/heartbeat-daemon.js +81 -1
- package/dist/cli/daemon/heartbeat-daemon.js.map +1 -1
- package/dist/cli/daemon/log-writer.d.ts +17 -0
- package/dist/cli/daemon/log-writer.d.ts.map +1 -0
- package/dist/cli/daemon/log-writer.js +62 -0
- package/dist/cli/daemon/log-writer.js.map +1 -0
- package/dist/cli/daemon/notification-router.d.ts +17 -0
- package/dist/cli/daemon/notification-router.d.ts.map +1 -0
- package/dist/cli/daemon/notification-router.js +35 -0
- package/dist/cli/daemon/notification-router.js.map +1 -0
- package/dist/cli/daemon/prompt-manager.d.ts +27 -0
- package/dist/cli/daemon/prompt-manager.d.ts.map +1 -0
- package/dist/cli/daemon/prompt-manager.js +107 -0
- package/dist/cli/daemon/prompt-manager.js.map +1 -0
- package/dist/cli/daemon/shared-context.d.ts +38 -0
- package/dist/cli/daemon/shared-context.d.ts.map +1 -0
- package/dist/cli/daemon/shared-context.js +129 -0
- package/dist/cli/daemon/shared-context.js.map +1 -0
- package/dist/cli/handlers/claude.d.ts.map +1 -1
- package/dist/cli/handlers/claude.js +18 -0
- package/dist/cli/handlers/claude.js.map +1 -1
- package/dist/cli/handlers/shared.js +1 -1
- package/dist/cli/handlers/shared.js.map +1 -1
- package/dist/cli/index.js +30 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/state/brain-query.d.ts +48 -0
- package/dist/cli/state/brain-query.d.ts.map +1 -0
- package/dist/cli/state/brain-query.js +113 -0
- package/dist/cli/state/brain-query.js.map +1 -0
- package/dist/cli/state/flowconfig-parser.d.ts +16 -0
- package/dist/cli/state/flowconfig-parser.d.ts.map +1 -0
- package/dist/cli/state/flowconfig-parser.js +166 -0
- package/dist/cli/state/flowconfig-parser.js.map +1 -0
- package/dist/cli/state/heartbeat-state.d.ts +16 -0
- package/dist/cli/state/heartbeat-state.d.ts.map +1 -0
- package/dist/cli/state/heartbeat-state.js +97 -0
- package/dist/cli/state/heartbeat-state.js.map +1 -0
- package/dist/cli/state/model-router.d.ts +8 -0
- package/dist/cli/state/model-router.d.ts.map +1 -0
- package/dist/cli/state/model-router.js +36 -0
- package/dist/cli/state/model-router.js.map +1 -0
- package/dist/cli/state/plan-parser.d.ts +16 -0
- package/dist/cli/state/plan-parser.d.ts.map +1 -0
- package/dist/cli/state/plan-parser.js +124 -0
- package/dist/cli/state/plan-parser.js.map +1 -0
- package/dist/cli/state/session-state.d.ts +21 -0
- package/dist/cli/state/session-state.d.ts.map +1 -0
- package/dist/cli/state/session-state.js +36 -0
- package/dist/cli/state/session-state.js.map +1 -0
- package/dist/cli/state/state-md-parser.d.ts +18 -0
- package/dist/cli/state/state-md-parser.d.ts.map +1 -0
- package/dist/cli/state/state-md-parser.js +222 -0
- package/dist/cli/state/state-md-parser.js.map +1 -0
- package/dist/cli/state/types.d.ts +137 -0
- package/dist/cli/state/types.d.ts.map +1 -0
- package/dist/cli/state/types.js +8 -0
- package/dist/cli/state/types.js.map +1 -0
- package/dist/cli/state/wave-calculator.d.ts +18 -0
- package/dist/cli/state/wave-calculator.d.ts.map +1 -0
- package/dist/cli/state/wave-calculator.js +134 -0
- package/dist/cli/state/wave-calculator.js.map +1 -0
- package/dist/cli/types.d.ts +15 -0
- package/dist/cli/types.d.ts.map +1 -1
- package/package.json +7 -2
- package/templates/shared/CLAUDE.md.template +4 -0
- package/.claude/resources/core/_index.md +0 -304
- package/.claude/resources/languages/_index.md +0 -76
- package/.claude/resources/patterns/_index.md +0 -200
- package/.claude/resources/skills/_index.md +0 -285
- package/.claude/resources/tools/_index.md +0 -110
- package/.claude/resources/tools/reference-expansion-tool.md +0 -326
|
@@ -9,6 +9,7 @@ This skill **implements the plan** by:
|
|
|
9
9
|
|
|
10
10
|
- Reading and parsing the plan file
|
|
11
11
|
- Grouping phases by complexity
|
|
12
|
+
- Analyzing dependencies and grouping into parallel waves (when enabled)
|
|
12
13
|
- Switching to Plan mode for each phase
|
|
13
14
|
- Implementing after user approval
|
|
14
15
|
- Updating progress in the plan file
|
|
@@ -149,9 +150,41 @@ Execution Groups:
|
|
|
149
150
|
|
|
150
151
|
---
|
|
151
152
|
|
|
153
|
+
### Step 2b: Wave Analysis (Wave Execution)
|
|
154
|
+
|
|
155
|
+
**Condition**: Only run this step when `wave_execution` is `true` in `flow/.flowconfig` (default: `true`). If `wave_execution` is `false` or the key is missing, skip entirely — proceed to Step 3 with sequential grouping only.
|
|
156
|
+
|
|
157
|
+
Read `.claude/resources/core/wave-execution.md` for the full system reference.
|
|
158
|
+
|
|
159
|
+
1. **Parse Dependencies**: For each phase, look for a `**Dependencies**:` line:
|
|
160
|
+
- `Phase 1, Phase 3` → depends on those phases completing first
|
|
161
|
+
- `None` → explicitly independent, can run in Wave 1 (if no other constraints)
|
|
162
|
+
- Missing field → implicit dependency on Phase N-1 (Phase 1 has no implicit dependency)
|
|
163
|
+
- Self-references and references to non-existent phases are ignored (warn on non-existent)
|
|
164
|
+
|
|
165
|
+
2. **Build dependency graph**: Map each phase to its dependency set (after applying defaults).
|
|
166
|
+
|
|
167
|
+
3. **Topological sort → assign wave numbers**:
|
|
168
|
+
- Phases with no dependencies → Wave 1
|
|
169
|
+
- For each remaining phase: `wave = max(wave of each dependency) + 1`
|
|
170
|
+
- Tests phase exception: Move to its own final wave regardless of computed wave number
|
|
171
|
+
- On circular dependency: warn user and **fall back to sequential execution**
|
|
172
|
+
|
|
173
|
+
4. **Apply aggregation to waves**: If phases within the same wave are adjacent and their combined complexity ≤ 6, aggregate them into a single sub-agent call (same aggregation rules as Step 2). Aggregated phases share one wave slot and one dependency set (union of all their dependencies).
|
|
174
|
+
|
|
175
|
+
5. **Estimate speedup**: Compare number of sequential phases vs number of waves.
|
|
176
|
+
|
|
177
|
+
6. **Store wave plan** for use in Steps 3 and 4.
|
|
178
|
+
|
|
179
|
+
**Backward compatibility**: Plans without any `Dependencies` fields produce a fully sequential wave plan (one phase per wave). This matches existing behavior exactly — no regression.
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
152
183
|
### Step 3: Present Execution Plan Summary
|
|
153
184
|
|
|
154
|
-
Before starting, present the execution plan to the user
|
|
185
|
+
Before starting, present the execution plan to the user.
|
|
186
|
+
|
|
187
|
+
**When wave execution is disabled** (or wave plan is fully sequential), present the standard summary:
|
|
155
188
|
|
|
156
189
|
```markdown
|
|
157
190
|
## Execution Plan Summary
|
|
@@ -174,6 +207,36 @@ Before starting, present the execution plan to the user:
|
|
|
174
207
|
Ready to begin execution?
|
|
175
208
|
```
|
|
176
209
|
|
|
210
|
+
**When wave execution is enabled** and the wave plan contains at least one wave with multiple phases, present the wave execution summary:
|
|
211
|
+
|
|
212
|
+
```markdown
|
|
213
|
+
## Execution Plan Summary
|
|
214
|
+
|
|
215
|
+
**Plan**: [Plan Name]
|
|
216
|
+
**Total Phases**: X
|
|
217
|
+
**Total Complexity**: XX/XX
|
|
218
|
+
**Execution Mode**: Wave-based parallel
|
|
219
|
+
|
|
220
|
+
### Wave Execution Plan:
|
|
221
|
+
|
|
222
|
+
| Wave | Phases | Parallel |
|
|
223
|
+
|------|--------|----------|
|
|
224
|
+
| 1 | Phase 1: Types, Phase 2: Utilities | Yes (2 parallel) |
|
|
225
|
+
| 2 | Phase 3: API Integration | No (1 phase) |
|
|
226
|
+
| 3 | Phase 4: Config Updates | No (1 phase) |
|
|
227
|
+
| 4 | Phase 5: Tests | No (always sequential) |
|
|
228
|
+
|
|
229
|
+
**Sequential phases**: 5 → **Waves**: 4 → **Estimated speedup**: ~20%
|
|
230
|
+
**Build Verification**: Only at the end, after ALL phases complete
|
|
231
|
+
|
|
232
|
+
Proceed with wave execution? (yes/no/sequential)
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
User response options for wave execution:
|
|
236
|
+
- **yes**: Execute with wave parallelism
|
|
237
|
+
- **no**: Stop execution
|
|
238
|
+
- **sequential**: Fall back to sequential execution (ignore waves, use standard Step 4)
|
|
239
|
+
|
|
177
240
|
Wait for user confirmation before proceeding.
|
|
178
241
|
|
|
179
242
|
---
|
|
@@ -184,6 +247,8 @@ Wait for user confirmation before proceeding.
|
|
|
184
247
|
|
|
185
248
|
**REMINDER**: Do NOT run `npm run build` between phases.
|
|
186
249
|
|
|
250
|
+
#### Step 4 — Sequential Mode (default, or when wave_execution is disabled)
|
|
251
|
+
|
|
187
252
|
**For Each Phase**:
|
|
188
253
|
|
|
189
254
|
1. **Auto-switch to Plan mode** - Call `SwitchMode` tool
|
|
@@ -206,10 +271,156 @@ Wait for user confirmation before proceeding.
|
|
|
206
271
|
- Append `patterns_captured` entries to `flow/resources/pending-patterns.md`
|
|
207
272
|
- Log `decisions` in phase completion message
|
|
208
273
|
- If inline mode (no isolation), capture patterns directly per `.claude/resources/core/pattern-capture.md`
|
|
274
|
+
- **Process task verifications** (if `task_verifications` array is present in the return):
|
|
275
|
+
- Count pass/fail totals and sum repairs applied
|
|
276
|
+
- Display a brief verification summary after the phase completion message:
|
|
277
|
+
```
|
|
278
|
+
Task Verification: X/Y passed | Z repairs applied
|
|
279
|
+
```
|
|
280
|
+
- If any task verification has `status: "fail"`, present each failed task with its last diagnosis and offer options:
|
|
281
|
+
```
|
|
282
|
+
⚠️ Task verification failed after N retries:
|
|
283
|
+
**Task**: <task description>
|
|
284
|
+
**Command**: <verify command>
|
|
285
|
+
**Last diagnosis**: <root_cause from last_diagnosis>
|
|
286
|
+
**Category**: <category from last_diagnosis>
|
|
287
|
+
|
|
288
|
+
Options:
|
|
289
|
+
1. Continue with remaining phases (issue noted)
|
|
290
|
+
2. Stop and fix manually
|
|
291
|
+
```
|
|
209
292
|
8. **Update progress** - Mark tasks complete in plan file
|
|
293
|
+
- **Note**: Sub-agent creates per-task commits directly (if `commit: true`). Coordinator does NOT create a phase-level commit. See `.claude/resources/core/atomic-commits.md` for commit format: `feat(phase-N.task-M): <desc> — <feature>`
|
|
210
294
|
9. **Record model used** - Track which model tier was used for this phase (for the completion summary)
|
|
211
295
|
10. **Continue to next phase** - NO BUILD between phases
|
|
212
296
|
|
|
297
|
+
#### Step 4 — Wave Mode (when wave_execution is enabled and user chose "yes")
|
|
298
|
+
|
|
299
|
+
Execute phases **wave by wave**. Within each wave, approve phases sequentially in Plan Mode, then spawn all wave phases as parallel Agent sub-agents.
|
|
300
|
+
|
|
301
|
+
**For Each Wave**:
|
|
302
|
+
|
|
303
|
+
##### 4a. Sequential Approval (Plan Mode)
|
|
304
|
+
|
|
305
|
+
For each phase in the current wave (in phase number order):
|
|
306
|
+
|
|
307
|
+
1. **Auto-switch to Plan mode** - Call `SwitchMode` tool
|
|
308
|
+
2. **Present phase details** - Show scope, tasks, approach, and wave context (e.g., "Wave 2 of 4, running in parallel with Phase 5")
|
|
309
|
+
3. **Wait for approval** - Get user confirmation
|
|
310
|
+
4. **Select model tier** - Same rules as sequential mode (step 4.4 above)
|
|
311
|
+
5. **Inject design context** - Same rules as sequential mode (step 4.5 above)
|
|
312
|
+
|
|
313
|
+
After ALL phases in the wave are approved, proceed to parallel spawning.
|
|
314
|
+
|
|
315
|
+
##### 4b. Parallel Spawning
|
|
316
|
+
|
|
317
|
+
Launch all approved wave phases simultaneously as independent Agent sub-agents:
|
|
318
|
+
|
|
319
|
+
1. **Prepare context for each phase**: Use the phase-isolation context template (see `.claude/resources/core/phase-isolation.md`). Key addition for wave execution: the `Files Modified in Previous Phases` section includes files from ALL completed waves (1 through N-1), not just the immediately preceding phase.
|
|
320
|
+
2. **Inject shared context from sibling phases** (multi-phase waves only):
|
|
321
|
+
- Skip this step for single-phase waves (no siblings to share with)
|
|
322
|
+
- Read `flow/.wave-context.jsonl` (create it if it doesn't exist yet — see wave lifecycle below)
|
|
323
|
+
- Filter entries: include only entries from OTHER phases in the current wave (not the agent's own phase). Also include entries from all previous waves.
|
|
324
|
+
- If there are matching entries, add an inline section in the sub-agent prompt after the phase spec:
|
|
325
|
+
```
|
|
326
|
+
## Shared Context from Sibling Phases
|
|
327
|
+
|
|
328
|
+
The following context entries were published by other phases. Use them to align on shared contracts, types, and architectural decisions.
|
|
329
|
+
|
|
330
|
+
- [phase N] (type: contract) name: UserAPI, signature: GET /users → { id, name, email }
|
|
331
|
+
- [phase N] (type: type_definition) name: UserRecord, fields: { id: string, name: string }
|
|
332
|
+
- [phase N] (type: decision) summary: Using Redis for session caching
|
|
333
|
+
```
|
|
334
|
+
- If no matching entries exist, omit the section entirely
|
|
335
|
+
3. **Spawn all in parallel**: Launch all wave phases simultaneously using Agent sub-agents with their respective model tiers.
|
|
336
|
+
4. **Wait for all to complete**: All sub-agents must return before post-wave processing.
|
|
337
|
+
|
|
338
|
+
**Wave context lifecycle**:
|
|
339
|
+
- **Create** `flow/.wave-context.jsonl` at wave start (before first spawn in Step 4b), if it does not already exist. Start with an empty file.
|
|
340
|
+
- Context entries **accumulate across all waves** — the file is NOT cleared between waves. Later waves benefit from contracts and decisions published by earlier waves.
|
|
341
|
+
- **Delete** `flow/.wave-context.jsonl` after execution completes (Step 7, after build/test verification).
|
|
342
|
+
|
|
343
|
+
##### 4c. Wave Coordinator — Post-Wave Processing
|
|
344
|
+
|
|
345
|
+
After all sub-agents in the wave return, process results **sequentially in phase number order**:
|
|
346
|
+
|
|
347
|
+
1. **Collect JSON returns**: Gather the structured JSON summary from each sub-agent
|
|
348
|
+
2. **Validate JSON**: Parse each return, check for required fields (status, phase, summary, files_created, files_modified)
|
|
349
|
+
3. **Collect context entries**: For each phase's JSON return, check for a `context_entries` array:
|
|
350
|
+
- If `context_entries` is present and non-empty, append each entry to `flow/.wave-context.jsonl` (one JSON object per line)
|
|
351
|
+
- If `context_entries` is absent or empty, treat as empty array — no entries to append
|
|
352
|
+
- Entry format: `{"phase": N, "type": "contract|type_definition|decision", "name": "...", "signature": "...", "fields": "...", "summary": "..."}`
|
|
353
|
+
- These entries become available to phases in subsequent waves via Step 4b
|
|
354
|
+
4. **Detect file conflicts**: Check for `files_modified` overlap between phases in this wave:
|
|
355
|
+
- For each pair of phases (A, B) in the wave: compute `overlap = A.files_modified ∩ B.files_modified`
|
|
356
|
+
- If overlap is not empty → file conflict detected
|
|
357
|
+
5. **Handle file conflicts** (if any):
|
|
358
|
+
- Present the conflicting files and which phases modified them
|
|
359
|
+
- Offer options:
|
|
360
|
+
- **(1) Accept as-is**: Last writer wins (the phase with the higher number committed last)
|
|
361
|
+
- **(2) Re-run conflicting phases sequentially**: Re-execute only the conflicting phases in order
|
|
362
|
+
- **(3) Stop execution**: Halt for manual resolution
|
|
363
|
+
- File conflicts do NOT affect non-conflicting phases — their results are preserved
|
|
364
|
+
6. **Detect contract conflicts**: For each pair of phases (A, B) in the wave, check their `context_entries` for contract entries with the same `name` but different `signature` or `fields`:
|
|
365
|
+
- Compare all entries where `type` is `contract` or `type_definition`
|
|
366
|
+
- If same `name` but different `signature`/`fields` → contract conflict detected
|
|
367
|
+
- Present conflicts and offer resolution (see Contract Conflicts below)
|
|
368
|
+
- Contract conflicts do NOT affect non-conflicting phases — their results are preserved
|
|
369
|
+
7. **Process each phase** (in phase number order):
|
|
370
|
+
- Check `status` field: `success` → continue; `failure` → present errors, ask retry/skip/stop; `partial` → present deviations, ask user
|
|
371
|
+
- Update plan file (mark tasks `[x]`)
|
|
372
|
+
- Accumulate `files_created` and `files_modified` into running list
|
|
373
|
+
- Buffer `patterns_captured` entries to `flow/resources/pending-patterns.md`
|
|
374
|
+
- Git commit if enabled (sequential, one commit **per task** in phase/task order — see `.claude/resources/core/atomic-commits.md`). For each phase (in phase number order), iterate `tasks_completed` and commit: `git add -A && git commit -m "feat(phase-N.task-M): <desc> — <feature>"`
|
|
375
|
+
- Log `decisions` in phase completion message
|
|
376
|
+
|
|
377
|
+
##### Contract Conflicts
|
|
378
|
+
|
|
379
|
+
If contract conflicts are detected (same API name, different signatures):
|
|
380
|
+
|
|
381
|
+
1. Present both versions:
|
|
382
|
+
```
|
|
383
|
+
Warning: Contract conflict detected:
|
|
384
|
+
**API**: GET /users
|
|
385
|
+
|
|
386
|
+
Phase 1 signature: GET /users → { id: string, name: string }
|
|
387
|
+
Phase 3 signature: GET /users → { id: string, name: string, email: string }
|
|
388
|
+
|
|
389
|
+
Options:
|
|
390
|
+
1. Use Phase 1's version
|
|
391
|
+
2. Use Phase 3's version
|
|
392
|
+
3. Stop execution for manual resolution
|
|
393
|
+
```
|
|
394
|
+
2. Apply the chosen version: update the corresponding entry in `flow/.wave-context.jsonl` so subsequent waves see the resolved contract
|
|
395
|
+
3. Contract conflicts do NOT affect non-conflicting phases — only the conflicting contract entries need resolution
|
|
396
|
+
|
|
397
|
+
8. **Report wave completion**: Present summary of all phases in this wave, including task verification stats:
|
|
398
|
+
- For each phase in the wave that returned `task_verifications`, include pass/fail counts and repairs applied
|
|
399
|
+
- Wave completion report template:
|
|
400
|
+
```
|
|
401
|
+
Wave N complete: X phases finished
|
|
402
|
+
- Phase A: success (Task Verification: 3/3 passed | 1 repair applied)
|
|
403
|
+
- Phase B: success (no verifications)
|
|
404
|
+
- Phase C: partial (Task Verification: 2/3 passed, 1 failed | 0 repairs applied)
|
|
405
|
+
```
|
|
406
|
+
- If any task verification failed, display the failed task details (same format as sequential mode step 7)
|
|
407
|
+
|
|
408
|
+
##### 4d. Wave Failure Handling
|
|
409
|
+
|
|
410
|
+
| Scenario | Behavior |
|
|
411
|
+
|----------|----------|
|
|
412
|
+
| One phase fails, others succeed | Process successful phases normally. Present failure to user. Offer: retry failed phase, skip it, or stop. |
|
|
413
|
+
| Multiple phases fail | Process any successful phases. Present all failures. Offer same options per failed phase. |
|
|
414
|
+
| All phases in wave fail | Present all failures. Offer: retry wave, skip wave, or stop. |
|
|
415
|
+
| Sub-agent timeout | Treat as failure for that phase. Other phases unaffected. |
|
|
416
|
+
| Invalid JSON return | Treat as failure for that phase. |
|
|
417
|
+
|
|
418
|
+
**Key rule**: A failed phase in a wave does NOT cancel other phases in the same wave. Parallel phases are independent — let them all complete.
|
|
419
|
+
|
|
420
|
+
##### 4e. Continue to Next Wave
|
|
421
|
+
|
|
422
|
+
After post-wave processing is complete (all commits done, failures handled), proceed to the next wave. Repeat from Step 4a.
|
|
423
|
+
|
|
213
424
|
**Phase Presentation Template**:
|
|
214
425
|
|
|
215
426
|
```markdown
|
|
@@ -218,6 +429,8 @@ Wait for user confirmation before proceeding.
|
|
|
218
429
|
**Complexity**: X/10
|
|
219
430
|
**Scope**: [Phase scope description]
|
|
220
431
|
**Design Context**: Available / Not applicable
|
|
432
|
+
**Wave**: [Wave N of M] / [Sequential]
|
|
433
|
+
**Parallel with**: [Phase Y, Phase Z] / [None]
|
|
221
434
|
|
|
222
435
|
### Tasks to Complete:
|
|
223
436
|
- [ ] Task 1
|
|
@@ -240,6 +453,20 @@ Wait for user confirmation before proceeding.
|
|
|
240
453
|
|
|
241
454
|
---
|
|
242
455
|
|
|
456
|
+
### Step 4f: STATE.md Phase Lifecycle Updates
|
|
457
|
+
|
|
458
|
+
Update `flow/STATE.md` at each phase transition to enable session resumability:
|
|
459
|
+
|
|
460
|
+
1. **Before phase starts**: Update `Current Phase: {N} — {Phase Name}`, `Current Task: first task`, `Next Action: Implement phase {N}`
|
|
461
|
+
2. **During phase** (inline mode only): Update `Current Task` as tasks progress; append decisions/blockers as they occur
|
|
462
|
+
3. **After phase completes**: Append to `Completed Phases`: `Phase N: Name — {outcome}`. Set `Current Phase: none`, `Current Task: none`. Append new files to `Files Modified`. Set `Next Action: Begin phase {N+1}` (or `Run build verification` if last phase)
|
|
463
|
+
4. **On phase failure**: Append to `Blockers`: `Phase {N} failed: {error} (status: open, tried: {attempts})`
|
|
464
|
+
5. **Wave mode**: Update STATE.md once before each wave (set current wave phases) and once after each wave completes (batch-update completed phases)
|
|
465
|
+
|
|
466
|
+
**Important**: In isolation mode, the coordinator (main session) handles STATE.md updates — sub-agents do not write to STATE.md.
|
|
467
|
+
|
|
468
|
+
---
|
|
469
|
+
|
|
243
470
|
### Step 5: Update Progress After Each Phase
|
|
244
471
|
|
|
245
472
|
Mark completed tasks in the plan file:
|
|
@@ -251,6 +478,8 @@ Mark completed tasks in the plan file:
|
|
|
251
478
|
|
|
252
479
|
Then continue to the next phase (NO BUILD HERE).
|
|
253
480
|
|
|
481
|
+
**Note**: In wave mode, progress updates happen during post-wave processing (Step 4c.5) rather than after each individual phase spawn. The coordinator handles updates sequentially in phase order after all wave sub-agents return.
|
|
482
|
+
|
|
254
483
|
---
|
|
255
484
|
|
|
256
485
|
### Step 5b: Phase-Boundary Context Check
|
|
@@ -262,16 +491,19 @@ Then continue to the next phase (NO BUILD HERE).
|
|
|
262
491
|
- Multiple phases completed and more remain
|
|
263
492
|
- You're about to start a complex phase (complexity >= 6)
|
|
264
493
|
|
|
494
|
+
**In wave mode**: Compact at **wave boundaries** (between waves), not between phases within a wave. Include wave progress in the compact summary.
|
|
495
|
+
|
|
265
496
|
**How to compact at a phase boundary**:
|
|
266
497
|
|
|
267
498
|
Run `/compact` with instructions that preserve execution state:
|
|
268
499
|
|
|
269
500
|
```
|
|
270
|
-
/compact Executing plan: [plan file path]. Completed phases: [list]. Next
|
|
501
|
+
/compact Executing plan: [plan file path]. Completed phases: [list]. Completed waves: [N of M]. Next wave: [wave N, phases: list]. Key files modified: [list]. Active tasklist items: [list from flow/tasklist.md]. Resume execution from wave [N] / phase [N].
|
|
271
502
|
```
|
|
272
503
|
|
|
273
504
|
**Rules**:
|
|
274
505
|
- NEVER compact mid-phase — only at phase boundaries (between phases)
|
|
506
|
+
- In wave mode, NEVER compact mid-wave — only at wave boundaries (between waves)
|
|
275
507
|
- Always include enough context in the compact instructions to resume
|
|
276
508
|
- After compaction, re-read the plan file and continue from the next phase
|
|
277
509
|
- In autopilot mode, compact automatically without asking — this is a maintenance action, not a user decision
|
|
@@ -291,6 +523,8 @@ The Tests phase is **always executed separately**, regardless of complexity scor
|
|
|
291
523
|
5. Implement tests
|
|
292
524
|
6. **DO NOT run tests yet** - Continue to Step 7
|
|
293
525
|
|
|
526
|
+
**Wave mode note**: The tests phase always runs alone in its own final wave. This is enforced during wave analysis (Step 2b.3) — the tests phase is moved to a dedicated final wave regardless of its computed wave number.
|
|
527
|
+
|
|
294
528
|
---
|
|
295
529
|
|
|
296
530
|
### Step 7b: Pattern Review
|
|
@@ -304,6 +538,82 @@ After all phases are complete but **before** build/test verification, run the pa
|
|
|
304
538
|
|
|
305
539
|
See `.claude/resources/core/pattern-capture.md` for the full end-of-skill review protocol.
|
|
306
540
|
|
|
541
|
+
### Step 7c: Auto-PR Creation
|
|
542
|
+
|
|
543
|
+
After pattern review completes, optionally create and push a Pull Request if enabled:
|
|
544
|
+
|
|
545
|
+
1. **Check if PR creation is enabled**: Read `flow/.flowconfig` and look for `pr: true`
|
|
546
|
+
- If `pr` is not set or is `false`, skip this entire step
|
|
547
|
+
- If `pr: true`, proceed to branch creation
|
|
548
|
+
|
|
549
|
+
2. **Create and push feature branch**:
|
|
550
|
+
- Sanitize feature name: Convert plan name to lowercase, replace spaces and special characters (except hyphens) with hyphens, trim leading/trailing hyphens
|
|
551
|
+
- Example: "Add User Authentication" → `add-user-authentication`, "Feature (WIP)" → `feature-wip`
|
|
552
|
+
- Create branch: `git checkout -b feat/<sanitized-feature-name>`
|
|
553
|
+
- Check for pre-existing branch: If the branch already exists, warn the user and skip branch creation — proceed with PR creation using the existing branch
|
|
554
|
+
- Push branch: `git push -u origin feat/<sanitized-feature-name>`
|
|
555
|
+
|
|
556
|
+
3. **Determine base branch**:
|
|
557
|
+
- Read `flow/.flowconfig` and check for `branch` setting
|
|
558
|
+
- If `branch` is set, use that as the base branch
|
|
559
|
+
- If `branch` is not set, detect the repository's default branch:
|
|
560
|
+
```bash
|
|
561
|
+
gh repo view --json defaultBranchRef -q '.defaultBranchRef.name'
|
|
562
|
+
```
|
|
563
|
+
- If `gh` CLI is not found or the command fails, default to `main`
|
|
564
|
+
|
|
565
|
+
4. **Create Pull Request**:
|
|
566
|
+
- Title format: `feat: <plan-name>` (use the plan's name from the plan file)
|
|
567
|
+
- Body format: Include plan overview and list of completed phases:
|
|
568
|
+
```markdown
|
|
569
|
+
## Overview
|
|
570
|
+
<Summary of the plan>
|
|
571
|
+
|
|
572
|
+
## Completed Phases
|
|
573
|
+
- Phase 1: <Phase Name>
|
|
574
|
+
- Phase 2: <Phase Name>
|
|
575
|
+
- Phase 3: <Phase Name>
|
|
576
|
+
```
|
|
577
|
+
- Command:
|
|
578
|
+
```bash
|
|
579
|
+
gh pr create --base <base-branch> --head feat/<sanitized-feature-name> --title "feat: <plan-name>" --body "<body>"
|
|
580
|
+
```
|
|
581
|
+
- Capture the PR URL from the command output (format: `https://github.com/<owner>/<repo>/pull/<number>`)
|
|
582
|
+
|
|
583
|
+
5. **Handle PR creation errors gracefully**:
|
|
584
|
+
- If `gh` CLI is not found or not installed, warn the user: `⚠️ GitHub CLI (gh) not found. Please create a PR manually: git push -u origin feat/<branch-name>`
|
|
585
|
+
- If `gh pr create` fails with any error, warn the user with the error message and continue: `⚠️ Failed to create PR: <error message>. You can create it manually on GitHub.`
|
|
586
|
+
- This is a best-effort feature — do not block execution if PR creation fails
|
|
587
|
+
|
|
588
|
+
6. **Store PR URL**: If PR is created successfully, store the URL for use in Step 7 completion summary
|
|
589
|
+
|
|
590
|
+
**Branch Naming Convention**:
|
|
591
|
+
|
|
592
|
+
Feature branches follow the pattern: `feat/<sanitized-feature-name>`
|
|
593
|
+
|
|
594
|
+
Sanitization rules:
|
|
595
|
+
- Convert to lowercase
|
|
596
|
+
- Replace spaces with hyphens
|
|
597
|
+
- Replace special characters (`/`, `\`, `.`, `@`, etc.) with hyphens (except leading/trailing)
|
|
598
|
+
- Collapse consecutive hyphens into a single hyphen
|
|
599
|
+
- Trim leading and trailing hyphens
|
|
600
|
+
- Result must be a valid git branch name
|
|
601
|
+
|
|
602
|
+
**PR Metadata**:
|
|
603
|
+
|
|
604
|
+
- **Title**: `feat: <plan-name>` — descriptive, follows conventional commits
|
|
605
|
+
- **Body**: Structured markdown with Overview and Completed Phases sections
|
|
606
|
+
- **Base branch**: Either from `.flowconfig` `branch` setting or detected default
|
|
607
|
+
- **Head branch**: `feat/<sanitized-feature-name>`
|
|
608
|
+
|
|
609
|
+
**Notification Enrichment**:
|
|
610
|
+
|
|
611
|
+
When a PR is successfully created, the completion notification event message should be enriched with the PR URL:
|
|
612
|
+
- Without PR: `"All done — plan execution complete"`
|
|
613
|
+
- With PR: `"All done — PR: https://github.com/owner/repo/pull/123"`
|
|
614
|
+
|
|
615
|
+
This allows users to quickly jump to the PR from notifications without needing to search for it.
|
|
616
|
+
|
|
307
617
|
---
|
|
308
618
|
|
|
309
619
|
### Step 7: Completion - Build and Test Verification
|
|
@@ -312,33 +622,65 @@ See `.claude/resources/core/pattern-capture.md` for the full end-of-skill review
|
|
|
312
622
|
|
|
313
623
|
After ALL phases are complete (including Tests phase):
|
|
314
624
|
|
|
315
|
-
1. **
|
|
625
|
+
1. **Clean up shared context**: If `flow/.wave-context.jsonl` exists, delete it. This file is ephemeral and should not persist after execution completes.
|
|
626
|
+
|
|
627
|
+
2. **Run final verification**:
|
|
316
628
|
|
|
317
629
|
```bash
|
|
318
630
|
npm run build && npm run test
|
|
319
631
|
```
|
|
320
632
|
|
|
321
|
-
|
|
633
|
+
3. **Handle failures**:
|
|
322
634
|
- If build fails: Fix the issue, re-run verification
|
|
323
635
|
- If tests fail: Fix the issue, re-run verification
|
|
324
636
|
- Only proceed after everything passes
|
|
325
637
|
|
|
326
|
-
|
|
638
|
+
4. **Present summary** of completed work, including model routing and wave execution info if enabled:
|
|
639
|
+
|
|
640
|
+
**Sequential mode summary**:
|
|
327
641
|
|
|
328
642
|
```markdown
|
|
329
|
-
| Phase | Complexity | Model | Status |
|
|
330
|
-
|
|
331
|
-
| 1. Setup types | 2/10 | haiku | Done |
|
|
332
|
-
| 2. Core logic | 5/10 | sonnet | Done |
|
|
333
|
-
| 3. Integration | 7/10 | opus |
|
|
334
|
-
| 4. Tests | 4/10 | sonnet | Done |
|
|
643
|
+
| Phase | Complexity | Model | Verification | Status |
|
|
644
|
+
|-------|-----------|-------|--------------|--------|
|
|
645
|
+
| 1. Setup types | 2/10 | haiku | 2/2 passed | Done |
|
|
646
|
+
| 2. Core logic | 5/10 | sonnet | 3/3 passed (1 repair) | Done |
|
|
647
|
+
| 3. Integration | 7/10 | opus | 1/2 passed (1 failed) | Partial |
|
|
648
|
+
| 4. Tests | 4/10 | sonnet | — | Done |
|
|
649
|
+
|
|
650
|
+
**Task verification totals**: 8 verified, 7 passed, 1 failed, 1 repair applied
|
|
651
|
+
**Commits**: 8 atomic commits (per-task)
|
|
652
|
+
**Model routing**: Saved ~X% vs all-opus execution
|
|
653
|
+
**PR**: https://github.com/owner/repo/pull/123
|
|
654
|
+
```
|
|
335
655
|
|
|
656
|
+
**Wave mode summary** (when wave execution was used):
|
|
657
|
+
|
|
658
|
+
```markdown
|
|
659
|
+
| Wave | Phases | Parallel | Status |
|
|
660
|
+
|------|--------|----------|--------|
|
|
661
|
+
| 1 | Phase 1: Types (haiku), Phase 2: Utilities (haiku) | Yes (2 parallel) | Done |
|
|
662
|
+
| 2 | Phase 3: API Integration (opus) | No | Done |
|
|
663
|
+
| 3 | Phase 4: Config Updates (sonnet) | No | Done |
|
|
664
|
+
| 4 | Phase 5: Tests (sonnet) | No | Done |
|
|
665
|
+
|
|
666
|
+
**Wave execution stats**:
|
|
667
|
+
- Sequential phases: 5
|
|
668
|
+
- Waves executed: 4
|
|
669
|
+
- Parallel phases: 2 (in Wave 1)
|
|
670
|
+
- File conflicts: 0
|
|
671
|
+
- Contract conflicts: 0
|
|
672
|
+
- Failed phases: 0
|
|
673
|
+
- Estimated speedup: ~20%
|
|
674
|
+
|
|
675
|
+
**Task verification totals**: 8 verified, 7 passed, 1 failed, 1 repair applied
|
|
676
|
+
**Commits**: 8 atomic commits (per-task)
|
|
336
677
|
**Model routing**: Saved ~X% vs all-opus execution
|
|
678
|
+
**PR**: https://github.com/owner/repo/pull/123
|
|
337
679
|
```
|
|
338
680
|
|
|
339
|
-
|
|
681
|
+
5. **List all key changes** made
|
|
340
682
|
|
|
341
|
-
|
|
683
|
+
6. **Ask if the plan should be archived**:
|
|
342
684
|
|
|
343
685
|
```bash
|
|
344
686
|
mv flow/plans/plan_feature_name_v1.md flow/archive/
|
|
@@ -348,6 +690,8 @@ mv flow/plans/plan_feature_name_v1.md flow/archive/
|
|
|
348
690
|
|
|
349
691
|
## Execution Flow Within a Group
|
|
350
692
|
|
|
693
|
+
### Sequential Mode
|
|
694
|
+
|
|
351
695
|
```
|
|
352
696
|
Group 1: Phase 1 + Phase 2 (combined complexity: 5)
|
|
353
697
|
|
|
|
@@ -366,6 +710,39 @@ Group 1: Phase 1 + Phase 2 (combined complexity: 5)
|
|
|
366
710
|
+-- Continue to next group (NO BUILD HERE)
|
|
367
711
|
```
|
|
368
712
|
|
|
713
|
+
### Wave Mode
|
|
714
|
+
|
|
715
|
+
```
|
|
716
|
+
Wave 1: Phase 1 + Phase 2 (parallel, no dependencies)
|
|
717
|
+
|
|
|
718
|
+
+-- APPROVAL PHASE (sequential):
|
|
719
|
+
| +-- AUTO-SWITCH to Plan Mode for Phase 1
|
|
720
|
+
| +-- Present Phase 1 details (Wave 1 of 4, parallel with Phase 2)
|
|
721
|
+
| +-- Get user approval
|
|
722
|
+
| |
|
|
723
|
+
| +-- AUTO-SWITCH to Plan Mode for Phase 2
|
|
724
|
+
| +-- Present Phase 2 details (Wave 1 of 4, parallel with Phase 1)
|
|
725
|
+
| +-- Get user approval
|
|
726
|
+
|
|
|
727
|
+
+-- EXECUTION PHASE (parallel):
|
|
728
|
+
| +-- Create flow/.wave-context.jsonl (if not exists)
|
|
729
|
+
| +-- Read shared context from sibling phases (if multi-phase wave)
|
|
730
|
+
| +-- Spawn Agent: Phase 1 (model: haiku, + shared context) ──┐
|
|
731
|
+
| +-- Spawn Agent: Phase 2 (model: haiku, + shared context) ──┤ (running simultaneously)
|
|
732
|
+
| +-- Wait for all to return ──┘
|
|
733
|
+
|
|
|
734
|
+
+-- POST-WAVE PROCESSING (sequential):
|
|
735
|
+
| +-- Collect JSON returns
|
|
736
|
+
| +-- Collect context_entries → append to .wave-context.jsonl
|
|
737
|
+
| +-- Check for file conflicts
|
|
738
|
+
| +-- Check for contract conflicts (same name, different signature)
|
|
739
|
+
| +-- Process Phase 1 result → update plan → git commit per task
|
|
740
|
+
| +-- Process Phase 2 result → update plan → git commit per task
|
|
741
|
+
| +-- Report wave completion
|
|
742
|
+
|
|
|
743
|
+
+-- Continue to Wave 2 (NO BUILD HERE)
|
|
744
|
+
```
|
|
745
|
+
|
|
369
746
|
---
|
|
370
747
|
|
|
371
748
|
## Complexity-Based Behavior
|
|
@@ -398,6 +775,21 @@ Group 1: Phase 1 + Phase 2 (combined complexity: 5)
|
|
|
398
775
|
|
|
399
776
|
---
|
|
400
777
|
|
|
778
|
+
## Per-Task Verification
|
|
779
|
+
|
|
780
|
+
When plans include tasks with `<verify>` tags, phase sub-agents run targeted verification after each task. If verification fails, a debug sub-agent (haiku) diagnoses the issue and the implementation sub-agent applies repairs automatically (up to `max_verify_retries` attempts, default: 2).
|
|
781
|
+
|
|
782
|
+
The execute-plan skill processes verification results at two levels:
|
|
783
|
+
|
|
784
|
+
1. **Phase level** (Steps 4/4c): After each sub-agent returns, display per-phase verification summaries and present failed tasks to the user
|
|
785
|
+
2. **Completion level** (Step 7): Aggregate verification stats across all phases in the final summary
|
|
786
|
+
|
|
787
|
+
Verification is internal to phase sub-agents — the coordinator and main session see only the `task_verifications` array in the JSON return. Plans without `<verify>` tags work unchanged (backward compatible).
|
|
788
|
+
|
|
789
|
+
See `.claude/resources/core/per-task-verification.md` for the full system reference: verify tag syntax, debug sub-agent prompt template, verification loop flow, JSON schemas, and configuration.
|
|
790
|
+
|
|
791
|
+
---
|
|
792
|
+
|
|
401
793
|
## Error Handling
|
|
402
794
|
|
|
403
795
|
### Build Failures (at Completion)
|
|
@@ -429,6 +821,8 @@ If the user wants to stop execution:
|
|
|
429
821
|
3. The plan can be resumed later from the last completed phase
|
|
430
822
|
4. When resuming, run build verification first
|
|
431
823
|
|
|
824
|
+
**Wave mode cancellation**: If cancelled mid-wave, all running sub-agents complete (cannot be interrupted), but their results are discarded. Progress is saved up to the last fully completed wave.
|
|
825
|
+
|
|
432
826
|
---
|
|
433
827
|
|
|
434
828
|
## Summary of Key Rules
|
|
@@ -438,8 +832,16 @@ If the user wants to stop execution:
|
|
|
438
832
|
| **Auto-switch to Plan mode** | Switch immediately for each phase, no asking |
|
|
439
833
|
| **Build ONLY at end** | `npm run build && npm run test` runs once, after ALL phases |
|
|
440
834
|
| **No intermediate builds** | Never run build between phases or groups |
|
|
441
|
-
| **Tests phase separate** | Always execute Tests phase individually
|
|
835
|
+
| **Tests phase separate** | Always execute Tests phase individually, in its own final wave |
|
|
442
836
|
| **Update progress** | Mark tasks complete in plan file after each phase |
|
|
837
|
+
| **Wave fallback** | When wave_execution disabled or all phases dependent, execute sequentially (no behavior change) |
|
|
838
|
+
| **Approve then spawn** | In wave mode, approve ALL wave phases before spawning any |
|
|
839
|
+
| **Deterministic commits** | Git commits happen per-task in phase/task order after wave completes: `feat(phase-N.task-M): <desc> — <feature>` |
|
|
840
|
+
| **Failures are isolated** | One failed phase does not cancel sibling phases in the same wave |
|
|
841
|
+
| **File conflicts presented** | Never silently resolve file conflicts, always ask the user |
|
|
842
|
+
| **Shared context injected** | Multi-phase waves inject sibling context entries; single-phase waves skip |
|
|
843
|
+
| **Contract conflicts detected** | Same API name with different signatures triggers user resolution |
|
|
844
|
+
| **Wave context is ephemeral** | `.wave-context.jsonl` accumulates across waves, deleted after execution completes |
|
|
443
845
|
|
|
444
846
|
---
|
|
445
847
|
|
|
@@ -449,6 +851,10 @@ If the user wants to stop execution:
|
|
|
449
851
|
| ------------------------------------------- | -------------------------------- |
|
|
450
852
|
| `.claude/resources/patterns/plans-patterns.md` | Plan patterns and rules |
|
|
451
853
|
| `.claude/resources/core/complexity-scoring.md` | Complexity scoring system |
|
|
854
|
+
| `.claude/resources/core/wave-execution.md` | Wave-based parallel execution system |
|
|
855
|
+
| `.claude/resources/core/phase-isolation.md` | Phase isolation and sub-agent spawning |
|
|
856
|
+
| `.claude/resources/core/per-task-verification.md` | Per-task verification system and debug sub-agents |
|
|
452
857
|
| `.claude/resources/tools/plan-mode-tool.md` | Plan mode switching instructions |
|
|
453
858
|
| `flow/plans/` | Input plan documents |
|
|
859
|
+
| `flow/.wave-context.jsonl` | Ephemeral shared context between wave phases (deleted after execution) |
|
|
454
860
|
| `flow/archive/` | Completed plans destination |
|