maestro-flow 0.3.13 → 0.3.15

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 (38) hide show
  1. package/.claude/commands/maestro-composer.md +354 -0
  2. package/.claude/commands/maestro-player.md +404 -0
  3. package/.claude/skills/skill-iter-tune/SKILL.md +382 -0
  4. package/.claude/skills/skill-iter-tune/phases/01-setup.md +144 -0
  5. package/.claude/skills/skill-iter-tune/phases/02-execute.md +292 -0
  6. package/.claude/skills/skill-iter-tune/phases/03-evaluate.md +312 -0
  7. package/.claude/skills/skill-iter-tune/phases/04-improve.md +186 -0
  8. package/.claude/skills/skill-iter-tune/phases/05-report.md +166 -0
  9. package/.claude/skills/skill-iter-tune/specs/evaluation-criteria.md +63 -0
  10. package/.claude/skills/skill-iter-tune/templates/eval-prompt.md +134 -0
  11. package/.claude/skills/skill-iter-tune/templates/execute-prompt.md +97 -0
  12. package/.claude/skills/workflow-skill-designer/SKILL.md +496 -0
  13. package/.claude/skills/workflow-skill-designer/phases/01-requirements-analysis.md +356 -0
  14. package/.claude/skills/workflow-skill-designer/phases/02-orchestrator-design.md +444 -0
  15. package/.claude/skills/workflow-skill-designer/phases/03-phase-design.md +458 -0
  16. package/.claude/skills/workflow-skill-designer/phases/04-validation.md +471 -0
  17. package/.codex/skills/maestro-composer/SKILL.md +285 -0
  18. package/.codex/skills/maestro-link-coordinate/SKILL.md +430 -224
  19. package/.codex/skills/maestro-player/SKILL.md +448 -0
  20. package/chains/milestone-fork-merge.json +6 -6
  21. package/dist/src/hooks/auto-mode.d.ts +18 -0
  22. package/dist/src/hooks/auto-mode.d.ts.map +1 -0
  23. package/dist/src/hooks/auto-mode.js +28 -0
  24. package/dist/src/hooks/auto-mode.js.map +1 -0
  25. package/dist/src/hooks/context-monitor.d.ts.map +1 -1
  26. package/dist/src/hooks/context-monitor.js +14 -3
  27. package/dist/src/hooks/context-monitor.js.map +1 -1
  28. package/dist/src/hooks/coordinator-tracker.d.ts +1 -0
  29. package/dist/src/hooks/coordinator-tracker.d.ts.map +1 -1
  30. package/dist/src/hooks/coordinator-tracker.js +19 -9
  31. package/dist/src/hooks/coordinator-tracker.js.map +1 -1
  32. package/package.json +1 -1
  33. package/templates/workflows/specs/node-catalog.md +170 -0
  34. package/templates/workflows/specs/template-schema.md +157 -0
  35. package/workflows/maestro-coordinate.codex.md +9 -9
  36. package/workflows/maestro-coordinate.md +9 -9
  37. package/workflows/maestro.md +2 -2
  38. package/.codex/skills/maestro-chain/SKILL.md +0 -233
