pi-maestro-flow 0.2.0 → 0.3.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 (235) hide show
  1. package/README.md +44 -72
  2. package/agents/cross-role-reviewer.md +1 -1
  3. package/agents/impeccable-agent.md +1 -1
  4. package/agents/ralph-executor.md +1 -1
  5. package/agents/team-worker.md +1 -1
  6. package/agents/workflow-analyzer.md +1 -1
  7. package/agents/workflow-codebase-mapper.md +1 -1
  8. package/agents/workflow-collab-planner.md +1 -1
  9. package/agents/workflow-debugger.md +1 -1
  10. package/agents/workflow-executor.md +1 -1
  11. package/agents/workflow-integration-checker.md +1 -1
  12. package/agents/workflow-nyquist-auditor.md +1 -1
  13. package/agents/workflow-phase-researcher.md +1 -1
  14. package/agents/workflow-planner.md +1 -1
  15. package/agents/workflow-project-researcher.md +1 -1
  16. package/agents/workflow-reviewer.md +1 -1
  17. package/agents/workflow-verifier.md +1 -1
  18. package/package.json +13 -4
  19. package/skills/codify-to-knowhow/SKILL.md +1 -1
  20. package/skills/delegation-check/SKILL.md +1 -1
  21. package/skills/domain-add/SKILL.md +5 -7
  22. package/skills/insight-challenge/SKILL.md +1 -1
  23. package/skills/learn-decompose/SKILL.md +4 -4
  24. package/skills/learn-follow/SKILL.md +5 -5
  25. package/skills/learn-investigate/SKILL.md +5 -5
  26. package/skills/learn-second-opinion/SKILL.md +5 -5
  27. package/skills/maestro/SKILL.md +9 -10
  28. package/skills/maestro-amend/SKILL.md +3 -3
  29. package/skills/maestro-analyze/SKILL.md +10 -13
  30. package/skills/maestro-blueprint/SKILL.md +8 -11
  31. package/skills/maestro-brainstorm/SKILL.md +11 -14
  32. package/skills/maestro-collab/SKILL.md +4 -4
  33. package/skills/maestro-companion/SKILL.md +3 -3
  34. package/skills/maestro-composer/SKILL.md +11 -12
  35. package/skills/maestro-execute/SKILL.md +9 -12
  36. package/skills/maestro-fork/SKILL.md +8 -11
  37. package/skills/maestro-grill/SKILL.md +13 -16
  38. package/skills/maestro-guard/SKILL.md +5 -5
  39. package/skills/maestro-help/SKILL.md +3 -3
  40. package/skills/maestro-impeccable/SKILL.md +7 -7
  41. package/skills/maestro-init/SKILL.md +9 -12
  42. package/skills/maestro-merge/SKILL.md +6 -8
  43. package/skills/maestro-milestone-audit/SKILL.md +3 -5
  44. package/skills/maestro-milestone-complete/SKILL.md +9 -12
  45. package/skills/maestro-milestone-release/SKILL.md +9 -11
  46. package/skills/maestro-next/SKILL.md +5 -5
  47. package/skills/maestro-overlay/SKILL.md +16 -16
  48. package/skills/maestro-plan/SKILL.md +9 -12
  49. package/skills/maestro-player/SKILL.md +5 -5
  50. package/skills/maestro-quick/SKILL.md +5 -7
  51. package/skills/maestro-ralph/SKILL.md +16 -17
  52. package/skills/maestro-ralph-cli/SKILL.md +6 -6
  53. package/skills/maestro-ralph-cli-execute/SKILL.md +2 -2
  54. package/skills/maestro-ralph-execute/SKILL.md +4 -4
  55. package/skills/maestro-ralph-v2/SKILL.md +18 -19
  56. package/skills/maestro-roadmap/SKILL.md +8 -9
  57. package/skills/maestro-swarm-workflow/SKILL.md +9 -9
  58. package/skills/maestro-tools-execute/SKILL.md +5 -7
  59. package/skills/maestro-tools-register/SKILL.md +7 -9
  60. package/skills/maestro-ui-codify/SKILL.md +9 -10
  61. package/skills/maestro-universal-workflow/SKILL.md +15 -15
  62. package/skills/maestro-update/SKILL.md +10 -10
  63. package/skills/manage-codebase-rebuild/SKILL.md +4 -6
  64. package/skills/manage-drift-realign/SKILL.md +8 -11
  65. package/skills/manage-harvest/SKILL.md +6 -9
  66. package/skills/manage-issue/SKILL.md +5 -8
  67. package/skills/manage-issue-discover/SKILL.md +8 -11
  68. package/skills/manage-kg-extractors/SKILL.md +3 -3
  69. package/skills/manage-knowhow/SKILL.md +3 -5
  70. package/skills/manage-knowhow-capture/SKILL.md +4 -6
  71. package/skills/manage-knowledge-audit/SKILL.md +6 -9
  72. package/skills/manage-status/SKILL.md +3 -5
  73. package/skills/manage-wiki/SKILL.md +5 -7
  74. package/skills/odyssey-debug/SKILL.md +13 -13
  75. package/skills/odyssey-improve/SKILL.md +15 -15
  76. package/skills/odyssey-planex/SKILL.md +16 -16
  77. package/skills/odyssey-review-test-fix/SKILL.md +11 -11
  78. package/skills/odyssey-ui/SKILL.md +10 -10
  79. package/skills/prompt-generator/SKILL.md +5 -5
  80. package/skills/quality-auto-test/SKILL.md +3 -5
  81. package/skills/quality-debug/SKILL.md +3 -5
  82. package/skills/quality-refactor/SKILL.md +3 -5
  83. package/skills/quality-retrospective/SKILL.md +10 -13
  84. package/skills/quality-review/SKILL.md +5 -8
  85. package/skills/quality-sync/SKILL.md +3 -5
  86. package/skills/quality-test/SKILL.md +4 -6
  87. package/skills/scholar-anti-ai-writing/SKILL.md +1 -1
  88. package/skills/scholar-citation-verify/SKILL.md +1 -1
  89. package/skills/scholar-experiment/SKILL.md +2 -2
  90. package/skills/scholar-ideation/SKILL.md +7 -7
  91. package/skills/scholar-latex-organizer/SKILL.md +1 -1
  92. package/skills/scholar-publish/SKILL.md +3 -3
  93. package/skills/scholar-rebuttal-pro/SKILL.md +3 -3
  94. package/skills/scholar-review/SKILL.md +1 -1
  95. package/skills/scholar-writing/SKILL.md +1 -1
  96. package/skills/security-audit/SKILL.md +2 -4
  97. package/skills/skill-generator/SKILL.md +3 -3
  98. package/skills/skill-iter-tune/SKILL.md +3 -3
  99. package/skills/skill-simplify/SKILL.md +1 -1
  100. package/skills/skill-tuning/SKILL.md +1 -1
  101. package/skills/spec-add/SKILL.md +5 -7
  102. package/skills/spec-load/SKILL.md +3 -5
  103. package/skills/spec-remove/SKILL.md +4 -6
  104. package/skills/spec-setup/SKILL.md +6 -8
  105. package/skills/team-adversarial-swarm/SKILL.md +5 -5
  106. package/skills/team-arch-opt/SKILL.md +2 -2
  107. package/skills/team-brainstorm/SKILL.md +3 -3
  108. package/skills/team-coordinate/SKILL.md +4 -4
  109. package/skills/team-designer/SKILL.md +1 -1
  110. package/skills/team-executor/SKILL.md +3 -3
  111. package/skills/team-frontend/SKILL.md +2 -2
  112. package/skills/team-frontend-debug/SKILL.md +3 -3
  113. package/skills/team-interactive-craft/SKILL.md +2 -2
  114. package/skills/team-issue/SKILL.md +3 -3
  115. package/skills/team-lifecycle-v4/SKILL.md +4 -4
  116. package/skills/team-motion-design/SKILL.md +2 -2
  117. package/skills/team-perf-opt/SKILL.md +3 -3
  118. package/skills/team-planex/SKILL.md +2 -2
  119. package/skills/team-quality-assurance/SKILL.md +3 -3
  120. package/skills/team-review/SKILL.md +3 -3
  121. package/skills/team-roadmap-dev/SKILL.md +3 -3
  122. package/skills/team-swarm/SKILL.md +4 -4
  123. package/skills/team-tech-debt/SKILL.md +2 -2
  124. package/skills/team-testing/SKILL.md +3 -3
  125. package/skills/team-ui-polish/SKILL.md +2 -2
  126. package/skills/team-uidesign/SKILL.md +2 -2
  127. package/skills/team-ultra-analyze/SKILL.md +4 -4
  128. package/skills/team-ux-improve/SKILL.md +3 -3
  129. package/skills/team-visual-a11y/SKILL.md +2 -2
  130. package/skills/workflow-skill-designer/SKILL.md +8 -8
  131. package/templates/business-test-report.json +68 -0
  132. package/templates/config.json +48 -0
  133. package/templates/context.md +16 -0
  134. package/templates/doc-index.json +11 -0
  135. package/templates/index.json +68 -0
  136. package/templates/issue.json +36 -0
  137. package/templates/plan.json +38 -0
  138. package/templates/project.md +60 -0
  139. package/templates/reflection-log.md +20 -0
  140. package/templates/roadmap.md +45 -0
  141. package/templates/scratch-index.json +19 -0
  142. package/templates/search-tool.json +1 -0
  143. package/templates/search-tools.md +47 -0
  144. package/templates/state.json +18 -0
  145. package/templates/task-summary.md +21 -0
  146. package/templates/task.json +89 -0
  147. package/templates/terminology-template.json +22 -0
  148. package/templates/uat.md +21 -0
  149. package/templates/validation.json +31 -0
  150. package/templates/verification.json +37 -0
  151. package/templates/workflow.md +14 -0
  152. package/templates/worktree-scope.json +9 -0
  153. package/templates/worktrees.json +26 -0
  154. package/workflows/agy-instructions.md +156 -0
  155. package/workflows/analyze.md +768 -0
  156. package/workflows/auto-test.md +705 -0
  157. package/workflows/blueprint.md +406 -0
  158. package/workflows/boundary-grill.md +50 -0
  159. package/workflows/brainstorm.md +508 -0
  160. package/workflows/business-test.md +574 -0
  161. package/workflows/chinese-response.md +25 -0
  162. package/workflows/claude-instructions.md +167 -0
  163. package/workflows/codebase-rebuild.md +267 -0
  164. package/workflows/codebase-refresh.md +168 -0
  165. package/workflows/codex-instructions.md +156 -0
  166. package/workflows/coding-philosophy.md +70 -0
  167. package/workflows/command-authoring.md +823 -0
  168. package/workflows/debug.md +409 -0
  169. package/workflows/delegate-usage.md +99 -0
  170. package/workflows/domain-add.md +121 -0
  171. package/workflows/drift-realign.md +396 -0
  172. package/workflows/execute.md +631 -0
  173. package/workflows/explore-usage.md +93 -0
  174. package/workflows/finish-work.md +124 -0
  175. package/workflows/fork.md +162 -0
  176. package/workflows/grill.md +494 -0
  177. package/workflows/harvest.md +478 -0
  178. package/workflows/impeccable.md +168 -0
  179. package/workflows/init.md +157 -0
  180. package/workflows/instruction-authoring-guide.md +97 -0
  181. package/workflows/integration-test.md +186 -0
  182. package/workflows/interview-mechanics.md +8 -0
  183. package/workflows/issue-analyze.md +20 -0
  184. package/workflows/issue-discover.md +238 -0
  185. package/workflows/issue-execute.md +110 -0
  186. package/workflows/issue-gaps-analyze.codex.md +256 -0
  187. package/workflows/issue-gaps-analyze.md +215 -0
  188. package/workflows/issue-plan.md +110 -0
  189. package/workflows/issue.md +338 -0
  190. package/workflows/knowhow.md +429 -0
  191. package/workflows/knowledge-audit.md +355 -0
  192. package/workflows/learn.md +271 -0
  193. package/workflows/maestro-chain-execute.md +20 -0
  194. package/workflows/maestro-link-coordinate.md +114 -0
  195. package/workflows/maestro-super.md +120 -0
  196. package/workflows/maestro.md +501 -0
  197. package/workflows/map.md +74 -0
  198. package/workflows/merge.md +122 -0
  199. package/workflows/milestone-audit.md +155 -0
  200. package/workflows/milestone-complete.md +167 -0
  201. package/workflows/milestone-release.md +82 -0
  202. package/workflows/odyssey-base-codex.md +305 -0
  203. package/workflows/odyssey-base.md +256 -0
  204. package/workflows/overlays.md +109 -0
  205. package/workflows/plan.md +520 -0
  206. package/workflows/quick.md +350 -0
  207. package/workflows/ralph-amend-goal.md +177 -0
  208. package/workflows/refactor.md +87 -0
  209. package/workflows/retrospective.md +471 -0
  210. package/workflows/review.md +448 -0
  211. package/workflows/roadmap-common.md +193 -0
  212. package/workflows/roadmap.md +106 -0
  213. package/workflows/shell-exec-protocol.md +30 -0
  214. package/workflows/skill-authoring.md +265 -0
  215. package/workflows/spec-generate.md +475 -0
  216. package/workflows/specs-add.md +123 -0
  217. package/workflows/specs-load.md +76 -0
  218. package/workflows/specs-remove.md +104 -0
  219. package/workflows/specs-setup.md +316 -0
  220. package/workflows/status.md +149 -0
  221. package/workflows/sync.md +116 -0
  222. package/workflows/tdd.md +255 -0
  223. package/workflows/test-gen.md +226 -0
  224. package/workflows/test.md +385 -0
  225. package/workflows/tools-spec.md +70 -0
  226. package/workflows/ui-codify-extract.md +372 -0
  227. package/workflows/ui-codify-knowhow.md +258 -0
  228. package/workflows/ui-codify-package.md +159 -0
  229. package/workflows/ui-codify.md +227 -0
  230. package/workflows/ui-design.md +393 -0
  231. package/workflows/ui-style.md +201 -0
  232. package/workflows/verify.md +557 -0
  233. package/workflows/wiki-connect.md +153 -0
  234. package/workflows/wiki-digest.md +180 -0
  235. package/workflows/wiki-manage.md +113 -0
