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,478 @@
1
+ # Harvest Workflow
2
+
3
+
4
+ ---
5
+
6
+ ## Argument Shape
7
+
8
+ ```
9
+ /manage-harvest → scan all sources, interactive selection
10
+ /manage-harvest <session-id> → harvest specific session (ANL-*, WFS-*, etc.)
11
+ /manage-harvest <path> → harvest from explicit directory or file
12
+ /manage-harvest --recent 7 → harvest from artifacts updated in last 7 days
13
+ /manage-harvest --source analysis → harvest only from analysis sessions
14
+ /manage-harvest <target> --to wiki → force all findings to wiki
15
+ /manage-harvest <target> --to spec → force all findings to spec
16
+ /manage-harvest <target> --to issue → force all findings to issue
17
+ /manage-harvest <target> --to auto → auto-classify routing (default)
18
+ /manage-harvest <target> --dry-run → preview without writing
19
+ /manage-harvest --prune → classify artifacts, graduate to knowhow, archive from state.json
20
+ /manage-harvest --prune --age 14 → only graduate artifacts older than 14 days
21
+ /manage-harvest --prune --dry-run → preview prune plan without modifying state.json
22
+ ```
23
+
24
+ | Flag | Effect |
25
+ |------|--------|
26
+ | `--to <target>` | Force routing target: `wiki`, `spec`, `issue`, `auto` (default: auto) |
27
+ | `--source <type>` | Filter by source type: `analysis`, `brainstorm`, `import`, `debug`, `lite-plan`, `lite-fix`, `scratchpad`, `session`, `all` |
28
+ | `--recent N` | Only scan artifacts updated within last N days (default: 30) |
29
+ | `--dry-run` | Preview extracted items without writing to any store |
30
+ | `-y` / `--yes` | Skip confirmation prompts, accept all routing |
31
+ | `--min-confidence N` | Minimum extraction confidence 0.0-1.0 (default: 0.5) |
32
+ | `--prune` | State hygiene: graduate harvested artifacts to knowhow, archive from state.json, prune accumulated_context |
33
+ | `--age N` | Graduation age threshold in days (default: 14). Used with `--prune` |
34
+
35
+ ---
36
+
37
+ ## Stage 1: parse_input
38
+
39
+ ```
40
+ Verify .workflow/ exists (else E001). Parse flags and first non-flag token:
41
+ mode: "scan" (no target) | "session" (ID match) | "path" (explicit path) | "prune" (--prune flag)
42
+ Defaults: target_filter=auto, source_filter=all, recent_days=30,
43
+ dry_run=false, auto_yes=false, min_confidence=0.5, age_threshold=14
44
+ Invalid --to → E002. Invalid --source → E003.
45
+ If --prune: mode = "prune", jump to Stage 9 (skip Stages 2-8).
46
+ ```
47
+
48
+ ---
49
+
50
+ ## Stage 2: discover_artifacts
51
+
52
+ ### Source Registry
53
+
54
+ | Source Type | Scan Path | Key Files | ID Pattern |
55
+ |-------------|-----------|-----------|------------|
56
+ | `analysis` | `.workflow/.analysis/ANL-*/` | `conclusions.json`, `*.md` | `ANL-*` |
57
+ | `brainstorm` | `.workflow/scratch/*-brainstorm-*/` | `guidance-specification.md`, `*/analysis.md`, `design-research.md` | directory name |
58
+ | `lite-plan` | `.workflow/.lite-plan/*/` | `plan.json`, `plan-overview.md` | directory name |
59
+ | `lite-fix` | `.workflow/.lite-fix/*/` | `fix-plan.json` | directory name |
60
+ | `debug` | `.workflow/.debug/*/` | `debug-log.md`, `hypothesis-*.md` | directory name |
61
+ | `scratchpad` | `.workflow/.scratchpad/` | `*.md`, `*.json` | filename |
62
+ | `session` | `.workflow/active/WFS-*/` | `workflow-session.json` | `WFS-*` |
63
+ | `import` | `.workflow/scratch/*-import-*/` | `context-package.json`, `source.*` | directory name |
64
+ | `knowhow` | `.workflow/knowhow/` | `*.md`, `digest-*.md` | filename |
65
+
66
+ For each matching directory/file within `--recent` window, extract: `source_type`, `id`, `path`, `title`, `updated_at`, `summary`, `file_count`.
67
+
68
+ ### Display candidates
69
+
70
+ ```
71
+ === HARVESTABLE ARTIFACTS ===
72
+
73
+ # Source ID Title Updated Files
74
+ ─ ────────── ──────────────────── ─────────────────────── ──────────── ─────
75
+ 1 analysis ANL-auth-20260410 Auth vulnerability scan 2026-04-10 4
76
+ 2 brainstorm brainstorm-cache Cache strategy options 2026-04-08 3
77
+ 3 lite-fix rate-limit-20260405 Rate limiter edge case 2026-04-05 2
78
+ 4 debug debug-memory-leak Memory leak in worker 2026-04-03 5
79
+
80
+ Found: 4 artifacts (filtered by: last 30 days)
81
+ ```
82
+
83
+ ### Selection logic
84
+
85
+ | Mode | Action |
86
+ |------|--------|
87
+ | `scan`, 0 candidates | Print "No harvestable artifacts found", exit 0 |
88
+ | `scan`, ≥1 candidates | AskUserQuestion: select one, multiple (comma-separated), or "all" |
89
+ | `session` | Find matching session ID in candidates; error E004 if not found |
90
+ | `path` | Validate path exists; auto-detect source type from structure |
91
+
92
+ ---
93
+
94
+ ## Stage 3: load_and_extract (per selected artifact)
95
+
96
+ ### 3a. Load artifact content
97
+
98
+ Build content bundle: `{ source_type, id, path, files[], metadata }`.
99
+
100
+ ### 3b. Extract knowledge fragments
101
+
102
+ Per source type:
103
+
104
+ **Analysis (`conclusions.json` + markdown):**
105
+ - `findings[]` → each finding is a fragment
106
+ - `recommendations[]` → each recommendation is a fragment
107
+ - `risks[]` → each risk is a fragment
108
+ - Markdown sections with `## ` headings → section-level fragments
109
+
110
+ **Brainstorm (`guidance-specification.md` + `{role}/analysis.md` + `design-research.md`):**
111
+ - guidance §4-§N Role Decisions tables → each row is a decision fragment
112
+ - guidance §10 Feature Decomposition rows → each feature is a fragment
113
+ - guidance §12 Cross-Role Resolutions table → each resolution is a decision fragment
114
+ - `{role}/analysis.md` §2 Decision Digest tables → decision / interface / position fragments by role
115
+ - `{role}/analysis.md` §3 Cross-Cutting Foundations subsections → architectural / data-model / pitfall fragments by role
116
+ - `{role}/analysis.md` §4 File Index → navigate to sub-files:
117
+ - `{role}/analysis-F-{id}-{slug}.md` → per-feature decision fragments (one file = one fragment)
118
+ - `{role}/findings-{slug}.md` → finding / discovery fragments
119
+ - `{role}/analysis.md` §5 Outstanding TODOs → task fragments
120
+ - `design-research.md` "Extractable Patterns" sections → pattern reference fragments
121
+
122
+ **Lite-plan (`plan.json`):**
123
+ - `tasks[]` → each with rationale → decision fragments
124
+ - `dependencies[]` → architectural constraint fragments
125
+ - `risks[]` → risk fragments
126
+
127
+ **Lite-fix (`fix-plan.json`):**
128
+ - `root_cause` → bug fragment
129
+ - `fix_strategy` → pattern fragment
130
+ - `verification` → test/validation fragment
131
+
132
+ **Import (`context-package.json` + `source.*`):**
133
+ - `requirements[]` → each requirement is a feature fragment
134
+ - `constraints[]` → each constraint is a decision fragment
135
+ - `non_goals[]` → each non-goal is a scope fragment
136
+ - `insights[]` → each insight is a knowledge fragment
137
+ - `domain.terminology[]` → each term is a terminology fragment
138
+ - `open_questions[]` → each question is a task/investigation fragment
139
+
140
+ **Debug (`debug-log.md`, `hypothesis-*.md`):**
141
+ - Final diagnosis → bug fragment
142
+ - Verified hypothesis → pattern/knowhow fragment
143
+ - Rejected hypotheses with reasoning → knowhow fragment
144
+
145
+ **Scratchpad (*.md):**
146
+ - Markdown sections → generic fragments
147
+ - Code blocks with explanations → pattern fragments
148
+
149
+ **Session (`workflow-session.json`):**
150
+ - `completed_tasks[].summary` → pattern/decision fragments
151
+ - `key_decisions[]` → decision fragments
152
+ - `deferred_items[]` → issue fragments
153
+
154
+ **Learning Insights (`specs/learnings.md`):**
155
+ - Each `<spec-entry>` → learning fragment (check if already routed to wiki/spec/issue)
156
+
157
+ Each fragment: `{ id: "HRV-{8 hex}", source_type, source_id, title, content, tags, category, confidence: 0.0-1.0 }`. Filter by `--min-confidence`.
158
+
159
+ **Shortcut**: If artifact has `context-package.json`, convert its fields directly to fragments (skip detailed parsing).
160
+
161
+ ---
162
+
163
+ ## Stage 4: classify_routing
164
+
165
+ For each fragment, determine the best routing target (unless `--to` forces a specific target).
166
+
167
+ ### Classification Rules
168
+
169
+ | Category | Default Target | Rationale |
170
+ |----------|---------------|-----------|
171
+ | `finding` | wiki (note) | Observations go to knowledge graph |
172
+ | `decision` | wiki (spec) or spec (decision) | Architectural decisions → spec ADR or wiki spec entry |
173
+ | `pattern` | spec (pattern) | Reusable code patterns → coding conventions |
174
+ | `bug` | issue or spec (bug) | Active bugs → issue; fixed bugs → spec learnings |
175
+ | `risk` | issue | Unmitigated risks → trackable issues |
176
+ | `task` | issue | Unfinished work → trackable issues |
177
+ | `knowhow` | wiki (knowhow) | Generalizable insights → wiki knowledge |
178
+ | `recommendation` | wiki (note) or issue | Actionable recommendations → issue; informational → wiki |
179
+
180
+ `--to wiki|spec|issue` forces all fragments to that target. `--to auto` uses classification rules.
181
+
182
+ Group into three buckets: `wiki`, `spec`, `issue`.
183
+
184
+ ---
185
+
186
+ ## Stage 5: preview_and_confirm
187
+
188
+ Display the routing plan:
189
+
190
+ ```
191
+ === HARVEST PLAN ===
192
+ Source: ANL-auth-20260410 (analysis)
193
+ Fragments extracted: 8 (filtered from 12 by confidence ≥ 0.5)
194
+
195
+ → Wiki (3 entries):
196
+ [note] "SQL injection vector in user input" tags: security, sql
197
+ [knowhow] "Parameterized queries prevent injection" tags: security, pattern
198
+ [spec] "Auth token rotation policy" tags: auth, security
199
+
200
+ → Spec (2 entries):
201
+ [pattern] "Always use parameterized queries for user input"
202
+ [decision] "JWT refresh tokens over session cookies"
203
+
204
+ → Issue (3 entries):
205
+ [high] "Unvalidated redirect in OAuth callback"
206
+ [medium] "Missing rate limit on token refresh endpoint"
207
+ [low] "Inconsistent error messages leak internal state"
208
+
209
+ Total: 3 wiki + 2 spec + 3 issue = 8 routed items
210
+ ```
211
+
212
+ `--dry-run` → display and exit. Otherwise (unless `-y`), AskUserQuestion: "yes" (apply), "edit" (per-item accept/reject), "skip" (abort).
213
+
214
+ ---
215
+
216
+ ## Stage 6: route_outputs
217
+
218
+ ### 6a. Wiki routing
219
+
220
+ `maestro wiki create --type <wiki_type> --slug harvest-<source_type>-<short_id>`. Fallback: write `.workflow/harvest/wiki-pending-{id}.md`; flag wiki entry as [LOW CONFIDENCE] (pending offline).
221
+
222
+ ### 6b. Spec routing
223
+
224
+ MANDATORY, NOT SUBSTITUTABLE by manual Read/Grep: `Skill({ skill: "spec-add", args: "<spec_type> <content>" })`. Mapping: pattern→pattern, decision→decision, bug→bug, knowhow→rule.
225
+
226
+ ### 6c. Issue routing
227
+
228
+ Append to `.workflow/issues/issues.jsonl`:
229
+
230
+ ```json
231
+ {
232
+ "id": "ISS-{YYYYMMDD}-{NNN}",
233
+ "title": "<title>",
234
+ "description": "<description>",
235
+ "severity": "<high|medium|low>",
236
+ "status": "open",
237
+ "source": "harvest",
238
+ "source_ref": "<source_id>",
239
+ "tags": [],
240
+ "created_at": "<ISO timestamp>",
241
+ "issue_history": [{ "action": "created", "timestamp": "<ISO>", "by": "harvest", "detail": "Extracted from <source_type> <source_id>" }]
242
+ }
243
+ ```
244
+
245
+ ### 6d. Track harvest provenance
246
+
247
+ For each routed item, record in `.workflow/harvest/harvest-log.jsonl`:
248
+
249
+ ```json
250
+ {
251
+ "fragment_id": "HRV-...",
252
+ "source_type": "analysis",
253
+ "source_id": "ANL-auth-20260410",
254
+ "routed_to": "wiki|spec|issue",
255
+ "target_id": "note-harvest-analysis-abc123|ISS-20260413-001|...",
256
+ "timestamp": "<ISO>",
257
+ "title": "<title>",
258
+ "confidence": 0.85
259
+ }
260
+ ```
261
+
262
+ ---
263
+
264
+ ## Stage 7: dedup_check
265
+
266
+ Before writing in Stage 6, check: `harvest-log.jsonl` (fragment_id), wiki (title), `issues.jsonl` (title/description), `specs/learnings.md` (content). Duplicates → `[SKIP-DUP]`, logged to report.
267
+
268
+ ---
269
+
270
+ ## Stage 8: report
271
+
272
+ Write `.workflow/harvest/harvest-report-{date}.md`:
273
+
274
+ ```markdown
275
+ # Harvest Report — {date}
276
+
277
+ ## Source
278
+ - Type: {source_type}
279
+ - ID: {source_id}
280
+ - Path: {path}
281
+
282
+ ## Extraction Summary
283
+ - Fragments found: {total}
284
+ - Filtered by confidence: {filtered_count}
285
+ - Duplicates skipped: {dup_count}
286
+
287
+ ## Routing Results
288
+
289
+ ### Wiki ({N} entries)
290
+ | # | Type | Slug | Title | Status |
291
+ |---|------|------|-------|--------|
292
+ | 1 | note | harvest-analysis-abc | SQL injection vector | CREATED |
293
+ | 2 | knowhow | harvest-analysis-def | Parameterized queries | CREATED |
294
+
295
+ ### Spec ({N} entries)
296
+ | # | Type | Content (truncated) | Status |
297
+ |---|------|---------------------|--------|
298
+ | 1 | pattern | Always use parameterized queries... | ADDED |
299
+
300
+ ### Issue ({N} entries)
301
+ | # | Severity | Title | ID | Status |
302
+ |---|----------|-------|-----|--------|
303
+ | 1 | high | Unvalidated redirect in OAuth... | ISS-20260413-001 | CREATED |
304
+
305
+ ## Skipped
306
+ | Fragment | Reason |
307
+ |----------|--------|
308
+ | HRV-abc123 | Duplicate: existing wiki entry note-sql-injection |
309
+ ```
310
+
311
+ Display summary:
312
+
313
+ ```
314
+ === HARVEST COMPLETE ===
315
+ Source: ANL-auth-20260410 (analysis)
316
+
317
+ Wiki: 3 created, 0 skipped
318
+ Spec: 2 added, 0 skipped
319
+ Issue: 3 created, 1 skipped (dup)
320
+
321
+ Report: .workflow/harvest/harvest-report-2026-04-13.md
322
+ Log: .workflow/harvest/harvest-log.jsonl
323
+
324
+ Next:
325
+ → Review wiki entries: maestro wiki list --type note
326
+ → Triage issues: Skill({ skill: "manage-issue", args: "list --source harvest" })
327
+ → Connect wiki graph: Skill({ skill: "wiki-connect", args: "--fix" })
328
+ → View specs: Skill({ skill: "spec-load", args: "--role implement" })
329
+ ```
330
+
331
+ ---
332
+
333
+ ## Stage 9: state_hygiene (--prune)
334
+
335
+ Skip Stages 2-8. Three concerns: artifact graduation, accumulated_context pruning, integrity validation.
336
+
337
+ ### 9a. Load state
338
+
339
+ ```
340
+ Read .workflow/state.json → { artifacts[], accumulated_context{}, current_milestone, milestones[] }
341
+ Read .workflow/harvest/harvest-log.jsonl → build harvested_map: { [source_id]: { fragment_count, routed_count, last_harvested } }
342
+ Defaults: age_threshold = --age value (default 14 days), dry_run = --dry-run flag
343
+ ```
344
+
345
+ ### 9b. Classify artifacts
346
+
347
+ For each artifact in `artifacts[]`, assign a classification:
348
+
349
+ | Classification | Criteria | Action |
350
+ |---|---|---|
351
+ | `active` | milestone == current_milestone OR age < age_threshold OR referenced by active plan (type=plan, status=completed, linked execute not completed) | **Keep** in artifacts[] |
352
+ | `graduated` | harvested == true AND not active | **Graduate** → knowhow → archive |
353
+ | `stale` | harvested == false AND not active AND age > age_threshold | **Suggest** harvest first |
354
+ | `protected` | type ∈ {plan, execute} AND linked downstream artifact is active | **Keep** regardless of age |
355
+
356
+ Age = days since `completed_at` (or `created_at`). Protected if referenced by any active plan/execute artifact.
357
+
358
+ ### 9c. Classify accumulated_context
359
+
360
+ Scan `accumulated_context` sub-arrays:
361
+
362
+ | Field | Prune Criteria | Keep Criteria |
363
+ |---|---|---|
364
+ | `key_decisions[]` | Entry exists verbatim in `specs/architecture-constraints.md` (deduplicated to spec) | Not yet in specs |
365
+ | `deferred[]` | status ∈ {"resolved", "cancelled", "superseded"} | status ∈ {"open", "deferred"} |
366
+ | `blockers[]` | status == "resolved" | status ∈ {"open", "investigating"} |
367
+
368
+ ### 9d. Preview
369
+
370
+ ```
371
+ === STATE HYGIENE PLAN ===
372
+
373
+ Artifacts (23 total):
374
+ active: 8 (keep)
375
+ graduated: 11 (→ knowhow → archive)
376
+ stale: 3 (suggest harvest first)
377
+ protected: 1 (keep)
378
+
379
+ Accumulated Context:
380
+ key_decisions: 12 total → 4 prunable (already in specs)
381
+ deferred: 5 total → 2 prunable (resolved)
382
+ blockers: 3 total → 1 prunable (resolved)
383
+
384
+ Stale artifacts (not yet harvested):
385
+ ANL-003 analysis 2026-03-15 "Security audit P2"
386
+ BRN-002 brainstorm 2026-03-10 "Cache strategy"
387
+ WFS-005 session 2026-03-08 "Feature toggle impl"
388
+ → Run: /manage-harvest ANL-003 BRN-002 WFS-005 (harvest before graduating)
389
+
390
+ Estimated state.json reduction: 23 → 9 artifacts, 20 → 13 context entries
391
+ ```
392
+
393
+ `--dry-run` → display and exit. Otherwise (unless `-y`), AskUserQuestion:
394
+ - "Proceed" — apply all
395
+ - "Graduate only" — archive graduated artifacts, skip accumulated_context prune
396
+ - "Harvest stale first" — run harvest on stale artifacts, then re-classify
397
+ - "Abort"
398
+
399
+ ### 9e. Graduate to knowhow
400
+
401
+ For each `graduated` artifact:
402
+
403
+ 1. **Build compact summary** from harvest-log entries:
404
+ - Fragment count, routing breakdown (N wiki, N spec, N issue)
405
+ - Top 3 fragment titles as representative items
406
+ - Original path for disk reference
407
+
408
+ 2. **Create knowhow entry**:
409
+ ```bash
410
+ maestro wiki create --type knowhow \
411
+ --slug "graduated-{type}-{short_id}" \
412
+ --title "Graduated: {type} {id}" \
413
+ --tags "graduated,{type},{milestone}" \
414
+ --body "{compact_summary}"
415
+ ```
416
+
417
+ 3. **Archive in state.json**: Move from `artifacts[]` to `artifact_archive[]`:
418
+ ```json
419
+ {
420
+ "id": "ANL-001",
421
+ "type": "analyze",
422
+ "milestone": "M1",
423
+ "path": "scratch/20260315-analyze-P2-security",
424
+ "graduated_at": "ISO-8601",
425
+ "knowhow_ref": "graduated-analyze-ANL-001",
426
+ "summary": "Security audit P2 — 8 fragments → 3 wiki, 2 spec, 3 issue"
427
+ }
428
+ ```
429
+
430
+ 4. **Files on disk**: NOT deleted. The `.workflow/{path}/` directory remains for reference. Only the state.json entry moves.
431
+
432
+ ### 9f. Prune accumulated_context
433
+
434
+ For each prunable entry identified in 9c:
435
+ - `key_decisions[]`: remove entry, log `[PRUNE] key_decision: "{text}" (deduplicated to spec)`
436
+ - `deferred[]`: remove entry, log `[PRUNE] deferred: "{title}" (status: {status})`
437
+ - `blockers[]`: remove entry, log `[PRUNE] blocker: "{title}" (resolved)`
438
+
439
+ ### 9g. Apply
440
+
441
+ 1. **Backup**: Copy `state.json` → `state.json.backup-prune-{timestamp}`
442
+ 2. **Write**: Updated state.json with:
443
+ - `artifacts[]` = active + protected entries only
444
+ - `artifact_archive[]` = existing archive + newly graduated
445
+ - `accumulated_context` = pruned version
446
+ - `last_pruned`: ISO-8601 timestamp
447
+ 3. **Validate**: Re-read and confirm artifact count matches expected
448
+
449
+ ### 9h. Report
450
+
451
+ Append prune results to harvest report:
452
+
453
+ ```
454
+ === PRUNE COMPLETE ===
455
+
456
+ Graduated: 11 artifacts → knowhow
457
+ Archived: 11 entries moved to artifact_archive[]
458
+ Pruned: 4 key_decisions + 2 deferred + 1 blocker = 7 context entries
459
+
460
+ State reduction: 23 → 9 artifacts, 20 → 13 context entries
461
+ Backup: .workflow/state.json.backup-prune-20260521T143022
462
+
463
+ Stale (not harvested, action needed):
464
+ → /manage-harvest ANL-003 BRN-002 WFS-005
465
+
466
+ Next:
467
+ → Review graduated knowhow: maestro wiki list --type knowhow --tags graduated
468
+ → Re-run prune after harvesting stale: /manage-harvest --prune
469
+ ```
470
+
471
+ ### Safety invariants
472
+
473
+ 1. NEVER prune current milestone artifacts
474
+ 2. NEVER delete files on disk — only state.json entries move
475
+ 3. ALWAYS backup before write (`state.json.backup-prune-{timestamp}`)
476
+ 4. ALWAYS flag stale artifacts before graduating (prevent knowledge loss)
477
+ 5. Spec dedup: only prune key_decisions with verbatim match in specs
478
+ 6. Idempotent: re-running with no changes produces empty plan
@@ -0,0 +1,168 @@
1
+ # Impeccable Harvest Workflow
2
+
3
+ > **Note**: Post-harvest hook, distinct from `/maestro-impeccable` command. This file is the harvest workflow invoked AFTER an impeccable run; it is not the impeccable command entry itself (see `chainMap['impeccable_*']` in `maestro.md`).
4
+
5
+ Post-execution knowledge capture for maestro-impeccable commands. Extracts design decisions and persists to `.workflow/knowhow/` + `specs/`.
6
+
7
+ ---
8
+
9
+ ## Pre-check
10
+
11
+ - If `--skip-harvest` → STOP, return
12
+ - If sub-command is `live` → STOP, return (interactive, no harvestable output)
13
+ - If `.workflow/knowhow/` does not exist → create it
14
+
15
+ ---
16
+
17
+ ## Step 1: Determine Harvest Type
18
+
19
+ Map sub-command to knowhow type:
20
+
21
+ | Command | Type | Prefix | Source |
22
+ |---------|------|--------|--------|
23
+ | craft | decision + asset | DCS- + AST- | Conversation (design decisions + tokens) |
24
+ | shape | decision | DCS- | Conversation (design brief decisions) |
25
+ | teach | reference | REF- | PRODUCT.md (read brand/user/principles) |
26
+ | document | asset | AST- | DESIGN.md YAML frontmatter (token system) |
27
+ | extract | asset | AST- | Conversation (extracted patterns) |
28
+ | critique | tip | TIP- | .impeccable/critique/ (latest snapshot) OR conversation |
29
+ | audit | tip | TIP- | Conversation (5-dimension scores) |
30
+ | polish | tip | TIP- | Conversation (polish points) |
31
+ | bolder | decision | DCS- | Conversation (amplification decisions) |
32
+ | quieter | decision | DCS- | Conversation (reduction decisions) |
33
+ | distill | decision | DCS- | Conversation (simplification decisions) |
34
+ | harden | tip | TIP- | Conversation (hardening patterns) |
35
+ | onboard | tip | TIP- | Conversation (onboarding patterns) |
36
+ | animate | decision | DCS- | Conversation (animation strategy) |
37
+ | colorize | decision | DCS- | Conversation (color strategy + OKLCH) |
38
+ | typeset | decision | DCS- | Conversation (typography decisions) |
39
+ | layout | decision | DCS- | Conversation (layout/spacing decisions) |
40
+ | delight | decision | DCS- | Conversation (personality decisions) |
41
+ | overdrive | decision | DCS- | Conversation (creative decisions) |
42
+ | clarify | tip | TIP- | Conversation (copy improvements) |
43
+ | adapt | tip | TIP- | Conversation (responsive decisions) |
44
+ | optimize | tip | TIP- | Conversation (performance fixes) |
45
+
46
+ ---
47
+
48
+ ## Step 2: Extract Content
49
+
50
+ ### File-source commands
51
+
52
+ **teach**: Read `PRODUCT.md` at project root. Extract: register, users, brand personality, anti-references, design principles. Summarize as reference.
53
+
54
+ **document**: Read `DESIGN.md` at project root. Parse YAML frontmatter for color tokens, typography scale, spacing, components. If `.impeccable/design.json` exists, read it for extended metadata.
55
+
56
+ **critique**: Check `.impeccable/critique/` for latest snapshot matching the target slug. If found, read score + findings. Otherwise extract from conversation.
57
+
58
+ ### Conversation-source commands (all others)
59
+
60
+ Summarize from the conversation context that is available after Skill() returns:
61
+ - **What decisions were made** (color strategy, font choice, spacing system, etc.)
62
+ - **What values were chosen** (OKLCH values, scale ratios, timing curves, etc.)
63
+ - **Why** (rationale, constraints, user requirements)
64
+
65
+ Keep concise: 5-15 bullet points maximum. Capture decisions, not process.
66
+
67
+ ---
68
+
69
+ ## Step 3: Write Knowhow Entry
70
+
71
+ ### For DCS- (decision), TIP- (tip), REF- (reference)
72
+
73
+ MANDATORY, NOT SUBSTITUTABLE by manual Read/Grep: use `store_knowhow` MCP tool:
74
+
75
+ ```json
76
+ {
77
+ "operation": "add",
78
+ "type": "<decision|tip|reference>",
79
+ "title": "maestro-impeccable <command>: <concise description>",
80
+ "description": "<one-line summary for search results>",
81
+ "body": "<markdown content from Step 2>",
82
+ "tags": ["impeccable", "<command>", "<category>", ...domain keywords]
83
+ }
84
+ ```
85
+
86
+ **Body structure** for decision type:
87
+ ```markdown
88
+ ## Context
89
+ maestro-impeccable {command} on {target}
90
+
91
+ ## Decisions
92
+ - {key decision 1}: {value/choice}
93
+ - {key decision 2}: {value/choice}
94
+ - ...
95
+
96
+ ## Rationale
97
+ {why these choices were made}
98
+
99
+ ## Source
100
+ /maestro-impeccable {command} {target}
101
+ ```
102
+
103
+ **Body structure** for tip type:
104
+ ```markdown
105
+ ## Summary
106
+ {command} on {target}: {one-line outcome}
107
+
108
+ ## Key Points
109
+ - {finding/fix 1}
110
+ - {finding/fix 2}
111
+ - ...
112
+
113
+ ## Source
114
+ /maestro-impeccable {command} {target}
115
+ ```
116
+
117
+ ### For AST- (asset)
118
+
119
+ Write directly to `.workflow/knowhow/AST-impeccable-<slug>-<YYYYMMDD>.md`:
120
+
121
+ ```yaml
122
+ ---
123
+ title: "maestro-impeccable <command>: <description>"
124
+ type: asset
125
+ assetType: <design-tokens|component-patterns|design-system>
126
+ category: ui
127
+ keywords: [impeccable, <command>, ...domain keywords]
128
+ codePaths: [<files modified by command>]
129
+ created: "<ISO-8601>"
130
+ tags: [impeccable, <command>]
131
+ ---
132
+ ```
133
+
134
+ Body: structured design token data or pattern descriptions extracted in Step 2.
135
+
136
+ ### For craft (dual entry)
137
+
138
+ Create both:
139
+ 1. DCS- via store_knowhow (design decisions)
140
+ 2. AST- via Write (concrete tokens/patterns committed)
141
+
142
+ ---
143
+
144
+ ## Step 4: Create Spec Index (DCS- and AST- only)
145
+
146
+ For decision and asset entries, create a spec reference for discoverability:
147
+
148
+ ```bash
149
+ # MANDATORY, NOT SUBSTITUTABLE by manual Read/Grep
150
+ maestro spec add ui "<title>" "<one-line summary>" \
151
+ --keywords impeccable,<command>,<domain keywords> \
152
+ --ref "knowhow/<filename>"
153
+ ```
154
+
155
+ Skip for TIP- and REF- types (too lightweight for spec indexing).
156
+
157
+ ---
158
+
159
+ ## Step 5: Report
160
+
161
+ Output one-line harvest summary:
162
+
163
+ ```
164
+ 收割: <type> <knowhow-id> — <title>
165
+ 查看: maestro wiki load <id>
166
+ ```
167
+
168
+ If harvest fails, emit W001 and continue (command execution already succeeded); flag harvest as [LOW CONFIDENCE] (harvest failed).