pi-maestro-flow 0.2.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 (179) hide show
  1. package/README.md +124 -0
  2. package/agents/aggregator.md +27 -0
  3. package/agents/cli-explore-agent.md +188 -0
  4. package/agents/cross-role-reviewer.md +171 -0
  5. package/agents/delegate.md +19 -0
  6. package/agents/explorer.md +23 -0
  7. package/agents/impeccable-agent.md +99 -0
  8. package/agents/ralph-executor.md +81 -0
  9. package/agents/reference.md +24 -0
  10. package/agents/role-design-author.md +220 -0
  11. package/agents/team-supervisor.md +143 -0
  12. package/agents/team-worker.md +237 -0
  13. package/agents/ui-design-agent.md +270 -0
  14. package/agents/workflow-analyzer.md +116 -0
  15. package/agents/workflow-codebase-mapper.md +77 -0
  16. package/agents/workflow-collab-planner.md +147 -0
  17. package/agents/workflow-debugger.md +104 -0
  18. package/agents/workflow-executor.md +133 -0
  19. package/agents/workflow-external-researcher.md +86 -0
  20. package/agents/workflow-integration-checker.md +83 -0
  21. package/agents/workflow-nyquist-auditor.md +85 -0
  22. package/agents/workflow-phase-researcher.md +85 -0
  23. package/agents/workflow-plan-checker.md +100 -0
  24. package/agents/workflow-planner.md +200 -0
  25. package/agents/workflow-project-researcher.md +74 -0
  26. package/agents/workflow-research-synthesizer.md +70 -0
  27. package/agents/workflow-reviewer.md +82 -0
  28. package/agents/workflow-roadmapper.md +81 -0
  29. package/agents/workflow-verifier.md +120 -0
  30. package/package.json +58 -0
  31. package/skills/codify-to-knowhow/SKILL.md +167 -0
  32. package/skills/delegation-check/SKILL.md +297 -0
  33. package/skills/domain-add/SKILL.md +75 -0
  34. package/skills/insight-challenge/SKILL.md +226 -0
  35. package/skills/learn-decompose/SKILL.md +124 -0
  36. package/skills/learn-follow/SKILL.md +163 -0
  37. package/skills/learn-investigate/SKILL.md +160 -0
  38. package/skills/learn-second-opinion/SKILL.md +128 -0
  39. package/skills/maestro/SKILL.md +239 -0
  40. package/skills/maestro-amend/SKILL.md +169 -0
  41. package/skills/maestro-analyze/SKILL.md +173 -0
  42. package/skills/maestro-blueprint/SKILL.md +159 -0
  43. package/skills/maestro-brainstorm/SKILL.md +193 -0
  44. package/skills/maestro-collab/SKILL.md +181 -0
  45. package/skills/maestro-companion/SKILL.md +536 -0
  46. package/skills/maestro-composer/SKILL.md +192 -0
  47. package/skills/maestro-execute/SKILL.md +193 -0
  48. package/skills/maestro-fork/SKILL.md +104 -0
  49. package/skills/maestro-grill/SKILL.md +151 -0
  50. package/skills/maestro-guard/SKILL.md +124 -0
  51. package/skills/maestro-help/SKILL.md +328 -0
  52. package/skills/maestro-impeccable/SKILL.md +302 -0
  53. package/skills/maestro-init/SKILL.md +151 -0
  54. package/skills/maestro-merge/SKILL.md +90 -0
  55. package/skills/maestro-milestone-audit/SKILL.md +117 -0
  56. package/skills/maestro-milestone-complete/SKILL.md +133 -0
  57. package/skills/maestro-milestone-release/SKILL.md +131 -0
  58. package/skills/maestro-next/SKILL.md +269 -0
  59. package/skills/maestro-overlay/SKILL.md +203 -0
  60. package/skills/maestro-plan/SKILL.md +194 -0
  61. package/skills/maestro-player/SKILL.md +184 -0
  62. package/skills/maestro-quick/SKILL.md +117 -0
  63. package/skills/maestro-ralph/SKILL.md +905 -0
  64. package/skills/maestro-ralph-cli/SKILL.md +976 -0
  65. package/skills/maestro-ralph-cli-execute/SKILL.md +229 -0
  66. package/skills/maestro-ralph-execute/SKILL.md +409 -0
  67. package/skills/maestro-ralph-v2/SKILL.md +1198 -0
  68. package/skills/maestro-roadmap/SKILL.md +157 -0
  69. package/skills/maestro-swarm-workflow/SKILL.md +272 -0
  70. package/skills/maestro-tools-execute/SKILL.md +143 -0
  71. package/skills/maestro-tools-register/SKILL.md +192 -0
  72. package/skills/maestro-ui-codify/SKILL.md +127 -0
  73. package/skills/maestro-universal-workflow/SKILL.md +622 -0
  74. package/skills/maestro-update/SKILL.md +156 -0
  75. package/skills/manage-codebase-rebuild/SKILL.md +111 -0
  76. package/skills/manage-drift-realign/SKILL.md +159 -0
  77. package/skills/manage-harvest/SKILL.md +121 -0
  78. package/skills/manage-issue/SKILL.md +88 -0
  79. package/skills/manage-issue-discover/SKILL.md +104 -0
  80. package/skills/manage-kg-extractors/SKILL.md +147 -0
  81. package/skills/manage-knowhow/SKILL.md +102 -0
  82. package/skills/manage-knowhow-capture/SKILL.md +109 -0
  83. package/skills/manage-knowledge-audit/SKILL.md +147 -0
  84. package/skills/manage-status/SKILL.md +80 -0
  85. package/skills/manage-wiki/SKILL.md +104 -0
  86. package/skills/odyssey-debug/SKILL.md +344 -0
  87. package/skills/odyssey-improve/SKILL.md +423 -0
  88. package/skills/odyssey-planex/SKILL.md +542 -0
  89. package/skills/odyssey-review-test-fix/SKILL.md +392 -0
  90. package/skills/odyssey-ui/SKILL.md +388 -0
  91. package/skills/prompt-generator/SKILL.md +470 -0
  92. package/skills/quality-auto-test/SKILL.md +168 -0
  93. package/skills/quality-debug/SKILL.md +176 -0
  94. package/skills/quality-refactor/SKILL.md +108 -0
  95. package/skills/quality-retrospective/SKILL.md +134 -0
  96. package/skills/quality-review/SKILL.md +169 -0
  97. package/skills/quality-sync/SKILL.md +90 -0
  98. package/skills/quality-test/SKILL.md +183 -0
  99. package/skills/scholar-anti-ai-writing/SKILL.md +173 -0
  100. package/skills/scholar-anti-ai-writing/references/patterns-chinese.md +242 -0
  101. package/skills/scholar-anti-ai-writing/references/patterns-english.md +242 -0
  102. package/skills/scholar-citation-verify/SKILL.md +166 -0
  103. package/skills/scholar-citation-verify/references/api-usage.md +372 -0
  104. package/skills/scholar-citation-verify/references/common-errors.md +384 -0
  105. package/skills/scholar-citation-verify/references/verification-rules.md +399 -0
  106. package/skills/scholar-experiment/SKILL.md +321 -0
  107. package/skills/scholar-ideation/SKILL.md +288 -0
  108. package/skills/scholar-latex-organizer/SKILL.md +186 -0
  109. package/skills/scholar-publish/SKILL.md +220 -0
  110. package/skills/scholar-rebuttal-pro/README.md +313 -0
  111. package/skills/scholar-rebuttal-pro/SKILL.md +511 -0
  112. package/skills/scholar-review/SKILL.md +227 -0
  113. package/skills/scholar-thesis-docx/README.md +111 -0
  114. package/skills/scholar-thesis-docx/README_EN.md +108 -0
  115. package/skills/scholar-thesis-docx/SKILL.md +212 -0
  116. package/skills/scholar-thesis-docx/references/failure-patterns-and-quality-gates.md +178 -0
  117. package/skills/scholar-thesis-docx/references/figure-and-code-rules.md +33 -0
  118. package/skills/scholar-thesis-docx/references/paper-format-workflow.md +68 -0
  119. package/skills/scholar-thesis-docx/references/script-usage.md +157 -0
  120. package/skills/scholar-thesis-docx/scripts/audit_docx_ooxml.py +429 -0
  121. package/skills/scholar-thesis-docx/scripts/check_word_com.ps1 +50 -0
  122. package/skills/scholar-thesis-docx/scripts/export_word_pdf.ps1 +62 -0
  123. package/skills/scholar-thesis-docx/scripts/normalize_word_styles.ps1 +498 -0
  124. package/skills/scholar-thesis-docx/scripts/render_mermaid_figure.ps1 +148 -0
  125. package/skills/scholar-writing/SKILL.md +296 -0
  126. package/skills/security-audit/SKILL.md +244 -0
  127. package/skills/skill-generator/SKILL.md +472 -0
  128. package/skills/skill-iter-tune/SKILL.md +382 -0
  129. package/skills/skill-simplify/SKILL.md +63 -0
  130. package/skills/skill-tuning/SKILL.md +174 -0
  131. package/skills/spec-add/SKILL.md +105 -0
  132. package/skills/spec-load/SKILL.md +98 -0
  133. package/skills/spec-remove/SKILL.md +74 -0
  134. package/skills/spec-setup/SKILL.md +75 -0
  135. package/skills/team-adversarial-swarm/SKILL.md +233 -0
  136. package/skills/team-adversarial-swarm/scripts/__pycache__/pheromone.cpython-313.pyc +0 -0
  137. package/skills/team-adversarial-swarm/scripts/__pycache__/scoring.cpython-313.pyc +0 -0
  138. package/skills/team-adversarial-swarm/scripts/aco.py +473 -0
  139. package/skills/team-adversarial-swarm/scripts/pheromone.py +144 -0
  140. package/skills/team-adversarial-swarm/scripts/scoring.py +92 -0
  141. package/skills/team-adversarial-swarm/scripts/test_aco.py +475 -0
  142. package/skills/team-arch-opt/SKILL.md +158 -0
  143. package/skills/team-brainstorm/SKILL.md +171 -0
  144. package/skills/team-coordinate/SKILL.md +266 -0
  145. package/skills/team-designer/SKILL.md +160 -0
  146. package/skills/team-executor/SKILL.md +189 -0
  147. package/skills/team-frontend/SKILL.md +136 -0
  148. package/skills/team-frontend-debug/SKILL.md +198 -0
  149. package/skills/team-interactive-craft/SKILL.md +141 -0
  150. package/skills/team-issue/SKILL.md +171 -0
  151. package/skills/team-lifecycle-v4/SKILL.md +209 -0
  152. package/skills/team-motion-design/SKILL.md +142 -0
  153. package/skills/team-perf-opt/SKILL.md +175 -0
  154. package/skills/team-planex/SKILL.md +137 -0
  155. package/skills/team-quality-assurance/SKILL.md +147 -0
  156. package/skills/team-review/SKILL.md +147 -0
  157. package/skills/team-roadmap-dev/SKILL.md +169 -0
  158. package/skills/team-swarm/SKILL.md +178 -0
  159. package/skills/team-swarm/scripts/aco.py +473 -0
  160. package/skills/team-swarm/scripts/pheromone.py +144 -0
  161. package/skills/team-swarm/scripts/scoring.py +92 -0
  162. package/skills/team-swarm/scripts/test_aco.py +475 -0
  163. package/skills/team-tech-debt/SKILL.md +128 -0
  164. package/skills/team-testing/SKILL.md +143 -0
  165. package/skills/team-ui-polish/SKILL.md +141 -0
  166. package/skills/team-uidesign/SKILL.md +144 -0
  167. package/skills/team-ultra-analyze/SKILL.md +173 -0
  168. package/skills/team-ux-improve/SKILL.md +151 -0
  169. package/skills/team-visual-a11y/SKILL.md +156 -0
  170. package/skills/workflow-skill-designer/SKILL.md +496 -0
  171. package/src/extension/index.ts +222 -0
  172. package/src/extension/schemas.ts +131 -0
  173. package/src/providers/cli-tools-loader.ts +74 -0
  174. package/src/providers/provider-registry.ts +130 -0
  175. package/src/tools/delegate.ts +85 -0
  176. package/src/tools/explore.ts +134 -0
  177. package/src/tools/moa.ts +213 -0
  178. package/src/tools/status.ts +99 -0
  179. package/src/tools/wait.ts +166 -0
