@curdx/flow 2.2.3 → 2.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/.claude-plugin/marketplace.json +3 -2
  2. package/.claude-plugin/plugin.json +2 -1
  3. package/CHANGELOG.md +4 -566
  4. package/README.md +47 -113
  5. package/agents/flow-adversary.md +1 -0
  6. package/agents/flow-architect.md +9 -36
  7. package/agents/flow-brownfield-analyst.md +7 -18
  8. package/agents/flow-debugger.md +1 -0
  9. package/agents/flow-edge-hunter.md +1 -0
  10. package/agents/flow-executor.md +1 -0
  11. package/agents/flow-planner.md +11 -37
  12. package/agents/flow-product-designer.md +9 -41
  13. package/agents/flow-qa-engineer.md +1 -0
  14. package/agents/flow-researcher.md +9 -45
  15. package/agents/flow-reviewer.md +1 -0
  16. package/agents/flow-security-auditor.md +1 -0
  17. package/agents/flow-triage-analyst.md +1 -0
  18. package/agents/flow-ui-researcher.md +1 -0
  19. package/agents/flow-ux-designer.md +1 -0
  20. package/agents/flow-verifier.md +1 -0
  21. package/cli/doctor-workflow.js +5 -914
  22. package/cli/install-companions.js +8 -8
  23. package/cli/lib/doctor-claude-settings.js +736 -0
  24. package/cli/lib/doctor-runtime-environment.js +196 -0
  25. package/cli/lib/semver.js +14 -0
  26. package/cli/uninstall-actions.js +323 -0
  27. package/cli/uninstall.js +9 -253
  28. package/gates/coverage-audit-gate.md +1 -3
  29. package/gates/tdd-gate.md +0 -6
  30. package/gates/verification-gate.md +1 -5
  31. package/knowledge/artifact-output-discipline.md +24 -0
  32. package/knowledge/artifact-summary-contracts.md +50 -0
  33. package/knowledge/execution-strategies.md +6 -4
  34. package/knowledge/poc-first-workflow.md +2 -6
  35. package/knowledge/spec-driven-development.md +0 -4
  36. package/knowledge/systematic-debugging.md +0 -6
  37. package/knowledge/two-stage-review.md +8 -6
  38. package/knowledge/wave-execution.md +2 -1
  39. package/package.json +2 -2
  40. package/schemas/agent-frontmatter.schema.json +4 -0
  41. package/skills/brownfield-index/SKILL.md +14 -20
  42. package/skills/brownfield-index/references/applicability.md +12 -0
  43. package/skills/brownfield-index/references/handoff.md +8 -0
  44. package/skills/brownfield-index/references/index-contract.md +10 -0
  45. package/skills/browser-qa/SKILL.md +15 -35
  46. package/skills/browser-qa/references/handoff.md +6 -0
  47. package/skills/browser-qa/references/prerequisites.md +10 -0
  48. package/skills/browser-qa/references/qa-contract.md +20 -0
  49. package/skills/cancel/SKILL.md +20 -61
  50. package/skills/cancel/references/destructive-mode.md +17 -0
  51. package/skills/cancel/references/reporting.md +18 -0
  52. package/skills/cancel/references/state-recovery.md +30 -0
  53. package/skills/cancel/references/target-resolution.md +7 -0
  54. package/skills/debug/SKILL.md +23 -87
  55. package/skills/debug/references/context-gathering.md +11 -0
  56. package/skills/debug/references/failure-guard.md +25 -0
  57. package/skills/debug/references/intake.md +12 -0
  58. package/skills/debug/references/phase-workflow.md +34 -0
  59. package/skills/debug/references/reporting.md +20 -0
  60. package/skills/epic/SKILL.md +18 -50
  61. package/skills/epic/references/epic-artifacts.md +20 -0
  62. package/skills/epic/references/epic-intake.md +9 -0
  63. package/skills/epic/references/slice-handoff.md +16 -0
  64. package/skills/fast/SKILL.md +34 -102
  65. package/skills/fast/references/applicability.md +25 -0
  66. package/skills/fast/references/clarification.md +20 -0
  67. package/skills/fast/references/execution-contract.md +56 -0
  68. package/skills/help/SKILL.md +26 -132
  69. package/skills/help/references/dispatch.md +20 -0
  70. package/skills/help/references/overview.md +39 -0
  71. package/skills/help/references/troubleshoot.md +47 -0
  72. package/skills/help/references/workflow.md +37 -0
  73. package/skills/implement/SKILL.md +61 -237
  74. package/skills/implement/references/error-recovery.md +36 -0
  75. package/skills/implement/references/linear-execution.md +32 -0
  76. package/skills/implement/references/preflight.md +43 -0
  77. package/skills/implement/references/progress-contract.md +32 -0
  78. package/skills/implement/references/state-init.md +33 -0
  79. package/skills/implement/references/stop-hook-execution.md +36 -0
  80. package/skills/implement/references/strategy-router.md +38 -0
  81. package/skills/implement/references/subagent-execution.md +43 -0
  82. package/skills/init/SKILL.md +26 -95
  83. package/skills/init/references/gitignore-and-health.md +26 -0
  84. package/skills/init/references/next-steps.md +22 -0
  85. package/skills/init/references/preflight.md +15 -0
  86. package/skills/init/references/scaffold-contract.md +27 -0
  87. package/skills/review/SKILL.md +45 -153
  88. package/skills/review/references/optional-passes.md +48 -0
  89. package/skills/review/references/preflight.md +38 -0
  90. package/skills/review/references/report-contract.md +49 -0
  91. package/skills/review/references/reporting.md +20 -0
  92. package/skills/review/references/stage-execution.md +32 -0
  93. package/skills/security-audit/SKILL.md +16 -34
  94. package/skills/security-audit/references/audit-contract.md +21 -0
  95. package/skills/security-audit/references/gate-handoff.md +8 -0
  96. package/skills/security-audit/references/scope-and-depth.md +9 -0
  97. package/skills/spec/SKILL.md +55 -182
  98. package/skills/spec/references/artifact-landing.md +31 -0
  99. package/skills/spec/references/phase-execution.md +50 -0
  100. package/skills/spec/references/planning-review.md +31 -0
  101. package/skills/spec/references/preflight-and-routing.md +46 -0
  102. package/skills/spec/references/reporting.md +21 -0
  103. package/skills/start/SKILL.md +40 -123
  104. package/skills/start/references/branch-routing.md +51 -0
  105. package/skills/start/references/mode-semantics.md +12 -0
  106. package/skills/start/references/preflight.md +13 -0
  107. package/skills/start/references/reporting.md +20 -0
  108. package/skills/start/references/state-seeding.md +44 -0
  109. package/skills/start/references/workflow-handoff.md +26 -0
  110. package/skills/status/SKILL.md +17 -61
  111. package/skills/status/references/gather-contract.md +27 -0
  112. package/skills/status/references/health-rules.md +27 -0
  113. package/skills/status/references/output-contract.md +24 -0
  114. package/skills/status/references/preflight.md +10 -0
  115. package/skills/status/references/recovery-hints.md +18 -0
  116. package/skills/ui-sketch/SKILL.md +15 -34
  117. package/skills/ui-sketch/references/brief-intake.md +10 -0
  118. package/skills/ui-sketch/references/iteration-handoff.md +5 -0
  119. package/skills/ui-sketch/references/variant-contract.md +15 -0
  120. package/skills/verify/SKILL.md +31 -86
  121. package/skills/verify/references/evidence-workflow.md +39 -0
  122. package/skills/verify/references/output-contract.md +23 -0
  123. package/skills/verify/references/preflight.md +11 -0
  124. package/skills/verify/references/report-handoff.md +35 -0
  125. package/skills/verify/references/strict-mode.md +12 -0
  126. package/README.zh.md +0 -160
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: implement
3
- description: Execute spec tasks the Strategy Router picks linear/subagent/stop-hook/wave based on task characteristics. Atomic commit per task.
3
+ description: Execute active-spec tasks with strategy routing and atomic progress.
4
4
  when_to_use: Use when the active spec already has tasks and the user wants execution, optionally with a chosen strategy or a single task id.
