@edupia-tutor/spec-driven-docs 0.14.7 → 0.14.8

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 (79) hide show
  1. package/commands/generate-bdd.md +59 -4
  2. package/commands/generate-bdd.tmpl +59 -4
  3. package/commands/generate-code.md +18 -1
  4. package/commands/generate-code.tmpl +18 -1
  5. package/commands/generate-design-spec.md +35 -5
  6. package/commands/generate-design-spec.tmpl +35 -5
  7. package/commands/generate-prd.md +7 -4
  8. package/commands/generate-tech-docs.md +1 -0
  9. package/commands/generate-tech-docs.tmpl +1 -0
  10. package/commands/propose-scenario.md +6 -2
  11. package/commands/propose-scenario.tmpl +6 -2
  12. package/commands/qc-analyze.md +14 -0
  13. package/commands/qc-analyze.tmpl +14 -0
  14. package/commands/refine-prd.md +15 -4
  15. package/commands/refine-prd.tmpl +15 -4
  16. package/commands/review-context.md +15 -11
  17. package/commands/review-context.tmpl +15 -11
  18. package/commands/validate-traces.md +1 -0
  19. package/commands/validate-traces.tmpl +1 -0
  20. package/core/FRAMEWORK_VERSION +1 -1
  21. package/core/commands/generate-bdd.md +59 -4
  22. package/core/commands/generate-code.md +18 -1
  23. package/core/commands/generate-design-spec.md +35 -5
  24. package/core/commands/generate-prd.md +7 -4
  25. package/core/commands/generate-tech-docs.md +1 -0
  26. package/core/commands/propose-scenario.md +6 -2
  27. package/core/commands/qc-analyze.md +14 -0
  28. package/core/commands/refine-prd.md +15 -4
  29. package/core/commands/review-context.md +15 -11
  30. package/core/commands/validate-traces.md +1 -0
  31. package/core/skills/code/SKILL.md +7 -759
  32. package/core/skills/debug/SKILL.md +9 -859
  33. package/core/skills/design-spec/SKILL.md +3 -582
  34. package/core/skills/prd/SKILL.md +5 -464
  35. package/core/skills/setup-ai-first/SKILL.md +3 -208
  36. package/core/skills/spec/SKILL.md +7 -450
  37. package/core/skills/test/SKILL.md +10 -1290
  38. package/core/steps/spawn-agent.md +12 -7
  39. package/core/templates/prd.template.md +7 -4
  40. package/docs/01-getting-started/core-concepts.md +2 -2
  41. package/docs/01-getting-started/quickstart.md +4 -3
  42. package/docs/02-guides/bdd-input-checklist.md +68 -0
  43. package/docs/02-guides/developer/README.md +3 -0
  44. package/docs/02-guides/developer/bdd-and-trace.md +1 -0
  45. package/docs/02-guides/developer/commands.md +3 -3
  46. package/docs/02-guides/developer/pr-checklist.md +1 -0
  47. package/docs/02-guides/developer/workflow.md +2 -2
  48. package/docs/02-guides/prd-input-checklist.md +94 -0
  49. package/docs/02-guides/product-owner/README.md +3 -1
  50. package/docs/02-guides/product-owner/commands.md +1 -1
  51. package/docs/02-guides/tech-docs-input-checklist.md +82 -0
  52. package/docs/02-guides/tester/README.md +1 -1
  53. package/docs/02-guides/tester/bug-reporting.md +1 -1
  54. package/docs/02-guides/tester/qc-automation.md +1 -1
  55. package/docs/03-concepts/README.md +1 -0
  56. package/docs/03-concepts/mechanisms-explained.md +34 -0
  57. package/docs/03-concepts/pipeline.md +12 -9
  58. package/docs/03-concepts/traceability.md +4 -1
  59. package/docs/04-operations/bug-flow.md +2 -0
  60. package/docs/05-reference/command-cheatsheet.md +8 -8
  61. package/docs/05-reference/commands.md +12 -10
  62. package/docs/05-reference/trace-schema.md +2 -1
  63. package/package.json +1 -1
  64. package/skills/code/SKILL.md +7 -759
  65. package/skills/code/SKILL.tmpl +7 -164
  66. package/skills/debug/SKILL.md +9 -859
  67. package/skills/debug/SKILL.tmpl +9 -252
  68. package/skills/design-spec/SKILL.md +3 -582
  69. package/skills/design-spec/SKILL.tmpl +3 -87
  70. package/skills/prd/SKILL.md +5 -464
  71. package/skills/prd/SKILL.tmpl +5 -63
  72. package/skills/setup-ai-first/SKILL.md +3 -208
  73. package/skills/setup-ai-first/SKILL.tmpl +3 -108
  74. package/skills/spec/SKILL.md +7 -450
  75. package/skills/spec/SKILL.tmpl +7 -162
  76. package/skills/test/SKILL.md +10 -1290
  77. package/skills/test/SKILL.tmpl +10 -288
  78. package/steps/spawn-agent.md +12 -7
  79. package/templates/prd.template.md +7 -4
