@longph2102/v-flow 1.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 (247) hide show
  1. package/AGENTS.md +265 -0
  2. package/CHANGELOG.md +318 -0
  3. package/LICENSE +21 -0
  4. package/README.md +326 -0
  5. package/agents/ba-agent.md +437 -0
  6. package/agents/ba-critic-agent.md +156 -0
  7. package/agents/ba-to-ptyc-agent.md +112 -0
  8. package/agents/bugfix-analyst-agent.md +221 -0
  9. package/agents/constitute-agent.md +155 -0
  10. package/agents/help-agent.md +168 -0
  11. package/agents/implement-agent.md +220 -0
  12. package/agents/import-ba-docs-agent.md +164 -0
  13. package/agents/master-check-agent.md +228 -0
  14. package/agents/metrics-agent.md +180 -0
  15. package/agents/operations-agent.md +123 -0
  16. package/agents/plan-agent.md +218 -0
  17. package/agents/prototype-agent.md +191 -0
  18. package/agents/retrospective-agent.md +196 -0
  19. package/agents/review-agent.md +210 -0
  20. package/agents/sprint-agent.md +191 -0
  21. package/agents/status-agent.md +186 -0
  22. package/agents/sync-agent.md +201 -0
  23. package/agents/test-agent.md +166 -0
  24. package/agents/understand-agent.md +339 -0
  25. package/cli/commands/check.js +96 -0
  26. package/cli/commands/dev-quiz.js +107 -0
  27. package/cli/commands/doctor.js +348 -0
  28. package/cli/commands/feature.js +259 -0
  29. package/cli/commands/hooks.js +163 -0
  30. package/cli/commands/init.js +189 -0
  31. package/cli/commands/log.js +199 -0
  32. package/cli/commands/plugin.js +230 -0
  33. package/cli/commands/score-card.js +203 -0
  34. package/cli/commands/status.js +269 -0
  35. package/cli/commands/sync.js +59 -0
  36. package/cli/commands/upgrade.js +150 -0
  37. package/cli/commands/validate.js +1259 -0
  38. package/cli/commands/watch.js +151 -0
  39. package/cli/index.js +46 -0
  40. package/cli/lib/ac-test-gate.js +89 -0
  41. package/cli/lib/activity-log.js +209 -0
  42. package/cli/lib/cli-error.js +183 -0
  43. package/cli/lib/constitution-lint.js +561 -0
  44. package/cli/lib/dev-quiz-grade.js +127 -0
  45. package/cli/lib/governance.js +78 -0
  46. package/cli/lib/hook-targets.js +167 -0
  47. package/cli/lib/i18n.js +375 -0
  48. package/cli/lib/knowledge-oracle.js +379 -0
  49. package/cli/lib/logger.js +203 -0
  50. package/cli/lib/module-card-lint.js +304 -0
  51. package/cli/lib/module-card-score.js +223 -0
  52. package/cli/lib/plugins.js +481 -0
  53. package/cli/lib/scanner.js +692 -0
  54. package/cli/lib/sync-core.js +232 -0
  55. package/cli/lib/sync-targets.js +84 -0
  56. package/cli/lib/templates.js +268 -0
  57. package/cli/lib/yaml-parser.js +203 -0
  58. package/commands/v.ba-critic.md +101 -0
  59. package/commands/v.ba-to-ptyc.md +71 -0
  60. package/commands/v.bugfix.md +86 -0
  61. package/commands/v.check.md +131 -0
  62. package/commands/v.constitute.md +87 -0
  63. package/commands/v.constitution.md +84 -0
  64. package/commands/v.fork.md +127 -0
  65. package/commands/v.help.md +73 -0
  66. package/commands/v.hotfix.md +200 -0
  67. package/commands/v.implement.md +92 -0
  68. package/commands/v.import-ba-docs.md +222 -0
  69. package/commands/v.metrics.md +74 -0
  70. package/commands/v.operations.md +70 -0
  71. package/commands/v.plan.md +78 -0
  72. package/commands/v.prototype.md +121 -0
  73. package/commands/v.quickfix.md +169 -0
  74. package/commands/v.retrospective.md +80 -0
  75. package/commands/v.review.md +78 -0
  76. package/commands/v.rewind.md +127 -0
  77. package/commands/v.specify.md +118 -0
  78. package/commands/v.sprint.md +75 -0
  79. package/commands/v.status.md +62 -0
  80. package/commands/v.sync.md +81 -0
  81. package/commands/v.test.md +67 -0
  82. package/commands/v.understand.md +112 -0
  83. package/package.json +65 -0
  84. package/skills/_shared/constitution-reader/SKILL.md +109 -0
  85. package/skills/_shared/constitution-reader/config.json +52 -0
  86. package/skills/_shared/constitution-reader/examples/good/b1-phase-output.md +48 -0
  87. package/skills/_shared/constitution-reader/gotchas.md +46 -0
  88. package/skills/_shared/context-reader/SKILL.md +111 -0
  89. package/skills/_shared/context-reader/config.json +54 -0
  90. package/skills/_shared/context-reader/examples/good/legacy-nodejs-output.md +35 -0
  91. package/skills/_shared/context-reader/gotchas.md +49 -0
  92. package/skills/_shared/ears-notation/SKILL.md +63 -0
  93. package/skills/_shared/ears-notation/config.json +55 -0
  94. package/skills/_shared/ears-notation/examples/good/plan-test-interpretation.md +29 -0
  95. package/skills/_shared/ears-notation/gotchas.md +43 -0
  96. package/skills/check/cross-validator/SKILL.md +206 -0
  97. package/skills/check/cross-validator/config.json +33 -0
  98. package/skills/check/cross-validator/examples/good/validation-report-pass-with-concerns.md +105 -0
  99. package/skills/check/cross-validator/gotchas.md +43 -0
  100. package/skills/implement/constitution-enforcer/SKILL.md +134 -0
  101. package/skills/implement/constitution-enforcer/config.json +16 -0
  102. package/skills/implement/constitution-enforcer/examples/bad/vague-report.md +42 -0
  103. package/skills/implement/constitution-enforcer/examples/good/compliance-report.md +57 -0
  104. package/skills/implement/constitution-enforcer/gotchas.md +26 -0
  105. package/skills/implement/constitution-enforcer/scripts/check-constitution.sh +88 -0
  106. package/skills/implement/no-go-zone-guard/SKILL.md +173 -0
  107. package/skills/implement/no-go-zone-guard/config.json +28 -0
  108. package/skills/implement/no-go-zone-guard/examples/good/adapter-workaround.md +46 -0
  109. package/skills/implement/no-go-zone-guard/gotchas.md +27 -0
  110. package/skills/implement/no-go-zone-guard/scripts/check-nogo-zones.sh +148 -0
  111. package/skills/implement/no-go-zone-guard/scripts/nogo-precommit.sh +96 -0
  112. package/skills/implement/tdd-driver/SKILL.md +159 -0
  113. package/skills/implement/tdd-driver/config.json +33 -0
  114. package/skills/implement/tdd-driver/examples/good/tdd-cycle-product-repo.md +81 -0
  115. package/skills/implement/tdd-driver/gotchas.md +34 -0
  116. package/skills/metrics/metrics-collector/SKILL.md +133 -0
  117. package/skills/metrics/metrics-collector/config.json +16 -0
  118. package/skills/metrics/metrics-collector/examples/bad/incomplete-report.md +48 -0
  119. package/skills/metrics/metrics-collector/examples/good/full-metrics-report.md +101 -0
  120. package/skills/metrics/metrics-collector/gotchas.md +26 -0
  121. package/skills/operations/incident-runbook/SKILL.md +167 -0
  122. package/skills/operations/incident-runbook/config.json +21 -0
  123. package/skills/operations/incident-runbook/examples/bad/vague-incident-report.md +48 -0
  124. package/skills/operations/incident-runbook/examples/good/p1-hotfix-response.md +119 -0
  125. package/skills/operations/incident-runbook/gotchas.md +26 -0
  126. package/skills/plan/architecture-designer/SKILL.md +228 -0
  127. package/skills/plan/architecture-designer/config.json +32 -0
  128. package/skills/plan/architecture-designer/examples/bad/vague-plan.md +62 -0
  129. package/skills/plan/architecture-designer/examples/good/expand-contract-migration.md +56 -0
  130. package/skills/plan/architecture-designer/examples/good/plan-structure.md +58 -0
  131. package/skills/plan/architecture-designer/gotchas.md +45 -0
  132. package/skills/plan/task-breakdown/SKILL.md +208 -0
  133. package/skills/plan/task-breakdown/config.json +26 -0
  134. package/skills/plan/task-breakdown/examples/bad/vague-tasks.md +77 -0
  135. package/skills/plan/task-breakdown/examples/good/spike-clarify-tasks.md +66 -0
  136. package/skills/plan/task-breakdown/examples/good/tasks-login-feature.md +111 -0
  137. package/skills/plan/task-breakdown/gotchas.md +39 -0
  138. package/skills/prototype/LOGIC.md +240 -0
  139. package/skills/prototype/SKILL.md +185 -0
  140. package/skills/prototype/UI.md +407 -0
  141. package/skills/prototype/config.json +104 -0
  142. package/skills/prototype/examples/bad/prototype-notes.md +68 -0
  143. package/skills/prototype/examples/good/prototype-notes-ui.md +109 -0
  144. package/skills/prototype/examples/good/prototype-notes.md +67 -0
  145. package/skills/prototype/gotchas.md +128 -0
  146. package/skills/prototype/scripts/check-flow-state.ps1 +112 -0
  147. package/skills/prototype/scripts/check-flow-state.sh +104 -0
  148. package/skills/prototype/scripts/check-prototype-cleanup.ps1 +124 -0
  149. package/skills/prototype/scripts/check-prototype-cleanup.sh +109 -0
  150. package/skills/prototype/scripts/check-prototype-notes.ps1 +107 -0
  151. package/skills/prototype/scripts/check-prototype-notes.sh +102 -0
  152. package/skills/review/adversarial-reviewer/SKILL.md +137 -0
  153. package/skills/review/adversarial-reviewer/config.json +32 -0
  154. package/skills/review/adversarial-reviewer/examples/good/review-report-template.md +56 -0
  155. package/skills/review/adversarial-reviewer/gotchas.md +46 -0
  156. package/skills/review/adversarial-reviewer/scripts/quick-security-scan.sh +52 -0
  157. package/skills/specify/ba-bpmn-doc-gen/SKILL.md +108 -0
  158. package/skills/specify/ba-bpmn-doc-gen/reference/reference-bpmn-generation.md +528 -0
  159. package/skills/specify/ba-bpmn-doc-gen/reference/reference-drawio-flowchart.md +466 -0
  160. package/skills/specify/ba-critic/SKILL.md +172 -0
  161. package/skills/specify/ba-critic/config.json +32 -0
  162. package/skills/specify/ba-critic/examples/good/critic-report-round1.md +51 -0
  163. package/skills/specify/ba-critic/gotchas.md +40 -0
  164. package/skills/specify/ba-critic/scripts/check-spec-quality.sh +72 -0
  165. package/skills/specify/ba-doc-generator/SKILL.md +102 -0
  166. package/skills/specify/ba-doc-generator/references/template-clevel.md +84 -0
  167. package/skills/specify/ba-doc-generator/references/template-compliance.md +83 -0
  168. package/skills/specify/ba-doc-generator/references/template-dev.md +138 -0
  169. package/skills/specify/ba-doc-generator/references/template-partner.md +167 -0
  170. package/skills/specify/ba-doc-generator/references/template-pm.md +92 -0
  171. package/skills/specify/ba-doc-generator/references/template-review.md +114 -0
  172. package/skills/specify/ba-doc-generator/references/template-tester.md +108 -0
  173. package/skills/specify/ba-doc-generator/references/template-user.md +98 -0
  174. package/skills/specify/bugfix-analyst/SKILL.md +296 -0
  175. package/skills/specify/bugfix-analyst/config.json +41 -0
  176. package/skills/specify/bugfix-analyst/examples/bad/common-mistakes.md +71 -0
  177. package/skills/specify/bugfix-analyst/examples/good/email-validation-bugfix.md +53 -0
  178. package/skills/specify/bugfix-analyst/gotchas.md +51 -0
  179. package/skills/specify/ears-writer/SKILL.md +129 -0
  180. package/skills/specify/ears-writer/config.json +20 -0
  181. package/skills/specify/ears-writer/examples/bad/common-mistakes.md +17 -0
  182. package/skills/specify/ears-writer/examples/good/login-requirements.md +41 -0
  183. package/skills/specify/ears-writer/gotchas.md +43 -0
  184. package/skills/specify/ears-writer/scripts/check-ears-compliance.sh +51 -0
  185. package/skills/test/test-case-generator/SKILL.md +161 -0
  186. package/skills/test/test-case-generator/config.json +33 -0
  187. package/skills/test/test-case-generator/examples/good/test-cases-login.md +104 -0
  188. package/skills/test/test-case-generator/gotchas.md +43 -0
  189. package/skills/understand/ba-docs-scanner/SKILL.md +239 -0
  190. package/skills/understand/ba-docs-scanner/config.json +47 -0
  191. package/skills/understand/ba-docs-scanner/examples/good/work-order-br-extract.md +28 -0
  192. package/skills/understand/ba-docs-scanner/gotchas.md +44 -0
  193. package/skills/understand/ba-docs-scanner/merge-rules.md +47 -0
  194. package/skills/understand/codebase-scanner/SKILL.md +260 -0
  195. package/skills/understand/codebase-scanner/config.json +56 -0
  196. package/skills/understand/codebase-scanner/examples/good/menu-module-output.md +44 -0
  197. package/skills/understand/codebase-scanner/gotchas.md +42 -0
  198. package/skills/understand/codebase-scanner/scripts/scan-project-structure.sh +64 -0
  199. package/templates/DESIGN.md +456 -0
  200. package/templates/agent-command-template.yaml +240 -0
  201. package/templates/agent-config-template.md +170 -0
  202. package/templates/agent-definition-template.md +145 -0
  203. package/templates/agent-metrics-template.md +150 -0
  204. package/templates/api-contract-template.md +72 -0
  205. package/templates/bugfix-report-template.md +195 -0
  206. package/templates/bugfix-spec-template.md +134 -0
  207. package/templates/code-review-report-template.md +119 -0
  208. package/templates/constitution-template.md +234 -0
  209. package/templates/context-template.md +94 -0
  210. package/templates/data-model-template.md +95 -0
  211. package/templates/decision-log-template.md +92 -0
  212. package/templates/flow-state-template.yaml +208 -0
  213. package/templates/github/workflows/v-flow-validate.yml +30 -0
  214. package/templates/knowledge/adr-template.md +70 -0
  215. package/templates/knowledge/api-contract-template.md +140 -0
  216. package/templates/knowledge/domain-glossary.md +29 -0
  217. package/templates/knowledge/golden-tests-readme.md +115 -0
  218. package/templates/knowledge/lessons-learned.md +41 -0
  219. package/templates/knowledge/patterns.md +103 -0
  220. package/templates/module-card/SKILL.md +85 -0
  221. package/templates/module-card/api-specs.md +96 -0
  222. package/templates/module-card/business-quiz.md +119 -0
  223. package/templates/module-card/cross-service.md +125 -0
  224. package/templates/module-card/db.md +85 -0
  225. package/templates/module-card/dev-quiz.md +62 -0
  226. package/templates/module-card/permissions.md +83 -0
  227. package/templates/module-card/state-diagram.md +64 -0
  228. package/templates/module-card/tech-context.md +90 -0
  229. package/templates/module-card/ui-flows.md +91 -0
  230. package/templates/module-card/use-cases.md +142 -0
  231. package/templates/module-template.yaml +161 -0
  232. package/templates/operations-report-template.md +108 -0
  233. package/templates/plan-template.md +308 -0
  234. package/templates/prototype-notes-template.md +116 -0
  235. package/templates/ptyc/PTYC.template.docx +0 -0
  236. package/templates/ptyc/ptyc.meta.example.yaml +44 -0
  237. package/templates/retrospective-report-template.md +136 -0
  238. package/templates/security-review-template.md +84 -0
  239. package/templates/session-template.md +167 -0
  240. package/templates/spec-review-log-template.md +75 -0
  241. package/templates/spec-template.md +229 -0
  242. package/templates/sprint-status-template.md +101 -0
  243. package/templates/tasks-template.md +275 -0
  244. package/templates/test-cases-template.md +124 -0
  245. package/templates/ux-checklist-template.md +79 -0
  246. package/templates/validation-report-template.md +125 -0
  247. package/templates/vflow-config-template.yaml +22 -0
