@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,224 +1,5 @@
1
- # Spring Boot AI System Prompt
2
-
3
- You are an expert Java Spring Boot developer. Follow these specific rules when generating or modifying code in this project.
4
-
5
- > **Code examples:** See `.rules/java/spring-boot-examples.md` read it when generating code for a specific layer.
6
-
7
- ---
8
-
9
- ## Project Stack
10
-
11
- - **Java:** 17+
12
- - **Spring Boot:** 3.x
13
- - **Build Tool:** Maven (prefer) or Gradle
14
- - **ORM:** Spring Data JPA + Hibernate
15
- - **Database:** MySQL / PostgreSQL
16
- - **Testing:** JUnit 5 + Mockito + AssertJ
17
- - **Utilities:** Lombok, MapStruct
18
- - **API Style:** RESTful JSON
19
-
20
- ---
21
-
22
- ## Architecture
23
-
24
- Follow strict **Layered Architecture**:
25
-
26
- ```
27
- Controller (HTTP layer)
28
-
29
- Service (Business logic)
30
-
31
- Repository (Data access - Spring Data JPA)
32
-
33
- Entity / Domain Model
34
- ```
35
-
36
- ### Package Structure
37
-
38
- ```
39
- com.company.project/
40
- ├── controller/ # \@RestController — HTTP endpoints only
41
- ├── service/
42
- │ ├── impl/ # \@Service — business logic implementation
43
- │ └── [Interface].java
44
- ├── repository/ # \@Repository — extends JpaRepository
45
- ├── entity/ # \@Entity — JPA entities
46
- ├── dto/
47
- │ ├── request/ # Input DTOs (e.g. CreateUserRequest)
48
- │ └── response/ # Output DTOs (e.g. UserResponse)
49
- ├── mapper/ # MapStruct mappers (Entity ↔ DTO)
50
- ├── exception/
51
- │ ├── GlobalExceptionHandler.java # \@RestControllerAdvice
52
- │ └── [CustomException].java
53
- ├── config/ # \@Configuration classes
54
- └── util/ # Pure utility helpers (stateless)
55
- ```
56
-
57
- ---
58
-
59
- ## Controller Rules
60
-
61
- - Annotate with `\@RestController` + `\@RequestMapping`
62
- - **Only** handle HTTP concerns: parse request, call service, return response
63
- - Never put business logic in Controller
64
- - Always use DTOs — never expose Entity directly
65
- - Use `ResponseEntity<T>` for explicit HTTP status control
66
- - Validate input with `\@Valid` + Bean Validation annotations
67
-
68
- ---
69
-
70
- ## Service Rules
71
-
72
- - Always define an **interface**, implement in the `impl/` package
73
- - Annotate implementation with `\@Service`
74
- - All business logic lives here
75
- - Use `\@Transactional` at the method level (not class level)
76
- - Throw specific custom exceptions, not generic `RuntimeException`
77
- - Never return an Entity — always convert to DTO via Mapper
78
-
79
- ---
80
-
81
- ## Repository Rules
82
-
83
- - Extend `JpaRepository<Entity, ID>`
84
- - Use **method name queries** for simple queries
85
- - Use `\@Query` (JPQL) for complex queries — avoid native SQL unless necessary
86
- - Never add business logic here
87
- - Use `\@EntityGraph` to solve N+1 problems
88
-
89
- ---
90
-
91
- ## Entity Rules
92
-
93
- - Use Lombok: `\@Getter`, `\@Setter`, `\@NoArgsConstructor`, `\@AllArgsConstructor`, `\@Builder`
94
- - Avoid `\@Data` on entities (causes issues with `equals/hashCode` + lazy loading)
95
- - Always use `\@Table(name = "snake_case_table_name")`
96
- - Use `\@Column(name = "snake_case_column_name")` explicitly
97
- - For soft delete: add `deleted` boolean + `deletedAt` timestamp
98
- - Extend `BaseEntity` for audit fields (`createdAt`, `updatedAt`)
99
-
100
- ---
101
-
102
- ## DTO Rules
103
-
104
- - Use separate DTOs for **Request** and **Response** — never share
105
- - Use Lombok: `\@Getter`, `\@Builder`, `\@AllArgsConstructor`, `\@NoArgsConstructor`
106
- - Validate in the Request DTO with Bean Validation (`\@NotBlank`, `\@Email`, `\@NotNull`, `\@Size`)
107
- - Never expose internal fields (password hash, audit timestamps) in the Response DTO
108
-
109
- ---
110
-
111
- ## MapStruct Mapper Rules
112
-
113
- - Use `\@Mapper(componentModel = "spring")` — inject as a Spring bean
114
- - Define explicit mappings with `\@Mapping` when field names differ
115
- - Never do manual mapping (`new DTO(); dto.setField(entity.getField())`)
116
-
117
- ---
118
-
119
- ## Exception Handling
120
-
121
- - Create custom exceptions extending `RuntimeException`
122
- - Handle all exceptions in one `\@RestControllerAdvice` class
123
- - Return a consistent error response format
124
- - Never expose stack traces to the client
125
-
126
- ---
127
-
128
- ## Testing Rules
129
-
130
- ### Unit Tests (Service layer)
131
- - Test class: `[ServiceImpl]Test.java`
132
- - Mock all dependencies with `\@ExtendWith(MockitoExtension.class)` + `\@Mock`
133
- - Test happy path + edge cases + exception scenarios
134
- - Use AssertJ: `assertThat(result).isEqualTo(expected)`
135
-
136
- ### Integration Tests (Controller layer)
137
- - Use `\@SpringBootTest` + `\@AutoConfigureMockMvc`
138
- - Test full HTTP flow with `MockMvc`
139
- - Use `\@Sql` or Testcontainers for database state
140
-
141
- ---
142
-
143
- ## Naming Conventions
144
-
145
- | Element | Convention | Example |
146
- |---------|-----------|---------|
147
- | Class | PascalCase | `UserService`, `OrderController` |
148
- | Method | camelCase | `findById`, `createOrder` |
149
- | Variable | camelCase | `userResponse`, `orderId` |
150
- | Constant | UPPER_SNAKE_CASE | `MAX_RETRY_COUNT` |
151
- | Package | lowercase | `com.company.project.service` |
152
- | DB Table | snake_case | `user_orders`, `product_items` |
153
- | DB Column | snake_case | `created_at`, `user_id` |
154
- | REST endpoint | kebab-case | `/api/v1/user-profiles` |
155
- | Request DTO | `[Action][Resource]Request` | `CreateOrderRequest` |
156
- | Response DTO | `[Resource]Response` | `OrderResponse` |
157
-
158
- ---
159
-
160
- ## API Design
161
-
162
- - Version all APIs: `/api/v1/...`
163
- - Use plural nouns for resources: `/users`, `/orders`
164
- - HTTP methods: `GET` (read), `POST` (create), `PUT` (full update), `PATCH` (partial), `DELETE`
165
- - Return `201 Created` for POST, `200 OK` for GET/PUT/PATCH, `204 No Content` for DELETE
166
- - Use consistent pagination: `?page=0&size=20&sort=createdAt,desc`
167
-
168
- ```
169
- GET /api/v1/users → 200 list
170
- POST /api/v1/users → 201 created
171
- GET /api/v1/users/{id} → 200 or 404
172
- PUT /api/v1/users/{id} → 200 or 404
173
- DELETE /api/v1/users/{id} → 204 or 404
174
- GET /api/v1/users/{id}/orders → 200 nested resource
175
- ```
176
-
177
- ---
178
-
179
- ## Performance Rules
180
-
181
- - Always use pagination — never return unbounded lists
182
- - Avoid N+1: use `\@EntityGraph` or `JOIN FETCH` in JPQL
183
- - Add database indexes on frequently queried columns
184
- - Use `\@Transactional(readOnly = true)` on read-only service methods
185
- - For heavy read operations, consider projection interfaces
186
-
187
- ---
188
-
189
- ## Security Rules
190
-
191
- - Never log passwords, tokens, or sensitive PII
192
- - Hash passwords with BCrypt: `passwordEncoder.encode(rawPassword)`
193
- - Validate and sanitize all user inputs via Bean Validation
194
- - Use `\@PreAuthorize` for method-level security
195
- - Never return stack traces to API consumers
196
- - Store secrets in environment variables / Vault — never in code
197
-
198
- ---
199
-
200
- ## Logging Rules
201
-
202
- - Use SLF4J with Lombok `\@Slf4j`
203
- - `log.info` — normal business events
204
- - `log.warn` — recoverable issues (not found, validation fail)
205
- - `log.error` — unexpected exceptions (always include `ex` as the second argument)
206
- - Never log sensitive data (password, credit card, token)
207
-
208
- ---
209
-
210
- ## Common Anti-Patterns to Avoid
211
-
212
- - ❌ `\@Autowired` field injection → use constructor injection (Lombok `\@RequiredArgsConstructor`)
213
- - ❌ `\@Data` on JPA entities → use `\@Getter \@Setter` separately
214
- - ❌ Returning `Entity` directly from Controller → always use DTO
215
- - ❌ `SELECT *` or unbounded `findAll()` → always paginate
216
- - ❌ Business logic in Controller → move to Service
217
- - ❌ Catching and swallowing exceptions → handle properly or rethrow
218
- - ❌ `new RuntimeException("something")` → create a specific custom exception
219
- - ❌ Hardcoding config values → use `\@Value` or `\@ConfigurationProperties`
220
- - ❌ `\@Transactional` on Controller → only on Service methods
221
-
222
- ---
223
-
224
- When explaining changes, refer to the [Spring Boot Official Documentation](https://docs.spring.io/spring-boot/docs/current/reference/html/) and [Spring Data JPA](https://docs.spring.io/spring-data/jpa/docs/current/reference/html/) conventions.
1
+ # Spring Boot AI System Prompt
2
+
3
+ You are an expert Java Spring Boot developer. Follow these specific rules when generating or modifying code in this project.
4
+
5
+ > **Rules & code examples:** Read `.rules/java/spring-boot-rules.md` (architecture, layer rules, naming, security, anti-patterns) and `.rules/java/spring-boot-examples.md` (code samples per layer) **in full** before writing or modifying any Java code in this project.
@@ -7,17 +7,17 @@ Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
8
  ---
9
9
 
10
- ## [0.2.2] - 2026-08-06
10
+ ## [Unreleased]
11
11
 
12
- ### Added
12
+ ## [0.2.2] - 2026-08-24
13
13
 
14
- - **`ak gate <n> skip --ticket <id> [--reason <text>]`** — a gate can now close as "skipped" (legitimately produced no deliverable) instead of only `start`/`approved`. First consumer: `ingest-data` Gate 3, when the AI decides the ingested content is reference-only and no task list is needed — it now runs `ak gate 3 skip` instead of leaving the gate untouched. `scripts/task.js`'s `updateTaskGateState()` gained a `skip` branch that records `skippedGates[gate] = {at, reason}` in `task-state.json` and advances `currentGate` exactly like `approved` does, so every existing "is this task done" check (which only ever inspects `currentGate`) keeps working with zero changes. Prompted by an impact assessment for the `ai-flow-ex` VS Code extension's dashboard, which was showing skipped-Gate-3 ingest-data tasks stuck as "ready to run Gate 3" forever — see `docs/superpowers/specs/2026-08-06-ingest-data-gate3-skipped-state-design.md` in `ai-flow-ex` for the paired UI-side change (reads `skippedGates` to render a distinct "⏭ Skipped" badge instead of the generic "✓ Approved").
14
+ ### Changed
15
15
 
16
- ### Fixed
16
+ - **`execute-test` flow (`execute-flow` + `script-sync` skills) no longer uses an `ak-test/` working dir at all — everything, including binary evidence, now lives inside `AK-Docs/03.Testing/`.** Previously the whole flow (Playwright scripts, per-TC `result.md`, bug drafts, `testreport.md`, and evidence) lived under `ak-test/{repo}/`, outside the project's docs tree — reports/bugs/scripts had no place in version control alongside the rest of `AK-Docs/03.Testing/` (Testcases, Reports, Bugs). New mapping: `05.Scripts/{repo}/{featureDir}/{ScreenID}.spec.ts` (Gate 2), `04.Evidence/{repo}/{featureDir}/run-{N}/` (Gate 3, screenshots/video/`trace.zip`/raw `results.json`), `02.Reports/{repo}/{featureDir}/run-{N}/{result.md, testreport.md}` (Gate 3/4), `06.Bugs/{repo}/{featureDir}/run-{N}/BUG-NNN-*.md` (Gate 3) — this restores `docs/common/Testing-Structure.md`'s original Gate 3 → `04.Evidence/` mapping instead of diverging from it (an earlier iteration of this change had evidence live in `ak-test/` to keep binaries out of AK-Docs entirely; superseded before release in favor of `.gitignore`). `05.Scripts/` is a self-contained, runnable Playwright project (`package.json`/`node_modules`/`tsconfig.json`) living inside AK-Docs — Gate 1 auto-scaffolds it and appends `03.Testing/04.Evidence/` plus `03.Testing/05.Scripts/**/{node_modules,test-results,playwright-report,blob-report}` to `.gitignore` if missing, so the binary evidence and Playwright build artifacts never get committed even though they're colocated with the rest of the docs tree. `playwright.config.ts`'s `outputDir`/JSON reporter path read `EVIDENCE_DIR` (set by the AI per run to the `04.Evidence/` path, a simple 1-level-up relative path from `05.Scripts/` since both now live under the same `03.Testing/` parent) so each run gets its own evidence folder.
17
17
 
18
- - **`ak task next` treated `ingest-data` as a 2-gate flow** a stale assumption left over from before Gate 3 (task creation & ticket generation) was added to `ingest-data` earlier in the same release cycle. `scripts/task.js` grouped it with `gen-doc`/`create-system-requirement` (`maxGate = 2`), so pausing via `ak task next` on Gate 2 would prematurely mark the task `status: 'done'` and `gateLabel(3, 'ingest-data')` returned `'Done'` instead of `'Sinh Task & Tạo Ticket'`. Split into its own 3-gate branch (`maxGate = 3`); `gen-doc`/`create-system-requirement` are unaffected.
18
+ - **`execute-flow`/`script-sync` gained explicit DOM-assertion and evidence-quality rules** to fix reported false pass/fail results and low-quality screenshots: locators that match more than one element are now called out as the primary root cause of mis-graded TCs (fix: scope to the right container or use `data-testid`, not `.first()`/broad CSS); assertions must check the actual Expected Result content (`toHaveText`/`toBeDisabled`/etc.), not just element presence; negative/validation TCs need an assertion on the actual blocking behavior, not "page didn't crash." New shared helper `custom/skills/execute-flow/templates/evidence-helper.ts` (copied once to `AK-Docs/03.Testing/05.Scripts/Shared/`) provides `waitForUiSettled()` (networkidle + no loading indicator + fonts ready fixes screenshots taken mid-spinner), `highlightElement()`/`removeHighlight()` (red 3px outline around the item to confirm), and `captureStepEvidence()`/`openAndCapture()` (per-TC-Step screenshot, click-to-open-modal before capturing, `scrollIntoViewIfNeeded()` for scrollable content) every generated spec must use these instead of ad-hoc screenshot calls. `playwright.config.ts` template gained `deviceScaleFactor: 2` and a configurable `locale` (default `ja-JP`) for sharper, correctly-rendered Kanji/Katakana text in evidence, plus 1 retry to absorb timing flakes before a TC is reported FAIL.
19
19
 
20
- ## [0.2.1] - 2026-08-05
20
+ ## [0.2.1] - 2026-08-17
21
21
 
22
22
  ### Added
23
23
 
@@ -30,6 +30,24 @@ Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
30
30
  - Approved tickets get their link written back into the originating `Meetings-Log`/`QnA-Log`/`Confirmations-Log` entry (`→ Tasks created: TICKET-101 (coding), ...`), keeping the traceability chain from PM Workflow §6 intact end-to-end.
31
31
  - **Still open, tracked in the PM Workflow doc's Vấn đề 5 implementation note:** no fixed feedback→task-type rule table (AI still judges per-context); new tickets don't auto-attach `functionId`/labels (Dev/BA/QA still assign on `ak use TICKET-XXX`); Backlog issueType/priority default to the project's first issueType and a "Normal"-named priority unless overridden explicitly in the task JSON.
32
32
 
33
+ - **`ak gate <n> skip --ticket <id> [--reason <text>]`** — a gate can now close as "skipped" (legitimately produced no deliverable) instead of only `start`/`approved`. First consumer: `ingest-data` Gate 3, when the AI decides the ingested content is reference-only and no task list is needed — it now runs `ak gate 3 skip` instead of leaving the gate untouched. `scripts/task.js`'s `updateTaskGateState()` gained a `skip` branch that records `skippedGates[gate] = {at, reason}` in `task-state.json` and advances `currentGate` exactly like `approved` does, so every existing "is this task done" check (which only ever inspects `currentGate`) keeps working with zero changes. Prompted by an impact assessment for the `ai-flow-ex` VS Code extension's dashboard, which was showing skipped-Gate-3 ingest-data tasks stuck as "ready to run Gate 3" forever — see `docs/superpowers/specs/2026-08-06-ingest-data-gate3-skipped-state-design.md` in `ai-flow-ex` for the paired UI-side change (reads `skippedGates` to render a distinct "⏭ Skipped" badge instead of the generic "✓ Approved").
34
+
35
+ ### Changed
36
+
37
+ - **Per-framework rule sections (Architecture, layer rules, naming, security, anti-patterns) moved out of `CLAUDE.md`/`AGENTS.md` into `.rules/<lang>/<framework>-rules.md`, alongside the existing `-examples.md`.** Extends the same on-demand `.rules/` pattern already used for code samples to the rules themselves: `custom/templates/<framework>.md` now holds only the title, a one-line intro, and a single "> **Rules & code examples:**" pointer to both files — everything else (Controller/Service/Repository/Entity/DTO/Mapper/Exception/Testing/Naming/API/Performance/Security/Logging/anti-patterns, per framework) lives in the new `-rules.md` file. Applied to all 9 templates that had this structure (`spring-boot`, `php`, `php-plain`, `reactjs`, `nestjs`, `nodejs-express`, `python`, `python-django`, `python-fastapi`, `python-ml`) — `nextjs`/`vue-nuxt`/`laravel` were already ~15 lines with no such structure and are untouched. Unlike the workflow-file pointer (read once at a clear Gate-start trigger), these rules apply continuously across every code edit in Gate 3, so `custom/templates/shared/gate-workflow.md` and `ml-gate-workflow.md` both gained an explicit bullet at the top of their Gate 3 (`Code Generation` / `Implement, Train & Iterate`) step: read the rules + examples files pointed to at the top of `CLAUDE.md`/`AGENTS.md` before the first line of code, and keep applying them to every subsequent edit, not just the first. Also fixed `generateSkillNameList()`'s "Codex indexes these automatically" wording, which became inaccurate once `claude` also uses the compact skill list (see previous entry) — reworded to name neither tool specifically. Measured on the kit's own dogfood skill set: solo `spring-boot`/`reactjs`/`php` 247/211/~205 → **41 lines each**; multi `spring-boot`+`php` 385 → **55 lines**.
38
+
39
+ - **`CLAUDE.md` now uses the same compact skill list as `AGENTS.md`, and 2 techstack templates dropped a redundant "Project Stack" section.** `AI_TOOL_SKILL_LIST_STYLE` gained `'claude': 'compact'` — Claude Code auto-discovers each skill's name + description from `.claude/skills/*/SKILL.md` frontmatter on its own (same mechanism the original Codex-only rationale assumed only Codex had), so restating the full description table in `CLAUDE.md` was duplicating information the tool already surfaces natively. `custom/templates/spring-boot.md` and `reactjs.md` also dropped their "## Project Stack" bullet list (Java/Spring Boot/Maven version pins, React/TypeScript/Vite/Router/etc.) — for spring-boot every item was already restated in a more specific rule section further down (Testing Rules, Entity Rules, Mapper Rules...); for reactjs most items were too (State Management, Form, Styling, API Layer Rules), except **Router (React Router v6), the shadcn/ui pairing with Tailwind, and Vitest as the specific test runner**, which had no other home in the file and are now gone rather than relocated — worth restoring into an existing rule section later if that specificity is missed. Measured on the kit's own dogfood skill set (~46 skills): solo `spring-boot` 306 → 247 lines, solo `reactjs` ~264 → 211 lines, multi `spring-boot`+`php` 444 → 385 lines.
40
+
41
+ - **`CLAUDE.md` now uses the pointer layout too, not just `AGENTS.md`.** `AI_TOOL_LAYOUT` in `scripts/init.js` gained `'claude': 'pointer'` alongside the existing `'codex': 'pointer'` — CLAUDE.md is loaded in full at the start of every session regardless of which gate (if any) is active, so inlining the ~115 KB DEV/TESTER/EXECUTE/gen-doc/ingest-data + BA + QA workflow set spent context on gates most sessions never touch. The workflow bodies now live in `.aiflow/instructions/` and CLAUDE.md just links to them, same as Codex. Unlike Codex's pointer layout, the skill registry keeps its full description table for `claude` (`resolveSkillListStyle()`/`resolveSkillsRoot()`) — Claude Code has no skill index of its own the way Codex does, so only the workflow bodies move out, not the registry.
42
+ - **Techstack rule templates (`custom/templates/<framework>.md`) no longer inline full code samples for every layer.** Following the pattern already used for `spring-boot.md`/`custom/rules/java/spring-boot-examples.md`, the same split was applied to the other 9 templates that had grown a "✅ Good / ❌ Bad" code block per rule area: `reactjs`, `php`, `php-plain`, `python-ml`, `nestjs`, `nodejs-express`, `python`, `python-django`, `python-fastapi`. Each template keeps its bullet rules, naming table, and anti-pattern list, with a one-line pointer to a new `custom/rules/<lang>/<framework>-examples.md` file holding the actual code samples — read on demand when generating code for that specific layer instead of being inlined into every session's context. `FRAMEWORK_LANGUAGE` in `scripts/init.js` also gained entries for `nodejs-express`, `python`, `python-django`, `python-fastapi`, and `php-plain` (previously missing, so `.rules/<lang>/` was never copied into projects using those frameworks).
43
+ - **Multi-framework projects no longer duplicate the tool header, skill registry, and workflow-files pointer once per framework.** A project with 2+ frameworks (e.g. a `spring-boot` backend + a `reactjs` frontend) calls `setupFramework()` once per framework with `multi: true`; each call used to emit a fully self-contained block (tool header + full skill registry + framework rules + "Installed workflow files" pointer note), so all three non-framework-specific sections got repeated verbatim per framework — the ~46-skill registry was the dominant cost in `CLAUDE.md` once the per-framework code samples above were split out. `setupFramework()` now builds all three via `buildSharedBlock()` once and writes it under its own fixed `<!-- aiflow-kit-start:shared -->` marker; per-framework blocks (`buildToolBlock(tool, ..., { includeShared: false })`) carry only the framework-specific rules and (for inline tools) the inlined gate-workflow body. The "Installed workflow files" note moved to the shared block because its 3 listed paths (`.aiflow/instructions/gate-workflow.md`, `create-spec-workflow.md`, `create-testcase-workflow.md`) are always the same 3 filenames regardless of framework — only their on-disk *content* varies per framework (e.g. ML vs standard gate workflow), not the pointer text itself. Re-running for an already-present framework upserts its block in place (new `upsertMarkerBlock()` helper) instead of appending another copy. Single-framework projects are unaffected (`includeShared` defaults to `true`, same single block as before). Measured on the kit's own dogfood project (spring-boot + php, ~46 real skills): 452 → 444 lines.
44
+
45
+ - **QnA-Log table (`skill-ba-qna-template-v1.md`) gained 3 response-tracking columns — Người trả lời, Ngày trả lời, Nguồn.** `skill-ba-qna-v1.md`'s Bước 4 now spells out how each is filled: **Người trả lời** defaults to `git config user.email` (fallback `user.name`) of whoever is running the session, overridden only when the BA explicitly names a different responder (e.g. answering on the customer's behalf); **Ngày trả lời** is stamped automatically from the current system date (`dd/mm/yyyy`), never asked; **Nguồn** is always BA-entered manually (e.g. "Khách hàng", "Nội bộ team", "Team Marketing") with no default or inference. Questions still **Open** leave all three columns blank (`—`). Checklist gained a matching item to catch missing values on **Confirmed** rows.
46
+
47
+ ### Fixed
48
+
49
+ - **`ak task next` treated `ingest-data` as a 2-gate flow** — a stale assumption left over from before Gate 3 (task creation & ticket generation) was added to `ingest-data` earlier in the same release cycle. `scripts/task.js` grouped it with `gen-doc`/`create-system-requirement` (`maxGate = 2`), so pausing via `ak task next` on Gate 2 would prematurely mark the task `status: 'done'` and `gateLabel(3, 'ingest-data')` returned `'Done'` instead of `'Sinh Task & Tạo Ticket'`. Split into its own 3-gate branch (`maxGate = 3`); `gen-doc`/`create-system-requirement` are unaffected.
50
+
33
51
  ## [0.2.0] - 2026-08-04
