flutter-pro-max-cli 2.3.4 → 2.3.5

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.
@@ -1,3 +1,8 @@
1
+ ---
2
+ description: Tự động sử dụng skill search trước khi viết code Flutter
3
+ globs: *
4
+ ---
5
+
1
6
  # Rule: Tự động sử dụng Skill
2
7
 
3
8
  > Kích hoạt: Khi làm việc với Flutter/Dart files
@@ -1,3 +1,8 @@
1
+ ---
2
+ description: Tiêu chuẩn Code Quality, Think-Before-Code, Hard Constraints
3
+ globs: lib/**/*.dart
4
+ ---
5
+
1
6
  # Rule: Code Quality & Hard Constraints
2
7
 
3
8
  > Kích hoạt: Khi tạo/chỉnh sửa files `.dart`
@@ -1,3 +1,8 @@
1
+ ---
2
+ description: Quy trình làm việc ABCR (Audit-Block-Critique-Refactor) khi nhận request
3
+ globs: *
4
+ ---
5
+
1
6
  # Rule: Interaction Flow (ABCR)
2
7
 
3
8
  > Kích hoạt: Khi review, refactor, hoặc fix bugs
@@ -1,3 +1,8 @@
1
+ ---
2
+ description: Đảm bảo tính nhất quán (Consistency) của UI, Design Tokens, Widget Patterns
3
+ globs: lib/presentation/**/*.dart, lib/ui/**/*.dart, lib/widgets/**/*.dart
4
+ ---
5
+
1
6
  # Rule: App Consistency
2
7
 
3
8
  > Kích hoạt: Khi tạo UI, thêm screen, hoặc chỉnh sửa widget
@@ -1,3 +1,8 @@
1
+ ---
2
+ description: Xử lý lỗi, Try-catch, Result pattern, Không fail im lặng
3
+ globs: lib/data/**/*.dart, lib/services/**/*.dart, lib/repositories/**/*.dart, lib/domain/**/*.dart
4
+ ---
5
+
1
6
  # Rule: Error Handling
2
7
 
3
8
  > Kích hoạt: Khi viết logic xử lý dữ liệu, API calls, hoặc async operations
@@ -1,3 +1,8 @@
1
+ ---
2
+ description: Viết Unit Test, Widget Test, Integration Test
3
+ globs: test/**/*.dart, lib/**/*.dart
4
+ ---
5
+
1
6
  # Rule: Testing
2
7
 
3
8
  > Kích hoạt: Khi tạo feature mới, fix bug, hoặc refactor logic
@@ -1,3 +1,8 @@
1
+ ---
2
+ description: Tối ưu hiệu năng, const, ListView.builder, Async computation
3
+ globs: lib/presentation/**/*.dart, lib/ui/**/*.dart, lib/widgets/**/*.dart
4
+ ---
5
+
1
6
  # Rule: Performance
2
7
 
3
8
  > Kích hoạt: Khi viết widget, xử lý danh sách, hoặc async operations
@@ -37,11 +42,21 @@ ValueListenableBuilder<int>(
37
42
  );
