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,372 @@
1
+ # UI Codify: Phase 2 — Parallel Agent Extraction
2
+
3
+ ## Overview
4
+
5
+ - 3 个 Agent 并行运行:Style、Animation、Layout
6
+ - 每个 Agent 可读取所有文件类型(CSS/SCSS/JS/TS/HTML)进行交叉引用
7
+ - 直接生成完整性报告
8
+ - 优雅的失败处理
9
+
10
+ ## Prerequisites
11
+
12
+ 来自 Phase 1 的变量:
13
+ - `source_path` — 源代码目录绝对路径
14
+ - `temp_dir` — 临时工作区路径
15
+
16
+ ## Step 2.1: File Discovery
17
+
18
+ ```bash
19
+ echo "[Phase 2] File Discovery Started"
20
+ echo " Source: ${source_path}"
21
+
22
+ # Discover files using script
23
+ discovery_file="${temp_dir}/.intermediates/import-analysis/discovered-files.json"
24
+ ccw tool exec discover_design_files '{"sourceDir":"'"${source_path}"'","outputPath":"'"${discovery_file}"'"}'
25
+
26
+ echo " Output: ${discovery_file}"
27
+ ```
28
+
29
+ **File Discovery Behavior**:
30
+ - **Automatic discovery**: 智能扫描源目录中所有样式相关文件
31
+ - **Supported file types**: CSS, SCSS, JavaScript, TypeScript, HTML
32
+ - **Smart filtering**: 查找主题相关 JS/TS 文件(tailwind.config.js, theme.js, styled-components 等)
33
+ - **Exclusions**: 自动排除 `node_modules/`, `dist/`, `.git/`, build 目录
34
+ - **Output**: `discovered-files.json` — `{ "css": [...], "js": [...], "html": [...], "counts": {...} }`
35
+
36
+ ---
37
+
38
+ ## Step 2.2: Parallel Agent Analysis
39
+
40
+ ```bash
41
+ echo "[Phase 2] Starting parallel agent analysis (3 agents)"
42
+ ```
43
+
44
+ ### Style Agent Task (design-tokens.json)
45
+
46
+ **Agent Task**:
47
+
48
+ ```javascript
49
+ Task(subagent_type="ui-design-agent",
50
+ run_in_background=false,
51
+ prompt="[STYLE_TOKENS_EXTRACTION]
52
+ Extract visual design tokens from code files using code import extraction pattern.
53
+
54
+ MODE: style-extraction | SOURCE: ${source_path} | BASE_PATH: ${temp_dir}
55
+
56
+ ## Input Files
57
+
58
+ **Discovered Files**: ${temp_dir}/.intermediates/import-analysis/discovered-files.json
59
+ $(cat \"${temp_dir}/.intermediates/import-analysis/discovered-files.json\" 2>/dev/null | grep -E '(count|files)' | head -30)
60
+
61
+ ## Code Import Extraction Strategy
62
+
63
+ **Step 0: Fast Conflict Detection** (Use Bash/Grep for quick global scan)
64
+ - Quick scan: \`rg --color=never -n "^\\s*--primary:|^\\s*--secondary:|^\\s*--accent:" --type css ${source_path}\` to find core color definitions with line numbers
65
+ - Semantic search: \`rg --color=never -B3 -A1 "^\\s*--primary:" --type css ${source_path}\` to capture surrounding context and comments
66
+ - Core token scan: Search for --primary, --secondary, --accent, --background patterns to detect all theme-critical definitions
67
+ - Pattern: rg → Extract values → Compare → If different → Read full context with comments → Record conflict
68
+ - Alternative (if many files): Execute CLI analysis for comprehensive report:
69
+ \`\`\`bash
70
+ ccw cli -p \"
71
+ PURPOSE: Detect color token conflicts across all CSS/SCSS/JS files
72
+ TASK: • Scan all files for color definitions • Identify conflicting values • Extract semantic comments
73
+ MODE: analysis
74
+ CONTEXT: @**/*.css @**/*.scss @**/*.js @**/*.ts
75
+ EXPECTED: JSON report listing conflicts with file:line, values, semantic context
76
+ RULES: Focus on core tokens | Report ALL variants | analysis=READ-ONLY
77
+ \" --tool gemini --mode analysis --cd ${source_path}
78
+ \`\`\`
79
+
80
+ **Step 1: Load file list**
81
+ - Read(${temp_dir}/.intermediates/import-analysis/discovered-files.json)
82
+ - Extract: file_types.css.files, file_types.js.files, file_types.html.files
83
+
84
+ **Step 2: Cross-source token extraction**
85
+ - CSS/SCSS: Colors, typography, spacing, shadows, borders
86
+ - JavaScript/TypeScript: Theme configs (Tailwind, styled-components, CSS-in-JS)
87
+ - HTML: Inline styles, usage patterns
88
+
89
+ **Step 3: Validation and Conflict Detection**
90
+ - Report missing tokens WITHOUT inference (mark as \"missing\" in _metadata.completeness)
91
+ - Detect and report inconsistent values across files (list ALL variants with file:line sources)
92
+ - Report missing categories WITHOUT auto-filling (document gaps for manual review)
93
+ - CRITICAL: Verify core tokens (primary, secondary, accent) against semantic comments in source code
94
+
95
+ ## Output Files
96
+
97
+ **Target Directory**: ${temp_dir}/style-extraction/style-1/
98
+
99
+ **Files to Generate**:
100
+ 1. **design-tokens.json**
101
+ - Follow [DESIGN_SYSTEM_GENERATION_TASK] standard token structure
102
+ - Add \"_metadata.extraction_source\": \"code_import\"
103
+ - Add \"_metadata.files_analyzed\": {css, js, html file lists}
104
+ - Add \"_metadata.completeness\": {status, missing_categories, recommendations}
105
+ - Add \"_metadata.conflicts\": Array of conflicting definitions (MANDATORY if conflicts exist)
106
+ - Add \"_metadata.code_snippets\": Map of code snippets (see below)
107
+ - Add \"_metadata.usage_recommendations\": Usage patterns from code (see below)
108
+ - Include \"source\" field for each token (e.g., \"file.css:23\")
109
+
110
+ **Code Snippet Recording**:
111
+ - For each extracted token, record the actual code snippet in `_metadata.code_snippets`
112
+ - Structure:
113
+ ```json
114
+ \"code_snippets\": {
115
+ \"file.css:23\": {
116
+ \"lines\": \"23-27\",
117
+ \"snippet\": \":root {\\n --color-primary: oklch(0.5555 0.15 270);\\n /* Primary brand color */\\n --color-primary-hover: oklch(0.6 0.15 270);\\n}\",
118
+ \"context\": \"css-variable\"
119
+ }
120
+ }
121
+ ```
122
+ - Context types: \"css-variable\" | \"css-class\" | \"js-object\" | \"js-theme-config\" | \"inline-style\"
123
+ - Record complete code blocks with all dependencies and relevant comments
124
+ - Typical ranges: Simple declarations (1-5 lines), Utility classes (5-15 lines), Complete configs (15-50 lines)
125
+ - Preserve original formatting and indentation
126
+
127
+ **Conflict Detection and Reporting**:
128
+ - When the same token is defined differently across multiple files, record in `_metadata.conflicts`
129
+ - Follow Agent schema for conflicts array structure (see ui-design-agent.md)
130
+ - Each conflict MUST include: token_name, category, all definitions with context, selected_value, selection_reason
131
+ - Selection priority:
132
+ 1. Definitions with semantic comments explaining intent (/* Blue theme */, /* Primary brand color */)
133
+ 2. Definitions that align with overall color scheme described in comments
134
+ 3. When in doubt, report ALL variants and flag for manual review in completeness.recommendations
135
+
136
+ **Usage Recommendations Generation**:
137
+ - Analyze code usage patterns to extract `_metadata.usage_recommendations` (see ui-design-agent.md schema)
138
+ - **Typography recommendations**:
139
+ * `common_sizes`: Identify most frequent font size usage (e.g., \"body_text\": \"base (1rem)\")
140
+ * `common_combinations`: Extract heading+body pairings from actual usage (e.g., h1 with p tags)
141
+ - **Spacing recommendations**:
142
+ * `size_guide`: Categorize spacing values into tight/normal/loose based on frequency
143
+ * `common_patterns`: Extract frequent padding/margin combinations from components
144
+ - Analysis method: Scan code for class/style usage frequency, extract patterns from component implementations
145
+ - Optional: If insufficient usage data, mark fields as empty arrays/objects with note in completeness.recommendations
146
+
147
+ ## Code Import Specific Requirements
148
+ - ✅ Read discovered-files.json FIRST to get file paths
149
+ - ✅ Track extraction source for each token (file:line)
150
+ - ✅ Record complete code snippets in _metadata.code_snippets (complete blocks with dependencies/comments)
151
+ - ✅ Include completeness assessment in _metadata
152
+ - ✅ Report inconsistent values with ALL source locations in _metadata.conflicts (DO NOT auto-normalize or choose)
153
+ - ✅ CRITICAL: Verify core theme tokens (primary, secondary, accent) match source code semantic intent
154
+ - ✅ When conflicts exist, prefer definitions with semantic comments explaining intent
155
+ - ❌ NO inference, NO smart filling, NO automatic conflict resolution
156
+ - ❌ NO external research or web searches (code-only extraction)
157
+ ")
158
+ ```
159
+
160
+ ### Animation Agent Task (animation-tokens.json)
161
+
162
+ **Agent Task**:
163
+
164
+ ```javascript
165
+ Task(subagent_type="ui-design-agent",
166
+ run_in_background=false,
167
+ prompt="[ANIMATION_TOKEN_GENERATION_TASK]
168
+ Extract animation tokens from code files using code import extraction pattern.
169
+
170
+ MODE: animation-extraction | SOURCE: ${source_path} | BASE_PATH: ${temp_dir}
171
+
172
+ ## Input Files
173
+
174
+ **Discovered Files**: ${temp_dir}/.intermediates/import-analysis/discovered-files.json
175
+ $(cat \"${temp_dir}/.intermediates/import-analysis/discovered-files.json\" 2>/dev/null | grep -E '(count|files)' | head -30)
176
+
177
+ ## Code Import Extraction Strategy
178
+
179
+ **Step 0: Fast Animation Discovery** (Use Bash/Grep for quick pattern detection)
180
+ - Quick scan: \`rg --color=never -n "@keyframes|animation:|transition:" --type css ${source_path}\` to find animation definitions with line numbers
181
+ - Framework detection: \`rg --color=never "framer-motion|gsap|@react-spring|react-spring" --type js --type ts ${source_path}\` to detect animation frameworks
182
+ - Pattern categorization: \`rg --color=never -B2 -A5 "@keyframes" --type css ${source_path}\` to extract keyframe animations with context
183
+ - Pattern: rg → Identify animation types → Map framework usage → Prioritize extraction targets
184
+ - Alternative (if complex framework mix): Execute CLI analysis for comprehensive report:
185
+ \`\`\`bash
186
+ ccw cli -p \"
187
+ PURPOSE: Detect animation frameworks and patterns
188
+ TASK: • Identify frameworks • Map animation patterns • Categorize by complexity
189
+ MODE: analysis
190
+ CONTEXT: @**/*.css @**/*.scss @**/*.js @**/*.ts
191
+ EXPECTED: JSON report listing frameworks, animation types, file locations
192
+ RULES: Focus on framework consistency | Map all animations | analysis=READ-ONLY
193
+ \" --tool gemini --mode analysis --cd ${source_path}
194
+ \`\`\`
195
+
196
+ **Step 1: Load file list**
197
+ - Read(${temp_dir}/.intermediates/import-analysis/discovered-files.json)
198
+ - Extract: file_types.css.files, file_types.js.files, file_types.html.files
199
+
200
+ **Step 2: Cross-source animation extraction**
201
+ - CSS/SCSS: @keyframes, transitions, animation properties
202
+ - JavaScript/TypeScript: Animation frameworks (Framer Motion, GSAP), CSS-in-JS
203
+ - HTML: Inline styles, data-animation attributes
204
+
205
+ **Step 3: Framework detection & normalization**
206
+ - Detect animation frameworks used (css-animations | framer-motion | gsap | none)
207
+ - Normalize into semantic token system
208
+ - Cross-reference CSS animations with JS configs
209
+
210
+ ## Output Files
211
+
212
+ **Target Directory**: ${temp_dir}/animation-extraction/
213
+
214
+ **Files to Generate**:
215
+ 1. **animation-tokens.json**
216
+ - Follow [ANIMATION_TOKEN_GENERATION_TASK] standard structure
217
+ - Add \"_metadata.framework_detected\"
218
+ - Add \"_metadata.files_analyzed\"
219
+ - Add \"_metadata.completeness\"
220
+ - Add \"_metadata.code_snippets\": Map of code snippets (same format as Style Agent)
221
+ - Include \"source\" field for each token
222
+
223
+ **Code Snippet Recording**:
224
+ - Record actual animation/transition code in `_metadata.code_snippets`
225
+ - Context types: \"css-keyframes\" | \"css-transition\" | \"js-animation\" | \"framer-motion\" | \"gsap\"
226
+ - Record complete blocks: @keyframes animations (10-30 lines), transition configs (5-15 lines), JS animation objects (15-50 lines)
227
+ - Include all animation steps, timing functions, and related comments
228
+ - Preserve original formatting and framework-specific syntax
229
+
230
+ ## Code Import Specific Requirements
231
+ - ✅ Read discovered-files.json FIRST to get file paths
232
+ - ✅ Detect animation framework if present
233
+ - ✅ Track extraction source for each token (file:line)
234
+ - ✅ Record complete code snippets in _metadata.code_snippets (complete animation blocks with all steps/timing)
235
+ - ✅ Normalize framework-specific syntax into standard tokens
236
+ - ❌ NO external research or web searches (code-only extraction)
237
+ ")
238
+ ```
239
+
240
+ ### Layout Agent Task (layout-templates.json)
241
+
242
+ **Agent Task**:
243
+
244
+ ```javascript
245
+ Task(subagent_type="ui-design-agent",
246
+ run_in_background=false,
247
+ prompt="[LAYOUT_TEMPLATE_GENERATION_TASK]
248
+ Extract layout patterns from code files using code import extraction pattern.
249
+
250
+ MODE: layout-extraction | SOURCE: ${source_path} | BASE_PATH: ${temp_dir}
251
+
252
+ ## Input Files
253
+
254
+ **Discovered Files**: ${temp_dir}/.intermediates/import-analysis/discovered-files.json
255
+ $(cat \"${temp_dir}/.intermediates/import-analysis/discovered-files.json\" 2>/dev/null | grep -E '(count|files)' | head -30)
256
+
257
+ ## Code Import Extraction Strategy
258
+
259
+ **Step 0: Fast Component Discovery** (Use Bash/Grep for quick component scan)
260
+ - Layout pattern scan: \`rg --color=never -n "display:\\s*(grid|flex)|grid-template" --type css ${source_path}\` to find layout systems
261
+ - Component class scan: \`rg --color=never "class.*=.*\\"[^\"]*\\b(btn|button|card|input|modal|dialog|dropdown)" --type html --type js --type ts ${source_path}\` to identify UI components
262
+ - Universal component heuristic: Components appearing in 3+ files = universal, <3 files = specialized
263
+ - Pattern: rg → Count occurrences → Classify by frequency → Prioritize universal components
264
+ - Alternative (if large codebase): Execute CLI analysis for comprehensive categorization:
265
+ \`\`\`bash
266
+ ccw cli -p \"
267
+ PURPOSE: Classify components as universal vs specialized
268
+ TASK: • Identify UI components • Classify reusability • Map layout systems
269
+ MODE: analysis
270
+ CONTEXT: @**/*.css @**/*.scss @**/*.js @**/*.ts @**/*.html
271
+ EXPECTED: JSON report categorizing components, layout patterns, naming conventions
272
+ RULES: Focus on component reusability | Identify layout systems | analysis=READ-ONLY
273
+ \" --tool gemini --mode analysis --cd ${source_path}
274
+ \`\`\`
275
+
276
+ **Step 1: Load file list**
277
+ - Read(${temp_dir}/.intermediates/import-analysis/discovered-files.json)
278
+ - Extract: file_types.css.files, file_types.js.files, file_types.html.files
279
+
280
+ **Step 2: Cross-source layout extraction**
281
+ - CSS/SCSS: Grid systems, flexbox utilities, layout classes, media queries
282
+ - JavaScript/TypeScript: Layout components (React/Vue), grid configs
283
+ - HTML: Semantic structure, component hierarchies
284
+
285
+ **Component Classification** (MUST annotate in extraction):
286
+ - **Universal Components**: Reusable multi-component templates (buttons, inputs, cards, modals, etc.)
287
+ - **Specialized Components**: Module-specific components from code (feature-specific layouts, custom widgets, domain components)
288
+
289
+ **Step 3: System identification**
290
+ - Detect naming convention (BEM | SMACSS | utility-first | css-modules)
291
+ - Identify layout system (12-column | flexbox | css-grid | custom)
292
+ - Extract responsive strategy and breakpoints
293
+
294
+ ## Output Files
295
+
296
+ **Target Directory**: ${temp_dir}/layout-extraction/
297
+
298
+ **Files to Generate**:
299
+
300
+ 1. **layout-templates.json**
301
+ - Follow [LAYOUT_TEMPLATE_GENERATION_TASK] standard structure
302
+ - Add \"extraction_metadata\" section:
303
+ * extraction_source: \"code_import\"
304
+ * naming_convention: detected convention
305
+ * layout_system: {type, confidence, source_files}
306
+ * responsive: {breakpoints, mobile_first, source}
307
+ * completeness: {status, missing_items, recommendations}
308
+ * code_snippets: Map of code snippets (same format as Style Agent)
309
+ - For each component in \"layout_templates\":
310
+ * Include \"source\" field (file:line)
311
+ * **Include \"component_type\" field: \"universal\" | \"specialized\"**
312
+ * dom_structure with semantic HTML5
313
+ * css_layout_rules using var() placeholders
314
+ * Add \"description\" field explaining component purpose and classification rationale
315
+ * **Add \"usage_guide\" field for universal components** (see ui-design-agent.md schema):
316
+ - common_sizes: Extract size variants (small/medium/large) from code
317
+ - variant_recommendations: Document when to use each variant (primary/secondary/etc)
318
+ - usage_context: List typical usage scenarios from actual implementation
319
+ - accessibility_tips: Extract ARIA patterns and a11y notes from code
320
+
321
+ **Code Snippet Recording**:
322
+ - Record actual layout/component code in `extraction_metadata.code_snippets`
323
+ - Context types: \"css-grid\" | \"css-flexbox\" | \"css-utility\" | \"html-structure\" | \"react-component\"
324
+ - Record complete blocks: Utility classes (5-15 lines), HTML structures (10-30 lines), React components (20-100 lines)
325
+ - For components: include HTML structure + associated CSS rules + component logic
326
+ - Preserve original formatting and framework-specific syntax
327
+
328
+ ## Code Import Specific Requirements
329
+ - ✅ Read discovered-files.json FIRST to get file paths
330
+ - ✅ Detect and document naming conventions
331
+ - ✅ Identify layout system with confidence level
332
+ - ✅ Extract component variants and states from usage patterns
333
+ - ✅ **Classify each component as \"universal\" or \"specialized\"** based on:
334
+ * Universal: Reusable across multiple features (buttons, inputs, cards, modals)
335
+ * Specialized: Feature-specific or domain-specific (checkout form, dashboard widget)
336
+ - ✅ Record complete code snippets in extraction_metadata.code_snippets (complete components/structures)
337
+ - ✅ **Document classification rationale** in component description
338
+ - ✅ **Generate usage_guide for universal components** (REQUIRED):
339
+ * Analyze code to extract size variants (scan for size-related classes/props)
340
+ * Document variant usage from code comments and implementation patterns
341
+ * List usage contexts from component instances in codebase
342
+ * Extract accessibility patterns from ARIA attributes and a11y comments
343
+ * If insufficient data, populate with minimal valid structure and note in completeness
344
+ - ❌ NO external research or web searches (code-only extraction)
345
+ ")
346
+ ```
347
+
348
+ ### Wait for All Agents
349
+
350
+ ```bash
351
+ # Agents run in parallel and write separate output files
352
+ # Each agent generates its own JSON directly
353
+ Glob ${temp_dir}/style-extraction/style-1/design-tokens.json, ${temp_dir}/animation-extraction/animation-tokens.json, ${temp_dir}/layout-extraction/layout-templates.json MUST exist before Phase 2 complete; BLOCKED if missing
354
+ echo "[Phase 2] Parallel agent analysis complete"
355
+ ```
356
+
357
+ ## Output Files
358
+
359
+ **Directory Structure**:
360
+ ```
361
+ ${temp_dir}/
362
+ ├── style-extraction/
363
+ │ └── style-1/
364
+ │ └── design-tokens.json # Design tokens with code snippets
365
+ ├── animation-extraction/
366
+ │ └── animation-tokens.json # Animation tokens with code snippets
367
+ ├── layout-extraction/
368
+ │ └── layout-templates.json # Layout patterns with code snippets
369
+ └── .intermediates/
370
+ └── import-analysis/
371
+ └── discovered-files.json # All discovered files
372
+ ```
@@ -0,0 +1,258 @@
1
+ # UI Codify: Phase 4 — Knowledge Asset Generation
2
+
3
+ 读取提取的 JSON 文件,构建 knowhow-manifest.json,调用 codify-to-knowhow 固化为知识资产。
4
+
5
+ ## Prerequisites
6
+
7
+ 来自前序 Phase 的变量:
8
+ - `package_dir` — 包目录(包含所有 token 文件)
9
+ - `package_name` — 包名(用作 slug)
10
+ - `temp_dir` — 临时工作区(清理用)
11
+
12
+ ## Step 4.1: Read Extracted Data
13
+
14
+ 读取 package_dir 中的 JSON 文件,提取构建 manifest 所需的数据:
15
+
16
+ ```javascript
17
+ // 1. Read design-tokens.json
18
+ const designTokens = Read("${package_dir}/design-tokens.json");
19
+ const tokenMetadata = designTokens._metadata || {};
20
+ const codePaths_tokens = Object.keys(tokenMetadata.code_snippets || {}).map(k => k.split(':')[0]);
21
+ const conflicts = tokenMetadata.conflicts || [];
22
+
23
+ // 2. Read layout-templates.json
24
+ const layoutTemplates = Read("${package_dir}/layout-templates.json");
25
+ const extractionMeta = layoutTemplates.extraction_metadata || {};
26
+ const codePaths_layout = Object.keys(extractionMeta.code_snippets || {}).map(k => k.split(':')[0]);
27
+
28
+ // Classify components
29
+ const allComponents = layoutTemplates.layout_templates || [];
30
+ const universalComponents = allComponents.filter(c => c.component_type === 'universal');
31
+ const specializedComponents = allComponents.filter(c => c.component_type === 'specialized');
32
+
33
+ // 3. Read animation-tokens.json (optional)
34
+ let animationTokens = null;
35
+ let codePaths_animation = [];
36
+ try {
37
+ animationTokens = Read("${package_dir}/animation-tokens.json");
38
+ const animMeta = animationTokens._metadata || {};
39
+ codePaths_animation = Object.keys(animMeta.code_snippets || {}).map(k => k.split(':')[0]);
40
+ } catch (e) {
41
+ // animation-tokens.json is optional
42
+ }
43
+
44
+ // 4. Deduplicate code paths
45
+ const allCodePaths = [...new Set([...codePaths_tokens, ...codePaths_layout, ...codePaths_animation])];
46
+ ```
47
+
48
+ ---
49
+
50
+ ## Step 4.2: Build Knowhow Manifest
51
+
52
+ 构建 `knowhow-manifest.json`,声明要创建的知识资产和 spec 条目。
53
+
54
+ **Slug**: 使用 `package_name` 作为 slug(已经是 kebab-case)。
55
+
56
+ ### Knowhow 资产声明
57
+
58
+ ```json
59
+ {
60
+ "slug": "${package_name}",
61
+ "domain": "ui-design",
62
+ "roles": ["implement", "review"],
63
+ "packagePath": "${package_dir}",
64
+
65
+ "knowhow": [
66
+ {
67
+ "prefix": "AST",
68
+ "fileSlug": "tokens",
69
+ "title": "${package_name} Design Tokens",
70
+ "type": "asset",
71
+ "assetType": "design-tokens",
72
+ "codePaths": ["<from allCodePaths — token sources>"],
73
+ "tags": ["design-tokens", "colors", "typography", "spacing", "${package_name}"],
74
+ "body": "## Design Token Reference\n\nExtracted from: ${package_dir}/design-tokens.json\n\n### Colors\n<summarize color categories and count>\n\n### Typography\n<summarize font families, scale>\n\n### Spacing\n<summarize spacing scale>\n\n> Full token data: `${package_dir}/design-tokens.json`",
75
+ "entries": [
76
+ {
77
+ "roles": "implement",
78
+ "keywords": "pattern,colors,design-tokens,${package_name}",
79
+ "title": "Color System",
80
+ "body": "<summarize primary, secondary, accent, semantic colors with values>"
81
+ },
82
+ {
83
+ "roles": "implement",
84
+ "keywords": "pattern,typography,design-tokens,${package_name}",
85
+ "title": "Typography Scale",
86
+ "body": "<summarize font families, sizes, weights>"
87
+ },
88
+ {
89
+ "roles": "implement",
90
+ "keywords": "pattern,spacing,design-tokens,${package_name}",
91
+ "title": "Spacing System",
92
+ "body": "<summarize spacing scale values>"
93
+ }
94
+ ]
95
+ },
96
+ {
97
+ "prefix": "AST",
98
+ "fileSlug": "components",
99
+ "title": "${package_name} Component Patterns",
100
+ "type": "asset",
101
+ "assetType": "component-patterns",
102
+ "codePaths": ["<from allCodePaths — layout sources>"],
103
+ "tags": ["components", "layout", "universal", "specialized", "${package_name}"],
104
+ "body": "## Component Pattern Reference\n\nExtracted from: ${package_dir}/layout-templates.json\n\n### Universal Components (${universalComponents.length})\n<list universal component names with descriptions>\n\n### Specialized Components (${specializedComponents.length})\n<list specialized component names with descriptions>\n\n> Full component data: `${package_dir}/layout-templates.json`",
105
+ "entries": [
106
+ {
107
+ "roles": "implement",
108
+ "keywords": "pattern,universal,components,${package_name}",
109
+ "title": "Universal Components",
110
+ "body": "<list each universal component: name, purpose, key variants>"
111
+ },
112
+ {
113
+ "roles": "implement",
114
+ "keywords": "pattern,specialized,components,${package_name}",
115
+ "title": "Specialized Components",
116
+ "body": "<list each specialized component: name, purpose, usage context>"
117
+ }
118
+ ]
119
+ }
120
+ ],
121
+
122
+ "specs": [
123
+ {
124
+ "roles": "implement",
125
+ "keywords": "coding,colors,design-tokens,${package_name}",
126
+ "title": "${package_name} 颜色编码约定",
127
+ "ref": "knowhow/AST-${package_name}-tokens.md",
128
+ "body": "<summarize: 主色使用 var(--color-primary),语义色映射规则,色彩命名约定>"
129
+ },
130
+ {
131
+ "roles": "implement",
132
+ "keywords": "coding,typography,design-tokens,${package_name}",
133
+ "title": "${package_name} 排版编码约定",
134
+ "ref": "knowhow/AST-${package_name}-tokens.md",
135
+ "body": "<summarize: 字体家族使用规则,字号层级,font-weight 约定>"
136
+ },
137
+ {
138
+ "roles": "implement",
139
+ "keywords": "coding,spacing,design-tokens,${package_name}",
140
+ "title": "${package_name} 间距编码约定",
141
+ "ref": "knowhow/AST-${package_name}-tokens.md",
142
+ "body": "<summarize: 间距 token 使用规则,padding/margin 约定>"
143
+ },
144
+ {
145
+ "roles": "plan",
146
+ "keywords": "arch,components,classification,${package_name}",
147
+ "title": "${package_name} 组件分类约束",
148
+ "ref": "knowhow/AST-${package_name}-components.md",
149
+ "body": "<summarize: universal vs specialized 分类标准,复用规则>"
150
+ }
151
+ ]
152
+ }
153
+ ```
154
+
155
+ ### Conditional: DCS Decision Asset (仅当存在冲突时)
156
+
157
+ 当 `conflicts.length > 0` 时,添加以下到 knowhow 数组:
158
+
159
+ ```json
160
+ {
161
+ "prefix": "DCS",
162
+ "fileSlug": "decisions",
163
+ "title": "${package_name} Design Decisions",
164
+ "type": "decision",
165
+ "tags": ["design-decisions", "conflicts", "${package_name}"],
166
+ "body": "## Design Conflict Decisions\n\n<for each conflict: describe token, list variants with sources, document selected value and reasoning>",
167
+ "entries": [
168
+ {
169
+ "roles": "plan",
170
+ "keywords": "decision,conflict,resolution,${package_name}",
171
+ "title": "Token Conflict Resolutions",
172
+ "body": "<summarize each conflict: token name, file sources, chosen value, rationale>"
173
+ }
174
+ ]
175
+ }
176
+ ```
177
+
178
+ 同时添加到 specs 数组:
179
+
180
+ ```json
181
+ {
182
+ "roles": "plan",
183
+ "keywords": "arch,design-decisions,conflicts,${package_name}",
184
+ "title": "${package_name} 设计决策约束",
185
+ "ref": "knowhow/DCS-${package_name}-decisions.md",
186
+ "body": "<summarize: 冲突解决策略,优先级规则>"
187
+ }
188
+ ```
189
+
190
+ ---
191
+
192
+ ## Step 4.3: Write Manifest
193
+
194
+ ```javascript
195
+ Write("${package_dir}/knowhow-manifest.json", JSON.stringify(manifest, null, 2));
196
+ echo " knowhow-manifest.json written to ${package_dir}"
197
+ ```
198
+
199
+ ---
200
+
201
+ ## Step 4.4: Call codify-to-knowhow
202
+
203
+ 通过 Skill tool 调用 codify-to-knowhow:
204
+
205
+ ```javascript
206
+ MANDATORY, NOT SUBSTITUTABLE by manual Read/Grep: Skill("codify-to-knowhow", args="${package_dir}")
207
+ ```
208
+
209
+ 等待 codify-to-knowhow 完成。它将:
210
+ 1. 读取 knowhow-manifest.json
211
+ 2. 创建 knowhow 文件(.workflow/knowhow/AST-*.md, DCS-*.md)
212
+ 3. 创建 spec 条目(.workflow/specs/coding-conventions.md, architecture-constraints.md)
213
+ 4. 验证 ref 链接
214
+
215
+ ---
216
+
217
+ ## Step 4.5: Cleanup Temporary Workspace
218
+
219
+ ```bash
220
+ # 清理临时工作区
221
+ if [ -d "${temp_dir}" ]; then
222
+ rm -rf "${temp_dir}"
223
+ echo " Temp workspace cleaned: ${temp_dir}"
224
+ fi
225
+ ```
226
+
227
+ ---
228
+
229
+ ## Step 4.6: Completion Report
230
+
231
+ ```
232
+ UI Design System Codified!
233
+
234
+ Package: ${package_name}
235
+ Location: ${package_dir}
236
+
237
+ Files:
238
+ design-tokens.json Design tokens (colors, typography, spacing)
239
+ layout-templates.json Component patterns (${universalComponents.length} universal, ${specializedComponents.length} specialized)
240
+ animation-tokens.json ${animationTokens ? 'Animation tokens' : '(not found)'}
241
+ preview.html Interactive showcase
242
+ preview.css Showcase styling
243
+ knowhow-manifest.json Knowledge asset manifest
244
+
245
+ Knowledge Assets:
246
+ AST-${package_name}-tokens.md Design token knowhow
247
+ AST-${package_name}-components.md Component pattern knowhow
248
+ ${conflicts.length > 0 ? 'DCS-' + package_name + '-decisions.md Design decisions' : ''}
249
+
250
+ Specs: ${specCount} entries (coding: colors/typography/spacing, arch: components${conflicts.length > 0 ? '/decisions' : ''})
251
+
252
+ Open preview:
253
+ file://${absolutePath}/preview.html
254
+
255
+ Next steps:
256
+ maestro wiki list --category coding
257
+ maestro spec load --keyword ${package_name}
258
+ ```