34
52
 
35
53
  ### Added
@@ -29,6 +29,7 @@
29
29
  | `99.Memory/` Project Brain — full design, scoring model, mem-id scheme, role/PM permissions | [Memory-Architecture-v1.0.md](./Memory-Architecture-v1.0.md) | v1.1 — Phase 1 (`draft/list/submit/remove`) is what's implemented today; later phases in this doc are roadmap, not shipped yet |
30
30
  | How updates to `AK-Docs`/`Shared-Docs` get reviewed — branch/Merge Request flow, who can merge to `main` | [Docs-Management-Flow.md](./Docs-Management-Flow.md) | Doc's own header says `Trạng thái: Draft — chờ PM review` — flag that when answering, don't present it as final policy |
31
31
  | PM/BrSE/Comtor — ingest a Backlog/Jira/SharePoint link or pasted text into `AK-Docs/01.QnA/` | [Project-Structure.md](./Project-Structure.md) (§ `01.QnA/`), `.claude/skills/ingest-data/SKILL.md` | `ak use` → taskType `ingest-data`, 2-gate flow (fetch/classify/draft → branch+MR). SharePoint link fetch is **not connected yet** — falls back to pasted text |
32
+ | Any role — how to read `System-Requirement_v{N}.md` (who reads which field, Classification/Implementation Reference/Tech Reference meaning), why it's separate from UC Spec, and how to review/approve it without reading code | [System-Requirement-Read-Guide.md](./System-Requirement-Read-Guide.md) | Field glossary + Classification state machine (Gap/Assumption/Decision/Deviation) + FAQ (why not merge with UC Spec, who writes it, when to update) + 6-step review checklist |
32
33
 
