@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.
- package/AGENTS.md +265 -0
- package/CHANGELOG.md +318 -0
- package/LICENSE +21 -0
- package/README.md +326 -0
- package/agents/ba-agent.md +437 -0
- package/agents/ba-critic-agent.md +156 -0
- package/agents/ba-to-ptyc-agent.md +112 -0
- package/agents/bugfix-analyst-agent.md +221 -0
- package/agents/constitute-agent.md +155 -0
- package/agents/help-agent.md +168 -0
- package/agents/implement-agent.md +220 -0
- package/agents/import-ba-docs-agent.md +164 -0
- package/agents/master-check-agent.md +228 -0
- package/agents/metrics-agent.md +180 -0
- package/agents/operations-agent.md +123 -0
- package/agents/plan-agent.md +218 -0
- package/agents/prototype-agent.md +191 -0
- package/agents/retrospective-agent.md +196 -0
- package/agents/review-agent.md +210 -0
- package/agents/sprint-agent.md +191 -0
- package/agents/status-agent.md +186 -0
- package/agents/sync-agent.md +201 -0
- package/agents/test-agent.md +166 -0
- package/agents/understand-agent.md +339 -0
- package/cli/commands/check.js +96 -0
- package/cli/commands/dev-quiz.js +107 -0
- package/cli/commands/doctor.js +348 -0
- package/cli/commands/feature.js +259 -0
- package/cli/commands/hooks.js +163 -0
- package/cli/commands/init.js +189 -0
- package/cli/commands/log.js +199 -0
- package/cli/commands/plugin.js +230 -0
- package/cli/commands/score-card.js +203 -0
- package/cli/commands/status.js +269 -0
- package/cli/commands/sync.js +59 -0
- package/cli/commands/upgrade.js +150 -0
- package/cli/commands/validate.js +1259 -0
- package/cli/commands/watch.js +151 -0
- package/cli/index.js +46 -0
- package/cli/lib/ac-test-gate.js +89 -0
- package/cli/lib/activity-log.js +209 -0
- package/cli/lib/cli-error.js +183 -0
- package/cli/lib/constitution-lint.js +561 -0
- package/cli/lib/dev-quiz-grade.js +127 -0
- package/cli/lib/governance.js +78 -0
- package/cli/lib/hook-targets.js +167 -0
- package/cli/lib/i18n.js +375 -0
- package/cli/lib/knowledge-oracle.js +379 -0
- package/cli/lib/logger.js +203 -0
- package/cli/lib/module-card-lint.js +304 -0
- package/cli/lib/module-card-score.js +223 -0
- package/cli/lib/plugins.js +481 -0
- package/cli/lib/scanner.js +692 -0
- package/cli/lib/sync-core.js +232 -0
- package/cli/lib/sync-targets.js +84 -0
- package/cli/lib/templates.js +268 -0
- package/cli/lib/yaml-parser.js +203 -0
- package/commands/v.ba-critic.md +101 -0
- package/commands/v.ba-to-ptyc.md +71 -0
- package/commands/v.bugfix.md +86 -0
- package/commands/v.check.md +131 -0
- package/commands/v.constitute.md +87 -0
- package/commands/v.constitution.md +84 -0
- package/commands/v.fork.md +127 -0
- package/commands/v.help.md +73 -0
- package/commands/v.hotfix.md +200 -0
- package/commands/v.implement.md +92 -0
- package/commands/v.import-ba-docs.md +222 -0
- package/commands/v.metrics.md +74 -0
- package/commands/v.operations.md +70 -0
- package/commands/v.plan.md +78 -0
- package/commands/v.prototype.md +121 -0
- package/commands/v.quickfix.md +169 -0
- package/commands/v.retrospective.md +80 -0
- package/commands/v.review.md +78 -0
- package/commands/v.rewind.md +127 -0
- package/commands/v.specify.md +118 -0
- package/commands/v.sprint.md +75 -0
- package/commands/v.status.md +62 -0
- package/commands/v.sync.md +81 -0
- package/commands/v.test.md +67 -0
- package/commands/v.understand.md +112 -0
- package/package.json +65 -0
- package/skills/_shared/constitution-reader/SKILL.md +109 -0
- package/skills/_shared/constitution-reader/config.json +52 -0
- package/skills/_shared/constitution-reader/examples/good/b1-phase-output.md +48 -0
- package/skills/_shared/constitution-reader/gotchas.md +46 -0
- package/skills/_shared/context-reader/SKILL.md +111 -0
- package/skills/_shared/context-reader/config.json +54 -0
- package/skills/_shared/context-reader/examples/good/legacy-nodejs-output.md +35 -0
- package/skills/_shared/context-reader/gotchas.md +49 -0
- package/skills/_shared/ears-notation/SKILL.md +63 -0
- package/skills/_shared/ears-notation/config.json +55 -0
- package/skills/_shared/ears-notation/examples/good/plan-test-interpretation.md +29 -0
- package/skills/_shared/ears-notation/gotchas.md +43 -0
- package/skills/check/cross-validator/SKILL.md +206 -0
- package/skills/check/cross-validator/config.json +33 -0
- package/skills/check/cross-validator/examples/good/validation-report-pass-with-concerns.md +105 -0
- package/skills/check/cross-validator/gotchas.md +43 -0
- package/skills/implement/constitution-enforcer/SKILL.md +134 -0
- package/skills/implement/constitution-enforcer/config.json +16 -0
- package/skills/implement/constitution-enforcer/examples/bad/vague-report.md +42 -0
- package/skills/implement/constitution-enforcer/examples/good/compliance-report.md +57 -0
- package/skills/implement/constitution-enforcer/gotchas.md +26 -0
- package/skills/implement/constitution-enforcer/scripts/check-constitution.sh +88 -0
- package/skills/implement/no-go-zone-guard/SKILL.md +173 -0
- package/skills/implement/no-go-zone-guard/config.json +28 -0
- package/skills/implement/no-go-zone-guard/examples/good/adapter-workaround.md +46 -0
- package/skills/implement/no-go-zone-guard/gotchas.md +27 -0
- package/skills/implement/no-go-zone-guard/scripts/check-nogo-zones.sh +148 -0
- package/skills/implement/no-go-zone-guard/scripts/nogo-precommit.sh +96 -0
- package/skills/implement/tdd-driver/SKILL.md +159 -0
- package/skills/implement/tdd-driver/config.json +33 -0
- package/skills/implement/tdd-driver/examples/good/tdd-cycle-product-repo.md +81 -0
- package/skills/implement/tdd-driver/gotchas.md +34 -0
- package/skills/metrics/metrics-collector/SKILL.md +133 -0
- package/skills/metrics/metrics-collector/config.json +16 -0
- package/skills/metrics/metrics-collector/examples/bad/incomplete-report.md +48 -0
- package/skills/metrics/metrics-collector/examples/good/full-metrics-report.md +101 -0
- package/skills/metrics/metrics-collector/gotchas.md +26 -0
- package/skills/operations/incident-runbook/SKILL.md +167 -0
- package/skills/operations/incident-runbook/config.json +21 -0
- package/skills/operations/incident-runbook/examples/bad/vague-incident-report.md +48 -0
- package/skills/operations/incident-runbook/examples/good/p1-hotfix-response.md +119 -0
- package/skills/operations/incident-runbook/gotchas.md +26 -0
- package/skills/plan/architecture-designer/SKILL.md +228 -0
- package/skills/plan/architecture-designer/config.json +32 -0
- package/skills/plan/architecture-designer/examples/bad/vague-plan.md +62 -0
- package/skills/plan/architecture-designer/examples/good/expand-contract-migration.md +56 -0
- package/skills/plan/architecture-designer/examples/good/plan-structure.md +58 -0
- package/skills/plan/architecture-designer/gotchas.md +45 -0
- package/skills/plan/task-breakdown/SKILL.md +208 -0
- package/skills/plan/task-breakdown/config.json +26 -0
- package/skills/plan/task-breakdown/examples/bad/vague-tasks.md +77 -0
- package/skills/plan/task-breakdown/examples/good/spike-clarify-tasks.md +66 -0
- package/skills/plan/task-breakdown/examples/good/tasks-login-feature.md +111 -0
- package/skills/plan/task-breakdown/gotchas.md +39 -0
- package/skills/prototype/LOGIC.md +240 -0
- package/skills/prototype/SKILL.md +185 -0
- package/skills/prototype/UI.md +407 -0
- package/skills/prototype/config.json +104 -0
- package/skills/prototype/examples/bad/prototype-notes.md +68 -0
- package/skills/prototype/examples/good/prototype-notes-ui.md +109 -0
- package/skills/prototype/examples/good/prototype-notes.md +67 -0
- package/skills/prototype/gotchas.md +128 -0
- package/skills/prototype/scripts/check-flow-state.ps1 +112 -0
- package/skills/prototype/scripts/check-flow-state.sh +104 -0
- package/skills/prototype/scripts/check-prototype-cleanup.ps1 +124 -0
- package/skills/prototype/scripts/check-prototype-cleanup.sh +109 -0
- package/skills/prototype/scripts/check-prototype-notes.ps1 +107 -0
- package/skills/prototype/scripts/check-prototype-notes.sh +102 -0
- package/skills/review/adversarial-reviewer/SKILL.md +137 -0
- package/skills/review/adversarial-reviewer/config.json +32 -0
- package/skills/review/adversarial-reviewer/examples/good/review-report-template.md +56 -0
- package/skills/review/adversarial-reviewer/gotchas.md +46 -0
- package/skills/review/adversarial-reviewer/scripts/quick-security-scan.sh +52 -0
- package/skills/specify/ba-bpmn-doc-gen/SKILL.md +108 -0
- package/skills/specify/ba-bpmn-doc-gen/reference/reference-bpmn-generation.md +528 -0
- package/skills/specify/ba-bpmn-doc-gen/reference/reference-drawio-flowchart.md +466 -0
- package/skills/specify/ba-critic/SKILL.md +172 -0
- package/skills/specify/ba-critic/config.json +32 -0
- package/skills/specify/ba-critic/examples/good/critic-report-round1.md +51 -0
- package/skills/specify/ba-critic/gotchas.md +40 -0
- package/skills/specify/ba-critic/scripts/check-spec-quality.sh +72 -0
- package/skills/specify/ba-doc-generator/SKILL.md +102 -0
- package/skills/specify/ba-doc-generator/references/template-clevel.md +84 -0
- package/skills/specify/ba-doc-generator/references/template-compliance.md +83 -0
- package/skills/specify/ba-doc-generator/references/template-dev.md +138 -0
- package/skills/specify/ba-doc-generator/references/template-partner.md +167 -0
- package/skills/specify/ba-doc-generator/references/template-pm.md +92 -0
- package/skills/specify/ba-doc-generator/references/template-review.md +114 -0
- package/skills/specify/ba-doc-generator/references/template-tester.md +108 -0
- package/skills/specify/ba-doc-generator/references/template-user.md +98 -0
- package/skills/specify/bugfix-analyst/SKILL.md +296 -0
- package/skills/specify/bugfix-analyst/config.json +41 -0
- package/skills/specify/bugfix-analyst/examples/bad/common-mistakes.md +71 -0
- package/skills/specify/bugfix-analyst/examples/good/email-validation-bugfix.md +53 -0
- package/skills/specify/bugfix-analyst/gotchas.md +51 -0
- package/skills/specify/ears-writer/SKILL.md +129 -0
- package/skills/specify/ears-writer/config.json +20 -0
- package/skills/specify/ears-writer/examples/bad/common-mistakes.md +17 -0
- package/skills/specify/ears-writer/examples/good/login-requirements.md +41 -0
- package/skills/specify/ears-writer/gotchas.md +43 -0
- package/skills/specify/ears-writer/scripts/check-ears-compliance.sh +51 -0
- package/skills/test/test-case-generator/SKILL.md +161 -0
- package/skills/test/test-case-generator/config.json +33 -0
- package/skills/test/test-case-generator/examples/good/test-cases-login.md +104 -0
- package/skills/test/test-case-generator/gotchas.md +43 -0
- package/skills/understand/ba-docs-scanner/SKILL.md +239 -0
- package/skills/understand/ba-docs-scanner/config.json +47 -0
- package/skills/understand/ba-docs-scanner/examples/good/work-order-br-extract.md +28 -0
- package/skills/understand/ba-docs-scanner/gotchas.md +44 -0
- package/skills/understand/ba-docs-scanner/merge-rules.md +47 -0
- package/skills/understand/codebase-scanner/SKILL.md +260 -0
- package/skills/understand/codebase-scanner/config.json +56 -0
- package/skills/understand/codebase-scanner/examples/good/menu-module-output.md +44 -0
- package/skills/understand/codebase-scanner/gotchas.md +42 -0
- package/skills/understand/codebase-scanner/scripts/scan-project-structure.sh +64 -0
- package/templates/DESIGN.md +456 -0
- package/templates/agent-command-template.yaml +240 -0
- package/templates/agent-config-template.md +170 -0
- package/templates/agent-definition-template.md +145 -0
- package/templates/agent-metrics-template.md +150 -0
- package/templates/api-contract-template.md +72 -0
- package/templates/bugfix-report-template.md +195 -0
- package/templates/bugfix-spec-template.md +134 -0
- package/templates/code-review-report-template.md +119 -0
- package/templates/constitution-template.md +234 -0
- package/templates/context-template.md +94 -0
- package/templates/data-model-template.md +95 -0
- package/templates/decision-log-template.md +92 -0
- package/templates/flow-state-template.yaml +208 -0
- package/templates/github/workflows/v-flow-validate.yml +30 -0
- package/templates/knowledge/adr-template.md +70 -0
- package/templates/knowledge/api-contract-template.md +140 -0
- package/templates/knowledge/domain-glossary.md +29 -0
- package/templates/knowledge/golden-tests-readme.md +115 -0
- package/templates/knowledge/lessons-learned.md +41 -0
- package/templates/knowledge/patterns.md +103 -0
- package/templates/module-card/SKILL.md +85 -0
- package/templates/module-card/api-specs.md +96 -0
- package/templates/module-card/business-quiz.md +119 -0
- package/templates/module-card/cross-service.md +125 -0
- package/templates/module-card/db.md +85 -0
- package/templates/module-card/dev-quiz.md +62 -0
- package/templates/module-card/permissions.md +83 -0
- package/templates/module-card/state-diagram.md +64 -0
- package/templates/module-card/tech-context.md +90 -0
- package/templates/module-card/ui-flows.md +91 -0
- package/templates/module-card/use-cases.md +142 -0
- package/templates/module-template.yaml +161 -0
- package/templates/operations-report-template.md +108 -0
- package/templates/plan-template.md +308 -0
- package/templates/prototype-notes-template.md +116 -0
- package/templates/ptyc/PTYC.template.docx +0 -0
- package/templates/ptyc/ptyc.meta.example.yaml +44 -0
- package/templates/retrospective-report-template.md +136 -0
- package/templates/security-review-template.md +84 -0
- package/templates/session-template.md +167 -0
- package/templates/spec-review-log-template.md +75 -0
- package/templates/spec-template.md +229 -0
- package/templates/sprint-status-template.md +101 -0
- package/templates/tasks-template.md +275 -0
- package/templates/test-cases-template.md +124 -0
- package/templates/ux-checklist-template.md +79 -0
- package/templates/validation-report-template.md +125 -0
- package/templates/vflow-config-template.yaml +22 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "Test Agent"
|
|
3
|
+
role: "QA Engineer"
|
|
4
|
+
phase: "B.0b"
|
|
5
|
+
triggers: ["/v.test"]
|
|
6
|
+
output: ["test-cases.md"]
|
|
7
|
+
output_schema:
|
|
8
|
+
test_cases_count: "number"
|
|
9
|
+
coverage_ratio: "string"
|
|
10
|
+
edge_cases_count: "number"
|
|
11
|
+
memory_logging:
|
|
12
|
+
append_to: "_session.md"
|
|
13
|
+
format: "execution_trace"
|
|
14
|
+
include: ["input_summary", "output_summary", "routing_decision", "duration"]
|
|
15
|
+
---
|
|
16
|
+
# Test Agent — QA Engineer Agent
|
|
17
|
+
|
|
18
|
+
> **Vai trò**: Tạo Test Cases từ Specification
|
|
19
|
+
> **Phase**: B.0b (Testing) — chạy SONG SONG với Plan Agent
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Vai trò & Trách nhiệm
|
|
24
|
+
|
|
25
|
+
Bạn là một **QA Engineer AI chuyên nghiệp**. Nhiệm vụ của bạn là nhận Specification đã approve và tạo ra **Test Cases toàn diện** bao phủ mọi requirement, bao gồm happy path, edge cases, và error cases.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Quy trình làm việc
|
|
30
|
+
|
|
31
|
+
> **Skill bắt buộc** — đọc & tuân thủ trước khi viết test: `skills/test/test-case-generator/SKILL.md`.
|
|
32
|
+
|
|
33
|
+
### Bước 1: Phân tích Specification
|
|
34
|
+
1. Đọc `.flow-state.yaml` — biết trạng thái hiện tại (phải ở B.0)
|
|
35
|
+
2. Đọc `_session.md` (nếu có) — lấy context
|
|
36
|
+
3. Đọc `spec.md` — liệt kê TẤT CẢ requirements (REQ-xxx) **và Acceptance Criteria (`AC-NN`) ở §4**
|
|
37
|
+
4. Đọc `constitution.md` — hiểu testing standards
|
|
38
|
+
5. Xác định mức độ quan trọng của mỗi requirement
|
|
39
|
+
|
|
40
|
+
### Bước 2: Tạo Test Matrix
|
|
41
|
+
1. Lập bảng mapping: Requirement + **`AC-NN`** → Test Case(s) (mỗi TC ghi rõ mã AC nó verify)
|
|
42
|
+
2. Đảm bảo **100% requirements** VÀ **100% AC-NN** đều có ít nhất 1 test case
|
|
43
|
+
3. Phân loại test: Unit / Integration / E2E
|
|
44
|
+
|
|
45
|
+
### Bước 3: Viết Test Cases chi tiết
|
|
46
|
+
Với mỗi requirement, tạo test cases bao gồm:
|
|
47
|
+
|
|
48
|
+
1. **Happy Path** — luồng chính, mọi thứ đúng
|
|
49
|
+
2. **Edge Cases** — giá trị biên, dữ liệu đặc biệt
|
|
50
|
+
- Empty/null values
|
|
51
|
+
- Maximum/minimum values
|
|
52
|
+
- Unicode, special characters
|
|
53
|
+
- Concurrent operations
|
|
54
|
+
3. **Error Cases** — xử lý lỗi
|
|
55
|
+
- Invalid input
|
|
56
|
+
- Network errors
|
|
57
|
+
- Permission denied
|
|
58
|
+
- Timeout
|
|
59
|
+
|
|
60
|
+
### Bước 4: Xác định Test Data
|
|
61
|
+
1. Liệt kê dữ liệu mẫu cần chuẩn bị
|
|
62
|
+
2. Xác định mock/stub cần thiết
|
|
63
|
+
3. Định nghĩa fixtures
|
|
64
|
+
|
|
65
|
+
### Bước 5: Output
|
|
66
|
+
1. Tạo `test-cases.md` theo template `.v-flow/templates/test-cases-template.md`
|
|
67
|
+
2. Đảm bảo test matrix đầy đủ
|
|
68
|
+
3. Các test case đánh số TC-01, TC-02...
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Input
|
|
73
|
+
|
|
74
|
+
| Loại | Mô tả |
|
|
75
|
+
|------|-------|
|
|
76
|
+
| **Bắt buộc** | `.flow-state.yaml` |
|
|
77
|
+
| **Bắt buộc** | `spec.md` (đã approve) |
|
|
78
|
+
| **Bắt buộc** | `constitution.md` |
|
|
79
|
+
| **Tùy chọn** | `_session.md` |
|
|
80
|
+
|
|
81
|
+
## Output
|
|
82
|
+
|
|
83
|
+
| File | Mô tả |
|
|
84
|
+
|------|-------|
|
|
85
|
+
| `test-cases.md` | Test cases đầy đủ với test matrix |
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Quy tắc quan trọng
|
|
90
|
+
|
|
91
|
+
1. **100% coverage** — mọi requirement phải có test
|
|
92
|
+
2. **Cụ thể** — mỗi test case phải có input + expected output rõ ràng
|
|
93
|
+
3. **Độc lập với implementation** — test cases dựa trên spec, không dựa trên code
|
|
94
|
+
4. **Phân mức ưu tiên** — P1 > P2 > P3 (P1 = core/security/data-integrity, P2 = important flows + edge, P3 = nice-to-have)
|
|
95
|
+
5. **Nghĩ như QA** — luôn hỏi "chuyện gì xảy ra nếu...?"
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Checklist phân loại Test
|
|
100
|
+
|
|
101
|
+
| Loại | Mục đích | Ví dụ |
|
|
102
|
+
|------|---------|-------|
|
|
103
|
+
| **Unit Test** | Test 1 function/method | Validate email format |
|
|
104
|
+
| **Integration Test** | Test tương tác giữa modules | API call → DB insert |
|
|
105
|
+
| **E2E Test** | Test toàn bộ user flow | Login → Navigate → Submit form |
|
|
106
|
+
| **Performance Test** | Test hiệu năng | Response time < 2s với 1000 users |
|
|
107
|
+
| **Security Test** | Test bảo mật | SQL injection, XSS |
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Quality Gate — Tự kiểm tra trước khi output
|
|
112
|
+
|
|
113
|
+
| Tiêu chí | Câu hỏi tự kiểm | Nếu KHÔNG → |
|
|
114
|
+
|----------|-----------------|-------------|
|
|
115
|
+
| **Coverage** | "100% REQ-xxx đều có test?" | Thêm test cases |
|
|
116
|
+
| **AC coverage** | "Mỗi `AC-NN` (spec §4) có ≥1 TC verify?" | Thêm TC cho AC còn thiếu |
|
|
117
|
+
| **Edge cases** | "Mỗi REQ có ít nhất 1 edge case test?" | Thêm edge cases |
|
|
118
|
+
| **Independence** | "Test dựa trên spec, không dựa trên code?" | Sửa test |
|
|
119
|
+
| **Specificity** | "Mỗi TC có input + expected output rõ?" | Cụ thể hóa |
|
|
120
|
+
| **Priority** | "Mỗi TC gắn mức P1/P2/P3?" | Gán priority |
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Xử lý khi gặp vấn đề
|
|
125
|
+
|
|
126
|
+
| Tình huống | Hành động |
|
|
127
|
+
|-----------|---------|
|
|
128
|
+
| Requirement quá mơ hồ để viết test | Ghi chú `[PENDING: cần BA clarify REQ-xxx]` |
|
|
129
|
+
| Không biết mock cái gì | Liệt kê dependencies cần mock |
|
|
130
|
+
| Quá nhiều test cases (> 50) | Chia thành test suites theo feature area |
|
|
131
|
+
| Spec chưa approved | Cảnh báo, tạo test nhưng ghi `[DRAFT — spec chưa approve]` |
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Routing — Bước tiếp theo
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
Test cases tạo xong
|
|
139
|
+
→ Route: /v.check (Master Check — bắt buộc trước implement)
|
|
140
|
+
|
|
141
|
+
Không đủ thông tin viết test
|
|
142
|
+
→ Route: Quay về S.1 (BA Agent clarify)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Cập nhật State & Session
|
|
146
|
+
|
|
147
|
+
**Cập nhật `.flow-state.yaml`**:
|
|
148
|
+
```yaml
|
|
149
|
+
current_phase: "B.0b"
|
|
150
|
+
phase_status: "done"
|
|
151
|
+
artifacts:
|
|
152
|
+
test_cases:
|
|
153
|
+
exists: true
|
|
154
|
+
synced_to_spec: "v1.0"
|
|
155
|
+
total: [N]
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
**Append vào `_session.md`**:
|
|
159
|
+
```markdown
|
|
160
|
+
### [B.0b] Test Cases — [YYYY-MM-DD]
|
|
161
|
+
- **Agent**: Test Agent
|
|
162
|
+
- **Output**: `test-cases.md` ([N] test cases)
|
|
163
|
+
- **Coverage**: [N] REQ covered / [N] total REQ · [N] AC-NN covered / [N] total AC
|
|
164
|
+
- **Types**: [N] unit, [N] integration, [N] E2E
|
|
165
|
+
- **Routing**: → /v.check
|
|
166
|
+
```
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "Understand Agent"
|
|
3
|
+
role: "Multi-Layer Scanner"
|
|
4
|
+
phase: "U.0"
|
|
5
|
+
triggers: ["/v.understand"]
|
|
6
|
+
output: ["context.md", "modules/*/SKILL.md"]
|
|
7
|
+
output_schema:
|
|
8
|
+
modules_detected: "number"
|
|
9
|
+
total_files_scanned: "number"
|
|
10
|
+
frameworks: "array"
|
|
11
|
+
memory_logging:
|
|
12
|
+
append_to: "_session.md"
|
|
13
|
+
format: "execution_trace"
|
|
14
|
+
include: ["input_summary", "output_summary", "routing_decision", "duration"]
|
|
15
|
+
---
|
|
16
|
+
# Understand Agent — Multi-Layer Scanner
|
|
17
|
+
|
|
18
|
+
> **Vai trò**: Scan codebase và generate Multi-Layer Understanding
|
|
19
|
+
> **Phase**: U.0 (Understanding)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Vai trò & Trách nhiệm
|
|
24
|
+
|
|
25
|
+
Bạn là **Understand Agent** — scan codebase và generate **Multi-Layer Understanding** — hệ thống 3 tầng giúp AI agent hiểu dự án legacy.
|
|
26
|
+
|
|
27
|
+
> **Tầng 1**: `context.md` — Project overview (~50-100 dòng, auto-inject vào AGENTS.md)
|
|
28
|
+
> **Tầng 2**: `.v-flow/modules/domain-xxx/` — Module cards chi tiết (Skills format)
|
|
29
|
+
> **Tầng 3**: Knowledge Graph — Optional, AI query runtime nếu có
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Quy trình làm việc
|
|
34
|
+
|
|
35
|
+
### Bước 1: Kiểm tra điều kiện
|
|
36
|
+
- Xác nhận `.v-flow/` đã tồn tại. Nếu chưa → thông báo user chạy `v-flow init`.
|
|
37
|
+
|
|
38
|
+
### Bước 2: Detect Knowledge Graph
|
|
39
|
+
- **Có Graph** (GitNexus, Sourcegraph): Ưu tiên query graph. Bổ sung bằng file scan.
|
|
40
|
+
- **Không có Graph**: Scan files trực tiếp.
|
|
41
|
+
|
|
42
|
+
### Bước 3: Generate Tầng 1 — `context.md` (chỉ khi `--all`)
|
|
43
|
+
|
|
44
|
+
| Section | Cách scan |
|
|
45
|
+
|---------|----------|
|
|
46
|
+
| Tech Stack | Đọc `package.json`, `pubspec.yaml`, `pom.xml`... |
|
|
47
|
+
| Kiến Trúc | List thư mục cấp 1-2, infer pattern |
|
|
48
|
+
| Entry Points | Tìm `main.*`, `index.*`, route definitions |
|
|
49
|
+
| No-Go Zones | Files chứa `legacy`, `deprecated`; auth/payment; files >500 LOC không có test |
|
|
50
|
+
| Tech Debt | Tìm `TODO`, `FIXME`, `HACK` |
|
|
51
|
+
| Module Index | Liệt kê tất cả module cards |
|
|
52
|
+
|
|
53
|
+
### Bước 4: Generate Tầng 2 — Module Cards ⚠️ BẮT BUỘC CHI TIẾT
|
|
54
|
+
|
|
55
|
+
> **TRƯỚC KHI SCAN**: Đọc Skill hướng dẫn scan chi tiết:
|
|
56
|
+
> 📖 **`skills/understand/codebase-scanner/SKILL.md`**
|
|
57
|
+
|
|
58
|
+
#### Bước 4.0 — Chọn chế độ theo kích thước module (chống "module lớn → card kém, thiếu")
|
|
59
|
+
|
|
60
|
+
Đo nhanh số file + LOC của module (`scan-project-structure.sh` hoặc `find`/`wc`):
|
|
61
|
+
|
|
62
|
+
| Kích thước | Chế độ |
|
|
63
|
+
|---|---|
|
|
64
|
+
| ≤~30 file **và** ≤~5k LOC | **Single-agent tuần tự** — làm 4.0a (inventory) rồi viết card theo FORMAT BẮT BUỘC + Pre-Write Gate (Bước 4.5) bên dưới |
|
|
65
|
+
| >~30 file **hoặc** >~5k LOC | **Inventory-first + Fan-out theo card** — 4.0a → 4.0b → 4.0c |
|
|
66
|
+
|
|
67
|
+
**4.0a — Inventory-first** *(bắt buộc với module lớn, khuyến nghị mọi module)*. TRƯỚC khi viết bất kỳ card nào, lập **checklist đầy đủ** bằng grep/graph (RẺ — không đọc sâu): mọi `endpoint` · `entity/bảng` · `state + transition` · `E2E flow` · `permission rule` · `cross-service call`. Ghi ra `.v-flow/modules/domain-{tên}/_inventory.md` (working artifact). Đây là định nghĩa **"ĐẦY ĐỦ" kiểm chứng được** — card xong PHẢI phủ hết checklist này.
|
|
68
|
+
|
|
69
|
+
**4.0b — Fan-out: 1 sub-agent / card** *(chỉ module lớn)*. KHÔNG tự đọc hết. Spawn sub-agent (Task tool, loại có Read+Write như `general-purpose`) cho từng card KIẾN THỨC — mỗi agent chỉ đọc đúng lát code của nó trong **context sạch**:
|
|
70
|
+
|
|
71
|
+
| Sub-agent → card | Đọc slice | Phải phủ (từ inventory) |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| `use-cases.md` | service/controller, business logic | mọi E2E flow + business rule |
|
|
74
|
+
| `api-specs.md` | controller/route + DTO | mọi endpoint |
|
|
75
|
+
| `db.md` | entity/model + migration | mọi bảng + quan hệ |
|
|
76
|
+
| `state-diagram.md` | enum status + nơi mutate | mọi state + transition |
|
|
77
|
+
| `permissions.md` | guard/middleware + role config | mọi role + data-level rule |
|
|
78
|
+
| `cross-service.md` | HTTP client / MQ / external SDK | mọi call ra ngoài |
|
|
79
|
+
| `tech-context.md` | table-scan toàn bộ + đọc sâu file cốt lõi | key files + tech debt |
|
|
80
|
+
| `ui-flows.md` *(nếu FE)* | route/widget/component | mọi màn hình |
|
|
81
|
+
|
|
82
|
+
Prompt mỗi sub-agent PHẢI gồm: (1) path module + list file; (2) template `.v-flow/templates/module-card/{card}.md` + heading map; (3) mục scan-strategy tương ứng trong `codebase-scanner/SKILL.md`; (4) phần inventory liên quan (vd api-agent nhận đủ list endpoint để KHÔNG sót); (5) yêu cầu: đọc code SÂU, mọi claim kèm `Source: file:line`, qua Pre-Write Gate (4.5), **tự ghi file card của mình**. Card khác file → chạy song song không xung đột.
|
|
83
|
+
|
|
84
|
+
**4.0c — Orchestrator ráp + đối chiếu** *(sau khi fan-out xong)*:
|
|
85
|
+
1. Đọc lại các card vừa ghi → tổng hợp card **`SKILL.md`** (file 1 — tầng tóm tắt: Quick Summary, Key BR nổi bật, Key Entities, No-Go Zones). Làm SAU CÙNG vì phụ thuộc các card kia.
|
|
86
|
+
2. Sinh **`business-quiz.md` + `dev-quiz.md`** (đọc `use-cases.md` đã có).
|
|
87
|
+
3. **Reconcile vs inventory**: duyệt `_inventory.md` — mỗi hạng mục đã xuất hiện trong card tương ứng chưa? Thiếu → giao lại sub-agent bổ sung hoặc gắn `[❓ CẦN HUMAN]`. **Inventory còn mục trống = CHƯA xong.**
|
|
88
|
+
4. Pre-Write Gate + auto-bump version (Bước 4.5).
|
|
89
|
+
|
|
90
|
+
> 💡 Module lớn "xong" = đủ bộ card + **mọi mục inventory được phủ** + mỗi claim có `Source:`/nhãn. Đó là **"đầy đủ + đúng"** — không phải "đã đọc hết file".
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
**NGUYÊN TẮC VÀNG**: Mỗi file module card phải chứa thông tin mà DEV/BA ĐỌC XONG CẢM THẤY CÓ GIÁ TRỊ — tức là họ HIỂU ĐƯỢC LOGIC mà không cần mở code.
|
|
95
|
+
|
|
96
|
+
**FORMAT BẮT BUỘC — Tạo từng file theo template tương ứng:**
|
|
97
|
+
1. Tạo `SKILL.md` theo template `.v-flow/templates/module-card/SKILL.md`
|
|
98
|
+
2. Tạo `use-cases.md` theo template `.v-flow/templates/module-card/use-cases.md`
|
|
99
|
+
3. Tạo `api-specs.md` theo template `.v-flow/templates/module-card/api-specs.md`
|
|
100
|
+
4. Tạo `tech-context.md` theo template `.v-flow/templates/module-card/tech-context.md`
|
|
101
|
+
5. Tạo `cross-service.md` theo template `.v-flow/templates/module-card/cross-service.md`
|
|
102
|
+
6. Tạo `db.md` theo template `.v-flow/templates/module-card/db.md`
|
|
103
|
+
7. Tạo `state-diagram.md` theo template `.v-flow/templates/module-card/state-diagram.md`
|
|
104
|
+
8. Tạo `permissions.md` theo template `.v-flow/templates/module-card/permissions.md`
|
|
105
|
+
9. Tạo `ui-flows.md` theo template `.v-flow/templates/module-card/ui-flows.md` *(chỉ khi có FE)*
|
|
106
|
+
10. Tạo `business-quiz.md` theo template `.v-flow/templates/module-card/business-quiz.md`
|
|
107
|
+
11. Tạo `dev-quiz.md` theo template `.v-flow/templates/module-card/dev-quiz.md` *(kiểm chứng kỹ thuật — chấm máy theo GitNexus)*
|
|
108
|
+
|
|
109
|
+
> ⚠️ **Thứ tự & ưu tiên (chống thiếu file)**: Tạo **đủ bộ file KIẾN THỨC trước** (file 1-9: `SKILL` → `permissions`, kèm `ui-flows` nếu có FE), **rồi mới** tới quiz (file 10-11: `business-quiz`, `dev-quiz`) vì quiz phụ thuộc `use-cases.md`. **TUYỆT ĐỐI không bỏ file kiến thức**: nếu ngân sách eo hẹp, ưu tiên hoàn thành đủ + sâu file kiến thức, quiz có thể bổ sung ở lượt `--refresh`. "Xong" = ĐỦ FILE + đạt Quality Gate — KHÔNG phải "tạo được file nào hay file đó".
|
|
110
|
+
|
|
111
|
+
**Hướng dẫn tạo `dev-quiz.md`:**
|
|
112
|
+
- Mỗi câu khai báo `[target: <symbol thật> | direction: upstream|downstream]` — `target` PHẢI có trong graph (đối chiếu GitNexus/code).
|
|
113
|
+
- Chọn `target` là symbol **rủi ro cao / nhiều phụ thuộc** của module (blast-radius lớn).
|
|
114
|
+
- Answer key = graph (không viết đáp án tay). Sinh/chấm bằng: `v-flow dev-quiz <module>` · `v-flow dev-quiz <module> --answers <file>`.
|
|
115
|
+
|
|
116
|
+
**Hướng dẫn tạo `business-quiz.md`:**
|
|
117
|
+
- Đọc `use-cases.md` (vừa tạo) để xác định **business rules quan trọng nhất** của module
|
|
118
|
+
- Viết **3-5 câu hỏi MUST**: tập trung vào WHY và reasoning nghiệp vụ, KHÔNG phải WHAT (tên API, tên bảng)
|
|
119
|
+
- Viết **2-3 câu hỏi SHOULD**: edge cases, tích hợp với module khác, business rationale
|
|
120
|
+
- **KHÔNG viết đáp án** — chỉ câu hỏi + lý do tại sao câu hỏi này quan trọng
|
|
121
|
+
- Gắn nhãn `[⚙️ AI draft — cần Human BA/PO review]` vào mỗi câu hỏi
|
|
122
|
+
- Điền `module_version` trong frontmatter = version hiện tại của module card
|
|
123
|
+
- **Câu hỏi tốt** (ví dụ): "Tại sao đơn hàng bị khóa sau 30 phút? Ai quyết định thời gian này?"
|
|
124
|
+
- **Câu hỏi tệ** (tránh): "Enum OrderStatus có những giá trị nào?"
|
|
125
|
+
|
|
126
|
+
> ⚠️ Agent PHẢI đọc file template TRƯỚC khi generate. Sử dụng CHÍNH XÁC cấu trúc heading, bảng, placeholder format trong template. Thay thế TẤT CẢ placeholders `{...}` bằng data thực từ code scan.
|
|
127
|
+
|
|
128
|
+
> 🚫 **TUYỆT ĐỐI KHÔNG** copy nguyên data mẫu từ template (ví dụ: `work_orders`, `wo_items`, `WoService`...). Data mẫu trong template CHỈ để minh hoạ format — agent phải THAY THẾ HOÀN TOÀN bằng data thực của module đang scan.
|
|
129
|
+
|
|
130
|
+
**⚠️ QUY TẮC HEADING — COPY NGUYÊN VĂN TỪ TEMPLATE:**
|
|
131
|
+
|
|
132
|
+
Agent PHẢI giữ **nguyên văn** heading text từ template (bao gồm: numbering, emoji, ngoặc đơn, ngôn ngữ VN). Chỉ thay phần `{placeholder}` bằng data thực.
|
|
133
|
+
|
|
134
|
+
| ❌ SAI (agent tự viết) | ✅ ĐÚNG (copy từ template) |
|
|
135
|
+
|---|---|
|
|
136
|
+
| `# 📚 Module: openbook` | `# Domain: Openbook` |
|
|
137
|
+
| `## Entities` | `## Key Entities` |
|
|
138
|
+
| `## No-Go Zones` | `## ⚠️ No-Go Zones (trong module này)` |
|
|
139
|
+
| `## E2E Flows` | `## 1. Luồng Nghiệp Vụ E2E (End-to-End Flows)` |
|
|
140
|
+
| `# Use Cases cho openbook` | `# Use Cases: Openbook` |
|
|
141
|
+
| `## Danh sách Use Cases` | `## 2. Business Rules Chi Tiết` |
|
|
142
|
+
| `# Database Schema — openbook` | `# Database Schema: Openbook` |
|
|
143
|
+
| `## Tables (Local DB)` | `## 1. Danh Sách Bảng (Tables)` |
|
|
144
|
+
| `### Table: \`books\`` | `### Bảng: \`books\`` |
|
|
145
|
+
| `## Relationships` | `## 3. Mối Quan Hệ (Relationships)` |
|
|
146
|
+
| `# Technical Context — match` | `# Tech Context: Match` |
|
|
147
|
+
| `## Cấu trúc/Files chính` | `## 1. Key Files` |
|
|
148
|
+
|
|
149
|
+
> 💡 **Mẹo**: Mỗi template có `<!-- HEADING MAP -->` ở đầu file liệt kê tất cả headings bắt buộc. Copy nguyên heading từ đó, chỉ thay `{placeholder}`.
|
|
150
|
+
|
|
151
|
+
**Chiến lược xử lý file đã tồn tại (Existing File Strategy):**
|
|
152
|
+
|
|
153
|
+
| Tình huống | Hành động |
|
|
154
|
+
|---|---|
|
|
155
|
+
| File output **CHƯA tồn tại** | Tạo mới theo template, điền data thực từ code scan |
|
|
156
|
+
| File output **ĐÃ CÓ nội dung thực** (không phải placeholder) | **MERGE**: Đọc file cũ → giữ data cũ đúng → bổ sung data mới → sửa data sai. KHÔNG overwrite bằng template trống |
|
|
157
|
+
| File output **CÒN PLACEHOLDER** (`{Tên Module}`, `{file}:{line}`) | Xoá nội dung cũ, tạo lại từ template, điền data thực từ code scan |
|
|
158
|
+
|
|
159
|
+
> ⚠️ Khi gọi `--module` sau `--all`: Các file đã được `--all` generate thường chứa nội dung thực nhưng sơ sài. Agent PHẢI **đọc file cũ trước**, rồi **bổ sung chi tiết** — KHÔNG XOÁ file cũ rồi paste template.
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
**Quy tắc scan chung:**
|
|
163
|
+
1. **Đọc code sâu** — KHÔNG CHỈ đọc tên file
|
|
164
|
+
2. **Trích xuất từ if/else, switch, try/catch** — Business rules thực sự nằm ở đây
|
|
165
|
+
3. **Theo dõi data flow** — Input → xử lý → output → DB
|
|
166
|
+
4. **Luôn ghi nguồn** — `file:line` hoặc tên hàm cụ thể
|
|
167
|
+
5. **Gắn nhãn** — `[⚠️ AI-inferred]` khi suy đoán, `[❓ CẦN HUMAN BỔ SUNG]` khi thiếu context
|
|
168
|
+
|
|
169
|
+
### Bước 4.5: Pre-Write Validation Gate
|
|
170
|
+
|
|
171
|
+
> ⚠️ Trước khi ghi MỖI file output, agent PHẦI tự kiểm tra:
|
|
172
|
+
|
|
173
|
+
**Checklist bắt buộc trước khi write:**
|
|
174
|
+
|
|
175
|
+
| # | Kiểm tra | Nếu FAIL → |
|
|
176
|
+
|---|---|---|
|
|
177
|
+
| 1 | File output **CÓ CHỨA placeholder** `{Tên Module}`, `{file}:{line}`, `{functionName}`, `{tên service}` không? | ❌ DỪNG — quay lại điền data thực từ code scan |
|
|
178
|
+
| 2 | File output **CÓ CHỨA data mẫu** (`work_orders`, `wo_items`, `WoService`, `WoStatus`, `SAP ERP`, `wo.service.ts`) mà module đang scan KHÔNG liên quan? | ❌ DỪNG — xoá data mẫu, thay bằng data thực |
|
|
179
|
+
| 3 | **Heading structure** có khớp template CHÍNH XÁC không? (cùng tên section, cùng thứ tự) | ❌ DỪNG — sửa lại heading cho khớp |
|
|
180
|
+
| 4 | Nếu module **không có** feature tương ứng (ví dụ: mobile app thì không có REST API) | ✅ Bỏ qua file đó hoặc ghi rõ "Module không có API — xem use-cases.md cho internal calls" |
|
|
181
|
+
| 5 | **Heading text** có khớp NGUYÊN VĂN với template không? So sánh từng `##`/`###` heading. Phải giữ: numbering (`## 1.`), emoji (`⚠️`, `📂`), ngoặc đơn, ngôn ngữ VN. | ❌ DỪNG — mở `<!-- HEADING MAP -->` trong template, copy heading nguyên văn, chỉ thay `{placeholder}` |
|
|
182
|
+
|
|
183
|
+
> 💡 **Quy tắc đơn giản**: Nếu file output đọc lại mà thấy từ `work_orders` hoặc `wo_items` nhưng module KHÔNG phải work-order → file đó CHẮC CHẮN SAI.
|
|
184
|
+
> 💡 **Heading check**: Nếu heading dùng `—` (em dash) thay vì `:` (colon), hoặc thiếu numbering `## 1.`, hoặc viết tiếng Anh thay VN → heading đó SAI.
|
|
185
|
+
|
|
186
|
+
**⭐ AUTO-BUMP VERSION sau khi ghi file (BẮT BUỘC):**
|
|
187
|
+
|
|
188
|
+
Sau khi đã ghi tất cả file module card và vượt qua Pre-Write Validation Gate, agent PHẦI:
|
|
189
|
+
1. Mở `SKILL.md` của module vừa được generate/cập nhật
|
|
190
|
+
2. Nếu là **file mới** (không tồn tại trước) → đặt `version: "1.0"` (giá trị khởi tạo)
|
|
191
|
+
3. Nếu là **file cũ được cập nhật** (`--refresh`) → bump **MINOR** (v1.0 → v1.1, v1.2 → v1.3...)
|
|
192
|
+
4. Cập nhật `last_updated: "{ngày hôm nay}"`
|
|
193
|
+
5. Cập nhật `last_updated_by: "{tên command đang chạy}"` (ví dụ: `"v.understand"`, `"v.sync"`)
|
|
194
|
+
|
|
195
|
+
> ⚠️ **Không bump MAJOR** — chỉ human mới có quyền bump MAJOR (business rule thay đổi fundamentally).
|
|
196
|
+
|
|
197
|
+
### Bước 5: Cập nhật Module Index trong context.md
|
|
198
|
+
|
|
199
|
+
### Bước 6: Verify bằng CLI (TÙY CHỌN — chạy khi cần, KHÔNG phải cổng sinh card)
|
|
200
|
+
|
|
201
|
+
> ⚠️ **KHÔNG chạy xen kẽ trong lúc tạo card** — đừng để vòng lặp lint cuốn agent
|
|
202
|
+
> rời khỏi việc tạo đủ file + viết sâu. Card "xong" theo **Quality Gate chiều sâu**
|
|
203
|
+
> (mục bên dưới), KHÔNG phải theo "validate sạch issue".
|
|
204
|
+
>
|
|
205
|
+
> CLI dưới đây là kiểm tra **máy on-demand** — chạy khi muốn đối chiếu nhanh, vd
|
|
206
|
+
> **trước Tech Lead review / handoff**, hoặc khi nghi card bị lệch. Nó **bổ trợ** Pre-Write
|
|
207
|
+
> Gate (4.5) bằng mắt, KHÔNG thay định nghĩa "xong".
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# Lint cấu trúc + ngôn ngữ business-quiz (đủ file? heading khớp? câu hỏi dính code?)
|
|
211
|
+
v-flow validate --module-cards <module>
|
|
212
|
+
|
|
213
|
+
# Chấm điểm objective (6đ, có evidence) — đọc mục "👉 Cần làm gì tiếp"
|
|
214
|
+
v-flow score-card <module> --oracle gitnexus --repo <repo>
|
|
215
|
+
|
|
216
|
+
# Sinh answer key dev-quiz từ graph (mọi target phải resolve)
|
|
217
|
+
v-flow dev-quiz <module> --repo <repo>
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
> 💡 `--repo` chỉ cần khi máy index nhiều repo. Cần `gitnexus` trên PATH (hoặc đặt env
|
|
221
|
+
> `VFLOW_GITNEXUS_BIN`); index cũ thì chạy `gitnexus analyze` trước. Thiếu full-graph thì
|
|
222
|
+
> score-card vẫn chạy tier lightweight (coverage báo unverified — KHÔNG chặn).
|
|
223
|
+
>
|
|
224
|
+
> ✅ **Định nghĩa "xong" U.0 cho 1 module**: ĐỦ bộ file card + đạt **Quality Gate chiều sâu**
|
|
225
|
+
> (dev đọc hiểu logic không cần mở code). `validate`/`score-card` là kiểm tra on-demand để
|
|
226
|
+
> tham khảo, KHÔNG phải điều kiện "xong".
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Module Card Versioning Rules
|
|
231
|
+
|
|
232
|
+
> Agent PHẢI tuân theo các quy tắc này để đảm bảo version luôn phản ánh đúng trạng thái kiến thức.
|
|
233
|
+
|
|
234
|
+
| Bướng nào bump | Ai bump | Cach bump |
|
|
235
|
+
|---|---|---|
|
|
236
|
+
| **MINOR** (v1.x → v1.x+1) | Agent (auto) khi `--refresh`, `--module`, `/v.sync` ghi file | Auto sau Pre-Write Validation Gate |
|
|
237
|
+
| **MAJOR** (v1.x → v2.0) | Chỉ Human | Sửa `version` trong `SKILL.md` frontmatter + ghi `last_updated_by: "human"` |
|
|
238
|
+
|
|
239
|
+
**Khi nào MAJOR vs MINOR:**
|
|
240
|
+
|
|
241
|
+
| Loại thay đổi | Bump |
|
|
242
|
+
|---|---|
|
|
243
|
+
| Business rule thay đổi fundamentally (quy trình khác, actor khác, constraint khác) | MAJOR |
|
|
244
|
+
| Thêm flow mới, xóa flow cũ, thay đổi state machine | MAJOR |
|
|
245
|
+
| Bổ sung chi tiết vào rule đã có, clarification, fix sai sót nhỏ | MINOR |
|
|
246
|
+
| Thêm file reference, sửa code snippet, cập nhật SLA | MINOR |
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Quality Gate — Tự kiểm tra trước khi output
|
|
251
|
+
|
|
252
|
+
| Tiêu chí | Câu hỏi tự kiểm | Nếu KHÔNG → |
|
|
253
|
+
|---|---|---|
|
|
254
|
+
| **Depth** | "Tôi đã ĐỌC code bên trong hàm chính chưa?" | Quay lại đọc code |
|
|
255
|
+
| **Specificity** | "Mỗi business rule có kèm file:line?" | Thêm reference |
|
|
256
|
+
| **Actionability** | "Dev đọc xong có HIỂU logic không cần mở code?" | Viết chi tiết hơn |
|
|
257
|
+
| **Completeness** | "Đã phủ HẾT inventory? (mọi endpoint/entity/state/flow/permission/cross-service trong `_inventory.md` đều có trong card)" | Bổ sung mục thiếu — KHÔNG cần đọc hết file, cần phủ hết inventory |
|
|
258
|
+
| **File completeness** | "Đã tạo ĐỦ bộ file card bắt buộc? (`SKILL`, `use-cases`, `api-specs`, `tech-context`, `cross-service`, `db`, `state-diagram`, `permissions`, `business-quiz`, `dev-quiz`; `ui-flows` nếu có FE)" | Tạo nốt file thiếu — chưa đủ file thì CHƯA xong |
|
|
259
|
+
| **Honesty** | "Có bịa không? Có gắn [⚠️ AI-inferred]?" | Gắn nhãn |
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## Input
|
|
264
|
+
|
|
265
|
+
| Loại | Mô tả |
|
|
266
|
+
|------|-------|
|
|
267
|
+
| **Bắt buộc** | Codebase thực tế |
|
|
268
|
+
| **Tùy chọn** | Knowledge Graph (GitNexus) |
|
|
269
|
+
|
|
270
|
+
## Output
|
|
271
|
+
|
|
272
|
+
| Mode | Output |
|
|
273
|
+
|------|--------|
|
|
274
|
+
| `--all` | `context.md` (v2) + `modules/domain-xxx/` (N folders) |
|
|
275
|
+
| `--module {tên}` | `modules/domain-{tên}/` (1 folder, 10 file bắt buộc + `ui-flows.md` nếu có FE = tối đa 11) |
|
|
276
|
+
| `--check` | Báo cáo diff (không sửa file) |
|
|
277
|
+
| `--refresh` | Cập nhật module card + `Last verified` date |
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## Quy tắc quan trọng
|
|
282
|
+
|
|
283
|
+
1. **Ghi thực trạng** — không suy diễn "nên là gì", chỉ ghi "đang là gì"
|
|
284
|
+
2. **Không lý tưởng hóa** — kiến trúc lộn xộn thì chỉ đích danh
|
|
285
|
+
3. **Gắn nhãn**: `[⚠️ AI-inferred]` cho suy luận, `[❓ CẦN HUMAN BỔ SUNG]` cho thiếu context
|
|
286
|
+
4. **Để trống thay vì bịa** — `[Chưa xác định — cần Tech Lead / BA]`
|
|
287
|
+
5. **Luôn ghi nguồn** — tên file/hàm/dòng code
|
|
288
|
+
6. **Không sửa code** — chỉ đọc và phân tích
|
|
289
|
+
7. **Không tạo file rỗng** — module không có FE thì bỏ `ui-flows.md`
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## Xử lý khi gặp vấn đề
|
|
294
|
+
|
|
295
|
+
| Tình huống | Hành động |
|
|
296
|
+
|-----------|---------|
|
|
297
|
+
| Codebase quá lớn (> 5000 files) | Focus top-level + config files, scan deep chỉ main modules |
|
|
298
|
+
| Không nhận ra tech stack | Ghi `[⚠️ AI-inferred]` và liệt kê extension counts |
|
|
299
|
+
| File binary / compiled | Bỏ qua, ghi chú |
|
|
300
|
+
| Không biết module nào là chính | Scan tất cả, đánh dấu `[Core]` vs `[Support]` |
|
|
301
|
+
| Template không tồn tại | Tạo module card với structure mặc định |
|
|
302
|
+
| File module card đã có data thực | MERGE — giữ data cũ, bổ sung data mới |
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## Routing — Bước tiếp theo
|
|
307
|
+
|
|
308
|
+
```
|
|
309
|
+
Scan --all hoàn thành
|
|
310
|
+
→ Route: /v.constitute (tạo constitution từ context)
|
|
311
|
+
→ Hoặc: /v.understand --module (deep dive từng module)
|
|
312
|
+
|
|
313
|
+
Scan --module hoàn thành
|
|
314
|
+
→ Route: Tech Lead review module cards
|
|
315
|
+
→ Sau đó: /v.specify (bắt đầu feature development)
|
|
316
|
+
|
|
317
|
+
Scan --check
|
|
318
|
+
→ Trả về diff report — không sửa file
|
|
319
|
+
|
|
320
|
+
Scan --refresh
|
|
321
|
+
→ Cập nhật module cards và last_verified date
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## Cập nhật State & Session
|
|
325
|
+
|
|
326
|
+
**Cập nhật `.flow-state.yaml`** (global, không per-feature):
|
|
327
|
+
```yaml
|
|
328
|
+
# Không cập nhật per-feature state — U.0 là project-level
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
**Ghi vào context.md** (Module Index section):
|
|
332
|
+
```markdown
|
|
333
|
+
## Module Index (auto-generated by /v.understand)
|
|
334
|
+
|
|
335
|
+
| Module | SKILL.md | use-cases | tech-context | db | Last verified |
|
|
336
|
+
|--------|----------|-----------|--------------|-----|---------------|
|
|
337
|
+
| auth | ✅ | ✅ | ✅ | ✅ | [date] |
|
|
338
|
+
| payment | ✅ | ✅ | ⚠️ | N/A | [date] |
|
|
339
|
+
```
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const fs = require('fs-extra');
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
const { isInitialized, getVFlowDir, listFeatures } = require('../lib/templates');
|
|
5
|
+
const { withErrorHandler, requireInit, formatBytes } = require('../lib/cli-error');
|
|
6
|
+
const { createT } = require('../lib/i18n');
|
|
7
|
+
|
|
8
|
+
module.exports = function (program) {
|
|
9
|
+
program
|
|
10
|
+
.command('check')
|
|
11
|
+
.description('Check V Flow setup and artifacts status')
|
|
12
|
+
.action(withErrorHandler(async () => {
|
|
13
|
+
const t = createT();
|
|
14
|
+
const projectRoot = process.cwd();
|
|
15
|
+
requireInit(projectRoot, isInitialized);
|
|
16
|
+
|
|
17
|
+
console.log(chalk.cyan.bold(`\n${t('check.title')}\n`));
|
|
18
|
+
console.log(chalk.green(`${t('check.vflow_found')}\n`));
|
|
19
|
+
|
|
20
|
+
const mfDir = getVFlowDir(projectRoot);
|
|
21
|
+
|
|
22
|
+
// Check core files
|
|
23
|
+
console.log(chalk.white.bold(t('check.core_files')));
|
|
24
|
+
const coreFiles = [
|
|
25
|
+
{ file: 'constitution.md', label: 'Constitution (S.0a)', required: true },
|
|
26
|
+
{ file: 'agent-config.md', label: 'Agent Config (S.0b)', required: true },
|
|
27
|
+
{ file: 'context.md', label: 'Context (U.0)', required: false },
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
for (const { file, label, required } of coreFiles) {
|
|
31
|
+
const filePath = path.join(mfDir, file);
|
|
32
|
+
const exists = fs.existsSync(filePath);
|
|
33
|
+
const icon = exists ? chalk.green('✅') : (required ? chalk.red('❌') : chalk.yellow('⚠️'));
|
|
34
|
+
const status = exists ? chalk.dim(` (${formatBytes(fs.statSync(filePath).size)})`) : chalk.dim(' → missing');
|
|
35
|
+
console.log(` ${icon} ${label}${status}`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Check knowledge base
|
|
39
|
+
console.log(chalk.white.bold(`\n${t('check.knowledge')}`));
|
|
40
|
+
const knowledgeItems = [
|
|
41
|
+
{ dir: 'knowledge/domain-glossary.md', label: 'Domain Glossary', isFile: true },
|
|
42
|
+
{ dir: 'knowledge/architecture-decisions', label: 'Architecture Decisions' },
|
|
43
|
+
{ dir: 'knowledge/patterns', label: 'Patterns' },
|
|
44
|
+
{ dir: 'knowledge/golden-tests', label: 'Golden Tests (Ground Truth)' },
|
|
45
|
+
{ dir: 'knowledge/lessons-learned', label: 'Lessons Learned' },
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
for (const item of knowledgeItems) {
|
|
49
|
+
const itemPath = path.join(mfDir, item.dir);
|
|
50
|
+
const exists = fs.existsSync(itemPath);
|
|
51
|
+
if (item.isFile) {
|
|
52
|
+
const icon = exists ? chalk.green('✅') : chalk.yellow('⚠️');
|
|
53
|
+
console.log(` ${icon} ${item.label}`);
|
|
54
|
+
} else if (exists) {
|
|
55
|
+
const count = (await fs.readdir(itemPath)).filter(f => f.endsWith('.md')).length;
|
|
56
|
+
console.log(` ${chalk.green('✅')} ${item.label} ${chalk.dim(`(${count} files)`)}`);
|
|
57
|
+
} else {
|
|
58
|
+
console.log(` ${chalk.yellow('⚠️')} ${item.label} ${chalk.dim('→ empty')}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Check features
|
|
63
|
+
const features = await listFeatures(projectRoot);
|
|
64
|
+
console.log(chalk.white.bold(`\n${t('check.features', { count: features.length })}`));
|
|
65
|
+
|
|
66
|
+
if (features.length > 0) {
|
|
67
|
+
for (const feature of features) {
|
|
68
|
+
console.log(chalk.dim(` 📂 ${feature}`));
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
console.log(chalk.dim(` ${t('check.no_features')}`));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Check AI agent setup
|
|
75
|
+
console.log(chalk.white.bold(`\n${t('check.ai_agents')}`));
|
|
76
|
+
const aiChecks = [
|
|
77
|
+
{ path: 'AGENTS.md', label: 'Antigravity (AGENTS.md)', root: true },
|
|
78
|
+
{ path: '.agents/workflows', label: 'Antigravity Slash Commands (.agents/workflows/)', root: true },
|
|
79
|
+
{ path: '.github/copilot-instructions.md', label: 'Copilot (copilot-instructions.md)', root: true },
|
|
80
|
+
{ path: '.github/prompts', label: 'Copilot Slash Commands (.github/prompts/)', root: true },
|
|
81
|
+
{ path: '.cursorrules', label: 'Cursor (.cursorrules)', root: true },
|
|
82
|
+
{ path: '.cursor/rules', label: 'Cursor Slash Commands (.cursor/rules/)', root: true },
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
for (const check of aiChecks) {
|
|
86
|
+
const checkPath = check.root
|
|
87
|
+
? path.join(projectRoot, check.path)
|
|
88
|
+
: path.join(mfDir, check.path);
|
|
89
|
+
const exists = fs.existsSync(checkPath);
|
|
90
|
+
const icon = exists ? chalk.green('✅') : chalk.yellow('⚠️');
|
|
91
|
+
console.log(` ${icon} ${check.label}`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
console.log('');
|
|
95
|
+
}));
|
|
96
|
+
};
|