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,542 @@
1
+ ---
2
+ name: odyssey-planex
3
+ description: "Requirement-driven iterative cycle — plan, execute, strict verify, fix loop until acceptance criteria met Arguments: <requirement> [--template <name>] [--max-iterations N] [--skip-generalize] [--auto] [--method agent|cli|auto] [--executor <tool>] [--skip-verify] [--heartbeat] [-y] [-c]"
4
+ allowed-tools: Read Write Edit Bash Glob Grep Agent AskUserQuestion
5
+ ---
6
+
7
+ <base>@~/.maestro/workflows/odyssey-base.md</base>
8
+
9
+ <purpose>
10
+ Requirement-to-delivery closed loop: parse requirement → define acceptance criteria →
11
+ plan → execute → verify → fix gaps → iterate until ALL criteria pass.
12
+ </purpose>
13
+
14
+ <boundary>
15
+ **In scope:** Single requirement delivery loop — from requirement parsing to all acceptance criteria passing + generalization.
16
+ **Out of scope:** Multi-requirement orchestration → `/maestro-roadmap` | Deep debugging → `/odyssey-debug` | Code review → `/odyssey-review-test-fix` | UI optimization → `/odyssey-ui`
17
+
18
+ **`--template <name>`:**
19
+
20
+ | Template | Criteria pattern | Use case |
21
+ |----------|-----------------|----------|
22
+ | `feature` | User story acceptance + boundary tests + UI verification | New feature |
23
+ | `bugfix` | Regression tests + root cause confirmation + boundary coverage | Bug fix |
24
+ | `refactor` | Behavior preservation + performance baseline + API compatibility | Refactoring |
25
+ | `migration` | Data consistency + rollback verification + performance comparison | Data/API migration |
26
+ | `api-endpoint` | Request/response contract + error handling + permission checks | API development |
27
+ </boundary>
28
+
29
+ <context>
30
+ $ARGUMENTS
31
+
32
+ **Flags:**
33
+
34
+ | Flag | Description | Default |
35
+ |------|-------------|---------|
36
+ | `--template <name>` | Predefined requirement template | — |
37
+ | `--max-iterations N` | Max verify-fix cycles before escalation | 3 |
38
+ | `--skip-generalize` | Skip S_GENERALIZE + S_DISCOVER | false |
39
+ | `--auto` | CLI delegate calls without confirmation | false |
40
+ | `--method agent\|cli\|auto` | Execution method | `auto` |
41
+ | `--executor <tool>` | Explicit executor tool for CLI delegate | First enabled |
42
+ | `--skip-verify` | Skip post-execution validation gate | false |
43
+ | `--heartbeat` | Enable periodic progress heartbeat | false |
44
+ | `-y` | Auto-confirm — decisions recorded as `deferred` | false |
45
+ | `-c` | Resume most recent session | — |
46
+
47
+ **Session**: `.workflow/scratch/{YYYYMMDD}-planex-odyssey-{slug}/`
48
+ **Output**: `session.json` | `evidence.ndjson` | `understanding.md`
49
+
50
+ **Output boundary**: ALL session artifacts MUST target the session directory (`.workflow/scratch/{YYYYMMDD}-planex-odyssey-{slug}/`) or `.workflow/state.json` only. Source code modifications during S_EXECUTE and S_FIX are in-scope but MUST be committed per action. NEVER write session artifacts outside these paths.
51
+
52
+ **session.json — planex-specific fields:**
53
+ ```json
54
+ { "requirement": "",
55
+ "acceptance_criteria": [{"id":"AC1","criterion":"","verify_method":"test|grep|cli-review|manual","status":"pending","evidence":"","passed_at":null}],
56
+ "plan": {"tasks":[{"id":"T1","title":"","description":"","criteria_refs":["AC1"],"status":"pending","files_modified":[],"domain":"general","executor":"agent"}],"created_at":""},
57
+ "execution_config": {"method":"auto","default_executor":"","domain_routing":{"frontend":"","backend":"","default":"agent"},"code_review_tool":"Skip","verification_tool":"Auto","confirmed":false},
58
+ "iterations": [{"iteration":1,"started_at":"","completed_at":"","criteria_before":{"passed":0,"total":0},"criteria_after":{"passed":0,"total":0},"gaps_fixed":[],"files_modified":[]}],
59
+ "current_iteration": 0,
60
+ "patterns": [{"id":"P1","source":"AC1 fix","layer":"syntax|semantic|structural","signature":"","description":"","risk":"","fix_template":""}],
61
+ "generalization_stats": "-> base shared_schemas" }
62
+ ```
63
+
64
+ **evidence.ndjson phases:** `planning|execution|verification|fix|decision|generalization|discovery|self-iteration`
65
+
66
+ **understanding.md — 8 sections:**
67
+ 1. Requirement & Criteria <- S_INTAKE | 2. Plan <- S_PLAN | 3. Execution <- S_EXECUTE
68
+ 4. Verification <- S_VERIFY | 5. Fix Log <- S_FIX | 6. Generalization <- S_GENERALIZE
69
+ 7. Discoveries <- S_DISCOVER | 8. Learnings <- S_RECORD
70
+
71
+ **phase_goals[]:**
72
+
73
+ | ID | Goal | done_when | phase | skip_when |
74
+ |----|------|-----------|-------|-----------|
75
+ | G1 | Acceptance criteria defined | >=1 criterion in acceptance_criteria[] | S_INTAKE | — |
76
+ | G2 | Plan created | session.json.plan populated | S_PLAN | — |
77
+ | G3 | Implementation complete | all plan tasks executed | S_EXECUTE | — |
78
+ | G4 | All criteria pass | all acceptance_criteria[].status == passed | S_VERIFY | — |
79
+ | G5 | Pattern generalized | patterns[] >=1 entry | S_GENERALIZE | skip_generalize |
80
+ | G6 | Discoveries triaged | all scan hits classified | S_DISCOVER | skip_generalize |
81
+ | G7 | Learnings persisted | spec entries created OR no actionable | S_RECORD | — |
82
+
83
+ **Knowledge Persistence (written to understanding.md section 8):**
84
+
85
+ | Category | Content | Follow-up |
86
+ |----------|---------|-----------|
87
+ | Multi-round fix cycle pattern | Problem scenario + fix iteration + final approach | `/spec-add debug` |
88
+ | Reusable implementation pattern | Pattern + applicable scope + code template | `/spec-add coding` |
89
+ | Acceptance criteria template | Standard template + verify_method suggestion | `/spec-add review` |
90
+ | Generalization pattern | Signature + risk + fix template | `/spec-add coding` |
91
+ </context>
92
+
93
+ <invariants>
94
+ Base execution_discipline #1-5.
95
+ 6. **Acceptance criteria are sacred** — no "close enough", no manual override without explicit escalation
96
+ 7. **Generalize is mandatory** — S_GENERALIZE and S_DISCOVER execute unless `skip_generalize == true`. "All criteria passed" or context pressure are NOT valid reasons to skip. The phase itself determines whether patterns exist.
97
+ </invariants>
98
+
99
+ <self_iteration>
100
+ Applies to: **S_PLAN, S_VERIFY, S_GENERALIZE**. Logic in base.
101
+ </self_iteration>
102
+
103
+ <execution>
104
+ Follow base execution discipline completely. Actions defined in state_machine below.
105
+
106
+ ### Phase Gates (MANDATORY, BLOCKING)
107
+
108
+ **GATE 1: INTAKE → PLAN**
109
+ - REQUIRED: Requirement parsed, >=1 acceptance criterion defined with verify_method assigned.
110
+ - REQUIRED: session.json initialized, understanding.md §1 written, G1 marked done.
111
+ - BLOCKED if: no requirement provided (E001) or zero criteria derived (W001).
112
+
113
+ **GATE 2: PLAN → EXECUTE**
114
+ - REQUIRED: Plan tasks decomposed with criteria_refs mapping each task to acceptance criteria.
115
+ - REQUIRED: session.json.plan populated, understanding.md §2 updated, G2 marked done.
116
+ - BLOCKED if: plan has zero tasks or unmapped criteria.
117
+
118
+ **GATE 3: EXECUTE → VERIFY**
119
+ - REQUIRED: All plan tasks executed (or marked blocked after 3 retries per deviation rule).
120
+ - REQUIRED: execution_config confirmed, per-task evidence logged, understanding.md §3 updated, G3 marked done.
121
+ - BLOCKED if: tasks still pending execution.
122
+
123
+ **GATE 4: VERIFY → FIX / GENERALIZE**
124
+ - REQUIRED: Every acceptance criterion verified by its assigned method (test/grep/cli-review/manual).
125
+ - REQUIRED: Per-criterion evidence logged with pass/fail status and iteration count.
126
+ - BLOCKED if: verification incomplete — all criteria must be checked before routing decision.
127
+ - Route: all passed → GENERALIZE (or RECORD if skip_generalize). Some failed + iteration < max → FIX.
128
+
129
+ **GATE 5: FIX → VERIFY**
130
+ - REQUIRED: current_iteration incremented, targeted fixes applied for each failed criterion.
131
+ - REQUIRED: Fix evidence logged, understanding.md §5 updated.
132
+ - BLOCKED if: no fix attempted for failing criteria.
133
+
134
+ **GATE 6: GENERALIZE → DISCOVER**
135
+ - REQUIRED: ALL 3 layers (syntax/semantic/structural) attempted with evidence logged.
136
+ - REQUIRED: generalization_stats written with by_layer entries for all 3 layers, G5 marked done.
137
+ - BLOCKED if: any layer not attempted (thoroughness floor violation).
138
+
139
+ **GATE 7: DISCOVER → RECORD**
140
+ - REQUIRED: All hits triaged with per-item classification and reason.
141
+ - REQUIRED: remaining_actionable == 0 OR loops >= max_loops with per-item reasons logged.
142
+ - REQUIRED: G6 marked done.
143
+ - BLOCKED if: unclassified hits remain.
144
+
145
+ </execution>
146
+
147
+ <state_machine>
148
+
149
+ <states>
150
+ S_INTAKE → S_PLAN → S_EXECUTE → S_VERIFY → S_FIX → S_GENERALIZE → S_DISCOVER → S_RECORD → END
151
+ </states>
152
+
153
+ <transitions>
154
+ S_INTAKE → S_INTAKE : -c + session found (resume)
155
+ S_INTAKE → S_PLAN : requirement + criteria defined
156
+ S_INTAKE → S_INTAKE : no requirement → AskUserQuestion
157
+
158
+ S_PLAN → S_EXECUTE
159
+ S_EXECUTE → S_VERIFY
160
+
161
+ S_VERIFY → S_GENERALIZE : all passed AND NOT skip_generalize
162
+ S_VERIFY → S_RECORD : all passed AND skip_generalize
163
+ S_VERIFY → S_FIX : some failed AND iteration < max
164
+ S_VERIFY → S_PLAN : fundamental plan flaw → cross_phase_loops++ (replan). **Criteria preservation:** acceptance_criteria[] statuses are preserved; only plan.tasks[] are regenerated. Previously passed criteria retain `passed` status; failed criteria reset to `pending` for re-verification after new plan execution.
165
+ S_VERIFY → S_RECORD : some failed AND iteration >= max (escalate)
166
+
167
+ S_FIX → S_VERIFY (loop)
168
+
169
+ S_GENERALIZE → S_DISCOVER : hits found
170
+ S_GENERALIZE → S_RECORD : all 3 layers scanned with evidence, total_hits == 0
171
+
172
+ S_DISCOVER → S_EXECUTE : discovery finds area needing same implementation → cross_phase_loops++
173
+ S_DISCOVER → S_RECORD : triage complete AND remaining_actionable == 0
174
+ S_DISCOVER → S_RECORD : loops >= max_loops → log per-item reasons
175
+
176
+ S_RECORD → END
177
+ </transitions>
178
+
179
+ <actions>
180
+
181
+ ### A_INTAKE
182
+
183
+ 1. Parse requirement and flags, generate slug, create SESSION_DIR
184
+ 2. **Define acceptance criteria** — analyze requirement → derive testable criteria. Each gets `verify_method`: test | grep | cli-review | manual
185
+ - Normal: AskUserQuestion to confirm/edit
186
+ - `-y`: auto-derive, record `{"phase":"decision","type":"criteria-confirmation","status":"deferred"}`
187
+ 3. Search prior knowledge: `maestro search`, related sessions
188
+ 4. Write session.json + understanding.md section 1. Mark G1 done. Emit Goal Prompt.
189
+
190
+ Commit: `"odyssey-planex({slug}): INTAKE — parse requirement and define criteria"`
191
+
192
+ ### A_PLAN
193
+
194
+ 1. Decompose requirement into ordered tasks mapped to acceptance criteria
195
+ 2. CLI-assisted planning (optional):
196
+ ```bash
197
+ maestro delegate "PURPOSE: Create implementation plan for: {requirement}
198
+ TASK: Decompose into subtasks | Map to acceptance criteria | Identify dependencies
199
+ MODE: analysis
200
+ CONTEXT: @**/* | Criteria: {criteria_summary}
201
+ EXPECTED: JSON [{task_id, title, description, criteria_refs, deps}]
202
+ " --role analyze --mode analysis
203
+ ```
204
+ Run with `run_in_background: true`, wait for callback.
205
+ 3. Write session.json.plan, append evidence (planning), update understanding.md section 2. Mark G2 done.
206
+
207
+ Commit: `"odyssey-planex({slug}): PLAN — create execution plan"`
208
+
209
+ ### A_EXECUTE
210
+
211
+ #### Step 1: Execution Options Confirmation
212
+
213
+ **Skip if** `-y` flag OR `--method` explicitly set OR `execution_config.confirmed == true` (resume).
214
+
215
+ Load available tools: `maestro delegate-config show --json`.
216
+
217
+ Present AskUserQuestion with 3 questions:
218
+ 1. **Executor** — Auto (domain routing) | Agent (all tasks) | specific CLI tool | Other (custom domain routing)
219
+ 2. **Review** — Skip | {tool} review (git diff quality check)
220
+ 3. **Verify** — Auto (delegate convergence + structure + anti-pattern check) | specific tool | Skip
221
+
222
+ Parse response → write `execution_config` to session.json, set `confirmed: true`. `--skip-verify` overrides verification to `"Skip"`.
223
+
224
+ #### Step 2: Executor Resolution
225
+
226
+ Per-task domain routing (when method == "auto"):
227
+
228
+ | Domain | Keywords / Patterns | Extensions |
229
+ |--------|-------------------|------------|
230
+ | frontend | UI, component, page, style, layout, CSS, view | .tsx/.jsx/.vue/.css/.html/.svelte |
231
+ | backend | API, server, database, service, algorithm, worker | .go/.rs/.java/.py/.sql/.proto |
232
+ | general | mixed, config, tests, unclear | .ts/.js/other |
233
+
234
+ Resolution: `execution_config.domain_routing[domain]` → fallback `domain_routing.default` ("agent").
235
+
236
+ #### Step 3: Task Execution
237
+
238
+ Execute tasks per plan order. Independent tasks may run in parallel.
239
+
240
+ **Agent path:**
241
+ ```
242
+ Spawn Agent with: task definition, acceptance criteria refs, prior task summaries, specs_content
243
+ Agent implements → verifies convergence → auto-fix (max 3) → returns result
244
+ ```
245
+
246
+ **CLI path:**
247
+ ```bash
248
+ maestro delegate "PURPOSE: Implement task ${task_id}: ${title}; success = criteria ${criteria_refs} satisfied
249
+ TASK: ${description} | Read existing code first | Verify convergence criteria after changes
250
+ MODE: write
251
+ CONTEXT: @${scope}/**/* | Criteria: ${criteria_summary}
252
+ EXPECTED: Working code changes, convergence evidence, summary of what was done
253
+ CONSTRAINTS: Scope limited to task files | Follow project specs
254
+
255
+ ## Acceptance Criteria (must satisfy)
256
+ ${criteria_refs.map(ref => criteria[ref].criterion).join('\n')}
257
+
258
+ ## Implementation Steps
259
+ ${task.description}
260
+
261
+ ## Project Specs
262
+ ${specs_content}
263
+
264
+ ## Prior Task Summaries
265
+ ${prior_summaries}
266
+ " --to ${resolved_executor} --mode write --id planex-${slug}-${task_id}
267
+ ```
268
+
269
+ Run with `run_in_background: true`, wait for callback.
270
+
271
+ **Deviation Rule** — max 3 auto-fix attempts per task:
272
+ 1. First attempt: normal dispatch
273
+ 2. Retry: `--resume planex-${slug}-${task_id}` with simplified prompt
274
+ 3. Final: fallback to Agent path
275
+ 4. All 3 fail → mark task `blocked`, record checkpoint, continue remaining tasks
276
+
277
+ #### Step 4: Per-Task Evidence
278
+
279
+ Per completed task:
280
+ - Record evidence: `{"phase":"execution","type":"task-completed","task_id":"T1","executor":"agent|agy|...","files_modified":[],"summary":"","attempt":1}`
281
+ - Update task status in session.json plan
282
+
283
+ #### Step 5: Post-Execution Validation
284
+
285
+ **Skip if** `execution_config.verification_tool == "Skip"` OR `--skip-verify` OR no completed tasks.
286
+
287
+ **Check 1: Summary Consistency** — cross-check task status vs actual file changes (git diff).
288
+
289
+ **Check 2: CLI Verification Gate** — delegate to external model:
290
+ ```bash
291
+ maestro delegate "PURPOSE: Verify execution output meets acceptance criteria; success = all criteria verified with file:line evidence
292
+ TASK:
293
+ 1. CONVERGENCE: For each criterion, read actual code, verify behavior exists, report status with evidence
294
+ 2. EXISTENCE: Verify all expected files exist on disk
295
+ 3. SUBSTANCE: Verify real implementation — flag stubs, placeholders, TODO-only
296
+ 4. ANTI-PATTERNS: Scan for TODO/FIXME/HACK, console.log debug, disabled tests
297
+ MODE: analysis
298
+ CONTEXT: @${modified_files}
299
+ EXPECTED: JSON { convergence: [{criterion, status, evidence}], issues: [{type, file, line, severity}], overall: passed|gaps_found }
300
+ CONSTRAINTS: Read-only | Check ALL criteria exhaustively | Evidence must be file:line
301
+
302
+ ## Acceptance Criteria (verify each)
303
+ ${acceptance_criteria.map(c => c.criterion).join('\n')}
304
+
305
+ ## Modified Files
306
+ ${modified_files.join('\n')}
307
+ " --to ${execution_config.verification_tool} --mode analysis
308
+ ```
309
+
310
+ Run with `run_in_background: true`, wait for callback.
311
+
312
+ On result:
313
+ - `overall == "passed"` → proceed to S_VERIFY with boosted confidence
314
+ - `overall == "gaps_found"` → log findings, proceed to S_VERIFY
315
+
316
+ **Check 3: Code Review** (if `execution_config.code_review_tool != "Skip"`):
317
+ ```bash
318
+ maestro delegate "Review git diff for correctness, style, bugs" --to ${code_review_tool} --mode analysis --rule analysis-review-code-quality
319
+ ```
320
+
321
+ #### Step 6: Completion
322
+
323
+ Update understanding.md section 3. Mark G3 done.
324
+
325
+ Commit: `"odyssey-planex({slug}): EXECUTE — implementation complete"`
326
+
327
+ ### A_VERIFY
328
+
329
+ Iron gate — every acceptance criterion checked objectively.
330
+
331
+ **Verify each criterion by method:**
332
+
333
+ | Method | Action |
334
+ |--------|--------|
335
+ | `test` | Run relevant tests, check pass/fail |
336
+ | `grep` | Grep for expected pattern |
337
+ | `cli-review` | `maestro delegate "PURPOSE: Verify criterion {criterion_id}: {criterion}\nTASK: Read implementation code \| Check behavior matches criterion \| Report pass/fail with file:line evidence\nMODE: analysis\nCONTEXT: @{relevant_files}\nEXPECTED: JSON {criterion_id, status: passed\|failed, evidence: [{file, line, detail}]}" --role review --mode analysis` |
338
+ | `manual` | Normal: AskUserQuestion / `-y`: record `deferred` |
339
+
340
+ Record per criterion: `{"phase":"verification","type":"criterion-check","criterion_id":"AC1","method":"","result":"passed|failed","evidence":"","iteration":N}`. Update acceptance_criteria[].status. Append to iterations[].
341
+
342
+ Update understanding.md section 4 with pass/fail table.
343
+
344
+ **Route:** all passed → mark G4 done → next state. Some failed + iteration < max → S_FIX. Some failed + iteration >= max → Normal: AskUserQuestion (continue/lower bar/accept) / `-y`: `deferred`, proceed S_RECORD.
345
+
346
+ Commit: `"odyssey-planex({slug}): VERIFY — acceptance check"`
347
+
348
+ ### A_FIX
349
+
350
+ 1. Increment current_iteration
351
+ 2. For each failed criterion: diagnose gap → targeted code fix
352
+ 3. CLI fix review (optional):
353
+ ```bash
354
+ maestro delegate "PURPOSE: Review fixes for failing criteria; success = no regressions and fixes correct
355
+ TASK: Check fix correctness | Verify no regressions on passing criteria | Report verdict with file:line evidence
356
+ MODE: analysis
357
+ CONTEXT: @{modified_files} | Passing: {passing} | Fixed: {fixed}
358
+ EXPECTED: JSON {verdict: passed|concerns_found, regression_risk: low|medium|high, concerns: [{criterion_id, file, line, description}]}
359
+ CONSTRAINTS: Read-only | Check ALL passing criteria for regressions
360
+ " --role review --mode analysis
361
+ ```
362
+ 4. Append evidence (fix), update understanding.md section 5 → S_VERIFY
363
+
364
+ Commit: `"odyssey-planex({slug}): FIX — targeted fix for failing criteria"`
365
+
366
+ ### A_GENERALIZE
367
+
368
+ **MANDATORY — executes unless `skip_generalize == true`. "All criteria passed" or context pressure are NOT valid skip reasons.**
369
+
370
+ Pattern source: implementation patterns from executed tasks.
371
+
372
+ **Step 1 — 3-layer pattern extraction** from implementation:
373
+
374
+ | Layer | Method | Targets |
375
+ |-------|--------|---------|
376
+ | Syntax | Build regex from implementation diffs → Grep | API contract patterns, validation shapes, error response format, config structure |
377
+ | Semantic | Understand implementation pattern → Agent scan | Similar feature needs elsewhere, analogous data flows, parallel business logic |
378
+ | Structural | Find modules with same structure / dependency shape | Parallel module structures, sibling endpoints, same-shape services |
379
+
380
+ Write `session.json.patterns[]`: `[{id, source, layer, signature, description, risk, fix_template, confidence}]`
381
+
382
+ **Thoroughness floor:** ALL 3 layers must be attempted and logged. Each layer records search method, scope, hit count in evidence phase=generalization. "No hits" requires all 3 layers to return 0 with logged evidence.
383
+
384
+ **Step 2 — 4-agent concurrent scan** (single message, 4 Agents):
385
+
386
+ | Agent | Strategy | Scope |
387
+ |-------|----------|-------|
388
+ | Syntax grep | Grep regex from pattern signatures | Full project |
389
+ | Semantic scan | Implementation pattern check | Related modules |
390
+ | Structural match | Find structurally similar modules | Full project |
391
+ | Historical grep | `git log -S` for pattern signatures | Git history |
392
+
393
+ **Step 3 — Cross-layer dedup:** multi-layer hit → boost | single-layer → `needs_review` | historically fixed → `regression_risk`
394
+
395
+ **Step 4 — Iterative deepening:** Module with ≥3 hits → targeted deep scan (max 1 round).
396
+
397
+ **Step 5 — Persist:** Update understanding.md section 6 + write `session.json.generalization_stats`:
398
+ ```json
399
+ {"patterns_extracted": 0, "total_hits": 0, "cross_layer_confirmed": 0, "regression_risks": 0, "by_layer": {"syntax": 0, "semantic": 0, "structural": 0}, "deepening_triggered": false}
400
+ ```
401
+
402
+ **Transition guard:** `S_GENERALIZE → S_RECORD` requires `by_layer` has entries for all 3 layers with search evidence logged. Mark G5 done.
403
+
404
+ Commit: `"odyssey-planex({slug}): GENERALIZE — pattern scan complete"`
405
+
406
+ ### A_DISCOVER
407
+
408
+ **Executes whenever `total_hits > 0`. Cannot be skipped without `skip_generalize == true`.**
409
+
410
+ 1. **Triage** each hit with ±10 lines context → classify:
411
+ - `bug` — area needing same implementation (missing feature parity)
412
+ - `risk` — potential inconsistency or missing pattern application
413
+ - `safe` — false positive (must log individual reason — blanket "pre-existing" forbidden)
414
+
415
+ 2. **Route (planex-specific — routes to S_EXECUTE, not S_FIX):**
416
+
417
+ | Classification | Action |
418
+ |---------------|--------|
419
+ | needs same implementation | Route to S_EXECUTE with new task, `cross_phase_loops++` |
420
+ | risk + guard addable | Fix directly |
421
+ | risk + complex | Create issue |
422
+ | safe | Skip with logged per-item reason |
423
+
424
+ Normal: AskUserQuestion per hit | `-y`: auto-route to execute, create issue for rest
425
+
426
+ 3. **Cross-phase loops:** `loops >= max_loops` → must log per-item reasons, advance to S_RECORD.
427
+
428
+ 4. Append evidence phase=discovery. Update understanding.md section 7. Mark G6 done.
429
+
430
+ Commit: `"odyssey-planex({slug}): DISCOVER — findings classified"`
431
+
432
+ ### A_RECORD
433
+
434
+ 1. Iteration summary: what worked, what needed rework, fix cycle patterns
435
+ 2. understanding.md section 8 — learnings by Knowledge Persistence categories:
436
+ - Multi-round fix cycle pattern → `/spec-add debug`
437
+ - Reusable implementation pattern → `/spec-add coding`
438
+ - Acceptance criteria template → `/spec-add review`
439
+ - Generalization pattern → `/spec-add coding`
440
+
441
+ 3. Mark G7 done. Pending decisions: Normal → AskUserQuestion | `-y` → skip (show deferred count).
442
+
443
+ 4. **Goal audit (hardened):**
444
+ - `done` → confirmed
445
+ - `skipped` → confirmed ONLY if corresponding `skip_when` flag is true
446
+ - **Hard rule:** G5 and G6 CANNOT be `skipped` unless `skip_generalize == true`. Pending without flag → `failed` (Normal: AskUserQuestion | `-y`: record `failed`)
447
+ - `phase_goals_all_done = true` only when all goals pass this audit
448
+
449
+ 5. `current_state = "COMPLETED"`, emit completion summary.
450
+
451
+ **Completion summary:**
452
+ ```
453
+ --- PLANEX ODYSSEY COMPLETE ---
454
+ Requirement: {requirement}
455
+ Criteria: {passed}/{total} passed
456
+ Iterations: {N} cycles
457
+ Patterns: {patterns_extracted} ({by_layer} distribution)
458
+ Scan hits: {total_hits} ({cross_layer_confirmed} cross-layer confirmed)
459
+ Issues: {N} created | Decisions: {N} resolved, {M} pending, {K} deferred
460
+ Learnings: {N} spec entries
461
+ Self-iter: {N} rounds across {M} stages
462
+ Goals: {done}/{total} confirmed ({skipped} skipped)
463
+ Status: {ALL_PASSED|PARTIAL|ESCALATED}
464
+ ---
465
+ ```
466
+
467
+ Commit: `"odyssey-planex({slug}): RECORD — session summary"`
468
+
469
+ </actions>
470
+
471
+ <appendix>
472
+
473
+ ### `-y` planex-specific points
474
+
475
+ | Decision Point | Normal | `-y` |
476
+ |---------------|--------|------|
477
+ | S_INTAKE criteria confirmation | AskUserQuestion | auto-derive, `deferred` |
478
+ | S_EXECUTE execution options | AskUserQuestion | use defaults (auto/Skip/Auto), `confirmed: true` |
479
+ | S_EXECUTE task blocked (3 retries) | AskUserQuestion: continue or stop | auto continue, log blocked |
480
+ | S_VERIFY manual criterion | AskUserQuestion | `deferred` |
481
+ | S_VERIFY max iteration reached | AskUserQuestion | auto accept, `deferred` |
482
+ | A_DISCOVER hit routing | AskUserQuestion | auto-route to execute, create issue for rest |
483
+
484
+ ### Goal Prompt convergence rules
485
+
486
+ ```
487
+ Exhaustive iteration: until all acceptance_criteria[*].status==passed
488
+ AND phase_goals_all_done=true. Verify failure auto-triggers fix->re-verify loop.
489
+ Each fix round re-verifies; new criterion violations continue fixing within max_iterations.
490
+ No "close enough" — all criteria must ALL pass.
491
+ ```
492
+
493
+ ### Iteration Model
494
+
495
+ ```
496
+ S_EXECUTE → S_VERIFY ──all pass──→ S_GENERALIZE → S_DISCOVER → S_RECORD
497
+ │ │
498
+ some fail + iter < max 3-layer scan, 0 hits ─→ S_RECORD
499
+
500
+ S_FIX ──→ S_VERIFY (loop)
501
+ ```
502
+
503
+ Max iterations (default 3) prevents infinite loops. Each iteration records criteria_before, gaps_fixed, criteria_after.
504
+
505
+ </appendix>
506
+
507
+ </state_machine>
508
+
509
+ <error_codes>
510
+ | Code | Severity | Condition | Recovery |
511
+ |------|----------|-----------|----------|
512
+ | E001 | error | No requirement provided | Provide requirement |
513
+ | W001 | warning | No acceptance criteria derived | Manual definition needed |
514
+ | W002 | warning | Max iterations reached, criteria still failing | Escalate to user |
515
+ | W003 | warning | CLI review regression concern | Review before next iteration |
516
+ | W004 | warning | Generalization 0 hits after full 3-layer scan | Advance to S_RECORD (requires all 3 layers attempted with evidence) |
517
+ </error_codes>
518
+
519
+ <success_criteria>
520
+ - [ ] Requirement parsed with >=1 acceptance criterion (verify_method assigned)
521
+ - [ ] Plan tasks mapped to criteria; execution options confirmed
522
+ - [ ] Tasks dispatched via resolved executor with deviation rule (max 3 retries)
523
+ - [ ] Post-execution validation gate run (unless --skip-verify)
524
+ - [ ] Every criterion verified per method; failing → targeted fix (not re-implementation)
525
+ - [ ] Iteration count tracked and max respected; unfixed criteria individually classified
526
+ - [ ] understanding.md sections 1-8 updated per phase; phase_goals G1-G7 audited
527
+ - [ ] Generalization + discovery completed (unless --skip-generalize)
528
+ - [ ] Quality Gate self-iteration triggered when insufficient
529
+ - [ ] Goal Prompt displayed once after intake; `-y` mode: no blocking prompts
530
+ - [ ] Session resumable via -c; completion summary output
531
+ </success_criteria>
532
+
533
+ <next_step_routing>
534
+ | Condition | Next |
535
+ |-----------|------|
536
+ | All criteria passed | `/odyssey-review-test-fix <changed-files>` |
537
+ | Max iterations, still failing | `/odyssey-debug "<failing criterion>"` |
538
+ | Formal review | `/quality-review <phase>` |
539
+ | Issues from discoveries | `/manage-issue list --source planex-odyssey` |
540
+ | Pattern worth documenting | `/learn-decompose <module>` |
541
+ </next_step_routing>
542
+ </output>