pi-maestro-flow 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/README.md +124 -0
  2. package/agents/aggregator.md +27 -0
  3. package/agents/cli-explore-agent.md +188 -0
  4. package/agents/cross-role-reviewer.md +171 -0
  5. package/agents/delegate.md +19 -0
  6. package/agents/explorer.md +23 -0
  7. package/agents/impeccable-agent.md +99 -0
  8. package/agents/ralph-executor.md +81 -0
  9. package/agents/reference.md +24 -0
  10. package/agents/role-design-author.md +220 -0
  11. package/agents/team-supervisor.md +143 -0
  12. package/agents/team-worker.md +237 -0
  13. package/agents/ui-design-agent.md +270 -0
  14. package/agents/workflow-analyzer.md +116 -0
  15. package/agents/workflow-codebase-mapper.md +77 -0
  16. package/agents/workflow-collab-planner.md +147 -0
  17. package/agents/workflow-debugger.md +104 -0
  18. package/agents/workflow-executor.md +133 -0
  19. package/agents/workflow-external-researcher.md +86 -0
  20. package/agents/workflow-integration-checker.md +83 -0
  21. package/agents/workflow-nyquist-auditor.md +85 -0
  22. package/agents/workflow-phase-researcher.md +85 -0
  23. package/agents/workflow-plan-checker.md +100 -0
  24. package/agents/workflow-planner.md +200 -0
  25. package/agents/workflow-project-researcher.md +74 -0
  26. package/agents/workflow-research-synthesizer.md +70 -0
  27. package/agents/workflow-reviewer.md +82 -0
  28. package/agents/workflow-roadmapper.md +81 -0
  29. package/agents/workflow-verifier.md +120 -0
  30. package/package.json +58 -0
  31. package/skills/codify-to-knowhow/SKILL.md +167 -0
  32. package/skills/delegation-check/SKILL.md +297 -0
  33. package/skills/domain-add/SKILL.md +75 -0
  34. package/skills/insight-challenge/SKILL.md +226 -0
  35. package/skills/learn-decompose/SKILL.md +124 -0
  36. package/skills/learn-follow/SKILL.md +163 -0
  37. package/skills/learn-investigate/SKILL.md +160 -0
  38. package/skills/learn-second-opinion/SKILL.md +128 -0
  39. package/skills/maestro/SKILL.md +239 -0
  40. package/skills/maestro-amend/SKILL.md +169 -0
  41. package/skills/maestro-analyze/SKILL.md +173 -0
  42. package/skills/maestro-blueprint/SKILL.md +159 -0
  43. package/skills/maestro-brainstorm/SKILL.md +193 -0
  44. package/skills/maestro-collab/SKILL.md +181 -0
  45. package/skills/maestro-companion/SKILL.md +536 -0
  46. package/skills/maestro-composer/SKILL.md +192 -0
  47. package/skills/maestro-execute/SKILL.md +193 -0
  48. package/skills/maestro-fork/SKILL.md +104 -0
  49. package/skills/maestro-grill/SKILL.md +151 -0
  50. package/skills/maestro-guard/SKILL.md +124 -0
  51. package/skills/maestro-help/SKILL.md +328 -0
  52. package/skills/maestro-impeccable/SKILL.md +302 -0
  53. package/skills/maestro-init/SKILL.md +151 -0
  54. package/skills/maestro-merge/SKILL.md +90 -0
  55. package/skills/maestro-milestone-audit/SKILL.md +117 -0
  56. package/skills/maestro-milestone-complete/SKILL.md +133 -0
  57. package/skills/maestro-milestone-release/SKILL.md +131 -0
  58. package/skills/maestro-next/SKILL.md +269 -0
  59. package/skills/maestro-overlay/SKILL.md +203 -0
  60. package/skills/maestro-plan/SKILL.md +194 -0
  61. package/skills/maestro-player/SKILL.md +184 -0
  62. package/skills/maestro-quick/SKILL.md +117 -0
  63. package/skills/maestro-ralph/SKILL.md +905 -0
  64. package/skills/maestro-ralph-cli/SKILL.md +976 -0
  65. package/skills/maestro-ralph-cli-execute/SKILL.md +229 -0
  66. package/skills/maestro-ralph-execute/SKILL.md +409 -0
  67. package/skills/maestro-ralph-v2/SKILL.md +1198 -0
  68. package/skills/maestro-roadmap/SKILL.md +157 -0
  69. package/skills/maestro-swarm-workflow/SKILL.md +272 -0
  70. package/skills/maestro-tools-execute/SKILL.md +143 -0
  71. package/skills/maestro-tools-register/SKILL.md +192 -0
  72. package/skills/maestro-ui-codify/SKILL.md +127 -0
  73. package/skills/maestro-universal-workflow/SKILL.md +622 -0
  74. package/skills/maestro-update/SKILL.md +156 -0
  75. package/skills/manage-codebase-rebuild/SKILL.md +111 -0
  76. package/skills/manage-drift-realign/SKILL.md +159 -0
  77. package/skills/manage-harvest/SKILL.md +121 -0
  78. package/skills/manage-issue/SKILL.md +88 -0
  79. package/skills/manage-issue-discover/SKILL.md +104 -0
  80. package/skills/manage-kg-extractors/SKILL.md +147 -0
  81. package/skills/manage-knowhow/SKILL.md +102 -0
  82. package/skills/manage-knowhow-capture/SKILL.md +109 -0
  83. package/skills/manage-knowledge-audit/SKILL.md +147 -0
  84. package/skills/manage-status/SKILL.md +80 -0
  85. package/skills/manage-wiki/SKILL.md +104 -0
  86. package/skills/odyssey-debug/SKILL.md +344 -0
  87. package/skills/odyssey-improve/SKILL.md +423 -0
  88. package/skills/odyssey-planex/SKILL.md +542 -0
  89. package/skills/odyssey-review-test-fix/SKILL.md +392 -0
  90. package/skills/odyssey-ui/SKILL.md +388 -0
  91. package/skills/prompt-generator/SKILL.md +470 -0
  92. package/skills/quality-auto-test/SKILL.md +168 -0
  93. package/skills/quality-debug/SKILL.md +176 -0
  94. package/skills/quality-refactor/SKILL.md +108 -0
  95. package/skills/quality-retrospective/SKILL.md +134 -0
  96. package/skills/quality-review/SKILL.md +169 -0
  97. package/skills/quality-sync/SKILL.md +90 -0
  98. package/skills/quality-test/SKILL.md +183 -0
  99. package/skills/scholar-anti-ai-writing/SKILL.md +173 -0
  100. package/skills/scholar-anti-ai-writing/references/patterns-chinese.md +242 -0
  101. package/skills/scholar-anti-ai-writing/references/patterns-english.md +242 -0
  102. package/skills/scholar-citation-verify/SKILL.md +166 -0
  103. package/skills/scholar-citation-verify/references/api-usage.md +372 -0
  104. package/skills/scholar-citation-verify/references/common-errors.md +384 -0
  105. package/skills/scholar-citation-verify/references/verification-rules.md +399 -0
  106. package/skills/scholar-experiment/SKILL.md +321 -0
  107. package/skills/scholar-ideation/SKILL.md +288 -0
  108. package/skills/scholar-latex-organizer/SKILL.md +186 -0
  109. package/skills/scholar-publish/SKILL.md +220 -0
  110. package/skills/scholar-rebuttal-pro/README.md +313 -0
  111. package/skills/scholar-rebuttal-pro/SKILL.md +511 -0
  112. package/skills/scholar-review/SKILL.md +227 -0
  113. package/skills/scholar-thesis-docx/README.md +111 -0
  114. package/skills/scholar-thesis-docx/README_EN.md +108 -0
  115. package/skills/scholar-thesis-docx/SKILL.md +212 -0
  116. package/skills/scholar-thesis-docx/references/failure-patterns-and-quality-gates.md +178 -0
  117. package/skills/scholar-thesis-docx/references/figure-and-code-rules.md +33 -0
  118. package/skills/scholar-thesis-docx/references/paper-format-workflow.md +68 -0
  119. package/skills/scholar-thesis-docx/references/script-usage.md +157 -0
  120. package/skills/scholar-thesis-docx/scripts/audit_docx_ooxml.py +429 -0
  121. package/skills/scholar-thesis-docx/scripts/check_word_com.ps1 +50 -0
  122. package/skills/scholar-thesis-docx/scripts/export_word_pdf.ps1 +62 -0
  123. package/skills/scholar-thesis-docx/scripts/normalize_word_styles.ps1 +498 -0
  124. package/skills/scholar-thesis-docx/scripts/render_mermaid_figure.ps1 +148 -0
  125. package/skills/scholar-writing/SKILL.md +296 -0
  126. package/skills/security-audit/SKILL.md +244 -0
  127. package/skills/skill-generator/SKILL.md +472 -0
  128. package/skills/skill-iter-tune/SKILL.md +382 -0
  129. package/skills/skill-simplify/SKILL.md +63 -0
  130. package/skills/skill-tuning/SKILL.md +174 -0
  131. package/skills/spec-add/SKILL.md +105 -0
  132. package/skills/spec-load/SKILL.md +98 -0
  133. package/skills/spec-remove/SKILL.md +74 -0
  134. package/skills/spec-setup/SKILL.md +75 -0
  135. package/skills/team-adversarial-swarm/SKILL.md +233 -0
  136. package/skills/team-adversarial-swarm/scripts/__pycache__/pheromone.cpython-313.pyc +0 -0
  137. package/skills/team-adversarial-swarm/scripts/__pycache__/scoring.cpython-313.pyc +0 -0
  138. package/skills/team-adversarial-swarm/scripts/aco.py +473 -0
  139. package/skills/team-adversarial-swarm/scripts/pheromone.py +144 -0
  140. package/skills/team-adversarial-swarm/scripts/scoring.py +92 -0
  141. package/skills/team-adversarial-swarm/scripts/test_aco.py +475 -0
  142. package/skills/team-arch-opt/SKILL.md +158 -0
  143. package/skills/team-brainstorm/SKILL.md +171 -0
  144. package/skills/team-coordinate/SKILL.md +266 -0
  145. package/skills/team-designer/SKILL.md +160 -0
  146. package/skills/team-executor/SKILL.md +189 -0
  147. package/skills/team-frontend/SKILL.md +136 -0
  148. package/skills/team-frontend-debug/SKILL.md +198 -0
  149. package/skills/team-interactive-craft/SKILL.md +141 -0
  150. package/skills/team-issue/SKILL.md +171 -0
  151. package/skills/team-lifecycle-v4/SKILL.md +209 -0
  152. package/skills/team-motion-design/SKILL.md +142 -0
  153. package/skills/team-perf-opt/SKILL.md +175 -0
  154. package/skills/team-planex/SKILL.md +137 -0
  155. package/skills/team-quality-assurance/SKILL.md +147 -0
  156. package/skills/team-review/SKILL.md +147 -0
  157. package/skills/team-roadmap-dev/SKILL.md +169 -0
  158. package/skills/team-swarm/SKILL.md +178 -0
  159. package/skills/team-swarm/scripts/aco.py +473 -0
  160. package/skills/team-swarm/scripts/pheromone.py +144 -0
  161. package/skills/team-swarm/scripts/scoring.py +92 -0
  162. package/skills/team-swarm/scripts/test_aco.py +475 -0
  163. package/skills/team-tech-debt/SKILL.md +128 -0
  164. package/skills/team-testing/SKILL.md +143 -0
  165. package/skills/team-ui-polish/SKILL.md +141 -0
  166. package/skills/team-uidesign/SKILL.md +144 -0
  167. package/skills/team-ultra-analyze/SKILL.md +173 -0
  168. package/skills/team-ux-improve/SKILL.md +151 -0
  169. package/skills/team-visual-a11y/SKILL.md +156 -0
  170. package/skills/workflow-skill-designer/SKILL.md +496 -0
  171. package/src/extension/index.ts +222 -0
  172. package/src/extension/schemas.ts +131 -0
  173. package/src/providers/cli-tools-loader.ts +74 -0
  174. package/src/providers/provider-registry.ts +130 -0
  175. package/src/tools/delegate.ts +85 -0
  176. package/src/tools/explore.ts +134 -0
  177. package/src/tools/moa.ts +213 -0
  178. package/src/tools/status.ts +99 -0
  179. package/src/tools/wait.ts +166 -0
