speccrew 0.5.13 → 0.5.16

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 (21) hide show
  1. package/.speccrew/agents/speccrew-team-leader.md +60 -4
  2. package/.speccrew/agents/speccrew-test-manager.md +361 -37
  3. package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/SKILL.md +63 -626
  4. package/.speccrew/skills/speccrew-knowledge-bizs-api-graph/SKILL.md +505 -0
  5. package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/SKILL.md +165 -31
  6. package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/SKILL.md +63 -728
  7. package/.speccrew/skills/speccrew-knowledge-bizs-ui-graph/SKILL.md +389 -0
  8. package/.speccrew/skills/speccrew-knowledge-module-summarize/SKILL.md +26 -0
  9. package/.speccrew/skills/speccrew-knowledge-system-summarize/SKILL.md +27 -0
  10. package/.speccrew/skills/speccrew-knowledge-techs-dispatch/SKILL.md +185 -21
  11. package/.speccrew/skills/speccrew-knowledge-techs-generate/SKILL.md +134 -883
  12. package/.speccrew/skills/speccrew-knowledge-techs-generate-conventions/SKILL.md +36 -0
  13. package/.speccrew/skills/speccrew-knowledge-techs-generate-quality/SKILL.md +414 -0
  14. package/.speccrew/skills/speccrew-knowledge-techs-generate-ui-style/SKILL.md +35 -0
  15. package/.speccrew/skills/speccrew-test-reporter/SKILL.md +297 -0
  16. package/.speccrew/skills/{speccrew-test-execute → speccrew-test-reporter}/templates/BUG-REPORT-TEMPLATE.md +24 -1
  17. package/.speccrew/skills/{speccrew-test-execute → speccrew-test-reporter}/templates/TEST-REPORT-TEMPLATE.md +8 -1
  18. package/.speccrew/skills/{speccrew-test-execute → speccrew-test-runner}/SKILL.md +142 -104
  19. package/.speccrew/skills/speccrew-test-runner/templates/TEST-EXECUTION-RESULT-TEMPLATE.md +80 -0
  20. package/lib/utils.js +1 -0
  21. package/package.json +1 -1
