@educa-corp/sdd-framework 0.4.0 → 0.5.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 (158) hide show
  1. package/bin/build.js +9 -0
  2. package/bin/index.js +115 -4
  3. package/bin/self-check.js +354 -0
  4. package/bin/trace-schema.json +1199 -0
  5. package/commands/debug.md +19 -12
  6. package/commands/define-product.md +19 -12
  7. package/commands/dev-gen-test.md +53 -19
  8. package/commands/dev-run-test.md +55 -20
  9. package/commands/dev-run-test.tmpl +2 -1
  10. package/commands/dev-smoke-test.md +19 -12
  11. package/commands/extend-prd.md +907 -0
  12. package/commands/extend-prd.tmpl +270 -0
  13. package/commands/fix-bug.md +101 -15
  14. package/commands/fix-bug.tmpl +29 -3
  15. package/commands/generate-architecture.md +19 -12
  16. package/commands/generate-bdd.md +174 -48
  17. package/commands/generate-bdd.tmpl +107 -18
  18. package/commands/generate-code.md +122 -29
  19. package/commands/generate-code.tmpl +69 -10
  20. package/commands/generate-design-spec.md +19 -12
  21. package/commands/generate-prd.md +44 -12
  22. package/commands/generate-prd.tmpl +25 -0
  23. package/commands/generate-spec-manifest.md +19 -12
  24. package/commands/generate-tech-docs.md +22 -15
  25. package/commands/generate-tech-docs.tmpl +2 -2
  26. package/commands/learn.md +19 -12
  27. package/commands/map-testids.md +19 -12
  28. package/commands/propose-scenario.md +91 -15
  29. package/commands/propose-scenario.tmpl +72 -3
  30. package/commands/qc-analyze.md +19 -12
  31. package/commands/qc-design-test.md +20 -12
  32. package/commands/qc-design-test.tmpl +1 -0
  33. package/commands/qc-plan.md +19 -12
  34. package/commands/qc-report.md +19 -12
  35. package/commands/qc-review.md +19 -12
  36. package/commands/qc-run-test.md +88 -22
  37. package/commands/qc-run-test.tmpl +35 -3
  38. package/commands/refine-prd.md +19 -12
  39. package/commands/report-bug.md +19 -12
  40. package/commands/review-code.md +60 -14
  41. package/commands/review-code.tmpl +41 -2
  42. package/commands/review-context.md +62 -16
  43. package/commands/review-context.tmpl +43 -4
  44. package/commands/review-tech-docs.md +50 -14
  45. package/commands/review-tech-docs.tmpl +31 -2
  46. package/commands/setup-ai-first.md +26 -16
  47. package/commands/setup-ai-first.tmpl +7 -4
  48. package/commands/sync.md +43 -18
  49. package/commands/sync.tmpl +37 -14
  50. package/commands/update-framework.md +43 -4
  51. package/commands/update-framework.tmpl +37 -0
  52. package/commands/validate-traces.md +481 -49
  53. package/commands/validate-traces.tmpl +462 -37
  54. package/core/FRAMEWORK_VERSION +1 -1
  55. package/core/README.md +56 -0
  56. package/core/commands/debug.md +19 -12
  57. package/core/commands/define-product.md +19 -12
  58. package/core/commands/dev-gen-test.md +53 -19
  59. package/core/commands/dev-run-test.md +55 -20
  60. package/core/commands/dev-smoke-test.md +19 -12
  61. package/core/commands/extend-prd.md +907 -0
  62. package/core/commands/fix-bug.md +101 -15
  63. package/core/commands/generate-architecture.md +19 -12
  64. package/core/commands/generate-bdd.md +174 -48
  65. package/core/commands/generate-code.md +122 -29
  66. package/core/commands/generate-design-spec.md +19 -12
  67. package/core/commands/generate-prd.md +44 -12
  68. package/core/commands/generate-spec-manifest.md +19 -12
  69. package/core/commands/generate-tech-docs.md +22 -15
  70. package/core/commands/learn.md +19 -12
  71. package/core/commands/map-testids.md +19 -12
  72. package/core/commands/propose-scenario.md +91 -15
  73. package/core/commands/qc-analyze.md +19 -12
  74. package/core/commands/qc-design-test.md +20 -12
  75. package/core/commands/qc-plan.md +19 -12
  76. package/core/commands/qc-report.md +19 -12
  77. package/core/commands/qc-review.md +19 -12
  78. package/core/commands/qc-run-test.md +88 -22
  79. package/core/commands/refine-prd.md +19 -12
  80. package/core/commands/report-bug.md +19 -12
  81. package/core/commands/review-code.md +60 -14
  82. package/core/commands/review-context.md +62 -16
  83. package/core/commands/review-tech-docs.md +50 -14
  84. package/core/commands/setup-ai-first.md +26 -16
  85. package/core/commands/sync.md +43 -18
  86. package/core/commands/update-framework.md +43 -4
  87. package/core/commands/validate-traces.md +481 -49
  88. package/core/modules/android-compose/stack-profile.yaml +1 -1
  89. package/core/modules/flutter/stack-profile.yaml +1 -1
  90. package/core/modules/ios-swiftui/stack-profile.yaml +1 -1
  91. package/core/modules/java-spring/stack-profile.yaml +1 -1
  92. package/core/modules/nextjs/stack-profile.yaml +1 -1
  93. package/core/modules/nuxt/stack-profile.yaml +1 -1
  94. package/core/modules/phaser-game/stack-profile.yaml +1 -1
  95. package/core/modules/php-laravel/stack-profile.yaml +1 -1
  96. package/core/modules/qc-playwright/stack-profile.yaml +1 -1
  97. package/core/modules/react/stack-profile.yaml +1 -1
  98. package/core/modules/react-native/stack-profile.yaml +1 -1
  99. package/core/modules/vue/stack-profile.yaml +1 -1
  100. package/core/rules/workflow.md +29 -0
  101. package/core/steps/gate.md +13 -8
  102. package/core/steps/report-footer.md +6 -4
  103. package/core/steps/trace-mirror.md +34 -7
  104. package/core/templates/README.md +47 -0
  105. package/core/templates/feature.template +14 -11
  106. package/core/templates/project-context.yaml +26 -14
  107. package/core/templates/tech-design.template.md +1 -1
  108. package/docs/01-getting-started/installation.md +18 -1
  109. package/docs/01-getting-started/what-is-sdd.md +4 -2
  110. package/docs/02-concepts/architecture.md +27 -3
  111. package/docs/02-concepts/pipeline-steps/02-specification.md +39 -3
  112. package/docs/02-concepts/pipeline-steps/04-bdd.md +24 -2
  113. package/docs/02-concepts/pipeline-steps/05-tech-docs.md +18 -1
  114. package/docs/02-concepts/pipeline-steps/06-code.md +35 -4
  115. package/docs/02-concepts/pipeline-steps/09-validate-traces.md +137 -12
  116. package/docs/02-concepts/pipeline-steps/10-feedback-loop.md +59 -3
  117. package/docs/02-concepts/roles-and-hitl.md +1 -1
  118. package/docs/02-concepts/traceability.md +126 -94
  119. package/docs/03-guides/developer.md +20 -4
  120. package/docs/03-guides/product-owner.md +72 -68
  121. package/docs/03-guides/tester-qa.md +81 -70
  122. package/docs/04-reference/commands.md +134 -105
  123. package/docs/04-reference/configuration.md +146 -94
  124. package/docs/04-reference/trace-schema.md +145 -37
  125. package/docs/explain/02-generate-prd.md +80 -78
  126. package/docs/explain/02b-extend-prd.md +125 -0
  127. package/docs/explain/03-refine-prd.md +86 -86
  128. package/docs/explain/04-review-context.md +18 -1
  129. package/docs/explain/06-generate-bdd.md +23 -0
  130. package/docs/explain/08-review-tech-docs.md +20 -5
  131. package/docs/explain/10-review-code.md +36 -2
  132. package/docs/explain/19-qc-run-test.md +87 -67
  133. package/docs/explain/21-validate-traces.md +74 -68
  134. package/docs/explain/23-fix-bug.md +19 -3
  135. package/docs/explain/26-propose-scenario.md +70 -63
  136. package/docs/explain/README.md +135 -134
  137. package/modules/android-compose/stack-profile.yaml +1 -1
  138. package/modules/flutter/stack-profile.yaml +1 -1
  139. package/modules/ios-swiftui/stack-profile.yaml +1 -1
  140. package/modules/java-spring/stack-profile.yaml +1 -1
  141. package/modules/nextjs/stack-profile.yaml +1 -1
  142. package/modules/nuxt/stack-profile.yaml +1 -1
  143. package/modules/phaser-game/stack-profile.yaml +1 -1
  144. package/modules/php-laravel/stack-profile.yaml +1 -1
  145. package/modules/qc-playwright/stack-profile.yaml +1 -1
  146. package/modules/react/stack-profile.yaml +1 -1
  147. package/modules/react-native/stack-profile.yaml +1 -1
  148. package/modules/vue/stack-profile.yaml +1 -1
  149. package/package.json +5 -4
  150. package/rules/workflow.md +29 -0
  151. package/scripts/migrate-bdd-platform.js +286 -0
  152. package/steps/gate.md +13 -8
  153. package/steps/report-footer.md +6 -4
  154. package/steps/trace-mirror.md +34 -7
  155. package/templates/README.md +47 -0
  156. package/templates/feature.template +14 -11
  157. package/templates/project-context.yaml +26 -14
  158. package/templates/tech-design.template.md +1 -1
