@relipa/ai-flow-kit 0.2.0 → 0.2.2-beta.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 (51) hide show
  1. package/README.md +4 -4
  2. package/custom/rules/java/spring-boot-rules.md +209 -0
  3. package/custom/rules/javascript/nestjs-examples.md +41 -0
  4. package/custom/rules/javascript/nestjs-rules.md +42 -0
  5. package/custom/rules/javascript/nodejs-express-examples.md +35 -0
  6. package/custom/rules/javascript/nodejs-express-rules.md +49 -0
  7. package/custom/rules/javascript/reactjs-examples.md +380 -0
  8. package/custom/rules/javascript/reactjs-rules.md +173 -0
  9. package/custom/rules/php/php-examples.md +161 -0
  10. package/custom/rules/php/php-rules.md +127 -0
  11. package/custom/rules/python/python-django-examples.md +34 -0
  12. package/custom/rules/python/python-django-rules.md +48 -0
  13. package/custom/rules/python/python-examples.md +32 -0
  14. package/custom/rules/python/python-fastapi-examples.md +30 -0
  15. package/custom/rules/python/python-fastapi-rules.md +35 -0
  16. package/custom/rules/python/python-ml-examples.md +187 -0
  17. package/custom/rules/python/python-ml-rules.md +121 -0
  18. package/custom/rules/python/python-rules.md +58 -0
  19. package/custom/skills/ba-skills/skill-ba-qna-template-v1.md +4 -4
  20. package/custom/skills/ba-skills/skill-ba-qna-v1.md +6 -0
  21. package/custom/skills/create-system-requirement/SKILL.md +99 -25
  22. package/custom/skills/create-system-requirement/system-requirement-template-v1.md +282 -0
  23. package/custom/skills/execute-flow/SKILL.md +142 -36
  24. package/custom/skills/execute-flow/templates/evidence-helper.ts +145 -0
  25. package/custom/skills/execute-flow/templates/playwright.config.ts +28 -8
  26. package/custom/skills/impact-analysis/SKILL.md +106 -106
  27. package/custom/skills/read-study-requirement/SKILL.md +1 -2
  28. package/custom/skills/report-customer/SKILL.md +99 -99
  29. package/custom/skills/script-sync/SKILL.md +54 -16
  30. package/custom/templates/nestjs.md +5 -72
  31. package/custom/templates/nodejs-express.md +5 -73
  32. package/custom/templates/php-plain.md +5 -261
  33. package/custom/templates/php.md +5 -261
  34. package/custom/templates/python-django.md +5 -71
  35. package/custom/templates/python-fastapi.md +5 -54
  36. package/custom/templates/python-ml.md +1 -269
  37. package/custom/templates/python.md +5 -79
  38. package/custom/templates/reactjs.md +5 -492
  39. package/custom/templates/shared/gate-workflow.md +18 -11
  40. package/custom/templates/shared/ml-gate-workflow.md +1 -0
  41. package/custom/templates/spring-boot.md +5 -224
  42. package/docs/common/CHANGELOG.md +24 -6
  43. package/docs/common/INDEX.md +1 -0
  44. package/docs/common/QUICK_START.md +1 -1
  45. package/docs/common/System-Requirement-Read-Guide.md +178 -0
  46. package/docs/common/Testing-Structure.md +31 -25
  47. package/docs/common/cli-reference.md +12 -10
  48. package/package.json +1 -1
  49. package/scripts/init.js +143 -40
  50. package/scripts/prompt.js +3 -3
  51. package/scripts/scaffold-playwright.js +2 -0
