@leejungkiin/awkit 1.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 (139) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +146 -0
  3. package/VERSION +1 -0
  4. package/bin/awf.js +549 -0
  5. package/bin/awk.js +1759 -0
  6. package/core/AGENTS.md +39 -0
  7. package/core/GEMINI.md +202 -0
  8. package/core/GEMINI.md.bak +244 -0
  9. package/core/orchestrator.md +58 -0
  10. package/package.json +46 -0
  11. package/schemas/brain.schema.json +342 -0
  12. package/schemas/preferences.schema.json +95 -0
  13. package/schemas/session.schema.json +112 -0
  14. package/skill-packs/neural-memory/README.md +111 -0
  15. package/skill-packs/neural-memory/pack.json +35 -0
  16. package/skill-packs/neural-memory/schemas/brain-snapshot.json +167 -0
  17. package/skill-packs/neural-memory/skills/nm-memory-audit/SKILL.md +157 -0
  18. package/skill-packs/neural-memory/skills/nm-memory-evolution/SKILL.md +202 -0
  19. package/skill-packs/neural-memory/skills/nm-memory-intake/SKILL.md +135 -0
  20. package/skill-packs/neural-memory/skills/nm-memory-sync/SKILL.md +184 -0
  21. package/skill-packs/neural-memory/workflows/nm-import.md +73 -0
  22. package/skill-packs/neural-memory/workflows/nm-recall.md +67 -0
  23. package/skill-packs/neural-memory/workflows/nm-snapshot.md +69 -0
  24. package/skills/adaptive-language/SKILL.md +189 -0
  25. package/skills/ambient-brain/SKILL.md +314 -0
  26. package/skills/ambient-brain/brain-router.md +185 -0
  27. package/skills/ambient-brain/brain-templates.md +201 -0
  28. package/skills/auto-save/SKILL.md +223 -0
  29. package/skills/awf-adaptive-language/SKILL.md +189 -0
  30. package/skills/awf-context-help/SKILL.md +180 -0
  31. package/skills/awf-error-translator/SKILL.md +153 -0
  32. package/skills/awf-session-restore/SKILL.md +270 -0
  33. package/skills/awf-version-tracker/SKILL.md +32 -0
  34. package/skills/awf-version-tracker/scripts/snapshot.sh +22 -0
  35. package/skills/beads-manager/SKILL.md +323 -0
  36. package/skills/brainstorm-agent/SKILL.md +295 -0
  37. package/skills/context-help/SKILL.md +180 -0
  38. package/skills/error-translator/SKILL.md +153 -0
  39. package/skills/ios-engineer/SKILL.md +101 -0
  40. package/skills/memory-sync/SKILL.md +378 -0
  41. package/skills/memory-sync/memory-router.md +185 -0
  42. package/skills/memory-sync/memory-templates.md +201 -0
  43. package/skills/orchestrator/SKILL.md +193 -0
  44. package/skills/session-restore/SKILL.md +240 -0
  45. package/templates/CODEBASE.md +80 -0
  46. package/templates/brain.example.json +321 -0
  47. package/templates/preferences.example.json +21 -0
  48. package/templates/project-identity/android.json +28 -0
  49. package/templates/project-identity/backend-nestjs.json +24 -0
  50. package/templates/project-identity/expo.json +27 -0
  51. package/templates/project-identity/ios.json +27 -0
  52. package/templates/project-identity/web-nextjs.json +24 -0
  53. package/templates/session.example.json +53 -0
  54. package/templates/specs/design-template.md +166 -0
  55. package/templates/specs/requirements-template.md +65 -0
  56. package/templates/specs/tasks-template.md +132 -0
  57. package/templates/structures/android.txt +10 -0
  58. package/templates/structures/backend-nestjs.txt +6 -0
  59. package/templates/structures/expo.txt +9 -0
  60. package/templates/structures/ios.txt +9 -0
  61. package/templates/structures/web-nextjs.txt +6 -0
  62. package/templates/workflow_dual_mode_template.md +87 -0
  63. package/workflows/_uncategorized/README.md +339 -0
  64. package/workflows/_uncategorized/ads-creative.md +357 -0
  65. package/workflows/_uncategorized/ads-full-optimization.md +308 -0
  66. package/workflows/_uncategorized/ads-plan.md +247 -0
  67. package/workflows/_uncategorized/ads-user-analysis.md +337 -0
  68. package/workflows/_uncategorized/skill-health.md +35 -0
  69. package/workflows/_uncategorized/skill-rollback.md +35 -0
  70. package/workflows/ads/admob.md +62 -0
  71. package/workflows/ads/ads-analyst.md +201 -0
  72. package/workflows/ads/ads-audit.md +106 -0
  73. package/workflows/ads/ads-optimize.md +97 -0
  74. package/workflows/ads/ads-targeting.md +241 -0
  75. package/workflows/ads/adsExpert.md +160 -0
  76. package/workflows/ads/smali-ads-config.md +400 -0
  77. package/workflows/ads/smali-ads-flow.md +331 -0
  78. package/workflows/ads/smali-ads-interstitial.md +377 -0
  79. package/workflows/ads/smali-ads-native.md +382 -0
  80. package/workflows/context/auto-execution-workflow.md +291 -0
  81. package/workflows/context/auto-implement.md +211 -0
  82. package/workflows/context/codebase-sync.md +163 -0
  83. package/workflows/context/logic-reasoning-workflow.md +260 -0
  84. package/workflows/context/next.md +195 -0
  85. package/workflows/context/recap.md +212 -0
  86. package/workflows/context/save-brain.md +285 -0
  87. package/workflows/context/user-intent-analysis-workflow.md +206 -0
  88. package/workflows/expert/codeExpert.md +126 -0
  89. package/workflows/expert/debugExpert.md +136 -0
  90. package/workflows/expert/planExpert.md +112 -0
  91. package/workflows/git/cloudflare-tunnel.md +135 -0
  92. package/workflows/git/git-commit-workflow.md +75 -0
  93. package/workflows/git/hotfix.md +357 -0
  94. package/workflows/git/release-notes.md +160 -0
  95. package/workflows/git/rollback.md +52 -0
  96. package/workflows/git/smart-git-ops.md +103 -0
  97. package/workflows/lifecycle/brainstorm.md +377 -0
  98. package/workflows/lifecycle/code.md +663 -0
  99. package/workflows/lifecycle/debug.md +116 -0
  100. package/workflows/lifecycle/deploy.md +95 -0
  101. package/workflows/lifecycle/init.md +152 -0
  102. package/workflows/lifecycle/master-code-workflow.md +300 -0
  103. package/workflows/lifecycle/migration.md +196 -0
  104. package/workflows/lifecycle/plan.md +91 -0
  105. package/workflows/lifecycle/refactor.md +165 -0
  106. package/workflows/lifecycle/run.md +52 -0
  107. package/workflows/lifecycle/test.md +91 -0
  108. package/workflows/meta/customize.md +346 -0
  109. package/workflows/meta/file-protection-rules.md +129 -0
  110. package/workflows/meta/help.html +350 -0
  111. package/workflows/meta/project-identity-enforcement.md +180 -0
  112. package/workflows/mobile/app-analysis.md +64 -0
  113. package/workflows/mobile/maestro-qa-workflow.md +470 -0
  114. package/workflows/mobile/maestro-test-workflow.md +84 -0
  115. package/workflows/mobile/structure-clean-architect.md +271 -0
  116. package/workflows/mobile/turbo-mobile-build.md +190 -0
  117. package/workflows/quality/accessibility-audit.md +311 -0
  118. package/workflows/quality/audit.md +217 -0
  119. package/workflows/quality/bug-hunter.md +243 -0
  120. package/workflows/quality/code-janitor.md +209 -0
  121. package/workflows/quality/code-quality-rules.md +132 -0
  122. package/workflows/quality/performance-audit.md +343 -0
  123. package/workflows/quality/project-audit.md +61 -0
  124. package/workflows/quality/self-healing-test.md +192 -0
  125. package/workflows/quality/ui-review.md +130 -0
  126. package/workflows/quality/ux-audit.md +213 -0
  127. package/workflows/quality/visual-debug.md +34 -0
  128. package/workflows/roles/oracle.md +267 -0
  129. package/workflows/roles/product-manager-workflow.md +52 -0
  130. package/workflows/roles/qa-engineer-workflow.md +41 -0
  131. package/workflows/roles/tech-lead-workflow.md +45 -0
  132. package/workflows/roles/ui-ux-designer-workflow.md +42 -0
  133. package/workflows/roles/vibe-coding-master-workflow.md +52 -0
  134. package/workflows/ui/app-screen-analyzer.md +152 -0
  135. package/workflows/ui/create-feature.md +332 -0
  136. package/workflows/ui/create-spec-architect.md +184 -0
  137. package/workflows/ui/design-to-ui.md +308 -0
  138. package/workflows/ui/ui-first-methodology.md +279 -0
  139. package/workflows/ui/visualize.md +298 -0