@@ -0,0 +1,192 @@
1
+ ---
2
+ name: maestro-tools-register
3
+ description: "Register tool specs - extract, generate, or optimize Arguments: [<description>] [--extract <path>] [--optimize <name>]"
4
+ allowed-tools: Read Write Edit Bash Glob Grep AskUserQuestion Agent
5
+ ---
6
+
7
+ <purpose>
8
+ Codify reusable business processes as knowhow documents with `tool: true` in `.workflow/knowhow/`.
9
+ Four modes: Extract, Generate, Optimize, Promote. Short processes inline; long use ref mode.
10
+ </purpose>
11
+
12
+ <required_reading>
13
+ @~/.maestro/workflows/tools-spec.md
14
+ </required_reading>
15
+
16
+ <context>
17
+ $ARGUMENTS — Intent description
18
+
19
+ **Examples**:
20
+ ```
21
+ /maestro-tools-register extract OAuth PKCE token exchange flow from src/auth/
22
+ /maestro-tools-register generate Stripe webhook idempotency verification
23
+ /maestro-tools-register generate E2E checkout flow with payment gateway mock setup
24
+ /maestro-tools-register optimize e2e-checkout tool
25
+ /maestro-tools-register promote RCP-db-migration-rollback as test tool
26
+ /maestro-tools-register promote knowhow-auth-api to coding tool
27
+ ```
28
+ </context>
29
+
30
+ <invariants>
31
+ 1. **Schema validation** — tool knowhow document MUST include `tool: true`, `category`, `keywords`, and `summary` in YAML frontmatter; missing fields → reject write
32
+ 2. **No duplicate names** — tool title MUST be unique within its category; duplicate detection → E002 warning with overwrite/optimize confirmation
33
+ 3. **Category required** — every tool MUST declare exactly one category from: coding, test, review, arch, debug; empty category → E003
34
+ 4. **Confirmation gate** — MUST AskUserQuestion before writing knowhow document and spec ref entry; NEVER persist without user confirmation
35
+ 5. **Promote is in-place** — promote mode MUST update existing knowhow frontmatter via `maestro wiki update`; NEVER recreate the document
36
+ 6. **Output boundary** — ALL file writes MUST target .workflow/knowhow/ (tool documents) and .workflow/specs/ (ref entries via maestro spec add) only. NEVER modify source code or files outside these paths
37
+ 7. **Description format** — first line after `### Title` MUST state "Use when ..." (usage timing); this is critical for ref entry summary visibility in spec-load
38
+ </invariants>
39
+
40
+ <execution>
41
+
42
+ ### Phase Gates (MANDATORY, BLOCKING)
43
+
44
+ **GATE 1: Parse → Gather**
45
+ - REQUIRED: Mode determined (extract/generate/optimize/promote) from argument parsing.
46
+ - REQUIRED: For optimize/promote modes, target tool/document exists and is loadable.
47
+ - BLOCKED if: empty args without user response to AskUserQuestion.
48
+
49
+ **GATE 2: Gather → Write**
50
+ - REQUIRED: Tool name, category, and usage timing confirmed.
51
+ - REQUIRED: Steps extracted or generated (extract: ≥1 step, generate: user-confirmed scope).
52
+ - REQUIRED: Inline vs ref mode decided based on step count.
53
+ - REQUIRED: User confirmed via AskUserQuestion (title, category, keywords, summary, step count).
54
+ - BLOCKED if: E001 (.workflow/specs/ not initialized), E003 (no category), user cancels.
55
+
56
+ **GATE 3: Write → Verify**
57
+ - REQUIRED: Knowhow document written with `tool: true` frontmatter (or updated in-place for promote).
58
+ - REQUIRED: Spec ref entry registered (if user confirmed).
59
+ - BLOCKED if: write failed or spec add returned error.
60
+
61
+ ### Step 1: Intent Detection
62
+
63
+ Parse $ARGUMENTS to determine mode:
64
+ - Contains "extract" → extract mode
65
+ - Contains "optimize/improve" → optimize mode
66
+ - Contains "promote" or references existing knowhow doc (path/ID) → promote mode
67
+ - Other → generate mode
68
+ - Empty → ask user with AskUserQuestion
69
+
70
+ ### Step 2: Gather Information
71
+
72
+ **Extract mode**:
73
+ - Identify source (current conversation, specified files, codebase scan)
74
+ - Extract step sequence, prerequisites, expected outputs
75
+
76
+ **Generate mode**:
77
+ - Confirm tool name, applicable roles, target scenario
78
+ - If unclear, ask user with AskUserQuestion
79
+
80
+ **Optimize mode**:
81
+ - Load existing tool: `maestro search "<name>" --type knowhow` → `maestro load --type knowhow --id <id>`
82
+ - Analyze improvement points (step splitting, prerequisites, error handling)
83
+
84
+ **Promote mode** (existing knowhow → tool):
85
+ - Locate document: `maestro search "<name>" --type knowhow` or by path in `.workflow/knowhow/`
86
+ - Read document, verify it contains actionable steps (numbered list or ## Steps section)
87
+ - If no actionable steps, suggest extract mode instead
88
+ - Determine category (Step 3) and summary ("Use when ...")
89
+ - Update frontmatter via: `maestro wiki update <id> --frontmatter '{"tool": true, "category": "<cat>", "summary": "<summary>"}'`
90
+ - Do NOT recreate the document — modify in place
91
+
92
+ ### Step 3: Determine Category
93
+
94
+ | Category | Consumer Agent | Decision Question | Signal Words |
95
+ |---|---|---|---|
96
+ | `coding` | code-developer, workflow-executor | 开发者实现时需要这个流程吗? | build, deploy, integrate, configure, setup, migrate, api-contract |
97
+ | `test` | tdd-developer, test-fix-agent | 测试者验证行为时需要这个流程吗? | verify, validate, assert, e2e, regression, coverage, idempotency |
98
+ | `review` | workflow-reviewer | 审查者需要这个作为 checklist 吗? | audit, checklist, compliance, quality-gate, standard |
99
+ | `arch` | workflow-planner | 规划者设计方案时需要这个吗? | design, architecture, decompose, trade-off, migration-strategy |
100
+ | `debug` | debug-explore-agent | 调试者排查问题时需要这个吗? | diagnose, trace, investigate, root-cause, reproduce |
101
+
102
+ **Multi-consumer split**: If content serves multiple consumers (e.g., API doc for both dev and test), split into separate documents:
103
+ - API contract (what endpoints look like) → `category: coding` (AST-*, tool: false)
104
+ - API verification steps (how to test) → `category: test` (RCP-*, tool: true)
105
+ - Ask user when ambiguous: "This tool content serves both developers and testers. Split into separate documents?"
106
+
107
+ ### Step 4: Decide Inline vs Ref
108
+
109
+ - Steps <10 and no code blocks → **inline mode**
110
+ - Steps >=10 or contains code examples/config → **ref mode**
111
+
112
+ ### Step 5: Write
113
+
114
+ **Description format**: First line after `### Title` must state **when to use** this tool (the usage timing from Step 2). This is critical for ref entries — `spec load` only shows the first 200 chars after the heading as the summary.
115
+
116
+ ```
117
+ ### {Title}
118
+
119
+ Use when {timing/trigger condition}.
120
+
121
+ 1. Step one ...
122
+ ```
123
+
124
+ **Confirm before writing** — Use `AskUserQuestion` to show the user the planned knowhow document (title, category, keywords, summary, step count) and spec ref entry before persisting:
125
+
126
+ ```
127
+ question: "确认写入以下 knowhow 工具文档?"
128
+ options:
129
+ - label: "确认写入"
130
+ description: "knowhow: {title} (category: {category}, keywords: {keywords}), spec ref entry"
131
+ - label: "修改后写入"
132
+ description: "调整 title/category/keywords 后重新确认"
133
+ - label: "取消"
134
+ description: "不写入任何文件"
135
+ ```
136
+
137
+ User confirms → proceed; user edits → re-gather; user cancels → END.
138
+
139
+ **Create knowhow tool document** in `.workflow/knowhow/` with `tool: true` in YAML frontmatter:
140
+ ```yaml
141
+ ---
142
+ title: <Title>
143
+ type: recipe
144
+ category: <category>
145
+ keywords: [<keywords>]
146
+ tool: true
147
+ summary: "Use when <timing>. <scope description>"
148
+ ---
149
+
150
+ ## Steps
151
+ 1. Step one ...
152
+ ```
153
+
154
+ **Optionally register spec ref entry** (after user confirmation above) for index discoverability:
155
+ ```bash
156
+ maestro spec add <category> "<title>" "Use when <timing>. <scope summary>" --keywords "<csv>" \
157
+ --description "<one-line summary>" --ref "knowhow/RCP-<slug>.md" --knowhow-type recipe
158
+ ```
159
+
160
+ ### Step 6: Verify
161
+
162
+ - `maestro load --type spec --category <category> --keyword <keyword>` to confirm loadable
163
+ - Display result: title, category, keywords, storage location
164
+
165
+ </execution>
166
+
167
+ <error_codes>
168
+ | Code | Severity | Description |
169
+ |------|----------|-------------|
170
+ | E001 | fatal | `.workflow/specs/` does not exist — run `maestro spec init` |
171
+ | E002 | warning | Duplicate tool name detected — confirm overwrite/optimize |
172
+ | E003 | fatal | category parameter empty — tools must declare a category |
173
+ </error_codes>
174
+
175
+ <success_criteria>
176
+ - [ ] Tool registered as knowhow document with `tool: true` frontmatter
177
+ - [ ] category correctly set
178
+ - [ ] keywords auto-extracted (3-5 terms)
179
+ - [ ] Description starts with "Use when ..." (usage timing)
180
+ - [ ] Loadable via `spec load --category <category>`
181
+ - [ ] Long processes use ref mode with knowhow file created
182
+ - [ ] Ref knowhow YAML includes `summary` with usage timing
183
+ </success_criteria>
184
+
185
+ <completion>
186
+ ### Next-step routing
187
+ | Condition | Suggestion |
188
+ |-----------|-----------|
189
+ | Tool registered, want to test | `/maestro-tools-execute <name>` |
190
+ | Want to register another | `/maestro-tools-register` |
191
+ | Tool for test agents | `/spec-load --category test` to verify discovery |
192
+ </completion>
@@ -0,0 +1,127 @@
1
+ ---
2
+ name: maestro-ui-codify
3
+ description: "Extract design system from code, generate reference package, persist as knowledge assets Arguments: <source-path> [--package-name <name>] [--output-dir <path>] [--overwrite]"
4
+ allowed-tools: Read Write Edit Bash Glob Grep Agent Skill AskUserQuestion
5
+ ---
6
+
7
+ <purpose>
8
+ Extract design system from source code into tokens, reference package, and knowledge assets.
9
+ 4-phase pipeline: validate → extract → package → knowhow.
10
+ </purpose>
11
+
12
+ <deferred_reading>
13
+ - [ui-codify.md](~/.maestro/workflows/ui-codify.md) — read always (main workflow orchestrator)
14
+ - [ui-codify-extract.md](~/.maestro/workflows/ui-codify-extract.md) — read when Phase 2 starts (style extraction with 3 agents)
15
+ - [ui-codify-package.md](~/.maestro/workflows/ui-codify-package.md) — read when Phase 3 starts (reference package generation)
16
+ - [ui-codify-knowhow.md](~/.maestro/workflows/ui-codify-knowhow.md) — read when Phase 4 starts (knowledge asset generation)
17
+ </deferred_reading>
18
+
19
+ <context>
20
+ $ARGUMENTS — source path (required) with optional flags.
21
+
22
+ Flags:
23
+ - `<source-path>` (positional, required): Directory containing CSS/SCSS/JS/TS/HTML source files
24
+ - `--package-name <name>`: Package name for reference output (default: auto-generated from source directory)
25
+ - `--output-dir <path>`: Output directory for reference package (default: `.workflow/reference_style`)
26
+ - `--overwrite`: Allow overwriting existing package directory
27
+
28
+ **Output boundary**: ALL file writes MUST target the `--output-dir` path (default: `.workflow/reference_style/`) for reference packages, and `.workflow/knowhow/` for knowledge assets (via `codify-to-knowhow`). NEVER modify the source directory being analyzed.
29
+ </context>
30
+
31
+ <invariants>
32
+ 1. **Source read-only** — the source path being analyzed MUST NOT be modified; extraction is purely read-only
33
+ 2. **Phase-sequential loading** — workflow files (ui-codify-extract, ui-codify-package, ui-codify-knowhow) MUST be read only when their phase starts; NEVER load all phases eagerly
34
+ 3. **User confirmation before knowhow** — Phase 3→4 gate MUST present AskUserQuestion before generating knowledge assets; NEVER auto-proceed to knowhow generation
35
+ 4. **Overwrite protection** — existing package directory MUST NOT be overwritten without `--overwrite` flag (E003)
36
+ 5. **Artifact completeness** — all 5 required artifacts MUST exist before reporting completion; NEVER skip artifact verification
37
+ 6. **Token-first extraction** — design-tokens.json MUST be generated before layout-templates.json; layout extraction depends on token foundation
38
+ </invariants>
39
+
40
+ <execution>
41
+ ## 1. Load UI Specs
42
+
43
+ Load project UI conventions before extracting design system:
44
+
45
+ ```bash
46
+ maestro load --type spec --category ui
47
+ ```
48
+
49
+ ## 2. Execute Workflow
50
+
51
+ Route to `~/.maestro/workflows/ui-codify.md` and follow completely.
52
+
53
+ The workflow orchestrates 4 phases with deferred loading of phase-specific workflow files. Each phase reads its workflow file only when execution reaches that phase.
54
+
55
+ ### Phase Gates (MANDATORY, BLOCKING)
56
+
57
+ **GATE Phase 1 → Phase 2: Validation → Extraction**
58
+ - REQUIRED: Source path validated and file discovery completed.
59
+ - REQUIRED: design-tokens.json generated with color, typography, spacing tokens.
60
+ - BLOCKED if missing: source path invalid (E002) or design-tokens.json not generated — extraction cannot proceed without token foundation.
61
+
62
+ **GATE Phase 2 → Phase 3: Extraction → Package**
63
+ - REQUIRED: layout-templates.json generated with component patterns.
64
+ - BLOCKED if missing: layout-templates.json absent — package generation requires component patterns as input.
65
+
66
+ **GATE Phase 3 → Phase 4: Package → Knowhow**
67
+ - REQUIRED: preview.html + preview.css generated as interactive showcase.
68
+ - BLOCKED if missing: preview artifacts not generated — knowhow phase needs rendered reference for validation.
69
+ - REQUIRED: AskUserQuestion confirmation before proceeding to knowhow generation:
70
+ ```
71
+ question: "Preview 生成完成。是否继续将设计系统持久化为 knowhow 知识资产?"
72
+ options:
73
+ - label: "继续生成 knowhow"
74
+ description: "调用 codify-to-knowhow 写入 AST/DCS assets 和 spec entries"
75
+ - label: "仅保留 preview,跳过 knowhow"
76
+ description: "保留 preview.html + preview.css,不写入知识库"
77
+ ```
78
+
79
+ **GATE Phase 4 → Completion: Knowhow → Done**
80
+ - REQUIRED: knowhow-manifest.json created with AST/DCS assets and spec entries.
81
+ - REQUIRED: codify-to-knowhow called and completed (only after user confirmation at Phase 3→4 gate).
82
+ - BLOCKED if missing: knowhow-manifest.json absent or codify-to-knowhow not invoked — knowledge assets not persisted.
83
+
84
+ ### Artifact Verification (before completion)
85
+
86
+ ```
87
+ REQUIRED_ARTIFACTS = [
88
+ "design-tokens.json", // Phase 1
89
+ "layout-templates.json", // Phase 2
90
+ "preview.html", // Phase 3
91
+ "preview.css", // Phase 3
92
+ "knowhow-manifest.json" // Phase 4
93
+ ]
94
+ ```
95
+ If any artifact is missing: DO NOT report completion.
96
+ </execution>
97
+
98
+ <error_codes>
99
+ | Code | Severity | Description | Stage |
100
+ |------|----------|-------------|-------|
101
+ | E001 | error | Source path argument required | parse_input |
102
+ | E002 | error | Source path not found or not a directory | validate |
103
+ | E003 | error | Package directory exists without --overwrite flag | validate |
104
+ | W001 | warning | animation-tokens.json not found (optional, extraction continues) | extract |
105
+ </error_codes>
106
+
107
+ <success_criteria>
108
+ - [ ] UI specs loaded via `spec load --category ui` (if available)
109
+ - [ ] Source path validated and file discovery completed
110
+ - [ ] design-tokens.json generated with color, typography, spacing tokens
111
+ - [ ] layout-templates.json generated with component patterns (universal/specialized)
112
+ - [ ] animation-tokens.json generated (optional, W001 if missing)
113
+ - [ ] preview.html + preview.css generated as interactive showcase
114
+ - [ ] knowhow-manifest.json created with AST/DCS assets and spec entries
115
+ - [ ] codify-to-knowhow called and completed successfully
116
+ - [ ] Temporary workspace cleaned up
117
+ </success_criteria>
118
+
119
+ <completion>
120
+ ### Next-step routing
121
+
122
+ | Condition | Suggestion |
123
+ |-----------|-----------|
124
+ | Codify complete | Use extracted tokens in `maestro impeccable craft` for new builds |
125
+ | Design system needs refinement | `maestro impeccable document` to regenerate DESIGN.md |
126
+ | Knowledge assets persisted | `maestro search --type knowhow "design system"` to verify |
127
+ </completion>