pi-maestro-flow 0.2.0 → 0.3.1

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 +18 -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 -5
  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 +8 -8
  28. package/skills/maestro-amend/SKILL.md +4 -4
  29. package/skills/maestro-analyze/SKILL.md +9 -9
  30. package/skills/maestro-blueprint/SKILL.md +7 -7
  31. package/skills/maestro-brainstorm/SKILL.md +10 -10
  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 +10 -10
  35. package/skills/maestro-execute/SKILL.md +8 -8
  36. package/skills/maestro-fork/SKILL.md +7 -7
  37. package/skills/maestro-grill/SKILL.md +12 -12
  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 +8 -8
  42. package/skills/maestro-merge/SKILL.md +6 -6
  43. package/skills/maestro-milestone-audit/SKILL.md +3 -3
  44. package/skills/maestro-milestone-complete/SKILL.md +8 -8
  45. package/skills/maestro-milestone-release/SKILL.md +9 -9
  46. package/skills/maestro-next/SKILL.md +5 -5
  47. package/skills/maestro-overlay/SKILL.md +19 -19
  48. package/skills/maestro-plan/SKILL.md +8 -8
  49. package/skills/maestro-player/SKILL.md +5 -5
  50. package/skills/maestro-quick/SKILL.md +5 -5
  51. package/skills/maestro-ralph/SKILL.md +15 -15
  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 +17 -17
  56. package/skills/maestro-roadmap/SKILL.md +7 -7
  57. package/skills/maestro-swarm-workflow/SKILL.md +9 -9
  58. package/skills/maestro-tools-execute/SKILL.md +5 -5
  59. package/skills/maestro-tools-register/SKILL.md +7 -7
  60. package/skills/maestro-ui-codify/SKILL.md +8 -8
  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 -4
  64. package/skills/manage-drift-realign/SKILL.md +7 -7
  65. package/skills/manage-harvest/SKILL.md +5 -5
  66. package/skills/manage-issue/SKILL.md +4 -4
  67. package/skills/manage-issue-discover/SKILL.md +7 -7
  68. package/skills/manage-kg-extractors/SKILL.md +3 -3
  69. package/skills/manage-knowhow/SKILL.md +3 -3
  70. package/skills/manage-knowhow-capture/SKILL.md +4 -4
  71. package/skills/manage-knowledge-audit/SKILL.md +5 -5
  72. package/skills/manage-status/SKILL.md +3 -3
  73. package/skills/manage-wiki/SKILL.md +5 -5
  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 -3
  81. package/skills/quality-debug/SKILL.md +3 -3
  82. package/skills/quality-refactor/SKILL.md +3 -3
  83. package/skills/quality-retrospective/SKILL.md +9 -9
  84. package/skills/quality-review/SKILL.md +4 -4
  85. package/skills/quality-sync/SKILL.md +3 -3
  86. package/skills/quality-test/SKILL.md +4 -4
  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 -2
  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 -5
  102. package/skills/spec-load/SKILL.md +3 -3
  103. package/skills/spec-remove/SKILL.md +4 -4
  104. package/skills/spec-setup/SKILL.md +6 -6
  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,159 @@