33
34
  ## Unanswered topics (do not invent — say so and stop here)
34
35
 
@@ -382,7 +382,7 @@ ak execute ./testcases/AD10.md # AI starts execute-flow with this TC file
382
382
  ak execute # AI asks: "TC file ở đâu?"
383
383
  ```
384
384
 
385
- Output lands in `ak-test/{repo}/results/{screenId}/run-{N}/` — never deleted between runs.
385
+ Evidence (screenshots/video/trace.zip) lands in `AK-Docs/03.Testing/04.Evidence/{repo}/{featureDir}/run-{N}/` — never deleted between runs. Scripts, result/report/bug docs live in `AK-Docs/03.Testing/` instead (05.Scripts / 02.Reports / 06.Bugs) so they're versioned with the rest of the project's docs, while binary evidence stays out of that git history.
386
386
 
387
387
  ### Figma Design → Code
388
388
 
@@ -0,0 +1,178 @@
1
+ # Hướng Dẫn Đọc System Requirement (mọi role)
2
+
3
+ > **Dành cho:** bất kỳ ai cần đọc một `System-Requirement_v{N}.md` — PM, Comtor, BrSE, Tester, Dev, Tech Lead. Mục tiêu của tài liệu này: giúp bạn biết **mình cần đọc phần nào**, đọc xong hiểu đúng, không cần đọc code hay đọc hết mọi dòng.
4
+ > **Tài liệu được đọc:** `AK-Docs/02.BA-Specs/00.Requirements/[functionId]/System-Requirement_v{N}.md`, sinh ra bởi task type **"📐 Create System Requirement"** — cầu nối giữa UC Spec (BA) và code (Dev).
5
+ > **Nếu bạn là người duyệt (approve)** tài liệu này, xem thêm Mục 5 (Checklist) — phần còn lại của guide vẫn áp dụng, checklist chỉ là bước cuối.
6
+
7
+ ---
8
+
9
+ ## 1. Ai đọc phần nào
10
+
11
+ Mỗi `System-Requirement_v{N}.md` đã có sẵn bảng này ngay ở đầu file (nói 1 lần, không lặp lại theo từng dòng). Nhắc lại ở đây để bạn không cần mở file mới nhớ ra:
12
+
13
+ | Field trong tài liệu | Ai cần đọc |
14
+ |---|---|
15
+ | `Requirement` | PM/BrSE/Comtor, Tester |
16
+ | `System Behavior` | Tester |
17
+ | `Error Response` | Tester (đầy đủ, gồm HTTP code) — PM/BrSE/Comtor chỉ cần câu thông báo hiển thị |
18
+ | `Traced UC Ref` / `Traced UC BR` / `Traced Exception Flow` | PM/BrSE/Comtor (đối chiếu UC Spec) |
19
+ | `Classification` | PM/BrSE/Comtor — dấu hiệu "cần quyết định" hoặc "đã chốt" |
20
+ | `Implementation Reference` / `Tech Reference` | Dev |
21
+ | Mục 5 (Acceptance Test Scenarios) | Tester |
22
+
23
+ **Dev và AI đọc toàn bộ tài liệu.** Nếu bạn là PM/Comtor/BrSE và thấy 1 dòng `Implementation Reference` mình không hiểu — đó là bình thường, **bỏ qua**, không phải bạn thiếu kiến thức.
24
+
25
+ ---
26
+
27
+ ## 2. Cách đọc 1 item (Requirement/System Behavior/Implementation Reference)
28
+
29
+ `System-Requirement_v{N}.md` được thiết kế theo 3 tầng, mỗi tầng cho 1 nhóm người đọc khác nhau trong **cùng một item**:
30
+
31
+ | Tầng | Viết bằng | Dành cho | Bạn cần đọc? |
32
+ |---|---|---|---|
33
+ | **Requirement** | Ngôn ngữ nghiệp vụ, không có tên class/method/framework | PM, Comtor, BrSE, **Tester** | ✅ Luôn đọc |
34
+ | **System Behavior** | Vẫn ngôn ngữ thường, mô tả điều kiện/thứ tự xử lý | BA, Tester | ✅ Luôn đọc |
35
+ | **Error Response** | HTTP code + message hiển thị cho end-user | Tester | ✅ Đọc nếu là Validation/Exception |
36
+ | **Implementation Reference / Tech Reference** | file:line, class, method, enum | Dev | ❌ **Bỏ qua được** — không phải Dev thì không cần đọc |
37
+
38
+ **Nguyên tắc:** nếu bạn phải đọc `Implementation Reference` để hiểu `Requirement` đang nói gì, đó là **lỗi của tài liệu** (leak kỹ thuật lên tầng nghiệp vụ) — báo lại cho Dev viết lại, không phải bạn thiếu kiến thức.
39
+
40
+ ---
41
+
42
+ ## 3. Giải thích về Classification
43
+
44
+ Mỗi item (FR/NFR/VR/ER) có thể mang 1 trong 4 nhãn `Classification`.
45
+
46
+ | Nhãn | Nghĩa | Ai tạo ra | Hành động bạn cần làm |
47
+ |---|---|---|---|
48
+ | **Gap** | UC Spec chưa có nội dung này | Dev, khi viết tài liệu | PM/BA phải trả lời. **Còn Gap chưa trả lời → tài liệu chưa được approve.** |
49
+ | **Assumption** | Dev suy đoán, chưa ai xác nhận | Dev | PM confirm → thành Decision. PM reject → quay lại Gap |
50
+ | **Decision** | Đã chốt, có ngày và người chốt | Sau khi PM trả lời | Chỉ đọc, không cần hành động |
51
+ | **Deviation** | Code hiện tại khác UC Spec | Dev, khi so sánh với code thật | BA/PM chọn: sửa code theo UC Spec, hoặc sửa UC Spec theo code |
52
+
53
+ ### Khi 1 item có nhiều quyết định — cách đọc
54
+
55
+ Trường hợp 1 item có **2+ quyết định** liên quan (ví dụ BA chốt 1 phần, Dev chốt phần còn lại). Ví dụ:
56
+
57
+ ```
58
+ Classification: Gap → Decision
59
+ - OQ-35 (BA): sử dụng mã lượt đặt hàng để xác định yêu cầu đặt hàng trùng và tránh tạo đơn nhiều lần.
60
+ - D-03 (Dev): nếu mã lượt đặt hàng đã được xử lý, không tạo đơn mới; trả về HTTP 400 kèm đơn đã tạo trước đó. Mã có hiệu lực trong 30 phút.
61
+ ```
62
+
63
+ Cách đọc: mỗi dòng là **1 mã số + ai chốt + nội dung ngắn**.
64
+ - `OQ-xx` = quyết định gốc do BA chốt, kế thừa từ UC Spec (thường trong lúc Q&A trước khi UC Spec được ký duyệt).
65
+ - `D-xx` = quyết định phát sinh riêng khi Dev soạn tài liệu System Requirement này (ví dụ: UC Spec chốt "phải chống trùng đơn" nhưng chưa viết rõ máy chủ trả gì — Dev phải tự chốt thêm chi tiết kỹ thuật đó, ghi lại thành D-xx để không tự quyết ngầm).
66
+
67
+ Nếu bạn không nhớ hoặc không đồng ý với 1 trong các quyết định đó, nêu lại ngay — đừng chờ tới khi ra sản phẩm.
68
+
69
+ ---
70
+
71
+ ## 4. Workflow trạng thái Classification
72
+
73
+ ```mermaid
74
+ %%{init: {'flowchart': {'curve': 'linear'}}}%%
75
+ flowchart TD
76
+ Start([Dev viết draft]) --> Gap[Gap]
77
+ Gap -->|"PM/BA trả lời chắc chắn"| Decision[Decision]
78
+ Gap -->|"PM/BA trả lời<br/>nhưng chưa chắc 100%"| Assumption[Assumption]
79
+ Assumption -->|"PM confirm đúng"| Decision
80
+ Assumption -->|"PM reject / cần hỏi lại"| Gap
81
+ Decision -->|"sau này Dev thấy<br/>code thực tế khác"| Deviation[Deviation]
82
+ Deviation -->|"PM chọn sửa code<br/>theo UC Spec (đã fix xong)"| Decision
83
+ Deviation -->|"PM chọn giữ code, sửa UC Spec<br/>(BA cập nhật UC Spec, tăng version mới)"| Decision
84
+ ```
85
+
86
+ **Rule:** tài liệu **không được approve** khi còn item ở trạng thái `Gap` chưa trả lời. `Assumption` được phép tồn tại tạm nếu PM đã xác nhận "tạm chấp nhận, sẽ chốt sau" — nhưng phải ghi rõ trong Mục 8 (Decision Log), không được im lặng bỏ qua.
87
+
88
+ ---
89
+
90
+ ## 5. Checklist Review (dành cho người duyệt — không cần đọc code)
91
+
92
+ Làm theo đúng thứ tự — dừng và reject ngay khi 1 bước fail.
93
+
94
+ ### Bước 1 — Đọc Executive Summary (30 giây)
95
+ - [ ] `Traceability coverage` = X/X? Thiếu → tài liệu chưa đầy đủ, trả lại Dev.
96
+ - [ ] `Action needed from PM` có danh sách → đây là Gap/Assumption bạn phải trả lời **trước**, ngay tại bước này.
97
+
98
+ ### Bước 2 — Khớp 1-1 với UC Spec (Mục 0 — Traceability Matrix)
99
+ - [ ] Mở UC Spec `v{N}` ghi ở header song song.
100
+ - [ ] Mỗi Main/Alternative/Exception Flow, mỗi Business Rule trong UC Spec → tìm đúng 1 dòng tương ứng trong Traceability Matrix.
101
+ - [ ] Thiếu dòng nào → **reject**.
102
+
103
+ ### Bước 3 — Đọc tầng Requirement (Mục 1–4)
104
+ - [ ] Chỉ đọc `Requirement` + `System Behavior` — bỏ qua `Implementation Reference`.
105
+ - [ ] Thấy tên class/method/framework lọt vào `Requirement`/`System Behavior` → **reject**, yêu cầu viết lại.
106
+ - [ ] Với Validation/Exception: `Error Response` phải giữ HTTP code + message hiển thị.
107
+
108
+ ### Bước 4 — Xử lý từng nhãn Classification
109
+ - [ ] `Gap`/`Assumption` → trả lời theo workflow ở Mục 4.
110
+ - [ ] `Deviation` → chọn rõ: sửa code hay sửa UC Spec — không để lơ lửng.
111
+ - [ ] `Decision` → chỉ xác nhận đúng là điều đã chốt; không nhớ đã chốt → hỏi lại, đừng mặc định đúng.
112
+
113
+ ### Bước 5 — Đối chiếu Mục 7 (Assumptions/Gaps/Decisions/Deviations)
114
+ - [ ] Mọi item có nhãn ở Mục 1–4 phải có dòng tương ứng ở Mục 7. Thiếu → reject.
115
+
116
+ ### Bước 6 — Quyết định
117
+ - [ ] Còn `Gap` chưa trả lời → **không approve**.
118
+ - [ ] Pass hết Bước 1–5 → gõ `APPROVED`.
119
+
120
+ ---
121
+
122
+ ## 6. Câu hỏi thường gặp (FAQ)
123
+
124
+ ### System Requirement để làm gì? Tôi có UC Spec rồi thì cần gì System Requirement nữa?
125
+
126
+ UC Spec và System Requirement trả lời 2 câu hỏi khác nhau:
127
+
128
+ - **UC Spec (BA viết)** trả lời: *"hệ thống PHẢI làm gì theo mong muốn của khách/nghiệp vụ?"* — viết **trước khi** biết chắc code hiện tại đang làm gì, không cần Dev tham gia để ký duyệt.
129
+ - **System Requirement (Dev viết, sau khi đọc UC Spec + mở code thật ra đối chiếu)** trả lời: *"code hiện tại đã làm đúng chưa? Còn thiếu gì? Có tình huống nào UC Spec không viết tới nhưng hệ thống vẫn phải xử lý?"*
130
+
131
+ Ví dụ thật trong tài liệu BUY074: UC Spec chỉ viết "chống bán vượt tồn kho", nhưng KHÔNG viết tới tình huống "2 khách đặt cùng 1 sản phẩm cùng lúc thì ai thắng, ai thua, giỏ của người thua xử lý sao, có bị deadlock không nếu đơn có nhiều sản phẩm giao nhau". Đây là những **Gap** mà chỉ khi Dev đọc code + tưởng tượng ra kịch bản thật mới phát hiện được — BA khi viết UC Spec không có đủ góc nhìn kỹ thuật để lường trước. System Requirement chính là nơi những Gap này được phát hiện, hỏi lại BA/PM, và ghi lại chốt là gì.
132
+
133
+ Nói ngắn: **UC Spec = ý định. System Requirement = ý định đó khi va vào code thật thì phải cụ thể hoá ra sao.**
134
+
135
+ ### Vì sao không gộp UC Spec và System Requirement thành 1 tài liệu, review 1 lần cho gọn?
136
+
137
+ 3 lý do:
138
+
139
+ 1. **Thời điểm ký duyệt khác nhau.** UC Spec phải được BA/PM ký duyệt **trước**, không cần chờ Dev có thời gian đọc hết code. Nếu gộp 2 tài liệu, UC Spec sẽ bị kẹt chờ Dev investigate code xong mới ký được — làm chậm cả quy trình dù bản chất nghiệp vụ đã rõ và có thể duyệt độc lập với chi tiết kỹ thuật.
140
+ 2. **Người review và tiêu chí review khác nhau.** Review UC Spec cần Dev đánh giá "khả thi kỹ thuật ở mức khái niệm" + Tester đánh giá "khả năng test được ở mức khái niệm". Review System Requirement cần Dev + Tester **đối chiếu từng dòng với UC Spec** (khác câu hỏi, khác độ chi tiết) — trộn 2 việc vào 1 lần review dễ khiến người review làm qua loa 1 trong 2, thay vì làm kỹ cả 2.
141
+ 3. **Traceability rõ ràng hơn khi tách riêng.** Mỗi `System-Requirement_v{N}` phải matching đúng 1 phiên bản UC Spec (`UC-Spec-Version` header) — nếu 2 tài liệu là một, việc UC Spec đổi version (do yêu cầu nghiệp vụ đổi) và System Requirement đổi version (do Dev phát hiện thêm case khi code) sẽ lẫn vào nhau, khó biết cái gì đổi vì lý do gì.
142
+
143
+ **Nhưng:** Dự án có thể linh hoạt sắp xếp gộp 1 buổi review chung cho 2 tài liệu này, trong trường hợp có thể output 2 tài liệu cùng nhau thay vì phải chờ 1 khoảng thời gian dài để Dev điều tra.
144
+
145
+ ### System Requirement có được phép thay đổi/thêm nội dung so với UC Spec không?
146
+
147
+ Không. System Requirement **không bao giờ bịa ra** nội dung mà UC Spec không có — mọi FR/VR/ER phải trace được về 1 dòng cụ thể trong UC Spec, hoặc được đánh dấu `Gap`/`Assumption`/`Deviation` và chờ PM/BA xác nhận. Nếu bạn thấy 1 `Requirement` mà không tìm được nguồn trong UC Spec, đó là lỗi — báo lại ngay (xem Bước 2/3 ở Mục 5).
148
+
149
+ ### Khi nào cần viết lại/update System Requirement?
150
+
151
+ Hai trường hợp: (1) UC Spec lên version mới (BA sửa yêu cầu) → System Requirement phải `RESYNC` theo version mới; (2) trong lúc code 1 ticket, Dev phát hiện 1 case UC Spec có viết nhưng System Requirement bỏ sót → được đề xuất bổ sung, ghi thêm 1 dòng ở Change Log (Mục 9), không cần tăng version vì UC Spec chưa đổi.
152
+
153
+ ### Mục 8 (Decision Log) chỉ có 1 dòng ngắn — thiếu thông tin à?
154
+
155
+ Không thiếu — chủ ý tránh viết trùng 2 nơi. Chi tiết đầy đủ đã nằm trong dòng `Classification` của item tương ứng ở Mục 1–4; Mục 8 chỉ là bảng tra cứu ngược (ID → ai chốt → ngày → 1 dòng tóm tắt).
156
+
157
+ ### Tôi không hiểu `Implementation Reference` ghi gì, có sao không?
158
+
159
+ Tuỳ role. Nếu bạn là **PM/BrSE/Comtor/Tester** — không sao, tầng đó không dành cho bạn (xem Mục 1, 2); nếu bạn *cần* hiểu nó để đánh giá đúng/sai của `Requirement`, đó là lỗi tài liệu — báo lại, đừng tự trách mình thiếu kiến thức.
160
+
161
+ Nếu bạn là **Dev** — **bắt buộc phải hiểu**, vì đây chính là field ghi cho bạn (file:line/class/method để code) và AI cũng dựa vào nó ở Gate 3 coding. Không hiểu được thì không phải lỗi của bạn cần bỏ qua, mà là dấu hiệu tài liệu viết thiếu rõ (ví dụ thiếu context, path sai, hoặc tham chiếu tới code không còn tồn tại) — cần hỏi lại người viết (Dev khác/AI) hoặc tự mở code kiểm tra trước khi bắt đầu implement, không được đoán.
162
+
163
+ ### `Tech Reference` trong Mục 6.2 (Glossary) khác gì `Implementation Reference`?
164
+
165
+ `Implementation Reference` nằm rải trong từng item, chỉ Dev cần. `Tech Reference` ở Mục 6.2 là **bảng tra cứu tập trung** — mỗi giá trị kỹ thuật (ví dụ enum `TagStatusEnum::PENDING`) map sang 1 ý nghĩa nghiệp vụ đã được PM xác nhận (`Decision`) hoặc chưa (`Assumption`). Dùng bảng này khi muốn biết "giá trị thô này nghĩa là gì với nghiệp vụ" mà không cần lục từng item.
166
+
167
+ ### Tài liệu này có thay UC Spec không?
168
+
169
+ Không. UC Spec là nguồn nghiệp vụ gốc (BA sign-off). System Requirement là bản dịch sang góc nhìn Dev + trace lại UC Spec.
170
+
171
+ ---
172
+
173
+ ## 7. Liên quan
174
+
175
+ - Skill sinh ra tài liệu này: `.claude/skills/create-system-requirement/SKILL.md`
176
+ - Template: `.claude/skills/create-system-requirement/system-requirement-template-v1.md`
177
+ - Cấu trúc thư mục `02.BA-Specs/`: [BA-Specs-Structure.md](./BA-Specs-Structure.md)
178
+ - Quy trình SDLC end-to-end (Checkpoint #2/#3, gộp thread review): `docs/internal/SDLC-Unified-Workflow_v1.0.md`
@@ -38,30 +38,34 @@
38
38
  │ ├── Users.csv
39
39
  │ └── Fixtures.sql
40
40
 
41
- ├── 04.Evidence/ # Gate 3: Screenshots, videos, logs per execution
42
- └── F-001_User-Login/
43
- ├── TICKET-100_2026-06-15/ # Ticket + date to identify execution round
44
- │ ├── TC_001_PASS/
45
- └── Screenshot.png
46
- └── TC_002_FAIL/
47
- ├── Screenshot.png
48
- └── Video.mp4
49
- └── TICKET-100_Retest_2026-06-18/
50
- │ └── TC_002_PASS/
51
- │ └── Screenshot.png
41
+ ├── 04.Evidence/ # ⚠️ MUST be in .gitignore binary (screenshots/video/trace.zip)
42
+ ├── F-001_User-Login/ # manual QA evidence (screenshots attached by hand)
43
+ │ └── TICKET-100_2026-06-15/ # Ticket + date to identify execution round
44
+ └── TC_003_PASS/
45
+ │ │ └── Screenshot.png
46
+ │ └── {repo}/{featureDir}/run-{N}/ # execute-test flow's AUTOMATION evidence (Gate 3)
47
+ │ ├── results.json # Playwright JSON output
48
+ │ └── {TC_ID}-{scenario}/
49
+ ├── step-NN-{desc}.png
50
+ │ └── trace.zip
52
51
 
53
- ├── 05.Scripts/ # Playwright automation (by Repo → Feature)
52
+ ├── 05.Scripts/ # Playwright automation — RUNNABLE project (by Repo → Feature)
53
+ │ ├── package.json # 1 install for the whole 05.Scripts tree
54
+ │ ├── tsconfig.json
55
+ │ ├── node_modules/ # gitignored — see Rules
56
+ │ ├── Shared/ # Fixtures, helpers, evidence-helper used across repos
57
+ │ │ ├── fixtures/test.ts
58
+ │ │ ├── BasePage.ts
59
+ │ │ └── evidence-helper.ts # waitForUiSettled / highlightElement / captureStepEvidence
54
60
  │ ├── Repo1/ # e.g. frontend app
55
- │ │ ├── playwright.config.ts # baseURL, browser config for this repo
61
+ │ │ ├── playwright.config.ts # baseURL, EVIDENCE_DIR-driven outputDir for this repo
62
+ │ │ ├── pages/LoginPage.ts
56
63
  │ │ └── F-001_User-Login/
57
64
  │ │ └── Login.spec.ts
58
- ├── Repo2/ # e.g. admin app
59
- ├── playwright.config.ts
60
- └── F-003_Admin-Panel/
61
- └── Admin.spec.ts
62
- │ └── Shared/ # Fixtures, helpers used across repos
63
- │ ├── Fixtures.ts
64
- │ └── Helpers.ts
65
+ └── Repo2/ # e.g. admin app
66
+ ├── playwright.config.ts
67
+ └── F-003_Admin-Panel/
68
+ └── Admin.spec.ts
65
69
 
66
70
  ├── 06.Bugs/ # Gate 3: Bug reports (AI draft on TC fail)
67
71
  │ └── F-001_User-Login/
@@ -109,9 +113,9 @@
109
113
  | Gate | Output | Folder |
110
114
  |---|---|---|
111
115
  | Gate 1 | Chuẩn bị & Lập kế hoạch thực thi | (Console output / Work Plan) |
112
- | Gate 2 | Đồng bộ kịch bản kiểm thử (Script Sync) | `05.Scripts/[Repo]/[Feature]/[Feature].spec.ts` |
113
- | Gate 3 | Thực thi test & Thu thập evidence | `04.Evidence/[Feature]/[Ticket]_[Date]/` & `06.Bugs/[Feature]/` |
114
- | Gate 4 | Báo cáo test & Log bug | `02.Reports/[Feature]/[Ticket]/Execution-Report.md` |
116
+ | Gate 2 | Đồng bộ kịch bản kiểm thử (Script Sync) | `05.Scripts/[Repo]/[Feature]/[Feature].spec.ts` (project chạy được tại chỗ — có `package.json`/`node_modules`) |
117
+ | Gate 3 | Thực thi test & Thu thập evidence | Binary evidence (screenshot/video/`trace.zip`) → `04.Evidence/[Repo]/[Feature]/run-{N}/` (gitignored, xem Rules) & bug reports (text) → `06.Bugs/[Repo]/[Feature]/run-{N}/` |
118
+ | Gate 4 | Báo cáo test & Log bug | `02.Reports/[Repo]/[Feature]/run-{N}/testreport.md` |
115
119
 
116
120
  ---
117
121
 
@@ -119,6 +123,8 @@
119
123
 
120
124
  - Không tự sửa template — template nằm trong shared repo riêng
121
125
  - Lưu testcase và kết quả lên GitLab **sau khi Gate 4 được APPROVED**
122
- - Khi retest: tạo subfolder `TICKET-XXX_Retest_Date/` mới trong Evidence — không ghi đè cũ
123
- - `05.Scripts/` chỉ chứa `.spec.ts` `playwright.config.ts` — không chứa testcase `.md`
126
+ - Khi retest: tạo subfolder `run-{N+1}/` mới trong Evidence & Reports — không ghi đè cũ
127
+ - `05.Scripts/` 1 Playwright project chạy tại chỗ trong AK-Docs (`.spec.ts`, `playwright.config.ts`, `pages/`, `Shared/` fixtures + `evidence-helper.ts`, `package.json`, `node_modules/`) — không chứa testcase `.md`
128
+ - `05.Scripts/**/node_modules/`, `test-results/`, `playwright-report/`, `blob-report/` **phải** nằm trong `.gitignore` của repo chứa AK-Docs — execute-flow Gate 1 tự kiểm tra và thêm nếu thiếu
129
+ - **`04.Evidence/` phải nằm trong `.gitignore`** — dù chứa cả evidence tay (manual QA) và evidence automation (execute-test), toàn bộ nội dung là binary (screenshot/video/`trace.zip`), không commit lên Git. Không có `ak-test/` hay working dir nào khác ngoài AK-Docs cho flow này nữa.
124
130
  - `07.AI-Artifacts/` là working docs của AI — không phải tài liệu chính thức
@@ -171,19 +171,21 @@ ak execute # manual — AI asks for TC file
171
171
  - `[target]` — Optional. A ticket ID (`PROJ-44`), a path to a TC file (`./testcases/AD10.md`), or omitted for manual entry.
172
172
 
173
173
  **What it does (4 gates):**
174
- 1. **Gate 1 — Pre-flight:** Parse TC file, verify `ak-test/{repo}/` and `playwright.config.ts` exist, check `BASE_URL`
175
- 2. **Gate 2 — Script Sync:** Hash-based sync — gen new TCs, update changed, skip unchanged. Uses Playwright MCP for real selectors (never fabricates).
176
- 3. **Gate 3 — Execute & Evidence:** Run Playwright, organize evidence into `run-{N}/`, update TC file R1/R2 columns (`✅ Pass` · `❌ Fail` · `⏭️ Untest` · `⏳ Pending`)
177
- 4. **Gate 4 — Report & Bug Logging:** Generate `testreport.md`, confirm each bug with TESTER before logging to Jira
174
+ 1. **Gate 1 — Pre-flight:** Parse TC file, verify `AK-Docs/03.Testing/` subfolders and `AK-Docs/03.Testing/05.Scripts/{repo}/playwright.config.ts` exist (auto-scaffold if missing), check `BASE_URL`
175
+ 2. **Gate 2 — Script Sync:** Hash-based sync — gen new TCs, update changed, skip unchanged. Uses Playwright MCP for real selectors (never fabricates). Every step captures evidence via `evidence-helper.ts` and asserts on actual Expected Result content (see "DOM Verification Rules" in `execute-flow` SKILL.md).
176
+ 3. **Gate 3 — Execute & Evidence:** Run Playwright from `AK-Docs/03.Testing/05.Scripts/`, evidence written into `AK-Docs/03.Testing/04.Evidence/{repo}/{featureDir}/run-{N}/` via `EVIDENCE_DIR`, update TC file R1/R2 columns (`✅ Pass` · `❌ Fail` · `⏭️ Untest` · `⏳ Pending`)
177
+ 4. **Gate 4 — Report & Bug Logging:** Generate `testreport.md` in AK-Docs, confirm each bug with TESTER before logging to Jira
178
178
 
179
179
  **Output structure:**
180
180
  ```