5
5
  argument-hint: "[spec-name] [--strategy=auto|linear|subagent|stop-hook|wave] [--task=<id>] [--quick]"
6
6
  disable-model-invocation: true
@@ -12,261 +12,85 @@ allowed-tools: [Read, Write, Edit, Bash, Agent, Grep, Glob]
12
12
  @${CLAUDE_PLUGIN_ROOT}/knowledge/execution-strategies.md
13
13
  @${CLAUDE_PLUGIN_ROOT}/knowledge/atomic-commits.md
14
14
 
15
- Execute spec tasks per tasks.md. Select the best execution strategy based on arguments and task characteristics.
15
+ This skill is the execution orchestrator. Keep the entrypoint focused on
16
+ preflight, routing, state updates, and stop conditions; load supporting files
17
+ for strategy-specific protocols:
16
18
 
17
- ## Step 1: Preflight Checks
19
+ - `references/preflight.md`
20
+ - `references/strategy-router.md`
21
+ - `references/state-init.md`
22
+ - `references/linear-execution.md`
23
+ - `references/subagent-execution.md`
24
+ - `references/wave-execution.md`
25
+ - `references/stop-hook-execution.md`
26
+ - `references/progress-contract.md`
27
+ - `references/error-recovery.md`
18
28
 
19
- ```bash
20
- [ ! -d ".flow" ] && { echo "✗ Not a CurdX-Flow project. Run /curdx-flow:init first"; exit 1; }
29
+ ## Arguments
21
30
 
22
- ARGS="$ARGUMENTS"
23
- SPEC_NAME=""
24
- STRATEGY="auto"
25
- TASK_ID=""
26
- QUICK=0
31
+ `$ARGUMENTS` may include:
27
32
 
28
- # Simple argument parsing
29
- for arg in $ARGS; do
30
- case "$arg" in
31
- --strategy=*) STRATEGY="${arg#--strategy=}" ;;
32
- --task=*) TASK_ID="${arg#--task=}" ;;
33
- --quick) QUICK=1 ;;
34
- --*) ;; # ignore unknown flags
35
- *) SPEC_NAME="$arg" ;;
36
- esac
37
- done
33
+ - `[spec-name]`
34
+ - `--strategy=auto|linear|subagent|stop-hook|wave`
35
+ - `--task=<id>`
36
+ - `--quick`
38
37
 
39
- [ -z "$SPEC_NAME" ] && SPEC_NAME=$(cat .flow/.active-spec 2>/dev/null)
40
- [ -z "$SPEC_NAME" ] && { echo "✗ No active spec. Run /curdx-flow:start first"; exit 1; }
38
+ ## Preflight and Task Stats
41
39
 
42
- DIR=".flow/specs/$SPEC_NAME"
43
- [ ! -f "$DIR/tasks.md" ] && { echo "✗ Missing tasks.md. Run /curdx-flow:spec first (or /curdx-flow:spec --phase=tasks to rebuild just the tasks phase)"; exit 1; }
44
- ```
40
+ Use `references/preflight.md` for:
45
41
 