@@ -1,106 +1,106 @@
1
- ---
2
- name: impact-analysis
3
- description: Analyze the impact scope when modifying logic or the database to ensure system-wide safety.
4
- keywords: impact, refactor, breaking change, scope
5
- ---
6
-
7
- # Impact Analysis
8
-
9
- ## When mandatory to run
10
-
11
- - Modifying **Core Services / shared utilities** used in many places
12
- - Changing **database schema** (add/rename/drop column, table)
13
- - Changing **API response structure** (rename field, remove field)
14
- - Changing **interfaces / contracts** between modules
15
- - After fixing a bug — to ensure the fix doesn't break other parts
16
-
17
- ---
18
-
19
- ## Analysis Process
20
-
21
- ### Step 1: Find all usage (Dependency Map)
22
-
23
- **Preferred — If GitNexus MCP is available** (`.mcp.json` has `gitnexus` entry):
24
- ```
25
- impact("ClassName") → structured blast radius: callers, dependents, risk score
26
- detect_changes() → reads current git diff, maps changed lines → affected symbols
27
- ```
28
- - Use `impact()` when you know the class/function name being modified.
29
- - Use `detect_changes()` when starting Gate 4 review — it auto-detects what changed from git diff without needing to specify names.
30
- - One call replaces all grep commands below. Proceed directly to Step 2 with the result.
31
-
32
- **Fallback — grep manually** (if GitNexus not configured):
33
- ```bash
34
- # Find all files importing/calling the class/function being modified
35
- grep -r "ClassName\|functionName\|methodName" --include="*.php" .
36
- grep -r "ClassName\|functionName\|methodName" --include="*.java" .
37
- grep -r "ClassName\|functionName\|methodName" --include="*.ts" .
38
-
39
- # Check which routes/controllers trigger this service
40
- grep -r "ServiceName" app/Http/Controllers/
41
- ```
42
-
43
- List all:
44
- - Controllers / Routes calling it directly
45
- - Jobs / Commands / Events calling it indirectly
46
- - Tests mocking/stubbing this class
47
- - Frontend components calling related APIs
48
-
49
- ### Step 2: Evaluate each aspect
50
-
51
- | Aspect | Checkpoint questions |
52
- |-----------|---------------------|
53
- | **Database / Cache** | Which queries are affected by schema changes? Which cache keys need flushing? |
54
- | **Background Jobs** | Which Crons / Queues call this logic? Will they break? |
55
- | **Import / Export** | Do bulk data flows use this field/logic? |
56
- | **Permissions** | Are API / UI permission checks sufficient after the change? |
57
- | **API / Mobile** | Will JSON responses lose fields? Do mobile clients need updates? |
58
- | **Tests** | Which tests will fail? Which mocks/stubs need updating? |
59
-
60
- ### Step 3: Classify impact level
61
-
62
- | Level | Definition | Action |
63
- |-----|-----------|-----------|
64
- | 🟢 Low | Only 1 file, no dependencies | Proceed |
65
- | 🟡 Medium | 2–5 files, tests need updates | Review carefully before merging |
66
- | 🔴 High | 6+ files, API breaking change, DB migration | Discuss with the team first |
67
- | ⛔ Critical | Affects payment, auth, data integrity | Tech Lead review mandatory |
68
-
69
- ### Step 4: Export report
70
-
71
- **Report structure:**
72
-
73
- ```
74
- ## Impact Analysis: [Change Name]
75
-
76
- **Level:** 🟡 Medium
77
-
78
- ### Impact Scope
79
- - [File/Class A] — [reason for impact]
80
- - [File/Class B] — [reason for impact]
81
-
82
- ### Breaking changes
83
- - [Describe breaking change if any]
84
-
85
- ### Tests to check after merge
86
- - [ ] [Test case / screen 1]
87
- - [ ] [Test case / screen 2]
88
- - [ ] [Job/Command to test run]
89
-
90
- ### Notes for QA
91
- [Specific points QA should pay attention to]
92
- ```
93
-
94
- Output language: auto-detect from the ticket/task input — see `custom/rules/output-language.md` (Vietnamese input → Vietnamese output; otherwise English).
95
-
96
- ---
97
-
98
- ## Completion Checklist
99
-
100
- - [ ] Found all dependencies using grep/IDE search
101
- - [ ] Checked Jobs, Events, and Crons
102
- - [ ] Checked API response structure
103
- - [ ] Checked tests
104
- - [ ] Determined impact level (Low/Medium/High/Critical)
105
- - [ ] Wrote impact report
106
- - [ ] Notified the team if High/Critical
1
+ ---
2
+ name: impact-analysis
3
+ description: Analyze the impact scope when modifying logic or the database to ensure system-wide safety.
4
+ keywords: impact, refactor, breaking change, scope
5
+ ---
6
+
7
+ # Impact Analysis
8
+
9
+ ## When mandatory to run
10
+
11
+ - Modifying **Core Services / shared utilities** used in many places
12
+ - Changing **database schema** (add/rename/drop column, table)
13
+ - Changing **API response structure** (rename field, remove field)
14
+ - Changing **interfaces / contracts** between modules
15
+ - After fixing a bug — to ensure the fix doesn't break other parts
16
+
17
+ ---
18
+
19
+ ## Analysis Process
20
+
21
+ ### Step 1: Find all usage (Dependency Map)
22
+
23
+ **Preferred — If GitNexus MCP is available** (`.mcp.json` has `gitnexus` entry):
24
+ ```
25
+ impact("ClassName") → structured blast radius: callers, dependents, risk score
26
+ detect_changes() → reads current git diff, maps changed lines → affected symbols
27
+ ```
28
+ - Use `impact()` when you know the class/function name being modified.
29
+ - Use `detect_changes()` when starting Gate 4 review — it auto-detects what changed from git diff without needing to specify names.
30
+ - One call replaces all grep commands below. Proceed directly to Step 2 with the result.
31
+
32
+ **Fallback — grep manually** (if GitNexus not configured):
33
+ ```bash
34
+ # Find all files importing/calling the class/function being modified
35
+ grep -r "ClassName\|functionName\|methodName" --include="*.php" .
36
+ grep -r "ClassName\|functionName\|methodName" --include="*.java" .
37
+ grep -r "ClassName\|functionName\|methodName" --include="*.ts" .
38
+
39
+ # Check which routes/controllers trigger this service
40
+ grep -r "ServiceName" app/Http/Controllers/
41
+ ```
42
+
43
+ List all:
44
+ - Controllers / Routes calling it directly
45
+ - Jobs / Commands / Events calling it indirectly
46
+ - Tests mocking/stubbing this class
47
+ - Frontend components calling related APIs
48
+
49
+ ### Step 2: Evaluate each aspect
50
+
51
+ | Aspect | Checkpoint questions |
52
+ |-----------|---------------------|
53
+ | **Database / Cache** | Which queries are affected by schema changes? Which cache keys need flushing? |
54
+ | **Background Jobs** | Which Crons / Queues call this logic? Will they break? |
55
+ | **Import / Export** | Do bulk data flows use this field/logic? |
56
+ | **Permissions** | Are API / UI permission checks sufficient after the change? |
57
+ | **API / Mobile** | Will JSON responses lose fields? Do mobile clients need updates? |
58
+ | **Tests** | Which tests will fail? Which mocks/stubs need updating? |
59
+
60
+ ### Step 3: Classify impact level
61
+
62
+ | Level | Definition | Action |
63
+ |-----|-----------|-----------|
64
+ | 🟢 Low | Only 1 file, no dependencies | Proceed |
65
+ | 🟡 Medium | 2–5 files, tests need updates | Review carefully before merging |
66
+ | 🔴 High | 6+ files, API breaking change, DB migration | Discuss with the team first |
67
+ | ⛔ Critical | Affects payment, auth, data integrity | Tech Lead review mandatory |
68
+
69
+ ### Step 4: Export report
70
+
71
+ **Report structure:**
72
+
73
+ ```
74
+ ## Impact Analysis: [Change Name]
75
+
76
+ **Level:** 🟡 Medium
77
+
78
+ ### Impact Scope
79
+ - [File/Class A] — [reason for impact]
80
+ - [File/Class B] — [reason for impact]
81
+
82
+ ### Breaking changes
83
+ - [Describe breaking change if any]
84
+
85
+ ### Tests to check after merge
86
+ - [ ] [Test case / screen 1]
87
+ - [ ] [Test case / screen 2]
88
+ - [ ] [Job/Command to test run]
89
+
90
+ ### Notes for QA
91
+ [Specific points QA should pay attention to]
92
+ ```
93
+
94
+ Output language: auto-detect from the ticket/task input — see `custom/rules/output-language.md` (Vietnamese input → Vietnamese output; otherwise English).
95
+
96
+ ---
97
+
98
+ ## Completion Checklist
99
+
100
+ - [ ] Found all dependencies using grep/IDE search
101
+ - [ ] Checked Jobs, Events, and Crons
102
+ - [ ] Checked API response structure
103
+ - [ ] Checked tests
104
+ - [ ] Determined impact level (Low/Medium/High/Critical)
105
+ - [ ] Wrote impact report
106
+ - [ ] Notified the team if High/Critical
@@ -22,8 +22,7 @@ Before reading the ticket in depth, verify the bridge document from UC Spec —
22
22
  3. Check `AK-Docs/02.BA-Specs/00.Requirements/[functionId]/System-Requirement_v*.md`:
