speccrew 0.6.28 → 0.6.30

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.
@@ -0,0 +1,385 @@
1
+ ---
2
+ name: speccrew-knowledge-bizs-ui-style-extract-xml
3
+ description: Extract and aggregate UI design patterns (page types, components, layouts) from analyzed bizs feature documents using XML workflow blocks, outputting to techs ui-style-patterns directory.
4
+ tools: Read, Write
5
+ ---
6
+
7
+ # Bizs UI Style Extract (XML Workflow)
8
+
9
+ Extract and aggregate **UI design patterns** from bizs pipeline analyzed feature documents using XML workflow blocks. Through cross-module clustering analysis, identify common page types, component patterns, and layout patterns, then output them to the techs knowledge base `ui-style-patterns/` subdirectory.
10
+
11
+ ## Language Adaptation
12
+
13
+ **CRITICAL**: All generated documents must match the user's language. Detect the language from the user's input and generate content accordingly.
14
+
15
+ - User writes in 中文 → Generate Chinese documents, use `language: "zh"`
16
+ - User writes in English → Generate English documents, use `language: "en"`
17
+ - User writes in other languages → Use appropriate language code
18
+
19
+ **All generated pattern documents must be in the language specified by the `language` parameter.**
20
+
21
+ ## Trigger Scenarios
22
+
23
+ - Called by `speccrew-knowledge-bizs-dispatch` Stage 3.5 (after Module Summarize, before System Summary)
24
+ - "Extract UI patterns from bizs features"
25
+ - "Aggregate UI design patterns"
26
+
27
+ ## Input
28
+
29
+ | Variable | Description | Required |
30
+ |----------|-------------|----------|
31
+ | `platform_id` | Platform identifier (e.g., web-vue, mobile-uniapp), used to locate output directory | Yes |
32
+ | `platform_type` | Platform type (web, mobile, desktop), only execute for frontend platforms | Yes |
33
+ | `feature_docs_path` | Completed feature documents base path, e.g., `speccrew-workspace/knowledges/bizs/{platform-type}/{module}/features/` | Yes |
34
+ | `features_manifest_path` | Path to features-{platform}.json, used to get completed feature list | Yes |
35
+ | `module_overviews_path` | **Parent directory** containing all module overview subdirectories. Example: `knowledges/bizs/web-vue/` (this directory contains `system/system-overview.md`, `user/user-overview.md`, etc.). **NOT** a specific module directory like `knowledges/bizs/web-vue/system/`. | Yes |
36
+ | `output_path` | Output directory, e.g., `speccrew-workspace/knowledges/techs/{platform_id}/ui-style-patterns/` | Yes |
37
+ | `language` | User language code | Yes |
38
+
39
+ ## Output
40
+
41
+ > **Directory Separation**: This skill outputs to `ui-style-patterns/` (NOT `ui-style/`).
42
+ > - `ui-style/` is managed by techs pipeline (framework-level design system, existing components/pages)
43
+ > - `ui-style-patterns/` is managed by bizs pipeline (business pattern aggregation from feature docs)
44
+ > This separation prevents file conflicts between the two pipelines.
45
+
46
+ ```
47
+ {output_path}/
48
+ ├── page-types/ # Page type pattern documents
49
+ │ ├── {pattern-name}.md
50
+ │ └── ...
51
+ ├── components/ # Component pattern documents
52
+ │ ├── {pattern-name}.md
53
+ │ └── ...
54
+ └── layouts/ # Layout pattern documents
55
+ ├── {pattern-name}.md
56
+ └── ...
57
+ ```
58
+
59
+ ## Absolute Constraints
60
+
61
+ > **These rules apply to ALL document generation steps. Violation = task failure.**
62
+
63
+ 1. **FORBIDDEN: `create_file` for pattern documents** — NEVER use `create_file` to write pattern documents. Each document MUST be created by copying the appropriate template then filling sections with `search_replace`.
64
+
65
+ 2. **FORBIDDEN: Full-file rewrite** — NEVER replace the entire document content in a single operation. Always use targeted `search_replace` on specific sections.
66
+
67
+ 3. **MANDATORY: Template-first workflow** — Copy template MUST execute before filling sections for every pattern document.
68
+
69
+ ## Workflow
70
+
71
+ <!--
72
+ == Block Types ==
73
+ input : Workflow input parameters (required=mandatory, default=default value)
74
+ output : Workflow output results (from=data source variable)
75
+ task : Execute action (action: run-skill | run-script | dispatch-to-worker)
76
+ gateway : Conditional branch/gate (mode: exclusive | guard | parallel)
77
+ loop : Iterate over collection (over=collection, as=current item)
78
+ event : Log/confirm/signal (action: log | confirm | signal)
79
+ error-handler : Exception handling (try > catch > finally)
80
+ checkpoint : Persistent milestone (name=checkpoint name, verify=verification condition)
81
+ rule : Constraint declaration (level: forbidden | mandatory | note)
82
+ -->
83
+
84
+ <workflow>
85
+
86
+ <!-- Input Block -->
87
+ <input name="platform_id" type="string" required="true" description="Platform identifier (e.g., web-vue, mobile-uniapp)" />
88
+ <input name="platform_type" type="string" required="true" description="Platform type (web, mobile, desktop)" />
89
+ <input name="feature_docs_path" type="string" required="true" description="Completed feature documents base path" />
90
+ <input name="features_manifest_path" type="string" required="true" description="Path to features-{platform}.json" />
91
+ <input name="module_overviews_path" type="string" required="true" description="Parent directory containing all module overview subdirectories" />
92
+ <input name="output_path" type="string" required="true" description="Output directory for pattern documents" />
93
+ <input name="language" type="string" required="true" description="User language code" />
94
+
95
+ <!-- Rule Block: Absolute Constraints -->
96
+ <rule level="forbidden">Using `create_file` to write pattern documents directly</rule>
97
+ <rule level="forbidden">Full-file rewrite of pattern documents</rule>
98
+ <rule level="mandatory">Copy template MUST execute before filling sections for every pattern document</rule>
99
+ <rule level="mandatory">All generated pattern documents must be in the specified language</rule>
100
+
101
+ <!-- Gateway: Platform Type Check -->
102
+ <gateway mode="exclusive">
103
+ <branch condition="platform_type NOT IN ['web', 'mobile', 'desktop']">
104
+ <event action="log">Skipping skill: backend platforms do not have UI patterns</event>
105
+ <output name="skip_reason" value="Backend platform - no UI patterns" />
106
+ <task name="return-skip" action="run-skill">
107
+ <return>
108
+ <status>skipped</status>
109
+ <reason>Backend platform does not have UI patterns</reason>
110
+ </return>
111
+ </task>
112
+ </branch>
113
+ <branch condition="platform_type IN ['web', 'mobile', 'desktop']">
114
+
115
+ <!-- Step 1: Load Features Manifest -->
116
+ <task name="load-features-manifest" action="run-script">
117
+ <description>Read the features manifest to identify all completed features</description>
118
+ <validation>
119
+ <rule>Verify features_manifest_path exists and is valid JSON</rule>
120
+ <rule>Verify feature_docs_path exists and is a directory</rule>
121
+ </validation>
122
+ <script type="read-file">
123
+ <path>{features_manifest_path}</path>
124
+ </script>
125
+ <filter>status === "completed"</filter>
126
+ <collect>featureId, module, documentPath</collect>
127
+ <output name="completed_features" />
128
+ </task>
129
+
130
+ <!-- Gateway: Check Completed Features -->
131
+ <gateway mode="guard">
132
+ <condition>completed_features.length > 0</condition>
133
+ <then>
134
+
135
+ <!-- Create Output Directory -->
136
+ <task name="create-output-dirs" action="run-script">
137
+ <description>Create output directory structure if it does not exist</description>
138
+ <create-directories>
139
+ <path>{output_path}/page-types/</path>
140
+ <path>{output_path}/components/</path>
141
+ <path>{output_path}/layouts/</path>
142
+ </create-directories>
143
+ </task>
144
+
145
+ <!-- Step 2: Read Feature Documents -->
146
+ <task name="read-feature-docs" action="run-skill">
147
+ <description>Extract UI-related information from all completed feature documents</description>
148
+ <input ref="completed_features" />
149
+ <input ref="feature_docs_path" />
150
+ <extraction>
151
+ <section name="Interface Prototype">
152
+ <extract>ASCII wireframe diagrams, layout regions</extract>
153
+ </section>
154
+ <section name="Page Elements Table">
155
+ <extract>Component names, types, responsibilities, interactions</extract>
156
+ </section>
157
+ <section name="Business Flow Description">
158
+ <extract>User interaction sequences, navigation patterns</extract>
159
+ </section>
160
+ </extraction>
161
+ <output name="ui_extracted_data" />
162
+ </task>
163
+
164
+ <!-- Step 3: Read Module Overviews -->
165
+ <task name="read-module-overviews" action="run-script">
166
+ <description>Gather module-level aggregated information for context</description>
167
+ <input ref="module_overviews_path" />
168
+ <script type="glob">
169
+ <pattern>{module_overviews_path}/*/module-overview.md</pattern>
170
+ </script>
171
+ <extraction>
172
+ <item>Common page structures</item>
173
+ <item>Shared components</item>
174
+ <item>Navigation patterns</item>
175
+ </extraction>
176
+ <output name="module_context" />
177
+ </task>
178
+
179
+ <!-- Checkpoint: Data Collection Complete -->
180
+ <checkpoint name="data-collection-complete" verify="ui_extracted_data is not empty AND module_context is not empty" />
181
+
182
+ <!-- Step 4: Cross-Module Clustering Analysis -->
183
+ <task name="cross-module-clustering" action="run-skill">
184
+ <description>Identify recurring UI patterns across modules through clustering analysis</description>
185
+ <input ref="ui_extracted_data" />
186
+ <input ref="module_context" />
187
+ <clustering-strategy>
188
+ <approach>Dynamic discovery - Agent automatically identifies and categorizes pattern types based on actual analysis results</approach>
189
+ <note>Templates only standardize output format, do not limit pattern types</note>
190
+ </clustering-strategy>
191
+ <categories>
192
+ <page-types>Pages with similar structure and purpose (e.g., list-page, form-page, detail-page, tree-list-page, dashboard-page, wizard-page)</page-types>
193
+ <component-patterns>Reusable component combinations (e.g., search-filter-bar, data-table-pagination, modal-form, drawer-detail, tab-panel)</component-patterns>
194
+ <layout-patterns>Repeating structural layouts (e.g., sidebar-content, topbar-sidebar-content, full-screen)</layout-patterns>
195
+ </categories>
196
+ <recognition-criteria>
197
+ <frequency>Pattern appears in 2+ features (stronger signal if across different modules)</frequency>
198
+ <similarity>Structural similarity in ASCII wireframes</similarity>
199
+ <semantic-alignment>Similar business purpose and interaction flow</semantic-alignment>
200
+ </recognition-criteria>
201
+ <note>Cross-module occurrence is a strong signal but not required. Patterns appearing in multiple features within a single module are also valid for extraction.</note>
202
+ <output name="identified_patterns" />
203
+ </task>
204
+
205
+ <!-- Gateway: Check Identified Patterns -->
206
+ <gateway mode="exclusive">
207
+ <branch condition="identified_patterns.length == 0">
208
+ <event action="log">No patterns identified from feature documents</event>
209
+ <output name="patterns" value="{}" />
210
+ </branch>
211
+ <branch condition="identified_patterns.length > 0">
212
+
213
+ <!-- Step 5: Generate Pattern Documents -->
214
+ <loop over="identified_patterns" as="pattern">
215
+
216
+ <!-- 5.1 Template Selection -->
217
+ <gateway mode="exclusive">
218
+ <branch condition="pattern.category == 'page-types'">
219
+ <task name="select-page-template" action="run-script">
220
+ <template-path>../speccrew-knowledge-bizs-ui-style-extract/templates/PAGE-TYPE-TEMPLATE.md</template-path>
221
+ <output-directory>{output_path}/page-types/</output-directory>
222
+ <output name="selected_template" />
223
+ </task>
224
+ </branch>
225
+ <branch condition="pattern.category == 'components'">
226
+ <task name="select-component-template" action="run-script">
227
+ <template-path>../speccrew-knowledge-bizs-ui-style-extract/templates/COMPONENT-PATTERN-TEMPLATE.md</template-path>
228
+ <output-directory>{output_path}/components/</output-directory>
229
+ <output name="selected_template" />
230
+ </task>
231
+ </branch>
232
+ <branch condition="pattern.category == 'layouts'">
233
+ <task name="select-layout-template" action="run-script">
234
+ <template-path>../speccrew-knowledge-bizs-ui-style-extract/templates/LAYOUT-PATTERN-TEMPLATE.md</template-path>
235
+ <output-directory>{output_path}/layouts/</output-directory>
236
+ <output name="selected_template" />
237
+ </task>
238
+ </branch>
239
+ </gateway>
240
+
241
+ <!-- 5.2 Copy Template to Document Path -->
242
+ <task name="copy-template" action="run-script">
243
+ <description>Copy template to output path with kebab-case filename</description>
244
+ <input ref="selected_template" />
245
+ <filename-format>kebab-case (e.g., list-page.md, search-filter-bar.md, sidebar-content.md)</filename-format>
246
+ <output-path>{selected_template.output-directory}/{pattern.name}.md</output-path>
247
+ <output name="document_path" />
248
+ </task>
249
+
250
+ <!-- 5.3 Fill Sections Using search_replace -->
251
+ <task name="fill-pattern-document" action="run-skill">
252
+ <description>Fill pattern document sections using search_replace</description>
253
+ <input ref="document_path" />
254
+ <input ref="pattern" />
255
+ <input ref="language" />
256
+ <constraints>
257
+ <rule level="forbidden">Using create_file to rewrite the entire document</rule>
258
+ <rule level="mandatory">Use search_replace to fill each section individually</rule>
259
+ <rule level="mandatory">All section titles MUST be preserved</rule>
260
+ </constraints>
261
+ <content-requirements>
262
+ <ascii-wireframes>Must be generalized versions (not direct copies from specific features)</ascii-wireframes>
263
+ <instance-references>Must use relative paths to reference actual feature documents</instance-references>
264
+ <mermaid-diagrams>
265
+ <rule>Follow speccrew-workspace/docs/rules/mermaid-rule.md rules</rule>
266
+ <rule>Use graph TB/LR syntax only</rule>
267
+ <rule>No br/ tags, no style definitions, no nested subgraph</rule>
268
+ <rule>No direction keyword, no special symbols</rule>
269
+ </mermaid-diagrams>
270
+ </content-requirements>
271
+ <output name="filled_document" />
272
+ </task>
273
+
274
+ <!-- Checkpoint: Pattern Document Generated -->
275
+ <checkpoint name="pattern-document-generated" verify="file_exists({document_path}) AND document_has_all_sections({document_path})" />
276
+
277
+ </loop>
278
+
279
+ </branch>
280
+ </gateway>
281
+
282
+ <!-- Step 6: Return Summary -->
283
+ <task name="return-summary" action="run-skill">
284
+ <description>Provide summary of generated pattern documents</description>
285
+ <collect>
286
+ <item>All generated file paths</item>
287
+ <item>Pattern counts by category</item>
288
+ </collect>
289
+ <output name="summary" />
290
+ </task>
291
+
292
+ </then>
293
+ <else>
294
+ <event action="log">No completed features found - returning empty result</event>
295
+ <output name="summary">
296
+ <status>completed</status>
297
+ <platform_id>{platform_id}</platform_id>
298
+ <patterns>
299
+ <page-types count="0" files="[]" />
300
+ <components count="0" files="[]" />
301
+ <layouts count="0" files="[]" />
302
+ </patterns>
303
+ <total_patterns>0</total_patterns>
304
+ <output_path>{output_path}</output_path>
305
+ </output>
306
+ </else>
307
+ </gateway>
308
+
309
+ </branch>
310
+ </gateway>
311
+
312
+ <!-- Output Block -->
313
+ <output name="final_summary" from="summary" description="Summary of generated pattern documents with file list and counts" />
314
+
315
+ </workflow>
316
+
317
+ ## Generation Rules
318
+
319
+ 1. **Pattern Quality**:
320
+ - Each pattern must have clear applicable scenarios
321
+ - Generalized ASCII wireframe (not feature-specific)
322
+ - At least 2 instance references (from same or different modules)
323
+
324
+ 2. **Template Compliance**:
325
+ - All sections from template must be filled
326
+ - Instance reference paths must be relative and valid
327
+
328
+ 3. **Mermaid Compliance**:
329
+ - Follow all rules in `mermaid-rule.md`
330
+ - Use basic `graph TB` or `graph LR` syntax
331
+ - No prohibited syntax elements
332
+
333
+ 4. **Language Consistency**:
334
+ - All content in the specified `language`
335
+ - Template section headers remain in English
336
+ - Content text matches user language
337
+
338
+ ## Error Handling
339
+
340
+ | Scenario | Handling |
341
+ |----------|----------|
342
+ | No completed features | Return empty result, log warning |
343
+ | No patterns identified | Return empty result, log message |
344
+ | Template not found | Use default structure, log warning |
345
+ | Feature document missing | Skip feature, continue with others |
346
+
347
+ ## Checklist
348
+
349
+ - [ ] Step 1: Features manifest loaded, completed features identified
350
+ - [ ] Step 2: All completed feature documents read
351
+ - [ ] Step 3: All module overviews read
352
+ - [ ] Step 4: Cross-module clustering analysis completed
353
+ - [ ] Step 5: Pattern documents generated with correct templates
354
+ - [ ] Step 5: File naming follows kebab-case convention
355
+ - [ ] Step 5: ASCII wireframes are generalized versions
356
+ - [ ] Step 5: Instance references use relative paths
357
+ - [ ] Step 5: Mermaid diagrams follow mermaid-rule.md
358
+ - [ ] Step 6: Summary returned with file list
359
+
360
+ ## Return
361
+
362
+ After completion, return a summary object to the caller:
363
+
364
+ ```json
365
+ {
366
+ "status": "completed",
367
+ "platform_id": "web-vue",
368
+ "patterns": {
369
+ "page_types": {
370
+ "count": 3,
371
+ "files": ["page-types/list-page.md", "page-types/form-page.md", "page-types/detail-page.md"]
372
+ },
373
+ "components": {
374
+ "count": 2,
375
+ "files": ["components/search-filter-bar.md", "components/modal-form.md"]
376
+ },
377
+ "layouts": {
378
+ "count": 1,
379
+ "files": ["layouts/sidebar-content.md"]
380
+ }
381
+ },
382
+ "total_patterns": 6,
383
+ "output_path": "speccrew-workspace/knowledges/techs/web-vue/ui-style-patterns/"
384
+ }
385
+ ```