@@ -0,0 +1,409 @@
1
+ # Debug Workflow
2
+
3
+ ---
4
+
5
+ ## Iron Law
6
+
7
+ **NO FIX PROPOSALS WITHOUT ROOT CAUSE EVIDENCE.**
8
+
9
+ Before proposing any fix, you MUST have:
10
+ 1. Reproduced or confirmed the symptom
11
+ 2. Gathered evidence (logs, code traces, test output)
12
+ 3. Identified the specific root cause with file:line references
13
+
14
+ Fix proposals without root cause evidence are forbidden — even "obvious" fixes.
15
+
16
+ ---
17
+
18
+ ## Red Flags — These Thoughts Mean STOP
19
+
20
+ If you catch yourself thinking any of these, STOP and return to evidence gathering:
21
+
22
+ - "Quick fix for now, investigate later"
23
+ - "I don't fully understand but this might work"
24
+ - "This is just a simple case, no need for full investigation"
25
+ - "Let me just try changing X and see if it works"
26
+ - "The fix is obvious, I don't need to reproduce it"
27
+ - "I'll skip the reproduction step to save time"
28
+ - "Multiple changes at once will be faster"
29
+ - "I already know what the problem is" (without evidence)
30
+
31
+ All of these mean: **return to Step 3/6 evidence gathering**.
32
+
33
+ ---
34
+
35
+ ## Rationalization Table
36
+
37
+ | Excuse | Reality |
38
+ |--------|---------|
39
+ | "It's probably just a typo" | Verify before assuming — typos cause cascading failures |
40
+ | "The error message says X so it must be X" | Error messages point to symptoms, not causes |
41
+ | "I fixed something similar before" | Similar symptoms can have different root causes |
42
+ | "The fix works in my test" | One passing test doesn't prove root cause was found |
43
+ | "We don't have time for full investigation" | Quick fixes create more bugs than they solve |
44
+ | "The code looks correct" | Reading code is not tracing execution |
45
+ | "Let me just add a try-catch/null check" | Suppressing errors hides the real problem |
46
+ | "3 failed hypotheses, let me try a 4th" | After 3 failures, STOP — escalate |
47
+
48
+ ---
49
+
50
+ ## Escalation Rule — 3-Strike Architecture Check
51
+
52
+ After **3 failed hypotheses**, STOP:
53
+
54
+ 1. Summarize all failed hypotheses and evidence
55
+ 2. Question architecture: "Is the problem deeper than individual code?"
56
+ 3. AskUserQuestion: Continue with different approach? / Re-examine architecture? / Bring in additional context?
57
+
58
+ NEVER propose a 4th hypothesis without user confirmation.
59
+
60
+ ---
61
+
62
+ ## Backward Tracing Method
63
+
64
+ 1. **Find** where incorrect value/behavior first appears
65
+ 2. **Trace backward** through call chain — what called this? What value was passed?
66
+ 3. **Continue** until you find where correct data becomes incorrect
67
+ 4. **Fix at the source**, not the symptom location
68
+
69
+ ---
70
+
71
+ ### Step 1: Check Active Sessions
72
+
73
+ ```bash
74
+ # Check scratch dirs (resolved via artifact registry) for debug sessions
75
+ find .workflow/scratch -path "*/.debug/*" -name "understanding.md" 2>/dev/null | head -5
76
+ find .workflow/scratch -type d -name "debug-*" 2>/dev/null | head -5
77
+ ```
78
+
79
+ **If active sessions exist AND no $ARGUMENTS:**
80
+
81
+ Read each session's understanding.md header for status and current hypothesis.
82
+
83
+ Display:
84
+ ```
85
+ ## Active Debug Sessions
86
+
87
+ | # | Location | Status | Current Hypothesis |
88
+ |---|----------|--------|--------------------|
89
+ | 1 | scratch/20260420-plan-P3-auth/.debug/jwt-expiry/ | investigating | Token not refreshed on 401 |
90
+ | 2 | scratch/20260314-debug-nav-crash/ | checkpoint | Awaiting user input |
91
+
92
+ Reply with a number to resume, or describe a new issue.
93
+ ```
94
+
95
+ Wait for user response.
96
+ - Number -> resume that session (load state, go to Step 11: Spawn Continuation)
97
+ - Text -> treat as new issue (go to Step 3 or Step 2)
98
+
99
+ | Result | Action |
100
+ |--------|--------|
101
+ | Active session found, no args | Offer resume list |
102
+ | Active session found, args given | Start new investigation |
103
+ | No active sessions, no args | Error E001 |
104
+ | No active sessions, args given | Continue to appropriate mode |
105
+
106
+ If resuming: load understanding.md + evidence.ndjson, spawn continuation agent.
107
+
108
+ ---
109
+
110
+ ### Step 1.5: Load Project Specs
111
+
112
+ ```
113
+ # MANDATORY, NOT SUBSTITUTABLE by manual Read/Grep
114
+ specs_content = maestro spec load --category debug
115
+ → Pass to debug agents as prior knowledge
116
+ ```
117
+
118
+ ---
119
+
120
+ ### Step 2: Load UAT Gaps (if --from-uat)
121
+
122
+ Skip if --from-uat not set → go to Step 3.
123
+
124
+ Read `{artifact_dir}/uat.md` Gaps section. For each gap:
125
+ ```yaml
126
+ - test: T-003
127
+ truth: "User can reply to comments"
128
+ status: failed
129
+ reason: "User reported: clicking reply does nothing"
130
+ severity: major
131
+ requirement_ref: SC-002
132
+ ```
133
+
134
+ **Cluster gaps by component/area:**
135
+ - Parse affected features from truth + reason
136
+ - Group by likely component (same module, same flow, same file area)
137
+ - Each cluster becomes one debug investigation
138
+
139
+ | Clustering | Example |
140
+ |-----------|---------|
141
+ | Same component | T-003 (reply) + T-004 (edit comment) -> "comment-actions" cluster |
142
+ | Same flow | T-001 (login) + T-002 (session) -> "auth-flow" cluster |
143
+ | Unrelated | T-005 (nav color) -> standalone "nav-styling" cluster |
144
+
145
+ **Issue enrichment:** For each gap with `issue_id`, look up in `.workflow/issues/issues.jsonl` and attach `issue_context` to the gap.
146
+
147
+ If `--parallel`: → Step 5. Else: → Step 6 (sequential).
148
+
149
+ ---
150
+
151
+ ### Step 3: Gather Symptoms (standalone mode only)
152
+
153
+ Skip if `--from-uat`. Generate slug from issue description (lowercase, hyphens, max 40 chars).
154
+
155
+ Ask 5 questions via AskUserQuestion:
156
+ 1. "What should happen? (expected behavior)"
157
+ 2. "What happens instead? (actual behavior)"
158
+ 3. "Any error messages? Paste them or describe."
159
+ 4. "When did this start? Did it ever work?"
160
+ 5. "How do you trigger this? (reproduction steps)"
161
+
162
+ Also gather: `git log --oneline -10`, `git diff --stat HEAD~3`.
163
+
164
+ Store responses → create debug session directory → Step 6.
165
+
166
+ ---
167
+
168
+ ### Step 4: Determine Output Directory
169
+
170
+ | Mode | Directory |
171
+ |------|-----------|
172
+ | Phase-scoped (from UAT) | `{ARTIFACT_DIR}/.debug/{gap-slug}/` |
173
+ | Standalone | `.workflow/scratch/{YYYYMMDD}-debug-{slug}/` |
174
+
175
+ Create the directory.
176
+
177
+ ---
178
+
179
+ ### Step 5: Spawn Parallel Debug Agents — MANDATORY, NOT SUBSTITUTABLE
180
+
181
+ For each cluster, spawn concurrently (`run_in_background: false`):
182
+
183
+ - **Input**: cluster name, phase, all gaps (test_id, truth, reason, severity). Mode: `symptoms_prefilled`.
184
+ - **Process**: form 2-3 hypotheses per gap, search code for evidence, log NDJSON, confirm/refute.
185
+ - **Output per gap**: `root_cause`, `fix_direction`, `affected_files` (file:line), `confidence` (multi-factor + legacy `confidence_level`), `evidence` summary.
186
+ - **Files**: `{debug_dir}/evidence-{cluster_slug}.ndjson`, `{debug_dir}/understanding-{cluster_slug}.md`
187
+
188
+ ---
189
+
190
+ ### Step 5.5: CLI Supplementary Evidence Gathering (optional)
191
+
192
+ **Skip if** no enabled CLI tools or standalone mode with minimal context.
193
+
194
+ ```
195
+ IF no CLI tools enabled: skip to Step 6
196
+
197
+ # Build evidence request from symptoms
198
+ symptom_summary = symptoms or gap descriptions, concatenated
199
+
200
+ Bash({
201
+ command: 'maestro delegate "PURPOSE: Gather codebase evidence related to a bug investigation
202
+ TASK: Trace call chains for affected functions | Find recent changes to related files | Identify error handling gaps | Check for similar patterns elsewhere
203
+ MODE: analysis
204
+ CONTEXT: @${affected_files or scoped_path}/**/*
205
+ EXPECTED: JSON { call_chains: [{ entry, chain: [file:line...] }], recent_changes: [{ file, commits: [...] }], error_gaps: [{ file, line, description }], similar_patterns: [{ file, line, description }] }
206
+ CONSTRAINTS: Focus on code paths related to the symptoms | Max 20 entries per category
207
+
208
+ Symptoms: ${symptom_summary}
209
+ " --role explore --mode analysis',
210
+ run_in_background: true
211
+ })
212
+ ```
213
+
214
+ **On callback:**
215
+ ```
216
+ cli_evidence = maestro delegate output <id>
217
+ Parse and append to evidence.ndjson with type: "cli-exploration"
218
+ Pass cli_evidence as supplementary_context to debug agent prompts in Step 5/6
219
+ ```
220
+
221
+ ---
222
+
223
+ ### Step 6: Spawn Single Debug Agent (sequential mode) — MANDATORY, NOT SUBSTITUTABLE
224
+
225
+ Spawn agent (`run_in_background: false`):
226
+
227
+ - **Input**: slug, description, symptoms. `symptoms_prefilled: {true if from UAT}`, goal: `find_and_fix`.
228
+ - **Process**: form hypotheses, test each, log NDJSON evidence, update understanding.md.
229
+ - **Return**: `## ROOT CAUSE FOUND` | `## CHECKPOINT REACHED` | `## INVESTIGATION INCONCLUSIVE`
230
+ - **Files**: `{$DEBUG_DIR}/understanding.md`, `{$DEBUG_DIR}/evidence.ndjson`
231
+
232
+ ---
233
+
234
+ ### Step 7: Collect and Unify Results
235
+
236
+ Build unified diagnosis from all agent results:
237
+ ```json
238
+ {
239
+ "session_id": "{debug session ID}",
240
+ "completed_at": "{ISO timestamp}",
241
+ "clusters": [
242
+ {
243
+ "name": "{cluster_name}",
244
+ "gaps": [
245
+ {
246
+ "test_id": "T-003",
247
+ "root_cause": "...",
248
+ "fix_direction": "...",
249
+ "affected_files": ["src/components/Comments.tsx:42"],
250
+ "confidence": { "overall": 0.78, "dimensions": {} }
251
+ }
252
+ ]
253
+ }
254
+ ],
255
+ "confidence": {}
256
+ }
257
+ ```
258
+
259
+ ### Step 7.0: Debug Confidence Scoring
260
+
261
+ Dimensions (4): hypothesis_quality, evidence_completeness, root_cause_isolation, fix_confidence. Factors (weights): evidence_depth(.30), evidence_strength(.25), coverage_breadth(.20), reproduction(.15), consistency(.10). Map to legacy levels: <40% = low, 40-70% = medium, >70% = high.
262
+
263
+ Quality mechanisms: Pressure Pass (before Step 9) — cross-check confirmed vs refuted hypotheses. Devil's Advocate — root_cause_isolation > 0.7 → "根因在更深层?". Stall Detection — no new evidence + delta < 5% for 2 continuations → "调查可能停滞".
264
+
265
+ Readiness Gate (blocks Step 9): evidence_completeness ≥ 40% | pressure pass done | no contradicting evidence | fix_direction has specific files. If blocked → AskUserQuestion: 补充调查 or 忽略风险并确认. Append confidence table to understanding.md.
266
+
267
+ ### Step 7.1: Update Issues with Diagnosis
268
+
269
+ For each diagnosed gap with `issue_id`, update in `.workflow/issues/issues.jsonl`:
270
+ - Set `status: "diagnosed"`, `context.suggested_fix: fix_direction`, `context.notes: root_cause`
271
+ - Append to `issue_history`: `{ from: previous_status, to: "diagnosed", changed_at: now(), actor: "debug-agent" }`
272
+
273
+ ---
274
+
275
+ ### Step 8: Update UAT (if --from-uat)
276
+
277
+ Skip if standalone. For each diagnosed gap, update uat.md Gaps:
278
+ ```yaml
279
+ - test: T-003
280
+ truth: "User can reply to comments"
281
+ status: failed
282
+ reason: "User reported: clicking reply does nothing"
283
+ severity: major
284
+ root_cause: "Reply handler not wired to API endpoint"
285
+ fix_direction: "Connect onReply to POST /api/comments/{id}/reply"
286
+ affected_files: ["src/components/Comments.tsx:42", "src/api/comments.ts:78"]
287
+ ```
288
+
289
+ ---
290
+
291
+ ### Step 9: Handle Root Cause Found
292
+
293
+ ```
294
+ ------------------------------------------------------------
295
+ ROOT CAUSE IDENTIFIED
296
+ ------------------------------------------------------------
297
+
298
+ {root cause description}
299
+
300
+ Evidence:
301
+ {key evidence points with file:line references}
302
+
303
+ Recommended fix:
304
+ {fix recommendation}
305
+
306
+ ------------------------------------------------------------
307
+ Options:
308
+ 1. Fix now -- Skill({ skill: "maestro-quick", args: "apply fix" })
309
+ 2. Plan fix -- Skill({ skill: "maestro-plan", args: "{phase} --gaps" })
310
+ 3. Manual fix -- investigate/fix yourself
311
+ ------------------------------------------------------------
312
+ ```
313
+
314
+ ---
315
+
316
+ ### Step 10: Handle Checkpoint
317
+
318
+ Present checkpoint to user via AskUserQuestion. Input → spawn continuation agent. Pause → save state, exit.
319
+
320
+ ---
321
+
322
+ ### Step 11: Handle Inconclusive
323
+
324
+ Display what was checked/eliminated. Offer: 1) Continue (fresh agent with prior state) 2) Add context 3) Manual investigation.
325
+
326
+ ---
327
+
328
+ ### Step 12: Spawn Continuation Agent
329
+
330
+ Load prior state (understanding.md + evidence.ndjson) + user checkpoint response. Handle return same as Step 6.
331
+
332
+ ---
333
+
334
+ **GATE Step 12→13**: Glob `{$DEBUG_DIR}/understanding.md` AND `{$DEBUG_DIR}/evidence.ndjson` MUST exist before Step 13 report; BLOCKED if missing.
335
+
336
+ ### Step 13: Report
337
+
338
+ ```
339
+ === DEBUG SESSION ===
340
+ Mode: {standalone | from-uat | parallel}
341
+ Target: {issue or phase}
342
+
343
+ Clusters: {cluster_count} investigated
344
+ Gaps: {total_gaps} total
345
+ Diagnosed: {diagnosed_count} root causes found
346
+ Uncertain: {uncertain_count} need more investigation
347
+
348
+ Files:
349
+ {debug_dir}/understanding.md (or understanding-{cluster}.md per cluster)
350
+ {debug_dir}/evidence.ndjson (or evidence-{cluster}.ndjson per cluster)
351
+
352
+ UAT Updated: {yes/no} ({uat_path} if yes)
353
+
354
+ Next steps:
355
+ {suggested_next_command}
356
+ ```
357
+
358
+ **Next step routing:**
359
+
360
+ | Result | Suggestion |
361
+ |--------|------------|
362
+ | All root causes found | Skill({ skill: "maestro-quick", args: "apply fixes" }) or Skill({ skill: "maestro-plan", args: "--gaps" }) |
363
+ | Some inconclusive | Resume with more context or manual investigation |
364
+ | From UAT, all diagnosed | Skill({ skill: "quality-test", args: "{phase} --auto-fix" }) to trigger gap-fix loop |
365
+
366
+ ---
367
+
368
+ ## Evidence Format
369
+
370
+ **evidence.ndjson** — one JSON object per line, append-only:
371
+
372
+ ```json
373
+ {"timestamp":"2026-03-14T10:30:00+08:00","hypothesis":"JWT token not refreshed on 401","action":"grep for 401 handler","result":"Found handler but no refresh call","conclusion":"confirmed"}
374
+ ```
375
+
376
+ ---
377
+
378
+ ## Understanding Template
379
+
380
+ ```markdown
381
+ # Debug: {issue slug}
382
+
383
+ ## Status
384
+ {investigating | checkpoint | resolved | inconclusive}
385
+
386
+ ## Issue
387
+ {original issue description}
388
+
389
+ ## Symptoms
390
+ - Expected: {expected}
391
+ - Actual: {actual}
392
+ - Errors: {errors}
393
+ - Timeline: {timeline}
394
+ - Reproduction: {steps}
395
+
396
+ ## Hypotheses
397
+
398
+ ### H1: {hypothesis} [CONFIRMED/REFUTED/TESTING]
399
+ Evidence: {summary of evidence}
400
+
401
+ ### H2: {hypothesis} [CONFIRMED/REFUTED/TESTING]
402
+ Evidence: {summary}
403
+
404
+ ## Root Cause
405
+ {filled when found}
406
+
407
+ ## Fix
408
+ {filled when determined}
409
+ ```
@@ -0,0 +1,99 @@
1
+ # Delegate Usage
2
+
3
+ ```bash
4
+ maestro delegate "<PROMPT>" [options]
5
+ ```
6
+
7
+ ## Options
8
+
9
+ | Option | Description | Default |
10
+ |--------|-------------|---------|
11
+ | `--to <tool>` | gemini, qwen, codex, claude, opencode | First enabled |
12
+ | `--role <role>` | analyze, explore, review, implement, plan, brainstorm, research | — |
13
+ | `--mode <mode>` | `analysis` (read-only) / `write` (modify) | `analysis` |
14
+ | `--model <model>` | Model override | Tool's `primaryModel` |
15
+ | `--cd <dir>` | Working directory | Current |
16
+ | `--rule <template>` | Protocol + prompt template | — |
17
+ | `--id <id>` | Execution ID | Auto: `{prefix}-{HHmmss}-{rand4}` |
18
+ | `--resume [id]` | Resume previous session | — |
19
+ | `--includeDirs <dirs>` | Additional directories (comma-separated) | — |
20
+
21
+ Tool resolution: `--to` > `--role` > first enabled in config.
22
+
23
+ **`--mode` is authoritative** — `MODE:` in prompt text is a hint only.
24
+
25
+ ## Prompt Template
26
+
27
+ ```
28
+ PURPOSE: [goal] + [success criteria]
29
+ TASK: [step 1] | [step 2] | [step 3]
30
+ MODE: analysis|write
31
+ CONTEXT: @[file patterns] | Memory: [prior work]
32
+ EXPECTED: [output format]
33
+ CONSTRAINTS: [scope limits]
34
+ ```
35
+
36
+ ### CONTEXT Patterns
37
+
38
+ - `@**/*` — all files (default)
39
+ - `@src/**/*.ts` — scoped
40
+ - `@../shared/**/*` — sibling dir (**requires `--includeDirs ../shared`**)
41
+
42
+ ### --rule Templates
43
+
44
+ **Universal**: `universal-rigorous-style`, `universal-creative-style`
45
+
46
+ **Analysis**: `analysis-trace-code-execution`, `analysis-diagnose-bug-root-cause`, `analysis-analyze-code-patterns`, `analysis-analyze-technical-document`, `analysis-review-architecture`, `analysis-review-code-quality`, `analysis-analyze-performance`, `analysis-assess-security-risks`
47
+
48
+ **Planning**: `planning-plan-architecture-design`, `planning-breakdown-task-steps`, `planning-design-component-spec`, `planning-plan-migration-strategy`
49
+
50
+ **Development**: `development-implement-feature`, `development-refactor-codebase`, `development-generate-tests`, `development-implement-component-ui`, `development-debug-runtime-issues`
51
+
52
+ ## Execution Rules
53
+
54
+ **ALWAYS** use `run_in_background: true`, then **stop immediately**:
55
+
56
+ ```
57
+ Bash({ command: "maestro delegate \"...\" --to gemini --mode analysis", run_in_background: true })
58
+ ```
59
+
60
+ - NEVER use foreground Bash for delegate calls
61
+ - NEVER output text or tool calls after the background Bash call
62
+ - Callback includes status + output — use it directly
63
+
64
+ ### Execution ID Prefix
65
+
66
+ gemini→`gem`, qwen→`qwn`, codex→`cdx`, claude→`cld`, opencode→`opc`
67
+
68
+ ### Resume
69
+
70
+ ```bash
71
+ maestro delegate "<PROMPT>" --to gemini --resume # last session
72
+ maestro delegate "<PROMPT>" --to gemini --resume <id> # specific
73
+ ```
74
+
75
+ ### Message Delivery
76
+
77
+ | Mode | Use For |
78
+ |------|---------|
79
+ | `inject` | Supplementary context to running worker |
80
+ | `after_complete` | Chained tasks after completion |
81
+
82
+ ```bash
83
+ maestro delegate message <exec-id> "additional context"
84
+ maestro delegate message <exec-id> "next task" --delivery after_complete
85
+ ```
86
+
87
+ ## Auto-Invoke Triggers
88
+
89
+ Proactively invoke for `analysis` mode — no user confirmation needed:
90
+
91
+ | Trigger | Suggested Rule |
92
+ |---------|---------------|
93
+ | Self-repair fails (1+ attempts) | `analysis-diagnose-bug-root-cause` |
94
+ | Ambiguous requirements | `planning-breakdown-task-steps` |
95
+ | Architecture decisions needed | `planning-plan-architecture-design` |
96
+ | Pattern uncertainty | `analysis-analyze-code-patterns` |
97
+ | Critical/security code paths | `analysis-assess-security-risks` |
98
+
99
+ **Always** `run_in_background: true`, default `--mode analysis`.
@@ -0,0 +1,121 @@
1
+ ---
2
+ name: domain-add
3
+ alias: domain-add
4
+ ---
5
+
6
+ # Workflow: domain-add
7
+
8
+ Register a domain term into `.workflow/domain/glossary.yaml`.
9
+
10
+ ## Arguments
11
+
12
+ ```
13
+ $ARGUMENTS: "<canonical> <definition>"
14
+
15
+ canonical -- kebab-case term name (e.g. "auth-token", "event-bus")
16
+ definition -- one-line definition (≤200 chars)
17
+ ```
18
+
19
+ ## Prerequisites
20
+
21
+ - `.workflow/domain/` directory must exist (run `maestro domain init` if missing)
22
+
23
+ ## Execution Steps
24
+
25
+ ### Step 1: Parse Arguments
26
+
27
+ ```
28
+ Parse $ARGUMENTS:
29
+ 1. canonical = first token (kebab-case, e.g. "auth-token")
30
+ 2. definition = remaining text
31
+ Validate:
32
+ - canonical is non-empty, kebab-case (lowercase, hyphens only)
33
+ - definition is non-empty, ≤200 chars
34
+ On failure: show usage `domain-add <canonical> "<definition>"`, exit
35
+ ```
36
+
37
+ ### Step 2: Check Glossary State
38
+
39
+ Verify `.workflow/domain/glossary.yaml` exists. If not, create via `maestro domain init`.
40
+
41
+ Read existing glossary and check for:
42
+ - **Exact duplicate**: same canonical name already registered → report existing entry, exit
43
+ - **Near match**: Levenshtein distance ≤ 2 or alias overlap → warn, ask to confirm or merge
44
+
45
+ ### Step 3: Extract Metadata
46
+
47
+ Auto-derive from the definition and codebase context:
48
+
49
+ - **aliases** (1-3): common abbreviations, Chinese translations, or alternate forms the term is known by
50
+ - **keywords** (3-5): search terms for discovery
51
+ - **tier**: `core` (fundamental project concept) | `extended` (secondary) | `peripheral` (rarely referenced)
52
+ - **relationships**: scan existing glossary for related terms (semantic overlap or dependency)
53
+
54
+ ### Step 4: Register Term
55
+
56
+ Write via `maestro domain add`:
57
+
58
+ ```bash
59
+ # MANDATORY, NOT SUBSTITUTABLE by manual Read/Grep
60
+ maestro domain add "<canonical>" "<definition>" --tier <tier>
61
+ ```
62
+
63
+ If aliases or relationships identified, update immediately:
64
+
65
+ ```bash
66
+ maestro domain update "<canonical>" --aliases "alias1,alias2" --keywords "kw1,kw2,kw3" --relationships "related-term-1,related-term-2"
67
+ ```
68
+
69
+ Records `source.kind = 'manual'`, `source.registered_at = now`.
70
+
71
+ **GATE Step 4→5**: REQUIRED term written via `maestro domain add` (exit 0); BLOCKED if write failed or term missing from glossary.
72
+
73
+ ### Step 5: Verify Injection
74
+
75
+ Confirm the term is injectable by checking:
76
+
77
+ ```bash
78
+ # MANDATORY, NOT SUBSTITUTABLE by manual Read/Grep
79
+ maestro domain show "<canonical>"
80
+ ```
81
+
82
+ Display: canonical name, definition, aliases, tier, relationships, and verify command:
83
+ ```
84
+ maestro domain list
85
+ ```
86
+
87
+ **GATE Step 5→6**: REQUIRED term verified injectable via `maestro domain show`; BLOCKED if not injectable.
88
+
89
+ ### Step 6: Report
90
+
91
+ ```
92
+ === DOMAIN TERM REGISTERED ===
93
+ Term: {canonical}
94
+ Definition: {definition}
95
+ Aliases: {alias1, alias2}
96
+ Tier: {tier}
97
+ Related: {rel1, rel2}
98
+ Injection: domain-compact (always) + domain-expanded (on keyword match)
99
+ Next: maestro domain list | maestro domain discover (find more candidates)
100
+ ```
101
+
102
+ ## Auto-Discovery Alternative
103
+
104
+ For batch registration from codebase scanning:
105
+
106
+ ```bash
107
+ maestro domain discover # scan codebase for term candidates
108
+ maestro domain import # batch import from external source
109
+ ```
110
+
111
+ ## Domain Term Lifecycle
112
+
113
+ ```
114
+ discover/manual → register → active → (optional) deprecated → removed
115
+
116
+ update aliases/keywords/relationships
117
+ ```
118
+
119
+ ## Output
120
+
121
+ One domain term entry added to `.workflow/domain/glossary.yaml`.