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,124 @@
1
+ ---
2
+ name: learn-decompose
3
+ description: "Extract design patterns from code into specs and wiki Arguments: <path|module> [--patterns <list>] [--save-spec] [--save-wiki] [-y]"
4
+ allowed-tools: Read Write Bash Glob Grep Agent AskUserQuestion
5
+ ---
6
+
7
+ <purpose>
8
+ Systematic pattern extraction: analyze module across 4 dimensions using parallel agents, catalog findings with code anchors, persist to specs/wiki. Produces reusable pattern catalog.
9
+ </purpose>
10
+
11
+ <context>
12
+ $ARGUMENTS — target path/module and optional flags.
13
+
14
+ **Target resolution**: file path → that file; directory → all source files; module name → Glob `src/**/{module}*`.
15
+
16
+ **Flags**:
17
+ - `--patterns <list>`: Comma-separated pattern names to look for (default: detect all)
18
+ - `--save-spec`: `Skill("spec-add")` for each new pattern
19
+ - `--save-wiki`: create wiki note per dimension group
20
+ - `-y`: Skip confirmation prompts for knowhow/spec writes
21
+
22
+ **Storage read**: target files + `coding-conventions.md` + `.workflow/specs/learnings.md` (dedup)
23
+ **Storage write**: `.workflow/knowhow/KNW-decompose-{slug}-{date}.md` + append `.workflow/specs/learnings.md`
24
+
25
+ **Output boundary**: ALL file writes MUST target `.workflow/knowhow/KNW-decompose-{slug}-{date}.md` and `.workflow/specs/learnings.md` only. NEVER modify source code or files outside these paths.
26
+ </context>
27
+
28
+ <invariants>
29
+ 1. **Read-only analysis** — NEVER modify source code files under analysis; all writes go to `.workflow/` only
30
+ 2. **Evidence-anchored findings** — every pattern MUST include at least one `file:line` anchor from source; unanchored patterns SHALL NOT be persisted
31
+ 3. **Dedup before persist** — MUST cross-reference against existing `learnings.md` and `coding-conventions.md` before writing; duplicate entries SHALL NOT be appended
32
+ 4. **Parallel agent isolation** — each dimension agent operates independently; NEVER share state between agents during analysis
33
+ 5. **Confirmation gate** — unless `-y` is set, MUST present all findings and target files via AskUserQuestion before any writes
34
+ 6. **Append-only learnings** — `.workflow/specs/learnings.md` MUST be appended, NEVER overwritten or truncated
35
+ </invariants>
36
+
37
+ <state_machine>
38
+
39
+ <states>
40
+ S_RESOLVE — 解析 target 为具体文件列表 PERSIST: —
41
+ S_DEDUP — 加载已有 patterns 用于去重 PERSIST: —
42
+ S_ANALYZE — 4 维度并行 Agent 分析 PERSIST: —
43
+ S_CROSSREF — 交叉引用、去重、标记状态 PERSIST: —
44
+ S_CATALOG — 生成 pattern catalog 报告 PERSIST: outputs
45
+ S_PERSIST — 写文件 + 可选 spec-add/wiki create PERSIST: knowhow files
46
+ </states>
47
+
48
+ <transitions>
49
+
50
+ S_RESOLVE:
51
+ → S_DEDUP WHEN: file list resolved
52
+ → S_RESOLVE WHEN: unresolvable DO: AskUserQuestion
53
+
54
+ S_DEDUP:
55
+ → S_ANALYZE DO: read coding-conventions.md + .workflow/specs/learnings.md → build known pattern set
56
+
57
+ S_ANALYZE:
58
+ → S_CROSSREF DO: A_PARALLEL_DIMENSION_ANALYSIS
59
+
60
+ S_CROSSREF:
61
+ → S_CATALOG DO: A_CROSSREF_DEDUP
62
+
63
+ S_CATALOG:
64
+ → S_PERSIST DO: write KNW-decompose report (grouped by dimension: pattern table + details)
65
+
66
+ S_PERSIST:
67
+ → END GATE: unless -y, AskUserQuestion showing files to write and patterns to persist — proceed only on confirm
68
+ DO: append .workflow/specs/learnings.md [+ spec-add if --save-spec] [+ wiki note if --save-wiki]
69
+
70
+ </transitions>
71
+
72
+ <actions>
73
+
74
+ ### A_PARALLEL_DIMENSION_ANALYSIS
75
+
76
+ Spawn 4 Agents in single message:
77
+
78
+ | Agent | Dimension | Looks for |
79
+ |-------|-----------|-----------|
80
+ | 1 | Structural | Class hierarchy, composition, DI/IoC, Factory/Builder/Singleton, barrel exports |
81
+ | 2 | Behavioral | Event flow, middleware chains, observer/pub-sub, command/strategy, state machines |
82
+ | 3 | Data | Repository/DAO, DTO pipelines, caching (memo/LRU/TTL), serialization, schema validation |
83
+ | 4 | Error | Error boundaries, retry/backoff/circuit-breaker, fallback chains, guard clauses, logging |
84
+
85
+ If `--patterns` specified: agents focus only on named patterns.
86
+
87
+ Each agent returns: `[{ name, dimension, confidence (high/medium/low), anchors [file:line], description, rationale, tradeoffs }]`
88
+
89
+ ### A_CROSSREF_DEDUP
90
+
91
+ For each finding, match against known pattern set:
92
+ | Status | Condition |
93
+ |--------|-----------|
94
+ | documented | Already in coding-conventions.md |
95
+ | known | In .workflow/specs/learnings.md (if file exists) |
96
+ | new | Not seen before (or learnings.md absent — treat all as new) |
97
+
98
+ Flag contradictions (finding conflicts with documented convention). Merge duplicates across agents (same pattern found by multiple dimensions).
99
+
100
+ </actions>
101
+
102
+ </state_machine>
103
+
104
+ <error_codes>
105
+ | Code | Condition | Recovery |
106
+ |------|-----------|----------|
107
+ | E001 | No target path/module provided | Prompt user for target |
108
+ | E002 | No source files in target | Check target has .ts/.js files |
109
+ | W001 | One+ dimension agent failed | Proceed with available dimensions |
110
+ | W002 | .workflow/specs/learnings.md missing or malformed | Treat all patterns as new; create file on persist |
111
+ | W003 | Large target (>50 files) | Consider --patterns filter |
112
+ </error_codes>
113
+
114
+ <success_criteria>
115
+ - [ ] 4 dimension agents spawned in parallel, findings with anchors
116
+ - [ ] Cross-reference: documented/known/new status assigned
117
+ - [ ] Pattern catalog written + .workflow/specs/learnings.md appended
118
+ </success_criteria>
119
+
120
+ <next_step_routing>
121
+ - Follow-along → `/learn-follow <anchor-file>`
122
+ - Second opinion → `/learn-second-opinion <target>`
123
+ - Add to specs → `/spec-add coding ...`
124
+ </next_step_routing>
@@ -0,0 +1,163 @@
1
+ ---
2
+ name: learn-follow
3
+ description: "Guided reading of code or wiki to extract patterns Arguments: <path|wiki-id|topic> [--depth shallow|deep] [--save-wiki] [-y]"
4
+ allowed-tools: Read Write Bash Glob Grep Agent AskUserQuestion
5
+ ---
6
+
7
+ <purpose>
8
+ Guided reading: walk through content section-by-section using forcing questions to extract patterns, identify assumptions, and build an understanding map. Findings persist to `.workflow/specs/learnings.md` as `<spec-entry>` blocks.
9
+ </purpose>
10
+
11
+ <context>
12
+ $ARGUMENTS — target and optional flags.
13
+
14
+ **Target resolution** (auto-detected):
15
+ | Input | Resolution |
16
+ |-------|-----------|
17
+ | File path (contains `/` or `\`) | Read source file |
18
+ | Wiki ID (`<type>-<slug>`) | `maestro wiki get <id>` |
19
+ | Topic string | `maestro search "<topic>"` → top result; fallback: Grep src/ |
20
+
21
+ **Flags**:
22
+ - `--depth shallow` (default): key patterns and structure only
23
+ - `--depth deep`: every function, every branch, every assumption
24
+ - `--save-wiki`: create wiki note entry with reading notes
25
+ - `-y`: Skip confirmation prompts for knowhow/spec writes
26
+
27
+ **Storage read**: target file + wiki forward/backlinks + `coding-conventions.md` + `.workflow/specs/learnings.md` (dedup)
28
+ **Storage write**: `.workflow/knowhow/KNW-follow-{slug}-{date}.md` + append `.workflow/specs/learnings.md`
29
+
30
+ **Output boundary**: ALL file writes MUST target `.workflow/knowhow/KNW-follow-{slug}-{date}.md` and `.workflow/specs/learnings.md` only. NEVER modify source code or files outside these paths.
31
+ </context>
32
+
33
+ <invariants>
34
+ 1. **Read-only traversal** — NEVER modify source code or wiki entries under analysis; all writes go to `.workflow/` only
35
+ 2. **Forcing questions mandatory** — each section MUST have all 4 forcing questions applied; NEVER skip questions even for trivial sections
36
+ 3. **Anchor requirement** — every extracted pattern MUST include a `file:line` anchor; unanchored patterns SHALL NOT be persisted to learnings.md
37
+ 4. **Convention cross-ref** — MUST check every finding against `coding-conventions.md` and mark status (documented/candidate); NEVER persist without status tag
38
+ 5. **Append-only learnings** — `.workflow/specs/learnings.md` MUST be appended, NEVER overwritten or truncated
39
+ 6. **Confirmation gate** — unless `-y` is set, MUST present findings and target files via AskUserQuestion before any writes
40
+ 7. **Depth contract** — `--depth shallow` MUST NOT descend into function bodies; `--depth deep` MUST cover every branch and sub-expression
41
+ </invariants>
42
+
43
+ <execution>
44
+
45
+ ### Phase Gates (MANDATORY, BLOCKING)
46
+
47
+ **GATE 1: Resolve → Context Building** (S_RESOLVE → S_CONTEXT)
48
+ - REQUIRED: Target resolved to a readable source (file path, wiki entry, or search result).
49
+ - BLOCKED if: target unresolvable after user prompt (E001/E002).
50
+
51
+ **GATE 2: Reading → Extraction** (S_READ → S_EXTRACT)
52
+ - REQUIRED: All sections traversed with 4 forcing questions applied per section.
53
+ - REQUIRED: Depth contract honored — shallow stays at top-level, deep covers every branch.
54
+ - BLOCKED if: any section skipped without forcing questions.
55
+
56
+ **GATE 3: Extraction → Persistence** (S_EXTRACT → S_PERSIST)
57
+ - REQUIRED: All extracted patterns have file:line anchors.
58
+ - REQUIRED: Convention cross-ref completed against coding-conventions.md (or marked "unknown status" if W002).
59
+ - BLOCKED if: unanchored patterns remain in extraction results.
60
+
61
+ **GATE 4: Persistence → Completion** (S_PERSIST → END)
62
+ - REQUIRED: Unless `-y`, AskUserQuestion showing files to write and spec-entries to append — user must confirm.
63
+ - REQUIRED: KNW-follow-{slug}-{date}.md written with understanding map.
64
+ - REQUIRED: learnings.md appended (not overwritten) with new spec-entry blocks.
65
+ - BLOCKED if: user declines confirmation — offer to adjust findings before retry.
66
+
67
+ </execution>
68
+
69
+ <state_machine>
70
+
71
+ <states>
72
+ S_RESOLVE — 解析 target (file/wiki/topic) PERSIST: —
73
+ S_CONTEXT — 构建 1-hop 上下文邻域 PERSIST: —
74
+ S_ORDER — 确定阅读顺序 PERSIST: —
75
+ S_READ — 逐节应用 forcing questions PERSIST: —
76
+ S_EXTRACT — 提取 patterns、cross-ref conventions PERSIST: —
77
+ S_PERSIST — 写 understanding map + spec-entry 块 PERSIST: knowhow files
78
+ </states>
79
+
80
+ <transitions>
81
+
82
+ S_RESOLVE:
83
+ → S_CONTEXT WHEN: target resolved
84
+ → S_RESOLVE WHEN: unresolvable DO: AskUserQuestion with suggestions
85
+
86
+ S_CONTEXT:
87
+ → S_ORDER DO: A_BUILD_CONTEXT_WEB
88
+
89
+ S_ORDER:
90
+ → S_READ DO: A_BUILD_READING_ORDER
91
+
92
+ S_READ:
93
+ → S_EXTRACT DO: A_GUIDED_READ (apply 4 forcing questions per section)
94
+
95
+ S_EXTRACT:
96
+ → S_PERSIST DO: A_EXTRACT_PATTERNS
97
+
98
+ S_PERSIST:
99
+ → END GATE: unless -y, AskUserQuestion showing files to write and spec-entries to append — proceed only on confirm
100
+ DO: write KNW-follow + append .workflow/specs/learnings.md [+ wiki note if --save-wiki]
101
+
102
+ </transitions>
103
+
104
+ <actions>
105
+
106
+ ### A_BUILD_CONTEXT_WEB
107
+
108
+ | Target type | Context |
109
+ |-------------|---------|
110
+ | Wiki entry | `maestro wiki forward <id>` + `maestro wiki backlinks <id>` → read top 3 related |
111
+ | Code file | Parse imports → dependency files; grep exports → reverse deps; read top 3 dependents (50 lines) |
112
+ | Directory | List files, identify entry points → build reading order: entry → core → utils → tests |
113
+
114
+ ### A_BUILD_READING_ORDER
115
+
116
+ - Single file: split by function/class/export boundaries
117
+ - Wiki entry: split by markdown headings
118
+ - Directory: order by dependency (entry points first, leaf last)
119
+ - `--depth shallow`: top-level structure only; `--depth deep`: every body and branch
120
+
121
+ ### A_GUIDED_READ
122
+
123
+ For each section, apply 4 forcing questions:
124
+
125
+ | # | Question | Extracts |
126
+ |---|----------|----------|
127
+ | 1 | "What pattern is being used here?" | Design patterns, idioms, conventions |
128
+ | 2 | "Why this approach instead of alternatives?" | Trade-offs, rejected options |
129
+ | 3 | "What assumption does this depend on?" | Implicit contracts, input shape, ordering |
130
+ | 4 | "What would break if this changed?" | Fragility, downstream effects |
131
+
132
+ ### A_EXTRACT_PATTERNS
133
+
134
+ Extract: design patterns (with file:line anchors), naming conventions, error handling approach, data flow, assumptions.
135
+ Cross-ref against `coding-conventions.md`: documented → "confirmed convention", undocumented → "candidate for spec-add".
136
+
137
+ Write understanding map: Key Concepts, Patterns (table: name/location/convention status), Assumptions, Open Questions, Connections.
138
+
139
+ </actions>
140
+
141
+ </state_machine>
142
+
143
+ <error_codes>
144
+ | Code | Condition | Recovery |
145
+ |------|-----------|----------|
146
+ | E001 | No target path/wiki-id/topic provided | Prompt user for target |
147
+ | E002 | Target path not found and wiki/grep search returned no results | Check path or broaden search terms |
148
+ | W001 | Wiki forward/backlinks unavailable | Proceed without context web; note reduced coverage |
149
+ | W002 | coding-conventions.md not found | All patterns marked "unknown status" |
150
+ | W003 | Target > 1000 lines | Auto-switch to shallow; use --depth deep to override |
151
+ </error_codes>
152
+
153
+ <success_criteria>
154
+ - [ ] 4 forcing questions applied per section
155
+ - [ ] Patterns extracted with file:line anchors and convention cross-ref
156
+ - [ ] Understanding map + spec-entry blocks written
157
+ </success_criteria>
158
+
159
+ <next_step_routing>
160
+ - Deep pattern dive → `/learn-decompose <path>`
161
+ - Add to specs → `/spec-add coding <description>`
162
+ - Second opinion → `/learn-second-opinion <file>`
163
+ </next_step_routing>
@@ -0,0 +1,160 @@
1
+ ---
2
+ name: learn-investigate
3
+ description: "Investigate questions with hypothesis testing and evidence logging Arguments: <question> [--scope <path>] [--max-hypotheses N] [-y]"
4
+ allowed-tools: Read Write Bash Glob Grep Agent AskUserQuestion
5
+ ---
6
+
7
+ <purpose>
8
+ Systematic investigation for understanding questions (not bug-fixing).
9
+ 4-phase scientific method with scope lock, 3-strike escalation, and evidence persistence.
10
+ </purpose>
11
+
12
+ <context>
13
+ $ARGUMENTS — question text and optional flags.
14
+
15
+ **Flags**:
16
+ - `--scope <path>`: Restrict to files under this dir (default: entire project)
17
+ - `--max-hypotheses N`: Max hypotheses before escalation (default: 3)
18
+ - `-y`: Skip confirmation prompts for report/spec writes
19
+
20
+ **Storage write**:
21
+ - `.workflow/knowhow/KNW-investigate-{slug}/evidence.ndjson` — structured evidence (one JSON line per item)
22
+ - `.workflow/knowhow/KNW-investigate-{slug}/understanding.md` — evolving understanding
23
+ - `.workflow/knowhow/KNW-investigate-{slug}/report.md` — final report
24
+ - `.workflow/specs/learnings.md` — appended `<spec-entry>` blocks
25
+
26
+ **Storage read**: source files in scope + `maestro search` + `.workflow/specs/learnings.md` + `debug-notes.md` + `codebase/architecture.md`
27
+
28
+ **Output boundary**: ALL file writes MUST target `.workflow/knowhow/KNW-investigate-{slug}/` and `.workflow/specs/learnings.md` only. NEVER modify source code or files outside these paths.
29
+ </context>
30
+
31
+ <invariants>
32
+ 1. **Read-only investigation** — NEVER modify source code files; all writes go to `.workflow/` only
33
+ 2. **Evidence append-only** — `evidence.ndjson` MUST be appended line-by-line; NEVER overwrite or truncate existing evidence entries
34
+ 3. **Scope lock** — once `--scope` is resolved in S_FRAME, NEVER expand search scope without explicit user confirmation via S_ESCALATE
35
+ 4. **Hypothesis cap** — MUST NOT generate more than `--max-hypotheses` (default 3) before triggering escalation; NEVER silently exceed the cap
36
+ 5. **Structured evidence format** — every evidence entry MUST include `{ts, type, source, relevance, content, note}`; incomplete entries SHALL NOT be appended
37
+ 6. **3-strike escalation** — after all hypotheses fail, MUST escalate to user via AskUserQuestion; NEVER silently conclude as INCONCLUSIVE without user interaction
38
+ 7. **Confirmation gate** — unless `-y` is set, MUST present report.md path and spec-entries via AskUserQuestion before final writes
39
+ </invariants>
40
+
41
+ <state_machine>
42
+
43
+ <states>
44
+ S_FRAME — 解析问题、确定 scope、搜索先验知识 PERSIST: understanding.md (initial)
45
+ S_EVIDENCE — 系统收集证据 PERSIST: evidence.ndjson
46
+ S_PATTERN — 比对已知模式 PERSIST: understanding.md (patterns)
47
+ S_HYPOTHESIZE — 生成假设列表 PERSIST: understanding.md (hypotheses)
48
+ S_CLI_EXPLORE — CLI 辅助探索(可选) PERSIST: evidence.ndjson (append)
49
+ S_TEST — 逐假设测试 PERSIST: evidence.ndjson + understanding.md
50
+ S_ESCALATE — 3-strike 升级 PERSIST: —
51
+ S_REPORT — 综合报告 + persist PERSIST: report.md + .workflow/specs/learnings.md
52
+ </states>
53
+
54
+ <transitions>
55
+
56
+ S_FRAME:
57
+ → S_EVIDENCE DO: A_FRAME_QUESTION
58
+
59
+ S_EVIDENCE:
60
+ → S_PATTERN DO: A_COLLECT_EVIDENCE
61
+
62
+ S_PATTERN:
63
+ → S_HYPOTHESIZE DO: match evidence against debug-notes.md + .workflow/specs/learnings.md patterns
64
+
65
+ S_HYPOTHESIZE:
66
+ → S_CLI_EXPLORE WHEN: CLI tools enabled (at least one tool in cli-tools.json enabled) AND hypotheses non-trivial (require cross-file tracing or data-flow analysis) DO: A_FORM_HYPOTHESES
67
+ → S_TEST WHEN: no CLI tools OR trivial hypotheses (answerable by local Grep/Read) DO: A_FORM_HYPOTHESES
68
+
69
+ S_CLI_EXPLORE:
70
+ → S_TEST DO: A_CLI_SUPPLEMENT (maestro delegate --to <first-enabled-tool> --mode analysis, run_in_background, STOP)
71
+
72
+ S_TEST:
73
+ → S_REPORT WHEN: hypothesis confirmed DO: A_TEST_HYPOTHESIS
74
+ → S_REPORT WHEN: all hypotheses tested (some confirmed) DO: A_TEST_HYPOTHESIS
75
+ → S_ESCALATE WHEN: max_hypotheses all failed DO: A_TEST_HYPOTHESIS
76
+
77
+ S_ESCALATE:
78
+ → S_HYPOTHESIZE WHEN: user broadens scope or provides new hypothesis DO: AskUserQuestion
79
+ → S_REPORT WHEN: user selects "Escalate" or still stuck DO: mark INCONCLUSIVE
80
+
81
+ S_REPORT:
82
+ → END GATE: unless -y, AskUserQuestion showing report.md path and spec-entries to append — proceed only on confirm
83
+ DO: A_SYNTHESIZE_REPORT
84
+
85
+ </transitions>
86
+
87
+ <actions>
88
+
89
+ ### A_FRAME_QUESTION
90
+
91
+ 1. Parse question, generate slug, create KNW-investigate-{slug}/
92
+ 2. Search prior knowledge: `maestro search "<question>"` + search .workflow/specs/learnings.md + read debug-notes.md
93
+ 3. Write initial understanding.md (question, prior knowledge summary, scope, timestamp)
94
+
95
+ ### A_COLLECT_EVIDENCE
96
+
97
+ Parallel evidence gathering:
98
+ 1. Code search: Grep keywords from question
99
+ 2. File inspection: Read most relevant files
100
+ 3. Import tracing: follow dependency chain
101
+ 4. Git history: `git log --oneline -10 -- <relevant-files>`
102
+
103
+ Each item → append evidence.ndjson: `{ts, type (code|git|search|doc), source (file:line), relevance (high|medium|low), content, note}`
104
+
105
+ ### A_FORM_HYPOTHESES
106
+
107
+ Generate ranked hypotheses: each is specific, testable claim about "how/why".
108
+ Rank by plausibility (evidence strength). Write to understanding.md:
109
+ - `[HIGH]` hypothesis — Evidence: {refs}
110
+ - `[MEDIUM]` hypothesis — Evidence: {refs}
111
+
112
+ ### A_CLI_SUPPLEMENT
113
+
114
+ ```
115
+ maestro delegate "PURPOSE: Gather evidence for hypotheses
116
+ TASK: Trace call chains and data flows per hypothesis | Find corroborating/contradicting patterns
117
+ EXPECTED: JSON [{hypothesis_rank, evidence: [{file, line, supports: bool, explanation}]}]
118
+ " --to <first-enabled-tool> --mode analysis
119
+ ```
120
+ Run_in_background, STOP, wait. On callback: append to evidence.ndjson.
121
+
122
+ ### A_TEST_HYPOTHESIS
123
+
124
+ For each hypothesis (rank order):
125
+ 1. Design test: what evidence would confirm/disprove?
126
+ 2. Execute: code trace, targeted search, data inspection
127
+ 3. Record: append evidence.ndjson with type: "test"
128
+ 4. Update: mark hypothesis confirmed / disproved / inconclusive
129
+
130
+ ### A_SYNTHESIZE_REPORT
131
+
132
+ Write report.md: Answer (or INCONCLUSIVE), Evidence Trail table, Hypotheses Tested table, Key Learnings, Open Questions.
133
+ Append to .workflow/specs/learnings.md: confirmed → roles="implement", disproved → roles="analyze" (gotcha).
134
+
135
+ </actions>
136
+
137
+ </state_machine>
138
+
139
+ <error_codes>
140
+ | Code | Condition | Recovery |
141
+ |------|-----------|----------|
142
+ | E001 | No question text provided | Prompt user for investigation question |
143
+ | E002 | --scope path not found | Check path |
144
+ | W001 | Prior knowledge search returned no results | Proceed without prior context; note cold-start |
145
+ | W002 | Very few evidence matches (<3) | Broaden search terms or expand scope |
146
+ | W003 | All hypotheses inconclusive | Investigation marked INCONCLUSIVE |
147
+ </error_codes>
148
+
149
+ <success_criteria>
150
+ - [ ] Evidence collected and logged to evidence.ndjson (structured NDJSON)
151
+ - [ ] At least 1 hypothesis formed and tested
152
+ - [ ] 3-strike escalation triggered if all fail
153
+ - [ ] Report + spec-entry blocks written
154
+ </success_criteria>
155
+
156
+ <next_step_routing>
157
+ - Save to specs → `/spec-add debug <finding>`
158
+ - Follow code → `/learn-follow <path>`
159
+ - Decompose patterns → `/learn-decompose <module>`
160
+ </next_step_routing>
@@ -0,0 +1,128 @@
1
+ ---
2
+ name: learn-second-opinion
3
+ description: "Get alternative perspectives — review, challenge, or consult Arguments: <target> [--mode review|challenge|consult] [-y]"
4
+ allowed-tools: Read Write Bash Glob Grep Agent AskUserQuestion
5
+ ---
6
+
7
+ <purpose>
8
+ Structured second-opinion on code, decisions, or plans via three modes: review (3 parallel agents),
9
+ challenge (adversarial), or consult (interactive Q&A). Findings persist to learnings.md.
10
+ </purpose>
11
+
12
+ <context>
13
+ $ARGUMENTS — target and optional mode flag.
14
+
15
+ **Target resolution** (auto-detected):
16
+ | Input | Resolution |
17
+ |-------|-----------|
18
+ | File path | Read file content |
19
+ | Wiki ID (`<type>-<slug>`) | `maestro wiki get <id>` |
20
+ | `HEAD` / `staged` | `git diff HEAD` / `git diff --staged` |
21
+ | Phase number | Resolve via state.json.artifacts[] → plan.json |
22
+
23
+ **Flags**:
24
+ - `--mode review|challenge|consult` (default: review)
25
+ - `-y`: Skip confirmation prompts for knowhow/spec writes
26
+
27
+ **Pre-load** (optional): `Skill("spec-load")` for conventions + `maestro search "<target topic>"` for related entries.
28
+
29
+ **Output**: `.workflow/knowhow/KNW-opinion-{slug}-{YYYY-MM-DD}.md`
30
+
31
+ **Output boundary**: ALL file writes MUST target `.workflow/knowhow/KNW-opinion-{slug}-{YYYY-MM-DD}.md` and `.workflow/specs/learnings.md` only. NEVER modify source code or files outside these paths.
32
+ </context>
33
+
34
+ <invariants>
35
+ 1. **Read-only analysis** — NEVER modify source code, wiki entries, or plan files under review; all writes go to `.workflow/` only
36
+ 2. **Agent independence** — in review mode, each of the 3 agents (Pragmatist/Purist/Strategist) MUST operate independently without shared state; NEVER pass one agent's findings to another
37
+ 3. **Evidence-backed verdicts** — every finding MUST include a `location` reference (file:line or section); ungrounded opinions SHALL NOT appear in the report
38
+ 4. **Mode contract** — MUST execute exactly the mode specified (review/challenge/consult); NEVER mix mode behaviors within a single execution
39
+ 5. **Append-only learnings** — `.workflow/specs/learnings.md` MUST be appended, NEVER overwritten or truncated
40
+ 6. **Confirmation gate** — unless `-y` is set, MUST present findings and target files via AskUserQuestion before any writes
41
+ </invariants>
42
+
43
+ <state_machine>
44
+
45
+ <states>
46
+ S_RESOLVE — 解析 target PERSIST: —
47
+ S_CONTEXT — 加载 specs/wiki 上下文 PERSIST: —
48
+ S_EXECUTE — 按 mode 执行分析 PERSIST: —
49
+ S_SYNTHESIZE — 综合观点、生成报告 PERSIST: outputs
50
+ S_PERSIST — 写文件、append .workflow/specs/learnings.md PERSIST: knowhow files
51
+ </states>
52
+
53
+ <transitions>
54
+
55
+ S_RESOLVE:
56
+ → S_CONTEXT WHEN: target resolved DO: read target content
57
+ → S_RESOLVE WHEN: unresolvable DO: AskUserQuestion for clarification
58
+
59
+ S_CONTEXT:
60
+ → S_EXECUTE DO: load specs + wiki search (optional, proceed without)
61
+
62
+ S_EXECUTE:
63
+ → S_SYNTHESIZE WHEN: mode == review DO: A_REVIEW
64
+ → S_SYNTHESIZE WHEN: mode == challenge DO: A_CHALLENGE
65
+ → S_SYNTHESIZE WHEN: mode == consult DO: A_CONSULT
66
+
67
+ S_SYNTHESIZE:
68
+ → S_PERSIST DO: merge perspectives → agreements, disagreements, verdict, top 3 recommendations
69
+
70
+ S_PERSIST:
71
+ → END GATE: unless -y, AskUserQuestion showing files to write and spec-entries to append — proceed only on confirm
72
+ DO: write KNW-opinion + append <spec-entry> blocks to .workflow/specs/learnings.md
73
+
74
+ </transitions>
75
+
76
+ <actions>
77
+
78
+ ### A_REVIEW
79
+ Spawn 3 Agents in single message:
80
+
81
+ | Agent | Focus | Question |
82
+ |-------|-------|----------|
83
+ | Pragmatist | simplicity, YAGNI, maintenance | "Simplest thing that works? Maintenance burden?" |
84
+ | Purist | correctness, edge cases, type safety | "What assumptions can be violated?" |
85
+ | Strategist | scalability, architecture alignment | "Supports future growth? Fits architecture?" |
86
+
87
+ Each returns: persona, verdict (approve/concern/reject), confidence, findings[{severity, description, location, suggestion}], summary.
88
+
89
+ ### A_CHALLENGE
90
+ Spawn 1 adversarial Agent:
91
+ - Find weakest assumption
92
+ - Propose concrete breaking scenario
93
+ - Identify single biggest risk
94
+ - Suggest alternative approach
95
+ - Apply forcing questions: "What invalidates this?", "Simplest thing that breaks this?", "What would you regret in 6 months?", "What implicit contract isn't enforced?"
96
+
97
+ ### A_CONSULT
98
+ Interactive loop:
99
+ 1. Agent studies target
100
+ 2. Display "Target loaded. What would you like to know?"
101
+ 3. AskUserQuestion → Agent answers with code refs → repeat until "done"
102
+ 4. Compile Q&A into report
103
+
104
+ </actions>
105
+
106
+ </state_machine>
107
+
108
+ <error_codes>
109
+ | Code | Condition | Recovery |
110
+ |------|-----------|----------|
111
+ | E001 | No target provided | Prompt user for target (path, wiki ID, HEAD, staged, or phase) |
112
+ | E002 | Unknown --mode value | Use: review, challenge, or consult |
113
+ | E003 | Target resolution failed — path not found, wiki ID invalid, or no staged changes | Check target exists |
114
+ | W001 | One review agent failed | Proceed with available perspectives |
115
+ | W002 | Specs/wiki pre-load unavailable | Proceed without convention context; note reduced coverage |
116
+ </error_codes>
117
+
118
+ <success_criteria>
119
+ - [ ] Mode executed: review (3 parallel agents) / challenge (adversarial) / consult (interactive Q&A)
120
+ - [ ] Synthesis with agreements, disagreements, verdict
121
+ - [ ] Report written + findings appended to .workflow/specs/learnings.md
122
+ </success_criteria>
123
+
124
+ <next_step_routing>
125
+ - Create issue → `/manage-issue create <description>`
126
+ - Decompose patterns → `/learn-decompose <path>`
127
+ - Follow code → `/learn-follow <path>`
128
+ </next_step_routing>