maestro-flow 0.3.42 → 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 (172) 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 +52 -80
  13. package/.claude/commands/maestro-ralph.md +2 -2
  14. package/.claude/commands/maestro-tools-execute.md +117 -0
  15. package/.claude/commands/maestro-tools-register.md +137 -0
  16. package/.claude/commands/maestro-ui-codify.md +67 -0
  17. package/.claude/commands/manage-harvest.md +1 -1
  18. package/.claude/commands/manage-learn.md +5 -7
  19. package/.claude/commands/manage-wiki.md +1 -1
  20. package/.claude/commands/quality-auto-test.md +1 -1
  21. package/.claude/commands/quality-debug.md +8 -0
  22. package/.claude/commands/quality-retrospective.md +4 -5
  23. package/.claude/commands/quality-review.md +8 -0
  24. package/.claude/commands/spec-add.md +25 -4
  25. package/.claude/commands/spec-load.md +26 -6
  26. package/.claude/commands/spec-setup.md +2 -2
  27. package/.claude/commands/wiki-connect.md +1 -1
  28. package/.claude/commands/wiki-digest.md +5 -6
  29. package/.claude/skills/codify-to-knowhow/SKILL.md +167 -0
  30. package/.claude/skills/codify-to-knowhow/phases/01-load-manifest.md +101 -0
  31. package/.claude/skills/codify-to-knowhow/phases/02-generate-knowhow.md +97 -0
  32. package/.claude/skills/codify-to-knowhow/phases/03-generate-specs.md +92 -0
  33. package/.claude/skills/codify-to-knowhow/phases/04-index-verify.md +119 -0
  34. package/.codex/skills/codify-to-knowhow/SKILL.md +427 -0
  35. package/.codex/skills/learn-decompose/SKILL.md +8 -8
  36. package/.codex/skills/learn-follow/SKILL.md +6 -6
  37. package/.codex/skills/learn-investigate/SKILL.md +4 -4
  38. package/.codex/skills/learn-retro/SKILL.md +7 -7
  39. package/.codex/skills/learn-second-opinion/SKILL.md +6 -6
  40. package/.codex/skills/maestro-analyze/SKILL.md +491 -491
  41. package/.codex/skills/maestro-collab/SKILL.md +1 -1
  42. package/.codex/skills/maestro-learn/SKILL.md +1 -1
  43. package/.codex/skills/maestro-milestone-complete/SKILL.md +122 -122
  44. package/.codex/skills/maestro-plan/SKILL.md +485 -485
  45. package/.codex/skills/maestro-tools-execute/SKILL.md +105 -0
  46. package/.codex/skills/maestro-tools-register/SKILL.md +144 -0
  47. package/.codex/skills/maestro-ui-codify/SKILL.md +398 -0
  48. package/.codex/skills/maestro-verify/SKILL.md +486 -486
  49. package/.codex/skills/manage-harvest/SKILL.md +3 -3
  50. package/.codex/skills/manage-issue-discover/SKILL.md +431 -431
  51. package/.codex/skills/manage-learn/SKILL.md +13 -13
  52. package/.codex/skills/manage-wiki/SKILL.md +1 -1
  53. package/.codex/skills/quality-auto-test/SKILL.md +553 -553
  54. package/.codex/skills/quality-refactor/SKILL.md +151 -151
  55. package/.codex/skills/quality-retrospective/SKILL.md +6 -6
  56. package/.codex/skills/spec-add/SKILL.md +17 -4
  57. package/.codex/skills/spec-load/SKILL.md +24 -28
  58. package/.codex/skills/team-quality-assurance/roles/executor/role.md +1 -1
  59. package/.codex/skills/team-review/roles/reviewer/role.md +1 -1
  60. package/.codex/skills/team-tech-debt/roles/scanner/role.md +1 -1
  61. package/.codex/skills/team-testing/roles/executor/role.md +1 -1
  62. package/.codex/skills/team-testing/roles/generator/role.md +1 -1
  63. package/.codex/skills/wiki-connect/SKILL.md +5 -5
  64. package/.codex/skills/wiki-digest/SKILL.md +8 -8
  65. package/dashboard/dist-server/dashboard/src/server/agents/claude-code-adapter.js +4 -2
  66. package/dashboard/dist-server/dashboard/src/server/agents/claude-code-adapter.js.map +1 -1
  67. package/dashboard/dist-server/dashboard/src/server/routes/specs.js +1 -1
  68. package/dashboard/dist-server/dashboard/src/server/routes/specs.js.map +1 -1
  69. package/dashboard/dist-server/dashboard/src/server/routes/wiki.js +2 -1
  70. package/dashboard/dist-server/dashboard/src/server/routes/wiki.js.map +1 -1
  71. package/dashboard/dist-server/dashboard/src/server/state/fs-watcher.js +2 -2
  72. package/dashboard/dist-server/dashboard/src/server/state/fs-watcher.js.map +1 -1
  73. package/dashboard/dist-server/dashboard/src/server/supervisor/self-learning-service.d.ts +1 -1
  74. package/dashboard/dist-server/dashboard/src/server/supervisor/self-learning-service.js +1 -1
  75. package/dashboard/dist-server/dashboard/src/server/supervisor/self-learning-service.js.map +1 -1
  76. package/dashboard/dist-server/dashboard/src/server/wiki/search.js +2 -2
  77. package/dashboard/dist-server/dashboard/src/server/wiki/search.js.map +1 -1
  78. package/dashboard/dist-server/dashboard/src/server/wiki/spec-entry-parser.d.ts +7 -3
  79. package/dashboard/dist-server/dashboard/src/server/wiki/spec-entry-parser.js +47 -15
  80. package/dashboard/dist-server/dashboard/src/server/wiki/spec-entry-parser.js.map +1 -1
  81. package/dashboard/dist-server/dashboard/src/server/wiki/stress.test.js +1 -1
  82. package/dashboard/dist-server/dashboard/src/server/wiki/stress.test.js.map +1 -1
  83. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.d.ts +1 -2
  84. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js +3 -52
  85. package/dashboard/dist-server/dashboard/src/server/wiki/virtual-wiki-adapters.js.map +1 -1
  86. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +67 -21
  87. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
  88. package/dashboard/dist-server/dashboard/src/server/wiki/wiki-types.d.ts +6 -1
  89. package/dashboard/dist-server/dashboard/src/server/wiki/writer-stress.test.js +1 -11
  90. package/dashboard/dist-server/dashboard/src/server/wiki/writer-stress.test.js.map +1 -1
  91. package/dashboard/dist-server/dashboard/src/server/wiki/writer.d.ts +7 -4
  92. package/dashboard/dist-server/dashboard/src/server/wiki/writer.js +27 -12
  93. package/dashboard/dist-server/dashboard/src/server/wiki/writer.js.map +1 -1
  94. package/dashboard/dist-server/src/tools/spec-entry-parser.d.ts +10 -2
  95. package/dashboard/dist-server/src/tools/spec-entry-parser.js +46 -12
  96. package/dashboard/dist-server/src/tools/spec-entry-parser.js.map +1 -1
  97. package/dashboard/dist-server/src/tools/spec-loader.d.ts +6 -2
  98. package/dashboard/dist-server/src/tools/spec-loader.js +119 -23
  99. package/dashboard/dist-server/src/tools/spec-loader.js.map +1 -1
  100. package/dist/src/commands/knowhow.d.ts.map +1 -1
  101. package/dist/src/commands/knowhow.js +21 -2
  102. package/dist/src/commands/knowhow.js.map +1 -1
  103. package/dist/src/commands/spec.d.ts +1 -1
  104. package/dist/src/commands/spec.d.ts.map +1 -1
  105. package/dist/src/commands/spec.js +78 -4
  106. package/dist/src/commands/spec.js.map +1 -1
  107. package/dist/src/commands/wiki.d.ts.map +1 -1
  108. package/dist/src/commands/wiki.js +51 -3
  109. package/dist/src/commands/wiki.js.map +1 -1
  110. package/dist/src/hooks/keyword-spec-injector.js +1 -1
  111. package/dist/src/hooks/keyword-spec-injector.js.map +1 -1
  112. package/dist/src/hooks/plugins/spec-injection-plugin.js +11 -11
  113. package/dist/src/hooks/plugins/spec-injection-plugin.js.map +1 -1
  114. package/dist/src/hooks/spec-injector.d.ts +1 -0
  115. package/dist/src/hooks/spec-injector.d.ts.map +1 -1
  116. package/dist/src/hooks/spec-injector.js +55 -22
  117. package/dist/src/hooks/spec-injector.js.map +1 -1
  118. package/dist/src/hooks/wiki-role-loader.d.ts +18 -0
  119. package/dist/src/hooks/wiki-role-loader.d.ts.map +1 -0
  120. package/dist/src/hooks/wiki-role-loader.js +43 -0
  121. package/dist/src/hooks/wiki-role-loader.js.map +1 -0
  122. package/dist/src/tools/spec-entry-parser.d.ts +10 -2
  123. package/dist/src/tools/spec-entry-parser.d.ts.map +1 -1
  124. package/dist/src/tools/spec-entry-parser.js +46 -12
  125. package/dist/src/tools/spec-entry-parser.js.map +1 -1
  126. package/dist/src/tools/spec-init.d.ts.map +1 -1
  127. package/dist/src/tools/spec-init.js +19 -0
  128. package/dist/src/tools/spec-init.js.map +1 -1
  129. package/dist/src/tools/spec-loader.d.ts +6 -2
  130. package/dist/src/tools/spec-loader.d.ts.map +1 -1
  131. package/dist/src/tools/spec-loader.js +119 -23
  132. package/dist/src/tools/spec-loader.js.map +1 -1
  133. package/dist/src/tools/spec-writer.d.ts +6 -1
  134. package/dist/src/tools/spec-writer.d.ts.map +1 -1
  135. package/dist/src/tools/spec-writer.js +29 -2
  136. package/dist/src/tools/spec-writer.js.map +1 -1
  137. package/dist/src/tools/store-knowhow.d.ts.map +1 -1
  138. package/dist/src/tools/store-knowhow.js +56 -27
  139. package/dist/src/tools/store-knowhow.js.map +1 -1
  140. package/package.json +1 -1
  141. package/workflows/analyze.md +2 -2
  142. package/workflows/auto-test.md +2 -2
  143. package/workflows/brainstorm.md +1 -1
  144. package/workflows/codebase-rebuild.md +1 -1
  145. package/workflows/codebase-refresh.md +1 -1
  146. package/workflows/debug.md +1 -1
  147. package/workflows/execute.md +3 -3
  148. package/workflows/harvest.md +13 -13
  149. package/workflows/integration-test.md +2 -2
  150. package/workflows/issue-discover.md +1 -1
  151. package/workflows/knowhow.md +72 -11
  152. package/workflows/learn.md +70 -58
  153. package/workflows/map.md +1 -1
  154. package/workflows/milestone-complete.md +2 -2
  155. package/workflows/plan.md +1 -1
  156. package/workflows/quick.md +1 -1
  157. package/workflows/refactor.md +1 -1
  158. package/workflows/retrospective.md +51 -57
  159. package/workflows/review.md +1 -1
  160. package/workflows/roadmap-common.md +1 -1
  161. package/workflows/specs-add.md +11 -2
  162. package/workflows/specs-load.md +17 -15
  163. package/workflows/test-gen.md +1 -1
  164. package/workflows/tools-spec.md +98 -0
  165. package/workflows/ui-codify-extract.md +373 -0
  166. package/workflows/ui-codify-knowhow.md +258 -0
  167. package/workflows/ui-codify-package.md +161 -0
  168. package/workflows/ui-codify.md +225 -0
  169. package/workflows/verify.md +1 -1
  170. package/workflows/wiki-connect.md +7 -7
  171. package/workflows/wiki-digest.md +13 -13
  172. package/workflows/wiki-manage.md +1 -1