1
+ # UI Codify: Phase 3 — Reference Package Generation
2
+
3
+ ## Prerequisites
4
+
5
+ 来自前序 Phase 的变量:
6
+ - `temp_dir` — 临时工作区,包含提取结果
7
+ - `package_dir` — 目标包目录
8
+ - `package_name` — 包名
9
+
10
+ ## Step 3.1: Copy Token Files
11
+
12
+ ```bash
13
+ echo "[Phase 3] Preparing component data from extraction"
14
+
15
+ # 1. Copy layout templates (required)
16
+ cp "${temp_dir}/layout-extraction/layout-templates.json" "${package_dir}/layout-templates.json"
17
+
18
+ if [ ! -f "${package_dir}/layout-templates.json" ]; then
19
+ echo "ERROR: Failed to copy layout templates"
20
+ exit 1
21
+ fi
22
+
23
+ component_count=$(jq -r '.layout_templates | length // 0' "${package_dir}/layout-templates.json" 2>/dev/null || echo 0)
24
+ echo " Layout templates copied (${component_count} components)"
25
+
26
+ # 2. Copy design tokens (required)
27
+ cp "${temp_dir}/style-extraction/style-1/design-tokens.json" "${package_dir}/design-tokens.json"
28
+
29
+ if [ ! -f "${package_dir}/design-tokens.json" ]; then
30
+ echo "ERROR: Failed to copy design tokens"
31
+ exit 1
32
+ fi
33
+ echo " Design tokens copied"
34
+
35
+ # 3. Copy animation tokens (optional)
36
+ if [ -f "${temp_dir}/animation-extraction/animation-tokens.json" ]; then
37
+ cp "${temp_dir}/animation-extraction/animation-tokens.json" "${package_dir}/animation-tokens.json"
38
+ echo " Animation tokens copied"
39
+ else
40
+ echo " W001: Animation tokens not found (optional, continuing)"
41
+ fi
42
+
43
+ echo "[Phase 3] Token files prepared"
44
+ ```
45
+
46
+ ---
47
+
48
+ ## Step 3.2: Preview Generation (Agent)
49
+
50
+ **Agent Task**:
51
+
52
+ ```javascript
53
+ MANDATORY, NOT SUBSTITUTABLE by manual Read/Grep: Agent(ui-design-agent): `
54
+ [PREVIEW_SHOWCASE_GENERATION]
55
+ Generate interactive multi-component showcase panel for reference package
56
+
57
+ PACKAGE_DIR: ${package_dir} | PACKAGE_NAME: ${package_name}
58
+
59
+ ## Input Files (MUST READ ALL)
60
+
61
+ 1. ${package_dir}/layout-templates.json (component layout patterns - REQUIRED)
62
+ 2. ${package_dir}/design-tokens.json (design tokens - REQUIRED)
63
+ 3. ${package_dir}/animation-tokens.json (optional, if exists)
64
+
65
+ ## Generation Agent
66
+
67
+ Create interactive showcase with these sections:
68
+
69
+ ### Section 1: Colors
70
+ - Display all color categories as color swatches
71
+ - Show hex/rgb values
72
+ - Group by: brand, semantic, surface, text, border
73
+
74
+ ### Section 2: Typography
75
+ - Display typography scale (font sizes, weights)
76
+ - Show typography combinations if available
77
+ - Include font family examples
78
+ - **Display usage recommendations** (from design-tokens.json _metadata.usage_recommendations.typography):
79
+ * Common sizes table (small_text, body_text, heading)
80
+ * Common combinations with use cases
81
+
82
+ ### Section 3: Components
83
+ - Render all components from layout-templates.json (use layout_templates field)
84
+ - **Universal Components**: Display reusable multi-component showcases (buttons, inputs, cards, etc.)
85
+ * **Display usage_guide** (from layout-templates.json):
86
+ - Common sizes table with dimensions and use cases
87
+ - Variant recommendations (when to use primary/secondary/etc)
88
+ - Usage context list (typical scenarios)
89
+ - Accessibility tips checklist
90
+ - **Specialized Components**: Display module-specific components from code (feature-specific layouts, custom widgets)
91
+ - Display all variants side-by-side
92
+ - Show DOM structure with proper styling
93
+ - Include usage code snippets in <details> tags
94
+ - Clearly label component types (universal vs specialized)
95
+
96
+ ### Section 4: Spacing & Layout
97
+ - Visual spacing scale
98
+ - Border radius examples
99
+ - Shadow depth examples
100
+ - **Display spacing recommendations** (from design-tokens.json _metadata.usage_recommendations.spacing):
101
+ * Size guide table (tight/normal/loose categories)
102
+ * Common patterns with use cases and pixel values
103
+
104
+ ### Section 5: Animations (if available)
105
+ - Animation duration examples
106
+ - Easing function demonstrations
107
+
108
+ ## Output Requirements
109
+
110
+ Generate 2 files:
111
+ 1. ${package_dir}/preview.html
112
+ 2. ${package_dir}/preview.css
113
+
114
+ ### preview.html Structure:
115
+ - Complete standalone HTML file
116
+ - Responsive design with mobile-first approach
117
+ - Sticky navigation for sections
118
+ - Interactive component demonstrations
119
+ - Code snippets in collapsible <details> elements
120
+ - Footer with package metadata
121
+
122
+ ### preview.css Structure:
123
+ - CSS Custom Properties from design-tokens.json
124
+ - Typography combination classes
125
+ - Component classes from layout-templates.json
126
+ - Preview page layout styles
127
+ - Interactive demo styles
128
+
129
+ ## Critical Requirements
130
+ - ✅ Read ALL input files (layout-templates.json, design-tokens.json, animation-tokens.json if exists)
131
+ - ✅ Generate complete, interactive showcase HTML
132
+ - ✅ All CSS uses var() references to design tokens
133
+ - ✅ Display ALL components from layout-templates.json
134
+ - ✅ **Separate universal components from specialized components** in the showcase
135
+ - ✅ Display component DOM structures with proper styling
136
+ - ✅ Include usage code snippets
137
+ - ✅ Label each component type clearly (Universal / Specialized)
138
+ - ✅ **Display usage recommendations** when available:
139
+ - Typography: common_sizes, common_combinations (from _metadata.usage_recommendations)
140
+ - Components: usage_guide for universal components (from layout-templates)
141
+ - Spacing: size_guide, common_patterns (from _metadata.usage_recommendations)
142
+ - ✅ Gracefully handle missing usage data (display sections only if data exists)
143
+ - ✅ Use Write() to save both files:
144
+ - ${package_dir}/preview.html
145
+ - ${package_dir}/preview.css
146
+ - ❌ NO external research or MCP calls
147
+ `
148
+ ```
149
+
150
+ ## Output Structure
151
+
152
+ ```
153
+ ${package_dir}/
154
+ ├── layout-templates.json # Layout templates (copied from extraction)
155
+ ├── design-tokens.json # Design tokens (copied from extraction)
156
+ ├── animation-tokens.json # Animation tokens (optional)
157
+ ├── preview.html # Interactive showcase (NEW)
158
+ └── preview.css # Showcase styling (NEW)
159
+ ```
@@ -0,0 +1,227 @@
1
+ # UI Codify: Main Workflow
2
+
3
+ 从源代码提取设计系统,生成参考包,固化为知识资产。
4
+
5
+ ## Architecture
6
+
7
+ ```
8
+ Phase 1 (inline) Phase 2 (deferred) Phase 3 (deferred) Phase 4 (deferred)
9
+ Validate & 3 Parallel Agents Reference Package Knowhow Assets
10
+ Setup ┌─ Style Agent Copy tokens + Manifest +
11
+ ├─ Parse args ├─ Animation Agent Generate preview codify-to-knowhow
12
+ ├─ Validate source └─ Layout Agent (preview.html/css) + cleanup
13
+ ├─ Package name ↓ ↓ ↓
14
+ └─ Workspace design-tokens.json preview.html knowhow-manifest.json
15
+ animation-tokens.json preview.css → knowhow files
16
+ layout-templates.json → spec entries
17
+ ```
18
+
19
+ ## Data Flow
20
+
21
+ ```
22
+ Input: source_path, package_name, output_dir, overwrite
23
+
24
+ Phase 1 → source_path, package_name, output_dir, temp_dir, package_dir
25
+
26
+ Phase 2 → design-tokens.json, animation-tokens.json, layout-templates.json
27
+ ↓ (written to temp_dir)
28
+ Phase 3 → preview.html, preview.css, token files copied to package_dir
29
+
30
+ Phase 4 → knowhow-manifest.json → codify-to-knowhow → knowhow + specs
31
+
32
+ Completion report
33
+ ```
34
+
35
+ ## TodoWrite Pattern
36
+
37
+ ```json
38
+ [
39
+ {"content": "Phase 1: 参数验证与工作区准备", "status": "in_progress"},
40
+ {"content": "Phase 2: 并行 Agent 提取 (Style + Animation + Layout)", "status": "pending"},
41
+ {"content": "Phase 3: 参考包生成 (preview.html + preview.css)", "status": "pending"},
42
+ {"content": "Phase 4: 知识资产固化 (manifest + codify-to-knowhow)", "status": "pending"}
43
+ ]
44
+ ```
45
+
46
+ ---
47
+
48
+ ## Phase 1: Parameter Validation & Workspace Setup (Inline)
49
+
50
+ ### Step 1.1: Parse Arguments
51
+
52
+ 从 `$ARGUMENTS` 中解析:
53
+
54
+ - `source_path` (positional, required) — 源代码目录
55
+ - `--package-name <name>` — 包名(可选,默认从源目录自动生成)
56
+ - `--output-dir <path>` — 输出目录(默认 `.workflow/reference_style`)
57
+ - `--overwrite` — 允许覆盖已存在的包目录
58
+
59
+ ```bash
60
+ # 验证 source_path 存在
61
+ if [ -z "$source_path" ]; then
62
+ echo "E001: Source path argument required"
63
+ echo "USAGE: /maestro-ui-codify <source-path> [--package-name <name>] [--output-dir <path>] [--overwrite]"
64
+ exit 1
65
+ fi
66
+
67
+ if [ ! -d "$source_path" ]; then
68
+ echo "E002: Source path not found or not a directory: $source_path"
69
+ exit 1
70
+ fi
71
+
72
+ source_path=$(cd "$source_path" && pwd)
73
+ echo "Source: $source_path"
74
+ ```
75
+
76
+ ### Step 1.2: Resolve Package Name
77
+
78
+ ```bash
79
+ # 自动生成包名: 目录名转 kebab-case,附加日期
80
+ if [ -z "$package_name" ]; then
81
+ dir_name=$(basename "$source_path")
82
+ package_name=$(echo "$dir_name" | tr '[:upper:]' '[:lower:]' | tr ' _' '-' | sed 's/[^a-z0-9-]//g')
83
+ package_name="${package_name}-style"
84
+ fi
85
+
86
+ # 验证包名格式
87
+ if ! [[ "$package_name" =~ ^[a-z0-9][a-z0-9-]*$ ]]; then
88
+ echo "ERROR: Invalid package name '$package_name'. Use lowercase, alphanumeric, hyphens only."
89
+ exit 1
90
+ fi
91
+
92
+ echo "Package name: $package_name"
93
+ ```
94
+
95
+ ### Step 1.3: Setup Directories
96
+
97
+ ```bash
98
+ output_dir="${output_dir:-.workflow/reference_style}"
99
+ package_dir="${output_dir}/${package_name}"
100
+
101
+ # 覆盖保护
102
+ if [ -d "$package_dir" ] && [ "$(ls -A "$package_dir" 2>/dev/null)" ]; then
103
+ if [ "$overwrite" != "true" ]; then
104
+ echo "E003: Package directory exists: $package_dir"
105
+ echo "HINT: Use --overwrite to replace, or choose a different --package-name"
106
+ exit 1
107
+ fi
108
+ echo "INFO: Overwriting existing package '$package_name'"
109
+ fi
110
+
111
+ # 创建临时工作区
112
+ timestamp=$(date +%Y%m%d%H%M%S)
113
+ temp_dir=".workflow/codify-temp-${timestamp}"
114
+ mkdir -p "$temp_dir/style-extraction/style-1"
115
+ mkdir -p "$temp_dir/animation-extraction"
116
+ mkdir -p "$temp_dir/layout-extraction"
117
+ mkdir -p "$temp_dir/.intermediates/import-analysis"
118
+ mkdir -p "$package_dir"
119
+
120
+ echo "[Phase 1] Setup complete"
121
+ echo " Source: $source_path"
122
+ echo " Package: $package_name"
123
+ echo " Temp workspace: $temp_dir"
124
+ echo " Output: $package_dir"
125
+ ```
126
+
127
+ **TodoWrite**: Mark Phase 1 completed, Phase 2 in_progress.
128
+
129
+ ---
130
+
131
+ ## Phase 2: Parallel Agent Extraction (Deferred)
132
+
133
+ MANDATORY: execute ui-codify-extract.md steps; REQUIRED produce: design-tokens.json, animation-tokens.json, layout-templates.json; BLOCKED if missing.
134
+
135
+ Variables available to Phase 2:
136
+ - `source_path` — absolute path to source directory
137
+ - `temp_dir` — temporary workspace path (e.g. `.workflow/codify-temp-20260510143022`)
138
+
139
+ Phase 2 writes:
140
+ - `${temp_dir}/style-extraction/style-1/design-tokens.json`
141
+ - `${temp_dir}/animation-extraction/animation-tokens.json`
142
+ - `${temp_dir}/layout-extraction/layout-templates.json`
143
+
144
+ **TodoWrite**: Mark Phase 2 completed, Phase 3 in_progress.
145
+
146
+ ---
147
+
148
+ ## Phase 3: Reference Package Generation (Deferred)
149
+
150
+ MANDATORY: execute ui-codify-package.md steps; REQUIRED produce: preview.html, preview.css, token files copied to package_dir; BLOCKED if missing.
151
+
152
+ Variables available to Phase 3:
153
+ - `temp_dir` — temporary workspace with extraction results
154
+ - `package_dir` — target package directory
155
+ - `package_name` — package name
156
+
157
+ Phase 3 writes:
158
+ - `${package_dir}/design-tokens.json`
159
+ - `${package_dir}/layout-templates.json`
160
+ - `${package_dir}/animation-tokens.json` (if available)
161
+ - `${package_dir}/preview.html`
162
+ - `${package_dir}/preview.css`
163
+
164
+ **TodoWrite**: Mark Phase 3 completed, Phase 4 in_progress.
165
+
166
+ ---
167
+
168
+ ## Phase 4: Knowledge Asset Generation (Deferred)
169
+
170
+ MANDATORY: execute ui-codify-knowhow.md steps; REQUIRED produce: knowhow-manifest.json, knowhow files, spec entries; BLOCKED if missing.
171
+
172
+ Variables available to Phase 4:
173
+ - `package_dir` — package directory with all token files
174
+ - `package_name` — package name (used as slug)
175
+ - `temp_dir` — temporary workspace (to clean up)
176
+
177
+ Phase 4 writes:
178
+ - `${package_dir}/knowhow-manifest.json`
179
+ - Then calls `/codify-to-knowhow ${package_dir}` via Skill tool
180
+
181
+ **TodoWrite**: Mark Phase 4 completed (all tasks done).
182
+
183
+ ---
184
+
185
+ ## Error Handling
186
+
187
+ | Phase | Error | Recovery |
188
+ |-------|-------|----------|
189
+ | 1 | E001: Missing source path | Report usage, exit |
190
+ | 1 | E002: Source not found | Report path, exit |
191
+ | 1 | E003: Package exists | Suggest --overwrite, exit |
192
+ | 2 | Agent failure | Report which agent failed, continue with partial results; flag partial results as [LOW CONFIDENCE] (agent failure) |
193
+ | 2 | No files discovered | Report empty discovery, exit |
194
+ | 3 | Token copy failed | Report missing file, exit |
195
+ | 3 | Preview generation failed | Report error, continue (preview is non-critical); flag preview.html/css as [LOW CONFIDENCE] (preview generation failed) |
196
+ | 4 | Manifest build failed | Report error, package still usable without knowhow; flag knowhow assets as [LOW CONFIDENCE] (manifest build failed) |
197
+ | 4 | codify-to-knowhow failed | Report error, manifest remains for manual retry; flag knowhow/spec entries as [LOW CONFIDENCE] (codify-to-knowhow failed) |
198
+
199
+ ## Completion Message
200
+
201
+ Glob all listed output files MUST exist before completion message; BLOCKED if missing.
202
+
203
+ ```
204
+ UI Design System Codified!
205
+
206
+ Package: {package_name}
207
+ Location: {package_dir}
208
+
209
+ Files:
210
+ design-tokens.json Design tokens (colors, typography, spacing)
211
+ layout-templates.json Component patterns ({universal_count} universal, {specialized_count} specialized)
212
+ animation-tokens.json Animation tokens {if exists else "(not found)"}
213
+ preview.html Interactive showcase
214
+ preview.css Showcase styling
215
+ knowhow-manifest.json Knowledge asset manifest
216
+
217
+ Knowledge Assets:
218
+ Knowhow: AST-{package_name}-tokens, AST-{package_name}-components{, DCS-{package_name}-decisions}
219
+ Specs: {spec_count} entries (coding + arch)
220
+
221
+ Open preview:
222
+ file://{absolute_path}/preview.html
223
+
224
+ Next steps:
225
+ maestro wiki list --category coding # Browse by category
226
+ maestro spec load --keyword {package_name} # Load related specs
227
+ ```