maestro-flow 0.3.43 → 0.3.44

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 (169) hide show
  1. package/.claude/commands/learn-decompose.md +10 -15
  2. package/.claude/commands/learn-follow.md +11 -16
  3. package/.claude/commands/learn-investigate.md +18 -22
  4. package/.claude/commands/learn-retro.md +23 -26
  5. package/.claude/commands/learn-second-opinion.md +11 -16
  6. package/.claude/commands/maestro-analyze.md +8 -0
  7. package/.claude/commands/maestro-brainstorm.md +8 -0
  8. package/.claude/commands/maestro-execute.md +11 -3
  9. package/.claude/commands/maestro-learn.md +4 -4
  10. package/.claude/commands/maestro-milestone-complete.md +6 -6
  11. package/.claude/commands/maestro-plan.md +8 -0
  12. package/.claude/commands/maestro-ralph-execute.md +1 -2
  13. package/.claude/commands/maestro-tools-execute.md +117 -0
  14. package/.claude/commands/maestro-tools-register.md +137 -0
  15. package/.claude/commands/maestro-ui-codify.md +67 -0
  16. package/.claude/commands/manage-harvest.md +1 -1
  17. package/.claude/commands/manage-learn.md +5 -7
  18. package/.claude/commands/manage-wiki.md +1 -1
  19. package/.claude/commands/quality-auto-test.md +1 -1
  20. package/.claude/commands/quality-debug.md +8 -0
  21. package/.claude/commands/quality-retrospective.md +4 -5
  22. package/.claude/commands/quality-review.md +8 -0
  23. package/.claude/commands/spec-add.md +25 -4
  24. package/.claude/commands/spec-load.md +26 -6
  25. package/.claude/commands/spec-setup.md +2 -2
  26. package/.claude/commands/wiki-connect.md +1 -1
  27. package/.claude/commands/wiki-digest.md +5 -6
  28. package/.claude/skills/codify-to-knowhow/SKILL.md +167 -0
  29. package/.claude/skills/codify-to-knowhow/phases/01-load-manifest.md +101 -0
  30. package/.claude/skills/codify-to-knowhow/phases/02-generate-knowhow.md +97 -0
  31. package/.claude/skills/codify-to-knowhow/phases/03-generate-specs.md +92 -0
  32. package/.claude/skills/codify-to-knowhow/phases/04-index-verify.md +119 -0
  33. package/.codex/skills/codify-to-knowhow/SKILL.md +427 -0
  34. package/.codex/skills/learn-decompose/SKILL.md +8 -8
  35. package/.codex/skills/learn-follow/SKILL.md +6 -6
  36. package/.codex/skills/learn-investigate/SKILL.md +4 -4
  37. package/.codex/skills/learn-retro/SKILL.md +7 -7
  38. package/.codex/skills/learn-second-opinion/SKILL.md +6 -6
  39. package/.codex/skills/maestro-analyze/SKILL.md +491 -491
  40. package/.codex/skills/maestro-collab/SKILL.md +1 -1
  41. package/.codex/skills/maestro-learn/SKILL.md +1 -1
  42. package/.codex/skills/maestro-milestone-complete/SKILL.md +122 -122
  43. package/.codex/skills/maestro-plan/SKILL.md +485 -485
  44. package/.codex/skills/maestro-tools-execute/SKILL.md +105 -0
  45. package/.codex/skills/maestro-tools-register/SKILL.md +144 -0
  46. package/.codex/skills/maestro-ui-codify/SKILL.md +398 -0
  47. package/.codex/skills/maestro-verify/SKILL.md +486 -486
  48. package/.codex/skills/manage-harvest/SKILL.md +3 -3
  49. package/.codex/skills/manage-issue-discover/SKILL.md +431 -431
  50. package/.codex/skills/manage-learn/SKILL.md +13 -13
  51. package/.codex/skills/manage-wiki/SKILL.md +1 -1
  52. package/.codex/skills/quality-auto-test/SKILL.md +553 -553
  53. package/.codex/skills/quality-refactor/SKILL.md +151 -151
  54. package/.codex/skills/quality-retrospective/SKILL.md +6 -6
  55. package/.codex/skills/spec-add/SKILL.md +17 -4
  56. package/.codex/skills/spec-load/SKILL.md +24 -28
  57. package/.codex/skills/team-quality-assurance/roles/executor/role.md +1 -1
  58. package/.codex/skills/team-review/roles/reviewer/role.md +1 -1
  59. package/.codex/skills/team-tech-debt/roles/scanner/role.md +1 -1
  60. package/.codex/skills/team-testing/roles/executor/role.md +1 -1
  61. package/.codex/skills/team-testing/roles/generator/role.md +1 -1
  62. package/.codex/skills/wiki-connect/SKILL.md +5 -5
  63. package/.codex/skills/wiki-digest/SKILL.md +8 -8
  64. package/dashboard/dist-server/dashboard/src/server/routes/specs.js +1 -1
  65. package/dashboard/dist-server/dashboard/src/server/routes/specs.js.map +1 -1
  66. package/dashboard/dist-server/dashboard/src/server/routes/wiki.js +2 -1
  67. package/dashboard/dist-server/dashboard/src/server/routes/wiki.js.map +1 -1
  68. package/dashboard/dist-server/dashboard/src/server/state/fs-watcher.js +2 -2
  69. package/dashboard/dist-server/dashboard/src/server/state/fs-watcher.js.map +1 -1
  70. package/dashboard/dist-server/dashboard/src/server/supervisor/self-learning-service.d.ts +1 -1
  71. package/dashboard/dist-server/dashboard/src/server/supervisor/self-learning-service.js +1 -1
  72. package/dashboard/dist-server/dashboard/src/server/supervisor/self-learning-service.js.map +1 -1
  73. package/dashboard/dist-server/dashboard/src/server/wiki/search.js +2 -2
  74. package/dashboard/dist-server/dashboard/src/server/wiki/search.js.map +1 -1
  75. package/dashboard/dist-server/dashboard/src/server/wiki/spec-entry-parser.d.ts +7 -3
  76. package/dashboard/dist-server/dashboard/src/server/wiki/spec-entry-parser.js +47 -15
  77. package/dashboard/dist-server/dashboard/src/server/wiki/spec-entry-parser.js.map +1 -1
  78. package/dashboard/dist-server/dashboard/src/server/wiki/stress.test.js +1 -1
  79. package/dashboard/dist-server/dashboard/src/server/wiki/stress.test.js.map +1 -1
  80. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.d.ts +1 -2
  81. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js +3 -52
  82. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js.map +1 -1
  83. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +67 -21
  84. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  85. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-types.d.ts +6 -1
  86. package/dashboard/dist-server/dashboard/src/server/wiki/writer-stress.test.js +1 -11
  87. package/dashboard/dist-server/dashboard/src/server/wiki/writer-stress.test.js.map +1 -1
  88. package/dashboard/dist-server/dashboard/src/server/wiki/writer.d.ts +7 -4
  89. package/dashboard/dist-server/dashboard/src/server/wiki/writer.js +27 -12
  90. package/dashboard/dist-server/dashboard/src/server/wiki/writer.js.map +1 -1
  91. package/dashboard/dist-server/src/tools/spec-entry-parser.d.ts +10 -2
  92. package/dashboard/dist-server/src/tools/spec-entry-parser.js +46 -12
  93. package/dashboard/dist-server/src/tools/spec-entry-parser.js.map +1 -1
  94. package/dashboard/dist-server/src/tools/spec-loader.d.ts +6 -2
  95. package/dashboard/dist-server/src/tools/spec-loader.js +119 -23
  96. package/dashboard/dist-server/src/tools/spec-loader.js.map +1 -1
  97. package/dist/src/commands/knowhow.d.ts.map +1 -1
  98. package/dist/src/commands/knowhow.js +21 -2
  99. package/dist/src/commands/knowhow.js.map +1 -1
  100. package/dist/src/commands/spec.d.ts +1 -1
  101. package/dist/src/commands/spec.d.ts.map +1 -1
  102. package/dist/src/commands/spec.js +78 -4
  103. package/dist/src/commands/spec.js.map +1 -1
  104. package/dist/src/commands/wiki.d.ts.map +1 -1
  105. package/dist/src/commands/wiki.js +51 -3
  106. package/dist/src/commands/wiki.js.map +1 -1
  107. package/dist/src/hooks/keyword-spec-injector.js +1 -1
  108. package/dist/src/hooks/keyword-spec-injector.js.map +1 -1
  109. package/dist/src/hooks/plugins/spec-injection-plugin.js +11 -11
  110. package/dist/src/hooks/plugins/spec-injection-plugin.js.map +1 -1
  111. package/dist/src/hooks/spec-injector.d.ts +1 -0
  112. package/dist/src/hooks/spec-injector.d.ts.map +1 -1
  113. package/dist/src/hooks/spec-injector.js +55 -22
  114. package/dist/src/hooks/spec-injector.js.map +1 -1
  115. package/dist/src/hooks/wiki-role-loader.d.ts +18 -0
  116. package/dist/src/hooks/wiki-role-loader.d.ts.map +1 -0
  117. package/dist/src/hooks/wiki-role-loader.js +43 -0
  118. package/dist/src/hooks/wiki-role-loader.js.map +1 -0
  119. package/dist/src/tools/spec-entry-parser.d.ts +10 -2
  120. package/dist/src/tools/spec-entry-parser.d.ts.map +1 -1
  121. package/dist/src/tools/spec-entry-parser.js +46 -12
  122. package/dist/src/tools/spec-entry-parser.js.map +1 -1
  123. package/dist/src/tools/spec-init.d.ts.map +1 -1
  124. package/dist/src/tools/spec-init.js +19 -0
  125. package/dist/src/tools/spec-init.js.map +1 -1
  126. package/dist/src/tools/spec-loader.d.ts +6 -2
  127. package/dist/src/tools/spec-loader.d.ts.map +1 -1
  128. package/dist/src/tools/spec-loader.js +119 -23
  129. package/dist/src/tools/spec-loader.js.map +1 -1
  130. package/dist/src/tools/spec-writer.d.ts +6 -1
  131. package/dist/src/tools/spec-writer.d.ts.map +1 -1
  132. package/dist/src/tools/spec-writer.js +29 -2
  133. package/dist/src/tools/spec-writer.js.map +1 -1
  134. package/dist/src/tools/store-knowhow.d.ts.map +1 -1
  135. package/dist/src/tools/store-knowhow.js +56 -27
  136. package/dist/src/tools/store-knowhow.js.map +1 -1
  137. package/package.json +1 -1
  138. package/workflows/analyze.md +2 -2
  139. package/workflows/auto-test.md +2 -2
  140. package/workflows/brainstorm.md +1 -1
  141. package/workflows/codebase-rebuild.md +1 -1
  142. package/workflows/codebase-refresh.md +1 -1
  143. package/workflows/debug.md +1 -1
  144. package/workflows/execute.md +3 -3
  145. package/workflows/harvest.md +13 -13
  146. package/workflows/integration-test.md +2 -2
  147. package/workflows/issue-discover.md +1 -1
  148. package/workflows/knowhow.md +72 -11
  149. package/workflows/learn.md +70 -58
  150. package/workflows/map.md +1 -1
  151. package/workflows/milestone-complete.md +2 -2
  152. package/workflows/plan.md +1 -1
  153. package/workflows/quick.md +1 -1
  154. package/workflows/refactor.md +1 -1
  155. package/workflows/retrospective.md +51 -57
  156. package/workflows/review.md +1 -1
  157. package/workflows/roadmap-common.md +1 -1
  158. package/workflows/specs-add.md +11 -2
  159. package/workflows/specs-load.md +17 -15
  160. package/workflows/test-gen.md +1 -1
  161. package/workflows/tools-spec.md +98 -0
  162. package/workflows/ui-codify-extract.md +373 -0
  163. package/workflows/ui-codify-knowhow.md +258 -0
  164. package/workflows/ui-codify-package.md +161 -0
  165. package/workflows/ui-codify.md +225 -0
  166. package/workflows/verify.md +1 -1
  167. package/workflows/wiki-connect.md +7 -7
  168. package/workflows/wiki-digest.md +13 -13
  169. package/workflows/wiki-manage.md +1 -1
