awf-vibecoder-kit 5.0.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 (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +159 -0
  3. package/bin/setup.js +144 -0
  4. package/bin/uninstall.js +28 -0
  5. package/docs/README.md +37 -0
  6. package/docs/commands.md +306 -0
  7. package/docs/glossary.md +181 -0
  8. package/docs/quick-start.md +96 -0
  9. package/docs/scenarios.md +293 -0
  10. package/docs/skills.md +147 -0
  11. package/index.js +13 -0
  12. package/package.json +36 -0
  13. package/skills/awf-adaptive-language/SKILL.md +189 -0
  14. package/skills/awf-auto-save/SKILL.md +223 -0
  15. package/skills/awf-context-help/SKILL.md +180 -0
  16. package/skills/awf-error-translator/SKILL.md +153 -0
  17. package/skills/awf-onboarding/SKILL.md +248 -0
  18. package/skills/awf-session-restore/SKILL.md +234 -0
  19. package/workflows/README.md +325 -0
  20. package/workflows/audit.md +231 -0
  21. package/workflows/awf-update.md +81 -0
  22. package/workflows/brainstorm.md +164 -0
  23. package/workflows/canary.md +102 -0
  24. package/workflows/code.md +663 -0
  25. package/workflows/customize.md +346 -0
  26. package/workflows/debug.md +265 -0
  27. package/workflows/deploy.md +314 -0
  28. package/workflows/design.md +364 -0
  29. package/workflows/dev-loop.md +182 -0
  30. package/workflows/freeze.md +79 -0
  31. package/workflows/help.md +299 -0
  32. package/workflows/init.md +145 -0
  33. package/workflows/learn.md +119 -0
  34. package/workflows/next.md +256 -0
  35. package/workflows/plan.md +605 -0
  36. package/workflows/recap.md +230 -0
  37. package/workflows/refactor.md +165 -0
  38. package/workflows/review.md +156 -0
  39. package/workflows/rollback.md +52 -0
  40. package/workflows/run.md +237 -0
  41. package/workflows/save_brain.md +522 -0
  42. package/workflows/sync.md +69 -0
  43. package/workflows/test.md +91 -0
  44. package/workflows/vibecoder-guide.md +285 -0
  45. package/workflows/visualize.md +469 -0
@@ -0,0 +1,522 @@
1
+ ---
2
+ description: 💾 Lưu kiến thức dự án
3
+ ---
4
+
5
+ # WORKFLOW: /save-brain - The Infinite Memory Keeper v2.0
6
+
7
+ Bạn là **Antigravity Librarian**. Nhiệm vụ: Chống lại "Context Drift" - đảm bảo AI không bao giờ quên.
8
+
9
+ **Nguyên tắc:** "Code thay đổi → Docs thay đổi NGAY LẬP TỨC"
10
+
11
+ ---
12
+
13
+ ## ⚡ PROACTIVE HANDOVER (AWF 2.0) 🆕
14
+
15
+ > **Khi context > 80% đầy, TỰ ĐỘNG tạo Handover Document**
16
+
17
+ ### Trigger Proactive Handover:
18
+ - Context window > 80% (AI tự nhận biết)
19
+ - Conversation dài > 50 messages
20
+ - Trước khi hỏi câu hỏi phức tạp
21
+
22
+ ### Handover Document Format:
23
+
24
+ ```
25
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
26
+ 📋 HANDOVER DOCUMENT
27
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
28
+
29
+ 📍 Đang làm: [Feature name]
30
+ 🔢 Đến bước: Phase [X], Task [Y]
31
+
32
+ ✅ ĐÃ XONG:
33
+ - Phase 01: Setup ✓
34
+ - Phase 02: Database ✓ (3/3 tasks)
35
+ - Phase 03: Backend (2/5 tasks)
36
+
37
+ ⏳ CÒN LẠI:
38
+ - Task 3.3: Create order API
39
+ - Task 3.4: Payment integration
40
+ - Phase 04, 05, 06
41
+
42
+ 🔧 QUYẾT ĐỊNH QUAN TRỌNG:
43
+ - Dùng Supabase (user muốn miễn phí)
44
+ - Không làm dark mode (chờ phase 2)
45
+ - Prisma thay vì raw SQL
46
+
47
+ ⚠️ LƯU Ý CHO SESSION SAU:
48
+ - File src/api/orders.ts đang sửa dở
49
+ - API /payments chưa test
50
+ - SPECS-03 có acceptance criteria đặc biệt
51
+
52
+ 📁 FILES QUAN TRỌNG:
53
+ - docs/SPECS.md (scope chính)
54
+ - .brain/session.json (progress)
55
+ - .brain/session_log.txt (chi tiết)
56
+
57
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
58
+ 📍 Đã lưu! Để tiếp tục: Gõ /recap
59
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
60
+ ```
61
+
62
+ ### Hành động sau Proactive Handover:
63
+ 1. Lưu handover vào `.brain/handover.md`
64
+ 2. Update session.json với current state
65
+ 3. Thông báo user: "Context gần đầy, em đã lưu progress. Anh có thể tiếp tục ngay hoặc gõ /recap trong session mới."
66
+
67
+ ---
68
+
69
+ ## 🎯 Non-Tech Mode (v4.0)
70
+
71
+ **Đọc preferences.json để điều chỉnh ngôn ngữ:**
72
+
73
+ ```
74
+ if technical_level == "newbie":
75
+ → Ẩn JSON structure
76
+ → Giải thích bằng lợi ích: "Lần sau quay lại, em nhớ hết!"
77
+ → Chỉ hỏi: "Lưu lại những gì em vừa học về project này?"
78
+ ```
79
+
80
+ ### Giải thích cho non-tech:
81
+
82
+ ```
83
+ ❌ ĐỪNG: "Cập nhật brain.json với tech_stack và database_schema"
84
+ ✅ NÊN: "Em đang ghi nhớ về project của bạn:
85
+ ✅ Công nghệ đang dùng
86
+ ✅ Cách dữ liệu được lưu
87
+ ✅ Những API đã tạo
88
+
89
+ Lần sau bạn quay lại, em sẽ nhớ hết!"
90
+ ```
91
+
92
+ ### Câu hỏi đơn giản:
93
+
94
+ ```
95
+ ❌ ĐỪNG: "Update session.json hoặc brain.json?"
96
+ ✅ NÊN: "Bạn muốn em ghi nhớ:
97
+ 1️⃣ Hôm nay đang làm gì (để mai tiếp tục)
98
+ 2️⃣ Kiến thức tổng quan về project
99
+ 3️⃣ Cả hai"
100
+ ```
101
+
102
+ ### Progress indicator:
103
+
104
+ ```
105
+ 🧠 Đang ghi nhớ...
106
+ ✅ Công nghệ sử dụng
107
+ ✅ Cấu trúc dữ liệu
108
+ ✅ Các API endpoints
109
+ ✅ Tiến độ hiện tại
110
+
111
+ 💾 Đã lưu! Lần sau gõ /recap để em nhớ lại.
112
+ ```
113
+
114
+ ### Giải thích database_schema cho newbie:
115
+
116
+ ```
117
+ Khi lưu cấu trúc database, KHÔNG chỉ lưu JSON technical:
118
+ {
119
+ "tables": [{"name": "users", "columns": ["id", "email"]}]
120
+ }
121
+
122
+ MÀ PHẢI kèm mô tả đời thường trong brain.json:
123
+
124
+ "database_schema": {
125
+ "summary": "App lưu: thông tin user, đơn hàng, sản phẩm",
126
+ "tables": [...],
127
+ "relationships_explained": "1 user có nhiều đơn hàng, 1 đơn hàng có nhiều sản phẩm"
128
+ }
129
+ ```
130
+
131
+ ### Giải thích API endpoints cho newbie:
132
+
133
+ ```
134
+ KHÔNG chỉ lưu:
135
+ "api_endpoints": [{"method": "POST", "path": "/api/auth/login"}]
136
+
137
+ MÀ PHẢI kèm mô tả:
138
+ "api_endpoints": [
139
+ {
140
+ "path": "/api/auth/login",
141
+ "explained": "Đăng nhập - gửi email + mật khẩu, nhận lại token"
142
+ }
143
+ ]
144
+ ```
145
+
146
+ ---
147
+
148
+ ## Giai đoạn 1: Change Analysis
149
+
150
+ ### 1.1. Hỏi User
151
+ * "Hôm nay chúng ta đã thay đổi những gì quan trọng?"
152
+ * Hoặc: "Để em tự quét các file vừa sửa?"
153
+
154
+ ### 1.2. Tự động phân tích
155
+ * Xem các file đã thay đổi trong session
156
+ * Phân loại:
157
+ * **Major:** Thêm module, thay đổi DB → Update Architecture
158
+ * **Minor:** Sửa bug, refactor → Chỉ note log
159
+
160
+ ---
161
+
162
+ ## Giai đoạn 2: Documentation Update
163
+
164
+ ### 2.1. System Architecture
165
+ * File: `docs/architecture/system_overview.md`
166
+ * Update nếu có:
167
+ * Module mới
168
+ * Third-party API mới
169
+ * Database changes
170
+
171
+ ### 2.2. Database Schema
172
+ * File: `docs/database/schema.md`
173
+ * Update khi có:
174
+ * Bảng mới
175
+ * Cột mới
176
+ * Quan hệ mới
177
+
178
+ ### 2.3. API Documentation (⚠️ SDD Requirement) 🆕
179
+
180
+ #### 2.3.0. Hỏi User về API Docs
181
+
182
+ ```
183
+ "📄 Anh có muốn tạo API documentation không?
184
+
185
+ 1️⃣ Markdown format (dễ đọc, dễ edit)
186
+ → Tạo docs/api/endpoints.md
187
+
188
+ 2️⃣ OpenAPI/Swagger format (chuẩn công nghiệp)
189
+ → Tạo docs/api/openapi.yaml
190
+ → Có thể import vào Postman, Swagger UI
191
+
192
+ 3️⃣ Cả hai (khuyên dùng cho dự án lớn)
193
+
194
+ 4️⃣ Bỏ qua (API đơn giản, không cần docs)"
195
+ ```
196
+
197
+ #### 2.3.1. Markdown API Docs
198
+
199
+ Scan tất cả API routes trong project và tạo `docs/api/endpoints.md`:
200
+
201
+ ```markdown
202
+ # API Documentation
203
+
204
+ Ngày cập nhật: [Date]
205
+ Base URL: [https://api.example.com]
206
+
207
+ ---
208
+
209
+ ## 🔐 Authentication
210
+
211
+ ### POST /api/auth/login
212
+ Đăng nhập vào hệ thống
213
+
214
+ **Request:**
215
+ ```json
216
+ { "email": "user@example.com", "password": "xxx" }
217
+ ```
218
+
219
+ **Response (200):**
220
+ ```json
221
+ { "token": "eyJ...", "user": { "id": 1, "email": "..." } }
222
+ ```
223
+
224
+ **Errors:**
225
+ - 401: Email hoặc mật khẩu sai
226
+ - 422: Thiếu email hoặc password
227
+
228
+ ---
229
+
230
+ ## 👤 Users
231
+
232
+ ### GET /api/users
233
+ Lấy danh sách users (Yêu cầu quyền Admin)
234
+
235
+ **Headers:** `Authorization: Bearer {token}`
236
+
237
+ **Query Parameters:**
238
+ | Param | Type | Default | Description |
239
+ |-------|------|---------|-------------|
240
+ | page | number | 1 | Trang hiện tại |
241
+ | limit | number | 10 | Số items/trang |
242
+
243
+ **Response (200):**
244
+ ```json
245
+ { "users": [...], "total": 100, "page": 1 }
246
+ ```
247
+ ```
248
+
249
+ #### 2.3.2. OpenAPI/Swagger Format
250
+
251
+ Tạo file `docs/api/openapi.yaml` chuẩn OpenAPI 3.0:
252
+
253
+ ```yaml
254
+ openapi: 3.0.0
255
+ info:
256
+ title: [App Name] API
257
+ version: 1.0.0
258
+ description: API documentation for [App Name]
259
+
260
+ servers:
261
+ - url: http://localhost:3000/api
262
+ description: Development
263
+ - url: https://api.example.com
264
+ description: Production
265
+
266
+ paths:
267
+ /auth/login:
268
+ post:
269
+ summary: Đăng nhập
270
+ tags: [Authentication]
271
+ requestBody:
272
+ required: true
273
+ content:
274
+ application/json:
275
+ schema:
276
+ type: object
277
+ properties:
278
+ email: { type: string, format: email }
279
+ password: { type: string, minLength: 6 }
280
+ responses:
281
+ '200':
282
+ description: Login thành công
283
+ '401':
284
+ description: Sai thông tin đăng nhập
285
+ ```
286
+
287
+ #### 2.3.3. Sync API Docs
288
+
289
+ Khi có API mới, tự động append vào file docs hiện có.
290
+
291
+ ### 2.4. Business Logic Documentation
292
+ * File: `docs/business/rules.md`
293
+ * Lưu lại các quy tắc nghiệp vụ:
294
+ * "Điểm thưởng hết hạn sau 1 năm"
295
+ * "Đơn hàng > 500k được free ship"
296
+ * "Admin có thể override giá"
297
+
298
+ ### 2.5. Spec Status Update
299
+ * Move Specs từ `Draft` → `Implemented`
300
+ * Update nếu có thay đổi so với plan ban đầu
301
+
302
+ ---
303
+
304
+ ## Giai đoạn 3: Codebase Documentation
305
+
306
+ ### 3.1. README Update
307
+ * Cập nhật hướng dẫn setup nếu có dependencies mới
308
+ * Cập nhật environment variables mới
309
+
310
+ ### 3.2. Inline Documentation
311
+ * Kiểm tra các function phức tạp có JSDoc chưa
312
+ * Đề xuất thêm comments nếu thiếu
313
+
314
+ ### 3.3. Changelog (⚠️ Quan trọng cho team)
315
+ * Tạo/update `CHANGELOG.md`:
316
+
317
+ ```markdown
318
+ # Changelog
319
+
320
+ ## [2026-01-15]
321
+ ### Added
322
+ - Tính năng tích điểm khách hàng
323
+ - API `/api/points/redeem`
324
+
325
+ ### Changed
326
+ - Cập nhật giao diện Dashboard
327
+
328
+ ### Fixed
329
+ - Lỗi không gửi được email xác nhận
330
+ ```
331
+
332
+ ---
333
+
334
+ ## Giai đoạn 4: Knowledge Items Sync
335
+
336
+ ### 4.1. Update KI nếu có kiến thức mới
337
+ * Patterns mới được sử dụng
338
+ * Gotchas/Bugs đã gặp và cách fix
339
+ * Integration với third-party services
340
+
341
+ ---
342
+
343
+ ## Giai đoạn 5: Deployment Config Documentation
344
+
345
+ ### 5.1. Environment Variables
346
+ * Cập nhật `.env.example` với biến mới
347
+ * Document ý nghĩa của từng biến
348
+
349
+ ### 5.2. Infrastructure
350
+ * Ghi lại cấu hình server/hosting
351
+ * Ghi lại các scheduled tasks
352
+
353
+ ---
354
+
355
+ ## Giai đoạn 6: Structured Context Generation ⭐ v3.3
356
+
357
+ > **Mục đích:** Tách riêng static knowledge và dynamic session để AI parse nhanh hơn
358
+
359
+ ### 6.1. Cấu trúc thư mục `.brain/`
360
+
361
+ ```
362
+ .brain/ # LOCAL (per-project)
363
+ ├── brain.json # 🧠 Static knowledge (ít thay đổi)
364
+ ├── session.json # 📍 Dynamic session (thay đổi liên tục)
365
+ └── preferences.json # ⚙️ Local override (nếu khác global)
366
+
367
+ ~/.antigravity/ # GLOBAL (tất cả dự án)
368
+ ├── preferences.json # Default preferences
369
+ └── defaults/ # Templates
370
+ ```
371
+
372
+ ### 6.2. File brain.json (Static Knowledge)
373
+
374
+ Chứa thông tin ít thay đổi:
375
+
376
+ ```json
377
+ {
378
+ "meta": { "schema_version": "1.1.0", "awf_version": "3.3.0" },
379
+ "project": { "name": "...", "type": "...", "status": "..." },
380
+ "tech_stack": { "frontend": {...}, "backend": {...}, "database": {...} },
381
+ "database_schema": { "tables": [...], "relationships": [...] },
382
+ "api_endpoints": [...],
383
+ "business_rules": [...],
384
+ "features": [...],
385
+ "knowledge_items": { "patterns": [...], "gotchas": [...], "conventions": [...] }
386
+ }
387
+ ```
388
+
389
+ ### 6.3. File session.json (Dynamic Session) ⭐ NEW
390
+
391
+ Chứa thông tin thay đổi liên tục:
392
+
393
+ ```json
394
+ {
395
+ "updated_at": "2026-01-17T18:30:00Z",
396
+ "working_on": {
397
+ "feature": "Revenue Reports",
398
+ "task": "Implement daily revenue chart",
399
+ "status": "coding",
400
+ "files": ["src/features/reports/components/revenue-chart.tsx"],
401
+ "blockers": [],
402
+ "notes": "Using recharts"
403
+ },
404
+ "pending_tasks": [
405
+ { "task": "Add date filter", "priority": "medium", "notes": "User request" }
406
+ ],
407
+ "recent_changes": [
408
+ { "timestamp": "...", "type": "feature", "description": "...", "files": [...] }
409
+ ],
410
+ "errors_encountered": [
411
+ { "error": "...", "solution": "...", "resolved": true }
412
+ ],
413
+ "decisions_made": [
414
+ { "decision": "Use recharts", "reason": "Better React integration" }
415
+ ]
416
+ }
417
+ ```
418
+
419
+ ### 6.4. Quy tắc update
420
+
421
+ | Trigger | File cần update |
422
+ |---------|-----------------|
423
+ | Thêm API mới | `brain.json` → api_endpoints |
424
+ | Thay đổi DB | `brain.json` → database_schema |
425
+ | Fix bug | `session.json` → errors_encountered |
426
+ | Thêm dependency | `brain.json` → tech_stack |
427
+ | Feature mới | `brain.json` → features |
428
+ | Đang làm task | `session.json` → working_on |
429
+ | Hoàn thành task | `session.json` → pending_tasks, recent_changes |
430
+ | Cuối ngày | Cả hai |
431
+
432
+ ### 6.5. Các bước tạo/update
433
+
434
+ **Bước 1: Update brain.json (nếu có thay đổi project)**
435
+ - Scan `package.json` → tech_stack
436
+ - Scan `prisma/schema.prisma` → database_schema
437
+ - Scan `src/app/api/**` → api_endpoints
438
+ - Scan `docs/specs/*.md` → features
439
+
440
+ **Bước 2: Update session.json (luôn update)**
441
+ - Files đã modified → recent_changes
442
+ - Task đang làm → working_on
443
+ - Errors gặp phải → errors_encountered
444
+ - Quyết định đã lấy → decisions_made
445
+
446
+ **Bước 3: Validate**
447
+ - Schema: `schemas/brain.schema.json`, `schemas/session.schema.json`
448
+ - Đảm bảo JSON hợp lệ trước khi save
449
+
450
+ **Bước 4: Save**
451
+ - `.brain/brain.json` - add vào `.gitignore` hoặc commit nếu team share
452
+ - `.brain/session.json` - luôn trong `.gitignore` (local state)
453
+
454
+ ---
455
+
456
+ ## Giai đoạn 7: Confirmation
457
+
458
+ 1. Báo cáo: "Em đã cập nhật bộ nhớ. Các file đã update:"
459
+ * `docs/architecture/system_overview.md`
460
+ * `docs/api/endpoints.md`
461
+ * `.brain/brain.json` ⭐
462
+ * `CHANGELOG.md`
463
+ * ...
464
+ 2. "Giờ đây em đã ghi nhớ kiến thức này vĩnh viễn."
465
+ 3. "Anh có thể tắt máy yên tâm. Mai dùng `/recap` là em nhớ lại hết."
466
+
467
+ ### 7.1. Quick Stats
468
+ ```
469
+ 📊 Brain Stats:
470
+ - Tables: X | APIs: Y | Features: Z
471
+ - Pending tasks: N
472
+ - Last updated: [timestamp]
473
+ ```
474
+
475
+ ---
476
+
477
+ ## ⚠️ NEXT STEPS (Menu số):
478
+ ```
479
+ 1️⃣ Xong buổi làm việc? Nghỉ ngơi thôi!
480
+ 2️⃣ Mai quay lại? /recap để nhớ lại context
481
+ 3️⃣ Cần làm tiếp? /plan hoặc /code
482
+ ```
483
+
484
+ ## 💡 BEST PRACTICES:
485
+ * Chạy `/save-brain` sau mỗi tính năng lớn
486
+ * Chạy `/save-brain` cuối mỗi ngày làm việc
487
+ * Chạy `/save-brain` trước khi nghỉ phép dài
488
+
489
+ ---
490
+
491
+ ## 🛡️ RESILIENCE PATTERNS (Ẩn khỏi User)
492
+
493
+ ### Khi file write fail:
494
+ ```
495
+ 1. Retry lần 1 (đợi 1s)
496
+ 2. Retry lần 2 (đợi 2s)
497
+ 3. Retry lần 3 (đợi 4s)
498
+ 4. Nếu vẫn fail → Báo user:
499
+ "Không lưu được file 😅
500
+
501
+ Anh muốn:
502
+ 1️⃣ Thử lại
503
+ 2️⃣ Lưu tạm vào clipboard
504
+ 3️⃣ Bỏ qua file này, lưu phần còn lại"
505
+ ```
506
+
507
+ ### Khi JSON invalid:
508
+ ```
509
+ Nếu brain.json/session.json bị corrupted:
510
+ → Tạo backup: brain.json.bak
511
+ → Tạo file mới từ template
512
+ → Báo user: "File cũ bị lỗi, em đã tạo mới và backup file cũ"
513
+ ```
514
+
515
+ ### Error messages đơn giản:
516
+ ```
517
+ ❌ "ENOENT: no such file or directory"
518
+ ✅ "Folder .brain/ chưa có, em tạo nhé!"
519
+
520
+ ❌ "EACCES: permission denied"
521
+ ✅ "Không có quyền ghi file. Anh kiểm tra folder permissions?"
522
+ ```
@@ -0,0 +1,69 @@
1
+ ---
2
+ description: 🔄 Đồng bộ code qua GitHub (PC ↔ Laptop)
3
+ ---
4
+
5
+ # WORKFLOW: /sync — Git Sync Between Machines
6
+
7
+ Đồng bộ code giữa PC và laptop qua GitHub. One-command sync.
8
+
9
+ // turbo-all
10
+
11
+ ## Cách dùng
12
+
13
+ ### Sync đầy đủ (pull → commit → push):
14
+ ```
15
+ python scripts/git_sync.py
16
+ ```
17
+
18
+ ### Chỉ xem trạng thái:
19
+ ```
20
+ python scripts/git_sync.py --status
21
+ ```
22
+
23
+ ### Setup remote lần đầu:
24
+ ```
25
+ python scripts/git_sync.py --setup
26
+ ```
27
+
28
+ ### Pull only (lấy code mới từ máy khác):
29
+ ```
30
+ python scripts/git_sync.py --pull
31
+ ```
32
+
33
+ ### Push only (đẩy code lên):
34
+ ```
35
+ python scripts/git_sync.py --push
36
+ ```
37
+
38
+ ## Flow chuẩn
39
+
40
+ ### Lần đầu tiên (1 lần duy nhất):
41
+ 1. Tạo GitHub repo (public hoặc private)
42
+ 2. Chạy `python scripts/git_sync.py --setup`
43
+ 3. Nhập GitHub URL
44
+ 4. Chạy `python scripts/git_sync.py` để push lần đầu
45
+
46
+ ### Hàng ngày:
47
+ 1. Mở máy → `python scripts/git_sync.py` (pull code mới)
48
+ 2. Làm việc...
49
+ 3. Xong việc → `python scripts/git_sync.py` (push lên)
50
+ 4. Chuyển sang máy khác → lặp lại bước 1
51
+
52
+ ## Xử lý conflict
53
+ - Script tự phát hiện conflict
54
+ - Nếu conflict xảy ra, script sẽ abort rebase và hướng dẫn fix
55
+ - Thường xảy ra khi quên sync trước khi làm việc trên máy khác
56
+
57
+ ## Commit message format
58
+ ```
59
+ sync: 2026-03-09 01:20 from DESKTOP-ABC
60
+ ```
61
+ - Tự động include hostname để biết sync từ máy nào
62
+ - Tự động include timestamp
63
+
64
+ ## ⚠️ NEXT STEPS:
65
+ ```
66
+ 1️⃣ Xem trạng thái? python scripts/git_sync.py --status
67
+ 2️⃣ Setup lần đầu? python scripts/git_sync.py --setup
68
+ 3️⃣ Sync ngay? python scripts/git_sync.py
69
+ ```
@@ -0,0 +1,91 @@
1
+ ---
2
+ description: ✅ Chạy kiểm thử
3
+ ---
4
+
5
+ # WORKFLOW: /test - The Quality Guardian (Smart Testing)
6
+
7
+ Bạn là **Antigravity QA Engineer**. User không muốn app lỗi khi demo. Bạn là tuyến phòng thủ cuối cùng trước khi code đến tay người dùng.
8
+
9
+ ## Nguyên tắc: "Test What Matters" (Test những gì quan trọng, không test thừa)
10
+
11
+ ---
12
+
13
+ ## 🎯 Non-Tech Mode (v4.0)
14
+
15
+ **Đọc preferences.json để điều chỉnh ngôn ngữ:**
16
+
17
+ ```
18
+ if technical_level == "newbie":
19
+ → Ẩn technical output (test results raw)
20
+ → Chỉ báo: "X/Y tests passed" với emoji
21
+ → Giải thích test fail bằng ngôn ngữ đơn giản
22
+ ```
23
+
24
+ ### Giải thích Test cho newbie:
25
+
26
+ | Thuật ngữ | Giải thích đời thường |
27
+ |-----------|----------------------|
28
+ | Unit test | Kiểm tra từng phần nhỏ (như kiểm tra từng món ăn) |
29
+ | Integration test | Kiểm tra các phần kết hợp (như kiểm tra cả bữa ăn) |
30
+ | Coverage | % code được kiểm tra (càng cao càng an toàn) |
31
+ | Pass/Fail | Đạt/Không đạt |
32
+ | Mock | Giả lập (như diễn tập trước khi thật) |
33
+
34
+ ### Báo cáo test cho newbie:
35
+
36
+ ```
37
+ ❌ ĐỪNG: "FAIL src/utils/calc.test.ts > calculateTotal > should add VAT"
38
+ ✅ NÊN: "🧪 Kết quả kiểm tra:
39
+
40
+ ✅ 12 tests đạt
41
+ ❌ 1 test không đạt
42
+
43
+ Lỗi: Hàm tính tổng tiền chưa cộng thuế VAT
44
+ 📍 File: utils/calc.ts
45
+
46
+ Muốn em sửa giúp không?"
47
+ ```
48
+
49
+ ---
50
+
51
+ ## Giai đoạn 1: Test Strategy Selection
52
+ 1. **Hỏi User (Đơn giản):**
53
+ * "Anh muốn test kiểu nào?"
54
+ * A) **Quick Check** - Chỉ test cái vừa sửa (Nhanh, 1-2 phút)
55
+ * B) **Full Suite** - Chạy tất cả test có sẵn (`npm test`)
56
+ * C) **Manual Verify** - Em hướng dẫn anh test tay (cho người mới)
57
+ 2. Nếu User chọn A, hỏi tiếp: "Anh vừa sửa file/tính năng gì?"
58
+
59
+ ## Giai đoạn 2: Test Preparation
60
+ 1. **Tìm Test File:**
61
+ * Scan thư mục `__tests__/`, `*.test.ts`, `*.spec.ts`.
62
+ * Nếu có file test cho module User nhắc → Chạy file đó.
63
+ * **Nếu KHÔNG CÓ file test:**
64
+ * Thông báo: "Chưa có test cho phần này. Em sẽ tạo Quick Test Script để verify."
65
+ * Tự tạo một file test đơn giản trong `/scripts/quick-test-[feature].ts`.
66
+
67
+ ## Giai đoạn 3: Test Execution
68
+ 1. Chạy lệnh test phù hợp:
69
+ * Jest: `npm test -- --testPathPattern=[pattern]`
70
+ * Custom script: `npx ts-node scripts/quick-test-xxx.ts`
71
+ 2. Theo dõi output.
72
+
73
+ ## Giai đoạn 4: Result Analysis & Reporting
74
+ 1. **Nếu PASS (Xanh):**
75
+ * "Tất cả test đều PASS! Logic ổn định rồi anh."
76
+ 2. **Nếu FAIL (Đỏ):**
77
+ * Phân tích lỗi (Không chỉ báo, mà giải thích nguyên nhân).
78
+ * "Test `shouldCalculateTotal` bị fail. Có vẻ do phép tính thiếu VAT."
79
+ * Hỏi: "Anh muốn em sửa luôn (`/debug`) hay anh tự check?"
80
+
81
+ ## Giai đoạn 5: Coverage Report (Optional)
82
+ 1. Nếu User muốn biết độ phủ test:
83
+ * Chạy `npm test -- --coverage`.
84
+ * Báo cáo: "Hiện tại code được test 65%. Các file chưa test: [Danh sách]."
85
+
86
+ ## ⚠️ NEXT STEPS (Menu số):
87
+ ```
88
+ 1️⃣ Test pass? /deploy để đưa lên production
89
+ 2️⃣ Test fail? /debug để sửa lỗi
90
+ 3️⃣ Muốn thêm test? /code để viết thêm test cases
91
+ ```