agent-flutter 0.1.1

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 (42) hide show
  1. package/README.md +57 -0
  2. package/bin/agent-flutter.js +8 -0
  3. package/package.json +36 -0
  4. package/src/cli.js +494 -0
  5. package/templates/shared/.ignore +24 -0
  6. package/templates/shared/TEMPLATES.md +54 -0
  7. package/templates/shared/rules/document-workflow-function.md +98 -0
  8. package/templates/shared/rules/integration-api.md +3 -0
  9. package/templates/shared/rules/new-template-project.md +148 -0
  10. package/templates/shared/rules/ui.md +268 -0
  11. package/templates/shared/rules/unit-test.md +3 -0
  12. package/templates/shared/rules/widget-test.md +3 -0
  13. package/templates/shared/skills/dart-best-practices/SKILL.md +20 -0
  14. package/templates/shared/skills/dart-language-patterns/SKILL.md +47 -0
  15. package/templates/shared/skills/dart-model-reuse/SKILL.md +38 -0
  16. package/templates/shared/skills/dart-tooling-ci/SKILL.md +38 -0
  17. package/templates/shared/skills/flutter-assets-management/SKILL.md +78 -0
  18. package/templates/shared/skills/flutter-bloc-state-management/SKILL.md +48 -0
  19. package/templates/shared/skills/flutter-bloc-state-management/references/REFERENCE.md +19 -0
  20. package/templates/shared/skills/flutter-bloc-state-management/references/auth-bloc-example.md +96 -0
  21. package/templates/shared/skills/flutter-bloc-state-management/references/property-based-state.md +103 -0
  22. package/templates/shared/skills/flutter-dependency-injection-injectable/SKILL.md +64 -0
  23. package/templates/shared/skills/flutter-dependency-injection-injectable/references/REFERENCE.md +15 -0
  24. package/templates/shared/skills/flutter-dependency-injection-injectable/references/modules.md +42 -0
  25. package/templates/shared/skills/flutter-error-handling/SKILL.md +25 -0
  26. package/templates/shared/skills/flutter-error-handling/references/REFERENCE.md +38 -0
  27. package/templates/shared/skills/flutter-error-handling/references/error-mapping.md +44 -0
  28. package/templates/shared/skills/flutter-navigation-manager/SKILL.md +81 -0
  29. package/templates/shared/skills/flutter-navigation-manager/references/REFERENCE.md +71 -0
  30. package/templates/shared/skills/flutter-navigation-manager/references/router-config.md +57 -0
  31. package/templates/shared/skills/flutter-standard-lib-src-architecture/SKILL.md +89 -0
  32. package/templates/shared/skills/flutter-standard-lib-src-architecture/references/REFERENCE.md +19 -0
  33. package/templates/shared/skills/flutter-standard-lib-src-architecture/references/folder-structure.md +35 -0
  34. package/templates/shared/skills/flutter-standard-lib-src-architecture/references/modular-injection.md +27 -0
  35. package/templates/shared/skills/flutter-standard-lib-src-architecture/references/shared-core.md +29 -0
  36. package/templates/shared/skills/flutter-standard-lib-src-architecture-dependency-rules/SKILL.md +58 -0
  37. package/templates/shared/skills/flutter-standard-lib-src-architecture-dependency-rules/references/REFERENCE.md +113 -0
  38. package/templates/shared/skills/flutter-standard-lib-src-architecture-dependency-rules/references/repository-mapping.md +48 -0
  39. package/templates/shared/skills/flutter-ui-widgets/SKILL.md +152 -0
  40. package/templates/shared/skills/getx-localization-standard/SKILL.md +101 -0
  41. package/templates/shared/skills/getx-localization-standard/references/new-page-localization.example.md +61 -0
  42. package/templates/shared/skills/ui-documentation-workflow/SKILL.md +55 -0