@@ -0,0 +1,427 @@
1
+ ---
2
+ name: codify-to-knowhow
3
+ description: Manifest-driven knowledge asset generator — converts structured packages into knowhow + spec entries
4
+ argument-hint: "<package-path>"
5
+ allowed-tools: Read, Write, Edit, Bash, Glob, Grep
6
+ ---
7
+
8
+ <purpose>
9
+ Sequential manifest-driven knowledge asset generator. Reads `knowhow-manifest.json` from a package directory, writes knowhow files and spec entries with ref linking. No wave execution needed — pure sequential file operations.
10
+
11
+ **Core workflow**: Validate Manifest -> Write Knowhow Files -> Write Spec Entries -> Verify & Index
12
+
13
+ ```
14
+ +---------------------------------------------------------------------------+
15
+ | CODIFY TO KNOWHOW (Direct Execution) |
16
+ +---------------------------------------------------------------------------+
17
+ | |
18
+ | Step 1: Parse package-path from $ARGUMENTS |
19
+ | |
20
+ | Step 2: Load & Validate knowhow-manifest.json |
21
+ | +-- Validate required fields: slug, roles, knowhow[], specs[] |
22
+ | +-- Parse manifest object |
23
+ | |
24
+ | Step 3: Generate Knowhow Assets |
25
+ | +-- For each manifest.knowhow[]: |
26
+ | | +-- Idempotency check (skip if file exists) |
27
+ | | +-- Build frontmatter + body with <knowhow-entry> tags |
28
+ | | +-- Write to .workflow/knowhow/{PREFIX}-{slug}-{fileSlug}.md |
29
+ | |
30
+ | Step 4: Generate Spec Entries |
31
+ | +-- For each manifest.specs[]: |
32
+ | | +-- Idempotency check (skip if title exists) |
33
+ | | +-- Write via maestro spec add CLI (fallback: direct append) |
34
+ | | +-- Include ref attribute linking to knowhow file |
35
+ | |
36
+ | Step 5: Refresh Wiki Index |
37
+ | +-- maestro wiki health |
38
+ | |
39
+ | Step 6: Verify & Report |
40
+ | +-- Verify knowhow files exist |
41
+ | +-- Verify spec entries written |
42
+ | +-- Verify ref links resolve |
43
+ | +-- Output completion report |
44
+ | |
45
+ +---------------------------------------------------------------------------+
46
+ ```
47
+
48
+ </purpose>
49
+
50
+ <context>
51
+ ```bash
52
+ $codify-to-knowhow ".workflow/reference_style/my-style-v1"
53
+ ```
54
+
55
+ **Arguments**:
56
+ - `<package-path>` (positional, required): Directory containing `knowhow-manifest.json`
57
+
58
+ **Upstream**: `maestro-ui-codify`, `learn-decompose`, or any skill that generates a manifest
59
+ **Downstream**: `maestro wiki list --role implement`, `maestro spec load --keyword <slug>`
60
+ </context>
61
+
62
+ <manifest_schema>
63
+
64
+ ### knowhow-manifest.json
65
+
66
+ ```json
67
+ {
68
+ "slug": "my-style-v1",
69
+ "domain": "ui-design",
70
+ "roles": ["implement", "review"],
71
+ "packagePath": ".workflow/reference_style/my-style-v1",
72
+
73
+ "knowhow": [
74
+ {
75
+ "prefix": "AST",
76
+ "fileSlug": "tokens",
77
+ "title": "Design Tokens",
78
+ "category": "asset",
79
+ "assetType": "design-tokens",
80
+ "codePaths": ["src/styles/"],
81
+ "tags": ["design-tokens", "colors"],
82
+ "body": "## Colors\n\n...",
83
+ "entries": [
84
+ {
85
+ "category": "pattern",
86
+ "keywords": "colors,tokens",
87
+ "title": "Color System",
88
+ "body": "## Colors\n\n..."
89
+ }
90
+ ]
91
+ }
92
+ ],
93
+
94
+ "specs": [
95
+ {
96
+ "category": "coding",
97
+ "keywords": "colors,design-tokens",
98
+ "title": "Color Coding Convention",
99
+ "ref": "knowhow/AST-my-style-v1-tokens.md",
100
+ "body": "Use var(--color-primary) for primary colors..."
101
+ }
102
+ ]
103
+ }
104
+ ```
105
+
106
+ **Required fields**:
107
+
108
+ | Field | Required | Description |
109
+ |-------|----------|-------------|
110
+ | `slug` | Yes | Package slug, used in file naming |
111
+ | `roles` | Yes | Role annotation array |
112
+ | `knowhow` | Yes | Knowhow asset declarations (can be empty) |
113
+ | `specs` | Yes | Spec entry declarations (can be empty) |
114
+ | `domain` | No | Domain identifier (ui-design, api, data) |
115
+ | `packagePath` | No | Original package path (metadata) |
116
+
117
+ **knowhow[] item fields**:
118
+
119
+ | Field | Required | Description |
120
+ |-------|----------|-------------|
121
+ | `prefix` | Yes | File prefix: AST, DCS, BLP, TIP, RCP, REF |
122
+ | `fileSlug` | Yes | File name suffix (e.g. "tokens") |
123
+ | `title` | Yes | Document title |
124
+ | `category` | Yes | asset, decision, blueprint, tip, recipe, reference |
125
+ | `tags` | Yes | Tag array |
126
+ | `body` | Yes | Markdown body content |
127
+ | `assetType` | No | Asset subtype (design-tokens, components, etc.) |
128
+ | `codePaths` | No | Related source code paths |
129
+ | `entries` | No | Sub-entries with `<knowhow-entry>` closed tags |
130
+
131
+ **specs[] item fields**:
132
+
133
+ | Field | Required | Description |
134
+ |-------|----------|-------------|
135
+ | `category` | Yes | coding, arch, quality, debug, test, review, learning |
136
+ | `title` | Yes | Entry title |
137
+ | `keywords` | Yes | Comma-separated keywords |
138
+ | `body` | Yes | Entry body text |
139
+ | `ref` | No | Reference path to knowhow file |
140
+
141
+ </manifest_schema>
142
+
143
+ <invariants>
144
+ 1. **Manifest Required**: No manifest = error exit, no fallback
145
+ 2. **Idempotent Writes**: Same-slug file exists = skip, never overwrite
146
+ 3. **Closed Tags**: All entries use `<spec-entry>` / `<knowhow-entry>` closed-tag format
147
+ 4. **Upstream Generates Manifest**: This skill only writes, never extracts knowledge
148
+ 5. **CLI First, File Fallback**: Prefer `maestro spec add` CLI; fall back to direct file append on failure
149
+ 6. **Ref Bridge**: Spec entries reference knowhow files via `ref` attribute
150
+ </invariants>
151
+
152
+ <execution>
153
+
154
+ ### Step 1: Parse Package Path
155
+
156
+ **Parse from `$ARGUMENTS`**:
157
+
158
+ | Variable | Source | Default |
159
+ |----------|--------|---------|
160
+ | `package_path` | positional (required) | ERROR if missing |
161
+
162
+ ```bash
163
+ package_path="${PACKAGE_PATH}"
164
+
165
+ # Validate directory exists
166
+ test -d "$package_path" || { echo "ERROR: Package path not found: $package_path"; exit 1; }
167
+
168
+ # Validate manifest exists
169
+ manifest_file="${package_path}/knowhow-manifest.json"
170
+ test -f "$manifest_file" || { echo "ERROR: knowhow-manifest.json not found in $package_path"; exit 1; }
171
+ ```
172
+
173
+ ### Step 2: Load & Validate Manifest
174
+
175
+ Read `${package_path}/knowhow-manifest.json` and validate:
176
+
177
+ ```javascript
178
+ const manifest = JSON.parse(manifestContent);
179
+
180
+ // Required field validation
181
+ const required = ['slug', 'roles', 'knowhow', 'specs'];
182
+ const missing = required.filter(f => !manifest[f]);
183
+ if (missing.length > 0) {
184
+ ERROR("Missing required fields: " + missing.join(', '));
185
+ EXIT(1);
186
+ }
187
+
188
+ // Summary
189
+ REPORT(`Manifest loaded:
190
+ Slug: ${manifest.slug}
191
+ Domain: ${manifest.domain || 'generic'}
192
+ Roles: ${manifest.roles.join(', ')}
193
+ Knowhow assets: ${manifest.knowhow.length}
194
+ Spec entries: ${manifest.specs.length}
195
+ `);
196
+ ```
197
+
198
+ ### Step 3: Generate Knowhow Assets
199
+
200
+ Ensure `.workflow/knowhow/` exists. For each `manifest.knowhow[]` item:
201
+
202
+ ```bash
203
+ mkdir -p .workflow/knowhow
204
+ ```
205
+
206
+ ```javascript
207
+ const knowhowPaths = [];
208
+
209
+ for (const asset of manifest.knowhow) {
210
+ const filename = `${asset.prefix}-${manifest.slug}-${asset.fileSlug}.md`;
211
+ const filepath = `.workflow/knowhow/${filename}`;
212
+
213
+ // Idempotency check
214
+ if (fileExists(filepath)) {
215
+ REPORT(`SKIP: ${filename} (already exists)`);
216
+ continue;
217
+ }
218
+
219
+ // Build frontmatter
220
+ let frontmatter = `---
221
+ title: ${asset.title}
222
+ type: ${asset.category}`;
223
+
224
+ if (asset.assetType) {
225
+ frontmatter += `\nassetType: ${asset.assetType}`;
226
+ }
227
+
228
+ frontmatter += `\nroles: [${manifest.roles.join(', ')}]`;
229
+
230
+ if (asset.codePaths && asset.codePaths.length > 0) {
231
+ frontmatter += `\ncodePaths:`;
232
+ for (const cp of asset.codePaths) {
233
+ frontmatter += `\n - ${cp}`;
234
+ }
235
+ }
236
+
237
+ frontmatter += `\ntags: [${asset.tags.join(', ')}]`;
238
+ frontmatter += `\n---`;
239
+
240
+ // Build body
241
+ let body = asset.body || '';
242
+
243
+ // If entries[], generate <knowhow-entry> closed tags
244
+ if (asset.entries && asset.entries.length > 0) {
245
+ const today = new Date().toISOString().split('T')[0];
246
+ for (let i = 0; i < asset.entries.length; i++) {
247
+ const entry = asset.entries[i];
248
+ const entryId = `${asset.prefix}-${manifest.slug}-${String(i + 1).padStart(3, '0')}`;
249
+ body += `\n\n<knowhow-entry keywords="${entry.category},${entry.keywords}" date="${today}" id="${entryId}" roles="${manifest.roles.join(',')}" source="codify-to-knowhow">
250
+
251
+ ### ${entry.title}
252
+
253
+ ${entry.body}
254
+
255
+ </knowhow-entry>`;
256
+ }
257
+ }
258
+
259
+ const content = `${frontmatter}\n\n${body}`;
260
+ Write(filepath, content);
261
+ REPORT(`CREATED: ${filename}`);
262
+ knowhowPaths.push(filepath);
263
+ }
264
+
265
+ const skippedCount = manifest.knowhow.length - knowhowPaths.length;
266
+ REPORT(`Knowhow assets: ${knowhowPaths.length} created, ${skippedCount} skipped`);
267
+ ```
268
+
269
+ ### Step 4: Generate Spec Entries
270
+
271
+ For each `manifest.specs[]` item, write spec entry with `<spec-entry>` closed tag:
272
+
273
+ ```javascript
274
+ const categoryFileMap = {
275
+ coding: 'coding-conventions.md',
276
+ arch: 'architecture-constraints.md',
277
+ quality: 'quality-rules.md',
278
+ debug: 'debug-notes.md',
279
+ test: 'test-conventions.md',
280
+ review: 'review-standards.md',
281
+ learning: 'learnings.md'
282
+ };
283
+
284
+ const today = new Date().toISOString().split('T')[0];
285
+ let specEntryCount = 0;
286
+
287
+ for (const spec of manifest.specs) {
288
+ const targetFile = `.workflow/specs/${categoryFileMap[spec.category]}`;
289
+
290
+ // Idempotency: check if title already exists
291
+ const titleExists = Bash(`grep -q "${spec.title}" "${targetFile}" 2>/dev/null && echo "exists" || echo "new"`);
292
+
293
+ if (titleExists.trim() === 'exists') {
294
+ REPORT(`SKIP spec: "${spec.title}" (already exists in ${spec.category})`);
295
+ continue;
296
+ }
297
+
298
+ // Build spec-entry closed tag
299
+ let refAttr = '';
300
+ if (spec.ref) {
301
+ refAttr = `\n ref="${spec.ref}"`;
302
+ }
303
+
304
+ const entryBlock = `
305
+
306
+ <spec-entry roles="${manifest.roles.join(',')}" keywords="${spec.keywords}" date="${today}"${refAttr}>
307
+
308
+ ### ${spec.title}
309
+
310
+ ${spec.body}
311
+
312
+ </spec-entry>`;
313
+
314
+ // Prefer CLI, fallback to direct append
315
+ const cliResult = Bash(`maestro spec add ${spec.category} "${spec.title}" "${spec.body}" --keywords "${spec.keywords}" 2>/dev/null`);
316
+
317
+ if (cliResult.exitCode !== 0) {
318
+ // Fallback: direct file append
319
+ Edit(targetFile, { append: entryBlock });
320
+ }
321
+
322
+ specEntryCount++;
323
+ REPORT(`CREATED spec: "${spec.title}" -> ${spec.category}`);
324
+ }
325
+
326
+ REPORT(`Spec entries: ${specEntryCount} created`);
327
+ ```
328
+
329
+ ### Step 5: Refresh Wiki Index
330
+
331
+ ```bash
332
+ maestro wiki health 2>/dev/null || echo "Wiki index refresh skipped (command not available)"
333
+ ```
334
+
335
+ ### Step 6: Verify & Report
336
+
337
+ **6a: Verify knowhow files**:
338
+
339
+ ```bash
340
+ echo "=== Knowhow Asset Verification ==="
341
+ for file in ${knowhowPaths}; do
342
+ if test -f "$file"; then
343
+ echo " OK: $file"
344
+ else
345
+ echo " MISSING: $file"
346
+ fi
347
+ done
348
+ ```
349
+
350
+ **6b: Verify spec entries**:
351
+
352
+ ```bash
353
+ echo "=== Spec Entry Verification ==="
354
+ grep -c "${slug}" .workflow/specs/coding-conventions.md 2>/dev/null && \
355
+ echo " OK: coding-conventions.md" || echo " MISSING: No entries in coding-conventions.md"
356
+
357
+ grep -c "${slug}" .workflow/specs/architecture-constraints.md 2>/dev/null && \
358
+ echo " OK: architecture-constraints.md" || echo " MISSING: No entries in architecture-constraints.md"
359
+ ```
360
+
361
+ **6c: Verify ref links**:
362
+
363
+ ```bash
364
+ echo "=== Ref Link Verification ==="
365
+ refs=$(grep -oP 'ref="knowhow/[^"]*"' .workflow/specs/coding-conventions.md .workflow/specs/architecture-constraints.md 2>/dev/null | grep "${slug}" || true)
366
+
367
+ if [ -n "$refs" ]; then
368
+ echo "$refs" | while IFS= read -r ref; do
369
+ filepath=$(echo "$ref" | grep -oP 'knowhow/[^"]*')
370
+ if test -f ".workflow/$filepath"; then
371
+ echo " OK: $filepath"
372
+ else
373
+ echo " BROKEN: $filepath (file not found)"
374
+ fi
375
+ done
376
+ else
377
+ echo " WARNING: No ref links found for ${slug}"
378
+ fi
379
+ ```
380
+
381
+ **6d: Completion report**:
382
+
383
+ ```
384
+ === Codify to Knowhow Complete ===
385
+
386
+ Package: {slug}
387
+ Source: {packagePath}
388
+
389
+ Knowhow Assets:
390
+ {list of created/skipped files}
391
+
392
+ Spec Entries ({specEntryCount} created):
393
+ {list of created/skipped entries by category}
394
+
395
+ Ref Links: spec -> knowhow bridge established
396
+ Wiki Index: refreshed
397
+
398
+ Next steps:
399
+ maestro wiki list --role implement # Browse by role
400
+ maestro spec load --keyword {slug} # Load related specs
401
+ maestro wiki load <id> # Load full entry
402
+ ```
403
+
404
+ </execution>
405
+
406
+ <error_codes>
407
+
408
+ | Error | Resolution |
409
+ |-------|------------|
410
+ | Package path not found | Abort: "Package path not found: {path}" |
411
+ | Manifest not found | Abort: "knowhow-manifest.json not found in {path}" |
412
+ | Missing required fields | Abort: "Missing required fields: {list}" |
413
+ | Idempotent conflict | Skip existing assets, report skip count |
414
+ | CLI spec add failed | Fallback to direct file append |
415
+ | Wiki health failed | Warning, continue (non-critical) |
416
+
417
+ </error_codes>
418
+
419
+ <success_criteria>
420
+ - [ ] Package path validated and manifest loaded
421
+ - [ ] All required manifest fields present
422
+ - [ ] Knowhow files written to .workflow/knowhow/ (idempotent)
423
+ - [ ] Spec entries written with <spec-entry> closed tags (idempotent)
424
+ - [ ] Ref links from specs point to existing knowhow files
425
+ - [ ] Wiki index refreshed
426
+ - [ ] Completion report with asset counts
427
+ </success_criteria>
@@ -8,7 +8,7 @@ allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, AskUser
8
8
  <purpose>