23
23
  - **Missing** → `⚠️ CẢNH BÁO: Không tìm thấy System Requirement cho [functionId]. Khuyến nghị chạy "ak use" → "📐 Create System Requirement" trước ticket kế tiếp — Gate 1 vẫn tiếp tục ngay bây giờ dựa trên UC Spec/ticket.`
24
24
  - **Exists, but its `UC-Spec-Version` header doesn't match the UC Spec found in step 2** → `⚠️ CẢNH BÁO: System Requirement đang trace theo UC Spec v[X], UC Spec hiện tại là v[Y] — nội dung có thể lỗi thời.` Treat its items as Assumption rather than Fact in Step 1.75.
25
- - **Exists, matches, but its `Status` header is not `✅ Approved`** `⚠️ CẢNH BÁO: System Requirement cho [functionId] chưa Approved (Status: [giá trị hiện tại])nội dung thể còn thay đổi.`
26
- - **Exists, matches, and Approved** → continue silently. Keep this file's path — Step 1 must read it as mandatory input.
25
+ - **Exists and matches** continue silently. Keep this file's path Step 1 must read it as mandatory input. (Its presence in the repo already means DEV approved and pushed it approval isn't tracked with a separate header.)
27
26
 
28
27
  Any warning raised above must also be written into this ticket's requirement doc (Section 1, Facts/Assumptions/Gaps in Step 4) — not just printed and forgotten. If DEV wants the gap closed properly, they can run `ak use` → "📐 Create System Requirement" for `[functionId]` at any point (before or after this ticket) — it's a separate 2-gate task type, not an inline sub-skill here.
