@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,41 @@
|
|
|
1
|
+
REQ-E01 [Event-driven]
|
|
2
|
+
Khi người dùng nhấn nút "Đăng nhập", hệ thống phải:
|
|
3
|
+
a) Validate email format theo RFC 5322
|
|
4
|
+
b) Kiểm tra credentials với auth service trong vòng 3 giây
|
|
5
|
+
c) Redirect về /dashboard nếu thành công
|
|
6
|
+
d) Hiển thị "Email hoặc mật khẩu không đúng" nếu thất bại (không nói cái nào sai)
|
|
7
|
+
|
|
8
|
+
Acceptance Criteria:
|
|
9
|
+
- [ ] Login thành công trong <3s
|
|
10
|
+
- [ ] Error message không reveal thông tin credential cụ thể
|
|
11
|
+
- [ ] Email không hợp lệ → hiển thị inline error ngay
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
REQ-U01 [Ubiquitous]
|
|
16
|
+
Hệ thống phải mã hóa mật khẩu bằng thuật toán hash an toàn trước khi lưu vào database.
|
|
17
|
+
|
|
18
|
+
Acceptance Criteria:
|
|
19
|
+
- [ ] Không có plaintext password trong database
|
|
20
|
+
- [ ] Hash output khác nhau cho cùng password (có salt)
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
REQ-S01 [State-driven]
|
|
25
|
+
Trong khi hệ thống đang gọi API đăng nhập, hệ thống phải:
|
|
26
|
+
a) Hiển thị loading indicator
|
|
27
|
+
b) Disable nút Đăng nhập để tránh submit trùng
|
|
28
|
+
|
|
29
|
+
Acceptance Criteria:
|
|
30
|
+
- [ ] Loading indicator visible khi isLoading = true
|
|
31
|
+
- [ ] Nút Đăng nhập disabled khi đang loading
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
REQ-O01 [Optional]
|
|
36
|
+
Nếu người dùng đã có access token hợp lệ trong storage, hệ thống phải
|
|
37
|
+
tự động redirect về /dashboard mà không hiển thị màn hình đăng nhập.
|
|
38
|
+
|
|
39
|
+
Acceptance Criteria:
|
|
40
|
+
- [ ] Có valid token → skip login screen
|
|
41
|
+
- [ ] Token expired → hiển thị login screen bình thường
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Gotchas — EARS Writer
|
|
2
|
+
|
|
3
|
+
> Cập nhật liên tục khi Agent gặp edge case mới.
|
|
4
|
+
> Mỗi lỗi lặp lại 2 lần → BẮT BUỘC thêm vào đây.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Anti-Patterns Phổ Biến
|
|
9
|
+
|
|
10
|
+
1. ❌ **Trộn nhiều actions**: "Hệ thống phải validate, hash, và lưu" → Tách 3 REQs.
|
|
11
|
+
- **Hậu quả**: Test Agent không biết test cái nào, Plan Agent không biết split task.
|
|
12
|
+
|
|
13
|
+
2. ❌ **Thiếu error case**: Chỉ viết happy path "Khi login thành công" → Quên REQ cho login fail.
|
|
14
|
+
- **Hậu quả**: Implement Agent skip error handling → bug production.
|
|
15
|
+
|
|
16
|
+
3. ❌ **Copy-paste prefix**: Dùng REQ-E cho tất cả → Mất ý nghĩa phân loại.
|
|
17
|
+
- **Dấu hiệu**: Toàn bộ spec chỉ có REQ-E → chắc chắn sai.
|
|
18
|
+
|
|
19
|
+
4. ❌ **AC không measurable**: "- [ ] Login nhanh" → Không test được.
|
|
20
|
+
- **Fix**: "- [ ] Login response < 3s" hoặc "- [ ] Test pass với mock delay 2s".
|
|
21
|
+
|
|
22
|
+
5. ❌ **Viết technical trong spec**: "Dùng SHA-256 với salt 16 bytes, bcrypt cost 12"
|
|
23
|
+
- **Fix**: Spec: "mã hóa mật khẩu". Plan quyết algorithm. Spec nói WHAT, không nói HOW.
|
|
24
|
+
|
|
25
|
+
6. ❌ **Quên actors**: Mọi REQ đều "Hệ thống phải..." — không rõ ai trigger.
|
|
26
|
+
- **Fix**: Event-driven REQ phải nói rõ: "Khi **Admin** nhấn Delete..."
|
|
27
|
+
|
|
28
|
+
7. ❌ **REQ quá vague nhưng có AC quá cụ thể**: REQ mơ hồ + AC chi tiết = inconsistency.
|
|
29
|
+
- **Fix**: REQ phải đủ cụ thể để AC derive tự nhiên.
|
|
30
|
+
|
|
31
|
+
8. ❌ **Quên cross-reference No-Go Zones**: Viết REQ cần sửa file No-Go → sẽ bị block ở B.1.
|
|
32
|
+
- **Fix**: Khi viết REQ → đọc context.md No-Go Zones → verify REQ khả thi.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Edge Cases Hay Quên
|
|
37
|
+
|
|
38
|
+
- Empty state: App mới không có data → UI hiện gì?
|
|
39
|
+
- Timeout: API call > timeout → hiện gì?
|
|
40
|
+
- Concurrent access: 2 users edit cùng 1 record → gì xảy ra?
|
|
41
|
+
- Network error: Offline → retry? Cache?
|
|
42
|
+
- Boundary values: limit = 0? price = 0? string = 255 chars?
|
|
43
|
+
- Unicode/emoji: Tên chứa emoji? Address chứa ký tự đặc biệt?
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# check-ears-compliance.sh — Validate spec.md follows EARS notation
|
|
3
|
+
# Usage: ./check-ears-compliance.sh <spec.md_path>
|
|
4
|
+
#
|
|
5
|
+
# Checks: ID format, banned words, EARS keyword presence, AC presence
|
|
6
|
+
|
|
7
|
+
SPEC="${1:-spec.md}"
|
|
8
|
+
|
|
9
|
+
if [ ! -f "$SPEC" ]; then
|
|
10
|
+
echo "❌ File not found: $SPEC"
|
|
11
|
+
exit 1
|
|
12
|
+
fi
|
|
13
|
+
|
|
14
|
+
echo "📋 EARS Compliance Check: $SPEC"
|
|
15
|
+
echo "════════════════════════════════════════"
|
|
16
|
+
ERRORS=0
|
|
17
|
+
WARNINGS=0
|
|
18
|
+
|
|
19
|
+
# 1. Check EARS IDs
|
|
20
|
+
echo ""
|
|
21
|
+
echo "### 1. REQ ID Format"
|
|
22
|
+
# Đếm theo SỐ TOKEN bằng `grep -o | wc -l` (mỗi match 1 dòng) — KHÔNG dùng
|
|
23
|
+
# `$(grep -c ... || echo 0)`: grep -c in "0" rồi exit 1 → `|| echo 0` tạo "0\n0"
|
|
24
|
+
# → lỗi "integer expression expected".
|
|
25
|
+
ALL_REQ=$(grep -oE "REQ-[A-Za-z][0-9]+" "$SPEC" | wc -l | tr -d ' ') # mọi REQ-X##
|
|
26
|
+
VALID=$(grep -oE "REQ-[UESO][0-9]+" "$SPEC" | wc -l | tr -d ' ') # đúng EARS U/E/S/O
|
|
27
|
+
INVALID=$((ALL_REQ - VALID))
|
|
28
|
+
echo " ✅ Valid EARS IDs: $VALID"
|
|
29
|
+
[ "$INVALID" -gt 0 ] && echo " ❌ Invalid IDs (not REQ-U/E/S/O): $INVALID" && ERRORS=$((ERRORS+INVALID))
|
|
30
|
+
|
|
31
|
+
# 2. Banned words
|
|
32
|
+
echo ""
|
|
33
|
+
echo "### 2. Banned Words"
|
|
34
|
+
for word in "nên" "should" "có thể" "hợp lý" "v.v." "etc." "dễ dùng" "user-friendly"; do
|
|
35
|
+
count=$(grep -ci "$word" "$SPEC" 2>/dev/null) # grep -c luôn in số nguyên (0 nếu không có)
|
|
36
|
+
[ "$count" -gt 0 ] && echo " ⚠️ '$word' found $count time(s)" && WARNINGS=$((WARNINGS+count))
|
|
37
|
+
done
|
|
38
|
+
[ "$WARNINGS" -eq 0 ] && echo " ✅ No banned words found"
|
|
39
|
+
|
|
40
|
+
# 3. Acceptance Criteria
|
|
41
|
+
echo ""
|
|
42
|
+
echo "### 3. Acceptance Criteria"
|
|
43
|
+
AC_COUNT=$(grep -c "\- \[ \]" "$SPEC" 2>/dev/null)
|
|
44
|
+
REQ_COUNT=$(grep -cE "REQ-[UESO]" "$SPEC" 2>/dev/null)
|
|
45
|
+
echo " REQs: $REQ_COUNT, ACs: $AC_COUNT"
|
|
46
|
+
[ "$REQ_COUNT" -gt 0 ] && [ "$AC_COUNT" -lt "$REQ_COUNT" ] && echo " ⚠️ Some REQs may be missing ACs" && WARNINGS=$((WARNINGS+1))
|
|
47
|
+
|
|
48
|
+
echo ""
|
|
49
|
+
echo "════════════════════════════════════════"
|
|
50
|
+
echo "📊 Errors: $ERRORS, Warnings: $WARNINGS"
|
|
51
|
+
[ "$ERRORS" -eq 0 ] && [ "$WARNINGS" -eq 0 ] && echo "✅ PASS" || echo "⚠️ NEEDS REVIEW"
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: test-case-generator
|
|
3
|
+
description: "Hướng dẫn Test Agent tạo test cases từ spec.md. Agent PHẢI đọc skill này khi /v.test được gọi. Đảm bảo 100% REQ coverage + edge cases + traceability."
|
|
4
|
+
trigger: "Khi /v.test được gọi, tạo test cases từ spec"
|
|
5
|
+
phase: "B.0b"
|
|
6
|
+
used_by:
|
|
7
|
+
- /v.test
|
|
8
|
+
hooks:
|
|
9
|
+
pre_generate: "Load spec.md → extract TẤT CẢ REQ-xxx + AC, tạo coverage matrix"
|
|
10
|
+
post_generate: "Verify: mỗi REQ có ≥1 TC, mỗi AC có TC, edge cases covered"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Test Case Generator — Tạo Test Cases Toàn Diện
|
|
14
|
+
|
|
15
|
+
> ⚠️ Đây là **Skill bắt buộc** cho Test Agent.
|
|
16
|
+
> Mỗi REQ PHẢI có ≥1 Test Case. REQ không có TC = gap nguy hiểm.
|
|
17
|
+
>
|
|
18
|
+
> → Xem `gotchas.md` cho lỗi phổ biến khi viết test cases.
|
|
19
|
+
> → Xem `examples/good/` cho mẫu test-cases.md chuẩn.
|
|
20
|
+
> → Xem `config.json` để customize (coverage_target, tc_format).
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Khi nào KHÔNG tạo test cases
|
|
25
|
+
|
|
26
|
+
- Documentation-only change — không có code logic
|
|
27
|
+
- Config/constant change — test ở integration level, nhưng vẫn cần TC cho behavior
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## REQ Type → Test Strategy Mapping
|
|
32
|
+
|
|
33
|
+
> 💡 Mỗi loại REQ gợi ý strategy test khác nhau (từ EARS notation).
|
|
34
|
+
|
|
35
|
+
| REQ Type | Test Strategy | Ví dụ |
|
|
36
|
+
|----------|--------------|-------|
|
|
37
|
+
| **REQ-U** (Ubiquitous) | Test ở MỌI entry point — always true | "Password always hashed" → test ở create, update, import |
|
|
38
|
+
| **REQ-E** (Event-driven) | Given trigger → expect action | "Khi login → redirect" → test trigger + verify action |
|
|
39
|
+
| **REQ-S** (State-driven) | While in state → verify behavior | "Trong khi offline → queue requests" → set state + verify |
|
|
40
|
+
| **REQ-O** (Optional) | Branch test: condition true + false | "Nếu admin → show panel" → test admin = true + false |
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Đặc Thù Và Quy Ước
|
|
45
|
+
|
|
46
|
+
### 1. Test Case ID Convention
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
TC-NN (đánh số tuần tự toàn file): TC-01, TC-02, TC-03 ...
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Traceability KHÔNG nhúng vào ID mà qua field **Gắn với: REQ-xxx** + **AC: AC-NN** trong mỗi TC — khớp `test-cases-template.md` và Master Check matrix (REQ + AC-NN).
|
|
53
|
+
|
|
54
|
+
### 2. Test Layers
|
|
55
|
+
|
|
56
|
+
Mỗi REQ nên có test ở ≥1 layer:
|
|
57
|
+
|
|
58
|
+
| Layer | Khi nào dùng | Ví dụ |
|
|
59
|
+
|-------|-------------|-------|
|
|
60
|
+
| **Unit** | Business logic, pure functions | UseCase, Repository, Validation |
|
|
61
|
+
| **Integration** | Cross-component interaction | API → DB → Response |
|
|
62
|
+
| **E2E** | User-facing flows | Login → Dashboard redirect |
|
|
63
|
+
|
|
64
|
+
**Rule**: Unit tests cho MỌI REQ. Integration cho cross-component REQ. E2E cho critical path.
|
|
65
|
+
|
|
66
|
+
### 3. Edge Case Generation — 7 Categories
|
|
67
|
+
|
|
68
|
+
Mỗi REQ, quét qua 7 categories để tìm edge cases:
|
|
69
|
+
|
|
70
|
+
| Category | Câu hỏi | Test cases cần có |
|
|
71
|
+
|----------|---------|-------------------|
|
|
72
|
+
| **Empty** | Input rỗng? List 0 items? | TC cho null, "", [], {} |
|
|
73
|
+
| **Boundary** | Min/max values? Off-by-one? | TC cho 0, 1, MAX, MAX+1 |
|
|
74
|
+
| **Error** | Network fail? Invalid input? | TC cho timeout, 400, 500 |
|
|
75
|
+
| **Concurrent** | 2 requests cùng lúc? | TC cho race condition |
|
|
76
|
+
| **Auth** | Không có token? Wrong role? | TC cho 401, 403 |
|
|
77
|
+
| **State** | First time? After reset? | TC cho initial state, reset |
|
|
78
|
+
| **Performance** | Large dataset? Slow network? | TC cho 10K items, 3s timeout |
|
|
79
|
+
|
|
80
|
+
### 4. Test Case Completeness Check
|
|
81
|
+
|
|
82
|
+
Trước khi submit test-cases.md:
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
[ ] Mỗi REQ-xxx có ≥1 TC (happy path)
|
|
86
|
+
[ ] Mỗi REQ Error path có TC riêng
|
|
87
|
+
[ ] Mỗi AC trong spec có TC verify
|
|
88
|
+
[ ] ≥1 edge case per REQ (từ 7 categories)
|
|
89
|
+
[ ] Test priority assigned (P1/P2/P3)
|
|
90
|
+
[ ] Test type assigned (Unit/Integration/E2E)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 5. Priority Assignment
|
|
94
|
+
|
|
95
|
+
| Priority | Criteria | PHẢI test |
|
|
96
|
+
|----------|---------|-----------|
|
|
97
|
+
| **P1** | Core business logic, security, data integrity | ✅ Bắt buộc |
|
|
98
|
+
| **P2** | Important flows, edge cases | ✅ Nên có |
|
|
99
|
+
| **P3** | Nice-to-have, optimization verify | ⚠️ Tùy scope |
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Test Case Template
|
|
104
|
+
|
|
105
|
+
```markdown
|
|
106
|
+
### TC-NN: {Tên test case mô tả behavior}
|
|
107
|
+
|
|
108
|
+
**Gắn với:** REQ-{xxx}
|
|
109
|
+
**AC:** AC-NN (tiêu chí chấp nhận spec §4 mà TC này verify — bắt buộc để cross-check AC↔TC)
|
|
110
|
+
**Loại:** Unit / Integration / E2E
|
|
111
|
+
**Priority:** P1 / P2 / P3
|
|
112
|
+
|
|
113
|
+
#### Preconditions
|
|
114
|
+
- {Trạng thái ban đầu cần thiết}
|
|
115
|
+
|
|
116
|
+
#### Test Steps
|
|
117
|
+
1. {Action 1}
|
|
118
|
+
2. {Action 2}
|
|
119
|
+
|
|
120
|
+
#### Expected Result
|
|
121
|
+
- {Kết quả mong đợi — measurable}
|
|
122
|
+
|
|
123
|
+
#### Edge Cases
|
|
124
|
+
- {Biến thể của test case này}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Coverage Matrix Template
|
|
130
|
+
|
|
131
|
+
> Đặt ở đầu test-cases.md để overview.
|
|
132
|
+
|
|
133
|
+
```markdown
|
|
134
|
+
## Coverage Matrix
|
|
135
|
+
|
|
136
|
+
| REQ | AC | Description | TC Count | Types | Priority |
|
|
137
|
+
|-----|----|------------|----------|-------|----------|
|
|
138
|
+
| REQ-E01 | AC-01 | Login success | 3 | Unit, E2E | P1 |
|
|
139
|
+
| REQ-E02 | AC-02 | Login error | 2 | Unit | P1 |
|
|
140
|
+
| REQ-U01 | AC-03 | Password hash | 1 | Unit | P1 |
|
|
141
|
+
| REQ-O01 | AC-04 | Rate limit | 2 | Unit, Integration | P2 |
|
|
142
|
+
|
|
143
|
+
**Coverage**: 4/4 REQs (100%) ✅
|
|
144
|
+
**Total TCs**: 8
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## V-Flow Integration Points
|
|
150
|
+
|
|
151
|
+
- **spec.md** (S.1) → Input: REQs + ACs
|
|
152
|
+
- **ears-notation skill** → REQ type → test strategy mapping
|
|
153
|
+
- **plan.md** (B.0a) → Component info cho integration test scope
|
|
154
|
+
- **tasks.md** (B.0a) → Test Agent map TC → TASK cho Implement Agent
|
|
155
|
+
- **cross-validator skill** → Master Check verify TC coverage
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Gotchas
|
|
160
|
+
|
|
161
|
+
→ Xem `gotchas.md` cho lỗi phổ biến khi viết test cases — cập nhật liên tục.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"setup_questions": [
|
|
3
|
+
{
|
|
4
|
+
"id": "coverage_target",
|
|
5
|
+
"question": "REQ coverage target (%)?",
|
|
6
|
+
"type": "number",
|
|
7
|
+
"default": 100,
|
|
8
|
+
"description": "Phần trăm REQs phải có test case. 100% recommended."
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"id": "tc_format",
|
|
12
|
+
"question": "Test case format?",
|
|
13
|
+
"options": ["structured", "gherkin", "tabular"],
|
|
14
|
+
"default": "structured",
|
|
15
|
+
"description": "structured = markdown template. gherkin = Given-When-Then. tabular = table format."
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"id": "edge_case_min",
|
|
19
|
+
"question": "Số edge case tối thiểu per REQ?",
|
|
20
|
+
"type": "number",
|
|
21
|
+
"default": 1
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"hooks": {
|
|
25
|
+
"pre_generate": "Load spec.md → extract REQ list + AC list → tạo coverage matrix skeleton",
|
|
26
|
+
"post_generate": "Verify coverage matrix 100%, mỗi AC có TC, edge cases ≥ min per REQ"
|
|
27
|
+
},
|
|
28
|
+
"memory": {
|
|
29
|
+
"file": "test-gen-history.log",
|
|
30
|
+
"format": "[date] | [feature] | [total_reqs] | [total_tcs] | [coverage_pct] | [edge_cases]",
|
|
31
|
+
"purpose": "Track test coverage patterns — dùng cho /v.metrics"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Ví dụ — Test Cases (User Login Feature)
|
|
2
|
+
|
|
3
|
+
> Đây là mẫu output chuẩn cho Test Agent.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Coverage Matrix
|
|
8
|
+
|
|
9
|
+
| REQ | Description | TC Count | Types | Priority |
|
|
10
|
+
|-----|------------|----------|-------|----------|
|
|
11
|
+
| REQ-E01 | Login success | 3 | Unit, E2E | P1 |
|
|
12
|
+
| REQ-E02 | Invalid credentials | 2 | Unit | P1 |
|
|
13
|
+
| REQ-U01 | Password security | 2 | Unit | P1 |
|
|
14
|
+
| REQ-O01 | Rate limiting | 3 | Unit, Integration | P2 |
|
|
15
|
+
|
|
16
|
+
**Coverage**: 4/4 REQs (100%) ✅
|
|
17
|
+
**Total TCs**: 10
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Test Cases
|
|
22
|
+
|
|
23
|
+
### TC-E01-01: Login thành công với credentials hợp lệ
|
|
24
|
+
|
|
25
|
+
**Gắn với:** REQ-E01
|
|
26
|
+
**Loại:** Unit
|
|
27
|
+
**Priority:** P1
|
|
28
|
+
|
|
29
|
+
#### Preconditions
|
|
30
|
+
- User "test@example.com" tồn tại trong DB
|
|
31
|
+
- Password hash hợp lệ
|
|
32
|
+
|
|
33
|
+
#### Test Steps
|
|
34
|
+
1. Gọi LoginUseCase.execute(email: "test@example.com", password: "Valid1@pass")
|
|
35
|
+
2. Verify response
|
|
36
|
+
|
|
37
|
+
#### Expected Result
|
|
38
|
+
- Result = Success
|
|
39
|
+
- AuthToken not null, length ≥ 32
|
|
40
|
+
- User object contains email, id
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
### TC-E01-02: Login redirect về dashboard sau success
|
|
45
|
+
|
|
46
|
+
**Gắn với:** REQ-E01
|
|
47
|
+
**Loại:** E2E
|
|
48
|
+
**Priority:** P1
|
|
49
|
+
|
|
50
|
+
#### Preconditions
|
|
51
|
+
- User tồn tại, credentials hợp lệ
|
|
52
|
+
|
|
53
|
+
#### Test Steps
|
|
54
|
+
1. Navigate to /login
|
|
55
|
+
2. Nhập email + password hợp lệ
|
|
56
|
+
3. Click "Đăng nhập"
|
|
57
|
+
|
|
58
|
+
#### Expected Result
|
|
59
|
+
- Redirect to /dashboard
|
|
60
|
+
- Token stored in secure storage
|
|
61
|
+
- Loading indicator hiện trong lúc chờ
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
### TC-E02-01: Login fail với wrong password
|
|
66
|
+
|
|
67
|
+
**Gắn với:** REQ-E02
|
|
68
|
+
**Loại:** Unit
|
|
69
|
+
**Priority:** P1
|
|
70
|
+
|
|
71
|
+
#### Preconditions
|
|
72
|
+
- User "test@example.com" tồn tại
|
|
73
|
+
- Password sai
|
|
74
|
+
|
|
75
|
+
#### Test Steps
|
|
76
|
+
1. Gọi LoginUseCase.execute(email: "test@example.com", password: "wrong")
|
|
77
|
+
|
|
78
|
+
#### Expected Result
|
|
79
|
+
- Result = Failure(InvalidCredentials)
|
|
80
|
+
- Error message = "Email hoặc mật khẩu không đúng" (không reveal cái nào sai)
|
|
81
|
+
|
|
82
|
+
#### Edge Cases
|
|
83
|
+
- Email không tồn tại → same error message (không leak info)
|
|
84
|
+
- Empty password → validation error trước khi gọi API
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
### TC-O01-01: Rate limit sau 5 attempts thất bại
|
|
89
|
+
|
|
90
|
+
**Gắn với:** REQ-O01
|
|
91
|
+
**Loại:** Integration
|
|
92
|
+
**Priority:** P2
|
|
93
|
+
|
|
94
|
+
#### Preconditions
|
|
95
|
+
- User tồn tại, attempt counter = 0
|
|
96
|
+
|
|
97
|
+
#### Test Steps
|
|
98
|
+
1. Gọi login 5 lần với wrong password
|
|
99
|
+
2. Gọi login lần 6 với ĐÚNG password
|
|
100
|
+
|
|
101
|
+
#### Expected Result
|
|
102
|
+
- Lần 1-5: Result = Failure(InvalidCredentials)
|
|
103
|
+
- Lần 6: Result = Failure(RateLimited), message = "Quá nhiều lần thử, đợi 15 phút"
|
|
104
|
+
- Lần 6 KHÔNG check credentials (block trước khi authenticate)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Gotchas — Test Case Generator
|
|
2
|
+
|
|
3
|
+
> Cập nhật liên tục khi Agent gặp edge case mới.
|
|
4
|
+
> Mỗi lỗi lặp lại 2 lần → BẮT BUỘC thêm vào đây.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Anti-Patterns
|
|
9
|
+
|
|
10
|
+
1. ❌ **Chỉ test happy path** — Viết TC cho success, quên error cases.
|
|
11
|
+
- **Hậu quả**: Error handling untested → crash production.
|
|
12
|
+
- **Fix**: Mỗi REQ event-driven → ≥1 TC happy + ≥1 TC error.
|
|
13
|
+
|
|
14
|
+
2. ❌ **TC không trace về REQ** — Test case "kiểm tra login" không reference REQ-xxx.
|
|
15
|
+
- **Hậu quả**: Master Check sẽ flag "REQ coverage gap".
|
|
16
|
+
- **Fix**: TC ID = TC-NN tuần tự; trace bằng field "Gắn với: REQ-xxx" + "AC: AC-NN" trong mỗi TC.
|
|
17
|
+
|
|
18
|
+
3. ❌ **TC mơ hồ** — "Expected: hệ thống hoạt động đúng."
|
|
19
|
+
- **Hậu quả**: Implement Agent không biết test gì → test useless.
|
|
20
|
+
- **Fix**: Expected Result = cụ thể + measurable: "Response 201, body.id not null".
|
|
21
|
+
|
|
22
|
+
4. ❌ **TC duplicate** — 3 TCs test cùng behavior nhưng khác wording.
|
|
23
|
+
- **Fix**: 1 behavior = 1 TC. Biến thể = edge cases trong cùng TC.
|
|
24
|
+
|
|
25
|
+
5. ❌ **Quên edge categories** — Viết 5 TCs nhưng toàn happy path biến thể.
|
|
26
|
+
- **Fix**: Quét 7 categories (Empty, Boundary, Error, Concurrent, Auth, State, Performance).
|
|
27
|
+
|
|
28
|
+
6. ❌ **Priority tất cả P1** — Mọi TC đều P1 → không biết test nào quan trọng nhất.
|
|
29
|
+
- **Fix**: P1 = core logic + security. P2 = edge cases. P3 = optimization.
|
|
30
|
+
|
|
31
|
+
7. ❌ **Thiếu preconditions** — TC nói "login" nhưng không nói user phải tồn tại trước.
|
|
32
|
+
- **Fix**: Mỗi TC PHẢI có preconditions rõ ràng: data state, auth state, system state.
|
|
33
|
+
|
|
34
|
+
8. ❌ **TC quá tightly coupled với implementation** — "Mock UserRepository.findByEmail()".
|
|
35
|
+
- **Fix**: TC mô tả BEHAVIOR, không mô tả implementation detail. Implement Agent quyết mock strategy.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Edge Cases
|
|
40
|
+
|
|
41
|
+
- ✅ Spec chỉ có 1-2 REQ → Vẫn cần edge cases. REQ ít ≠ test ít.
|
|
42
|
+
- ✅ REQ-U (ubiquitous) → Test ở NHIỀU entry points, không chỉ 1.
|
|
43
|
+
- ✅ Feature liên quan external API → TC cho API down, slow, wrong format.
|