9
9
  Systematic pattern extraction from code via CSV wave pipeline. 4 parallel dimension agents
10
10
  scan a module, then a cross-reference agent deduplicates against existing patterns and
11
- produces a catalog. Discovered patterns persist to `lessons.jsonl` and optionally to
11
+ produces a catalog. Discovered patterns persist to `specs/learnings.md` and optionally to
12
12
  specs (via `spec-add`) and wiki.
13
13
 
14
14
  ```
@@ -32,7 +32,7 @@ $ARGUMENTS — target path/module and optional flags.
32
32
  - `--save-spec`: Invoke `spec-add` for each new pattern
33
33
  - `--save-wiki`: Create wiki note entries per dimension group
34
34
 
35
- **Output**: `.workflow/.csv-wave/{session-id}/` + `.workflow/learning/decompose-{slug}-{date}.md`
35
+ **Output**: `.workflow/.csv-wave/{session-id}/` + `.workflow/knowhow/KNW-decompose-{slug}-{date}.md`
36
36
  </context>
37
37
 
38
38
  <invariants>
@@ -40,7 +40,7 @@ $ARGUMENTS — target path/module and optional flags.
40
40
  2. **Evidence required**: Every finding must have file:line anchors
41
41
  3. **Dedup before persist**: Cross-reference against existing specs + lessons
42
42
  4. **Stable IDs**: INS-id from `hash("decompose" + target + pattern_name)`
43
- 5. **No files modified outside** `.workflow/learning/` (and optionally specs/wiki)
43
+ 5. **No files modified outside** `.workflow/knowhow/` (and optionally specs/wiki)
44
44
  </invariants>
45
45
 
46
46
  <execution>
@@ -50,7 +50,7 @@ $ARGUMENTS — target path/module and optional flags.
50
50
  Parse flags from `$ARGUMENTS`: `-y`/`--yes`, `--patterns <list>`, `--save-spec`, `--save-wiki`, `--continue`, `-c N`.
51
51
  Extract remaining text as target path/module.
52
52
 
53
- Resolve target to file list. Load existing patterns from `coding-conventions.md` + `lessons.jsonl` for dedup set.
53
+ Resolve target to file list. Load existing patterns from `coding-conventions.md` + `specs/learnings.md` for dedup set.
54
54
 
55
55
  ### Phase 2: Wave 1 — Parallel Dimension Scans
56
56
 
@@ -87,8 +87,8 @@ Single agent receives all wave 1 findings via `prev_context`. Tasks:
87
87
 
88
88
  ### Phase 4: Persist
89
89
 
90
- 1. Write `decompose-{slug}-{date}.md` with full catalog
91
- 2. Append each **new** pattern to `lessons.jsonl` (source: "decompose", category: "pattern")
90
+ 1. Write `KNW-decompose-{slug}-{date}.md` with full catalog
91
+ 2. Append each **new** pattern to `specs/learnings.md` (source: "decompose", category: "pattern")
92
92
  3. If `--save-spec`: invoke `spec-add` per new pattern
93
93
  4. If `--save-wiki`: create wiki note per dimension group
94
94
  </execution>
@@ -107,7 +107,7 @@ Single agent receives all wave 1 findings via `prev_context`. Tasks:
107
107
  - [ ] 4 dimension agents spawned in parallel via spawn_agents_on_csv
108
108
  - [ ] Each finding has: name, dimension, confidence, anchors, description
109
109
  - [ ] Cross-reference performed (documented / known / new)
110
- - [ ] Pattern catalog written to `decompose-{slug}-{date}.md`
111
- - [ ] New patterns appended to `lessons.jsonl` with stable INS-ids
110
+ - [ ] Pattern catalog written to `KNW-decompose-{slug}-{date}.md`
111
+ - [ ] New patterns appended to `specs/learnings.md` with stable INS-ids
112
112
  - [ ] If --save-spec / --save-wiki: entries created
113
113
  </success_criteria>
@@ -8,7 +8,7 @@ allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
8
8
  <purpose>
9
9
  Guided reading experience for code files, wiki entries, or topics. Walks through content
10
10
  section by section using 4 forcing questions to extract patterns, identify assumptions,
11
- and build a structured understanding map. Insights persist to `lessons.jsonl`.
11
+ and build a structured understanding map. Insights persist to `specs/learnings.md`.
12
12
 
13
13
  Unlike `learn-decompose` which is parallel pattern extraction, this is sequential
14
14
  deep reading that builds understanding incrementally.
@@ -27,7 +27,7 @@ $ARGUMENTS — target and optional flags.
27
27
  - `--depth deep` — Every function, branch, assumption
28
28
  - `--save-wiki` — Create wiki note with reading notes
29
29
 
30
- **Output**: `.workflow/learning/follow-{slug}-{date}.md`
30
+ **Output**: `.workflow/knowhow/KNW-follow-{slug}-{date}.md`
31
31
  </context>
32
32
 
33
33
  <execution>
@@ -56,8 +56,8 @@ From forcing question answers, extract: design patterns (with file:line anchors)
56
56
  Cross-reference against `coding-conventions.md`: documented vs undocumented patterns.
57
57
 
58
58
  ### Stage 5: Persist
59
- 1. Write `follow-{slug}-{date}.md` with understanding map
60
- 2. Append new patterns to `lessons.jsonl` (source: "follow", stable INS-ids)
59
+ 1. Write `KNW-follow-{slug}-{date}.md` with understanding map
60
+ 2. Append new patterns to `specs/learnings.md` (source: "follow", stable INS-ids)
61
61
  3. If `--save-wiki`: create wiki note entry
62
62
 
63
63
  **Next steps:** `/learn-decompose <path>`, `/spec-add coding ...`, `/learn-second-opinion <file>`
@@ -78,6 +78,6 @@ Cross-reference against `coding-conventions.md`: documented vs undocumented patt
78
78
  - [ ] All 4 forcing questions applied per section
79
79
  - [ ] Patterns extracted with file:line anchors
80
80
  - [ ] Understanding map produced with concepts, patterns, assumptions, questions
81
- - [ ] `follow-{slug}-{date}.md` written
82
- - [ ] `lessons.jsonl` appended with stable INS-ids
81
+ - [ ] `KNW-follow-{slug}-{date}.md` written
82
+ - [ ] `specs/learnings.md` appended with stable INS-ids
83
83
  </success_criteria>
@@ -21,14 +21,14 @@ $ARGUMENTS — question text and optional flags.
21
21
  - `--scope <path>` — Restrict to files under this directory (default: entire project)
22
22
  - `--max-hypotheses N` — Max hypotheses before escalating (default: 3)
23
23
 
24
- **Output**: `.workflow/learning/investigate-{slug}/` (evidence.ndjson, understanding.md, report.md)
24
+ **Output**: `.workflow/knowhow/KNW-investigate-{slug}/` (evidence.ndjson, understanding.md, report.md)
25
25
  </context>
26
26
 
27
27
  <execution>
28
28
 
29
29
  ### Stage 1: Frame the Question
30
30
  - Parse question, generate slug, create investigation directory
31
- - Search prior knowledge: wiki search, grep lessons.jsonl, read debug-notes.md
31
+ - Search prior knowledge: wiki search, grep specs/learnings.md, read debug-notes.md
32
32
  - Write initial `understanding.md`
33
33
 
34
34
  ### Stage 2: Evidence Collection
@@ -54,7 +54,7 @@ If all hypotheses fail: broaden scope, search wiki with alt keywords, or mark IN
54
54
 
55
55
  ### Stage 5: Synthesize + Persist
56
56
  1. Write `report.md` with answer, evidence trail, hypothesis results
57
- 2. Append to `lessons.jsonl`:
57
+ 2. Append to `specs/learnings.md`:
58
58
  - Confirmed → category: "technique" / "pattern"
59
59
  - Disproved → category: "gotcha"
60
60
  3. Display summary with next-step routing
@@ -78,6 +78,6 @@ If all hypotheses fail: broaden scope, search wiki with alt keywords, or mark IN
78
78
  - [ ] At least 1 hypothesis formed and tested
79
79
  - [ ] understanding.md tracks evolving understanding
80
80
  - [ ] report.md written with answer and evidence trail
81
- - [ ] Findings appended to lessons.jsonl with stable INS-ids
81
+ - [ ] Findings appended to specs/learnings.md with stable INS-ids
82
82
  - [ ] 3-strike escalation triggered if all hypotheses fail
83
83
  </success_criteria>
@@ -22,7 +22,7 @@ $ARGUMENTS — lens selection and scope flags.
22
22
  **Git flags:** `--days N` (default: 7), `--author <name>`, `--area <path>`, `--compare`
23
23
  **Decision flags:** `--phase N`, `--tag <tag>`, `--id <id>`
24
24
 
25
- **Output**: `.workflow/learning/retro-{date}.md` + `retro-{date}.json`
25
+ **Output**: `.workflow/knowhow/KNW-retro-{date}.md` + `KNW-retro-{date}.json`
26
26
  </context>
27
27
 
28
28
  <execution>
@@ -41,7 +41,7 @@ $ARGUMENTS — lens selection and scope flags.
41
41
  **Trend comparison** if prior `retro-*.json` exists.
42
42
 
43
43
  ### Phase 3: Decision Lens (skip if --lens git)
44
- **3a: Collect decisions** from wiki, specs, git log, phase context, lessons.jsonl.
44
+ **3a: Collect decisions** from wiki, specs, git log, phase context, specs/learnings.md.
45
45
  **3b: Build decision registry** per decision (id, title, source, rationale, alternatives, evidence).
46
46
 
47
47
  **3c: Multi-perspective evaluation** via spawn_agents_on_csv (3 parallel agents):
@@ -55,10 +55,10 @@ $ARGUMENTS — lens selection and scope flags.
55
55
  **3d: Classify lifecycle**: Validated / Aging / Questionable / Stale / Reversed.
56
56
 
57
57
  ### Phase 4: Unified Report
58
- Write `retro-{date}.md` + `retro-{date}.json` with metrics, sessions, hotspots, decision health, combined insights, recommended actions.
58
+ Write `KNW-retro-{date}.md` + `KNW-retro-{date}.json` with metrics, sessions, hotspots, decision health, combined insights, recommended actions.
59
59
 
60
60
  ### Phase 5: Persist
61
- Append insights to `lessons.jsonl` (source: "retro-git" or "retro-decision"). Display summary.
61
+ Append insights to `specs/learnings.md` (source: "retro-git" or "retro-decision"). Display summary.
62
62
 
63
63
  **Next steps:** `/learn-follow <path>`, `/quality-auto-test <area>`, `/learn-investigate <question>`
64
64
  </execution>
@@ -69,7 +69,7 @@ Append insights to `lessons.jsonl` (source: "retro-git" or "retro-decision"). Di
69
69
  | E001 | error | Not inside git repo (git lens) | Navigate to git repo |
70
70
  | E002 | error | No commits in time window | Increase --days |
71
71
  | E003 | error | No decisions found (decision lens) | Check wiki/specs content |
72
- | W001 | warning | .workflow/learning/ not found | Auto-bootstrap |
72
+ | W001 | warning | .workflow/knowhow/ not found | Auto-bootstrap |
73
73
  | W002 | warning | No prior retro for comparison | First retro establishes baseline |
74
74
  | W003 | warning | Decision perspective agent failed | Proceed with partial evaluation |
75
75
  </error_codes>
@@ -78,6 +78,6 @@ Append insights to `lessons.jsonl` (source: "retro-git" or "retro-decision"). Di
78
78
  - [ ] Lens selection parsed correctly
79
79
  - [ ] Git lens: metrics computed, sessions detected, hotspots identified
80
80
  - [ ] Decision lens: decisions collected, 3 agents spawned in parallel, lifecycle classified
81
- - [ ] Unified report written to retro-{date}.md + retro-{date}.json
82
- - [ ] lessons.jsonl appended with insights (stable INS-ids)
81
+ - [ ] Unified report written to KNW-retro-{date}.md + KNW-retro-{date}.json
82
+ - [ ] specs/learnings.md appended with insights (stable INS-ids)
83
83
  </success_criteria>
@@ -11,7 +11,7 @@ Structured second-opinion for code, decisions, or plans. Three modes:
11
11
  - **challenge**: single adversarial agent via spawn_agents_on_csv (1 worker)
12
12
  - **consult**: interactive Q&A (no CSV wave — direct orchestration)
13
13
 
14
- Findings persist to `lessons.jsonl`. Decoupled from phase lifecycle.
14
+ Findings persist to `specs/learnings.md`. Decoupled from phase lifecycle.
15
15
  </purpose>
16
16
 
17
17
  <context>
@@ -28,7 +28,7 @@ $ARGUMENTS — target and optional flags.
28
28
  - `--mode challenge` — Adversarial single-agent analysis
29
29
  - `--mode consult` — Interactive Q&A session
30
30
 
31
- **Output**: `.workflow/learning/opinion-{slug}-{date}.md`
31
+ **Output**: `.workflow/knowhow/KNW-opinion-{slug}-{date}.md`
32
32
  </context>
33
33
 
34
34
  <execution>
@@ -61,8 +61,8 @@ Single agent via spawn_agents_on_csv (1 worker). Adversarial analysis with forci
61
61
  Interactive loop via AskUserQuestion. Agent studies target, answers questions with code references. Compile Q&A into report on exit.
62
62
 
63
63
  ### Phase 3: Persist
64
- 1. Write `opinion-{slug}-{date}.md` with per-persona findings + synthesis
65
- 2. Append non-trivial findings to `lessons.jsonl` (source: "second-opinion")
64
+ 1. Write `KNW-opinion-{slug}-{date}.md` with per-persona findings + synthesis
65
+ 2. Append non-trivial findings to `specs/learnings.md` (source: "second-opinion")
66
66
  3. Display summary with verdict and next steps
67
67
 
68
68
  **Next steps:** `/manage-issue create`, `/learn-decompose <path>`, `/learn-follow <path>`
@@ -81,6 +81,6 @@ Interactive loop via AskUserQuestion. Agent studies target, answers questions wi
81
81
  - [ ] Target resolved and context loaded
82
82
  - [ ] Mode executed: review (3 parallel agents), challenge (adversarial), or consult (interactive)
83
83
  - [ ] Synthesis produced with agreements, disagreements, verdict
84
- - [ ] Report written to `opinion-{slug}-{date}.md`
85
- - [ ] Non-trivial findings appended to `lessons.jsonl`
84
+ - [ ] Report written to `KNW-opinion-{slug}-{date}.md`
85
+ - [ ] Non-trivial findings appended to `specs/learnings.md`
86
86
  </success_criteria>