38
43
  ```
39
44
 
45
+ ### 4. Performance (Bài toán Scale)
46
+
47
+ Code chạy mượt ở 10 items có thể crash app ở 10,000 items. Lỗi tràn RAM (OOM - Out of Memory) thường âm thầm và khó debug.
48
+
49
+ | Quy mô | Giải pháp Render |
50
+ |--------|------------------|
51
+ | Ít items (< 20) | `Column` bọc trong `SingleChildScrollView` (Có thể chấp nhận) |
52
+ | Nhiều items (Hàng ngàn) | **BẮT BUỘC** dùng `ListView.builder` kết hợp Pagination/Infinite Scroll |
53
+ | Bảng dữ liệu lớn | PaginatedDataTable hoặc Virtualized Lists |
54
+
40
55
  ### Checklist trước ship
41
56
 
42
57
  - [ ] Tất cả widget có `const` constructor nếu có thể
43
58
  - [ ] ListView/GridView dùng `.builder` hoặc `.separated`
59
+ - [ ] Màn hình danh sách có hỗ trợ phân trang (Pagination) nếu data có thể phình to
44
60
  - [ ] Không có `print()` còn sót (dùng `developer.log`)
45
- - [ ] Images có loading/error builders
46
61
 
47
- > 🔴 **Nếu list > 20 items → BẮT BUỘC dùng `.builder`.** Không exceptions.
62
+ > 🔴 **Nếu list > 20 items → BẮT BUỘC dùng `.builder`.** Luôn tự hỏi: *"Nếu user có 1 triệu record thì sao?"*
@@ -1,3 +1,8 @@
1
+ ---
2
+ description: Bảo mật, API Keys, Authentication, Data Protection
3
+ globs: lib/data/**/*.dart, lib/services/**/*.dart, lib/core/env/*.dart
4
+ ---
5
+
1
6
  # Rule: Security
2
7
 
3
8
  > Kích hoạt: Khi xử lý authentication, API keys, user data, hoặc storage
@@ -1,3 +1,8 @@
1
+ ---
2
+ description: Quản lý state theo cấp độ (Native-first), ValueNotifier
3
+ globs: lib/presentation/**/*.dart, lib/ui/**/*.dart
4
+ ---
5
+
1
6
  # Rule: State Management
2
7
 
3
8
  > Kích hoạt: Khi quản lý state trong widget, screen, hoặc app-level
@@ -1,3 +1,8 @@
1
+ ---
2
+ description: Quy tắc đặt tên (Naming), Cấu trúc thư mục (Folder Structure), Git Commit
3
+ globs: lib/**/*.dart, test/**/*.dart
4
+ ---
5
+
1
6
  # Rule: Naming & Conventions
2
7
 
3
8
  > Kích hoạt: Khi tạo files, classes, functions, hoặc variables
@@ -1,3 +1,8 @@
1
+ ---
2
+ description: Tiêu chuẩn tiếp cận (Accessibility), Semantics, Contrast
3
+ globs: lib/presentation/**/*.dart, lib/widgets/**/*.dart
4
+ ---
5
+
1
6
  # Rule: Accessibility
2
7
 
3
8
  > Kích hoạt: Khi tạo UI, interactive elements, hoặc form inputs
@@ -0,0 +1,22 @@
1
+ ---
2
+ description: Xử lý Network Failures, Tránh bão Request, Exponential Backoff, Circuit Breaker
3
+ globs: lib/data/**/*.dart, lib/services/**/*.dart, lib/repositories/**/*.dart
4
+ ---
5
+
6
+ # Rule: Network & API Resiliency
7
+
8
+ > Kích hoạt: Khi viết API calls, cấu hình HTTP clients (Dio/Http), xử lý timeout
9
+
10
+ ## Nguyên tắc: Tránh bão Request
11
+
12
+ Khi API lỗi do server quá tải, **TUYỆT ĐỐI KHÔNG** dùng vòng lặp retry vô tội vạ, vì sẽ tạo thêm gánh nặng làm sập hẳn server đang "thở oxy".
13
+
14
+ ### Giải pháp bắt buộc
15
+
16
+ | Tình huống | Kỹ thuật áp dụng |
17
+ |------------|------------------|
18
+ | Lỗi 5xx / Timeout | **Exponential Backoff**: Tăng thời gian chờ sau mỗi lần thử (vd: 1s, 2s, 4s, 8s...) |
19
+ | Server chết liên tục | **Circuit Breaker**: Ngắt hoàn toàn request trong 1 khoảng thời gian nhất định để server phục hồi. |
20
+ | Mạng chập chờn | Cảnh báo UI thanh lịch (Snackbar / Retry button), không quăng exception đỏ màn hình. |
21
+
22
+ > 🔴 **Luôn tự hỏi:** *"Nếu API endpoint này sập, app của mình có sập theo hay không bị treo cứng không?"*
@@ -0,0 +1,25 @@
1
+ ---
2
+ description: Tư duy Offline-First, Cache dữ liệu, Đồng bộ ngầm, Xử lý khi mất mạng
3
+ globs: lib/data/**/*.dart, lib/repositories/**/*.dart, lib/presentation/**/*.dart
4
+ ---
5
+
6
+ # Rule: Offline-First Experience
7
+
8
+ > Kích hoạt: Khi thiết kế luồng dữ liệu, fetch data cho màn hình chính (Dashboard, List)
9
+
10
+ ## Nguyên tắc: Sống sót không cần mạng
11
+
12
+ Khi thiết bị lọt vào vùng mất mạng, **TUYỆT ĐỐI KHÔNG** để vòng xoay loading chạy vô tận hoặc văng ra màn hình trắng trơn.
13
+
14
+ ### Kiến trúc Offline-First
15
+
16
+ 1. **Lớp Cache Cache:** Bắt buộc có Local DB (SQLite, Isar, Hive) để lưu dữ liệu quan trọng.
17
+ 2. **Luồng ưu tiên Local:**
18
+ - Khi mở màn hình: Load data từ Local DB hiển thị lên UI **ngay lập tức**.
19
+ - Kích hoạt đồng bộ ngầm (background fetch) với server.
20
+ - Khi có data mới từ server: Cập nhật DB nội bộ, luồng stream tự động đẩy data thiết kế mới lên UI một cách mượt mà.
21
+
22
+ ### Checklist Offline
23
+ - [ ] Mở app khi ngắt Wi-Fi vẫn thấy được dữ liệu cũ.
24
+ - [ ] Thao tác (Like, Xoá, Nút bấm) được lưu tạm hàng đợi (Queue) để sync lại khi có mạng.
25
+ - [ ] Có thông báo tinh tế báo hiệu đang xài ở chế độ Offline.
@@ -0,0 +1,23 @@
1
+ ---
2
+ description: Xử lý Graceful Degradation, Fallback UI khi component/dữ liệu lỗi
3
+ globs: lib/presentation/**/*.dart, lib/ui/**/*.dart, lib/widgets/**/*.dart
4
+ ---
5
+
6
+ # Rule: Graceful Degradation (UI Fallback)
7
+
8
+ > Kích hoạt: Khi build UI components, handle Image Network, List Items
9
+
10
+ ## Nguyên tắc: Lỗi cục bộ không được sập toàn cục
11
+
12
+ Khi một thành phần UI hoặc dữ liệu bị fail, **đừng làm sập cả màn hình**. Tính thanh lịch của app nằm ở việc fallback giấu lỗi.
13
+
14
+ ### Các Fallback Pattern Bắt Buộc
15
+
16
+ | Lỗi Component | Giải pháp UI (Fallback) |
17
+ |---------------|-------------------------|
18
+ | Hình ảnh (Avatar, Banner) lỗi tải (CDN down/404) | Hiển thị Default Image Icon, Placeholder, hoặc Chữ cái đầu của Tên (Initials Avatar). |
19
+ | 1 Item lỗi trong ListView | Hiển thị `ErrorItemWidget` nhỏ cho riêng dòng đó, thay vì ném Exception break toàn list. |
20
+ | Font chữ không tải được | Cấu hình Fallback về System Font mặc định. |
21
+ | Widget tương tác lỗi | Vô hiệu hoá (Disable) nút bấm đó và đổi màu xám thay vì crash khi bấm. |
22
+
23
+ > 🔴 **Quy tắc vàng:** Luôn định nghĩa thuộc tính `errorBuilder` cho mọi Network Image.
@@ -0,0 +1,30 @@
1
+ ---
2
+ description: Xử lý Vòng đời thiêt bị (Lifecycle), Orientation Change, Background State
3
+ globs: lib/presentation/**/*.dart, lib/logic/**/*.dart, lib/providers/**/*.dart
4
+ ---
5
+
6
+ # Rule: State & Lifecycle Resilience
7
+
8
+ > Kích hoạt: Khi quản lý State (Bloc/Provider/Riverpod), xử lý orientation, handle app background state
9
+
10
+ ## Nguyên tắc: Chống hao pin & lag vô ích
11
+
12
+ Quản lý vòng đời (lifecycle) kém sẽ làm máy nóng, lag và hao pin nhanh chóng, đặc biệt trên thiết bị Android yếu.
13
+
14
+ ### Xử lý Lifecycle Events
15
+
16
+ 1. **Xoay màn hình (Orientation Change):**
17
+ - Việc xoay dọc/ngang không được làm trigger lại các API requests.
18
+ - State phải được giữ nguyên bằng cơ chế State Management chuyên biệt, widget chỉ rebuild UI Layout.
19
+
20
+ 2. **App chuyển vào nền (Backgrounded):**
21
+ - Lập tức ngắt (Pause/Cancel) các Streams liên tục (như vị trí GPS, socket).
22
+ - Tạm dừng các `Timer` đếm ngược.
23
+
24
+ 3. **Memory Warning (Cảnh báo RAM):**
25
+ - Clear cache hình ảnh trong bộ nhớ (ví dụ: xoá cache network images).
26
+ - Giải phóng tài nguyên memory lớn không dùng tới.
27
+
28
+ ### Rò rỉ bộ nhớ (Memory Leaks)
29
+ - Luôn gọi `dispose()` trên các Controller (AnimationController, ScrollController, TextEditingController).
30
+ - Đảm bảo huỷ (cancel) StreamSubscription khi Widget bị huỷ.
@@ -172,11 +172,15 @@ async function generateRulesFile(targetDir, config) {
172
172
  }
173
173
  existing += '\n\n';
174
174
  }
175
+ // Helper to strip YAML frontmatter for appended files
176
+ const stripFrontmatter = (content) => {
177
+ return content.replace(/^---\n[\s\S]*?\n---\n+/, '');
178
+ };
175
179
  // Concatenate all rule files
176
180
  const allRules = ['# Flutter Pro Max — Agent Rules\n'];
177
181
  for (const file of ruleFiles) {
178
182
  const content = await readFile(join(rulesDir, file), 'utf-8');
179
- allRules.push(content);
183
+ allRules.push(stripFrontmatter(content));
180
184
  }
181
185
  await writeFile(rulesFilePath, existing + allRules.join('\n---\n\n'), 'utf-8');
182
186
  }
@@ -184,9 +188,12 @@ async function generateRulesFile(targetDir, config) {
184
188
  // Create mode: generate separate files in rules directory
185
189
  const rulesTargetDir = dirname(join(targetDir, config.rulesFile.path));
186
190
  await mkdir(rulesTargetDir, { recursive: true });
191
+ // If rulesFile.path ends with .mdc, we use .mdc extension for files
192
+ const useMdc = config.rulesFile.path.endsWith('.mdc');
187
193
  for (const file of ruleFiles) {
188
194
  const content = await readFile(join(rulesDir, file), 'utf-8');
189
- const targetPath = join(rulesTargetDir, file);
195
+ const targetExt = useMdc ? '.mdc' : '.md';
196
+ const targetPath = join(rulesTargetDir, file.replace(/\.md$/, targetExt));
190
197
  await writeFile(targetPath, content, 'utf-8');
191
198
  }
192
199
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flutter-pro-max-cli",
3
- "version": "2.3.4",
3
+ "version": "2.3.5",
4
4
  "description": "CLI to install Flutter Pro Max skill for AI coding assistants",
5
5
  "type": "module",
6
6
  "bin": {