46
- ## Step 2: Parse Task Characteristics from tasks.md
42
+ - `.flow/` and active-spec resolution
43
+ - argument parsing
44
+ - `tasks.md` presence checks
45
+ - `TOTAL`, `DONE`, `REMAINING`, `PARALLEL`, and `SEQUENTIAL` extraction
47
46
 
48
- ```bash
49
- TOTAL=$(grep -Ec "^- \[[ xX]\] \*\*" "$DIR/tasks.md")
50
- DONE=$(grep -Ec "^- \[[xX]\] \*\*" "$DIR/tasks.md")
51
- REMAINING=$((TOTAL - DONE))
52
- PARALLEL=$(grep -c "^- \[ \] \*\*.*\[P\]" "$DIR/tasks.md")
53
- SEQUENTIAL=$(grep -c "^- \[ \] \*\*.*\[SEQUENTIAL\]" "$DIR/tasks.md")
47
+ ## Strategy Routing
54
48
 
55
- echo "Task stats: remaining $REMAINING, done $DONE, [P] parallel $PARALLEL, [SEQUENTIAL] serial $SEQUENTIAL"
56
- ```
49
+ Use `references/strategy-router.md` for the full decision tree and routing
50
+ signals. The runtime selector is:
57
51
 
58
- ## Step 3: Strategy Router
52
+ ## Execute State Init
59
53
 
60
- If `STRATEGY=auto` (default), pick via the decision tree:
54
+ Use `references/state-init.md` before dispatching any execution protocol.
61
55
 
62
- ```bash
63
- if [ "$STRATEGY" = "auto" ]; then
64
- if [ $REMAINING -lt 5 ] || [ $SEQUENTIAL -gt $((REMAINING / 2)) ]; then
65
- STRATEGY="linear"
66
- elif [ $PARALLEL -ge $((REMAINING * 4 / 10)) ]; then
67
- STRATEGY="wave"
68
- elif [ $REMAINING -ge 20 ] && [ $QUICK -eq 1 ]; then
69
- STRATEGY="stop-hook"
70
- elif [ $REMAINING -ge 8 ]; then
71
- STRATEGY="subagent"
72
- else
73
- STRATEGY="linear"
74
- fi
75
- fi
56
+ ## Run the Selected Execution Protocol
76
57
 
77
- echo "✓ Selected strategy: $STRATEGY"
78
- ```
58
+ - `linear`: stay inline in the main agent and execute the first unchecked task
59
+ to completion. Full task loop: `references/linear-execution.md`
60
+ - `subagent`: dispatch one isolated `flow-executor` at a time. Full prompt
61
+ contract: `references/subagent-execution.md`
62
+ - `wave`: dispatch multiple Agent calls in parallel within a single response;
63
+ the serial/parallel boundaries and conflict rules live in
64
+ `references/wave-execution.md`
65
+ - `stop-hook`: run one task per round and let the stop watcher decide whether
66
+ to continue. Full continuation contract:
67
+ `references/stop-hook-execution.md`
79
68
 
80
- **Decision tree explanation**:
81
- - Few tasks / strong dependencies → `linear` (main agent executes sequentially)
82
- - Many parallel opportunities → `wave` (parallel Agent dispatch within a wave)
83
- - Long chain + quick mode → `stop-hook` (auto-loop, requires hook support)
84
- - Medium scale → `subagent` (isolated context per task)
69
+ If `STRATEGY` is not one of `linear`, `subagent`, `wave`, `stop-hook`, stop
70
+ immediately rather than guessing.
85
71
 