@@ -0,0 +1,140 @@
1
+ # API Contract: [Service/Module Name]
2
+
3
+ > **Version**: 1.0.0
4
+ > **Last Updated**: YYYY-MM-DD
5
+ > **Owner**: [Tên người/team chịu trách nhiệm]
6
+ > **REQ Reference**: REQ-xxx
7
+
8
+ ---
9
+
10
+ ## Overview
11
+
12
+ *(Mô tả ngắn gọn API này phục vụ nghiệp vụ gì)*
13
+
14
+ ---
15
+
16
+ ## Base URL
17
+
18
+ ```
19
+ Production: https://api.example.com/v1
20
+ Staging: https://api-staging.example.com/v1
21
+ ```
22
+
23
+ ---
24
+
25
+ ## Authentication
26
+
27
+ | Method | Header | Notes |
28
+ |--------|--------|-------|
29
+ | Bearer Token | `Authorization: Bearer <token>` | JWT, TTL = 1h |
30
+
31
+ ---
32
+
33
+ ## Endpoints
34
+
35
+ ### POST /resource
36
+
37
+ > **Mô tả**: Tạo mới resource
38
+ > **Auth**: Required
39
+ > **Rate Limit**: 100 req/min
40
+
41
+ #### Request
42
+
43
+ ```json
44
+ {
45
+ "name": "string (required, max 255)",
46
+ "description": "string (optional, max 1000)",
47
+ "category_id": "integer (required)"
48
+ }
49
+ ```
50
+
51
+ #### Response — 201 Created
52
+
53
+ ```json
54
+ {
55
+ "id": 1,
56
+ "name": "Example",
57
+ "description": "...",
58
+ "category_id": 1,
59
+ "created_at": "2026-04-27T00:00:00Z",
60
+ "updated_at": null
61
+ }
62
+ ```
63
+
64
+ #### Error Responses
65
+
66
+ | Status | Code | Message | When |
67
+ |--------|------|---------|------|
68
+ | 400 | `VALIDATION_ERROR` | Field-level error details | Invalid input |
69
+ | 401 | `UNAUTHORIZED` | "Authentication required" | Missing/invalid token |
70
+ | 409 | `CONFLICT` | "Resource already exists" | Duplicate name |
71
+ | 422 | `UNPROCESSABLE` | "Category not found" | Invalid category_id |
72
+ | 500 | `INTERNAL_ERROR` | "Internal server error" | Unexpected failure |
73
+
74
+ ---
75
+
76
+ ### GET /resource/:id
77
+
78
+ > **Mô tả**: Lấy thông tin resource theo ID
79
+ > **Auth**: Required
80
+
81
+ #### Response — 200 OK
82
+
83
+ ```json
84
+ {
85
+ "id": 1,
86
+ "name": "Example",
87
+ "description": "...",
88
+ "category_id": 1,
89
+ "created_at": "2026-04-27T00:00:00Z",
90
+ "updated_at": null
91
+ }
92
+ ```
93
+
94
+ #### Error Responses
95
+
96
+ | Status | Code | When |
97
+ |--------|------|------|
98
+ | 404 | `NOT_FOUND` | Resource does not exist |
99
+
100
+ ---
101
+
102
+ ## Data Models
103
+
104
+ ### Resource
105
+
106
+ | Field | Type | Constraints | Notes |
107
+ |-------|------|------------|-------|
108
+ | `id` | integer | PK, auto-increment | |
109
+ | `name` | string | max 255, unique | |
110
+ | `description` | string | max 1000, nullable | |
111
+ | `category_id` | integer | FK → categories.id | |
112
+ | `created_at` | datetime | auto-set | ISO 8601 |
113
+ | `updated_at` | datetime | nullable | ISO 8601 |
114
+
115
+ ---
116
+
117
+ ## SLA & Performance
118
+
119
+ | Metric | Target |
120
+ |--------|--------|
121
+ | P95 Latency | < 200ms |
122
+ | Availability | 99.9% |
123
+ | Rate Limit | 100 req/min per user |
124
+ | Max Payload | 1MB |
125
+
126
+ ---
127
+
128
+ ## Versioning Policy
129
+
130
+ - **Breaking changes** → Increment major version (v1 → v2)
131
+ - **Additive changes** → No version bump (new optional fields OK)
132
+ - **Deprecation** → 6-month sunset notice in `Sunset` header
133
+
134
+ ---
135
+
136
+ ## Change Log
137
+
138
+ | Date | Version | Changes |
139
+ |------|---------|---------|
140
+ | YYYY-MM-DD | 1.0.0 | Initial contract |
@@ -0,0 +1,29 @@
1
+ # Domain Glossary
2
+
3
+ > Từ điển thuật ngữ của dự án. Cập nhật khi gặp thuật ngữ mới.
4
+ > Agent PHẢI dùng đúng thuật ngữ từ glossary — không dùng synonym.
5
+
6
+ ---
7
+
8
+ ## Thuật ngữ V-Flow
9
+
10
+ | Thuật ngữ | Định nghĩa | Context |
11
+ |-----------|------------|--------|
12
+ | **Spec** | Specification — đặc tả yêu cầu kỹ thuật, Single Source of Truth | S.1 phase |
13
+ | **Constitution** | Bộ nguyên tắc và luật lệ của dự án — mọi Agent phải tuân thủ | S.0a phase |
14
+ | **EARS** | Easy Approach to Requirements Syntax — 4 loại: Ubiquitous, Event, State, Optional | S.1 phase |
15
+ | **No-Go Zone** | Vùng code mà Agent KHÔNG được sửa | context.md |
16
+ | **Master Check** | Quality gate — cross-validate Spec↔Plan↔Tests | R.0 phase |
17
+ | **Concern** | Warning (W-xxx) từ Master Check — phải resolve | R.0 → B.1 |
18
+ | **Routing** | Quyết định next phase sau Master Check | R.0 output |
19
+ | **Golden Test** | Test case mẫu chất lượng cao, dùng làm reference | Knowledge base |
20
+ | **Flow State** | Trạng thái pipeline dạng machine-readable (YAML) | .flow-state.yaml |
21
+ | **Session** | Working memory — ghi lại decisions, trace | _session.md |
22
+
23
+ ## Thuật ngữ dự án
24
+
25
+ *Điền thuật ngữ domain-specific của dự án ở đây*
26
+
27
+ | Thuật ngữ | Định nghĩa | Context |
28
+ |-----------|------------|--------|
29
+ | | | |
@@ -0,0 +1,115 @@
1
+ # Golden Tests — Hướng Dẫn
2
+
3
+ > Golden tests là **bộ test tham chiếu** — input + expected output cố định — dùng để đảm bảo behavior không thay đổi sau khi refactor hoặc thêm tính năng.
4
+
5
+ ---
6
+
7
+ ## Khi Nào Cần Golden Test?
8
+
9
+ | Tình huống | Lý do |
10
+ |-----------|-------|
11
+ | API response format | Đảm bảo backward compatibility |
12
+ | Template generation output | Verify output không bị sai sau refactor |
13
+ | State machine transitions | Lock valid state transitions |
14
+ | Complex business rules | Document exact expected behavior |
15
+ | Data migration | Verify data transform đúng |
16
+
17
+ ---
18
+
19
+ ## Cấu Trúc Golden Test
20
+
21
+ ```
22
+ knowledge/golden-tests/
23
+ ├── README.md ← File này
24
+ ├── api-responses/
25
+ │ ├── get-user.input.json
26
+ │ ├── get-user.expected.json
27
+ │ ├── create-order.input.json
28
+ │ └── create-order.expected.json
29
+ ├── state-transitions/
30
+ │ ├── order-lifecycle.input.yaml
31
+ │ └── order-lifecycle.expected.yaml
32
+ └── templates/
33
+ ├── context-md.input.json
34
+ └── context-md.expected.md
35
+ ```
36
+
37
+ ---
38
+
39
+ ## Quy Tắc
40
+
41
+ 1. **Tên file có ý nghĩa** — `{action}.input.{ext}` + `{action}.expected.{ext}`
42
+ 2. **Không dùng mock** — Golden test dùng dữ liệu thật hoặc realistic fixtures
43
+ 3. **Khi test fail → xác nhận** — Nếu expected output thay đổi là intentional → update golden file
44
+ 4. **Ghi ngày tạo** — Trong comment hoặc metadata, ghi ngày golden test được tạo
45
+ 5. **Liên kết REQ** — Mỗi golden test nên tham chiếu REQ-xxx nếu có
46
+
47
+ ---
48
+
49
+ ## Template Cho Golden Test
50
+
51
+ ### Input file (`*.input.json`)
52
+
53
+ ```json
54
+ {
55
+ "_meta": {
56
+ "created": "YYYY-MM-DD",
57
+ "req": "REQ-xxx",
58
+ "description": "Mô tả scenario"
59
+ },
60
+ "data": {
61
+ // Input data cho function/API
62
+ }
63
+ }
64
+ ```
65
+
66
+ ### Expected file (`*.expected.json`)
67
+
68
+ ```json
69
+ {
70
+ "_meta": {
71
+ "approved_by": "Tên người approve",
72
+ "approved_date": "YYYY-MM-DD"
73
+ },
74
+ "result": {
75
+ // Expected output
76
+ }
77
+ }
78
+ ```
79
+
80
+ ---
81
+
82
+ ## Ví Dụ: Scan Codebase → context.md
83
+
84
+ **Input** (`context-md.input.json`):
85
+ ```json
86
+ {
87
+ "_meta": { "created": "2026-04-27", "req": "U.0", "description": "Scanner generates context.md" },
88
+ "data": {
89
+ "projectName": "my-app",
90
+ "languages": ["TypeScript", "JavaScript"],
91
+ "frameworks": ["Next.js", "React"],
92
+ "testingTools": ["Jest"],
93
+ "packageManager": "pnpm"
94
+ }
95
+ }
96
+ ```
97
+
98
+ **Expected** (`context-md.expected.md`):
99
+ ```markdown
100
+ # context.md — Codebase Understanding Report
101
+ > **Dự án**: my-app
102
+ ...
103
+ | **Ngôn ngữ chính** | TypeScript, JavaScript |
104
+ | **Framework** | Next.js, React |
105
+ ```
106
+
107
+ ---
108
+
109
+ ## Tích Hợp Với CI
110
+
111
+ ```yaml
112
+ # .github/workflows/golden-tests.yml
113
+ - name: Run Golden Tests
114
+ run: npx jest tests/golden/ --ci
115
+ ```
@@ -0,0 +1,41 @@
1
+ # V-Flow Lessons Learned
2
+
3
+ > Bài học rút ra từ các feature cycles. Cập nhật sau mỗi `/v.retrospective`.
4
+
5
+ ---
6
+
7
+ ## Template Entry
8
+
9
+ ```markdown
10
+ ### LL-{N}: {Tiêu đề}
11
+ - **Feature**: {feature name}
12
+ - **Phase**: {phase khi phát hiện}
13
+ - **Mô tả**: {bối cảnh + vấn đề}
14
+ - **Bài học**: {rút ra điều gì}
15
+ - **Action**: {thay đổi process/skill/constitution}
16
+ ```
17
+
18
+ ---
19
+
20
+ ## Entries
21
+
22
+ ### LL-001: Master Check bắt issues BA/Plan bỏ sót
23
+ - **Feature**: 001-user-login
24
+ - **Phase**: R.0 (Master Check)
25
+ - **Mô tả**: BA Agent và Plan Agent không đề cập rate limiting cho login API. Master Check phát hiện qua concern W-001.
26
+ - **Bài học**: Cross-validation giữa 3 artifacts (Spec↔Plan↔Tests) hiệu quả hơn review từng artifact riêng.
27
+ - **Action**: Thêm "Security considerations" checklist vào BA Agent spec.
28
+
29
+ ### LL-002: API response format change là breaking change
30
+ - **Feature**: 002-legacy-crud
31
+ - **Phase**: R.0 (Master Check)
32
+ - **Mô tả**: GET /api/products đổi từ array sang `{ data, pagination }` object. Master Check phát hiện W-002.
33
+ - **Bài học**: Mọi API response format change cần explicit approval từ Tech Lead, kèm migration plan cho consumers.
34
+ - **Action**: Thêm "Backward Compatibility Check" vào Plan Agent checklist cho legacy projects.
35
+
36
+ ### LL-003: EARS notation giúp tránh requirement ambiguity
37
+ - **Feature**: 001-user-login
38
+ - **Phase**: S.1 (Specification)
39
+ - **Mô tả**: Trước EARS: "User đăng nhập được" → không measurable. Sau EARS: "Khi user nhấn Đăng nhập, hệ thống phải validate email format" → clear, testable.
40
+ - **Bài học**: EARS notation bắt buộc Agent viết requirements có structure, mỗi loại (U/E/S/O) map rõ vào component type.
41
+ - **Action**: EARS notation là standard bắt buộc cho tất cả projects, không phải optional.
@@ -0,0 +1,103 @@
1
+ # V-Flow Patterns Library
2
+
3
+ > Reusable patterns cho development pipeline. Mỗi entry mô tả KHI NÀO dùng, CÁCH dùng, và GOTCHAS.
4
+
5
+ ---
6
+
7
+ ## 1. Adapter Pattern (No-Go Zone Workaround)
8
+
9
+ **Khi dùng**: Cần interact với No-Go Zone module mà không sửa nó.
10
+
11
+ ```
12
+ // Thay vì sửa no-go-module trực tiếp
13
+ // Tạo adapter wrap interface cần thiết
14
+
15
+ // adapters/payment-adapter.js
16
+ const payment = require('../no-go/payment');
17
+ module.exports = {
18
+ getStatus: (id) => payment.checkStatus(id), // wrap method hiện có
19
+ // Thêm method mới MÀ KHÔNG SỬA payment module
20
+ getStatusFormatted: (id) => {
21
+ const raw = payment.checkStatus(id);
22
+ return { ...raw, formattedDate: formatDate(raw.date) };
23
+ }
24
+ };
25
+ ```
26
+
27
+ **Gotcha**: Adapter KHÔNG được modify behavior của original — chỉ wrap hoặc extend.
28
+
29
+ ---
30
+
31
+ ## 2. Concern Carry-Forward Pattern
32
+
33
+ **Khi dùng**: Master Check (R.0) phát hiện concern (W-xxx) → track qua B.1 → verify ở R.1.
34
+
35
+ ```
36
+ R.0: validation-report.md
37
+ → W-001: "Thiếu rate limiting"
38
+ → Route: B.1, assigned_to: T-004
39
+
40
+ B.1: _session.md
41
+ → Agent đọc concerns từ validation-report.md
42
+ → Implement fix trong T-004
43
+ → Ghi: "W-001: Resolved — added loginAttempts counter"
44
+
45
+ R.1: code-review-report.md
46
+ → Review Agent verify W-001 resolved
47
+ → Check implementation quality
48
+ ```
49
+
50
+ **Gotcha**: KHÔNG skip concerns. Review Agent PHẢI verify mỗi W-xxx.
51
+
52
+ ---
53
+
54
+ ## 3. Regression Test Pattern
55
+
56
+ **Khi dùng**: Refactor legacy code — verify existing behavior giữ nguyên.
57
+
58
+ ```
59
+ 1. TRƯỚC refactor: capture current behavior
60
+ - Record API responses cho tất cả endpoints
61
+ - Document expected behavior
62
+
63
+ 2. SAU refactor: run regression suite
64
+ - Same inputs → same outputs
65
+ - Performance không degrade
66
+ - Error codes/messages giữ nguyên
67
+
68
+ 3. ĐẶC BIỆT chú ý:
69
+ - Response format changes (breaking!)
70
+ - Side effects (events, notifications)
71
+ - Error handling differences
72
+ ```
73
+
74
+ **Gotcha**: "Same behavior" bao gồm cả error paths, không chỉ happy paths.
75
+
76
+ ---
77
+
78
+ ## 4. TDD Red-Green-Refactor Pattern
79
+
80
+ **Khi dùng**: Implement mọi task trong tasks.md.
81
+
82
+ ```
83
+ 🔴 RED: test-cases.md → viết test → chạy → FAIL
84
+ 🟢 GREEN: viết code tối thiểu → chạy → PASS
85
+ 🔵 REFACTOR: clean code → chạy → vẫn PASS
86
+ ```
87
+
88
+ **Gotcha**: Nếu test PASS ngay ở RED → test sai, xem lại.
89
+
90
+ ---
91
+
92
+ ## 5. Dual BA Loop Pattern
93
+
94
+ **Khi dùng**: Feature phức tạp cần spec review kỹ — `/v.specify --dual`.
95
+
96
+ ```
97
+ Round 1: BA Agent → draft spec.md
98
+ Round 2: BA Critic → phản biện (≥3 issues)
99
+ Round 3: BA Agent → revise spec
100
+ (Optional) Round 4: BA Critic → final check
101
+ ```
102
+
103
+ **Gotcha**: BA Critic PHẢI fresh context mỗi round — không bị ảnh hưởng round trước.
@@ -0,0 +1,85 @@
1
+ <!-- HEADING MAP — Agent PHẢI dùng CHÍNH XÁC các heading dưới đây:
2
+ # Domain: {Tên Module}
3
+ ## Quick Summary
4
+ ## Key Business Rules
5
+ ## Key Entities
6
+ ## ⚠️ No-Go Zones (trong module này)
7
+ ## 📂 Supporting Files
8
+ -->
9
+ ---
10
+ name: domain-{tên-module}
11
+ version: "1.0" # MAJOR.MINOR — bump khi có thay đổi. MAJOR = business rule thay đổi lớn; MINOR = bổ sung/clarification
12
+ last_updated: "YYYY-MM-DD" # auto-set khi bump version
13
+ last_updated_by: "v.understand" # "human" | "v.understand" | "v.sync" | tên agent khác
14
+ description: "{Mô tả chức năng cốt lõi — module làm gì, tích hợp với gì, dùng pattern gì}"
15
+ user-invocable: false
16
+ when_to_use: "Khi làm feature liên quan đến {keywords cụ thể}"
17
+ ---
18
+
19
+ > ⚠️ **Versioning Convention**: Nếu bạn chỉnh sửa bất kỳ file nào trong thư mục module card này, hãy bump `version` trong file này trước khi commit. **MAJOR** nếu thay đổi business rule/flow. **MINOR** nếu bổ sung chi tiết hoặc fix sai sót nhỏ.
20
+
21
+ # Domain: {Tên Module}
22
+
23
+ **Service(s)**: {danh sách service chủ}
24
+ **Complexity**: {⭐ đến ⭐⭐⭐⭐⭐} — {giải thích ngắn}
25
+ **Last verified**: {YYYY-MM-DD}
26
+ **Files count**: {N files} | **LOC ước tính**: {~X dòng}
27
+
28
+ ## Quick Summary
29
+
30
+ <!-- HƯỚNG DẪN: Viết 3-4 câu PHÂN TÍCH CHUYÊN SÂU kiến trúc module — KHÔNG phải mô tả chung chung.
31
+ Phải nêu rõ: pattern sử dụng, cách tổ chức layer, state management, tích hợp gì, thiếu gì.
32
+ VD: "Module X sử dụng Clean Architecture (entity → usecases → repository). Frontend dùng Riverpod StateNotifier.
33
+ Backend xử lý qua Isolate riêng. Dữ liệu lưu SQLite local. Không có unit test cho business logic."
34
+ -->
35
+
36
+ {Viết phân tích chuyên sâu ở đây — KHÔNG copy đoạn VD trên}
37
+
38
+ ## Key Business Rules
39
+
40
+ > ⚠️ Trích xuất TỪ CODE CỤ THỂ. Mỗi rule phải kèm file + hàm tham chiếu.
41
+
42
+ <!-- HƯỚNG DẪN: Mỗi BR phải có dạng:
43
+ - Source: `tên_file_thực.dart:dòng`, hàm `tên_hàm_thực`
44
+ - Code: `đoạn code ngắn thực tế từ codebase`
45
+ KHI CHƯA SCAN: Để trống hoặc ghi [❓ CẦN SCAN CODE]
46
+ -->
47
+
48
+ - **BR-01**: {Rule quan trọng nhất — mô tả chi tiết điều kiện, hành động, ngoại lệ}
49
+ - Source: `{file_thực}:{line}`, hàm `{function_thực}`
50
+ - [⚠️ AI-inferred]
51
+ - **BR-02**: {Rule quan trọng thứ 2}
52
+ - Source: `{file_thực}:{line}`
53
+ - [⚠️ AI-inferred]
54
+
55
+ ## Key Entities
56
+
57
+ > Liệt kê models/entities chính kèm fields quan trọng và bảng DB.
58
+
59
+ <!-- HƯỚNG DẪN: Lấy TỪ CODE THỰC TẾ — entity/model files, ORM definitions.
60
+ Phải ghi đúng tên class, tên bảng, tên fields từ codebase.
61
+ -->
62
+
63
+ - `{EntityName}` — {mô tả ngắn}
64
+ - **Bảng DB**: `{table_name_thực}`
65
+ - **Fields chính**: `{field1}` ({type}), `{field2}` ({type}, {constraint})
66
+ - **Relationships**: → `{RelatedEntity}` (1-n)
67
+
68
+ ## ⚠️ No-Go Zones (trong module này)
69
+
70
+ > Files/methods nguy hiểm — Agent KHÔNG đụng nếu không có chỉ định rõ ràng.
71
+
72
+ | File / Method | LOC | Có Test? | Lý do không đụng |
73
+ |---|---|---|---|
74
+ | `{file_thực}` | {N} | ❌ | {lý do cụ thể} |
75
+
76
+ ## 📂 Supporting Files
77
+
78
+ - [use-cases.md](use-cases.md) — Luồng E2E, state machines, business rules chi tiết
79
+ - [api-specs.md](api-specs.md) — API endpoints, data contracts, enums
80
+ - [ui-flows.md](ui-flows.md) — Màn hình, UI components, field mapping
81
+ - [tech-context.md](tech-context.md) — Patterns, key files, tech debt
82
+ - [cross-service.md](cross-service.md) — Tích hợp với modules/services khác
83
+ - [db.md](db.md) — Database schema, quan hệ bảng, DDL links
84
+ - [state-diagram.md](state-diagram.md) — Chi tiết state machine, triggers
85
+ - [permissions.md](permissions.md) — Ma trận phân quyền, roles, data policies
@@ -0,0 +1,96 @@
1
+ <!-- HEADING MAP — Agent PHẢI dùng CHÍNH XÁC các heading dưới đây:
2
+ # API Specs: {Tên Module}
3
+ ## 1. Endpoints
4
+ ### {Nhóm chức năng}
5
+ #### `{METHOD}` {/path/thực}
6
+ ## 2. Data Contracts (DTOs)
7
+ ### {TênDTO_thực}
8
+ ## 3. Enums & Constants
9
+ ## 4. Error Codes (Module-specific)
10
+ -->
11
+ # API Specs: {Tên Module}
12
+
13
+ > **Audience chính**: Dev
14
+ > **AI generate**: Scan controllers, DTOs, entities → auto-generate. Human review accuracy.
15
+
16
+ **Service**: {tên service thực}
17
+ **Base path**: {base path thực từ code}
18
+ **Auth scheme**: {scheme thực — VD: Bearer JWT, API Key, Session, hoặc "N/A — local app"}
19
+
20
+ ---
21
+
22
+ ## 1. Endpoints
23
+
24
+ > ⚠️ Liệt kê TẤT CẢ endpoints trong module. Mỗi endpoint phải có đủ: Method, Path, Auth, Request, Response, Error cases.
25
+ > Nếu module KHÔNG có REST API (VD: mobile-only, library module) → ghi rõ và liệt kê internal method calls thay thế.
26
+
27
+ ### {Nhóm 1: tên nhóm chức năng}
28
+
29
+ <!-- HƯỚNG DẪN: Với mỗi endpoint, mô tả ĐẦY ĐỦ:
30
+ - Chức năng cụ thể (không chung chung)
31
+ - Auth: role cụ thể từ code
32
+ - Controller file + line number
33
+ - Request Body/Params: TỪNG field với type, required, validation
34
+ - Response: format JSON thực tế
35
+ - Errors: error codes + điều kiện trigger cụ thể
36
+ -->
37
+
38
+ #### `{METHOD}` {/path/thực/từ/code}
39
+
40
+ - **Chức năng**: {mô tả cụ thể}
41
+ - **Auth**: {role cụ thể từ code}
42
+ - **Controller**: `{file_thực}:{line}` → hàm `{function_thực}`
43
+ - **Request Body**:
44
+ ```json
45
+ {
46
+ "{field_thực_1}": "{type} ({required/optional}, {validation})",
47
+ "{field_thực_2}": "{type} ({required/optional}, {validation})"
48
+ }
49
+ ```
50
+ - **Response {status_code}**:
51
+ ```json
52
+ {
53
+ "{field_thực}": "{type — mô tả}"
54
+ }
55
+ ```
56
+ - **Errors**:
57
+ | Code | Điều kiện | Message |
58
+ |---|---|---|
59
+ | {code} | {điều kiện từ code} | "{message từ code}" |
60
+
61
+ #### `{METHOD}` {/path/thực/từ/code/2}
62
+
63
+ - **Chức năng**: {mô tả}
64
+ - **Auth**: {roles}
65
+ - **Query Params** (nếu GET):
66
+ | Param | Type | Required | Mô tả | Default |
67
+ |---|---|---|---|---|
68
+ | `{param}` | {type} | {✅/❌} | {mô tả} | {default} |
69
+
70
+ ---
71
+
72
+ ## 2. Data Contracts (DTOs)
73
+
74
+ > ⚠️ Liệt kê CHI TIẾT từng field. Không bỏ sót validation rules.
75
+
76
+ ### {TênDTO_thực}
77
+
78
+ | Field | Type | Required | Validation | Ghi chú |
79
+ |---|---|---|---|---|
80
+ | `{field_thực}` | `{type}` | {✅/❌} | `{validation annotation thực}` | {mô tả} |
81
+
82
+ ---
83
+
84
+ ## 3. Enums & Constants
85
+
86
+ | Enum | Values | Ý nghĩa | File reference |
87
+ |---|---|---|---|
88
+ | `{EnumName_thực}` | `{VALUE_1}`, `{VALUE_2}`, ... | {ý nghĩa} | `{file_thực}:{line}` |
89
+
90
+ ---
91
+
92
+ ## 4. Error Codes (Module-specific)
93
+
94
+ | HTTP Code | Error Code | Message | Điều kiện trigger | File reference |
95
+ |---|---|---|---|---|
96
+ | {code} | `{ERROR_CODE_thực}` | "{message thực}" | {điều kiện từ code} | `{file_thực}:{line}` |