@@ -2,295 +2,17 @@
2
2
  description: Sinh unit và integration test từ BDD spec, chạy test suite và report kết quả, hoặc dev-smoke-test các API endpoint live trên service đang chạy. Trigger when: "/dev-gen-test", "/dev-run-test", "/dev-smoke-test", "tạo test", "viết test", "chạy test", "generate tests", "run tests", "test kết quả", "smoke test", "test API", "kiểm tra endpoint đang chạy".
3
3
  ---
4
4
 
5
- # Test Skills — Generate, Run & Smoke Test
5
+ # Test Skills — Generate, Run & Smoke (Dev Self-Check)
6
6
 
7
- Skill này xử lý ba lệnh: `/dev-gen-test`, `/dev-run-test`, `/dev-smoke-test`.
7
+ Skill này xử lý `/dev-gen-test`, `/dev-run-test`, `/dev-smoke-test` — **dev self-check** (`dev_selftest`), KHÔNG phải QC chính thức (`/qc-*`). Để **không lệch**, skill KHÔNG nhân bản — mỗi lệnh thực thi **y hệt** command.
8
8
 
9
- ---
10
-
11
- ## /dev-gen-test — Generate Unit & Integration Tests
12
-
13
- ### Gate
14
-
15
- <!-- Directory: specs/*/*/bdd/*.feature — or pass UC-ID/class path as argument -->
16
- {{include:steps/gate.md}}
17
-
18
- Cũng đọc:
19
- - File `.feature` để hiểu các behavior kỳ vọng
20
- - Tìm file cần test: Controller có `@trace.implements={UC-ID}`, Service implementation, Facade implementation (nếu áp dụng)
21
-
22
- ### CHECKPOINT — Test Plan
23
-
24
- Trước khi sinh, trình bày plan:
25
-
26
- ```
27
- Test Plan — {UC-ID}:
28
-
29
- Unit Tests ({unit test framework}):
30
- - {ServiceName}ServiceImplTest
31
- • {method}: {scenario} → {expected result}
32
- - {FacadeName}FacadeImplTest (if applicable)
33
- • {method}: {scenario} → {expected result}
34
-
35
- Integration Tests:
36
- - {ControllerName}ControllerTest
37
- • {endpoint}: {scenario} → HTTP {status}
38
-
39
- Total: {N} test classes, ~{M} test cases
40
- Proceed? (Y/N)
41
- ```
42
-
43
- Chờ xác nhận.
44
-
45
- ### Generate
46
-
47
- #### Unit Test Template
48
-
49
- ```
50
- // @trace.verifies={UC-ID}
51
- // @trace.test_type=unit
52
- [Test class using your project's test framework]
53
-
54
- class {Resource}ServiceImplTest {
55
-
56
- // Mock dependencies
57
-
58
- @Test
59
- // "Should {expected outcome} when {condition}"
60
- void methodName_whenValid_shouldReturnExpected() {
61
- // Given — set up mocks and inputs
62
- // When — call the method under test
63
- // Then — assert results and verify interactions
64
- }
65
-
66
- @Test
67
- // "Should throw {Exception} when {resource} not found"
68
- void methodName_whenNotFound_shouldThrowException() {
69
- // Given — mock returns empty/null
70
- // When & Then — assert exception is thrown
71
- }
72
- }
73
- ```
74
-
75
- #### Integration Test Template (Controller/HTTP layer)
76
-
77
- ```
78
- // @trace.verifies={UC-ID}
79
- // @trace.test_type=integration
80
- [Integration test class for HTTP layer]
81
-
82
- class {Resource}ControllerTest {
83
-
84
- // Inject MockMvc or HTTP test client
85
- // MockBean/stub the Facade/Service
86
-
87
- @Test
88
- // "GET /v1/{resource} - should return 200 with data"
89
- void filter_shouldReturn200() {
90
- // Given — stub facade/service
91
- // When — perform HTTP GET
92
- // Then — assert status 200 and response body
93
- }
94
-
95
- @Test
96
- // "POST /v1/{resource} - should return 201 when valid"
97
- void create_shouldReturn201() {
98
- // Given — stub facade/service
99
- // When — perform HTTP POST with valid body
100
- // Then — assert status 201
101
- }
102
-
103
- @Test
104
- // "POST /v1/{resource} - should return 400 when invalid"
105
- void create_shouldReturn400WhenInvalid() {
106
- // Given — no stub needed
107
- // When — perform HTTP POST with missing required fields
108
- // Then — assert status 400
109
- }
110
- }
111
- ```
112
-
113
- ### File Placement
114
-
115
- Theo cấu trúc test của dự án từ CLAUDE.md. Điển hình:
116
- ```
117
- src/test/{language}/{package}/
118
- ├── service/impl/{Resource}ServiceImplTest.{ext}
119
- ├── facade/impl/{Resource}FacadeImplTest.{ext} (if applicable)
120
- └── controller/{Resource}ControllerTest.{ext}
121
- ```
122
-
123
- ### Self-Review Checklist
124
-
125
- - [ ] Tag `@trace.verifies` trên mỗi test class
126
- - [ ] Mỗi scenario trong .feature có ít nhất một test
127
- - [ ] Chỉ mock đúng layer (không mock repo trong controller test)
128
- - [ ] Test name theo pattern `methodName_whenCondition_shouldOutcome`
129
- - [ ] Không có debug print trong test
130
-
131
- ### Output
132
-
133
- ```
134
- /dev-gen-test Complete — {UC-ID}:
135
- ✅ service/{Service}Test.{ext} ({M} tests)
136
- ✅ facade/{Facade}Test.{ext} ({M} tests)
137
- ✅ controller/{Controller}Test.{ext} ({M} tests)
138
- ```
139
-
140
- {{include:steps/report-footer.md}}
141
-
142
- ---
143
-
144
- ## /dev-run-test — Run Tests & Report Results
145
-
146
- ### Gate
147
-
148
- {{include:steps/context-loader.md}}
149
-
150
- Xác định service/module từ argument (UC-ID hoặc tên service).
151
- Đọc `conventions.test_command` từ project context đã nạp.
152
-
153
- ### Run
154
-
155
- ```bash
156
- # Run all tests in module
157
- {TEST_COMMAND}
158
-
159
- # Run specific test class (faster)
160
- {TEST_COMMAND_FOR_CLASS}
161
-
162
- # Run by pattern
163
- {TEST_COMMAND_BY_PATTERN}
164
- ```
165
-
166
- ### Analyze Results
167
-
168
- #### Khi test PASS
169
-
170
- ```
171
- ✅ Tests passed
172
- - Total: {N}
173
- - Passed: {N}
174
- - Duration: {X}s
175
- ```
176
-
177
- #### Khi test FAIL — Debug Mode
178
-
179
- Đọc stack trace và phân tích:
180
-
181
- | Error Pattern | Nguyên nhân thường gặp | Suggested Fix |
182
- |---|---|---|
183
- | NullPointerException trong test | Thiếu setup mock | Kiểm tra setup `given(...)` cho dependency null |
184
- | Bean/dependency not found | Thiếu khai báo mock/stub | Thêm mock cho dependency thiếu |
185
- | Expected 200 but got 403 | Thiếu setup auth trong test | Thêm auth user/role vào test context |
186
- | Expected 200 but got 400 | Request body fail validation | Kiểm tra field bắt buộc trong request DTO |
187
- | LazyInitializationException | Lazy collection truy cập ngoài transaction | Thêm `@Transactional` trên test hoặc dùng eager fetch |
188
- | Mapper/mapper implementation not found | Code generator (vd MapStruct) chưa chạy | Chạy compile trước khi test |
189
-
190
- ### Output
191
-
192
- ```
193
- /dev-run-test Report — {service}
194
- Run at: {datetime}
195
-
196
- ## Summary
197
- ✅ Passed: {N} | ❌ Failed: {M} | ⏭️ Skipped: {K}
198
- Duration: {X}s
199
-
200
- ## Failed Tests
201
- | Test | Error | Root Cause |
202
- |------|-------|-----------|
203
- | {TestClass}.{method} | {exception} | {analysis} |
204
-
205
- ## Recommendations
206
- {specific fix for each failure}
207
- ```
208
-
209
- {{include:steps/report-footer.md}}
210
-
211
- ---
212
-
213
- ## /dev-smoke-test — Test Live API Endpoints
214
-
215
- Dùng khi service **đang chạy sẵn** để verify endpoint hoạt động đúng.
216
- Khác `/dev-run-test` (chạy unit/integration test không cần live server).
217
-
218
- ### Phase 1 — Find Service URL
219
-
220
- {{include:steps/context-loader.md}}
221
-
222
- Đọc `conventions.service_run` từ project context đã nạp để tìm port.
223
- Default: `http://localhost:8080`
224
-
225
- Kiểm tra service đang chạy:
226
- ```bash
227
- curl -s http://localhost:{port}/health
228
- # or /actuator/health for Spring Boot
229
- ```
230
-
231
- Nếu chưa chạy: "Service is not running. Start it with: `{RUN_COMMAND}` from your project root."
232
-
233
- ### Phase 2 — Identify Endpoints
234
-
235
- Từ UC-ID → tìm Controller có `@trace.implements={UC-ID}`:
236
- - Liệt kê: method, path, auth/role bắt buộc
237
-
238
- ### Phase 3 — Get Auth Token (nếu cần)
239
-
240
- Nếu endpoint yêu cầu auth, hỏi:
241
- ```
242
- This endpoint requires authentication. Options:
243
- 1. Paste your Bearer token (from Postman / browser DevTools / test login)
244
- 2. Use a test/dev token from your local config
245
- 3. Skip auth — only test public endpoints
246
- ```
247
-
248
- ### Phase 4 — Run Smoke Test
249
-
250
- ```bash
251
- # GET
252
- curl -s -X GET "http://localhost:{port}/v1/{resource}?page=0&size=5" \
253
- -H "Authorization: Bearer {token}" | {JSON_FORMATTER}
254
-
255
- # POST
256
- curl -s -X POST "http://localhost:{port}/v1/{resource}" \
257
- -H "Authorization: Bearer {token}" \
258
- -H "Content-Type: application/json" \
259
- -d '{"field1": "test_value"}'
260
- ```
261
-
262
- ### Phase 5 — Interpret Results
263
-
264
- | Result | Ý nghĩa |
265
- |--------|---------|
266
- | 200/201 + đúng data | ✅ OK |
267
- | 200 + sai data | ⚠️ Logic bug → dùng `/debug` |
268
- | 400 | Request body sai → kiểm tra field bắt buộc |
269
- | 401 | Token hết hạn hoặc sai realm |
270
- | 403 | Sai role → kiểm tra auth config |
271
- | 500 + stacktrace | Server error → dán vào `/debug` |
272
- | Connection refused | Service chưa chạy hoặc sai port |
273
-
274
- Nếu có lỗi trong log:
275
- ```bash
276
- tail -n 100 {LOG_FILE_PATH}
277
- ```
278
-
279
- ### Output
280
-
281
- ```
282
- /dev-smoke-test Report — {UC-ID}
283
- Tested at: {datetime}
284
- Base URL: http://localhost:{port}
285
-
286
- ## Endpoints Tested
287
- | Method | Path | Status | Result |
288
- |--------|------|--------|--------|
289
- | GET | /v1/{resource} | 200 ✅ | 5 records returned |
290
- | POST | /v1/{resource} | 201 ✅ | Created id=42 |
9
+ ## /dev-gen-test — Sinh test dev self-check
10
+ → **Đọc và tuân theo `commands/dev-gen-test.md`** với cùng `$ARGUMENTS`.
291
11
 
292
- ## Issues Found
293
- {describe any failures}
294
- ```
12
+ ## /dev-run-test — Chạy test & ghi `dev_selftest`
13
+ **Đọc và tuân theo `commands/dev-run-test.md`** với cùng `$ARGUMENTS`.
14
+ (Command lo: bảng phân tích lỗi theo platform · ghi `dev_selftest`/`dev_selftest_at` vào trace TSV.)
295
15
 
296
- {{include:steps/report-footer.md}}
16
+ ## /dev-smoke-test — Smoke test service/app đang chạy
17
+ → **Đọc và tuân theo `commands/dev-smoke-test.md`** với cùng `$ARGUMENTS`.
18
+ (Command lo: flow theo từng platform — backend curl/health · web E2E Playwright/Cypress · mobile device/emulator · LLM pipeline.)
@@ -71,14 +71,18 @@ Dựng payload và gọi Agent tool cho từng UC:
71
71
  ```json
72
72
  {
73
73
  "_agent_mode": true,
74
- "command": "generate-bdd",
75
- "uc_id": "{TICKET-ID}-UC{N}",
76
- "target_file": "{đường dẫn tuyệt đối tới PRD hoặc feature file}",
77
- "uc_section": { "line_start": {N}, "line_end": {N} },
78
- "context": { "<context gọn từ Bước A>" }
74
+ "command": "generate-bdd",
75
+ "uc_id": "{TICKET-ID}-UC{N}",
76
+ "target_file": "{đường dẫn tuyệt đối tới PRD hoặc feature file}",
77
+ "uc_section": { "line_start": {N}, "line_end": {N} },
78
+ "context": { "<context gọn từ Bước A>" },
79
+ "active_platform": "{web|app|system — platform orchestrator đã chọn ở Platform Selection}",
80
+ "design_coverage": { "<Screen States + AC-UI behavioral orchestrator đã trích ở 'Design Spec — Gate & Load' (B1); rỗng nếu BE / không có design-spec>" }
79
81
  }
80
82
  ```
81
83
 
84
+ > **Truyền state orchestrator đã phân giải (quan trọng):** orchestrator (session chính) đã chạy các Guard + chọn platform + nạp design-spec MỘT LẦN *trước* khi spawn. Phải kèm `active_platform` và `design_coverage` vào payload để sub-agent áp đúng (đặc biệt phủ Screen States + AC-UI cho FE/App). KHÔNG kèm → sub-agent sinh BDD thiếu phần design (PRD lớn mất B1).
85
+
82
86
  > **Phạm vi lệnh**: Chỉ `/generate-bdd` khởi động chế độ orchestration. `/generate-code` và `/dev-gen-test` có thể chạy như sub-agent (chúng tôn trọng `_agent_mode: true` từ Gate Bước 0), nhưng không spawn thêm sub-agent — phạm vi của chúng vốn đã là một UC duy nhất.
83
87
 
84
88
  Serialize JSON này và truyền làm `$ARGUMENTS` khi gọi lệnh sub-agent.
@@ -108,8 +112,9 @@ Khi `gate.md Bước 0` phát hiện `_agent_mode: true`:
108
112
  2. **Bỏ qua context-loader.md** — dùng trực tiếp `payload.context`
109
113
  3. **Chỉ giới hạn ở `payload.uc_id`** — không xử lý các UC khác trong file
110
114
  4. Chỉ đọc section PRD giữa `payload.uc_section.line_start` và `line_end`
111
- 5. Thực thi logic thường của lệnh cho riêng UC này
112
- 6. Trả về JSON kết quả cấu trúc (định dạng Bước E trên)
115
+ 5. **Dùng state orchestrator đã phân giải:** `active_platform` = `payload.active_platform`; `design_coverage` = `payload.design_coverage`. **KHÔNG chạy lại** các Guard (PRD approved / Design-Spec) hay tự nạp lại design-spec / hỏi platform — orchestrator đã làm một lần ở session chính.
116
+ 6. Thực thi logic thường của lệnh cho riêng UC này (dùng `design_coverage` từ payload để phủ Screen States + AC-UI)
117
+ 7. Trả về JSON kết quả có cấu trúc (định dạng Bước E ở trên)
113
118
 
114
119
  ---
115
120
 
@@ -197,11 +197,14 @@ _(Nếu không có độ vênh: ghi "Không có — toàn bộ nội dung đã
197
197
 
198
198
  # Change Log
199
199
 
200
- ### v1.0 {mô tả} ({date})
200
+ > Hiện tại: **v1.0** ({date}) · Lịch sử đầy đủ → [changelog](./changelog/{TICKET}-{N}-{slug}.changelog.md) *(file kho chỉ tạo khi changelog vượt 5 version)*
201
201
 
202
- | Mục | Thay đổi |
203
- |-----|----------|
204
- | — | Bản đầu — sinh từ product-definition. |
202
+ <!-- Bảng phẳng, MỘT dòng/version, MỚI NHẤT TRÊN CÙNG. Chỉ giữ tối đa 5 version gần nhất ở đây;
203
+ cũ hơn → /refine-prd & /review-context tự dồn (rollover) sang file changelog/ ở link trên. -->
204
+
205
+ | Version | Date | Changes (UC/AC/BR bị ảnh hưởng) |
206
+ |---------|------|---------------------------------|
207
+ | 1.0 | {date} | Bản đầu — sinh từ product-definition. |
205
208
 
206
209
  ---
207
210