@@ -0,0 +1,119 @@
1
+ # Phase 4: Index and Verify
2
+
3
+ 刷新 wiki 索引,验证所有创建的资产已正确索引和链接。
4
+
5
+ ## Objective
6
+
7
+ - 刷新 wiki-index.json 以包含新创建的资产
8
+ - 验证 knowhow 文件存在并已索引
9
+ - 验证 spec 条目已写入
10
+ - 验证 ref 链接从 spec 指向 knowhow
11
+ - 输出完成报告
12
+
13
+ ## Execution
14
+
15
+ ### Step 4.1: Refresh Wiki Index
16
+
17
+ 触发 wiki 索引刷新以识别新增的 knowhow 文件:
18
+
19
+ ```bash
20
+ # 刷新 wiki 索引
21
+ maestro wiki health 2>/dev/null || echo "Wiki index refresh skipped (command not available)"
22
+ ```
23
+
24
+ 索引刷新确保 `wiki-index.json` 包含新创建的 AST-/DCS- 文件的 WikiEntry。
25
+
26
+ ### Step 4.2: Verify Knowhow Files
27
+
28
+ 检查所有预期的 knowhow 文件是否存在:
29
+
30
+ ```bash
31
+ echo "=== Knowhow 资产验证 ==="
32
+
33
+ # 必需文件
34
+ for file in ${knowhowPaths}; do
35
+ if test -f "$file"; then
36
+ echo " OK: $file"
37
+ else
38
+ echo " MISSING: $file"
39
+ fi
40
+ done
41
+ ```
42
+
43
+ ### Step 4.3: Verify Spec Entries
44
+
45
+ 检查 spec 文件中是否包含新增的条目:
46
+
47
+ ```bash
48
+ echo "=== Spec 条目验证 ==="
49
+
50
+ # 检查 coding-conventions.md 中是否含 slug 相关条目
51
+ grep -c "${slug}" .workflow/specs/coding-conventions.md 2>/dev/null && \
52
+ echo " OK: coding-conventions.md (${slug} entries found)" || \
53
+ echo " MISSING: No ${slug} entries in coding-conventions.md"
54
+
55
+ # 检查 architecture-constraints.md 中是否含 slug 相关条目
56
+ grep -c "${slug}" .workflow/specs/architecture-constraints.md 2>/dev/null && \
57
+ echo " OK: architecture-constraints.md (${slug} entries found)" || \
58
+ echo " MISSING: No ${slug} entries in architecture-constraints.md"
59
+ ```
60
+
61
+ ### Step 4.4: Verify Ref Links
62
+
63
+ 检查 spec 条目中的 ref 属性指向的 knowhow 文件是否存在:
64
+
65
+ ```bash
66
+ echo "=== Ref 链接验证 ==="
67
+
68
+ # 从 spec 文件中提取 ref 属性值
69
+ refs=$(grep -oP 'ref="knowhow/[^"]*"' .workflow/specs/coding-conventions.md .workflow/specs/architecture-constraints.md 2>/dev/null | grep "${slug}" || true)
70
+
71
+ if [ -n "$refs" ]; then
72
+ echo "$refs" | while IFS= read -r ref; do
73
+ # 提取文件路径
74
+ filepath=$(echo "$ref" | grep -oP 'knowhow/[^"]*')
75
+ if test -f ".workflow/$filepath"; then
76
+ echo " OK: $filepath"
77
+ else
78
+ echo " BROKEN: $filepath (file not found)"
79
+ fi
80
+ done
81
+ else
82
+ echo " WARNING: No ref links found for ${slug}"
83
+ fi
84
+ ```
85
+
86
+ ### Step 4.5: Generate Completion Report
87
+
88
+ ```
89
+ === Codify to Knowhow 完成 ===
90
+
91
+ 包: {slug}
92
+ 来源: {packagePath}
93
+
94
+ Knowhow 资产:
95
+ AST-{slug}-tokens.md — 设计 token 资产
96
+ AST-{slug}-components.md — 组件模式资产
97
+ DCS-{slug}-decisions.md — 设计决策 {仅当有冲突}
98
+
99
+ Spec 条目 ({specEntryCount} 条):
100
+ coding: 颜色约定, 排版约定, 间距约定
101
+ arch: 组件分类约束{, 设计决策约束 — 仅当有冲突}
102
+
103
+ Ref 链接: spec → knowhow 桥梁已建立
104
+ Wiki 索引: 已刷新
105
+
106
+ 后续操作:
107
+ maestro wiki list --role implement # 按角色浏览
108
+ maestro spec load --keyword {slug} # 加载相关 spec
109
+ maestro wiki load <id> # 加载详文
110
+ ```
111
+
112
+ ## Output
113
+
114
+ - **Report**: 验证结果(所有资产/条目/链接状态)
115
+ - **TodoWrite**: Mark Phase 4 completed (all tasks done)
116
+
117
+ ## Completion
118
+
119
+ Codify to Knowhow 已完成。设计包已固化为知识资产。
@@ -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>