29
28
 
@@ -1,99 +1,99 @@
1
- ---
2
- name: report-customer
3
- description: Write an incident report for customers or customer service after a production bug fix. Non-technical, easy-to-understand language.
4
- keywords: report, incident, customer, customer service, CS
5
- ---
6
-
7
- # Report Customer (Incident Report)
8
-
9
- ## When to use
10
-
11
- - After fixing a bug that affects users/customers
12
- - Customer Service needs a report explaining the cause to customers
13
- - Need to document the incident for future reference
14
-
15
- ---
16
-
17
- ## Process
18
-
19
- ### Step 1: Gather information
20
-
21
- Collect from `investigate-bug` results or developer descriptions:
22
- - Ticket ID and title
23
- - Discovery time / impact duration
24
- - Number of affected users / orders
25
- - Identified root cause
26
- - Deployment status
27
-
28
- ### Step 2: Write the report
29
-
30
- Fill in the structure below. **Use simple language, avoiding technical jargon.**
31
-
32
- ---
33
-
34
- ## Standard Structure
35
-
36
- Output language: auto-detect from the ticket/task input — see `custom/rules/output-language.md`
37
- (Vietnamese ticket → Vietnamese report; otherwise English). CS can request a specific language
38
- explicitly, which overrides auto-detect. Structure below is shown in English.
39
-
40
- ```markdown
41
- ## 📋 Incident Verification Report
42
-
43
- **Ticket ID:** [ID]
44
- **Assigned to:** [Dev Name]
45
- **Resolution Date:** [YYYY-MM-DD]
46
- **Status:** ✅ Resolved / 🔄 In Progress
47
-
48
- ---
49
-
50
- ### 1. Summary
51
-
52
- [1–2 sentences describing the issue in non-technical language.
53
- Example: "Between 14:00–15:30 on [Date], some
54
- users were unable to complete order payments."]
55
-
56
- ---
57
-
58
- ### 2. Root Cause
59
-
60
- [Simple explanation, no code references.
61
- Example: "Due to a system update failing to correctly handle
62
- slow connections with the payment gateway."]
63
-
64
- ---
65
-
66
- ### 3. Resolution
67
-
68
- [Steps taken by the technical team.
69
- Example: "Updated the timeout handling mechanism and deployed
70
- the fix at 16:00 on [Date]."]
71
-
72
- ---
73
-
74
- ### 4. Data Impact
75
-
76
- - Was existing data affected? [Yes / No]
77
- - Data recovery status: [Update script run / Not necessary]
78
-
79
- ---
80
-
81
- ### 5. Expected Behavior
82
-
83
- [Actions the customer should take to verify normal operation.
84
- Example: "Customers can now attempt payment normally.
85
- If problems persist, please contact our support hotline..."]
86
- ```
87
-
88
- ---
89
-
90
- ## Writing Rules
91
-
92
- - ✅ Simple language, avoid technical jargon
93
- - ✅ Honest about scope and duration of impact
94
- - ✅ Focus on **user impact**, not code details
95
- - ✅ Always include instructions for the customer to verify the fix
96
- - ❌ Do not blame third parties unless certain
97
- - ❌ Do not commit to specific deadlines unless certain
98
-
99
- Present clearly and professionally, in the language determined above.
1
+ ---
2
+ name: report-customer
3
+ description: Write an incident report for customers or customer service after a production bug fix. Non-technical, easy-to-understand language.
4
+ keywords: report, incident, customer, customer service, CS
5
+ ---
6
+
7
+ # Report Customer (Incident Report)
8
+
9
+ ## When to use
10
+
11
+ - After fixing a bug that affects users/customers
12
+ - Customer Service needs a report explaining the cause to customers
13
+ - Need to document the incident for future reference
14
+
15
+ ---
16
+
17
+ ## Process
18
+
19
+ ### Step 1: Gather information
20
+
21
+ Collect from `investigate-bug` results or developer descriptions:
22
+ - Ticket ID and title
23
+ - Discovery time / impact duration
24
+ - Number of affected users / orders
25
+ - Identified root cause
26
+ - Deployment status
27
+
28
+ ### Step 2: Write the report
29
+
30
+ Fill in the structure below. **Use simple language, avoiding technical jargon.**
31
+
32
+ ---
33
+
34
+ ## Standard Structure
35
+
36
+ Output language: auto-detect from the ticket/task input — see `custom/rules/output-language.md`
37
+ (Vietnamese ticket → Vietnamese report; otherwise English). CS can request a specific language
38
+ explicitly, which overrides auto-detect. Structure below is shown in English.
39
+
40
+ ```markdown
41
+ ## 📋 Incident Verification Report
42
+
43
+ **Ticket ID:** [ID]
44
+ **Assigned to:** [Dev Name]
45
+ **Resolution Date:** [YYYY-MM-DD]
46
+ **Status:** ✅ Resolved / 🔄 In Progress
47
+
48
+ ---
49
+
50
+ ### 1. Summary
51
+
52
+ [1–2 sentences describing the issue in non-technical language.
53
+ Example: "Between 14:00–15:30 on [Date], some
54
+ users were unable to complete order payments."]
55
+
56
+ ---
57
+
58
+ ### 2. Root Cause
59
+
60
+ [Simple explanation, no code references.
61
+ Example: "Due to a system update failing to correctly handle
62
+ slow connections with the payment gateway."]
63
+
64
+ ---
65
+
66
+ ### 3. Resolution
67
+
68
+ [Steps taken by the technical team.
69
+ Example: "Updated the timeout handling mechanism and deployed
70
+ the fix at 16:00 on [Date]."]
71
+
72
+ ---
73
+
74
+ ### 4. Data Impact
75
+
76
+ - Was existing data affected? [Yes / No]
77
+ - Data recovery status: [Update script run / Not necessary]
78
+
79
+ ---
80
+
81
+ ### 5. Expected Behavior
82
+
83
+ [Actions the customer should take to verify normal operation.
84
+ Example: "Customers can now attempt payment normally.
85
+ If problems persist, please contact our support hotline..."]
86
+ ```
87
+
88
+ ---
89
+
90
+ ## Writing Rules
91
+
92
+ - ✅ Simple language, avoid technical jargon
93
+ - ✅ Honest about scope and duration of impact
94
+ - ✅ Focus on **user impact**, not code details
95
+ - ✅ Always include instructions for the customer to verify the fix
96
+ - ❌ Do not blame third parties unless certain
97
+ - ❌ Do not commit to specific deadlines unless certain
98
+
99
+ Present clearly and professionally, in the language determined above.
@@ -18,7 +18,9 @@ Sync test cases (từ TC file `.md`) với Playwright spec files, sử dụng **
18
18
  - `tcFile`: path đến TC file markdown (vd `testcases/AD10.md`)