@@ -0,0 +1,152 @@
1
+ ---
2
+ name: Flutter UI Widgets
3
+ description: Principles for maintainable UI components and project-specific widget standards.
4
+ ---
5
+
6
+ # UI & Widgets
7
+
8
+ ## **Priority: P1**
9
+
10
+ - **Design Tokens (STRICT)**:
11
+ - Typography: 1–1 mapping from Figma. Use `AppStyles`; `height = lineHeight / fontSize`. Bundle exact font-family/weight.
12
+ - Colors: Use `AppColors`; no hex/raw colors.
13
+ - Spacing: Use `int_extensions` and `AppDimensions`; no free-form numbers.
14
+ - Radius: Preserve Figma values; do not coerce to presets.
15
+ - Icon: Sizes must follow Figma numeric tokens. Common 24×24; container per Figma (e.g., 40×40, 44×44). Do not assume fixed size. Reference via `AppAssets`.
16
+ - Shadows: Normalize `BoxShadow` close to CSS box-shadow.
17
+ - Backgrounds: Use `DecorationImage` + appropriate `BoxFit` (cover/contain).
18
+
19
+ ## Quality & Safety
20
+ - **Async Gaps**: After `await`, check `if (context.mounted)` before using `BuildContext`.
21
+ - **Optimization**: Prefer `ColoredBox`/`Padding`/`DecoratedBox` over `Container` when only color/background/padding is needed.
22
+ - **Layout Tips**: Avoid `IntrinsicWidth/Height`; use `Stack` + `FractionallySizedBox` for overlays; `Flex` + int extensions (`n.height`/`n.width`) for spacing.
23
+ - **Large Lists**: Use `AppListView` for large lists.
24
+ - **SVG Color**: Do not use `colorFilter` if the SVG already matches Figma; only apply when design requires and the icon is flattened stroke→fill (see Assets Skill).
25
+
26
+ ## Examples
27
+
28
+ ### Async Gaps
29
+ ```dart
30
+ onPressed: () async {
31
+ await Future.delayed(const Duration(milliseconds: 100));
32
+ if (!context.mounted) return;
33
+ Navigator.pop(context);
34
+ }
35
+ ```
36
+
37
+ ### ColoredBox vs Container
38
+ ```dart
39
+ // GOOD: only color + padding
40
+ ColoredBox(
41
+ color: AppColors.white,
42
+ child: Padding(
43
+ padding: const EdgeInsets.all(16),
44
+ child: Text('Content', style: AppStyles.bodyLarge()),
45
+ ),
46
+ );
47
+ ```
48
+
49
+ ### Spacing with int extensions
50
+ ```dart
51
+ Column(
52
+ children: [
53
+ Text('Title', style: AppStyles.h3),
54
+ 12.height, // vertical space
55
+ Row(
56
+ children: [
57
+ Text('Left'),
58
+ 8.width, // horizontal space
59
+ Text('Right'),
60
+ ],
61
+ ),
62
+ ],
63
+ );
64
+ ```
65
+
66
+ ### SVG Color Handling
67
+ ```dart
68
+ // No recolor (SVG already has Figma color)
69
+ SvgPicture.asset(AppAssets.iconsCalendarSvg);
70
+
71
+ // Recolor only for mono icons prepared with fill
72
+ SvgPicture.asset(AppAssets.iconsChevronSolidSvg, color: AppColors.primary);
73
+ ```
74
+
75
+ ### Overlay Layout
76
+ ```dart
77
+ Stack(
78
+ children: [
79
+ Image.asset(AppAssets.bgContainerPng, fit: BoxFit.cover),
80
+ const FractionallySizedBox(
81
+ alignment: Alignment.bottomCenter,
82
+ heightFactor: 0.25,
83
+ child: AppCardSection(child: Text('Bottom Sheet')),
84
+ ),
85
+ ],
86
+ );
87
+ ```
88
+
89
+ ## Customization & Defaults
90
+ - Every `App*` widget must provide parameters to override tokens per Figma: `size`, `radius`, `padding/margin`, `backgroundColor`, `textStyle`, `iconSize`, `constraints`.
91
+ - Defaults are fallbacks and must use tokens (`AppStyles`, `AppColors`, `AppDimensions`). Do not hardcode display values.
92
+ - Example: `AppButtonBar(size: 40, radius: 14, iconSize: 24, backgroundColor: AppColors.white)`; if Figma differs, pass matching parameters.
93
+ - When overriding numeric tokens, preserve Figma values; do not round or force presets.
94
+
95
+ - **Naming Convention**:
96
+ - Shared widgets in `lib/src/ui/widgets` MUST use the `App` prefix (e.g., `AppInput`, `AppButton`, `AppCardSection`).
97
+ - Use these pre-built `App*` widgets instead of raw Material/Cupertino widgets to ensure consistency.
98
+ - **Styling (Colors & Typography)**:
99
+ - **Source of Truth**: Always use `AppColors` and `AppStyles` from `lib/src/utils/`.
100
+ - **Forbidden**: Do NOT hardcode colors (e.g., `Colors.red`, `Color(0xFF...)`) or text styles.
101
+ - **Usage**: `AppColors.primary`, `AppStyles.bodyMedium`.
102
+ - **State**:
103
+ - Use `StatelessWidget` by default.
104
+ - Use `StatefulWidget` for self-contained UI logic (e.g., `AppInput` handling focus/password visibility internally) to keep parent Pages clean.
105
+ - **Composition**: Extract UI into small, atomic `const` widgets.
106
+ - **Theming**: Use `Theme.of(context)` where applicable, but prefer `AppColors`/`AppStyles` for specific design system tokens.
107
+ - **Layout**: Use `Flex` + int extensions (`n.height`/`n.width`).
108
+ - **Specialized**:
109
+ - `SelectionArea`: For multi-widget text selection.
110
+ - `InteractiveViewer`: For zoom/pan.
111
+ - `ListWheelScrollView`: For pickers.
112
+ - `IntrinsicWidth/Height`: Avoid unless strictly required.
113
+ - **Large Lists**: Always use `ListView.builder` (or `AppListView` if available).
114
+
115
+ ## **Common System Widgets**
116
+
117
+ Refer to `lib/src/ui/widgets/` for the source of truth. Common examples:
118
+
119
+ - **Inputs**: `AppInput` (handles focus, labels, password visibility).
120
+ - **Buttons**: `AppButtonBar` (standard back button; container/radius/icon size per Figma, e.g., 40×40, radius 14, icon 24), `AppButton` (primary actions).
121
+ - **Text**: `AppTextGradient` (gradient text).
122
+ - **Containers**: `AppCardSection`, `AppContainerExpand`.
123
+
124
+ ```dart
125
+ // Example of using project-standard widgets and styles
126
+ class WorkDetailPage extends StatelessWidget {
127
+ @override
128
+ Widget build(BuildContext context) {
129
+ return Scaffold(
130
+ backgroundColor: AppColors.background, // Use AppColors
131
+ appBar: AppBar(
132
+ leading: AppButtonBar(), // Standard back button
133
+ title: AppTextGradient( // Standard styled text
134
+ text: 'Detail',
135
+ gradient: AppColors.primaryTextGradient(),
136
+ ),
137
+ ),
138
+ body: Column(
139
+ children: [
140
+ Text('Welcome', style: AppStyles.h3), // Use AppStyles
141
+ AppInput(label: 'Email'),
142
+ AppInput(label: 'Password', isPassword: true),
143
+ ],
144
+ ),
145
+ );
146
+ }
147
+ }
148
+ ```
149
+
150
+ ## Related Topics
151
+
152
+ performance | testing
@@ -0,0 +1,101 @@
1
+ ---
2
+ name: GetX Localization Standard
3
+ description: "Standards for GetX-based multi-language (locale_key + lang_*.dart). Invoke when generating a new page/feature or adding any user-facing text."
4
+ ---
5
+
6
+ # GetX Localization Standard
7
+
8
+ ## **Priority: P1 (HIGH)**
9
+
10
+ All user-facing text MUST be localized via **GetX Translations** using `locale_key.dart` + `lang_*.dart`.
11
+
12
+ ## Core Rules (When generating a page)
13
+
14
+ ### 1) locale_key.dart MUST be updated
15
+ - Add every new key used by the new page.
16
+ - Keys MUST be stable and semantic.
17
+ - Key naming format: `<feature>_<screen>_<element>` in `snake_case` (e.g. `customer_detail_title`).
18
+
19
+ ### 2) ALL language files MUST be updated
20
+ Whenever a new key is added, you MUST update:
21
+ - `lang_en.dart`
22
+ - `lang_ja.dart`
23
+ - Any existing `lang_*.dart` languages in the project
24
+
25
+ No language is allowed to miss keys.
26
+
27
+ ### 3) UI MUST use `.tr` (no raw strings)
28
+ - Always write: `LocaleKey.someKey.tr`
29
+ - Never hardcode labels like `'Home'`, `'ホーム'`, `'Trang chủ'` in widgets.
30
+
31
+ ## Project Implementation (Source of Truth)
32
+
33
+ - Keys: `lib/src/core/localization/locale_key.dart`
34
+ - Translations:
35
+ - `lib/src/core/localization/lang_en.dart`
36
+ - `lib/src/core/localization/lang_ja.dart`
37
+ - Registry: `lib/src/core/localization/app_translations.dart`
38
+ - App wiring: `lib/main.dart` uses `GetMaterialApp(...)` with `translations`, `supportedLocales`, `fallbackLocale`, and Flutter `localizationsDelegates`.
39
+
40
+ ## Conflict-Free Workflow (Recommended)
41
+ - **Modularize per Feature**: Split translations by feature to avoid PR conflicts:
42
+ - `lib/src/core/localization/en/<feature>.dart`
43
+ - `lib/src/core/localization/ja/<feature>.dart`
44
+ - **Aggregate Maps**: Keep `lang_en.dart` and `lang_ja.dart` as aggregators that merge feature maps:
45
+ ```dart
46
+ // lang_en.dart
47
+ import 'en/home.dart' as en_home;
48
+ import 'en/customer.dart' as en_customer;
49
+ final Map<String, String> enUs = {
50
+ ...en_home.map,
51
+ ...en_customer.map,
52
+ // ...
53
+ };
54
+ ```
55
+ ```dart
56
+ // en/home.dart
57
+ final map = <String, String>{
58
+ LocaleKey.home_title: 'Home',
59
+ // ...
60
+ };
61
+ ```
62
+ - **Key Namespacing**: Prefix keys by feature (`customer_detail_title`), keep `snake_case`.
63
+ - **Sorting & Lint**: Sort keys alphabetically; reject PRs with duplicate keys or missing locales.
64
+ - **Append-Only**: Do not rename/remove keys in active release branches; add new keys and deprecate old ones separately.
65
+ - **CI Check (Optional)**: Script to validate:
66
+ - All keys in `locale_key.dart` exist in every `lang_*.dart`.
67
+ - No duplicate keys across feature maps.
68
+ - Aggregators compile successfully.
69
+
70
+ ## Integration with TranslationManager
71
+ - **Existing Manager**: `lib/src/locale/translation_manager.dart` expects `enUs` and `jaJp` maps from `lang_en.dart` and `lang_ja.dart`.
72
+ - **Do NOT rename** exported variables `enUs` / `jaJp`. Keep aggregator files exporting exactly these names.
73
+ - **Wiring remains**: `TranslationManager.keys` continues to return `{'en_US': enUs, 'ja_JP': jaJp}` — modularization happens inside aggregators.
74
+ - **Adding Languages**: When adding a new language, update:
75
+ - Aggregator `lang_<code>.dart` to export `<code>_<COUNTRY>` map variable.
76
+ - `TranslationManager.appLocales` and `.keys` to include the new locale.
77
+
78
+ ## Common Keys & Reuse Policy
79
+ - **Purpose**: Reduce duplicate text using shared keys for app-wide phrases.
80
+ - **Common Module**:
81
+ - Create `lib/src/core/localization/en/common.dart` and `ja/common.dart` for common phrases (Save, Cancel, OK, Back, Next, Loading, Error, Retry…).
82
+ - Aggregators include `...common.map` before feature maps.
83
+ - **Key Naming**: Use `common_` prefix (e.g., `common_save`, `common_cancel`, `common_error_network`).
84
+ - **Feature Usage**: When a screen uses text that matches common, **reuse** `LocaleKey.common_*` instead of creating a feature key.
85
+ - **Screen-Specific**: Create new keys only for context-specific texts (e.g., `customer_detail_no_records_found`).
86
+ - **CI De-dup (Optional)**:
87
+ - Script detects repeated values within a language and suggests moving to `common_*`.
88
+ - Reject PRs if a common phrase appears under multiple different keys across features.
89
+
90
+ ## Adding a New Language
91
+
92
+ 1. Create `lang_<code>.dart` (e.g. `lang_ko.dart`) as `Map<String, String>`.
93
+ 2. Register it in `AppTranslations.keys` using `<lang>_<COUNTRY>` (e.g. `ko_KR`).
94
+ 3. Add the corresponding `Locale('<lang>', '<COUNTRY>')` to `supportedLocales`.
95
+ 4. Ensure every key in `locale_key.dart` exists in the new language map.
96
+
97
+ ## Quality Gates (Reject if violated)
98
+
99
+ - Any new page introduces raw strings in UI.
100
+ - `locale_key.dart` is changed but any `lang_*.dart` misses the same keys.
101
+ - Key names are generic or unstable (e.g. `title1`, `text_2`, random ids).
@@ -0,0 +1,61 @@
1
+ # New Page Localization Template (GetX)
2
+
3
+ This template matches the current project structure (TranslationManager uses `enUs` / `jaJp`).
4
+
5
+ ## 1) Add keys (locale_key.dart)
6
+
7
+ Example for `customer_detail` page:
8
+
9
+ ```dart
10
+ // lib/src/locale/locale_key.dart
11
+ class LocaleKey {
12
+ // ...
13
+ static const String customerDetailTitle = 'customerDetailTitle';
14
+ static const String customerDetailSave = 'customerDetailSave';
15
+ static const String customerDetailDelete = 'customerDetailDelete';
16
+ }
17
+ ```
18
+
19
+ ## 2) Add translations (ALL languages)
20
+
21
+ `lang_en.dart`
22
+ ```dart
23
+ // lib/src/locale/lang_en.dart
24
+ import 'package:link_home/src/locale/locale_key.dart';
25
+
26
+ Map<String, String> enUs = {
27
+ // ...
28
+ LocaleKey.customerDetailTitle: 'Customer Detail',
29
+ LocaleKey.customerDetailSave: 'Save', // Prefer reuse: LocaleKey.ok if suitable
30
+ LocaleKey.customerDetailDelete: 'Delete',
31
+ };
32
+ ```
33
+
34
+ `lang_ja.dart`
35
+ ```dart
36
+ // lib/src/locale/lang_ja.dart
37
+ import 'package:link_home/src/locale/locale_key.dart';
38
+
39
+ Map<String, String> jaJp = {
40
+ // ...
41
+ LocaleKey.customerDetailTitle: '顧客詳細',
42
+ LocaleKey.customerDetailSave: '保存',
43
+ LocaleKey.customerDetailDelete: '削除',
44
+ };
45
+ ```
46
+
47
+ ## 3) Use in UI
48
+
49
+ ```dart
50
+ Text(LocaleKey.customerDetailTitle.tr)
51
+ ```
52
+
53
+ ## 4) Common Keys & Reuse (Recommended)
54
+
55
+ - Reuse common keys when the text is generic:
56
+ - `LocaleKey.ok`, `LocaleKey.cancel`, `LocaleKey.success`, `LocaleKey.error`, `LocaleKey.next`...
57
+ - Only create feature-specific keys for context-specific texts that differ from common meanings.
58
+
59
+ ## 5) Optional: Modularization to avoid conflicts
60
+
61
+ - If needed, split translations by feature (`en/<feature>.dart`, `ja/<feature>.dart`) and merge them in `lang_en.dart` / `lang_ja.dart` to keep `enUs` / `jaJp` for `TranslationManager`.
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: "UI Documentation Workflow"
3
+ description: "Generates and maintains spec/ui-workflow.md for UI flows. Invoke when creating/modifying features or when asked to update documentation."
4
+ ---
5
+
6
+ # AI Documentation Workflow (UI)
7
+
8
+ ## Goal
9
+ Automatically generate and maintain `spec/ui-workflow.md` describing business logic and user flows, so devs/AI can understand features quickly.
10
+
11
+ ## Trigger (When to Invoke)
12
+ - A new UI feature is created
13
+ - An existing UI feature is significantly modified
14
+ - User explicitly requests to update documentation
15
+
16
+ ## Workflow
17
+ 1) Analyze the Feature
18
+ - Read for EACH feature:
19
+ - `*_page.dart`: UI elements and interactions
20
+ - `interactor/*_bloc.dart` (or Controller): logic, state changes, API calls
21
+ - `binding/*_binding.dart`: dependencies
22
+ - `locale_key.dart`: terminology
23
+
24
+ 2) Write Documentation
25
+ - Append or update a section in `spec/ui-workflow.md` with:
26
+ ```
27
+ ## [Feature Name]
28
+ **Path**: lib/src/ui/<feature>
29
+
30
+ ### 1. Description
31
+ Goal: ...
32
+ Features:
33
+ - ...
34
+
35
+ ### 2. UI Structure
36
+ - Screen: <Page>
37
+ - Components: ...
38
+
39
+ ### 3. User Flow & Logic
40
+ 1) ...
41
+ 2) ...
42
+
43
+ ### 4. Key Dependencies
44
+ - ...
45
+
46
+ ### 5. Notes & Known Issues (Optional)
47
+ - Tech Debt: ...
48
+ - UX Issues: ...
49
+ - Todo: ...
50
+ ```
51
+
52
+ 3) Verification
53
+ - Ensure documented flow matches code
54
+ - Keep “User Flow” business-friendly; avoid low-level jargon
55
+ - Note raw strings, complex logic, or potential issues