@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,81 @@
1
+ ---
2
+ description: "Sync Agent — Cập nhật plan/tasks/tests khi spec thay đổi"
3
+ phase: "Any"
4
+ agent: "sync-agent"
5
+ ---
6
+
7
+ # /v.sync
8
+
9
+ > Orchestration wrapper cho **Sync Agent**. Đọc `agents/sync-agent.md` để thực hiện core logic.
10
+
11
+ > **Nguyên tắc cốt lõi**: `spec.md` là Single Source of Truth — spec luôn thắng.
12
+
13
+ ## Điều kiện tiên quyết
14
+ - `spec.md` đã được chỉnh sửa (bump version) sau khi đã có plan/tasks/tests
15
+ - Artifact Sync Status trong spec.md Status block có **❌** (cần sync)
16
+ - `plan.md`, `tasks.md`, `test-cases.md` phải tồn tại
17
+
18
+ ## Execution
19
+ 1. Đọc agent definition: `agents/sync-agent.md`
20
+ 2. Thực hiện toàn bộ quy trình trong agent definition
21
+ 3. Báo cáo sync summary
22
+
23
+ ## Options
24
+
25
+ ### (không có argument) — Feature hiện tại
26
+ Sync artifacts cho feature đang active trong context.
27
+
28
+ ### --dry-run — Chỉ báo cáo, không sửa
29
+ ```
30
+ /v.sync --dry-run
31
+ ```
32
+ Hiển thị delta analysis mà không thay đổi files.
33
+
34
+ ---
35
+
36
+ ## 🔀 Routing Rules — Sau Sync
37
+
38
+ ```
39
+ Sync hoàn tất
40
+ → Route: /v.check (BẮT BUỘC — validation-report cũ không còn giá trị)
41
+
42
+ Change quá lớn (architecture impact)
43
+ → Route: /v.plan (re-plan từ đầu)
44
+ ```
45
+
46
+ ## Cập nhật State & Session
47
+
48
+ **Cập nhật `.flow-state.yaml`**:
49
+ ```yaml
50
+ spec_version_latest: "vX.Y"
51
+ artifacts:
52
+ plan:
53
+ synced_to_spec: "vX.Y"
54
+ tasks:
55
+ synced_to_spec: "vX.Y"
56
+ test_cases:
57
+ synced_to_spec: "vX.Y"
58
+ validation_report:
59
+ verdict: "PENDING_RECHECK"
60
+ ```
61
+
62
+ **Append vào `_session.md`**:
63
+ ```markdown
64
+ ### [Sync] Spec Sync — [YYYY-MM-DD]
65
+ - **Agent**: Sync Agent
66
+ - **Trigger**: spec v[old] → v[new]
67
+ - **Changes**: [+N tasks, ~M modified, -K superseded]
68
+ - **Tests updated**: [+N, ~M, -K]
69
+ - **Validation**: Reset to PENDING RECHECK
70
+ - **Routing**: → /v.check (mandatory)
71
+ ```
72
+
73
+ ---
74
+
75
+ ## Ví dụ
76
+
77
+ ```
78
+ /v.sync
79
+ /v.sync feature 001-user-login
80
+ /v.sync --dry-run
81
+ ```
@@ -0,0 +1,67 @@
1
+ ---
2
+ description: "Test Agent — Tạo Test Cases toàn diện từ Specification"
3
+ phase: "B.0b"
4
+ agent: "test-agent"
5
+ ---
6
+
7
+ # /v.test
8
+
9
+ > Orchestration wrapper cho **Test Agent**. Đọc `agents/test-agent.md` để thực hiện core logic.
10
+
11
+ Chạy **SONG SONG** với `/v.plan`.
12
+
13
+ ## Điều kiện tiên quyết
14
+ - `spec.md` phải tồn tại và đã **Approved**
15
+ - `constitution.md` phải tồn tại
16
+ - `.flow-state.yaml` phải tồn tại
17
+
18
+ ## Execution
19
+ 1. Đọc agent definition: `agents/test-agent.md`
20
+ 2. Thực hiện toàn bộ quy trình trong agent definition
21
+ 3. Tạo `test-cases.md` với test matrix đầy đủ
22
+
23
+ ---
24
+
25
+ ## 🔀 Routing Rules — Sau Test
26
+
27
+ ```
28
+ Test cases tạo xong
29
+ → Nếu /v.plan chưa xong → Chờ Plan Agent
30
+ → Nếu /v.plan đã xong → /v.check (Master Check)
31
+
32
+ Không đủ thông tin viết test
33
+ → Route: Quay về S.1 (BA Agent clarify REQ)
34
+ ```
35
+
36
+ ## Cập nhật State & Session
37
+
38
+ **Cập nhật `.flow-state.yaml`**:
39
+ ```yaml
40
+ current_phase: "B.0b"
41
+ phase_status: "done"
42
+ artifacts:
43
+ test_cases:
44
+ exists: true
45
+ total: [N]
46
+ synced_to_spec: "v1.0"
47
+ ```
48
+
49
+ **Append vào `_session.md`**:
50
+ ```markdown
51
+ ### [B.0b] Test — [YYYY-MM-DD]
52
+ - **Agent**: Test Agent
53
+ - **Output**: test-cases.md ([N] test cases)
54
+ - **Test Matrix**: Unit: [N], Integration: [N], E2E: [N]
55
+ - **Coverage**: [N]/[N] REQ covered (100%)
56
+ - **Edge cases**: [N] edge case tests
57
+ - **Routing**: → /v.check (khi /v.plan xong)
58
+ ```
59
+
60
+ ---
61
+
62
+ ## Ví dụ
63
+
64
+ ```
65
+ /v.test
66
+ /v.test feature 001-user-login
67
+ ```
@@ -0,0 +1,112 @@
1
+ ---
2
+ description: "Understand Agent — Scan codebase và generate Multi-Layer Understanding (context.md + Module Cards)"
3
+ phase: "U.0"
4
+ agent: "understand-agent"
5
+ ---
6
+
7
+ # /v.understand
8
+
9
+ > Orchestration wrapper cho **Understand Agent**. Đọc `agents/understand-agent.md` để thực hiện core logic.
10
+
11
+ ## Điều kiện tiên quyết
12
+ - `.v-flow/` phải tồn tại (đã chạy `v-flow init`)
13
+ - Codebase phải có source files để scan
14
+ - Nếu dùng `--module`: module name phải tương ứng với domain có trong codebase
15
+
16
+ ## Modes
17
+
18
+ ### Mode 1: `--module {tên}` — Scan 1 module (khuyến khích)
19
+
20
+ ```
21
+ /v.understand --module {tên-module}
22
+ ```
23
+
24
+ Generate folder `.v-flow/modules/domain-{tên}/` gồm 10 file bắt buộc: `SKILL.md`, `use-cases.md`, `api-specs.md`, `tech-context.md`, `cross-service.md`, `db.md`, `state-diagram.md`, `permissions.md`, `business-quiz.md`, `dev-quiz.md` — cộng `ui-flows.md` nếu có FE (tối đa 11).
25
+
26
+ ### Mode 2: `--all` — Scan toàn bộ
27
+
28
+ ```
29
+ /v.understand --all
30
+ ```
31
+
32
+ 1. Generate/update `context.md` (Tầng 1)
33
+ 2. Auto-detect modules → generate tất cả module folders (Tầng 2)
34
+
35
+ ### Mode 3: `--check` — Kiểm tra stale (chỉ báo cáo)
36
+
37
+ ```
38
+ /v.understand --check --module {tên}
39
+ ```
40
+
41
+ ### Mode 4: `--refresh` — Re-scan và update
42
+
43
+ ```
44
+ /v.understand --module {tên} --refresh
45
+ ```
46
+
47
+ ## Execution
48
+ 1. Đọc agent definition: `agents/understand-agent.md`
49
+ 2. Đọc Skill hướng dẫn scan: `skills/understand/codebase-scanner/SKILL.md`
50
+ 3. Thực hiện quy trình trong agent definition theo mode được chọn
51
+ 4. **(Tùy chọn) Verify bằng CLI khi cần** (Bước 6 trong agent): KHÔNG chạy xen kẽ lúc sinh card. Card "xong" theo Quality Gate chiều sâu + đủ file. Khi muốn đối chiếu máy (vd trước Tech Lead review) → `v-flow validate --module-cards <module>` + `v-flow score-card <module>` + `v-flow dev-quiz <module>`. Đây là kiểm tra on-demand, KHÔNG phải điều kiện "xong". Mode `--check` bỏ qua.
52
+
53
+ ---
54
+
55
+ ## ❌ Anti-patterns (Output VÔ GIÁ TRỊ)
56
+
57
+ | Anti-pattern | Ví dụ BAD | Ví dụ GOOD |
58
+ |---|---|---|
59
+ | Liệt kê tên file không giải thích | "Key files: service.ts, controller.ts" | "service.ts (250 LOC): Xử lý CRUD WO, validate business rules" |
60
+ | Business rule chung chung | "Validate input trước khi lưu" | "`amount` phải > 0, `assignee_id` cùng `branch_id` (file: wo_service.dart:89)" |
61
+ | API không chi tiết | "POST /api/orders — Tạo order" | "POST /api/orders — Auth: ROLE_USER. Body: {itemId: required, qty: min:1}." |
62
+
63
+ ---
64
+
65
+ ## 🔀 Routing — Bước tiếp theo
66
+
67
+ ```
68
+ context.md + Module Cards tạo xong (đủ file + đạt Quality Gate chiều sâu)
69
+ → (tùy chọn) Verify máy khi cần: v-flow validate --module-cards <module> + score-card + dev-quiz
70
+ → Tech Lead review: xóa [⚠️ AI-inferred], set Last verified
71
+ → Tiến sang S.0a (/v.constitute) hoặc S.1 (/v.specify)
72
+ ```
73
+
74
+ ## Output
75
+
76
+ | Mode | Output |
77
+ |------|--------|
78
+ | `--all` | `.v-flow/context.md` (v2) + `.v-flow/modules/domain-xxx/` (N folders, mỗi folder đủ bộ card gồm `business-quiz.md` + `dev-quiz.md`) |
79
+ | `--module {tên}` | `.v-flow/modules/domain-{tên}/` (1 folder, 10 file bắt buộc + `ui-flows.md` nếu có FE = tối đa 11) |
80
+ | `--check` | Báo cáo diff (không sửa file) |
81
+ | `--refresh` | Cập nhật module card + bump MINOR version trong `SKILL.md` |
82
+
83
+ ---
84
+
85
+ ## Cập nhật State & Session
86
+
87
+ **Không cập nhật `.flow-state.yaml`** — U.0 là project-level, không per-feature.
88
+
89
+ **Auto-bump MINOR version** (sau mỗi lần ghi module card):
90
+ - `SKILL.md` được cập nhật `version`, `last_updated`, `last_updated_by` tự động
91
+ - Không bump MAJOR — chỉ human mới được bump MAJOR
92
+
93
+ **Ghi vào context.md** (khi `--all`):
94
+ ```markdown
95
+ ## Module Index (auto-generated by /v.understand)
96
+
97
+ | Module | SKILL.md | use-cases | business-quiz | version | Last verified |
98
+ |--------|----------|-----------|---------------|---------|---------------|
99
+ | auth | ✅ | ✅ | ✅ ready | v1.2 | [date] |
100
+ | payment | ✅ | ✅ | ⚠️ draft | v2.0 | [date] |
101
+ ```
102
+
103
+ ---
104
+
105
+ ## Ví dụ
106
+
107
+ ```
108
+ /v.understand --all
109
+ /v.understand --module orders
110
+ /v.understand --module payment --refresh
111
+ /v.understand --check --module auth
112
+ ```
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@longph2102/v-flow",
3
+ "version": "1.5.0",
4
+ "description": "CLI toolkit for V Flow — Agentic AI Software Development Process (Spec-Driven Development)",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "main": "cli/index.js",
9
+ "bin": {
10
+ "v-flow": "./cli/index.js"
11
+ },
12
+ "files": [
13
+ "cli/",
14
+ "agents/",
15
+ "commands/",
16
+ "skills/",
17
+ "templates/",
18
+ "AGENTS.md",
19
+ "README.md",
20
+ "CHANGELOG.md",
21
+ "LICENSE"
22
+ ],
23
+ "scripts": {
24
+ "test": "jest --coverage",
25
+ "test:watch": "jest --watch",
26
+ "lint": "eslint cli/ tests/",
27
+ "lint:fix": "eslint cli/ tests/ --fix",
28
+ "validate": "node cli/index.js validate",
29
+ "validate:strict": "node cli/index.js validate --strict",
30
+ "prepublishOnly": "npm run lint && npm test"
31
+ },
32
+ "keywords": [
33
+ "v-flow",
34
+ "spec-driven-development",
35
+ "agentic-ai",
36
+ "sdlc",
37
+ "ai-agents",
38
+ "specification"
39
+ ],
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "git+https://github.com/quochoang228/v-Flow.git"
43
+ },
44
+ "bugs": {
45
+ "url": "https://github.com/quochoang228/v-Flow/issues"
46
+ },
47
+ "homepage": "https://github.com/quochoang228/v-Flow#readme",
48
+ "author": "quochoang228",
49
+ "license": "MIT",
50
+ "engines": {
51
+ "node": ">=18"
52
+ },
53
+ "dependencies": {
54
+ "chalk": "^4.1.2",
55
+ "commander": "^12.0.0",
56
+ "fs-extra": "^11.2.0",
57
+ "js-yaml": "^4.1.0"
58
+ },
59
+ "devDependencies": {
60
+ "eslint": "^8.57.0",
61
+ "exceljs": "^4.4.0",
62
+ "jest": "^30.3.0",
63
+ "markdown-docx": "^1.6.0"
64
+ }
65
+ }
@@ -0,0 +1,109 @@
1
+ ---
2
+ name: constitution-reader
3
+ description: "Load và parse constitution.md, extract rules áp dụng cho phase hiện tại. Agent PHẢI gọi skill này ở đầu MỖI session."
4
+ trigger: "Đầu mỗi agent session / mỗi phase mới"
5
+ phase: "All"
6
+ used_by:
7
+ - /v.specify
8
+ - /v.plan
9
+ - /v.test
10
+ - /v.check
11
+ - /v.implement
12
+ - /v.review
13
+ ---
14
+
15
+ # Constitution Reader — Load Project Rules
16
+
17
+ > ⚠️ Đây là **Skill dùng chung** — chạy ĐẦU TIÊN trong mọi agent session.
18
+ > Nếu constitution.md không tồn tại → WARN, nhưng vẫn tiếp tục.
19
+ >
20
+ > → Xem `gotchas.md` cho lỗi phổ biến khi đọc constitution.
21
+ > → Xem `examples/good/` cho mẫu output per phase.
22
+
23
+ ---
24
+
25
+ ## Khi nào KHÔNG đọc
26
+
27
+ - Chạy `/v.constitute` (đang TẠO constitution)
28
+ - Chạy `/v.understand` lần đầu (chưa có constitution)
29
+
30
+ ---
31
+
32
+ ## Nguồn Constitution
33
+
34
+ ```
35
+ Đường dẫn: .v-flow/constitution.md
36
+ Nếu không tồn tại → WARN: "No constitution found. Consider running /v.constitute"
37
+ ```
38
+
39
+ ---
40
+
41
+ ## Mapping Sections → Phases
42
+
43
+ > 💡 Agent KHÔNG cần đọc toàn bộ constitution. Chỉ đọc sections LIÊN QUAN cho phase hiện tại.
44
+
45
+ | Constitution Section | Áp dụng cho Phase | Agent đọc |
46
+ |---------------------|:------------------:|-----------|
47
+ | §1 Architecture Principles | B.0a, B.1 | Plan, Implement |
48
+ | §2 Code Standards | B.1, R.1 | Implement, Review |
49
+ | §3 Testing Policy | B.0b, B.1 | Test, Implement |
50
+ | §4 API Conventions | S.1, B.0a | BA, Plan |
51
+ | §5 Security Requirements | ALL | ALL |
52
+ | §6 Naming Conventions | B.1, R.1 | Implement, Review |
53
+ | §7 No-Go Zones | B.0a, B.1 | Plan, Implement |
54
+ | §8 Error Handling | B.0a, B.1 | Plan, Implement |
55
+ | §9 Spec Change Policy | S.1 | BA |
56
+
57
+ ## Per-Agent Extraction Depth
58
+
59
+ > 💡 Mỗi Agent cần KHÁC NHAU từ constitution. Đây là bảng chi tiết:
60
+
61
+ | Agent | Sections cần | Extraction depth | Quyết định gì từ constitution |
62
+ |-------|-------------|:-----:|-----|
63
+ | **BA Agent** | §4, §5, §9 | Shallow | API naming style → ảnh hưởng spec endpoint names |
64
+ | **Plan Agent** | §1, §4, §5, §7, §8 | Deep | Architecture pattern → ảnh hưởng task breakdown |
65
+ | **Test Agent** | §3, §5 | Medium | Coverage target, test strategy → ảnh hưởng TC count |
66
+ | **Implement Agent** | §1-§3, §5-§8 | Deep | Everything — most affected by constitution |
67
+ | **Review Agent** | §1-§8 | Deep | Review criteria derived from rules |
68
+ | **Master Check** | §5, §7 | Shallow | Security và No-Go → blocking concerns |
69
+
70
+ ---
71
+
72
+ ## Cross-Reference With context.md
73
+
74
+ Nếu context.md tồn tại (legacy project):
75
+ - No-Go Zones từ context.md **override** constitution §7
76
+ - Technical Debt từ context.md **bổ sung** vào awareness
77
+ - Architecture thực tế từ context.md **có thể khác** constitution (→ flag mismatch)
78
+
79
+ ### Conflict Resolution
80
+
81
+ | Conflict | Rule |
82
+ |----------|------|
83
+ | context.md nói "monolith" + constitution nói "clean architecture" | Code MỚI → follow constitution. Code CŨ → don't refactor (No-Go) |
84
+ | context.md nói "raw SQL" + constitution nói "ORM" | New features → ORM. Existing queries → keep raw SQL |
85
+ | constitution §7 lists No-Go + context.md lists MORE No-Go | **Union** — cả hai đều block |
86
+ | constitution `[Cần quyết định]` | DỪNG. Ghi _session.md. Hỏi Tech Lead |
87
+ | Version mismatch (constitution updated mid-pipeline) | WARN → suggest `/v.sync` |
88
+
89
+ ---
90
+
91
+ ## Đặc Thù
92
+
93
+ ### Constitution có thể chưa hoàn chỉnh
94
+ - Sections ghi `[Cần quyết định]` → Agent ghi vào _session.md và hỏi Tech Lead
95
+ - KHÔNG tự quyết định thay — **đây là lỗi phổ biến nhất**
96
+
97
+ ### Constitution version
98
+ - Check version ở header → so sánh với .flow-state.yaml `constitution_version`
99
+ - Nếu mismatch → WARN: "Constitution updated since last pipeline run"
100
+ - **Action**: Suggest `/v.sync` để propagate changes
101
+
102
+ ### Multiple projects in monorepo
103
+ - Mỗi sub-project có thể có constitution riêng
104
+ - Đọc constitution gần nhất theo directory hierarchy
105
+
106
+ ### Edge Case: No constitution + No context
107
+ - Greenfield project chưa chạy `/v.constitute`
108
+ - Agent PHẢI vẫn chạy được — dùng best-practice defaults
109
+ - Ghi WARN vào _session.md: "No project rules found"
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "constitution-reader",
3
+ "version": "1.0",
4
+ "description": "Load và parse constitution.md, extract rules áp dụng cho phase hiện tại",
5
+ "agent": "_shared",
6
+ "phase": ["All"],
7
+ "triggers": ["session_start", "phase_change"],
8
+ "dependencies": [],
9
+ "config": {
10
+ "constitution_path": ".v-flow/constitution.md",
11
+ "fallback_behavior": "warn_and_continue",
12
+ "cache_duration": "session",
13
+ "section_mapping": {
14
+ "S.1": ["§4", "§5", "§9"],
15
+ "B.0a": ["§1", "§4", "§5", "§7", "§8"],
16
+ "B.0b": ["§3", "§5"],
17
+ "B.1": ["§1", "§2", "§3", "§5", "§6", "§7", "§8"],
18
+ "R.0": ["§5", "§7"],
19
+ "R.1": ["§1", "§2", "§3", "§5", "§6", "§7", "§8"]
20
+ }
21
+ },
22
+ "setup_questions": [
23
+ {
24
+ "id": "extraction_depth",
25
+ "question": "Default extraction depth khi không có mapping rõ ràng?",
26
+ "options": ["shallow", "medium", "deep"],
27
+ "default": "medium",
28
+ "description": "shallow = chỉ đọc headings. medium = headings + rules. deep = toàn bộ nội dung."
29
+ },
30
+ {
31
+ "id": "version_check",
32
+ "question": "Có kiểm tra constitution version vs .flow-state.yaml không?",
33
+ "type": "boolean",
34
+ "default": true
35
+ },
36
+ {
37
+ "id": "mismatch_action",
38
+ "question": "Khi phát hiện constitution version mismatch?",
39
+ "options": ["warn", "block", "auto-sync"],
40
+ "default": "warn"
41
+ }
42
+ ],
43
+ "hooks": {
44
+ "pre_read": "Check constitution.md tồn tại → nếu không → fallback_behavior",
45
+ "post_read": "Compare constitution version với .flow-state.yaml → warn nếu mismatch"
46
+ },
47
+ "memory": {
48
+ "file": "constitution-reads.log",
49
+ "format": "[date] | [agent] | [phase] | [sections_read] | [version] | [warnings]",
50
+ "purpose": "Track agent nào đọc sections nào — dùng cho audit và optimization"
51
+ }
52
+ }
@@ -0,0 +1,48 @@
1
+ # Good Example — Constitution Reader Output cho Phase B.1
2
+
3
+ > Mẫu output khi constitution-reader extract rules cho Implement Agent.
4
+
5
+ ## Input
6
+ - Phase: B.1 (Implementation)
7
+ - Agent: Implement Agent
8
+ - Constitution: v2.1
9
+
10
+ ## Output
11
+
12
+ ```markdown
13
+ ## Active Constitution Rules (Phase: B.1 Implementation)
14
+
15
+ ### §1 Architecture (ACTIVE)
16
+ - ✅ Clean Architecture: Presentation → Domain → Data
17
+ - ✅ Dependency Rule: inner layers không depend outer layers
18
+ - ✅ Domain layer: pure Dart, no framework imports
19
+
20
+ ### §2 Code Standards (ACTIVE)
21
+ - ✅ camelCase for variables/functions
22
+ - ✅ PascalCase for classes
23
+ - ✅ Max function length: 50 LOC
24
+ - ✅ Max file length: 300 LOC
25
+
26
+ ### §3 Testing (ACTIVE)
27
+ - ✅ Coverage target: ≥ 80%
28
+ - ✅ TDD mandatory: test before code
29
+ - ✅ Naming: should_X_when_Y
30
+
31
+ ### §5 Security (ALWAYS ACTIVE)
32
+ - ✅ No hardcoded secrets
33
+ - ✅ Validate all external input
34
+
35
+ ### §7 No-Go Zones (ACTIVE)
36
+ - 🔴 lib/core/engine/ — FFI bridge, native code
37
+ - 🟡 lib/core/auth/ — shared by 5 modules
38
+
39
+ ### Not applicable for B.1
40
+ - §4 API Conventions → Plan phase only
41
+ - §9 Spec Change Policy → Spec phase only
42
+ ```
43
+
44
+ ## Điểm đáng chú ý
45
+
46
+ ✅ **Chỉ sections liên quan** — skip §4, §9 (không dùng ở B.1)
47
+ ✅ **No-Go Zones LUÔN included** — dù phase nào
48
+ ✅ **Actionable** — rules cụ thể, không generic
@@ -0,0 +1,46 @@
1
+ # Gotchas — Constitution Reader
2
+
3
+ > Cập nhật liên tục khi Agent gặp edge case mới.
4
+ > Đây là "institutional memory" cho constitutional compliance.
5
+
6
+ ---
7
+
8
+ ## Gotchas Phổ Biến
9
+
10
+ 1. ❌ **Đọc toàn bộ constitution mỗi lần** — Waste context window (500+ LOC).
11
+ - **Fix**: Chỉ đọc sections liên quan (xem Per-Agent Extraction Depth table).
12
+ - **Hậu quả**: Agent chậm, context window bị chiếm bởi rules không dùng.
13
+
14
+ 2. ❌ **Constitution nói A, context.md nói B** — Conflict không phát hiện.
15
+ - **VD**: Constitution: "No ORM, use raw SQL". Context.md: "Sequelize ORM đang dùng".
16
+ - **Fix**: context.md reflect THỰC TẾ → ưu tiên context.md cho legacy. Ghi conflict.
17
+ - **Hậu quả**: Agent dùng sai pattern → code inconsistent.
18
+
19
+ 3. ❌ **Bỏ qua `[Cần quyết định]`** — Agent tự fill placeholder.
20
+ - **VD**: §3 Testing: "[Cần quyết định]". Agent pick "80%" tự ý.
21
+ - **Rule**: KHÔNG tự quyết. Ghi vào _session.md, chờ Tech Lead.
22
+ - **Hậu quả**: Tech Lead không biết Agent đã quyết thay.
23
+
24
+ 4. ❌ **Quên No-Go Zones** — Constitution §7 liệt kê nhưng Agent quên extract.
25
+ - **Fix**: Output ALWAYS include No-Go list ở cuối, DÙ phase nào.
26
+ - **Hậu quả**: Implement Agent đụng No-Go → bị block muộn.
27
+
28
+ 5. ❌ **Version mismatch** — Constitution updated nhưng pipeline chạy từ version cũ.
29
+ - **Fix**: Compare header version vs .flow-state.yaml. Flag nếu khác.
30
+ - **Hậu quả**: Agent follow rules cũ → drift.
31
+
32
+ 6. ❌ **Skip constitution cho greenfield** — "Dự án mới, chưa cần rules".
33
+ - **Rule**: Greenfield CŨNG cần. Nếu chưa có → suggest `/v.constitute`.
34
+ - **Hậu quả**: Code không consistent từ đầu.
35
+
36
+ 7. ❌ **§5 Security bị skip** — Agent chỉ đọc §1, §2, quên §5.
37
+ - **Rule**: §5 Security = ALWAYS ACTIVE cho MỌI phase.
38
+ - **Hậu quả**: Security holes không được catch sớm.
39
+
40
+ ---
41
+
42
+ ## Edge Cases
43
+
44
+ - **Monorepo**: Nhiều constitution files → đọc gần nhất theo directory
45
+ - **Empty sections**: Constitution có heading nhưng nội dung trống → treat như [Cần quyết định]
46
+ - **Spec change mid-pipeline**: constitution.md §9 quy định enqueue/interrupt → đọc kỹ