@educa-corp/sdd-framework 0.5.0 → 0.7.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 (243) hide show
  1. package/bin/build.js +113 -19
  2. package/bin/gate-trace.js +487 -0
  3. package/bin/index.js +445 -146
  4. package/bin/lint-trace.js +643 -0
  5. package/bin/self-check.js +804 -2
  6. package/bin/trace-schema.json +621 -10
  7. package/core/FRAMEWORK_VERSION +1 -1
  8. package/core/README.md +20 -0
  9. package/core/commands/amend-prd.md +518 -0
  10. package/core/commands/debug.md +123 -511
  11. package/core/commands/define-product.md +86 -510
  12. package/core/commands/dev-gen-test.md +86 -510
  13. package/core/commands/dev-run-test.md +133 -519
  14. package/core/commands/dev-smoke-test.md +86 -510
  15. package/core/commands/extend-prd.md +128 -522
  16. package/core/commands/fix-bug.md +118 -509
  17. package/core/commands/generate-architecture.md +94 -515
  18. package/core/commands/generate-bdd.md +128 -513
  19. package/core/commands/generate-code.md +119 -510
  20. package/core/commands/generate-design-spec.md +86 -510
  21. package/core/commands/generate-prd.md +89 -510
  22. package/core/commands/generate-spec-manifest.md +86 -510
  23. package/core/commands/generate-tech-docs.md +120 -512
  24. package/core/commands/learn.md +172 -496
  25. package/core/commands/map-testids.md +86 -510
  26. package/core/commands/propose-scenario.md +86 -510
  27. package/core/commands/qc-analyze.md +86 -510
  28. package/core/commands/qc-design-test.md +86 -510
  29. package/core/commands/qc-plan.md +86 -510
  30. package/core/commands/qc-report.md +86 -510
  31. package/core/commands/qc-review.md +86 -510
  32. package/core/commands/qc-run-test.md +115 -513
  33. package/core/commands/refine-prd.md +112 -522
  34. package/core/commands/report-bug.md +86 -510
  35. package/core/commands/review-code.md +123 -511
  36. package/core/commands/review-context.md +136 -522
  37. package/core/commands/review-tech-docs.md +90 -511
  38. package/core/commands/setup-ai-first.md +166 -138
  39. package/core/commands/sync.md +155 -107
  40. package/core/commands/update-framework.md +16 -103
  41. package/core/commands/validate-traces.md +426 -511
  42. package/core/hooks/data-guard.js +174 -83
  43. package/core/hooks/settings.json +2 -1
  44. package/core/rules/workflow.md +64 -4
  45. package/core/steps/capture-lesson.md +34 -1
  46. package/core/steps/context-loader.md +50 -8
  47. package/core/steps/gate.md +92 -35
  48. package/core/steps/report-footer.md +23 -0
  49. package/core/templates/README.md +24 -1
  50. package/core/templates/ci/trace-gate.yml +146 -0
  51. package/core/templates/feature.template +1 -1
  52. package/core/templates/hooks/pre-push +61 -0
  53. package/docs/02-concepts/architecture.md +61 -6
  54. package/docs/02-concepts/traceability.md +57 -0
  55. package/docs/03-guides/architect.md +63 -0
  56. package/docs/04-reference/commands.md +148 -134
  57. package/docs/04-reference/model-selection.md +32 -19
  58. package/docs/04-reference/trace-schema.md +39 -0
  59. package/docs/explain/02b-extend-prd.md +1 -1
  60. package/docs/explain/02c-amend-prd.md +152 -0
  61. package/docs/explain/21-validate-traces.md +2 -1
  62. package/docs/explain/27-learn.md +5 -3
  63. package/docs/explain/28-sync.md +25 -0
  64. package/docs/explain/README.md +136 -135
  65. package/package.json +5 -9
  66. package/commands/debug.md +0 -917
  67. package/commands/debug.tmpl +0 -257
  68. package/commands/define-product.md +0 -862
  69. package/commands/define-product.tmpl +0 -225
  70. package/commands/dev-gen-test.md +0 -1124
  71. package/commands/dev-gen-test.tmpl +0 -490
  72. package/commands/dev-run-test.md +0 -859
  73. package/commands/dev-run-test.tmpl +0 -225
  74. package/commands/dev-smoke-test.md +0 -798
  75. package/commands/dev-smoke-test.tmpl +0 -217
  76. package/commands/extend-prd.md +0 -907
  77. package/commands/extend-prd.tmpl +0 -270
  78. package/commands/fix-bug.md +0 -910
  79. package/commands/fix-bug.tmpl +0 -197
  80. package/commands/generate-architecture.md +0 -775
  81. package/commands/generate-architecture.tmpl +0 -194
  82. package/commands/generate-bdd.md +0 -1347
  83. package/commands/generate-bdd.tmpl +0 -590
  84. package/commands/generate-code.md +0 -1283
  85. package/commands/generate-code.tmpl +0 -649
  86. package/commands/generate-design-spec.md +0 -1161
  87. package/commands/generate-design-spec.tmpl +0 -524
  88. package/commands/generate-prd.md +0 -1143
  89. package/commands/generate-prd.tmpl +0 -223
  90. package/commands/generate-spec-manifest.md +0 -745
  91. package/commands/generate-spec-manifest.tmpl +0 -164
  92. package/commands/generate-tech-docs.md +0 -1344
  93. package/commands/generate-tech-docs.tmpl +0 -273
  94. package/commands/learn.md +0 -723
  95. package/commands/learn.tmpl +0 -63
  96. package/commands/map-testids.md +0 -662
  97. package/commands/map-testids.tmpl +0 -81
  98. package/commands/propose-scenario.md +0 -783
  99. package/commands/propose-scenario.tmpl +0 -202
  100. package/commands/qc-analyze.md +0 -693
  101. package/commands/qc-analyze.tmpl +0 -112
  102. package/commands/qc-design-test.md +0 -650
  103. package/commands/qc-design-test.tmpl +0 -69
  104. package/commands/qc-plan.md +0 -630
  105. package/commands/qc-plan.tmpl +0 -49
  106. package/commands/qc-report.md +0 -641
  107. package/commands/qc-report.tmpl +0 -60
  108. package/commands/qc-review.md +0 -634
  109. package/commands/qc-review.tmpl +0 -53
  110. package/commands/qc-run-test.md +0 -750
  111. package/commands/qc-run-test.tmpl +0 -116
  112. package/commands/refine-prd.md +0 -1074
  113. package/commands/refine-prd.tmpl +0 -278
  114. package/commands/report-bug.md +0 -729
  115. package/commands/report-bug.tmpl +0 -148
  116. package/commands/review-code.md +0 -803
  117. package/commands/review-code.tmpl +0 -143
  118. package/commands/review-context.md +0 -1323
  119. package/commands/review-context.tmpl +0 -527
  120. package/commands/review-tech-docs.md +0 -982
  121. package/commands/review-tech-docs.tmpl +0 -401
  122. package/commands/setup-ai-first.md +0 -574
  123. package/commands/setup-ai-first.tmpl +0 -378
  124. package/commands/sync.md +0 -486
  125. package/commands/sync.tmpl +0 -384
  126. package/commands/update-framework.md +0 -290
  127. package/commands/update-framework.tmpl +0 -188
  128. package/commands/validate-traces.md +0 -1435
  129. package/commands/validate-traces.tmpl +0 -854
  130. package/hooks/data-guard.js +0 -141
  131. package/hooks/settings.json +0 -18
  132. package/modules/android-compose/module.yaml +0 -13
  133. package/modules/android-compose/stack-profile.yaml +0 -57
  134. package/modules/angular/architecture-snippets/component-patterns.md +0 -187
  135. package/modules/angular/module.yaml +0 -6
  136. package/modules/angular/stack-profile.yaml +0 -38
  137. package/modules/context-engineering/architecture-snippets/context-design.md +0 -119
  138. package/modules/context-engineering/module.yaml +0 -9
  139. package/modules/context-engineering/stack-profile.yaml +0 -61
  140. package/modules/dotnet/architecture-snippets/clean-arch.md +0 -160
  141. package/modules/dotnet/module.yaml +0 -6
  142. package/modules/dotnet/stack-profile.yaml +0 -50
  143. package/modules/flutter/module.yaml +0 -14
  144. package/modules/flutter/stack-profile.yaml +0 -59
  145. package/modules/golang/architecture-snippets/domain-layout.md +0 -283
  146. package/modules/golang/module.yaml +0 -6
  147. package/modules/golang/stack-profile.yaml +0 -40
  148. package/modules/ios-swiftui/module.yaml +0 -13
  149. package/modules/ios-swiftui/stack-profile.yaml +0 -55
  150. package/modules/java-spring/architecture-snippets/layered-arch.md +0 -201
  151. package/modules/java-spring/module.yaml +0 -15
  152. package/modules/java-spring/stack-profile.yaml +0 -28
  153. package/modules/nextjs/architecture-snippets/app-router-patterns.md +0 -269
  154. package/modules/nextjs/module.yaml +0 -14
  155. package/modules/nextjs/stack-profile.yaml +0 -74
  156. package/modules/nuxt/module.yaml +0 -14
  157. package/modules/nuxt/stack-profile.yaml +0 -58
  158. package/modules/phaser-game/architecture-snippets/phaser-scene-patterns.md +0 -646
  159. package/modules/phaser-game/module.yaml +0 -15
  160. package/modules/phaser-game/stack-profile.yaml +0 -90
  161. package/modules/php-laravel/architecture-snippets/service-repository.md +0 -302
  162. package/modules/php-laravel/module.yaml +0 -15
  163. package/modules/php-laravel/stack-profile.yaml +0 -56
  164. package/modules/qc-playwright/stack-profile.yaml +0 -66
  165. package/modules/react/architecture-snippets/hooks-query-patterns.md +0 -254
  166. package/modules/react/module.yaml +0 -14
  167. package/modules/react/stack-profile.yaml +0 -63
  168. package/modules/react-native/module.yaml +0 -14
  169. package/modules/react-native/stack-profile.yaml +0 -56
  170. package/modules/vue/module.yaml +0 -14
  171. package/modules/vue/stack-profile.yaml +0 -65
  172. package/rules/data-protection.md +0 -80
  173. package/rules/workflow.md +0 -73
  174. package/scripts/init.sh +0 -49
  175. package/scripts/upgrade.sh +0 -94
  176. package/skills/code/SKILL.md +0 -19
  177. package/skills/code/SKILL.tmpl +0 -19
  178. package/skills/debug/SKILL.md +0 -19
  179. package/skills/debug/SKILL.tmpl +0 -19
  180. package/skills/design-spec/SKILL.md +0 -11
  181. package/skills/design-spec/SKILL.tmpl +0 -11
  182. package/skills/discovery/SKILL.md +0 -14
  183. package/skills/discovery/SKILL.tmpl +0 -14
  184. package/skills/prd/SKILL.md +0 -19
  185. package/skills/prd/SKILL.tmpl +0 -19
  186. package/skills/qc/qa-analyst/DOC_GAPS.template.md +0 -63
  187. package/skills/qc/qa-analyst/acceptance-criteria.md +0 -60
  188. package/skills/qc/qa-analyst/business-rules.md +0 -59
  189. package/skills/qc/qa-analyst/data-flow.md +0 -64
  190. package/skills/qc/qa-analyst/spec-breakdown.md +0 -61
  191. package/skills/qc/qa-designer/e2e/journey.md +0 -41
  192. package/skills/qc/qa-designer/exploratory/charter.md +0 -68
  193. package/skills/qc/qa-designer/exploratory/explore-to-functional.md +0 -43
  194. package/skills/qc/qa-designer/functional/api.md +0 -45
  195. package/skills/qc/qa-designer/functional/gui-feature.md +0 -46
  196. package/skills/qc/qa-designer/functional/gui-screen.md +0 -52
  197. package/skills/qc/qa-designer/integration/api.md +0 -42
  198. package/skills/qc/qa-designer/integration/db.md +0 -39
  199. package/skills/qc/qa-designer/integration/gui.md +0 -40
  200. package/skills/qc/qa-designer/integration/kafka.md +0 -40
  201. package/skills/qc/qa-designer/non-functional.md +0 -40
  202. package/skills/qc/qa-planner/test-plan.md +0 -120
  203. package/skills/qc/qa-reviewer/script/e2e.md +0 -87
  204. package/skills/qc/qa-reviewer/script/exploratory.md +0 -45
  205. package/skills/qc/qa-reviewer/script/functional.md +0 -101
  206. package/skills/qc/qa-reviewer/script/integration.md +0 -91
  207. package/skills/qc/qa-reviewer/script/non-functional.md +0 -126
  208. package/skills/qc/qa-reviewer/test-case/e2e.md +0 -73
  209. package/skills/qc/qa-reviewer/test-case/exploratory.md +0 -43
  210. package/skills/qc/qa-reviewer/test-case/functional.md +0 -76
  211. package/skills/qc/qa-reviewer/test-case/integration.md +0 -69
  212. package/skills/qc/qa-reviewer/test-case/non-functional.md +0 -73
  213. package/skills/qc/qa-runner/e2e.md +0 -49
  214. package/skills/qc/qa-runner/exploratory/session.md +0 -36
  215. package/skills/qc/qa-runner/functional/api.md +0 -35
  216. package/skills/qc/qa-runner/functional/gui-feature.md +0 -51
  217. package/skills/qc/qa-runner/functional/gui-screen.md +0 -55
  218. package/skills/qc/qa-runner/integration.md +0 -47
  219. package/skills/qc/qa-runner/non-functional.md +0 -49
  220. package/skills/qc/qa-runner/report/report.md +0 -37
  221. package/skills/setup-ai-first/SKILL.md +0 -19
  222. package/skills/setup-ai-first/SKILL.tmpl +0 -19
  223. package/skills/spec/SKILL.md +0 -19
  224. package/skills/spec/SKILL.tmpl +0 -19
  225. package/skills/test/SKILL.md +0 -18
  226. package/skills/test/SKILL.tmpl +0 -18
  227. package/steps/business-language.md +0 -56
  228. package/steps/capture-lesson.md +0 -79
  229. package/steps/context-loader.md +0 -385
  230. package/steps/gate.md +0 -94
  231. package/steps/report-footer.md +0 -102
  232. package/steps/review-fanout.md +0 -159
  233. package/steps/spawn-agent.md +0 -129
  234. package/steps/trace-mirror.md +0 -53
  235. package/templates/README.md +0 -47
  236. package/templates/architecture.template.md +0 -394
  237. package/templates/design-spec.template.md +0 -217
  238. package/templates/feature.template +0 -123
  239. package/templates/platform-guide.template.md +0 -145
  240. package/templates/prd.template.md +0 -283
  241. package/templates/product-definition.template.md +0 -188
  242. package/templates/project-context.yaml +0 -212
  243. package/templates/tech-design.template.md +0 -490