@@ -0,0 +1,382 @@
1
+ ---
2
+ name: skill-iter-tune
3
+ description: Iterative skill tuning via execute-evaluate-improve feedback loop. Uses ccw cli Claude to execute skill, Gemini to evaluate quality, and Agent to apply improvements. Iterates until quality threshold or max iterations. Triggers on "skill iter tune", "iterative skill tuning", "tune skill".
4
+ allowed-tools: Skill, Agent, AskUserQuestion, TaskCreate, TaskUpdate, TaskList, Read, Write, Edit, Bash, Glob, Grep
5
+ ---
6
+
7
+ # Skill Iter Tune
8
+
9
+ Iterative skill refinement through execute-evaluate-improve feedback loops. Each iteration runs the skill via Claude, evaluates output via Gemini, and applies improvements via Agent.
10
+
11
+ ## Architecture Overview
12
+
13
+ ```
14
+ ┌──────────────────────────────────────────────────────────────────────────┐
15
+ │ Skill Iter Tune Orchestrator (SKILL.md) │
16
+ │ → Parse input → Setup workspace → Iteration Loop → Final Report │
17
+ └────────────────────────────┬─────────────────────────────────────────────┘
18
+
19
+ ┌───────────────────┼───────────────────────────────────┐
20
+ ↓ ↓ ↓
21
+ ┌──────────┐ ┌─────────────────────────────┐ ┌──────────┐
22
+ │ Phase 1 │ │ Iteration Loop (2→3→4) │ │ Phase 5 │
23
+ │ Setup │ │ ┌─────┐ ┌─────┐ ┌─────┐ │ │ Report │
24
+ │ │─────→│ │ P2 │→ │ P3 │→ │ P4 │ │────→│ │
25
+ │ Backup + │ │ │Exec │ │Eval │ │Impr │ │ │ History │
26
+ │ Init │ │ └─────┘ └─────┘ └─────┘ │ │ Summary │
27
+ └──────────┘ │ ↑ │ │ └──────────┘
28
+ │ └───────────────┘ │
29
+ │ (if score < threshold │
30
+ │ AND iter < max) │
31
+ └─────────────────────────────┘
32
+ ```
33
+
34
+ ### Chain Mode Extension
35
+
36
+ ```
37
+ Chain Mode (execution_mode === "chain"):
38
+
39
+ Phase 2 runs per-skill in chain_order:
40
+ Skill A → ccw cli → artifacts/skill-A/
41
+ ↓ (artifacts as input)
42
+ Skill B → ccw cli → artifacts/skill-B/
43
+ ↓ (artifacts as input)
44
+ Skill C → ccw cli → artifacts/skill-C/
45
+
46
+ Phase 3 evaluates entire chain output + per-skill scores
47
+ Phase 4 improves weakest skill(s) in chain
48
+ ```
49
+
50
+ ## Key Design Principles
51
+
52
+ 1. **Iteration Loop**: Phases 2-3-4 repeat until quality threshold, max iterations, or convergence
53
+ 2. **Two-Tool Pipeline**: Claude (write/execute) + Gemini (analyze/evaluate) = complementary perspectives
54
+ 3. **Pure Orchestrator**: SKILL.md coordinates only — execution detail lives in phase files
55
+ 4. **Progressive Phase Loading**: Phase docs read only when that phase executes
56
+ 5. **Skill Versioning**: Each iteration snapshots skill state before execution
57
+ 6. **Convergence Detection**: Stop early if score stalls (no improvement in 2 consecutive iterations)
58
+
59
+ ## Interactive Preference Collection
60
+
61
+ ```javascript
62
+ // ★ Auto mode detection
63
+ const autoYes = /\b(-y|--yes)\b/.test($ARGUMENTS)
64
+
65
+ if (autoYes) {
66
+ workflowPreferences = {
67
+ autoYes: true,
68
+ maxIterations: 5,
69
+ qualityThreshold: 80,
70
+ executionMode: 'single'
71
+ }
72
+ } else {
73
+ const prefResponse = AskUserQuestion({
74
+ questions: [
75
+ {
76
+ question: "选择迭代调优配置:",
77
+ header: "Tune Config",
78
+ multiSelect: false,
79
+ options: [
80
+ { label: "Quick (3 iter, 70)", description: "快速迭代,适合小幅改进" },
81
+ { label: "Standard (5 iter, 80) (Recommended)", description: "平衡方案,适合多数场景" },
82
+ { label: "Thorough (8 iter, 90)", description: "深度优化,适合生产级 skill" }
83
+ ]
84
+ }
85
+ ]
86
+ })
87
+
88
+ const configMap = {
89
+ "Quick": { maxIterations: 3, qualityThreshold: 70 },
90
+ "Standard": { maxIterations: 5, qualityThreshold: 80 },
91
+ "Thorough": { maxIterations: 8, qualityThreshold: 90 }
92
+ }
93
+ const selected = Object.keys(configMap).find(k =>
94
+ prefResponse["Tune Config"].startsWith(k)
95
+ ) || "Standard"
96
+ workflowPreferences = { autoYes: false, ...configMap[selected] }
97
+
98
+ // ★ Mode selection: chain vs single
99
+ const modeResponse = AskUserQuestion({
100
+ questions: [{
101
+ question: "选择调优模式:",
102
+ header: "Tune Mode",
103
+ multiSelect: false,
104
+ options: [
105
+ { label: "Single Skill (Recommended)", description: "独立调优每个 skill,适合单一 skill 优化" },
106
+ { label: "Skill Chain", description: "按链序执行,前一个 skill 的产出作为后一个的输入" }
107
+ ]
108
+ }]
109
+ });
110
+ workflowPreferences.executionMode = modeResponse["Tune Mode"].startsWith("Skill Chain")
111
+ ? "chain" : "single";
112
+ }
113
+ ```
114
+
115
+ ## Input Processing
116
+
117
+ ```
118
+ $ARGUMENTS → Parse:
119
+ ├─ Skill path(s): first arg, comma-separated for multiple
120
+ │ e.g., ".claude/skills/my-skill" or "my-skill" (auto-prefixed)
121
+ │ Chain mode: order preserved as chain_order
122
+ ├─ Test scenario: --scenario "description" or remaining text
123
+ └─ Flags: --max-iterations=N, --threshold=N, -y/--yes
124
+ ```
125
+
126
+ ## Execution Flow
127
+
128
+ > **⚠️ COMPACT DIRECTIVE**: Context compression MUST check TodoWrite phase status.
129
+ > The phase currently marked `in_progress` is the active execution phase — preserve its FULL content.
130
+ > Only compress phases marked `completed` or `pending`.
131
+
132
+ ### Phase 1: Setup (one-time)
133
+
134
+ Read and execute: `Ref: phases/01-setup.md`
135
+
136
+ - Parse skill paths, validate existence
137
+ - Create workspace at `.workflow/.scratchpad/skill-iter-tune-{ts}/`
138
+ - Backup original skill files
139
+ - Initialize iteration-state.json
140
+
141
+ Output: `workDir`, `targetSkills[]`, `testScenario`, initialized state
142
+
143
+ ### Iteration Loop
144
+
145
+ ```javascript
146
+ // Orchestrator iteration loop
147
+ while (true) {
148
+ // Increment iteration
149
+ state.current_iteration++;
150
+ state.iterations.push({
151
+ round: state.current_iteration,
152
+ status: 'pending',
153
+ execution: null,
154
+ evaluation: null,
155
+ improvement: null
156
+ });
157
+
158
+ // Update TodoWrite
159
+ TaskUpdate(iterationTask, {
160
+ subject: `Iteration ${state.current_iteration}/${state.max_iterations}`,
161
+ status: 'in_progress',
162
+ activeForm: `Running iteration ${state.current_iteration}`
163
+ });
164
+
165
+ // === Phase 2: Execute ===
166
+ // Read: phases/02-execute.md
167
+ // Single mode: one ccw cli call for all skills
168
+ // Chain mode: sequential ccw cli per skill in chain_order, passing artifacts
169
+ // Snapshot skill → construct prompt → ccw cli --tool claude --mode write
170
+ // Collect artifacts
171
+
172
+ // === Phase 3: Evaluate ===
173
+ // Read: phases/03-evaluate.md
174
+ // Construct eval prompt → ccw cli --tool gemini --mode analysis
175
+ // Parse score → write iteration-N-eval.md → check termination
176
+
177
+ // Check termination
178
+ if (shouldTerminate(state)) {
179
+ break; // → Phase 5
180
+ }
181
+
182
+ // === Phase 4: Improve ===
183
+ // Read: phases/04-improve.md
184
+ // Agent applies suggestions → write iteration-N-changes.md
185
+
186
+ // Update TodoWrite with score
187
+ // Continue loop
188
+ }
189
+ ```
190
+
191
+ ### Phase 2: Execute Skill (per iteration)
192
+
193
+ Read and execute: `Ref: phases/02-execute.md`
194
+
195
+ - Snapshot skill → `iteration-{N}/skill-snapshot/`
196
+ - Build execution prompt from skill content + test scenario
197
+ - Execute: `ccw cli -p "..." --tool claude --mode write --cd "${iterDir}/artifacts"`
198
+ - Collect artifacts
199
+
200
+ ### Phase 3: Evaluate Quality (per iteration)
201
+
202
+ Read and execute: `Ref: phases/03-evaluate.md`
203
+
204
+ - Build evaluation prompt with skill + artifacts + criteria + history
205
+ - Execute: `ccw cli -p "..." --tool gemini --mode analysis`
206
+ - Parse 5-dimension score (Clarity, Completeness, Correctness, Effectiveness, Efficiency)
207
+ - Write `iteration-{N}-eval.md`
208
+ - Check termination: score >= threshold | iter >= max | convergence | error limit
209
+
210
+ ### Phase 4: Apply Improvements (per iteration, skipped on termination)
211
+
212
+ Read and execute: `Ref: phases/04-improve.md`
213
+
214
+ - Read evaluation suggestions
215
+ - Launch general-purpose Agent to apply changes
216
+ - Write `iteration-{N}-changes.md`
217
+ - Update state
218
+
219
+ ### Phase 5: Final Report (one-time)
220
+
221
+ Read and execute: `Ref: phases/05-report.md`
222
+
223
+ - Generate comprehensive report with score progression table
224
+ - Write `final-report.md`
225
+ - Display summary to user
226
+
227
+ **Phase Reference Documents** (read on-demand when phase executes):
228
+
229
+ | Phase | Document | Purpose | Compact |
230
+ |-------|----------|---------|---------|
231
+ | 1 | [phases/01-setup.md](phases/01-setup.md) | Initialize workspace and state | TodoWrite 驱动 |
232
+ | 2 | [phases/02-execute.md](phases/02-execute.md) | Execute skill via ccw cli Claude | TodoWrite 驱动 + 🔄 sentinel |
233
+ | 3 | [phases/03-evaluate.md](phases/03-evaluate.md) | Evaluate via ccw cli Gemini | TodoWrite 驱动 + 🔄 sentinel |
234
+ | 4 | [phases/04-improve.md](phases/04-improve.md) | Apply improvements via Agent | TodoWrite 驱动 + 🔄 sentinel |
235
+ | 5 | [phases/05-report.md](phases/05-report.md) | Generate final report | TodoWrite 驱动 |
236
+
237
+ **Compact Rules**:
238
+ 1. **TodoWrite `in_progress`** → 保留完整内容,禁止压缩
239
+ 2. **TodoWrite `completed`** → 可压缩为摘要
240
+ 3. **🔄 sentinel fallback** → 若 compact 后仅存 sentinel 而无完整 Step 协议,立即 `Read()` 恢复
241
+
242
+ ## Core Rules
243
+
244
+ 1. **Start Immediately**: First action is preference collection → Phase 1 setup
245
+ 2. **Progressive Loading**: Read phase doc ONLY when that phase is about to execute
246
+ 3. **Snapshot Before Execute**: Always snapshot skill state before each iteration
247
+ 4. **Background CLI**: ccw cli runs in background, wait for hook callback before proceeding
248
+ 5. **Parse Every Output**: Extract structured JSON from CLI outputs for state updates
249
+ 6. **DO NOT STOP**: Continuous iteration until termination condition met
250
+ 7. **Single State Source**: `iteration-state.json` is the only source of truth
251
+
252
+ ## Data Flow
253
+
254
+ ```
255
+ User Input (skill paths + test scenario)
256
+ ↓ (+ execution_mode + chain_order if chain mode)
257
+
258
+ Phase 1: Setup
259
+ ↓ workDir, targetSkills[], testScenario, iteration-state.json
260
+
261
+ ┌─→ Phase 2: Execute (ccw cli claude)
262
+ │ ↓ artifacts/ (skill execution output)
263
+ │ ↓
264
+ │ Phase 3: Evaluate (ccw cli gemini)
265
+ │ ↓ score, dimensions[], suggestions[], iteration-N-eval.md
266
+ │ ↓
267
+ │ [Terminate?]─── YES ──→ Phase 5: Report → final-report.md
268
+ │ ↓ NO
269
+ │ ↓
270
+ │ Phase 4: Improve (Agent)
271
+ │ ↓ modified skill files, iteration-N-changes.md
272
+ │ ↓
273
+ └───┘ next iteration
274
+ ```
275
+
276
+ ## TodoWrite Pattern
277
+
278
+ ```javascript
279
+ // Initial state
280
+ TaskCreate({ subject: "Phase 1: Setup workspace", activeForm: "Setting up workspace" })
281
+ TaskCreate({ subject: "Iteration Loop", activeForm: "Running iterations" })
282
+ TaskCreate({ subject: "Phase 5: Final Report", activeForm: "Generating report" })
283
+
284
+ // Chain mode: create per-skill tracking tasks
285
+ if (state.execution_mode === 'chain') {
286
+ for (const skillName of state.chain_order) {
287
+ TaskCreate({
288
+ subject: `Chain: ${skillName}`,
289
+ activeForm: `Tracking ${skillName}`,
290
+ description: `Skill chain member position ${state.chain_order.indexOf(skillName) + 1}`
291
+ })
292
+ }
293
+ }
294
+
295
+ // During iteration N
296
+ // Single mode: one score per iteration (existing behavior)
297
+ // Chain mode: per-skill status updates
298
+ if (state.execution_mode === 'chain') {
299
+ // After each skill executes in Phase 2:
300
+ TaskUpdate(chainSkillTask, {
301
+ subject: `Chain: ${skillName} — Iter ${N} executed`,
302
+ activeForm: `${skillName} iteration ${N}`
303
+ })
304
+ // After Phase 3 evaluates:
305
+ TaskUpdate(chainSkillTask, {
306
+ subject: `Chain: ${skillName} — Score ${chainScores[skillName]}/100`,
307
+ activeForm: `${skillName} scored`
308
+ })
309
+ } else {
310
+ // Single mode (existing)
311
+ TaskCreate({
312
+ subject: `Iteration ${N}: Score ${score}/100`,
313
+ activeForm: `Iteration ${N} complete`,
314
+ description: `Strengths: ... | Weaknesses: ... | Suggestions: ${count}`
315
+ })
316
+ }
317
+
318
+ // Completed — collapse
319
+ TaskUpdate(iterLoop, {
320
+ subject: `Iteration Loop (${totalIters} iters, final: ${finalScore})`,
321
+ status: 'completed'
322
+ })
323
+ ```
324
+
325
+ ## Termination Logic
326
+
327
+ ```javascript
328
+ function shouldTerminate(state) {
329
+ // 1. Quality threshold met
330
+ if (state.latest_score >= state.quality_threshold) {
331
+ return { terminate: true, reason: 'quality_threshold_met' };
332
+ }
333
+ // 2. Max iterations reached
334
+ if (state.current_iteration >= state.max_iterations) {
335
+ return { terminate: true, reason: 'max_iterations_reached' };
336
+ }
337
+ // 3. Convergence: ≤2 points improvement over last 2 iterations
338
+ if (state.score_trend.length >= 3) {
339
+ const last3 = state.score_trend.slice(-3);
340
+ if (last3[2] - last3[0] <= 2) {
341
+ state.converged = true;
342
+ return { terminate: true, reason: 'convergence_detected' };
343
+ }
344
+ }
345
+ // 4. Error limit
346
+ if (state.error_count >= state.max_errors) {
347
+ return { terminate: true, reason: 'error_limit_reached' };
348
+ }
349
+ return { terminate: false };
350
+ }
351
+ ```
352
+
353
+ ## Error Handling
354
+
355
+ | Phase | Error | Recovery |
356
+ |-------|-------|----------|
357
+ | 2: Execute | CLI timeout/crash | Retry once with simplified prompt, then skip |
358
+ | 3: Evaluate | CLI fails | Retry once, then use score 50 with warning |
359
+ | 3: Evaluate | JSON parse fails | Extract score heuristically, save raw output |
360
+ | 4: Improve | Agent fails | Rollback from `iteration-{N}/skill-snapshot/` |
361
+ | Any | 3+ consecutive errors | Terminate with error report |
362
+
363
+ **Error Budget**: Each phase gets 1 retry. 3 consecutive failed iterations triggers termination.
364
+
365
+ ## Coordinator Checklist
366
+
367
+ ### Pre-Phase Actions
368
+ - [ ] Read iteration-state.json for current state
369
+ - [ ] Verify workspace directory exists
370
+ - [ ] Check error count hasn't exceeded limit
371
+
372
+ ### Per-Iteration Actions
373
+ - [ ] Increment current_iteration in state
374
+ - [ ] Create iteration-{N} subdirectory
375
+ - [ ] Update TodoWrite with iteration status
376
+ - [ ] After Phase 3: check termination before Phase 4
377
+ - [ ] After Phase 4: write state, proceed to next iteration
378
+
379
+ ### Post-Workflow Actions
380
+ - [ ] Execute Phase 5 (Report)
381
+ - [ ] Display final summary to user
382
+ - [ ] Update all TodoWrite tasks to completed
@@ -0,0 +1,144 @@
1
+ # Phase 1: Setup
2
+
3
+ Initialize workspace, backup skills, parse inputs.
4
+
5
+ ## Objective
6
+
7
+ - Parse skill path(s) and test scenario from user input
8
+ - Validate all skill paths exist and contain SKILL.md
9
+ - Create isolated workspace directory structure
10
+ - Backup original skill files
11
+ - Initialize iteration-state.json
12
+
13
+ ## Execution
14
+
15
+ ### Step 1.1: Parse Input
16
+
17
+ Parse `$ARGUMENTS` to extract skill paths and test scenario.
18
+
19
+ ```javascript
20
+ // Parse skill paths (first argument or comma-separated)
21
+ const args = $ARGUMENTS.trim();
22
+ const pathMatch = args.match(/^([^\s]+)/);
23
+ const rawPaths = pathMatch ? pathMatch[1].split(',') : [];
24
+
25
+ // Parse test scenario
26
+ const scenarioMatch = args.match(/(?:--scenario|--test)\s+"([^"]+)"/);
27
+ const scenarioText = scenarioMatch ? scenarioMatch[1] : args.replace(rawPaths.join(','), '').trim();
28
+
29
+ // Record chain order (preserves input order for chain mode)
30
+ const chainOrder = rawPaths.map(p => p.startsWith('.claude/') ? p.split('/').pop() : p);
31
+
32
+ // If no scenario, ask user
33
+ if (!scenarioText) {
34
+ const response = AskUserQuestion({
35
+ questions: [{
36
+ question: "Please describe the test scenario for evaluating this skill:",
37
+ header: "Test Scenario",
38
+ multiSelect: false,
39
+ options: [
40
+ { label: "General quality test", description: "Evaluate overall skill quality with a generic task" },
41
+ { label: "Specific scenario", description: "I'll describe a specific test case" }
42
+ ]
43
+ }]
44
+ });
45
+ // Use response to construct testScenario
46
+ }
47
+ ```
48
+
49
+ ### Step 1.2: Validate Skill Paths
50
+
51
+ ```javascript
52
+ const targetSkills = [];
53
+ for (const rawPath of rawPaths) {
54
+ const skillPath = rawPath.startsWith('.claude/') ? rawPath : `.claude/skills/${rawPath}`;
55
+
56
+ // Validate SKILL.md exists
57
+ const skillFiles = Glob(`${skillPath}/SKILL.md`);
58
+ if (skillFiles.length === 0) {
59
+ throw new Error(`Skill not found at: ${skillPath} -- SKILL.md missing`);
60
+ }
61
+
62
+ // Collect all skill files
63
+ const allFiles = Glob(`${skillPath}/**/*.md`);
64
+ targetSkills.push({
65
+ name: skillPath.split('/').pop(),
66
+ path: skillPath,
67
+ files: allFiles.map(f => f.replace(skillPath + '/', '')),
68
+ primary_file: 'SKILL.md'
69
+ });
70
+ }
71
+ ```
72
+
73
+ ### Step 1.3: Create Workspace
74
+
75
+ ```javascript
76
+ const ts = Date.now();
77
+ const workDir = `.workflow/.scratchpad/skill-iter-tune-${ts}`;
78
+
79
+ Bash(`mkdir -p "${workDir}/backups" "${workDir}/iterations"`);
80
+ ```
81
+
82
+ ### Step 1.4: Backup Original Skills
83
+
84
+ ```javascript
85
+ for (const skill of targetSkills) {
86
+ Bash(`cp -r "${skill.path}" "${workDir}/backups/${skill.name}"`);
87
+ }
88
+ ```
89
+
90
+ ### Step 1.5: Initialize State
91
+
92
+ Write `iteration-state.json` with initial state:
93
+
94
+ ```javascript
95
+ const initialState = {
96
+ status: 'running',
97
+ started_at: new Date().toISOString(),
98
+ updated_at: new Date().toISOString(),
99
+ target_skills: targetSkills,
100
+ test_scenario: {
101
+ description: scenarioText,
102
+ // Parse --requirements and --input-args from $ARGUMENTS if provided
103
+ // e.g., --requirements "clear output,no errors" --input-args "my-skill --scenario test"
104
+ requirements: parseListArg(args, '--requirements') || [],
105
+ input_args: parseStringArg(args, '--input-args') || '',
106
+ success_criteria: parseStringArg(args, '--success-criteria') || 'Produces correct, high-quality output'
107
+ },
108
+ execution_mode: workflowPreferences.executionMode || 'single',
109
+ chain_order: workflowPreferences.executionMode === 'chain'
110
+ ? targetSkills.map(s => s.name)
111
+ : [],
112
+ current_iteration: 0,
113
+ max_iterations: workflowPreferences.maxIterations,
114
+ quality_threshold: workflowPreferences.qualityThreshold,
115
+ latest_score: 0,
116
+ score_trend: [],
117
+ converged: false,
118
+ iterations: [],
119
+ errors: [],
120
+ error_count: 0,
121
+ max_errors: 3,
122
+ work_dir: workDir,
123
+ backup_dir: `${workDir}/backups`
124
+ };
125
+
126
+ Write(`${workDir}/iteration-state.json`, JSON.stringify(initialState, null, 2));
127
+
128
+ // Chain mode: create per-skill tracking tasks
129
+ if (initialState.execution_mode === 'chain') {
130
+ for (const skill of targetSkills) {
131
+ TaskCreate({
132
+ subject: `Chain: ${skill.name}`,
133
+ activeForm: `Tracking ${skill.name}`,
134
+ description: `Skill chain member: ${skill.path} | Position: ${targetSkills.indexOf(skill) + 1}/${targetSkills.length}`
135
+ });
136
+ }
137
+ }
138
+ ```
139
+
140
+ ## Output
141
+
142
+ - **Variables**: `workDir`, `targetSkills[]`, `testScenario`, `chainOrder` (chain mode)
143
+ - **Files**: `iteration-state.json`, `backups/` directory with skill copies
144
+ - **TodoWrite**: Mark Phase 1 completed, start Iteration Loop. Chain mode: per-skill tracking tasks created