19
19
  - `repo`: tên repo (vd `repo-fe`)
20
20
  - `screenId`: mã màn hình, always lowercase (vd `ad10`, not `AD10`) — directory paths use lowercase; spec file name `{ScreenID}.spec.ts` remains uppercase
21
+ - `featureDir`: `{ScreenID}_{Screen-Name-kebab-case}` (vd `AD10_create-product`)
21
22
  - `baseUrl`: URL của app để Playwright MCP snapshot
23
+ - `scriptsRoot`: `AK-Docs/03.Testing/05.Scripts/{repo}/` — script + Page Object sinh ra nằm ở đây, `Shared/evidence-helper.ts` nằm ở `AK-Docs/03.Testing/05.Scripts/Shared/`
22
24
 
23
25
  ---
24
26
 
@@ -39,7 +41,7 @@ Không tính vào hash: `Severity`, `Pre-condition`, `Data Test`, `Ticket ID`, `
39
41
 
40
42
  ## Spec File Structure
41
43
 
42
- Mỗi TC trong spec file có metadata comment ngay trước `test()`:
44
+ Mỗi TC trong spec file có metadata comment ngay trước `test()`. File nằm ở `AK-Docs/03.Testing/05.Scripts/{repo}/{featureDir}/{ScreenID}.spec.ts`:
43
45
 
44
46
  ```typescript
45
47
  // @screen-id: AD10
@@ -48,20 +50,25 @@ Mỗi TC trong spec file có metadata comment ngay trước `test()`:
48
50
  // @screen-url: /admin/products/create
