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,343 @@
1
+ ---
2
+ name: speccrew-knowledge-bizs-ui-graph-xml
3
+ description: Constructs knowledge graph data (nodes, edges, relationships) from UI analysis results using XML workflow blocks. Generates graph JSON files and completion markers for the bizs knowledge pipeline.
4
+ tools: Read, Write, Glob, Grep, Bash
5
+ ---
6
+
7
+ # UI Knowledge Graph Constructor (XML Workflow)
8
+
9
+ > **CRITICAL CONSTRAINT**: DO NOT create temporary scripts, batch files, or workaround code files (`.py`, `.bat`, `.sh`, `.ps1`, etc.) under any circumstances.
10
+
11
+ Construct knowledge graph data (nodes, edges, relationships) from UI feature analysis results and write completion marker files for the bizs knowledge pipeline.
12
+
13
+ ## Language Adaptation
14
+
15
+ This skill automatically adapts to the user's input language. All documentation and output will be generated in the same language as the user's query.
16
+
17
+ ## Trigger Scenarios
18
+
19
+ - "Construct graph data for UI feature {fileName}"
20
+ - "Generate graph nodes and edges from UI analysis"
21
+ - "Write completion markers for feature {fileName}"
22
+
23
+ ## Input Variables
24
+
25
+ | Variable | Type | Description | Example |
26
+ |----------|------|-------------|---------|
27
+ | `{{feature}}` | object | Complete feature object from features.json | - |
28
+ | `{{fileName}}` | string | Feature file name | `"index"`, `"UserForm"` |
29
+ | `{{sourcePath}}` | string | Relative path to source file | `"frontend-web/src/views/system/user/index.vue"` |
30
+ | `{{documentPath}}` | string | Path to generated documentation | `"speccrew-workspace/knowledges/bizs/..."` |
31
+ | `{{module}}` | string | Business module name | `"system"`, `"trade"`, `"_root"` |
32
+ | `{{platform_type}}` | string | Platform type | `"web"`, `"mobile"` |
33
+ | `{{platform_subtype}}` | string | Platform subtype | `"vue"`, `"react"` |
34
+ | `{{completed_dir}}` | string | Marker files output directory | `"speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/completed"` |
35
+ | `{{sourceFile}}` | string | Source features JSON file name | `"features-web-vue.json"` |
36
+ | `{{status}}` | string | Analysis status from UI analysis | `"success"`, `"partial"`, `"failed"` |
37
+ | `{{analysisNotes}}` | string | Analysis notes from UI analysis | `"Successfully analyzed..."` |
38
+
39
+ ## Output
40
+
41
+ **Generated Files (MANDATORY):**
42
+ 1. `{{completed_dir}}/{module}-{subpath}-{fileName}.graph.json` - Graph data with nodes and edges
43
+ 2. `{{completed_dir}}/{module}-{subpath}-{fileName}.graph-done.json` - Graph completion marker
44
+
45
+ ## Workflow
46
+
47
+ <!--
48
+ == Block Types ==
49
+ input : Workflow input parameters (required=mandatory, default=default value)
50
+ output : Workflow output results (from=data source variable)
51
+ task : Execute action (action: run-skill | run-script | dispatch-to-worker)
52
+ gateway : Conditional branch/gate (mode: exclusive | guard | parallel)
53
+ loop : Iterate over collection (over=collection, as=current item)
54
+ event : Log/confirm/signal (action: log | confirm | signal)
55
+ error-handler : Exception handling (try > catch > finally)
56
+ checkpoint : Persistent milestone (name=checkpoint name, verify=verification condition)
57
+ rule : Constraint declaration (level: forbidden | mandatory | note)
58
+ -->
59
+
60
+ ```xml
61
+ <workflow name="ui-knowledge-graph-construction" version="1.0">
62
+
63
+ <!-- Input Parameters -->
64
+ <input name="feature" type="object" required="true" description="Complete feature object from features.json"/>
65
+ <input name="fileName" type="string" required="true" description="Feature file name without extension"/>
66
+ <input name="sourcePath" type="string" required="true" description="Relative path to source file"/>
67
+ <input name="documentPath" type="string" required="true" description="Path to generated documentation"/>
68
+ <input name="module" type="string" required="true" description="Business module name"/>
69
+ <input name="platform_type" type="string" required="true" description="Platform type"/>
70
+ <input name="platform_subtype" type="string" required="true" description="Platform subtype"/>
71
+ <input name="completed_dir" type="string" required="true" description="Marker files output directory"/>
72
+ <input name="sourceFile" type="string" required="true" description="Source features JSON file name"/>
73
+ <input name="status" type="string" required="true" default="success" description="Analysis status from UI analysis"/>
74
+ <input name="analysisNotes" type="string" required="true" default="" description="Analysis notes from UI analysis"/>
75
+
76
+ <!-- Step 1: Read Source File -->
77
+ <checkpoint name="step-1-read-source">
78
+ <task action="read" target="{{sourcePath}}" output="sourceContent"/>
79
+ <task action="extract-api-imports" input="{{sourceContent}}" output="apiImports"/>
80
+ <task action="extract-component-usage" input="{{sourceContent}}" output="componentUsage"/>
81
+ <task action="extract-navigation-patterns" input="{{sourceContent}}" output="navigationPatterns"/>
82
+ <event action="log" message="Step 1 Status: COMPLETED - Read {{sourcePath}}, found {{apiImports.count}} APIs, {{componentUsage.count}} components, {{navigationPatterns.count}} navigations"/>
83
+ </checkpoint>
84
+
85
+ <!-- Step 2: Construct Graph Nodes -->
86
+ <checkpoint name="step-2-construct-nodes">
87
+ <task action="construct-node" type="page" id="page-{{module}}-{{fileName}}"
88
+ name="{{fileName}}" module="{{module}}"
89
+ sourcePath="{{sourcePath}}" documentPath="{{documentPath}}"
90
+ context-route="{{extractedRoute}}" context-components="{{componentUsage.list}}"
91
+ context-platform="{{platform_type}}-{{platform_subtype}}"
92
+ output="pageNode"/>
93
+ <loop over="{{componentUsage.list}}" as="component">
94
+ <task action="construct-node" type="component" id="component-{{module}}-{{component.name}}"
95
+ name="{{component.name}}" module="{{module}}"
96
+ sourcePath="{{component.path}}" documentPath="{{documentPath}}"
97
+ context-props="{{component.props}}" context-events="{{component.events}}"
98
+ output="componentNodes[]"/>
99
+ </loop>
100
+ <event action="log" message="Step 2 Status: COMPLETED - Constructed {{nodeCount}} nodes"/>
101
+ </checkpoint>
102
+
103
+ <!-- Step 3: Construct Graph Edges -->
104
+ <checkpoint name="step-3-construct-edges">
105
+ <!-- API Call Edges -->
106
+ <loop over="{{apiImports.list}}" as="api">
107
+ <task action="construct-edge" source="page-{{module}}-{{fileName}}"
108
+ target="api-{{api.module}}-{{api.name}}" type="calls"
109
+ metadata-trigger="{{api.trigger}}" metadata-method="{{api.method}}"
110
+ metadata-context="{{api.context}}"
111
+ output="apiEdges[]"/>
112
+ </loop>
113
+ <!-- Navigation Edges -->
114
+ <loop over="{{navigationPatterns.list}}" as="nav">
115
+ <task action="construct-edge" source="page-{{module}}-{{fileName}}"
116
+ target="page-{{nav.targetModule}}-{{nav.targetPage}}" type="navigates-to"
117
+ metadata-trigger="{{nav.trigger}}" metadata-method="{{nav.method}}"
118
+ output="navEdges[]"/>
119
+ </loop>
120
+ <!-- Component Usage Edges -->
121
+ <loop over="{{componentUsage.list}}" as="comp">
122
+ <task action="construct-edge" source="page-{{module}}-{{fileName}}"
123
+ target="component-{{module}}-{{comp.name}}" type="uses"
124
+ metadata-context="{{comp.usageContext}}"
125
+ output="useEdges[]"/>
126
+ </loop>
127
+ <event action="log" message="Step 3 Status: COMPLETED - Constructed {{edgeCount}} edges ({{apiEdges.count}} API calls, {{navEdges.count}} navigations, {{useEdges.count}} component uses)"/>
128
+ </checkpoint>
129
+
130
+ <!-- Step 4: Write Graph JSON -->
131
+ <checkpoint name="step-4-write-graph-json" verify="valid-json-structure">
132
+ <task action="calculate-marker-filename" module="{{module}}" subpath="{{extractSubpath sourcePath}}"
133
+ fileName="{{fileName}}" output="markerFilename"/>
134
+ <task action="write" target="{{completed_dir}}/{{markerFilename}}.graph.json">
135
+ <content>
136
+ {
137
+ "module": "{{module}}",
138
+ "nodes": [
139
+ {{pageNode}},
140
+ {{#each componentNodes}}
141
+ {{this}}{{#unless @last}},{{/unless}}
142
+ {{/each}}
143
+ ],
144
+ "edges": [
145
+ {{#each apiEdges}}
146
+ {{this}}{{#unless @last}},{{/unless}}
147
+ {{/each}},
148
+ {{#each navEdges}}
149
+ {{this}}{{#unless @last}},{{/unless}}
150
+ {{/each}},
151
+ {{#each useEdges}}
152
+ {{this}}{{#unless @last}},{{/unless}}
153
+ {{/each}}
154
+ ]
155
+ }
156
+ </content>
157
+ </task>
158
+ <event action="log" message="Step 4 Status: COMPLETED - Graph JSON written to {{completed_dir}}/{{markerFilename}}.graph.json"/>
159
+ </checkpoint>
160
+
161
+ <!-- Step 5: Write Completion Marker -->
162
+ <checkpoint name="step-5-write-marker" verify="valid-marker-structure">
163
+ <task action="write" target="{{completed_dir}}/{{markerFilename}}.graph-done.json">
164
+ <content>
165
+ {
166
+ "fileName": "{{fileName}}",
167
+ "sourcePath": "{{sourcePath}}",
168
+ "sourceFile": "{{sourceFile}}",
169
+ "module": "{{module}}",
170
+ "documentPath": "{{documentPath}}",
171
+ "marker": "graph_completed",
172
+ "graphFile": "{{markerFilename}}.graph.json",
173
+ "nodeCount": {{nodeCount}},
174
+ "edgeCount": {{edgeCount}},
175
+ "status": "{{status}}",
176
+ "analysisNotes": "{{analysisNotes}}"
177
+ }
178
+ </content>
179
+ </task>
180
+ <event action="log" message="Step 5 Status: COMPLETED - Graph completion marker written to {{completed_dir}}/{{markerFilename}}.graph-done.json"/>
181
+ </checkpoint>
182
+
183
+ <!-- Output Results -->
184
+ <output name="status" from="success"/>
185
+ <output name="module" from="{{module}}"/>
186
+ <output name="fileName" from="{{fileName}}"/>
187
+ <output name="graphFile" from="{{completed_dir}}/{{markerFilename}}.graph.json"/>
188
+ <output name="nodeCount" from="{{nodeCount}}"/>
189
+ <output name="edgeCount" from="{{edgeCount}}"/>
190
+ <output name="message" from="Generated graph data with {{nodeCount}} nodes and {{edgeCount}} edges"/>
191
+
192
+ <!-- Constraints -->
193
+ <rule level="mandatory" description="100% API coverage - ALL imported API functions MUST be represented as calls edges"/>
194
+ <rule level="mandatory" description="Valid JSON format - Both .graph.json and .graph-done.json MUST be valid JSON"/>
195
+ <rule level="mandatory" description="Root-level module field - .graph.json MUST include module at root level"/>
196
+ <rule level="mandatory" description="Correct filename pattern - Use {module}-{subpath}-{fileName} composite naming"/>
197
+ <rule level="mandatory" description="No file extension in fileName - The fileName field in .graph-done.json MUST NOT include extension"/>
198
+ <rule level="mandatory" description="documentPath as N/A - Use N/A when no document exists, never empty string"/>
199
+
200
+ </workflow>
201
+ ```
202
+
203
+ ## Node Structure Reference
204
+
205
+ ```json
206
+ {
207
+ "id": "page-{module}-{feature-name}",
208
+ "type": "page",
209
+ "name": "<display name>",
210
+ "module": "{{module}}",
211
+ "sourcePath": "{{sourcePath}}",
212
+ "documentPath": "{{documentPath}}",
213
+ "description": "...",
214
+ "tags": [...],
215
+ "keywords": [...],
216
+ "context": {
217
+ "route": "...",
218
+ "components": [...],
219
+ "platform": "{{platform_type}}-{{platform_subtype}}"
220
+ }
221
+ }
222
+ ```
223
+
224
+ ## Edge Structure Reference
225
+
226
+ ```json
227
+ {
228
+ "source": "page-{module}-{name}",
229
+ "target": "api-{module}-{api-name}",
230
+ "type": "calls",
231
+ "metadata": {
232
+ "trigger": "onClick|onMounted|onSubmit|...",
233
+ "method": "getUserList",
234
+ "context": "Page initialization - load user list"
235
+ }
236
+ }
237
+ ```
238
+
239
+ ## Node ID Naming Convention
240
+
241
+ ```
242
+ {type}-{module}-{name}
243
+
244
+ Examples:
245
+ page-system-user-list
246
+ page-system-user-detail
247
+ component-system-user-form
248
+ component-shared-delete-confirm
249
+ ```
250
+
251
+ ## Marker File Naming Convention
252
+
253
+ ```
254
+ {completed_dir}/{module}-{subpath}-{fileName}.graph.json
255
+ ```
256
+
257
+ **Naming Rule Explanation:**
258
+
259
+ The marker filename MUST follow the composite naming pattern `{module}-{subpath}-{fileName}` to prevent conflicts between same-named source files.
260
+
261
+ **How to Extract Each Component from `{{sourcePath}}`:**
262
+
263
+ 1. **module**: Use `{{module}}` input variable directly (e.g., `system`, `trade`, `bpm`)
264
+
265
+ 2. **subpath**: Extract the middle path between the platform source root and the file name:
266
+ - Remove the top-level directory prefix (e.g., `yudao-ui/yudao-ui-admin-vue3/src/views/`)
267
+ - Remove the file name at the end
268
+ - Replace path separators (`/`) with hyphens (`-`)
269
+ - If the file is at the module root directory, subpath will be empty → omit from filename
270
+
271
+ 3. **fileName**: Use `{{fileName}}` input variable (file name WITHOUT extension)
272
+
273
+ **Examples:**
274
+
275
+ | sourcePath | module | subpath | fileName | Marker Filename |
276
+ |------------|--------|---------|----------|-----------------|
277
+ | `yudao-ui/.../system/notify/message/index.vue` | `system` | `notify-message` | `index` | `system-notify-message-index.graph.json` |
278
+ | `yudao-ui/.../system/user/index.vue` | `system` | `user` | `index` | `system-user-index.graph.json` |
279
+ | `yudao-ui/.../bpm/process-instance/index.vue` | `bpm` | `process-instance` | `index` | `bpm-process-instance-index.graph.json` |
280
+
281
+ **Special Case - Empty subpath:**
282
+ - If the file is directly in the module root directory: `{module}-{fileName}.graph.json`
283
+ - Example: `yudao-ui/.../system/index.vue` → `system-index.graph.json`
284
+
285
+ ## Edge Types Reference
286
+
287
+ | Edge Type | Direction | When to Create |
288
+ |-----------|-----------|----------------|
289
+ | `calls` | page → api | Page calls an API endpoint |
290
+ | `navigates-to` | page → page | Page navigates to another page |
291
+ | `uses` | page → component | Page uses a shared/local component |
292
+
293
+ ## API Coverage Verification Checklist
294
+
295
+ - [ ] List ALL imported API functions from the source file
296
+ - [ ] For each imported API, verify there is a corresponding `calls` edge
297
+ - [ ] Check event handlers for API calls
298
+ - [ ] Check lifecycle hooks for initialization API calls
299
+ - [ ] Check status toggles, action buttons for special operation APIs
300
+ - [ ] Verify no imported API is left unmapped
301
+
302
+ ## Pre-write Verification Checklist
303
+
304
+ ### Graph JSON Verification:
305
+ - [ ] Filename follows `{module}-{subpath}-{fileName}.graph.json` pattern
306
+ - [ ] JSON is valid (no trailing commas, all strings quoted)
307
+ - [ ] Root-level `module` field is present
308
+ - [ ] `nodes` and `edges` are arrays
309
+ - [ ] ALL imported API functions are represented as `calls` edges
310
+
311
+ ### Completion Marker Verification:
312
+ - [ ] Filename follows `{module}-{subpath}-{fileName}.graph-done.json` pattern
313
+ - [ ] JSON is valid
314
+ - [ ] `fileName` does NOT contain file extension
315
+ - [ ] `sourceFile` matches `features-{platform}.json` pattern
316
+ - [ ] `module` field is present and non-empty
317
+ - [ ] `documentPath` is `"N/A"` when no document exists (not empty string)
318
+ - [ ] `nodeCount` and `edgeCount` match actual graph data
319
+
320
+ ## Constraints
321
+
322
+ 1. **100% API coverage** - ALL imported API functions MUST be represented as `calls` edges
323
+ 2. **Valid JSON format** - Both `.graph.json` and `.graph-done.json` MUST be valid JSON
324
+ 3. **Root-level module field** - `.graph.json` MUST include `module` at root level
325
+ 4. **Correct filename pattern** - Use `{module}-{subpath}-{fileName}` composite naming
326
+ 5. **No file extension in fileName** - The `fileName` field in `.graph-done.json` MUST NOT include extension
327
+ 6. **documentPath as N/A** - Use `"N/A"` when no document exists, never empty string
328
+
329
+ ## Task Completion Report
330
+
331
+ When the task is complete, report the following:
332
+
333
+ **Status:** `success` | `partial` | `failed`
334
+
335
+ **Summary:**
336
+ - Feature: `{{fileName}}`
337
+ - Module: `{{module}}`
338
+ - Nodes constructed: `{{nodeCount}}`
339
+ - Edges constructed: `{{edgeCount}}`
340
+
341
+ **Files Generated:**
342
+ - `{{completed_dir}}/{marker-filename}.graph.json`
343
+ - `{{completed_dir}}/{marker-filename}.graph-done.json`