86
- ## Step 4: Initialize execute_state
72
+ For `subagent` and `wave`, after the agent completes, read the output marker
73
+ defined by the supporting file before mutating state or advancing the task
74
+ cursor.
87
75
 
88
- ```python
89
- import json
90
- p = f'.flow/specs/{SPEC_NAME}/.state.json'
91
- s = json.load(open(p))
92
- try:
93
- cfg = json.load(open('.flow/config.json'))
94
- except Exception:
95
- cfg = {}
96
- execution_cfg = cfg.get('execution', {}) if isinstance(cfg, dict) else {}
97
- recovery_mode = execution_cfg.get('recovery_mode', 'manual')
98
- max_fix_tasks = execution_cfg.get('max_fix_tasks_per_original', 2)
99
- s['phase'] = 'execute'
100
- s['strategy'] = STRATEGY
101
- s.setdefault('phase_status', {})['execute'] = 'in_progress'
102
- s.setdefault('execute_state', {})
103
- s['execute_state'].setdefault('task_index', DONE)
104
- s['execute_state']['total_tasks'] = TOTAL
105
- s['execute_state'].setdefault('failed_attempts', 0)
106
- s['execute_state'].setdefault('global_iteration', 1)
107
- s['execute_state'].setdefault('recovery_mode', recovery_mode)
108
- s['execute_state'].setdefault('max_fix_tasks_per_original', max_fix_tasks)
109
- s['execute_state'].setdefault('fix_task_map', {})
110
- if QUICK:
111
- s['quickMode'] = True
112
- json.dump(s, open(p, 'w'), indent=2, ensure_ascii=False)
113
- ```
76
+ ## Progress and Completion Contract
114
77
 
115
- ## Step 5: Execution Strategies
78
+ Use `references/progress-contract.md` for both in-flight progress output and
79
+ the execute-complete summary. Do not claim the feature is shipped from execute
80
+ alone. The primary handoff remains:
116
81
 
117
- ### Strategy: linear
82
+ - `/curdx-flow:verify` for goal-backward evidence
83
+ - `/curdx-flow:review` for code-quality findings after verification
118
84
 
119
- The main agent (you) executes sequentially:
85
+ ## Recovery Rules and Stop Conditions
120
86
 
121
- ```
122
- for task in remaining tasks:
123
- read task fields (Do/Files/Done-when/Verify/Commit)
124
- execute per the flow-executor agent rules:
125
- - follow Karpathy surgical principles
126
- - Verify must pass
127
- - atomic commit
128
- - mark [x]
129
- - update .progress.md
130
- output "✓ Task X.Y complete"
131
- next
132
- output "ALL_TASKS_COMPLETE" when all tasks are done
133
- ```
87
+ All retry, fix-task, and stop thresholds are centralized in
88
+ `references/error-recovery.md`.
134
89
 
135
- If there are 5 failures, stop + TASK_FAILED.
90
+ The stop invariant is strict:
136
91
 