@@ -1,105 +1,134 @@
1
- [← Docs Home](../README.md) · [Reference](./)
2
-
3
- # Reference · Commands — Bảng đầy đủ (Command Catalog)
4
-
5
- > 31 slash command, gom theo phase pipeline. Chi tiết cơ chế từng bước → [Pipeline Steps](../02-concepts/pipeline-steps/).
6
-
7
- Mọi lệnh chạy chung một **Gate** (model check → target → context-loader → checkpoint). Xem [Khung chung](../02-concepts/pipeline-steps/README.md#khung-chung-mọi-command-common-gate).
8
-
9
- ---
10
-
11
- ## 0 · Setup & Foundation
12
-
13
- | Lệnh | Input | Output | Owner |
14
- |------|-------|--------|-------|
15
- | `/setup-ai-first` | Dự án trống/có code | `.agent/`, `.claude/`, `project-context.yaml`, `CLAUDE.md` | Admin/Lead |
16
- | `/generate-architecture` | config + tài liệu (`--from`) + code | `architecture.md` (SSOT kiến trúc, theo tier) | SA/Lead |
17
-
18
- ## 1 · Discovery
19
-
20
- | Lệnh | Input | Output | Owner |
21
- |------|-------|--------|-------|
22
- | `/define-product` | Ý tưởng (+Figma) | `product-definition/*.md` (8 chặng) | PO |
23
-
24
- ## 2 · Specification (PRD)
25
-
26
- | Lệnh | Input | Output | Owner |
27
- |------|-------|--------|-------|
28
- | `/generate-prd` | product-definition | PRD draft | PO |
29
- | `/refine-prd` | PRD | Findings 3 lăng kính DEV/SA/PO | PO+SA+Dev |
30
- | `/review-context` (PRD) | PRD | Findings P0–P5 `Status: approved` | PO |
31
-
32
- ## 3 · Design-Spec (chỉ FE/App)
33
-
34
- | Lệnh | Input | Output | Owner |
35
- |------|-------|--------|-------|
36
- | `/generate-design-spec` | PRD approved + Figma | `design-spec/*.md` | PO/PM |
37
-
38
- ## 4 · BDD
39
-
40
- | Lệnh | Input | Output | Owner |
41
- |------|-------|--------|-------|
42
- | `/generate-bdd` | PRD approved (+design-spec) | `bdd/**/*.feature` | PO |
43
- | `/review-context` (BDD) | `.feature` | Findings B1–B6 → `@trace.status: approved` | PO/Dev |
44
-
45
- ## 5 · Tech-Docs
46
-
47
- | Lệnh | Input | Output | Owner |
48
- |------|-------|--------|-------|
49
- | `/generate-tech-docs` | BDD approved + entity catalog | `tech-docs/{TICKET}-tech-design.md` | SA |
50
- | `/review-tech-docs` | tech-design | Findings đa chiều + T7 | SA/Lead |
51
-
52
- ## 6 · Code
53
-
54
- | Lệnh | Input | Output | Owner |
55
- |------|-------|--------|-------|
56
- | `/generate-code` | `.feature` approved + tech-design | Code + `.trace/*.tsv` | Dev |
57
- | `/review-code` | Code | Findings (read-only) | Dev/Lead |
58
- | `/fix-bug` | Bug report | Fix + regression test | Dev |
59
- | `/map-testids` | UI code | testid map (FE) | Dev |
60
- | `/debug` | Mô tả lỗi | Phân tích (read-only) | Dev |
61
-
62
- ## 7 · Dev self-test
63
-
64
- | Lệnh | Input | Output | Owner |
65
- |------|-------|--------|-------|
66
- | `/dev-gen-test` | Code + `.feature` | Bộ self-test | Dev |
67
- | `/dev-run-test` | Self-test | Kết quả + cột `dev_selftest` | Dev |
68
- | `/dev-smoke-test` | Service/app đang chạy | Kết quả smoke tại chỗ | Dev |
69
-
70
- ## 8 · QC Automation
71
-
72
- | Lệnh | Input | Output | Owner |
73
- |------|-------|--------|-------|
74
- | `/qc-analyze` | UC + spec | `REQUIREMENT_ANALYSIS.md`, `DOC_GAPS.md` | QA |
75
- | `/qc-plan` | Analysis | `TEST_PLAN.md` (rủi ro) | QA |
76
- | `/qc-design-test` | Plan | `test-cases/*.Test.md` | QA |
77
- | `/qc-review` | Test case/script | 🛑 Cổng review | QA |
78
- | `/qc-run-test` | `.Test.md` reviewed | Script Playwright + `qc_status` | QA |
79
- | `/qc-report` | Kết quả run | Report + evidence + product-gap | QA |
80
-
81
- ## 9 · Quality & Trace
82
-
83
- | Lệnh | Input | Output | Owner |
84
- |------|-------|--------|-------|
85
- | `/validate-traces` | `.trace/*.tsv` + spec/code/test | Ma trận coverage (read-only) | Dev/QA/Lead |
86
- | `/generate-spec-manifest` | Specs | Mục lục spec cho agent ngoài | SA/Lead |
87
-
88
- ## 10 · Feedback & Ops
89
-
90
- | Lệnh | Input | Output | Owner |
91
- |------|-------|--------|-------|
92
- | `/report-bug` | Lỗi phát hiện | `feedback/bug-reports/` (spec-anchored) | Tester/QC |
93
- | `/propose-scenario` | Scenario thiếu | `feedback/bdd-proposals/` | Tester/QC |
94
- | `/learn` | Định hướng lặp lại | `project-lessons.md` | Tất cả |
95
- | `/sync` | (umbrella) | Pull + submodule + nổi feedback + Living Docs | Lead |
96
- | `/update-framework` | | Sync bản npm mới | Lead |
97
-
98
- ---
99
-
100
- ## hiệu trạng thái trong report
101
-
102
- - 🛑 checkpoint (dừng, chờ `Y`) · 🔒 gate trạng thái (chặn downstream) · read-only
103
- - ⚠️ cảnh báo mềm (không chặn) · pass · fail
104
-
105
- [Trace Schema](trace-schema.md) · [Modules](modules.md) · [Configuration](configuration.md) · [Model Selection](model-selection.md)
1
+ [← Docs Home](../README.md) · [Reference](./)
2
+
3
+ # Reference · Commands — Bảng đầy đủ (Command Catalog)
4
+
5
+ > 32 slash command, gom theo phase pipeline. Chi tiết cơ chế từng bước → [Pipeline Steps](../02-concepts/pipeline-steps/).
6
+
7
+ Mọi lệnh chạy chung một **Gate** (model check → target → context-loader → checkpoint). Xem [Khung chung](../02-concepts/pipeline-steps/README.md#khung-chung-mọi-command-common-gate).
8
+
9
+ ---
10
+
11
+ ## 0 · Setup & Foundation
12
+
13
+ | Lệnh | Input | Output | Owner |
14
+ |------|-------|--------|-------|
15
+ | `/setup-ai-first` | Dự án trống/có code | `.agent/`, `.claude/`, `project-context.yaml`, `CLAUDE.md` | Admin/Lead |
16
+ | `/generate-architecture` | config + tài liệu (`--from`) + code | `architecture.md` (SSOT kiến trúc, theo tier) | SA/Lead |
17
+
18
+ ## 1 · Discovery
19
+
20
+ | Lệnh | Input | Output | Owner |
21
+ |------|-------|--------|-------|
22
+ | `/define-product` | Ý tưởng (+Figma) | `product-definition/*.md` (8 chặng) | PO |
23
+
24
+ ## 2 · Specification (PRD)
25
+
26
+ | Lệnh | Input | Output | Owner |
27
+ |------|-------|--------|-------|
28
+ | `/generate-prd` | product-definition | PRD draft **mới** | PO |
29
+ | `/extend-prd` | **PRD đã có** + `feedback/prd-change-requests/` | PRD v+1 (UC/AC/BR nối tiếp, `Status → draft`) | PO |
30
+ | `/refine-prd` | PRD | Findings 3 lăng kính DEV/SA/PO | PO+SA+Dev |
31
+ | `/review-context` (PRD) | PRD | Findings P0–P5 → `Status: approved` | PO |
32
+
33
+ > **Chọn lệnh nào cho PRD:**
34
+ > - PRD **chưa tồn tại** `/generate-prd` (từ discovery). Nó **từ chối chạy** nếu file đã có.
35
+ > - PRD đã có, muốn **thêm** UC/AC/BR mới → `/extend-prd`. Đánh số **nối tiếp**, ghi **add-only** kèm guard sau-ghi, tăng version + changelog nêu rõ scope.
36
+ > - PRD đã có, muốn **sửa vấn đề** đã soi ra → `/refine-prd` Review Board → `--resume`.
37
+ >
38
+ > `/refine-prd` **không** thêm được yêu cầu mới (nó tự cấm đụng section ngoài findings). `/generate-prd` **không** dùng lại được trên PRD đã có (sẽ mất changelog + đánh số lại BR → hỏng `@trace.business_rules` trong BDD đã sinh).
39
+
40
+ ## 3 · Design-Spec (chỉ FE/App)
41
+
42
+ | Lệnh | Input | Output | Owner |
43
+ |------|-------|--------|-------|
44
+ | `/generate-design-spec` | PRD approved + Figma | `design-spec/*.md` | PO/PM |
45
+
46
+ ## 4 · BDD
47
+
48
+ | Lệnh | Input | Output | Owner |
49
+ |------|-------|--------|-------|
50
+ | `/generate-bdd` | PRD approved (+design-spec) | `bdd/**/*.feature` | PO |
51
+ | `/review-context` (BDD) | `.feature` | Findings B1–B6 → `@trace.status: approved` | PO/Dev |
52
+
53
+ ## 5 · Tech-Docs
54
+
55
+ | Lệnh | Input | Output | Owner |
56
+ |------|-------|--------|-------|
57
+ | `/generate-tech-docs` | BDD approved + entity catalog | `tech-docs/{TICKET}-tech-design.md` | SA |
58
+ | `/review-tech-docs` | tech-design | Findings đa chiều + T7 | SA/Lead |
59
+
60
+ ## 6 · Code
61
+
62
+ | Lệnh | Input | Output | Owner |
63
+ |------|-------|--------|-------|
64
+ | `/generate-code` | `.feature` approved + tech-design | Code + `.trace/*.tsv` | Dev |
65
+ | `/review-code` | Code | Findings (read-only) | Dev/Lead |
66
+ | `/fix-bug` | Bug report | Fix + regression test | Dev |
67
+ | `/map-testids` | UI code | testid map (FE) | Dev |
68
+ | `/debug` | tả lỗi | Phân tích (read-only) | Dev |
69
+
70
+ ## 7 · Dev self-test
71
+
72
+ | Lệnh | Input | Output | Owner |
73
+ |------|-------|--------|-------|
74
+ | `/dev-gen-test` | Code + `.feature` | Bộ self-test | Dev |
75
+ | `/dev-run-test` | Self-test | Kết quả + cột `dev_selftest` | Dev |
76
+ | `/dev-smoke-test` | Service/app đang chạy | Kết quả smoke tại chỗ | Dev |
77
+
78
+ ## 8 · QC Automation
79
+
80
+ | Lệnh | Input | Output | Owner |
81
+ |------|-------|--------|-------|
82
+ | `/qc-analyze` | UC + spec | `REQUIREMENT_ANALYSIS.md`, `DOC_GAPS.md` | QA |
83
+ | `/qc-plan` | Analysis | `TEST_PLAN.md` (rủi ro) | QA |
84
+ | `/qc-design-test` | Plan | `test-cases/*.Test.md` | QA |
85
+ | `/qc-review` | Test case/script | 🛑 Cổng review | QA |
86
+ | `/qc-run-test` | `.Test.md` reviewed | Script Playwright + `qc_status` | QA |
87
+ | `/qc-report` | Kết quả run | Report + evidence + product-gap | QA |
88
+
89
+ ## 9 · Quality & Trace
90
+
91
+ | Lệnh | Input | Output | Owner |
92
+ |------|-------|--------|-------|
93
+ | `/validate-traces` | `.trace/*.tsv` + spec/code/test | Ma trận coverage · `trace-report.json` · **`trace-history.jsonl`** (append) · đếm hàng đợi | Dev/QA/Lead |
94
+ | `/validate-traces --realign-prd-version {UC}` | cờ `PRD_STALE_REF` | Sửa **chỉ dòng `@trace.*`** — không đụng logic | Dev |
95
+ | `/validate-traces --realign-techdoc-revision {UC}` | cờ `TECHDOC_STALE_REF` | như trên | Dev |
96
+ | `/generate-spec-manifest` | Specs | Mục lục spec cho agent ngoài | SA/Lead |
97
+
98
+ ## 10 · Feedback & Ops
99
+
100
+ | Lệnh | Input | Output | Owner |
101
+ |------|-------|--------|-------|
102
+ | `/report-bug` | Lỗi phát hiện | `feedback/bug-reports/` (spec-anchored) | Tester/QC |
103
+ | `/propose-scenario` | Scenario thiếu | **A:** `feedback/bdd-proposals/` `/generate-bdd` chèn · **B:** `feedback/prd-change-requests/` → PO chạy `/extend-prd` | Tester/QC |
104
+ | `/learn` | Định hướng lặp lại | `project-lessons.md` | Tất cả |
105
+ | `/sync` | (umbrella) | Pull + submodule + nổi feedback + Living Docs | Lead |
106
+ | `/update-framework` | — | Sync bản npm mới | Lead |
107
+
108
+ ---
109
+
110
+ ## Ký hiệu trạng thái trong report
111
+
112
+ - 🛑 checkpoint (dừng, chờ `Y`) · 🔒 gate trạng thái (chặn downstream) · ⚪ read-only
113
+ - ⚠️ cảnh báo mềm (không chặn) · ✅ pass · ❌ fail
114
+ - 🔴 cờ **chặn PR** — `SEAM_UNWIRED` · `STUB_UNRESOLVED` · `ORPHANED` · `TRACE_ORPHAN`. Build xanh + test từng-UC xanh **không** đủ để bỏ qua chúng.
115
+ - 🟠 cờ drift **không chặn PR** — `PRD_DRIFT` · `BDD_DRIFT` · `TECHDOC_DRIFT` · `FE_TECHDOC_DRIFT` · `TECHDOC_STALE_VS_BDD` · `DESIGNSPEC_DRIFT` · `DESIGNSPEC_STALE_VS_BDD`. *"Code chưa theo kịp spec"*, khác *"code đang hỏng"*. **Hết cờ 🔴 ≠ sạch.**
116
+ - ⓘ cờ **không phải lỗi** — `PRD_STALE_REF` · `TECHDOC_STALE_REF` (version lệch nhưng changelog không nêu UC này → chỉ con trỏ cũ) · `SEAM_PENDING` · `STUB_PENDING` (owner chưa gen).
117
+
118
+ ---
119
+
120
+ ## CLI maintenance (không phải slash command)
121
+
122
+ Chạy qua `npx @educa-corp/sdd-framework <flag>`. Tất cả **dry-run mặc định** — thêm `--apply` để thực thi.
123
+
124
+ | Flag | Việc |
125
+ |------|------|
126
+ | `--init` | Cài/nâng cấp `.agent/` + shortcut `.claude/commands/`. Backup file bạn đã sửa sang `.agent/.overwritten-*/` và liệt kê ra |
127
+ | `--migrate-bdd-platform` | `bdd/*.feature` phẳng → `bdd/{platform}/`. Báo `OCCUPIED` / `LOST SPEC` thay vì đoán |
128
+ | `--migrate-specs` | Bố cục artifact-type-first cũ (`specs/prd/`, `specs/bdd/`) → feature-package |
129
+ | `--rename-prd-files` | `prd.md` → `{TICKET-ID}-{prd-slug}.md` |
130
+ | `--help` | Danh sách đầy đủ |
131
+
132
+ Trong repo framework: `npm run build` (assemble template + chạy self-check) · `npm run self-check` (chỉ kiểm contract trace).
133
+
134
+ → [Trace Schema](trace-schema.md) · [Modules](modules.md) · [Configuration](configuration.md) · [Model Selection](model-selection.md)
@@ -1,94 +1,146 @@
1
- [← Reference](./) · [Concepts › Architecture](../02-concepts/architecture.md)
2
-
3
- # Reference · Configuration
4
-
5
- > Hai file cấu hình chính. `/update-framework` **không** đụng chúng — đây là nội dung của bạn.
6
-
7
- ---
8
-
9
- ## 1. `project-context.yaml`
10
-
11
- **Single source of truth** cho paths/mode/routing. Nằm ở `.agent/project-context.yaml`, sinh từ `templates/project-context.yaml` qua token substitution khi init. Mọi workflow đọc file này để biết **WHERE** tìm mọi thứ.
12
-
13
- ### Cấu trúc chính
14
-
15
- ```yaml
16
- project:
17
- name: "..."
18
- description: "..."
19
-
20
- paths:
21
- specs_dir: "specs" # gốc mọi spec artifact
22
- trace_dir: ".trace" # trace state .tsv
23
- qc_dir: "docs" # working docs của QC
24
- qc_skills_dir: ".agent/skills/qc" # nơi qc-* nạp skill (override sang repo QC riêng)
25
- refinement_dir: ".agent/review" # findings review
26
-
27
- setup:
28
- mode: single | umbrella
29
- spec_source: "..." # (umbrella) spec repo dùng chung
30
-
31
- services: # (multi/umbrella) map domain → service
32
- # dạng phẳng: {domain}: { path, module }
33
- # dạng map-theo-platform: {domain}: { web: {path,module}, app: {...}, system: {...} }
34
-
35
- conventions:
36
- build_command: "..." # lệnh build verify (≤3 retry)
37
- test_command: "..."
38
-
39
- tech_stack:
40
- database: "..." # vd PostgreSQL
41
- ```
42
-
43
- ### Bố cục feature-package (path resolution)
44
-
45
- Mọi artifact của một feature nằm chung `specs/{domain}/{prd-slug}/`:
46
-
47
- ```
48
- specs/{domain}/{prd-slug}/
49
- ├── {TICKET-ID}-{prd-slug}.md # PRD (file .md duy nhất ở gốc)
50
- ├── bdd/{web|app|system}/*.feature # BDD
51
- ├── tech-docs/{TICKET-ID}-tech-design.md
52
- └── design-spec/{TICKET-ID}*.md # FE/App
53
- .trace/{domain}/{prd-slug}/{UC-ID}-{platform}.tsv
54
- ```
55
-
56
- - `{domain}` = segment đầu sau `specs_dir`.
57
- - `{prd-slug}` = segment kế tiếp (folder feature-package)**không** phải folder cha trực tiếp của file lồng sâu.
58
-
59
- ---
60
-
61
- ## 2. `CLAUDE.md` (phân tầng)
62
-
63
- Instruction cho AI agent AI *follow* file này thay *invent*.
64
-
65
- | Tầng | Nội dung |
66
- |------|----------|
67
- | **root** `CLAUDE.md` | Luật chung dự án/umbrella |
68
- | **overlay** `{service}/CLAUDE.md` | §2 kiến trúc & thứ tự layer & package strategy · §3 coding standards · §5 error handling — **theo stack** |
69
-
70
- > Service overlay **thắng** root khi mâu thuẫn. context-loader nạp cả hai, đặt ở **cuối** context (Lost-in-the-Middle: "follow style này").
71
-
72
- ---
73
-
74
- ## 3. Single vs Umbrella
75
-
76
- | | Single | Umbrella |
77
- |---|--------|----------|
78
- | `setup.mode` | `single` | `umbrella` |
79
- | Spec ở đâu | Cùng repo | **Spec repo dùng chung** (`spec_source`) |
80
- | Code đâu | Cùng repo | Service submodule (chỉ code + tooling) |
81
- | Trace/feedback/findings | Cùng repo | Trong spec repo (một nơi authoritative) |
82
- | Đồng bộ | | `/sync` (pull + submodule + nổi feedback + Living Docs) |
83
-
84
- Khi `spec_source` được đặt, **mọi** PRD/BDD/tech-doc/design-spec/`.trace`/`.agent/review`/`feedback` route về spec repo — vì đều là **artifact liên team**.
85
-
86
- ---
87
-
88
- ## Không bị ghi đè khi update
89
-
90
- `/update-framework` ghi đè `.agent/commands|steps|hooks|rules|templates|skills|modules` nhưng **giữ nguyên**: `CLAUDE.md`, `project-context.yaml`, `domain-knowledge/`, `.trace/`.
91
-
92
- ---
93
-
94
- [Architecture Configuration](../02-concepts/architecture.md#configuration-2-file) · [Modules](modules.md)
1
+ [← Reference](./) · [Concepts › Architecture](../02-concepts/architecture.md)
2
+
3
+ # Reference · Configuration
4
+
5
+ > Hai file cấu hình chính. `/update-framework` **không** đụng chúng — đây là nội dung của bạn.
6
+
7
+ ---
8
+
9
+ ## 1. `project-context.yaml`
10
+
11
+ **Single source of truth** cho paths/mode/routing. Nằm ở `.agent/project-context.yaml`, sinh từ `templates/project-context.yaml` qua token substitution khi init. Mọi workflow đọc file này để biết **WHERE** tìm mọi thứ.
12
+
13
+ ### Cấu trúc chính
14
+
15
+ ```yaml
16
+ project:
17
+ name: "..."
18
+ description: "..."
19
+
20
+ paths:
21
+ specs_dir: "specs" # gốc mọi spec artifact
22
+ trace_dir: ".trace" # trace state .tsv
23
+ qc_dir: "docs" # working docs của QC
24
+ qc_skills_dir: ".agent/skills/qc" # nơi qc-* nạp skill (override sang repo QC riêng)
25
+ refinement_dir: ".agent/review" # findings review
26
+
27
+ setup:
28
+ mode: single | umbrella
29
+ spec_source: "..." # (umbrella) spec repo dùng chung
30
+
31
+ services: # (multi/umbrella) map domain → service
32
+ # dạng phẳng: {domain}: { path, module }
33
+ # dạng map-theo-platform: {domain}: { web: {path,module}, app: {...}, system: {...} }
34
+
35
+ conventions:
36
+ build_command: "..." # lệnh build verify (≤3 retry)
37
+ test_command: "..."
38
+
39
+ tech_stack:
40
+ database: "..." # vd PostgreSQL
41
+ ```
42
+
43
+ ### Bố cục feature-package (path resolution)
44
+
45
+ Mọi artifact của một feature nằm chung `specs/{domain}/{prd-slug}/`:
46
+
47
+ ```
48
+ specs/{domain}/{prd-slug}/
49
+ ├── {TICKET-ID}-{prd-slug}.md # PRD (file .md duy nhất ở gốc)
50
+ ├── bdd/{web|app|system}/*.feature # BDD — subfolder platform LUÔN có
51
+ ├── tech-docs/{TICKET-ID}-tech-design.md # MỘT doc gộp cho cả PRD
52
+ ├── design-spec/{TICKET-ID}*.md # FE/App
53
+ └── changelog/{TICKET-ID}-{prd-slug}.changelog.md # chỉ tạo khi changelog vượt 5 version
54
+ .trace/{domain}/{prd-slug}/{UC-ID}-{platform}.tsv # MỘT sổ / UC × platform (24 cột)
55
+ .trace/{domain}/{prd-slug}/_seams.tsv # sổ seam/stub — nguồn 2 cờ 🔴 chặn PR
56
+ .trace/trace-report.json # snapshot cho panel GHI ĐÈ mỗi lần chạy
57
+ .trace/trace-history.jsonl # nhật append-onlyPHẢI commit
58
+ ```
59
+
60
+ - `{domain}` = segment đầu sau `specs_dir`.
61
+ - `{prd-slug}` = segment kế tiếp (folder feature-package) — **không** phải folder cha trực tiếp của file lồng sâu.
62
+ - **Segment `{platform}` không optional** — mọi mode, kể cả umbrella. `web` và `system` của cùng một UC là hai file khác nhau; bỏ segment thì chúng va tên và **ghi đè nhau**. Trace tách theo platform nên bố cục spec phải khớp.
63
+ *Project còn bố cục phẳng: `npx @educa-corp/sdd-framework --migrate-bdd-platform` (dry-run mặc định).*
64
+
65
+ ---
66
+
67
+ ## 2. `CLAUDE.md` (phân tầng)
68
+
69
+ Instruction cho AI agent — AI *follow* file này thay vì *invent*.
70
+
71
+ | Tầng | Nội dung |
72
+ |------|----------|
73
+ | **root** `CLAUDE.md` | Luật chung dự án/umbrella |
74
+ | **overlay** `{service}/CLAUDE.md` | §2 kiến trúc & thứ tự layer & package strategy · §3 coding standards · §5 error handling — **theo stack** |
75
+
76
+ > Service overlay **thắng** root khi mâu thuẫn. context-loader nạp cả hai, đặt ở **cuối** context (Lost-in-the-Middle: "follow style này").
77
+
78
+ ---
79
+
80
+ ## 3. Single vs Umbrella
81
+
82
+ | | Single | Umbrella |
83
+ |---|--------|----------|
84
+ | `setup.mode` | `single` | `umbrella` |
85
+ | Spec ở đâu | Cùng repo | **Spec repo dùng chung** (`spec_source`) |
86
+ | Code ở đâu | Cùng repo | Service submodule (chỉ code + tooling) |
87
+ | Trace/feedback/findings | Cùng repo | Trong spec repo (một nơi authoritative) |
88
+ | Đồng bộ | | `/sync` (pull + submodule + nổi feedback + Living Docs) |
89
+
90
+ Khi `spec_source` được đặt, **mọi** PRD/BDD/tech-doc/design-spec/`.trace`/`.agent/review`/`feedback` route về spec repo đều là **artifact liên team**.
91
+
92
+ ---
93
+
94
+ ## Vùng nào bị ghi đè khi update
95
+
96
+ `.agent/` là **mirror sinh ra**: `/update-framework` chạy `npx … --init`, và `--init` copy `core/` → `.agent/` **vô điều kiện**.
97
+
98
+ | Đường dẫn | Sửa được? | Vì sao |
99
+ |---|:---:|---|
100
+ | `CLAUDE.md` | ✅ | ngoài `.agent/` |
101
+ | `.agent/project-context.yaml` | ✅ | file **duy nhất trong `.agent/`** có guard: chỉ tạo nếu chưa tồn tại |
102
+ | `.agent/project-lessons.md` · `.agent/review/` | ✅ | không nằm trong `core/` nên nâng cấp không đụng |
103
+ | `specs/domain-knowledge/` · `.trace/` · `feedback/` | ✅ | ngoài `.agent/` |
104
+ | `.agent/commands` `steps` `rules` `skills` `hooks` `templates` `modules` | ❌ | copy từ repo framework, **ghi đè mỗi lần nâng cấp** |
105
+
106
+ **Nếu bạn đã sửa gì trong vùng ❌** — từ v0.4.2 `--init` tự cứu:
107
+
108
+ - bản cũ copy sang `.agent/.overwritten-{version}-{YYYYMMDD}/` (giữ nguyên cây thư mục)
109
+ - danh sách file bị ghi đè in ra ngay sau bước cài
110
+ - `.agent/.install-manifest.json` ghi hash của **đúng những gì lần cài trước đã viết** — nhờ đó lệnh phân biệt được *bạn sửa file* với *framework tự đổi file giữa hai version* (một phép so nội dung thuần sẽ flag cả hai và báo oan hàng chục file mỗi lần nâng cấp)
111
+
112
+ Thêm vào `.gitignore` của project:
113
+
114
+ ```gitignore
115
+ .agent/.overwritten-*/
116
+ .agent/.install-manifest.json
117
+ .trace-mirror/ # bản sao cho panel VS Code — sinh lại được
118
+ .living-docs/ # report gộp — sinh lại được (đặt trong .gitignore của spec repo)
119
+ ```
120
+
121
+ > ### ⚠️ `.trace/` **KHÔNG** được gitignore
122
+ >
123
+ > Đây là chỗ dễ mất dữ liệu nhất trong toàn framework.
124
+ >
125
+ > | Đường dẫn | Vai trò | Git |
126
+ > |---|---|---|
127
+ > | `{paths.trace_dir}` (`.trace/`) | **AUTHORITATIVE** — `.tsv` + `trace-history.jsonl`. **Không regenerate được** | **PHẢI commit** |
128
+ > | `.trace-mirror/` | bản sao cho panel VS Code | gitignore |
129
+ > | `.living-docs/` | report gộp | gitignore |
130
+ >
131
+ > **Trước v0.4.3 cả hai cùng tên `.trace`.** Khi dev mở thẳng spec repo làm workspace thì hai đường dẫn **bằng nhau** — và `/sync` (bản cũ) gợi ý gitignore theo **tên**, không theo vai trò. Làm theo là **mất sổ gốc, im lặng**: máy vẫn chạy, dashboard vẫn có số; chỉ người thứ hai clone về mới phát hiện, và lúc đó lịch sử đã mất vĩnh viễn.
132
+ >
133
+ > **Kiểm dự án đang chạy:**
134
+ > ```bash
135
+ > git -C {spec_source} check-ignore .trace # trả về kết quả = ĐANG DÍNH
136
+ > ```
137
+ > Dính thì gỡ dòng khớp `.trace` khỏi `.gitignore` rồi `git add -f .trace && git commit`.
138
+ > Từ v0.4.3 `/sync` Step 4b tự kiểm và báo động 🔴 nếu phát hiện.
139
+
140
+ > Muốn thay đổi **bền vững** thì sửa trong repo framework rồi phát hành. Tuỳ biến riêng của một project thuộc về `CLAUDE.md`, `.agent/project-context.yaml`, hoặc `.agent/project-lessons.md` — cả ba đều không bị ghi đè. Ranh giới đầy đủ: `.agent/README.md`.
141
+ >
142
+ > **Template `.feature`/PRD không cấu hình được.** Skeleton được `{{include}}` nướng cứng vào file lệnh lúc build, nên sửa `.agent/templates/` **không có tác dụng** (và sẽ bị ghi đè). Đổi cấu trúc artifact = sửa `templates/*` trong repo framework rồi `npm run build`. Chi tiết: `.agent/templates/README.md`.
143
+
144
+ ---
145
+
146
+ → [Architecture › Configuration](../02-concepts/architecture.md#configuration-2-file) · [Modules](modules.md)