@@ -0,0 +1,196 @@
1
+ ---
2
+ description: 🔄 Nâng cấp SDK & Dependencies
3
+ ---
4
+
5
+ # WORKFLOW: /migration - SDK & Dependency Migration
6
+
7
+ Hướng dẫn nâng cấp an toàn SDK, dependencies, và platform versions.
8
+
9
+ ---
10
+
11
+ ## Khi nào cần migration?
12
+
13
+ - iOS SDK upgrade (iOS 17 → iOS 18)
14
+ - Android SDK upgrade (API 33 → API 34)
15
+ - Expo SDK upgrade (SDK 50 → SDK 51)
16
+ - Major dependency updates (React Native, Firebase, etc.)
17
+ - Breaking changes in libraries
18
+
19
+ ---
20
+
21
+ ## Giai đoạn 1: Pre-Migration Assessment
22
+
23
+ ### 1.1. Đọc Release Notes
24
+
25
+ - [ ] Review breaking changes
26
+ - [ ] Check deprecated APIs
27
+ - [ ] Note new features
28
+ - [ ] Identify migration guides
29
+
30
+ ### 1.2. Check Compatibility
31
+
32
+ ```bash
33
+ # iOS: Check Xcode compatibility
34
+ xcodebuild -version
35
+
36
+ # Android: Check Gradle compatibility
37
+ ./gradlew --version
38
+
39
+ # Expo: Check SDK compatibility
40
+ npx expo-doctor
41
+ ```
42
+
43
+ ### 1.3. Backup Current State
44
+
45
+ ```bash
46
+ # Create backup branch
47
+ git checkout -b backup/pre-migration-$(date +%Y%m%d)
48
+ git push origin backup/pre-migration-$(date +%Y%m%d)
49
+
50
+ # Tag current version
51
+ git tag -a v1.0.0-pre-migration -m "Before SDK migration"
52
+ git push origin v1.0.0-pre-migration
53
+ ```
54
+
55
+ ---
56
+
57
+ ## Giai đoạn 2: Update Dependencies
58
+
59
+ ### iOS Migration
60
+
61
+ ```bash
62
+ # Update Podfile
63
+ # Edit Podfile: platform :ios, '18.0'
64
+
65
+ # Update pods
66
+ pod update
67
+
68
+ # Update Swift version if needed
69
+ # Xcode → Build Settings → Swift Language Version
70
+ ```
71
+
72
+ ### Android Migration
73
+
74
+ ```kotlin
75
+ // build.gradle.kts
76
+ android {
77
+ compileSdk = 34
78
+ defaultConfig {
79
+ minSdk = 24
80
+ targetSdk = 34
81
+ }
82
+ }
83
+
84
+ // Update dependencies
85
+ dependencies {
86
+ implementation("androidx.core:core-ktx:1.12.0")
87
+ // ... other updates
88
+ }
89
+ ```
90
+
91
+ ```bash
92
+ # Sync and build
93
+ ./gradlew clean build
94
+ ```
95
+
96
+ ### Expo Migration
97
+
98
+ ```bash
99
+ # Upgrade Expo SDK
100
+ npx expo install expo@latest
101
+
102
+ # Upgrade all Expo packages
103
+ npx expo install --fix
104
+
105
+ # Check for issues
106
+ npx expo-doctor
107
+ ```
108
+
109
+ ---
110
+
111
+ ## Giai đoạn 3: Fix Breaking Changes
112
+
113
+ ### 3.1. Compiler Errors
114
+
115
+ Fix errors one by one:
116
+ - Deprecated API usage
117
+ - Changed method signatures
118
+ - Removed classes/methods
119
+
120
+ ### 3.2. Runtime Issues
121
+
122
+ Test thoroughly:
123
+ - [ ] App launches
124
+ - [ ] Core features work
125
+ - [ ] No crashes
126
+ - [ ] Performance is acceptable
127
+
128
+ ---
129
+
130
+ ## Giai đoạn 4: Testing
131
+
132
+ ### 4.1. Automated Tests
133
+
134
+ ```bash
135
+ # iOS
136
+ xcodebuild test -scheme YourApp -destination 'platform=iOS Simulator,name=iPhone 15'
137
+
138
+ # Android
139
+ ./gradlew test
140
+ ./gradlew connectedAndroidTest
141
+
142
+ # Expo
143
+ npm test
144
+ ```
145
+
146
+ ### 4.2. Manual Testing
147
+
148
+ - [ ] Test on oldest supported device
149
+ - [ ] Test on newest device
150
+ - [ ] Test all critical user flows
151
+ - [ ] Test edge cases
152
+
153
+ ---
154
+
155
+ ## Giai đoạn 5: Rollout
156
+
157
+ ### 5.1. Internal Testing
158
+
159
+ - Deploy to TestFlight/Internal Testing
160
+ - Monitor for 2-3 days
161
+ - Check crash reports
162
+
163
+ ### 5.2. Phased Rollout
164
+
165
+ - Start with 10% users
166
+ - Monitor for 24 hours
167
+ - Increase to 50% if stable
168
+ - Full rollout after 48 hours
169
+
170
+ ---
171
+
172
+ ## Rollback Plan
173
+
174
+ If issues occur:
175
+
176
+ ```bash
177
+ # Revert to backup branch
178
+ git checkout main
179
+ git reset --hard backup/pre-migration-YYYYMMDD
180
+ git push origin main --force
181
+
182
+ # Redeploy previous version
183
+ ```
184
+
185
+ ---
186
+
187
+ ## Post-Migration
188
+
189
+ - [ ] Update documentation
190
+ - [ ] Remove deprecated code
191
+ - [ ] Update CI/CD configs
192
+ - [ ] Communicate changes to team
193
+
194
+ ---
195
+
196
+ **Next Steps**: `/test` để chạy full test suite
@@ -0,0 +1,91 @@
1
+ ---
2
+ description: 📝 Thiết kế tính năng (Dual-Mode v5.0)
3
+ ---
4
+
5
+ # WORKFLOW: /plan - The Logic Architect v3 (Dual-Mode + Beads)
6
+
7
+ > **Mode A (Expert):** `/plan "Feature Name" --auto` -> Tạo plan chuẩn ngay lập tức.
8
+ > **Mode B (Guided):** `/plan` -> Dẫn dắt từng bước Socratic.
9
+
10
+ ---
11
+
12
+ ## 🅰️ Expert Mode (Direct Execution)
13
+
14
+ **Usage:**
15
+ ```bash
16
+ /plan "E-commerce Cart" --auto
17
+ ```
18
+
19
+ **Logic:**
20
+ 1. **Analyze Intent:** Extract feature name from args.
21
+ 2. **Generate Spec:** Create `docs/specs/ecommerce-cart_spec.md` with standard sections.
22
+ 3. **Generate Phases:** Create `plans/[timestamp]-ecommerce-cart/` with 4-6 standard phases.
23
+ 4. **Sync Beads:** Auto-create tasks in Beads for each phase.
24
+ 5. **Report:** "✅ Plan created at `plans/...`. 6 tasks synced to Beads."
25
+
26
+ ---
27
+
28
+ ## 🅱️ Guided Mode (Interactive Wizard)
29
+
30
+ ### Phase 1: Vibe Capture & Context
31
+ 1. **Understand Intent:** "Mô tả ý tưởng của bạn đi? (Nói tự nhiên thôi)"
32
+ 2. **Socratic Questions:** (Based on previous Logic Architect v2 logic)
33
+ - Auth? Files? Notifications? Payment?
34
+ - *New:* "Có cần tạo task trong Beads luôn không?"
35
+
36
+ ### Phase 2: Architecture & Flow
37
+ 1. **Visualize:** Vẽ sơ đồ Mermaid (Flowchart/Entity Relationship).
38
+ 2. **Confirm:** "Luồng đi như vậy đúng ý anh chưa?"
39
+ 3. **Menu:**
40
+ ```markdown
41
+ 1️⃣ ✅ Đúng rồi, chốt plan!
42
+ 2️⃣ ✏️ Sửa lại luồng
43
+ 3️⃣ 🔙 Quay lại bước 1
44
+ ```
45
+
46
+ ### Phase 3: Plan Generation
47
+ 1. **Action:** Tạo folder structure và file markdown (như v2).
48
+ 2. **Sync Beads:** (Nếu user đồng ý ở Phase 1)
49
+ - Loop qua từng Phase -> `bd create "Phase X: [Name]"`
50
+ - Loop qua từng Step trong Phase -> `bd dep add [Child] [Parent]`
51
+
52
+ ### Phase 4: Handoff
53
+ 1. **Report:** Hiển thị chi tiết Plan và Link Beads.
54
+ 2. **Next Steps Menu:**
55
+ ```markdown
56
+ 1️⃣ 🚀 Bắt đầu code ngay (`/code phase-01`)
57
+ 2️⃣ 👁️ Xem trước UI (`/visualize`)
58
+ 3️⃣ 📿 Xem danh sách task (`/todo`)
59
+ 4️⃣ 🔄 Chỉnh sửa lại plan
60
+ ```
61
+
62
+ ---
63
+
64
+ ## 🧠 Brain & Beads Integration Details
65
+
66
+ ### 1. Auto-Sync Logic
67
+ Khi tạo file `phase-01-setup.md`, hệ thống sẽ:
68
+ 1. Parse các dòng `- [ ] Task Name`.
69
+ 2. Chạy `bd create "Task Name"`.
70
+ 3. Ghi lại Bead ID vào cuối dòng trong file MD: `- [ ] Task Name <!-- bead:123 -->`.
71
+
72
+ ### 2. Context Retention
73
+ - Lưu đường dẫn Plan vào `brain/active_plans.json`.
74
+ - Khi User gõ `/next`, hệ thống đọc file này để biết đang làm Feature nào.
75
+
76
+ ---
77
+
78
+ ## 🛡️ Resilience Patterns
79
+
80
+ - **Duplicate Plan:** Nếu folder đã tồn tại -> Hỏi "Ghi đè (Overwrite) hay Tạo bản sao (Copy)?"
81
+ - **Beads Error:** Nếu `bd` command lỗi -> Vẫn tạo file MD, báo warning "Task tracking disabled".
82
+
83
+ ---
84
+
85
+ ## ⚠️ NEXT STEPS (Menu số):
86
+ ```
87
+ 1️⃣ Bắt đầu code Phase 1? `/code phase-01`
88
+ 2️⃣ Muốn xem UI trước? `/visualize`
89
+ 3️⃣ Cần chỉnh sửa plan? Nói em biết cần sửa gì
90
+ 4️⃣ Xem toàn bộ plan? Em show `plan.md`
91
+ ```
@@ -0,0 +1,165 @@
1
+ ---
2
+ description: 🧹 Dọn dẹp & tối ưu code
3
+ ---
4
+
5
+ # WORKFLOW: /refactor - The Code Gardener (Safe Cleanup)
6
+
7
+ Bạn là **Senior Code Reviewer**. Code đang chạy được nhưng "bẩn", User muốn dọn dẹp mà SỢ NHẤT là "sửa xong hỏng".
8
+
9
+ **Nhiệm vụ:** Làm đẹp code mà KHÔNG thay đổi logic.
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
+ → Giải thích code smell bằng hậu quả
20
+ → Ẩn chi tiết kỹ thuật (nesting depth, complexity metrics)
21
+ → Chỉ báo cáo: "Cần dọn X chỗ, mất khoảng Y phút"
22
+ ```
23
+
24
+ ### Bảng dịch "code smell" cho non-tech:
25
+
26
+ | Thuật ngữ | Giải thích đời thường |
27
+ |-----------|----------------------|
28
+ | Long function | Hàm quá dài → khó đọc, dễ bug |
29
+ | Deep nesting | Code quá nhiều tầng → rối |
30
+ | Dead code | Code thừa không ai dùng → làm rối project |
31
+ | Duplication | Copy-paste nhiều lần → sửa 1 chỗ quên chỗ khác |
32
+ | God class | 1 file làm quá nhiều việc → khó maintain |
33
+ | Magic number | Số xuất hiện không giải thích → không ai hiểu |
34
+
35
+ ### Báo cáo cho newbie:
36
+
37
+ ```
38
+ ❌ ĐỪNG: "Found 3 functions with cyclomatic complexity > 10"
39
+ ✅ NÊN: "🧹 Em tìm thấy 3 chỗ cần dọn:
40
+
41
+ 1. File orders.ts - Hàm quá dài (khó đọc)
42
+ 2. File utils.ts - Code lặp lại 5 lần
43
+ 3. File api.ts - Code cũ không ai dùng
44
+
45
+ Muốn em dọn giúp không? App vẫn chạy y như cũ!"
46
+ ```
47
+
48
+ ### Safety promise cho newbie:
49
+
50
+ ```
51
+ 🔒 CAM KẾT AN TOÀN:
52
+ - App vẫn chạy đúng như cũ
53
+ - Chỉ thay đổi cách viết, không thay đổi cách chạy
54
+ - Có thể quay lại bản cũ nếu cần
55
+ ```
56
+
57
+ ---
58
+
59
+ ## Giai đoạn 1: Scope & Safety
60
+
61
+ ### 1.1. Xác định phạm vi
62
+ * "Anh muốn dọn dẹp file/module nào?"
63
+ * A) **1 file cụ thể** (An toàn nhất)
64
+ * B) **1 module/feature** (Vừa phải)
65
+ * C) **Toàn bộ project** (Cần cẩn thận)
66
+
67
+ ### 1.2. Cam kết an toàn
68
+ * "Em cam kết: **Logic nghiệp vụ giữ nguyên 100%**. Chỉ thay đổi cách viết, không thay đổi cách chạy."
69
+
70
+ ### 1.3. Backup Suggestion
71
+ * "Trước khi refactor, anh có muốn em tạo backup branch không?"
72
+ * Nếu CÓ → `git checkout -b backup/before-refactor`
73
+
74
+ ---
75
+
76
+ ## Giai đoạn 2: Code Smell Detection (Ngửi mùi code tệ)
77
+
78
+ ### 2.1. Structural Issues
79
+ * **Long Functions:** Hàm > 50 dòng → Cần tách nhỏ
80
+ * **Deep Nesting:** If/else > 3 cấp → Cần flatten
81
+ * **Large Files:** File > 500 dòng → Cần tách module
82
+ * **God Objects:** Class làm quá nhiều việc → Cần tách
83
+
84
+ ### 2.2. Naming Issues
85
+ * **Vague Names:** `data`, `obj`, `temp`, `x` → Cần đặt tên rõ nghĩa
86
+ * **Inconsistent Style:** `getUserData` vs `fetch_user_info` → Cần thống nhất
87
+
88
+ ### 2.3. Duplication
89
+ * **Copy-Paste Code:** Đoạn code lặp lại → Cần tách thành hàm dùng chung
90
+ * **Similar Logic:** Logic tương tự nhưng khác data → Cần generalize
91
+
92
+ ### 2.4. Outdated Code
93
+ * **Dead Code:** Code không ai gọi → Cần xóa
94
+ * **Commented Code:** Code bị comment out → Cần xóa (đã có Git lưu)
95
+ * **Unused Imports:** Import nhưng không dùng → Cần xóa
96
+
97
+ ### 2.5. Missing Best Practices
98
+ * **No Types:** JavaScript thuần → Cần thêm TypeScript types
99
+ * **No Error Handling:** Thiếu try-catch → Cần thêm
100
+ * **No JSDoc:** Hàm phức tạp không có comment → Cần thêm
101
+
102
+ ---
103
+
104
+ ## Giai đoạn 3: Refactoring Plan (Kế hoạch dọn dẹp)
105
+
106
+ ### 3.1. Liệt kê thay đổi
107
+ * "Em sẽ thực hiện những thay đổi sau:"
108
+ 1. Tách hàm `processOrder` (120 dòng) thành 4 hàm nhỏ
109
+ 2. Đổi tên biến `d` thành `orderDate`
110
+ 3. Xóa 3 import không dùng
111
+ 4. Thêm JSDoc cho các hàm public
112
+
113
+ ### 3.2. Xin phép
114
+ * "Anh OK với kế hoạch này không?"
115
+
116
+ ---
117
+
118
+ ## Giai đoạn 4: Safe Execution (Thực hiện an toàn)
119
+
120
+ ### 4.1. Micro-Steps
121
+ * Thực hiện từng bước nhỏ (không thay đổi nhiều cùng lúc).
122
+ * Sau mỗi bước, kiểm tra code vẫn chạy được.
123
+
124
+ ### 4.2. Pattern Application
125
+ * **Extract Function:** Tách logic thành hàm riêng
126
+ * **Rename Variable:** Đổi tên cho rõ nghĩa
127
+ * **Remove Dead Code:** Xóa code không dùng
128
+ * **Add Types:** Thêm TypeScript annotations
129
+ * **Add Comments:** Thêm JSDoc cho hàm phức tạp
130
+
131
+ ### 4.3. Format & Lint
132
+ * Chạy Prettier để format code.
133
+ * Chạy ESLint để kiểm tra lỗi.
134
+
135
+ ---
136
+
137
+ ## Giai đoạn 5: Quality Assurance
138
+
139
+ ### 5.1. Before/After Comparison
140
+ * "Trước: [Code cũ]"
141
+ * "Sau: [Code mới]"
142
+ * "Logic không đổi, chỉ dễ đọc hơn."
143
+
144
+ ### 5.2. Test Suggestion
145
+ * "Em đề xuất chạy `/test` để confirm logic không bị ảnh hưởng."
146
+
147
+ ---
148
+
149
+ ## Giai đoạn 6: Handover
150
+
151
+ 1. Báo cáo: "Đã dọn dẹp xong [X] file."
152
+ 2. Liệt kê:
153
+ * "Đã tách [Y] hàm lớn"
154
+ * "Đã đổi tên [Z] biến"
155
+ * "Đã xóa [W] dòng code thừa"
156
+ 3. Khuyến nghị: "Anh chạy `/test` để chắc chắn không có gì bị hỏng."
157
+
158
+ ---
159
+
160
+ ## ⚠️ NEXT STEPS (Menu số):
161
+ ```
162
+ 1️⃣ Chạy /test để kiểm tra logic không bị ảnh hưởng
163
+ 2️⃣ Có lỗi? /rollback để quay lại
164
+ 3️⃣ OK rồi? /save-brain để lưu thay đổi
165
+ ```
@@ -0,0 +1,52 @@
1
+ ---
2
+ description: ▶️ Chạy ứng dụng
3
+ ---
4
+
5
+ # WORKFLOW: /run - The Application Launcher (Smart Start)
6
+
7
+ Bạn là **Antigravity Operator**. User muốn thấy app chạy trên màn hình. Nhiệm vụ của bạn là làm mọi cách để app LÊN SÓNG.
8
+
9
+ ## Nguyên tắc: "One Command to Rule Them All" (User chỉ cần gõ /run, còn lại AI lo)
10
+
11
+ ## Giai đoạn 1: Environment Detection
12
+ 1. **Tự động scan dự án:**
13
+ * Có `docker-compose.yml`? → Docker Mode.
14
+ * Có `package.json` với script `dev`? → Node Mode.
15
+ * Có `requirements.txt`? → Python Mode.
16
+ * Có `Makefile`? → Đọc Makefile tìm lệnh run.
17
+ 2. **Hỏi User nếu có nhiều lựa chọn:**
18
+ * "Em thấy dự án này có thể chạy bằng Docker hoặc Node trực tiếp. Anh muốn chạy kiểu nào?"
19
+ * A) Docker (Giống môi trường thật hơn)
20
+ * B) Node trực tiếp (Nhanh hơn, dễ debug hơn)
21
+
22
+ ## Giai đoạn 2: Pre-Run Checks
23
+ 1. **Dependency Check:**
24
+ * Kiểm tra `node_modules/` có tồn tại không.
25
+ * Nếu chưa có → Tự chạy `npm install` trước.
26
+ 2. **Port Check:**
27
+ * Kiểm tra port mặc định (3000, 8080...) có bị chiếm không.
28
+ * Nếu bị chiếm → Hỏi: "Port 3000 đang bị app khác dùng. Anh muốn em kill nó, hay chạy port khác?"
29
+
30
+ ## Giai đoạn 3: Launch & Monitor
31
+ 1. **Khởi động app:**
32
+ * Dùng `run_command` với `WaitMsBeforeAsync` để chạy nền.
33
+ * Theo dõi output đầu tiên để bắt lỗi sớm.
34
+ 2. **Nhận diện trạng thái:**
35
+ * Nếu thấy "Ready on http://..." → THÀNH CÔNG.
36
+ * Nếu thấy "Error:", "EADDRINUSE", "Cannot find module" → THẤT BẠI.
37
+
38
+ ## Giai đoạn 4: Handover
39
+ 1. **Nếu thành công:**
40
+ * "App đang chạy tại: `http://localhost:3000`"
41
+ * "Anh mở trình duyệt và truy cập để xem. Nếu cần sửa giao diện, gõ `/visualize`."
42
+ 2. **Nếu thất bại:**
43
+ * Phân tích lỗi và báo cáo (Ngôn ngữ người thường).
44
+ * "Có vẻ thiếu thư viện. Em sẽ cài thêm..." → Tự cài và thử lại.
45
+ * Hoặc: "Lỗi code. Anh gõ `/debug` để em sửa."
46
+
47
+ ## ⚠️ NEXT STEPS (Menu số):
48
+ ```
49
+ 1️⃣ App chạy OK? /visualize để chỉnh UI, hoặc /code tiếp
50
+ 2️⃣ App lỗi? /debug để sửa
51
+ 3️⃣ Muốn dừng app? Gõ Ctrl+C ở terminal
52
+ ```
@@ -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
+ ```