181
- ak-test/{repo}/
182
- ├── scripts/{screenId}/{ScreenID}.spec.ts
183
- └── results/{screenId}/run-{N}/
184
- ├── {TC_ID}-{scenario}/ (screenshots, trace.zip, result.md)
185
- ├── bugs/BUG-NNN-{slug}.md
186
- └── testreport.md
181
+ AK-Docs/03.Testing/
182
+ ├── 04.Evidence/{repo}/{featureDir}/run-{N}/ # gitignored — screenshots, trace.zip
183
+ └── {TC_ID}-{scenario}/
184
+ ├── 05.Scripts/{repo}/{featureDir}/{ScreenID}.spec.ts # runnable Playwright project
185
+ ├── 02.Reports/{repo}/{featureDir}/run-{N}/
186
+ │ ├── {TC_ID}-{scenario}/result.md
187
+ │ └── testreport.md
188
+ └── 06.Bugs/{repo}/{featureDir}/run-{N}/BUG-NNN-{slug}.md
187
189
  ```
188
190
 
189
191
  **Example:**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@relipa/ai-flow-kit",
3
- "version": "0.2.0",
3
+ "version": "0.2.2-beta.0",
4
4
  "description": "All-in-one AI Flow Kit for team development with Claude AI - skills, templates, and MCP adapters",
5
5
  "author": "Example Team",
6
6
  "publishConfig": {