@@ -0,0 +1,505 @@
1
+ ---
2
+ name: speccrew-knowledge-bizs-api-graph
3
+ description: Constructs knowledge graph data (nodes, edges, relationships) from API analysis results. Generates graph JSON files and completion markers for the bizs knowledge pipeline.
4
+ tools: Read, Write, Glob, Grep, Bash
5
+ ---
6
+
7
+ # API Knowledge Graph Constructor
8
+
9
+ > **CRITICAL CONSTRAINT**: DO NOT create temporary scripts, batch files, or workaround code files (`.py`, `.bat`, `.sh`, `.ps1`, etc.) under any circumstances. If execution encounters errors, STOP and report the exact error. Fixes must be applied to the Skill definition or source scripts — not patched at runtime.
10
+
11
+ Construct knowledge graph data structures (nodes and edges) from API analysis results. This skill transforms structured API documentation into graph JSON format for knowledge base integration.
12
+
13
+ ## Trigger Scenarios
14
+
15
+ - "Construct graph data from API analysis results"
16
+ - "Generate knowledge graph nodes and edges for API feature"
17
+ - "Write graph JSON for API controller"
18
+
19
+ ## Input Parameters
20
+
21
+ | Parameter | Required | Description | Example |
22
+ |-----------|----------|-------------|---------|
23
+ | `api_analysis_path` | Yes | Path to the API analysis document (from bizs-api-analyze) | `"speccrew-workspace/knowledges/bizs/admin-api/system/user/UserController.md"` |
24
+ | `platform_id` | Yes | Target platform identifier | `"admin-api"`, `"app-api"` |
25
+ | `output_dir` | Yes | Output directory for graph data | `"speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/completed"` |
26
+ | `module` | Yes | Business module name | `"system"`, `"trade"`, `"ai"` |
27
+ | `fileName` | Yes | Controller class name (without extension) | `"UserController"` |
28
+ | `sourcePath` | Yes | Relative path to source file | `"yudao-module-system/.../UserController.java"` |
29
+ | `sourceFile` | Yes | Source features JSON filename | `"features-admin-api.json"` |
30
+ | `language` | Yes | Target language for content | `"zh"`, `"en"` |
31
+ | `subpath` | No | Subpath extracted from sourcePath (for marker naming) | `"controller-admin-user"` |
32
+
33
+ ## Output Variables
34
+
35
+ | Variable | Type | Description |
36
+ |----------|------|-------------|
37
+ | `{{status}}` | string | Graph construction status: `"success"` or `"failed"` |
38
+ | `{{graph_file}}` | string | Path to the generated graph JSON file |
39
+ | `{{node_count}}` | integer | Number of nodes generated |
40
+ | `{{edge_count}}` | integer | Number of edges generated |
41
+
42
+ ## Execution Requirements
43
+
44
+ This skill operates in **strict sequential execution mode**:
45
+ - Execute steps in exact order (Step 1 → Step 2 → ... → Step 5)
46
+ - Output step status after each step completion
47
+ - Do NOT skip any step
48
+
49
+ ## Output
50
+
51
+ **Generated Files:**
52
+ 1. `{{output_dir}}/{module}-{subpath}-{fileName}.graph.json` - Graph data with nodes and edges
53
+ 2. `{{output_dir}}/{module}-{subpath}-{fileName}.graph-done.json` - Graph completion marker
54
+
55
+ **Return Value:**
56
+ ```json
57
+ {
58
+ "status": "success|failed",
59
+ "module": "{{module}}",
60
+ "fileName": "{{fileName}}",
61
+ "graphFile": "{{output_dir}}/{module}-{subpath}-{fileName}.graph.json",
62
+ "nodeCount": 15,
63
+ "edgeCount": 23,
64
+ "message": "Generated graph data with 15 nodes and 23 edges"
65
+ }
66
+ ```
67
+
68
+ ## Workflow
69
+
70
+ ```mermaid
71
+ graph TB
72
+ Start([Start]) --> Step1[Step 1 Read API Analysis Document]
73
+ Step1 --> Step2[Step 2 Extract Graph Nodes]
74
+ Step2 --> Step3[Step 3 Extract Graph Edges]
75
+ Step3 --> Step4[Step 4 Write Graph JSON]
76
+ Step4 --> Step5[Step 5 Write Graph Completion Marker]
77
+ Step5 --> Step6[Step 6 Report Results]
78
+ Step6 --> End([End])
79
+ ```
80
+
81
+ ---
82
+
83
+ ### Step 1: Read API Analysis Document
84
+
85
+ **Step 1 Status: 🔄 IN PROGRESS**
86
+
87
+ **Actions:**
88
+
89
+ 1. **Read the API analysis document** from `{{api_analysis_path}}`
90
+
91
+ 2. **Parse the document structure** to extract:
92
+ - API endpoints (method, path, description)
93
+ - Service references
94
+ - Database tables accessed
95
+ - DTOs used
96
+ - Business rules and permissions
97
+
98
+ 3. **Validate required information** is present for graph construction
99
+
100
+ **Output:** "Step 1 Status: ✅ COMPLETED - Read {{api_analysis_path}} ({{lineCount}} lines), Found {{endpointCount}} endpoints"
101
+
102
+ ---
103
+
104
+ ### Step 2: Extract Graph Nodes
105
+
106
+ **Step 2 Status: 🔄 IN PROGRESS**
107
+
108
+ Based on the API analysis document, extract graph nodes for each entity type.
109
+
110
+ **Node Types to Extract:**
111
+
112
+ | Node Type | Source | ID Format | Context Fields |
113
+ |-----------|--------|-----------|----------------|
114
+ | `api` | Each public API endpoint | `api-{module}-{name}` | `method`, `path`, `params`, `tables`, `permissions` |
115
+ | `service` | Each injected service | `service-{module}-{name}` | `methods`, `dependencies` |
116
+ | `table` | Each database table accessed | `table-{module}-{tableName}` | `fields`, `indexes`, `engine` |
117
+ | `dto` | Each request/response DTO | `dto-{module}-{name}` | `fields`, `validation` |
118
+
119
+ **Node ID Naming Convention:**
120
+ ```
121
+ {type}-{module}-{name}
122
+
123
+ Examples:
124
+ api-system-user-list
125
+ api-system-user-create
126
+ service-system-user-service
127
+ table-system-system_user
128
+ dto-system-user-create-req
129
+ ```
130
+
131
+ **Node Structure:**
132
+ ```json
133
+ {
134
+ "id": "api-{module}-{endpoint-name}",
135
+ "type": "api",
136
+ "name": "<display name>",
137
+ "module": "{{module}}",
138
+ "sourcePath": "{{sourcePath}}",
139
+ "documentPath": "{{api_analysis_path}}",
140
+ "description": "...",
141
+ "metadata": {
142
+ "method": "GET",
143
+ "path": "/admin-api/system/user/page",
144
+ "permissions": ["system:user:query"]
145
+ }
146
+ }
147
+ ```
148
+
149
+ **Service Node Example:**
150
+ ```json
151
+ {
152
+ "id": "service-{module}-{service-name}",
153
+ "type": "service",
154
+ "name": "UserService",
155
+ "module": "{{module}}",
156
+ "sourcePath": "relative/path/to/UserService.java",
157
+ "description": "User business logic service",
158
+ "metadata": {
159
+ "methods": ["getUserPage", "createUser", "updateUser"]
160
+ }
161
+ }
162
+ ```
163
+
164
+ **Table Node Example:**
165
+ ```json
166
+ {
167
+ "id": "table-{module}-{table-name}",
168
+ "type": "table",
169
+ "name": "system_user",
170
+ "module": "{{module}}",
171
+ "sourcePath": "",
172
+ "description": "User table",
173
+ "metadata": {
174
+ "fields": ["id", "username", "password", "status"],
175
+ "indexes": ["idx_username"]
176
+ }
177
+ }
178
+ ```
179
+
180
+ **DTO Node Example:**
181
+ ```json
182
+ {
183
+ "id": "dto-{module}-{dto-name}",
184
+ "type": "dto",
185
+ "name": "UserCreateReqVO",
186
+ "module": "{{module}}",
187
+ "sourcePath": "relative/path/to/UserCreateReqVO.java",
188
+ "description": "Create user request DTO",
189
+ "metadata": {
190
+ "fields": ["username", "password", "nickname"],
191
+ "validation": ["@NotBlank username", "@Size(max=50) nickname"]
192
+ }
193
+ }
194
+ ```
195
+
196
+ **IMPORTANT:**
197
+ - `module` comes from `{{module}}` input variable
198
+ - `name` should be a short, readable slug derived from the entity name
199
+ - Each node must include `sourcePath` and `documentPath` (if applicable)
200
+ - Convert class names to kebab-case for node IDs (e.g., `UserService` → `user-service`)
201
+
202
+ **Output:** "Step 2 Status: ✅ COMPLETED - Extracted {{nodeCount}} graph nodes ({{apiCount}} APIs, {{serviceCount}} services, {{tableCount}} tables, {{dtoCount}} DTOs)"
203
+
204
+ ---
205
+
206
+ ### Step 3: Extract Graph Edges
207
+
208
+ **Step 3 Status: 🔄 IN PROGRESS**
209
+
210
+ Based on the API analysis document, extract graph edges representing relationships between nodes.
211
+
212
+ **Edge Types to Extract:**
213
+
214
+ | Edge Type | Direction | When to Create |
215
+ |-----------|-----------|----------------|
216
+ | `operates` | api → table | API endpoint reads/writes a database table |
217
+ | `invokes` | api → service | Controller calls a service method |
218
+ | `references` | api → dto | API endpoint uses a request/response DTO |
219
+ | `depends-on` | service → service | Service depends on another service |
220
+ | `maps-to` | dto → table | DO/Entity maps to database table |
221
+
222
+ **Edge Structure:**
223
+ ```json
224
+ {
225
+ "source": "api-system-user-create",
226
+ "target": "table-system-system_user",
227
+ "type": "operates",
228
+ "metadata": {
229
+ "operation": "INSERT",
230
+ "description": "Create new user record"
231
+ }
232
+ }
233
+ ```
234
+
235
+ **Edge Examples:**
236
+
237
+ 1. **API → Table (operates):**
238
+ ```json
239
+ {
240
+ "source": "api-system-user-list",
241
+ "target": "table-system-system_user",
242
+ "type": "operates",
243
+ "metadata": {
244
+ "operation": "SELECT",
245
+ "description": "Query user list with pagination"
246
+ }
247
+ }
248
+ ```
249
+
250
+ 2. **API → Service (invokes):**
251
+ ```json
252
+ {
253
+ "source": "api-system-user-create",
254
+ "target": "service-system-user-service",
255
+ "type": "invokes",
256
+ "metadata": {
257
+ "method": "createUser",
258
+ "description": "Create user business logic"
259
+ }
260
+ }
261
+ ```
262
+
263
+ 3. **API → DTO (references):**
264
+ ```json
265
+ {
266
+ "source": "api-system-user-create",
267
+ "target": "dto-system-user-create-req",
268
+ "type": "references",
269
+ "metadata": {
270
+ "usage": "request",
271
+ "description": "Create user request body"
272
+ }
273
+ }
274
+ ```
275
+
276
+ 4. **Service → Service (depends-on):**
277
+ ```json
278
+ {
279
+ "source": "service-system-user-service",
280
+ "target": "service-system-permission-service",
281
+ "type": "depends-on",
282
+ "metadata": {
283
+ "description": "User service depends on permission service for role checks"
284
+ }
285
+ }
286
+ ```
287
+
288
+ 5. **DTO → Table (maps-to):**
289
+ ```json
290
+ {
291
+ "source": "dto-system-user-do",
292
+ "target": "table-system-system_user",
293
+ "type": "maps-to",
294
+ "metadata": {
295
+ "description": "UserDO maps to system_user table"
296
+ }
297
+ }
298
+ ```
299
+
300
+ **Output:** "Step 3 Status: ✅ COMPLETED - Extracted {{edgeCount}} graph edges"
301
+
302
+ ---
303
+
304
+ ### Step 4: Write Graph JSON
305
+
306
+ **Step 4 Status: 🔄 IN PROGRESS**
307
+
308
+ Write the complete graph data to JSON file.
309
+
310
+ **Marker File Naming Convention:**
311
+ ```
312
+ {output_dir}/{module}-{subpath}-{fileName}.graph.json
313
+ ```
314
+
315
+ **How to Extract Each Component:**
316
+
317
+ 1. **module**: Use `{{module}}` input variable directly (e.g., `system`, `trade`, `ai`)
318
+
319
+ 2. **subpath**: Extract from `{{sourcePath}}`:
320
+ - For Java: Remove package prefix up to the business layer (e.g., `controller/admin/`, `controller/app/`)
321
+ - Remove the file name at the end
322
+ - Replace path separators (`/`) with hyphens (`-`)
323
+ - If the file is at module root, subpath will be empty → omit from filename
324
+
325
+ 3. **fileName**: Use `{{fileName}}` input variable (class name WITHOUT extension)
326
+
327
+ **Examples:**
328
+
329
+ | sourcePath | module | subpath | fileName | Marker Filename |
330
+ |------------|--------|---------|----------|-----------------|
331
+ | `yudao-module-system/.../controller/admin/notify/NotifyMessageController.java` | `system` | `controller-admin-notify` | `NotifyMessageController` | `system-controller-admin-notify-NotifyMessageController.graph.json` |
332
+ | `yudao-module-system/.../controller/admin/user/UserController.java` | `system` | `controller-admin-user` | `UserController` | `system-controller-admin-user-UserController.graph.json` |
333
+ | `yudao-module-ai/.../controller/admin/chat/ChatConversationController.java` | `ai` | `controller-admin-chat` | `ChatConversationController` | `ai-controller-admin-chat-ChatConversationController.graph.json` |
334
+
335
+ **CRITICAL - API Endpoint Coverage Check:**
336
+ Before writing the graph.json file, verify:
337
+ - [ ] ALL public API endpoint methods in the controller are represented as `api` nodes
338
+ - [ ] Status update endpoints (updateStatus, toggleEnable) are included
339
+ - [ ] Special operation endpoints (resetPassword, export, import, batch operations) are included
340
+ - [ ] Each `api` node has proper metadata with HTTP method and path
341
+ - [ ] No public endpoint method is left without a corresponding node
342
+
343
+ **Pre-write Verification (MUST check before writing):**
344
+ - [ ] Root-level `module` field is present (MANDATORY)
345
+ - [ ] `nodes` and `edges` are arrays (can be empty)
346
+ - [ ] Valid JSON (no trailing commas, all strings quoted)
347
+ - [ ] All node IDs are unique
348
+ - [ ] All edge source/target references point to valid node IDs
349
+
350
+ **Complete JSON Template:**
351
+ ```json
352
+ {
353
+ "module": "{{module}}",
354
+ "nodes": [
355
+ {
356
+ "id": "api-{module}-{endpoint-name}",
357
+ "type": "api",
358
+ "name": "<display name>",
359
+ "module": "{{module}}",
360
+ "sourcePath": "{{sourcePath}}",
361
+ "documentPath": "{{api_analysis_path}}",
362
+ "description": "...",
363
+ "metadata": {
364
+ "method": "GET",
365
+ "path": "/admin-api/system/user/page",
366
+ "permissions": ["system:user:query"]
367
+ }
368
+ }
369
+ ],
370
+ "edges": [
371
+ {
372
+ "source": "api-...",
373
+ "target": "service-...",
374
+ "type": "invokes",
375
+ "metadata": { ... }
376
+ }
377
+ ]
378
+ }
379
+ ```
380
+
381
+ **⚠️ CRITICAL - Module Field Requirement:**
382
+ - The `.graph.json` file **MUST** have a root-level `module` field
383
+ - Do NOT assume scripts will fall back to reading from `.done` file
384
+ - Missing `module` field will cause the graph merge pipeline to reject this file
385
+
386
+ **⚠️ CRITICAL - Path Format:**
387
+ - `sourcePath` in nodes: Relative path (as-is from input)
388
+ - `documentPath` in nodes: Relative path (as-is from input)
389
+ - NEVER convert relative paths to absolute paths in JSON content
390
+
391
+ **Full Path Example:**
392
+ `d:/dev/speccrew/speccrew-workspace/knowledges/base/sync-state/knowledge-bizs/completed/system-controller-admin-user-UserController.graph.json`
393
+
394
+ **Output:** "Step 4 Status: ✅ COMPLETED - Graph JSON written to {{output_dir}}/{module}-{subpath}-{fileName}.graph.json ({{fileSize}} bytes)"
395
+
396
+ ---
397
+
398
+ ### Step 5: Write Graph Completion Marker
399
+
400
+ **Step 5 Status: 🔄 IN PROGRESS**
401
+
402
+ Write the `.graph-done.json` completion marker file to signal successful graph data generation.
403
+
404
+ **Marker File Path:**
405
+
406
+ ```
407
+ {output_dir}/{module}-{subpath}-{fileName}.graph-done.json
408
+ ```
409
+
410
+ **Marker JSON Structure:**
411
+
412
+ ```json
413
+ {
414
+ "fileName": "{{fileName}}",
415
+ "module": "{{module}}",
416
+ "marker": "graph_completed",
417
+ "graphFile": "{module}-{subpath}-{fileName}.graph.json",
418
+ "nodeCount": {{node_count}},
419
+ "edgeCount": {{edge_count}},
420
+ "status": "completed"
421
+ }
422
+ ```
423
+
424
+ **Field Descriptions:**
425
+
426
+ | Field | Description | Example |
427
+ |-------|-------------|---------|
428
+ | `fileName` | Feature file name WITHOUT extension | `"UserController"` |
429
+ | `module` | Business module name | `"system"` |
430
+ | `marker` | Fixed marker type | `"graph_completed"` |
431
+ | `graphFile` | Corresponding graph JSON filename | `"system-controller-admin-user-UserController.graph.json"` |
432
+ | `nodeCount` | Number of nodes in graph | `15` |
433
+ | `edgeCount` | Number of edges in graph | `23` |
434
+ | `status` | Completion status | `"completed"` |
435
+
436
+ **Pre-write Verification:**
437
+ - [ ] Filename follows `{module}-{subpath}-{fileName}.graph-done.json` pattern
438
+ - [ ] JSON is valid
439
+ - [ ] All required fields are present
440
+ - [ ] `nodeCount` and `edgeCount` match actual graph data
441
+
442
+ **Output:** "Step 5 Status: ✅ COMPLETED - Graph completion marker written to {{output_dir}}/{module}-{subpath}-{fileName}.graph-done.json"
443
+
444
+ ---
445
+
446
+ ### Step 6: Report Results
447
+
448
+ **Step 6 Status: 🔄 IN PROGRESS**
449
+
450
+ Return graph construction result summary to dispatch:
451
+
452
+ ```json
453
+ {
454
+ "status": "success",
455
+ "module": "{{module}}",
456
+ "fileName": "{{fileName}}",
457
+ "graphFile": "{{output_dir}}/{module}-{subpath}-{fileName}.graph.json",
458
+ "nodeCount": {{node_count}},
459
+ "edgeCount": {{edge_count}},
460
+ "message": "Generated graph data with {{node_count}} nodes and {{edge_count}} edges"
461
+ }
462
+ ```
463
+
464
+ Or in case of failure:
465
+
466
+ ```json
467
+ {
468
+ "status": "failed",
469
+ "module": "{{module}}",
470
+ "fileName": "{{fileName}}",
471
+ "message": "{{error_message}}"
472
+ }
473
+ ```
474
+
475
+ **Output:** "Step 6 Status: ✅ COMPLETED - Graph construction {{status}}: {{message}}"
476
+
477
+ ---
478
+
479
+ ## Constraints
480
+
481
+ 1. **Single Document Input**: This skill processes ONE API analysis document at a time
482
+ 2. **JSON Format**: All output files MUST be valid JSON
483
+ 3. **Module Field**: The root-level `module` field is MANDATORY in graph JSON
484
+ 4. **Node Uniqueness**: Each node ID must be unique within the graph
485
+ 5. **Edge Validity**: Edge source/target must reference existing node IDs
486
+ 6. **Path Format**: Use relative paths, NEVER absolute paths in JSON content
487
+
488
+ ## Node Type Reference
489
+
490
+ | Type | Description | Required Metadata |
491
+ |------|-------------|-------------------|
492
+ | `api` | API endpoint | `method`, `path`, `permissions` |
493
+ | `service` | Service class | `methods` |
494
+ | `table` | Database table | `fields`, `indexes` |
495
+ | `dto` | Data Transfer Object | `fields`, `validation` |
496
+
497
+ ## Edge Type Reference
498
+
499
+ | Type | Description | Source → Target |
500
+ |------|-------------|-----------------|
501
+ | `operates` | API operates on table | api → table |
502
+ | `invokes` | API calls service | api → service |
503
+ | `references` | API uses DTO | api → dto |
504
+ | `depends-on` | Service dependency | service → service |
505
+ | `maps-to` | DTO maps to table | dto → table |