137
- ### Strategy: subagent
138
-
139
- For each remaining task, dispatch flow-executor:
140
-
141
- ```
142
- Agent:
143
- subagent_type: general-purpose
144
- description: "Execute $SPEC_NAME task $TASK_ID"
145
- prompt: |
146
- You are the flow-executor agent. Full definition at:
147
- ${CLAUDE_PLUGIN_ROOT}/agents/flow-executor.md
148
-
149
- Execute task:
150
- spec_name: $SPEC_NAME
151
- task_id: next (or a specific ID)
152
- quick_mode: $QUICK
153
-
154
- Required reading:
155
- - .flow/specs/$SPEC_NAME/tasks.md (locate the task)
156
- - .flow/specs/$SPEC_NAME/.state.json
157
- - .flow/specs/$SPEC_NAME/.progress.md
158
- - .flow/specs/$SPEC_NAME/design.md (if task references AD-NN)
159
- - .flow/specs/$SPEC_NAME/requirements.md (if referencing FR/AC)
160
-
161
- On success output: TASK_COMPLETE: <task_id>
162
- On failure output: TASK_FAILED: <task_id> + Reason
163
-
164
- When all tasks are done output: ALL_TASKS_COMPLETE
165
- ```
166
-
167
- After the agent completes, read the output marker:
168
- - `TASK_COMPLETE` → continue to the next
169
- - `TASK_FAILED` → accumulate failures, stop at >= 3
170
- - `ALL_TASKS_COMPLETE` → mark phase completed
171
-
172
- ### Strategy: wave
173
-
174
- See `skills/implement/references/wave-execution.md` for the full walkthrough.
175
- Knowledge-layer canonical algorithm: `@${CLAUDE_PLUGIN_ROOT}/knowledge/wave-execution.md`.
176
-
177
- **Core**: consecutive `[P]` tasks form a wave; dispatch multiple Agent calls in parallel within a single response; serial across waves. The execution loop is:
178
-
179
- 1. **DAG analysis** — group remaining `[ ]` tasks by `[P]` / `[SEQUENTIAL]` / `[VERIFY]` tags; conflicting `Files` sets split into a new wave.
180
- 2. **Pre-conflict detection** — within each wave, assert per-task `Files` are disjoint; auto-split if not.
181
- 3. **Dispatch** — list multiple `Agent(...)` tool calls in a single main-agent response (splitting across responses = serial degradation; nested `Agent` dispatches forbidden). Each Agent prompt follows the subagent strategy's uniform format (see `references/wave-execution.md` Step 3).
182
- 4. **Aggregate** — parse each result for `TASK_COMPLETE` / `TASK_FAILED`; run post-hoc conflict detection via git diff to confirm executors only touched declared files.
183
- 5. **Failure handling** — 0 failed → next wave; 1 failed → `config.wave_fail_policy` (`continue-on-single` or `stop-on-any`); ≥2 failed → likely environment issue, stop immediately; cumulative `failed_attempts >= 3` → stop, user intervention.
184
- 6. **Progress feedback** — print a wave summary after each wave (see `references/wave-execution.md` Step 6).
185
-
186
- Configuration under `.flow/config.json.execution`: `strategy: "wave"`, `max_parallel: 5` (wave-parallel ceiling), `wave_fail_policy: "continue-on-single" | "stop-on-any"`.
187
-
188
- ### Strategy: stop-hook
189
-
190
- ```
191
- 1. Execute 1 task (dispatch flow-executor, wait for completion)
192
- 2. Do not loop manually — rely on the stop-watcher.sh hook
193
- 3. Stop event triggers → hook checks if there are remaining tasks → injects "continue"
194
- 4. Claude auto-starts next round
195
- 5. Repeat until ALL_TASKS_COMPLETE or 3 failures
196
- ```
197
-
198
- Stop-hook completion is double-checked: `.state.json` must say execute is complete AND `tasks.md` must have zero unchecked tasks. If either disagrees, the hook blocks and resumes the first unchecked task. During a stop-hook continuation, `stop_hook_active=true` is only a context signal; the hook still evaluates transcript signals, `.state.json`, and `tasks.md` parity before deciding whether to continue or stop.
199
-
200
- Prerequisites:
201
- - `--quick` must be set (otherwise AskUserQuestion will block the loop)
202
- - `.flow/config.json` or `.state.json` must have strategy=stop-hook
203
-
204
- ## Step 6: Progress Feedback
205
-
206
- At each wave boundary (or periodically during long linear runs), print status:
207
-
208
- ```
209
- ═════ Progress ═════
210
- Spec: $SPEC_NAME
211
- Strategy: $STRATEGY
212
- Done: X / $TOTAL
213
- Recent commits:
214
- - abc123f feat(auth): ...
215
- - def456g test(auth): ...
216
- ════════════════════
217
- ```
218
-
219
- ## Step 7: Completion Handling
220
-
221
- ```
222
- if all tasks done:
223
- update .state.json:
224
- phase = "verify"
225
- phase_status.execute = "completed"
226
- append .progress.md: "## execute phase complete YYYY-MM-DD"
227
- output "ALL_TASKS_COMPLETE"
228
- suggest next step: /curdx-flow:verify
229
- ```
230
-
231
- ## Error Recovery
232
-
233
- - Verify field in tasks.md is "manual" → stop, suggest re-running `/curdx-flow:spec --phase=tasks --regenerate` to fix
234
- - `TASK_FAILED` default (`recovery_mode: manual`) → do not skip the task; root-cause, retry the first unchecked task, stop at 3 failures
235
- - `TASK_FAILED` with `recovery_mode: fix-task` → insert one targeted `[FIX <task_id>]` task immediately after the failed task, update `execute_state.fix_task_map`, execute that fix task, then retry the original task; never exceed `max_fix_tasks_per_original`
236
- - 3 consecutive TASK_FAILED → stop, prompt for user intervention
237
- - git operation failure → stop immediately, do not continue (avoid state corruption)
238
- - Test framework not found (npm test not found) → stop, suggest running npx @curdx/flow doctor
239
- - State says complete but tasks.md still has unchecked tasks → trust tasks.md, continue remaining unchecked tasks only
240
-
241
- ### Fix-Task Recovery Format
242
-
243
- When enabled, generated recovery tasks must be narrowly scoped and traceable:
244
-
245
- ```markdown
246
- - [ ] **<task_id>.<n>** [FIX <task_id>] Fix: <short root cause>
247
- - **Do**: <specific repair steps>
248
- - **Files**: <same declared files or narrower>
249
- - **Done when**: Original failure no longer reproduces
250
- - **Verify**: <original verify command or tighter reproduction>
251
- - **Commit**: `fix(<scope>): address <failure>`
252
- ```
253
-
254
- Do not execute a newly generated fix task in the same breath that creates it unless the task is already written to `tasks.md` and `fix_task_map` has been updated. The ledger stays ahead of execution.
255
-
256
- ## Output to User
257
-
258
- ```
259
- ✓ execute phase complete: $SPEC_NAME
260
-
261
- Strategy: $STRATEGY
262
- Tasks done: N / N
263
- Commits: M atomic commits
264
- Verify passed: K / K
265
-
266
- Next steps:
267
- - /curdx-flow:verify — goal-driven reverse verification
268
- - /curdx-flow:review — two-stage code review after verification
269
-
270
- Do not claim the feature is shipped from execute alone. Execute completes tasks;
271
- verify proves user-visible goals; review checks implementation quality.
272
- ```
92
+ - Never skip a failed task implicitly
93
+ - Never continue after git-state corruption
94
+ - Stop after 3 consecutive `TASK_FAILED`
95
+ - If `.state.json` says complete but `tasks.md` still has unchecked tasks, trust
96
+ `tasks.md` and continue only the unchecked work
@@ -0,0 +1,36 @@
1
+ # Error Recovery — Failure Policy
2
+
3
+ All implement strategies use the same recovery ledger and stop thresholds.
4
+
5
+ ## Failure Rules
6
+
7
+ - `Verify` field is `manual` or malformed -> stop and suggest
8
+ `/curdx-flow:spec --phase=tasks --regenerate`
9
+ - `TASK_FAILED` with `recovery_mode: manual` -> do not skip the task; root-cause
10
+ it, then retry the first unchecked task
11
+ - `TASK_FAILED` with `recovery_mode: fix-task` -> insert one targeted
12
+ `[FIX <task_id>]` task immediately after the failed task, update
13
+ `execute_state.fix_task_map`, execute that fix task, then retry the original
14
+ task
15
+ - Never exceed `max_fix_tasks_per_original`
16
+ - 3 consecutive `TASK_FAILED` -> stop and require user intervention
17
+ - Git operation failure -> stop immediately to avoid state corruption
18
+ - Missing local test framework -> stop and suggest `npx @curdx/flow doctor`
19
+ - State says complete but `tasks.md` still has unchecked tasks -> trust
20
+ `tasks.md`
21
+
22
+ ## Fix-Task Recovery Format
23
+
24
+ Generated repair tasks must stay narrow and traceable:
25
+
26
+ ```markdown
27
+ - [ ] **<task_id>.<n>** [FIX <task_id>] Fix: <short root cause>
28
+ - **Do**: <specific repair steps>
29
+ - **Files**: <same declared files or narrower>
30
+ - **Done when**: Original failure no longer reproduces
31
+ - **Verify**: <original verify command or tighter reproduction>
32
+ - **Commit**: `fix(<scope>): address <failure>`
33
+ ```
34
+
35
+ Do not execute a newly generated fix task until both `tasks.md` and
36
+ `fix_task_map` have been updated. The ledger must move ahead of execution.
@@ -0,0 +1,32 @@
1
+ # Linear Execution — Inline Task Loop
2
+
3
+ Use this mode when the backlog is small, heavily sequential, or the operator
4
+ needs maximum visibility in the main session.
5
+
6
+ ## Main Loop
7
+
8
+ ```text
9
+ for task in remaining tasks:
10
+ read task fields (Do / Files / Done when / Verify / Commit)
11
+ execute the task inline in the current session
12
+ run the task's Verify command
13
+ make the atomic commit declared by the task
14
+ mark the task [x] in tasks.md
15
+ append the outcome to .progress.md
16
+ print "✓ Task X.Y complete"
17
+ ```
18
+
19
+ ## Execution Rules
20
+
21
+ - Follow the `flow-executor` contract even though you stay inline
22
+ - Respect the declared `Files` scope; do not quietly expand task boundaries
23
+ - Verification must pass before the task can be marked complete
24
+ - One task, one atomic commit
25
+ - If the task is too broad or unsafe, stop and surface `TASK_FAILED` semantics
26
+ instead of improvising extra subtasks
27
+
28
+ ## Stop Conditions
29
+
30
+ - Any git operation failure: stop immediately
31
+ - Missing or invalid Verify command: stop and ask for a task regeneration
32
+ - 3 consecutive `TASK_FAILED`: stop and require intervention
@@ -0,0 +1,43 @@
1
+ # Implement Preflight — Resolve Scope and Task Stats
2
+
3
+ Before selecting a strategy:
4
+
5
+ ```bash
6
+ [ ! -d ".flow" ] && { echo "✗ Not a CurdX-Flow project. Run /curdx-flow:init first"; exit 1; }
7
+
8
+ ARGS="$ARGUMENTS"
9
+ SPEC_NAME=""
10
+ STRATEGY="auto"
11
+ TASK_ID=""
12
+ QUICK=0
13
+
14
+ for arg in $ARGS; do
15
+ case "$arg" in
16
+ --strategy=*) STRATEGY="${arg#--strategy=}" ;;
17
+ --task=*) TASK_ID="${arg#--task=}" ;;
18
+ --quick) QUICK=1 ;;
19
+ --*) ;;
20
+ *) SPEC_NAME="$arg" ;;
21
+ esac
22
+ done
23
+
24
+ [ -z "$SPEC_NAME" ] && SPEC_NAME=$(cat .flow/.active-spec 2>/dev/null)
25
+ [ -z "$SPEC_NAME" ] && { echo "✗ No active spec. Run /curdx-flow:start first"; exit 1; }
26
+
27
+ DIR=".flow/specs/$SPEC_NAME"
28
+ [ ! -f "$DIR/tasks.md" ] && { echo "✗ Missing tasks.md. Run /curdx-flow:spec first (or /curdx-flow:spec --phase=tasks to rebuild just the tasks phase)"; exit 1; }
29
+
30
+ TOTAL=$(grep -Ec "^- \[[ xX]\] \*\*" "$DIR/tasks.md")
31
+ DONE=$(grep -Ec "^- \[[xX]\] \*\*" "$DIR/tasks.md")
32
+ REMAINING=$((TOTAL - DONE))
33
+ PARALLEL=$(grep -c "^- \[ \] \*\*.*\[P\]" "$DIR/tasks.md")
34
+ SEQUENTIAL=$(grep -c "^- \[ \] \*\*.*\[SEQUENTIAL\]" "$DIR/tasks.md")
35
+ ```
36
+
37
+ These counters are part of the runtime contract:
38
+
39
+ - `TOTAL` = all declared task rows
40
+ - `DONE` = checked task rows
41
+ - `REMAINING` = `TOTAL - DONE`
42
+ - `PARALLEL` = unchecked `[P]` tasks
43
+ - `SEQUENTIAL` = unchecked `[SEQUENTIAL]` tasks
@@ -0,0 +1,32 @@
1
+ # Implement Progress Contract — Mid-Run and Completion Output
2
+
3
+ At each wave boundary, retry, or long linear stretch, print:
4
+
5
+ ```text
6
+ ═════ Progress ═════
7
+ Spec: $SPEC_NAME
8
+ Strategy: $STRATEGY
9
+ Done: X / $TOTAL
10
+ Recent commits:
11
+ - abc123f feat(auth): ...
12
+ - def456g test(auth): ...
13
+ ════════════════════
14
+ ```
15
+
16
+ When all tasks are complete:
17
+
18
+ ```text
19
+ ✓ execute phase complete: $SPEC_NAME
20
+
21
+ Strategy: $STRATEGY
22
+ Tasks done: N / N
23
+ Commits: M atomic commits
24
+ Verify passed: K / K
25
+
26
+ Next steps:
27
+ - /curdx-flow:verify — goal-driven reverse verification
28
+ - /curdx-flow:review — two-stage code review after verification
29
+ ```
30
+
31
+ Do not claim the feature is shipped from execute alone. Execute completes
32
+ tasks; verify proves user-visible goals; review checks implementation quality.
@@ -0,0 +1,33 @@
1
+ # Implement State Init — Seed execute_state Before Running
2
+
3
+ After strategy selection and before execution begins:
4
+
5
+ ```python
6
+ import json
7
+ p = f'.flow/specs/{SPEC_NAME}/.state.json'
8
+ s = json.load(open(p))
9
+ try:
10
+ cfg = json.load(open('.flow/config.json'))
11
+ except Exception:
12
+ cfg = {}
13
+ execution_cfg = cfg.get('execution', {}) if isinstance(cfg, dict) else {}
14
+ recovery_mode = execution_cfg.get('recovery_mode', 'manual')
15
+ max_fix_tasks = execution_cfg.get('max_fix_tasks_per_original', 2)
16
+ s['phase'] = 'execute'
17
+ s['strategy'] = STRATEGY
18
+ s.setdefault('phase_status', {})['execute'] = 'in_progress'
19
+ s.setdefault('execute_state', {})
20
+ s['execute_state'].setdefault('task_index', DONE)
21
+ s['execute_state']['total_tasks'] = TOTAL
22
+ s['execute_state'].setdefault('failed_attempts', 0)
23
+ s['execute_state'].setdefault('global_iteration', 1)
24
+ s['execute_state'].setdefault('recovery_mode', recovery_mode)
25
+ s['execute_state'].setdefault('max_fix_tasks_per_original', max_fix_tasks)
26
+ s['execute_state'].setdefault('fix_task_map', {})
27
+ if QUICK:
28
+ s['quickMode'] = True
29
+ json.dump(s, open(p, 'w'), indent=2, ensure_ascii=False)
30
+ ```
31
+
32
+ The execute-state ledger must be initialized before any task dispatch so hooks,
33
+ recovery, and status views observe the same state transition.
@@ -0,0 +1,36 @@
1
+ # Stop-Hook Execution — Hook-Driven Continuation
2
+
3
+ Use this mode for long unattended runs where each execution round should end
4
+ naturally and the hook layer decides whether Claude continues.
5
+
6
+ ## Protocol
7
+
8
+ ```text
9
+ 1. Execute 1 task (inline or via flow-executor, then wait for completion)
10
+ 2. End the response naturally
11
+ 3. stop-watcher.sh evaluates transcript markers, .state.json, and tasks.md
12
+ 4. If unchecked tasks remain, the hook blocks stop and injects continuation
13
+ 5. Repeat until ALL_TASKS_COMPLETE or recovery forces a halt
14
+ ```
15
+
16
+ ## Completion Invariant
17
+
18
+ Stop-hook completion is double-checked:
19
+
20
+ - `.state.json` must say execute is complete
21
+ - `tasks.md` must have zero unchecked tasks
22
+
23
+ If either side disagrees, the hook resumes the first unchecked task instead of
24
+ allowing the session to stop cleanly.
25
+
26
+ ## Prerequisites
27
+
28
+ - `--quick` should be set; otherwise `AskUserQuestion` can stall the loop
29
+ - `.flow/config.json` or `.state.json` should pin `strategy=stop-hook`
30
+ - The hook layer must remain the final authority for continuation
31
+
32
+ ## Context Signal
33
+
34
+ During a stop-hook continuation, `stop_hook_active=true` is only a hint. The
35
+ hook still checks transcript signals, `.state.json`, and `tasks.md` parity
36
+ before deciding whether to continue or stop.
@@ -0,0 +1,38 @@
1
+ # Strategy Router — Selection Rules
2
+
3
+ `/curdx-flow:implement` defaults to `--strategy=auto`. The router converts task
4
+ shape into one of four concrete execution modes.
5
+
6
+ ## Runtime Decision Tree
7
+
8
+ ```bash
9
+ if [ "$STRATEGY" != "auto" ]; then
10
+ use the explicit value
11
+ elif [ $REMAINING -lt 5 ] || [ $SEQUENTIAL -gt $((REMAINING / 2)) ]; then
12
+ STRATEGY="linear"
13
+ elif [ $PARALLEL -ge $((REMAINING * 4 / 10)) ]; then
14
+ STRATEGY="wave"
15
+ elif [ $REMAINING -ge 20 ] && [ $QUICK -eq 1 ]; then
16
+ STRATEGY="stop-hook"
17
+ elif [ $REMAINING -ge 8 ]; then
18
+ STRATEGY="subagent"
19
+ else
20
+ STRATEGY="linear"
21
+ fi
22
+ ```
23
+
24
+ ## Routing Signals
25
+
26
+ - Few tasks or dependency-heavy work: `linear`
27
+ - Meaningful `[P]` coverage and disjoint file sets: `wave`
28
+ - Long unattended run with `--quick`: `stop-hook`
29
+ - Mid-sized backlog without safe parallelism: `subagent`
30
+
31
+ ## Guardrails
32
+
33
+ - `--strategy=<mode>` always wins over auto-routing
34
+ - Unknown strategy values are fatal; do not silently fall back
35
+ - `--task=<id>` narrows execution scope, but does not change the selected
36
+ strategy by itself
37
+ - `--quick` is a routing hint only; it does not relax verification or commit
38
+ rules
@@ -0,0 +1,43 @@
1
+ # Subagent Execution — Serial Isolated Executors
2
+
3
+ Use this mode when tasks are moderately sized and benefit from fresh context per
4
+ task, but the backlog is not parallel-safe enough for waves.
5
+
6
+ ## Dispatch Contract
7
+
8
+ Dispatch one `flow-executor` at a time with a uniform prompt:
9
+
10
+ ```text
11
+ You are the flow-executor agent. Full definition at:
12
+ ${CLAUDE_PLUGIN_ROOT}/agents/flow-executor.md
13
+
14
+ Execute task:
15
+ spec_name: $SPEC_NAME
16
+ task_id: next (or a specific ID)
17
+ quick_mode: $QUICK
18
+
19
+ Required reading:
20
+ - .flow/specs/$SPEC_NAME/tasks.md
21
+ - .flow/specs/$SPEC_NAME/.state.json
22
+ - .flow/specs/$SPEC_NAME/.progress.md
23
+ - .flow/specs/$SPEC_NAME/design.md (if task references AD-NN)
24
+ - .flow/specs/$SPEC_NAME/requirements.md (if task references FR/AC)
25
+
26
+ On success output: TASK_COMPLETE: <task_id>
27
+ On failure output: TASK_FAILED: <task_id> + Reason
28
+ When all tasks are done output: ALL_TASKS_COMPLETE
29
+ ```
30
+
31
+ ## Aggregation Rules
32
+
33
+ After the agent completes, read the output marker:
34
+
35
+ - `TASK_COMPLETE` -> mark progress and dispatch the next task
36
+ - `TASK_FAILED` -> increment failure tracking and enter recovery
37
+ - `ALL_TASKS_COMPLETE` -> mark execute complete and move to verify
38
+
39
+ ## Guardrails
40
+
41
+ - This strategy is serial; a single Agent dispatch is not parallel execution
42
+ - Do not batch multiple independent tasks into one `flow-executor` prompt
43
+ - Do not trust narrative summaries over the end marker