package/commands/sync.md DELETED
@@ -1,486 +0,0 @@
1
- # /sync — Sync & Refresh Umbrella Project
2
-
3
- Một lệnh cho cả **setup lần đầu** lẫn **cập nhật hằng ngày** một umbrella repo có git submodule.
4
- An toàn chạy lặp lại — tự phát hiện cần làm gì.
5
-
6
- **Argument tuỳ chọn:** `/sync [spec-branch]` — branch của spec submodule để pull (vd `/sync develop`). Nếu bỏ, branch được phân giải tự động (xem Step 0-D).
7
-
8
- ---
9
-
10
- ## Step 0 — Pre-flight Checks
11
-
12
- **A. Git repo check**
13
-
14
- Xác minh thư mục hiện tại nằm trong git repo. Nếu không → dừng:
15
- ```
16
- ❌ Not a git repository. Open Claude Code from umbrella root and retry.
17
- ```
18
-
19
- **B. Đọc project config sớm**
20
-
21
- Đọc `.agent/project-context.yaml` trước khi chạy lệnh git nào. Trích:
22
- - `setup.spec_source` → path của spec submodule (vd `"my-project-specs"`)
23
- - `services` → map domain → `{path, module, ...}` cho mỗi service submodule
24
-
25
- Cần cái này để phân biệt spec vs service submodule ở Step 1.
26
-
27
- Nếu `.agent/project-context.yaml` không tồn tại → cảnh báo và set `spec_source = null`, `services = {}`.
28
-
29
- **C. Submodule status scan**
30
-
31
- Chạy `git submodule status --recursive` và phân loại mỗi entry theo ký tự đầu:
32
-
33
- | Char | Ý nghĩa | Hành động |
34
- |------|---------|--------|
35
- | `-` | Chưa init | → **Setup mode** |
36
- | ` ` | Khớp pointer đã ghi | → OK |
37
- | `+` | Ahead của pointer đã ghi (local advance chưa commit) | → cảnh báo từng submodule |
38
- | `U` | Merge conflict | → **STOP** |
39
-
40
- Nếu **bất kỳ** entry nào có `U`:
41
- ```
42
- ❌ Merge conflict in submodule: {path}
43
- Resolve manually before running /sync:
44
- cd {path} && git status
45
- ```
46
-
47
- Nếu **bất kỳ** entry nào có `+` (commit đang checkout khác pointer đã ghi):
48
- ```
49
- ℹ️ {path} is ahead of the umbrella's recorded pointer.
50
- /sync classifies it in Step 1b — if you're on a branch there, it stays untouched.
51
- ```
52
- Đừng xử lý `+` ở đây — Step 1b quyết định cách xử lý đúng cho từng submodule.
53
-
54
- In mode phát hiện: `Mode: Setup (first-time init)` hoặc `Mode: Update (sync latest)`.
55
-
56
- ---
57
-
58
- ## Step 1 — Umbrella Pull
59
-
60
- Ghi branch umbrella hiện tại trước (đây là cái `git pull` cập nhật):
61
- `git rev-parse --abbrev-ref HEAD` → lưu thành `umbrella_branch` và hiển thị.
62
-
63
- ```bash
64
- # 1. Pull latest umbrella (includes updated submodule pointer records)
65
- git pull
66
-
67
- # 2. Sync .gitmodules config into local git config
68
- # (needed when new submodules were added since last clone)
69
- git submodule sync --recursive
70
-
71
- # 3. Initialize any NOT-yet-cloned submodules ONLY (the '-' entries from Step 0-C).
72
- # Do NOT run a blanket `git submodule update --recursive` — that would detach
73
- # a submodule you are actively working in. Per-submodule handling is Step 1b.
74
- git submodule update --init {paths that were '-' in Step 0-C}
75
- ```
76
-
77
- Nếu `git pull` exit khác 0 → in lỗi và dừng với `❌`.
78
-
79
- ---
80
-
81
- ## Step 1b — Phân loại & Sync từng Submodule
82
-
83
- **Ý tưởng cốt lõi:** `/sync` không bao giờ áp một branch lên submodule. Nó **kiểm tra checkout hiện tại của từng submodule** và tôn trọng nó. Đây là cách nó biết submodule nào bạn đang làm vs cái nào là dependency thụ động.
84
-
85
- Với mỗi submodule (dùng `git submodule foreach` hoặc lặp các path), đọc state:
86
-
87
- ```bash
88
- # Inside each submodule:
89
- git symbolic-ref --short -q HEAD # → branch name, or empty/non-zero if DETACHED
90
- git status --porcelain # → non-empty means uncommitted local changes
91
- ```
92
-
93
- Phân loại vào một trong bốn case và xử lý tương ứng:
94
-
95
- | Case | State phát hiện | Hành động |
96
- |------|----------------|--------|
97
- | **Spec submodule** | `path == spec_source` | Advance tới `spec_branch` (Step 1c bên dưới) |
98
- | **Active (on a branch)** | HEAD là một branch, không detached | **KHÔNG checkout.** Đây là nơi bạn (hoặc đồng đội) đang code. Chỉ `git -C {path} fetch` và report branch + ahead/behind. Để working tree y nguyên. |
99
- | **Passive (detached, clean)** | Detached HEAD, không có thay đổi local | An toàn align về pointer đã ghi của umbrella: `git submodule update {path}` |
100
- | **Dirty (uncommitted changes)** | `git status --porcelain` non-empty | **Đừng đụng.** Cảnh báo: `⚠️ {path} has uncommitted changes — skipped. Commit or stash before syncing this submodule.` |
101
-
102
- > **Vì sao quan trọng:** Một `git submodule update` toàn bộ checkout mọi submodule về **detached HEAD** ở pointer đã ghi. Nếu bạn đang checkout `feature/FEAT-01` trong `user-service/` và đang làm dở, cái đó sẽ âm thầm chuyển bạn khỏi branch. Phân loại trước bảo vệ công việc đang làm của bạn.
103
-
104
- ---
105
-
106
- ## Step 1c — Advance Spec Submodule *(chỉ khi `spec_source` được cấu hình)*
107
-
108
- Spec submodule là submodule duy nhất ta cố ý advance tới một branch HEAD (PO push spec liên tục).
109
-
110
- **Phân giải spec branch** (giờ submodule đã init), theo thứ tự ưu tiên:
111
-
112
- 1. **Command argument** — nếu `$ARGUMENTS` chứa tên branch → dùng nó (override một lần)
113
- 2. **`.gitmodules` config** — `git config -f .gitmodules --get submodule.{spec_source}.branch`. Nếu set → dùng nó (default committed của team)
114
- 3. **Remote default** — else branch default của spec repo: `git -C {spec_source} rev-parse --abbrev-ref origin/HEAD` (bỏ prefix `origin/`)
115
-
116
- Lưu thành `spec_branch` + `spec_branch_source` (argument | .gitmodules | remote-default). Nếu nó rơi xuống remote-default mà không có gì pin, thêm hint này vào output:
117
- ```
118
- ℹ️ Spec submodule branch not pinned in .gitmodules — using remote default '{spec_branch}'.
119
- To pin it for the whole team:
120
- git config -f .gitmodules submodule.{spec_source}.branch {spec_branch}
121
- git add .gitmodules && git commit -m "chore: pin spec submodule branch"
122
- ```
123
-
124
- Rồi kiểm tra an toàn: nếu spec submodule có thay đổi chưa commit → cảnh báo và skip (dev nên coi spec là read-only). Ngược lại dùng **explicit checkout** (không phải `--remote` trần) để branch rõ ràng:
125
-
126
- ```bash
127
- cd {spec_source}
128
- git fetch origin
129
- git checkout {spec_branch} # branch resolved in Step 0-D
130
- git pull origin {spec_branch}
131
- cd - # back to umbrella root
132
- ```
133
-
134
- In: `Spec submodule {spec_source}: pulled branch '{spec_branch}' (source: {spec_branch_source})`
135
-
136
- > **Vì sao không `--remote` cho service submodule?** Service submodule bị version-lock bởi pointer đã ghi của umbrella — cố ý để mọi dev làm từ cùng commit. `--remote` sẽ bỏ qua lock này và tạo pointer drift chưa commit. Spec submodule là ngoại lệ: PO push liên tục, nên ta advance nó tới branch HEAD — nhưng làm bằng explicit `checkout {spec_branch}` thay vì `--remote` để nó không bao giờ âm thầm theo sai branch.
137
-
138
- Nếu `git pull` hoặc `git submodule update` exit khác 0 → in lỗi và dừng với `❌`.
139
-
140
- Thu từ output:
141
- - Submodule nào đổi SHA
142
- - Cái nào đã up to date
143
- - `{old_sha}..{new_sha}` của spec submodule (cần cho Step 1d)
144
-
145
- ---
146
-
147
- ## Step 1d — Surface Feedback của Tester/QC *(bug report / scenario proposal / PRD change request)*
148
-
149
- `/report-bug`, `/propose-scenario` của tester & QC (gồm cả PRD change request Case B) commit feedback vào spec repo. Step này cho PO/Dev biết cái gì tới trong **lần** pull này, để họ được thông báo qua routine bình thường. Nó phủ cả hai đối tượng:
150
-
151
- - **Dev/tester trong umbrella** → feedback tới qua spec submodule advance (Step 1c)
152
- - **PO làm trực tiếp trong spec repo** → feedback tới qua `git pull` của umbrella/current-repo (Step 1)
153
-
154
- Chọn repo + range đã pull feedback:
155
- - Umbrella có `spec_source` → `REPO={spec_source}`, range = spec submodule `{old_sha}..{new_sha}`
156
- - Ngược lại (chạy trong chính spec repo) → `REPO=.`, range = `{old_sha}..{new_sha}` của `git pull` từ Step 1
157
-
158
- Nếu `feedback/` không tồn tại trong REPO → skip âm thầm.
159
-
160
- ```bash
161
- git -C {REPO} diff --name-status {old_sha}..{new_sha} -- feedback/bug-reports/ feedback/bdd-proposals/ feedback/prd-change-requests/
162
- ```
163
-
164
- Với mỗi entry, đọc title/summary + `State` và report. **Bug report: chỉ surface `State: Open`** là cần chú ý; liệt kê `Fixed`/`Closed` riêng (hoặc bỏ) để PO/PM thấy cái gì còn pending:
165
- ```
166
- 📥 New feedback (pulled this sync):
167
- Bug reports (open):
168
- BUG-20260608-01 FT-001 — account locks after 6 fails (spec says 5) [layer: Code · waiting: dev]
169
- Bug reports (fixed, awaiting QC re-verify): BUG-20260605-02
170
- Scenario proposals:
171
- FT-001-trailing-spaces.md → maps to AC2 (pending review)
172
- PRD change requests:
173
- FT-001-bulk-export.md → new requirement, needs an AC (waiting: PO)
174
- ```
175
-
176
- Nếu không có gì đổi → in `📥 Feedback: none new this sync`.
177
-
178
- Nếu người đọc là PO/Dev, thêm một dòng nudge:
179
- `→ Review feedback/ then act: /fix-bug {BUG-ID} · promote proposal via /generate-bdd · or add an AC to the PRD.`
180
-
181
- ---
182
-
183
- ## Step 2 — Post-sync State Check
184
-
185
- Chạy `git status --short` và kiểm tra entry submodule bị modified (dòng bắt đầu bằng ` M` mà path khớp một submodule).
186
-
187
- Nếu pointer submodule nào đổi (thường là spec submodule sau `--remote`):
188
- ```
189
- ⚠️ Submodule pointer(s) updated — commit to lock new version into umbrella:
190
- git add {spec_source} && git commit -m "chore: sync {spec_source} to latest"
191
- ```
192
-
193
- Nếu không có thay đổi → `✅ Umbrella state clean — no commit needed`.
194
-
195
- ---
196
-
197
- ## Step 3 — Bootstrap Service Configs
198
-
199
- *Skip nếu `services` rỗng.*
200
-
201
- **Trước tiên — làm phẳng `services` thành danh sách submodule.** Một giá trị trong `services` có thể lồng tới ba tầng (xem `context-loader.md` Bước 1.5), nên duyệt nông sẽ **bỏ sót** submodule:
202
-
203
- | Dạng | Cách lấy submodule |
204
- |---|---|
205
- | `services.{domain}.path` (2a) | một entry |
206
- | `services.{domain}.{platform}.path` (2b) | một entry mỗi platform |
207
- | `…by_prd_slug.{slug}.path` (2c) | một entry mỗi `slug` — ở cấp domain hoặc cấp platform |
208
-
209
- Kết quả là tập các cặp `{path, module}` **duy nhất theo `path`** (nhiều domain/platform/slug có thể trỏ chung một submodule — chỉ xử lý một lần). Mọi bước dưới đây chạy trên danh sách đã làm phẳng này.
210
-
211
- Với mỗi entry trong danh sách đó:
212
-
213
- **A. Nếu `{service.path}/.agent/project-context.yaml` đã tồn tại:**
214
- - Đọc `conventions.test_command` và `conventions.build_command`
215
- - Report: `✅ {service.path} — test: {test_command} | build: {build_command}`
216
-
217
- **B. Nếu thiếu — tự tạo:**
218
-
219
- 1. Xác định `module` từ umbrella `services[].module` (authoritative). Nếu không set, auto-detect từ file trong `{service.path}/`:
220
-
221
- | File có mặt | Module phát hiện | test_command | build_command |
222
- |---|---|---|---|
223
- | `pom.xml` | `java-spring` | `mvn test` | `mvn compile` |
224
- | `build.gradle` or `build.gradle.kts` | `java-spring` | `./gradlew test` | `./gradlew build` |
225
- | `go.mod` | `golang` | `go test ./...` | `go build ./...` |
226
- | `*.csproj` or `*.sln` | `dotnet` | `dotnet test` | `dotnet build` |
227
- | `composer.json` | `php-laravel` | `php artisan test` | `composer install` |
228
- | `pubspec.yaml` | `flutter` | `flutter test` | `flutter build apk` |
229
- | `angular.json` | `angular` | `npx ng test --watch=false` | `npm run build` |
230
- | `next.config.*` | `nextjs` | `npx vitest run` | `npm run build` |
231
- | `package.json` + `nest-cli.json` | `nestjs` | `npm test` | `npm run build` |
232
- | `package.json` (fallback) | `react` | `npx vitest run` | `npm run build` |
233
- | `requirements.txt` or `pyproject.toml` | `context-engineering` | `pytest tests/ -v` | `pip install -r requirements.txt` |
234
- | *(none matched)* | `unknown` | `{{TEST_COMMAND}}` | `{{BUILD_COMMAND}}` |
235
-
236
- 2. Tạo thư mục `{service.path}/.agent/` nếu chưa có.
237
-
238
- 3. Ghi `{service.path}/.agent/project-context.yaml`:
239
-
240
- ```yaml
241
- # Auto-generated by /sync — review and update as needed
242
- tech_stack:
243
- language: "{detected or from module}"
244
- framework: "{detected or from module}"
245
- module: "{module}"
246
-
247
- conventions:
248
- test_command: "{test_command}"
249
- build_command: "{build_command}"
250
-
251
- paths:
252
- trace_dir: ".trace"
253
- lessons_file: ".agent/project-lessons.md" # per-service guardrails (see /learn)
254
- ```
255
-
256
- 4. Report:
257
- - Nếu auto-detect: `✅ Created {service.path}/.agent/project-context.yaml (module: {module}, test: {test_command})`
258
- - Nếu unknown/placeholder: `⚠️ Created {service.path}/.agent/project-context.yaml — fill in {{TEST_COMMAND}} and {{BUILD_COMMAND}}`
259
-
260
- ---
261
-
262
- ## Step 4 — Check `.gitignore`
263
-
264
- *Bước này kiểm **hai chiều ngược nhau**, và nhầm chiều là mất dữ liệu — đọc bảng trước:*
265
-
266
- | Đường dẫn | Vai trò | Kỳ vọng |
267
- |---|---|---|
268
- | `{paths.trace_dir}` (`.trace/` hoặc `{spec_source}/.trace/`) | **AUTHORITATIVE** — TSV + `trace-history.jsonl`, không regenerate được | **PHẢI commit** — gitignore nó là **lỗi nghiêm trọng** |
269
- | `.trace-mirror/` | bản sao tiện cho panel VS Code | phải gitignore |
270
- | `.living-docs/` | report sinh ra | phải gitignore |
271
-
272
- **4a. Cảnh báo mềm — mirror chưa gitignore.**
273
- Kiểm `.trace-mirror/` trong `.gitignore` của repo hiện tại (hoặc `.git/info/exclude`), và `.living-docs/` trong `.gitignore` của **specs module** (khi `setup.spec_source` được set). Thiếu cái nào:
274
- ```
275
- ⚠️ Mirror chưa gitignore — chúng được sinh ra, đừng bao giờ commit:
276
- echo ".trace-mirror/" >> .gitignore
277
- echo ".living-docs/" >> {spec_source}/.gitignore # specs module (nếu có spec_source)
278
- ```
279
-
280
- **4b. 🔴 Báo động — sổ gốc ĐANG bị bỏ qua.**
281
- Phân giải `{paths.trace_dir}`; nếu nó nằm trong một git repo, chạy `git -C {repo} check-ignore -q {trace_dir}`. **Trúng** (exit 0) → in ngay, mức chặn:
282
- ```
283
- 🔴 NGUY HIỂM — sổ gốc trace ĐANG bị git bỏ qua: {paths.trace_dir}
284
- Toàn bộ trạng thái theo dõi (spec_ver · gen_ver · implemented_by · test_count ·
285
- dev_selftest · qc_status) VÀ trace-history.jsonl KHÔNG được lưu vào git.
286
- Người khác clone repo về sẽ không thấy gì, và lịch sử thì KHÔNG dựng lại được.
287
-
288
- Sửa:
289
- 1. Gỡ dòng khớp `.trace` khỏi .gitignore của {repo}
290
- 2. git -C {repo} add -f {trace_dir} && git -C {repo} commit -m "restore trace state"
291
- Nguyên nhân thường gặp: bản trước v0.4.3 gọi panel mirror là `.trace` (trùng tên sổ gốc),
292
- nên gợi ý "gitignore .trace/" của chính lệnh này có thể đã nhắm trúng sổ gốc.
293
- ```
294
- > **Vì sao cần báo động này:** trước v0.4.3, mirror và sổ gốc **cùng tên `.trace`**. Khi dev mở thẳng spec repo làm workspace thì hai path bằng nhau — và Step 4 (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. Bản v0.4.3 đổi tên mirror thành `.trace-mirror` để cái bẫy biến mất, nhưng **dự án đã dính từ trước thì vẫn dính** — 4b là để tìm ra chúng.
295
-
296
- ---
297
-
298
- ## Step 5 — Refresh Living Docs *(chỉ umbrella mode)*
299
-
300
- *Skip nếu `services` rỗng.*
301
-
302
- **Phân giải Living Docs home (cùng quy tắc như `/validate-traces`):**
303
- - `living_docs_dir` = `{spec_source}/.living-docs` nếu `setup.spec_source` được set, else `.living-docs` ở umbrella root. *(Specs module được mount trong mọi service workspace, nên panel phân giải nó kể cả khi dev mở một service submodule đơn.)*
304
- - `panel_mirror` = `./.trace-mirror` ở gốc workspace hiện tại. *(Cố ý KHÁC tên `.trace` — xem Step 4.)*
305
-
306
- 1. Với mỗi service trong danh sách **đã làm phẳng** ở Step 3 (gồm cả các submodule nằm dưới `by_prd_slug` — bỏ sót chúng là mất trace của các repo chia theo feature): nếu `{service.path}/.trace/` có file `.tsv` → copy chúng vào `{living_docs_dir}/{service-name}/` (tạo dir nếu cần).
307
- 2. Ghi merged `{living_docs_dir}/trace-report.json`:
308
- - Tổng hợp TSV `.trace/` của mỗi service, thêm field `"service"` **và `"platform"`** (suy từ tên file `{UC-ID}-{platform}.tsv`) cho mỗi row, tính lại summary totals. **Không dedupe theo `sc_id` giữa các platform** — `web·SC1` và `system·SC1` là 2 row khác nhau; nhờ field `platform` dashboard hiển thị tách bạch coverage từng platform.
309
- 3. **Mirror tới panel location:** copy `{living_docs_dir}/trace-report.json` (+ TSV namespaced) → `{panel_mirror}/` để panel trong repo đang mở không rỗng. Skip nếu `panel_mirror` đã bằng `living_docs_dir`, hoặc nếu `{paths.trace_dir}` đã nằm trong workspace hiện tại (panel đọc thẳng ở đó). **KHÔNG** copy `trace-history.jsonl` — nó là dữ liệu tích luỹ, không phải thứ sinh lại được.
310
-
311
- In kết quả sync:
312
- ```
313
- Living Docs → {living_docs_dir}/ synced (canonical, specs module)
314
- {service-name}: {N} TSVs
315
- trace-report.json: {total} scenarios across {S} services
316
- Panel mirror → {panel_mirror}/ (current workspace)
317
- ```
318
-
319
- Nếu không tìm thấy dir `.trace/` → `Living Docs: no trace data yet — run /generate-bdd then /generate-code first.`
320
-
321
- ---
322
-
323
- ## Step 6 — Refresh Spec Manifest *(nếu có spec_source)*
324
-
325
- *Skip nếu `setup.spec_source` vắng.*
326
-
327
- Nếu `spec-manifest.yaml` tồn tại HOẶC `setup.spec_source` được cấu hình:
328
- - Re-scan các file PRD `{spec_source}/specs/*/*/*.md` (file `.md` ở gốc mỗi feature folder = PRD; tech-docs/design-spec `.md` nằm sâu hơn nên không bị quét nhầm)
329
- - Rebuild `spec-manifest.yaml` map TICKET-ID → path PRD/BDD/tech-doc
330
- - In: `spec-manifest.yaml refreshed — {N} features indexed`
331
-
332
- ---
333
-
334
- ## Output
335
-
336
- # Report Footer — Định dạng output chuẩn cho mọi lệnh
337
-
338
- Mọi report của lệnh phải kết thúc bằng section footer chuẩn này.
339
-
340
- ## Status Badge
341
-
342
- Chọn một theo kết quả:
343
- - `✅ Complete` — mọi bước thành công, không có vấn đề
344
- - `❌ Failed` — lệnh không hoàn thành được do lỗi chặn
345
- - `⚠️ Warnings` — hoàn thành nhưng có vấn đề không chặn, nên review lại
346
-
347
- ## Output Artifacts
348
-
349
- Liệt kê mọi file được tạo hoặc sửa bởi lệnh này:
350
- ```
351
- Output Artifacts:
352
- {created|updated} {file-path} ({mô tả ngắn})
353
- {created|updated} {file-path} ({mô tả ngắn})
354
- ```
355
-
356
- Nếu không ghi file nào (vd: lệnh review hoặc phân tích) → ghi `Output Artifacts: none (read-only)`.
357
-
358
- ## Pipeline Position
359
-
360
- In một sơ đồ pipeline một dòng, đánh dấu phase của lệnh HIỆN TẠI bằng `◀ bạn ở đây`,
361
- để người dùng luôn thấy lệnh này nằm ở đâu trong luồng end-to-end:
362
-
363
- ```
364
- Discovery → PRD → [Design Spec] → BDD → Tech Design → Code → Dev Self-Check → QC → Trace Audit
365
- ```
366
-
367
- Tìm lệnh hiện tại trong bảng phase dưới đây và đánh dấu **phase của nó** trong sơ đồ trên:
368
-
369
- | Phase | Commands |
370
- |-------|----------|
371
- | Discovery | `/define-product` |
372
- | PRD | `/generate-prd` · `/extend-prd` · `/refine-prd` · `/review-context` (PRD) |
373
- | Design Spec | `/generate-design-spec` |
374
- | BDD | `/generate-bdd` · `/review-context` (BDD) |
375
- | Tech Design | `/generate-tech-docs` · `/map-testids` · `/review-tech-docs` |
376
- | Code | `/generate-code` · `/review-code` |
377
- | Dev Self-Check | `/dev-gen-test` · `/dev-run-test` · `/dev-smoke-test` |
378
- | QC | `/qc-analyze` · `/qc-plan` · `/qc-design-test` · `/qc-review` · `/qc-run-test` · `/qc-report` |
379
- | Trace Audit | `/validate-traces` |
380
-
381
- Với **lệnh review**, thêm vòng review 3 bước và đánh dấu bước hiện tại, vd:
382
- `Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume`.
383
-
384
- **Lệnh xuyên suốt** (`/sync`, `/update-framework`, `/fix-bug`, `/debug`, `/learn`,
385
- `/report-bug`, `/propose-scenario`, `/generate-spec-manifest`) nằm ngoài pipeline tuyến tính —
386
- **bỏ hẳn dòng Pipeline** cho các lệnh này (đừng cố nhét chúng vào sơ đồ).
387
-
388
- ## Gợi ý lệnh tiếp theo
389
-
390
- Gợi ý lệnh kế tiếp hợp lý theo phase của workflow:
391
-
392
- | Lệnh hiện tại | Gợi ý lệnh tiếp theo |
393
- |-------------------------|-----------------------------------------------|
394
- | /setup-ai-first | `/define-product` để bắt đầu feature đầu tiên |
395
- | /define-product | `/generate-prd {product-definition-file}` |
396
- | /generate-prd | `/refine-prd {prd-file}` rồi `/review-context {prd-file}` |
397
- | /extend-prd | `/refine-prd {prd-file}` (soi phần vừa thêm) rồi `/review-context {prd-file}` → PO duyệt → `/generate-bdd` **chỉ cho UC MỚI**; UC cũ dùng `/validate-traces --realign-prd-version {UC-ID}` |
398
- | /refine-prd | Mở Review Board → cập nhật PRD → `/review-context {prd-file}` |
399
- | /review-context (PRD) | Khi 0 critical → PO đặt `Status: approved`, rồi FE/App: `/generate-design-spec {prd-file}` (→ design sign-off → BDD); BE: `/generate-bdd {prd-file}`. Còn critical/NEEDS_FIX → sửa PRD (giữ draft) |
400
- | /generate-design-spec | Designer review → xác nhận link Figma → PO + Designer sign-off → `/generate-bdd {prd-file}` |
401
- | /generate-bdd | `/review-context {feature-file}` để kiểm tra độ phủ |
402
- | /review-context (BDD) | `/generate-tech-docs {UC-ID}` nếu APPROVED; sinh lại nếu NEEDS_FIX |
403
- | /qc-analyze | `/qc-plan {UC-ID}` (xử lý các gap blocker 🔴 trước) |
404
- | /qc-plan | `/qc-design-test {UC-ID}` |
405
- | /qc-design-test | `/qc-review {UC-ID}` (review test-case) |
406
- | /qc-review (test-case) | `/qc-run-test {UC-ID}` nếu APPROVED; sửa TC nếu NEEDS_FIX |
407
- | /qc-run-test | `/qc-report {UC-ID}` rồi `/qc-review {UC-ID}` (review script) |
408
- | /qc-review (script) | `/qc-report {UC-ID}` rồi tạo PR nếu APPROVED |
409
- | /qc-report | `/validate-traces {UC-ID}` để làm mới Living Docs (qc_status) |
410
- | /map-testids | `/qc-design-test {UC-ID}` (QC dựng Page Object từ contract §4.5.6 vừa ghi) |
411
- | /generate-tech-docs | `/review-tech-docs {tech-design-file}` |
412
- | /review-tech-docs | `/generate-code {feature-file}` nếu APPROVED; sửa doc nếu NEEDS_FIX |
413
- | /generate-code | Lần gen đầu → `/review-code {UC-ID}`; gen lại → `/dev-gen-test {UC-ID}` |
414
- | /dev-gen-test | `/dev-run-test {UC-ID}` |
415
- | /dev-run-test (passing) | `/review-code {UC-ID}` |
416
- | /dev-run-test (failing) | `/fix-bug {ticket-id}` hoặc `/debug {error}` |
417
- | /review-code | `/dev-smoke-test {UC-ID}` hoặc tạo PR |
418
- | /dev-smoke-test | Tạo PR và link tới ticket |
419
- | /validate-traces | **Cờ 🔴 trước (chặn PR):** SEAM_UNWIRED → nối binding sang class thật, xoá/thay stub · STUB_UNRESOLVED → `/generate-code {owner_uc}` (lấp logic tại chỗ + xoá hàm song song) · ORPHANED/TRACE_ORPHAN → quyết định thủ công (xoá code+test, đưa scenario trở lại `.feature`, hoặc sửa `sc_id` của tag). **Rồi:** DRIFT/UNTRACKED → `/generate-code {UC-ID}` · BDD_DRIFT → `/generate-code {feature-file}` · tech-doc lỗi thời vs BDD → `/generate-tech-docs` → `/review-tech-docs` · PRD drift → `/generate-bdd {prd-file}` · GAP → `/dev-gen-test {UC-ID}`. **Chỉ tạo PR khi mọi cờ 🔴 = 0** |
420
- | /fix-bug | `/dev-run-test {UC-ID}` (dev_selftest vừa reset về not_run) → tạo PR; nếu fix một `{BUG-ID}` → QC chạy `/qc-run-test {UC-ID}` để verify + đóng bug |
421
- | /debug | `/fix-bug {ticket-id}` nếu cần sửa |
422
- | /report-bug | Gửi cho dev (`/fix-bug {BUG-ID}`); nếu thiếu coverage → `/propose-scenario {UC-ID}` |
423
- | /propose-scenario | **Case A** (thiếu scenario cho AC có sẵn) → báo PO/Dev review trong `feedback/bdd-proposals/`; `/generate-bdd` tự chèn khi `Status: accepted`. **Case B** (requirement mới) → `feedback/prd-change-requests/` — PO phải đưa vào PRD trước, KHÔNG tự vào BDD được; `/validate-traces` nhắc lại kèm số ngày chờ chừng nào `Status: Open` |
424
- | /learn | Tiếp tục làm việc — lesson áp dụng ở lệnh kế tiếp |
425
- | /sync | `/validate-traces` để xem độ phủ đầy đủ; xử lý mọi `📥 tester feedback` được nêu |
426
- | /update-framework | Review `git diff .agent/`, commit; `/sync` để đồng bộ nội dung dự án |
427
-
428
- Định dạng footer như sau:
429
- ```
430
- ---
431
- Status : {badge}
432
- {khối Output Artifacts}
433
- Pipeline : Discovery → PRD → [BDD ◀ bạn ở đây] → Tech Design → Code → Dev Self-Check → QC → Trace Audit
434
- (lệnh review) Vòng review: [① phân tích ◀] → ② Review Board → ③ --resume
435
- Next : {lệnh gợi ý kèm ví dụ tham số}
436
- ```
437
- *(Bỏ dòng `Pipeline` cho các lệnh xuyên suốt liệt kê ở trên.)*
438
-
439
-
440
- ```
441
- /sync — {Setup | Update}
442
-
443
- Git
444
- ✅ git pull — umbrella on branch '{umbrella_branch}'
445
- ✅ submodule sync — .gitmodules config refreshed
446
-
447
- Submodules (each handled by its current state)
448
- ✅ {spec_source} [spec] — pulled branch '{spec_branch}' ({spec_branch_source}) → {new-sha}
449
- ✋ user-service [active] — on 'feature/FEAT-01' — left untouched, fetched (↓2 behind origin)
450
- ✅ order-service [passive] — aligned to umbrella pointer {sha}
451
- ⚠️ payment-service [dirty] — uncommitted changes, skipped (commit/stash first)
452
-
453
- Umbrella state
454
- ⚠️ Pointer changed: git add {spec_source} && git commit -m "chore: sync specs"
455
- (or: ✅ Clean — no commit needed)
456
-
457
- Tester feedback (pulled this sync)
458
- 📥 1 bug report: BUG-20260608-01 FT-001 [Code]
459
- 1 proposal: FT-001-trailing-spaces → AC2 (pending review)
460
- (or: 📥 none new this sync)
461
- → /fix-bug {BUG-ID} · promote proposal into BDD · or update PRD
462
-
463
- Service Configs
464
- ✅ user-service — test: mvn test | build: mvn compile
465
- ✅ order-service — test: mvn test | build: mvn compile
466
- ⚠️ payment-service — .agent/project-context.yaml missing
467
- → create it so /dev-run-test works correctly
468
-
469
- .gitignore
470
- ✅ .trace-mirror/ + .living-docs/ gitignored (mirror — sinh lại được)
471
- ✅ {paths.trace_dir}/ KHÔNG bị gitignore (sổ gốc — phải commit)
472
- (hoặc: ⚠️ Thêm .trace-mirror/ vào .gitignore)
473
- (hoặc: 🔴 NGUY HIỂM — sổ gốc {paths.trace_dir} đang bị gitignore, xem Step 4b)
474
-
475
- Living Docs
476
- ✅ {panel_mirror}/ synced — {N} TSVs across {S} services
477
- (chạy /validate-traces để có report coverage đầy đủ)
478
-
479
- Spec Manifest
480
- ✅ spec-manifest.yaml — {N} features indexed
481
-
482
- ---
483
- Status : ✅ Complete | ⚠️ Warnings
484
- Output Artifacts: updated .trace-mirror/ (panel mirror), spec-manifest.yaml
485
- Next : /validate-traces (full coverage check) | /generate-code {UC-ID} (start coding)
486
- ```