@@ -0,0 +1,382 @@
1
+ ---
2
+ name: skill-iter-tune
3
+ description: "Iterative skill tuning via execute-evaluate-improve feedback loop. Uses maestro delegate Claude to execute skill, Agy 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 Agy, 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 → maestro delegate → artifacts/skill-A/
41
+ ↓ (artifacts as input)
42
+ Skill B → maestro delegate → artifacts/skill-B/
43
+ ↓ (artifacts as input)
44
+ Skill C → maestro delegate → 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) + Agy (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 maestro delegate call for all skills
168
+ // Chain mode: sequential maestro delegate per skill in chain_order, passing artifacts
169
+ // Snapshot skill → construct prompt → maestro delegate --to claude --mode write
170
+ // Collect artifacts
171
+
172
+ // === Phase 3: Evaluate ===
173
+ // Read: phases/03-evaluate.md
174
+ // Construct eval prompt → maestro delegate --to agy --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: `maestro delegate "..." --to 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: `maestro delegate "..." --to agy --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 maestro delegate Claude | TodoWrite 驱动 + 🔄 sentinel |
233
+ | 3 | [phases/03-evaluate.md](phases/03-evaluate.md) | Evaluate via maestro delegate Agy | 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**: maestro delegate 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 (maestro delegate claude)
262
+ │ ↓ artifacts/ (skill execution output)
263
+ │ ↓
264
+ │ Phase 3: Evaluate (maestro delegate agy)
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,63 @@
1
+ ---
2
+ name: skill-simplify
3
+ description: "SKILL.md simplification with functional integrity verification. Analyze redundancy, optimize content, check no functionality lost. Triggers on \"simplify skill\", \"optimize skill\", \"skill-simplify\"."
4
+ allowed-tools: AskUserQuestion Read Write Edit Bash Glob Grep
5
+ ---
6
+
7
+ # Skill Simplify
8
+
9
+ Three-phase pipeline: analyze functional inventory, apply optimization rules, verify integrity.
10
+
11
+ **Phase Reference Documents** (read on-demand):
12
+
13
+ | Phase | Document | Purpose |
14
+ |-------|----------|---------|
15
+ | 1 | [phases/01-analysis.md](phases/01-analysis.md) | Extract functional inventory, identify redundancy, validate pseudo-code format |
16
+ | 2 | [phases/02-optimize.md](phases/02-optimize.md) | Apply simplification rules, fix format issues |
17
+ | 3 | [phases/03-check.md](phases/03-check.md) | Verify functional integrity, validate format |
18
+
19
+ ## Pre-load (before execution)
20
+
21
+ 1. **Codebase docs**: If `.workflow/codebase/ARCHITECTURE.md` exists, read for project context
22
+ 2. **Specs**: `maestro load --type spec --category coding` — load coding conventions
23
+ 3. **Wiki knowledge**: `maestro search "skill design optimization" --json` — top 5 entries as prior context
24
+ 4. All optional — proceed without if unavailable
25
+
26
+ ## Input Processing
27
+
28
+ ```javascript
29
+ const targetPath = input.trim()
30
+ const targetFile = targetPath.endsWith('.md') ? targetPath : `${targetPath}/SKILL.md`
31
+ const originalContent = Read(targetFile)
32
+ const originalLineCount = originalContent.split('\n').length
33
+ ```
34
+
35
+ ## TodoWrite Pattern
36
+
37
+ ```javascript
38
+ TodoWrite({ todos: [
39
+ { content: `Phase 1: Analyzing ${targetFile}`, status: "in_progress", activeForm: "Extracting functional inventory" },
40
+ { content: "Phase 2: Optimize", status: "pending" },
41
+ { content: "Phase 3: Integrity Check", status: "pending" }
42
+ ]})
43
+ ```
44
+
45
+ ## Core Rules
46
+
47
+ 1. **Preserve ALL functional elements**: Code blocks with logic, agent calls, data structures, routing, error handling, input/output specs
48
+ 2. **Only reduce descriptive content**: Flowcharts, verbose comments, duplicate sections, examples that repeat logic
49
+ 3. **Never summarize algorithm logic**: If-else branches, function bodies, schemas must remain verbatim
50
+ 4. **Classify code blocks**: Distinguish `functional` (logic, routing, schemas) from `descriptive` (ASCII art, examples, display templates) — only descriptive blocks may be deleted
51
+ 5. **Merge equivalent variants**: Single/multi-perspective templates differing only by a parameter → one template with variant comment
52
+ 6. **Fix format issues**: Nested backtick template literals in code fences → convert to prose; hardcoded option lists → flag for dynamic generation; workflow handoff references → ensure execution steps present
53
+ 7. **Validate pseudo-code**: Check bracket matching, variable consistency, structural completeness
54
+ 8. **Quantitative verification**: Phase 3 counts must match Phase 1 counts for functional categories; descriptive block decreases are expected
55
+
56
+ ## Error Handling
57
+
58
+ | Error | Resolution |
59
+ |-------|------------|
60
+ | Target file not found | Report error, stop |
61
+ | Check FAIL (missing functional elements) | Show delta, revert to original, report which elements lost |
62
+ | Check WARN (descriptive decrease or merge) | Show delta with justification |
63
+ | Format issues found | Report in check, fix in Phase 2 |
@@ -0,0 +1,174 @@
1
+ ---
2
+ name: skill-tuning
3
+ description: "Universal skill diagnosis and optimization tool. Detect and fix skill execution issues including context explosion, long-tail forgetting, data flow disruption, and agent coordination failures. Supports Agy CLI for deep analysis. Triggers on \"skill tuning\", \"tune skill\", \"skill diagnosis\", \"optimize skill\", \"skill debug\"."
4
+ allowed-tools: Agent AskUserQuestion Read Write Bash Glob Grep
5
+ ---
6
+
7
+ # Skill Tuning
8
+
9
+ Autonomous diagnosis and optimization for skill execution issues.
10
+
11
+ ## Pre-load (before execution)
12
+
13
+ 1. **Codebase docs**: If `.workflow/codebase/ARCHITECTURE.md` exists, read for project context
14
+ 2. **Specs**: `maestro load --type spec --category coding` — load coding conventions
15
+ 3. **Wiki knowledge**: `maestro search "skill design optimization" --json` — top 5 entries as prior context
16
+ 4. All optional — proceed without if unavailable
17
+
18
+ ## Architecture
19
+
20
+ ```
21
+ ┌─────────────────────────────────────────────────────┐
22
+ │ Phase 0: Read Specs (mandatory) │
23
+ │ → problem-taxonomy.md, tuning-strategies.md │
24
+ └─────────────────────────────────────────────────────┘
25
+
26
+ ┌─────────────────────────────────────────────────────┐
27
+ │ Orchestrator (state-driven) │
28
+ │ Read state → Select action → Execute → Update → ✓ │
29
+ └─────────────────────────────────────────────────────┘
30
+ ↓ ↓
31
+ ┌──────────────────────┐ ┌──────────────────┐
32
+ │ Diagnosis Phase │ │ Agy CLI │
33
+ │ • Context │ │ Deep analysis │
34
+ │ • Memory │ │ (on-demand) │
35
+ │ • DataFlow │ │ │
36
+ │ • Agent │ │ Complex issues │
37
+ │ • Docs │ │ Architecture │
38
+ │ • Token Usage │ │ Performance │
39
+ └──────────────────────┘ └──────────────────┘
40
+
41
+ ┌───────────────────┐
42
+ │ Fix & Verify │
43
+ │ Apply → Re-test │
44
+ └───────────────────┘
45
+ ```
46
+
47
+ ## Core Issues Detected
48
+
49
+ | Priority | Problem | Root Cause | Fix Strategy |
50
+ |----------|---------|-----------|--------------|
51
+ | **P0** | Authoring Violation | Intermediate files, state bloat, file relay | eliminate_intermediate, minimize_state |
52
+ | **P1** | Data Flow Disruption | Scattered state, inconsistent formats | state_centralization, schema_enforcement |
53
+ | **P2** | Agent Coordination | Fragile chains, no error handling | error_wrapping, result_validation |
54
+ | **P3** | Context Explosion | Unbounded history, full content passing | sliding_window, path_reference |
55
+ | **P4** | Long-tail Forgetting | Early constraint loss | constraint_injection, checkpoint_restore |
56
+ | **P5** | Token Consumption | Verbose prompts, state bloat | prompt_compression, lazy_loading |
57
+
58
+ ## Problem Categories (Detailed Specs)
59
+
60
+ See [specs/problem-taxonomy.md](specs/problem-taxonomy.md) for:
61
+ - Detection patterns (regex/checks)
62
+ - Severity calculations
63
+ - Impact assessments
64
+
65
+ ## Tuning Strategies (Detailed Specs)
66
+
67
+ See [specs/tuning-strategies.md](specs/tuning-strategies.md) for:
68
+ - 10+ strategies per category
69
+ - Implementation patterns
70
+ - Verification methods
71
+
72
+ ## Workflow
73
+
74
+ | Step | Action | Orchestrator Decision | Output |
75
+ |------|--------|----------------------|--------|
76
+ | 1 | `action-init` | status='pending' | Backup, session created |
77
+ | 2 | `action-analyze-requirements` | After init | Required dimensions + coverage |
78
+ | 3 | Diagnosis (6 types) | Focus areas | state.diagnosis.{type} |
79
+ | 4 | `action-agy-analysis` | Critical issues OR user request | Deep findings |
80
+ | 5 | `action-generate-report` | All diagnosis complete | state.final_report |
81
+ | 6 | `action-propose-fixes` | Issues found | state.proposed_fixes[] |
82
+ | 7 | `action-apply-fix` | Pending fixes | Applied + verified |
83
+ | 8 | `action-complete` | Quality gates pass | session.status='completed' |
84
+
85
+ ## Action Reference
86
+
87
+ | Category | Actions | Purpose |
88
+ |----------|---------|---------|
89
+ | **Setup** | action-init | Initialize backup, session state |
90
+ | **Analysis** | action-analyze-requirements | Decompose user request via Agy CLI |
91
+ | **Diagnosis** | action-diagnose-{context,memory,dataflow,agent,docs,token_consumption} | Detect category-specific issues |
92
+ | **Deep Analysis** | action-agy-analysis | Agy CLI: complex/critical issues |
93
+ | **Reporting** | action-generate-report | Consolidate findings → final_report |
94
+ | **Fixing** | action-propose-fixes, action-apply-fix | Generate + apply fixes |
95
+ | **Verify** | action-verify | Re-run diagnosis, check gates |
96
+ | **Exit** | action-complete, action-abort | Finalize or rollback |
97
+
98
+ Full action details: [phases/actions/](phases/actions/)
99
+
100
+ ## State Management
101
+
102
+ **Single source of truth**: `.workflow/.scratchpad/skill-tuning-{ts}/state.json`
103
+
104
+ ```json
105
+ {
106
+ "status": "pending|running|completed|failed",
107
+ "target_skill": { "name": "...", "path": "..." },
108
+ "diagnosis": {
109
+ "context": {...},
110
+ "memory": {...},
111
+ "dataflow": {...},
112
+ "agent": {...},
113
+ "docs": {...},
114
+ "token_consumption": {...}
115
+ },
116
+ "issues": [{"id":"...", "severity":"...", "category":"...", "strategy":"..."}],
117
+ "proposed_fixes": [...],
118
+ "applied_fixes": [...],
119
+ "quality_gate": "pass|fail",
120
+ "final_report": "..."
121
+ }
122
+ ```
123
+
124
+ See [phases/state-schema.md](phases/state-schema.md) for complete schema.
125
+
126
+ ## Orchestrator Logic
127
+
128
+ See [phases/orchestrator.md](phases/orchestrator.md) for:
129
+ - Decision logic (termination checks → action selection)
130
+ - State transitions
131
+ - Error recovery
132
+
133
+ ## Key Principles
134
+
135
+ 1. **Problem-First**: Diagnosis before any fix
136
+ 2. **Data-Driven**: Record traces, token counts, snapshots
137
+ 3. **Iterative**: Multiple rounds until quality gates pass
138
+ 4. **Reversible**: All changes with backup checkpoints
139
+ 5. **Non-Invasive**: Minimal changes, maximum clarity
140
+
141
+ ## Usage Examples
142
+
143
+ ```bash
144
+ # Basic skill diagnosis
145
+ /skill-tuning "Fix memory leaks in my skill"
146
+
147
+ # Deep analysis with Agy
148
+ /skill-tuning "Architecture issues in async workflow"
149
+
150
+ # Focus on specific areas
151
+ /skill-tuning "Optimize token consumption and fix agent coordination"
152
+
153
+ # Custom issue
154
+ /skill-tuning "My skill produces inconsistent outputs"
155
+ ```
156
+
157
+ ## Output
158
+
159
+ After completion, review:
160
+ - `.workflow/.scratchpad/skill-tuning-{ts}/state.json` - Full state with final_report
161
+ - `state.final_report` - Markdown summary (in state.json)
162
+ - `state.applied_fixes` - List of applied fixes with verification results
163
+
164
+ ## Reference Documents
165
+
166
+ | Document | Purpose |
167
+ |----------|---------|
168
+ | [specs/problem-taxonomy.md](specs/problem-taxonomy.md) | Classification + detection patterns |
169
+ | [specs/tuning-strategies.md](specs/tuning-strategies.md) | Fix implementation guide |
170
+ | [specs/dimension-mapping.md](specs/dimension-mapping.md) | Dimension ↔ Spec mapping |
171
+ | [specs/quality-gates.md](specs/quality-gates.md) | Quality verification criteria |
172
+ | [phases/orchestrator.md](phases/orchestrator.md) | Workflow orchestration |
173
+ | [phases/state-schema.md](phases/state-schema.md) | State structure definition |
174
+ | [phases/actions/](phases/actions/) | Individual action implementations |