49
51
  // @generated: YYYY-MM-DD
50
52
 
51
- import { test, expect } from '../../shared/fixtures/test'
53
+ import { test, expect } from '../../Shared/fixtures/test'
54
+ import { captureStepEvidence } from '../../Shared/evidence-helper'
52
55
  import { AD10Page } from '../pages/AD10Page'
53
56
 
54
57
  test.describe('AD10 - Create Product', () => {
55
58
 
56
59
  // @tc-hash: a3f9b2c1
57
60
  // @tc-id: AD10_001
58
- test('AD10_001 - Truy cập trực tiếp qua URL khi chưa đăng nhập', async ({ page }) => {
61
+ test('AD10_001 - Truy cập trực tiếp qua URL khi chưa đăng nhập', async ({ page }, testInfo) => {
62
+ const pageObj = new AD10Page(page)
59
63
  // ...
64
+ // xem "Assertion Rules" + "Evidence Capture per Step" bên dưới — mỗi step UI trong TC
65
+ // phải gọi captureStepEvidence(page, testInfo, N, 'desc', {...}) và assertion phải khẳng
66
+ // định đúng nội dung Expected Result, không chỉ kiểm tra element tồn tại.
60
67
  })
61
68
 
62
69
  // @tc-hash: d7e2f4a9
63
70
  // @tc-id: AD10_002
64
- test('AD10_002 - Truy cập trực tiếp qua URL khi đã đăng nhập', async ({ page }) => {
71
+ test('AD10_002 - Truy cập trực tiếp qua URL khi đã đăng nhập', async ({ page }, testInfo) => {
65
72
  // ...
66
73
  })
67
74
 
@@ -84,7 +91,7 @@ Nhận diện **Manual TCs** — các TC không thể automation:
84
91
 
85
92
  ### Bước 2: Scan spec file hiện tại
86
93
 
87
- Tìm `ak-test/{repo}/scripts/{screenId}/{ScreenID}.spec.ts`.
94
+ Tìm `AK-Docs/03.Testing/05.Scripts/{repo}/{featureDir}/{ScreenID}.spec.ts` (`scriptsRoot` từ input + `{featureDir}/{ScreenID}.spec.ts`).
88
95
 
89
96
  Nếu tồn tại: đọc file, extract tất cả cặp `@tc-hash` + `@tc-id` bằng regex:
90
97
  ```
@@ -114,25 +121,40 @@ Với mỗi TC cần gen mới:
114
121
  - `mcp__playwright__browser_navigate` → `baseUrl + screenUrl`
115
122
  - `mcp__playwright__browser_snapshot` → lấy accessibility tree
116
123
  - Với từng element trong Steps: `mcp__playwright__browser_generate_locator`
117
- 3. Sinh test block với metadata comments:
124
+ - Nếu locator match **nhiều hơn 1 element** trên snapshot → không dùng locator đó, tìm locator scope hẹp hơn (trong đúng container/row/modal) hoặc dùng `data-testid` cụ thể. Xem "Assertion Rules" — locator mơ hồ là nguyên nhân chính gây false pass/fail.
125
+ 3. Sinh test block với metadata comments — **mỗi Step trong TC file map 1:1 với 1 action + 1 evidence capture**, assertion cuối phải khẳng định đúng nội dung Expected Result:
118
126
 
119
127
  ```typescript
120
128
  // @tc-hash: {hash}
121
129
  // @tc-id: {TC_ID}
122
- test('{TC_ID} - {Test Case Name}', async ({ page }) => {
130
+ test('{TC_ID} - {Test Case Name}', async ({ page }, testInfo) => {
123
131
  const pageObj = new {ScreenID}Page(page)
124
- // Step 1: {step text}
132
+
133
+ // Step 1: {step text — vd "Trên màn hình danh sách, click item A để mở A1"}
125
134
  await pageObj.{action}()
126
- // Step 2: {step text}
135
+ await captureStepEvidence(page, testInfo, 1, '{step-1-desc}', { highlightSelector: pageObj.itemALocator })
136
+
137
+ // Step 2: {step text — vd "Trên A1, click button B để mở modal B1"}
127
138
  await pageObj.{action}()
128
- // Expected: {expected result}
129
- await expect(page.{locator}).{assertion}
139
+ await captureStepEvidence(page, testInfo, 2, '{step-2-desc}', { highlightSelector: pageObj.buttonBLocator })
140
+
141
+ // Step 3 (nếu step mở popup/modal): chờ modal hiện + settle rồi mới chụp + assert
142
+ await expect(pageObj.modalB1Locator).toBeVisible()
143
+ await captureStepEvidence(page, testInfo, 3, '{step-3-desc}', {
144
+ highlightSelector: pageObj.confirmFieldLocator, // đúng vùng cần confirm theo Expected Result
145
+ scrollSelector: pageObj.confirmFieldLocator, // nếu modal có scroll
146
+ })
147
+
148
+ // Expected: {expected result — assertion PHẢI check đúng nội dung, không chỉ tồn tại}
149
+ await expect(pageObj.confirmFieldLocator).toHaveText('{expected text từ TC file}')
130
150
  })
131
151
  ```
132
152
 
153
+ > Nếu TC chỉ có 1 step / không mở modal mới, vẫn gọi `captureStepEvidence` ít nhất 1 lần ở trạng thái cuối (sau khi `waitForUiSettled`) — không bỏ qua evidence.
154
+
133
155
  4. Nếu spec file chưa tồn tại: tạo file mới với file header + describe wrapper + test block.
134
156
  5. Nếu spec file đã tồn tại: append test block vào trước closing `})` của `test.describe`.
135
- 6. Nếu `{ScreenID}Page.ts` chưa tồn tại: tạo Page Object với locators cho các elements đã snapshot.
157
+ 6. Nếu `{ScreenID}Page.ts` chưa tồn tại: tạo Page Object với locators cho các elements đã snapshot — **đặt tên locator theo đúng item được mô tả trong Step** (vd `itemALocator`, `buttonBLocator`) để dùng lại cho `highlightSelector` ở bước capture evidence.
136
158
 
137
159
  **File header khi tạo spec mới:**
138
160
  ```typescript
@@ -142,7 +164,8 @@ Với mỗi TC cần gen mới:
142
164
  // @screen-url: {url path}
143
165
  // @generated: {YYYY-MM-DD}
144
166
 
145
- import { test, expect } from '../../shared/fixtures/test'
167
+ import { test, expect } from '../../Shared/fixtures/test'
168
+ import { captureStepEvidence } from '../../Shared/evidence-helper'
146
169
  import { {ScreenID}Page } from '../pages/{ScreenID}Page'
147
170
 
148
171
  test.describe('{ScreenID} - {Screen Name}', () => {
@@ -188,8 +211,8 @@ mcp__playwright__browser_close
188
211
  ⚠️ Manual: {N} TCs → {TC_IDs} (lý do)
189
212
  ❌ Blocked: {N} TCs → {TC_IDs} (lý do)
190
213
 
191
- → Script: ak-test/{repo}/scripts/{screenId}/{ScreenID}.spec.ts
192
- → Page Object: ak-test/{repo}/scripts/pages/{ScreenID}Page.ts
214
+ → Script: AK-Docs/03.Testing/05.Scripts/{repo}/{featureDir}/{ScreenID}.spec.ts
215
+ → Page Object: AK-Docs/03.Testing/05.Scripts/{repo}/pages/{ScreenID}Page.ts
193
216
  ```
194
217
 
195
218
  Trả về danh sách kết quả cho `execute-flow`:
@@ -199,10 +222,25 @@ Trả về danh sách kết quả cho `execute-flow`:
199
222
 
200
223
  ---
201
224
 
225
+ ## Assertion Rules (bắt buộc — tránh false pass/fail)
226
+
227
+ - ❌ **Không** dùng locator match nhiều hơn 1 element làm căn cứ assertion — verify qua `browser_snapshot` rằng locator chỉ trúng đúng 1 node trước khi dùng. Nếu snapshot cho thấy nhiều node giống nhau (list item, nhiều modal ẩn/hiện cùng lúc) → scope locator trong đúng container (`getByRole('dialog').getByText(...)`, `row.getByTestId(...)`) hoặc thêm `.filter({ hasText: ... })`.
228
+ - ❌ **Không** dùng `toBeVisible()`/`toBeAttached()` làm assertion duy nhất khi Expected Result mô tả **nội dung cụ thể** (text, giá trị, số lượng, trạng thái field) — phải dùng `toHaveText`/`toContainText`/`toHaveValue`/`toBeDisabled`/`toHaveCount` tương ứng.
229
+ - ❌ **Không** wrap action trong `try/catch` rồi để pass nếu catch nuốt lỗi mà không có assertion thay thế khẳng định behavior đúng.
230
+ - ✅ Với negative/validation TC (kỳ vọng lỗi, kỳ vọng bị chặn) → assertion phải khẳng định đúng **hành vi chặn** đó xảy ra (message lỗi đúng text, hoặc action bị disable, hoặc điều hướng không xảy ra) — không chỉ assert "trang không crash".
231
+ - ✅ Mỗi step có mô tả thay đổi UI trong TC Steps → phải có 1 lệnh gọi `captureStepEvidence(...)` tương ứng, đặt **ngay sau** `waitForUiSettled` implicit trong helper — xem "Evidence Capture per Step" dưới.
232
+
233
+ ## Evidence Capture per Step
234
+
235
+ - Import `captureStepEvidence`, `waitForUiSettled`, `highlightElement` từ `Shared/evidence-helper.ts` (không viết lại logic này trong từng spec).
236
+ - Nếu Step yêu cầu click để mở popup/modal → thực hiện click **trước**, chờ modal `toBeVisible()`, rồi mới `captureStepEvidence` cho step đó — không chụp step trước khi hành động mở modal xảy ra.
237
+ - Nếu vùng cần confirm nằm ngoài viewport (modal dài, table nhiều dòng) → truyền `scrollSelector` để helper tự `scrollIntoViewIfNeeded()` trước khi chụp.
238
+ - Truyền `highlightSelector` = đúng locator của item/nội dung mà Expected Result yêu cầu tester xác nhận — helper tự khoanh viền đỏ rồi remove sau khi chụp.
239
+
202
240
  ## Mandatory Rules
203
241
 
204
242
  - ❌ **Không bao giờ bịa selector** — phải dùng Playwright MCP snapshot
205
243
  - ❌ **Không overwrite** test block có hash match — skip hoàn toàn
206
244
  - ✅ Ưu tiên locator: `getByRole` > `getByLabel` > `getByPlaceholder` > `getByText` > `getByTestId` > CSS
207
- - ✅ Không tạo lại `BasePage.ts` / `fixtures/test.ts` nếu đã tồn tại
245
+ - ✅ Không tạo lại `BasePage.ts` / `fixtures/test.ts` / `evidence-helper.ts` nếu đã tồn tại
208
246
  - ✅ Test names/comments theo ngôn ngữ của TC input (xem `custom/rules/output-language.md`) — TC tiếng Việt → tiếng Việt, TC tiếng Anh → tiếng Anh
@@ -1,72 +1,5 @@
1
- # NestJS AI System Prompt
2
-
3
- You are an expert NestJS developer. Follow these modular architecture rules and best practices.
4
-
5
- ---
6
-
7
- ## Project Architecture
8
-
9
- NestJS follows a strict **Module-based** architecture. Every feature should be contained in its own module.
10
-
11
- ```
12
- src/
13
- ├── app.module.ts
14
- ├── main.ts
15
- └── features/
16
- └── [feature-name]/
17
- ├── [feature].module.ts
18
- ├── [feature].controller.ts
19
- ├── [feature].service.ts
20
- ├── [feature].entity.ts (if using TypeORM)
21
- └── dto/
22
- ├── create-[feature].dto.ts
23
- └── update-[feature].dto.ts
24
- ```
25
-
26
- ---
27
-
28
- ## NestJS Rules
29
-
30
- - Use **Constructor Injection** for all dependencies.
31
- - Always use **DTOs** (Data Transfer Objects) with `class-validator` for input validation.
32
- - Annotate controllers with `@Controller()`.
33
- - Use `@Injectable()` for services.
34
- - Leverage **Pipes** for data transformation and validation.
35
- - Leverage **Interceptors** for logging and response mapping.
36
-
37
- ```typescript
38
- // ✅ Good: DTO with validation
39
- export class CreateUserDto {
40
- @IsEmail()
41
- email: string;
42
-
43
- @IsString()
44
- @MinLength(8)
45
- password: string;
46
- }
47
- ```
48
-
49
- ---
50
-
51
- ## Testing Rules
52
-
53
- - Use the built-in **Jest** testing suite.
54
- - Use `Test.createTestingModule` to create isolated environments for unit tests.
55
-
56
- ```typescript
57
- describe('UsersService', () => {
58
- let service: UsersService;
59
-
60
- beforeEach(async () => {
61
- const module: TestingModule = await Test.createTestingModule({
62
- providers: [UsersService],
63
- }).compile();
64
-
65
- service = module.get<UsersService>(UsersService);
66
- });
67
-
68
- it('should be defined', () => {
69
- expect(service).toBeDefined();
70
- });
71
- });
72
- ```
1
+ # NestJS AI System Prompt
2
+
3
+ You are an expert NestJS developer. Follow these modular architecture rules and best practices.
4
+
5
+ > **Rules & code examples:** Read `.rules/javascript/nestjs-rules.md` (architecture, module rules, testing) and `.rules/javascript/nestjs-examples.md` (code samples per rule area) **in full** before writing or modifying any NestJS code in this project.