speccrew 0.1.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.
- package/.speccrew/agents/speccrew-feature-designer.md +142 -0
- package/.speccrew/agents/speccrew-product-manager.md +61 -0
- package/.speccrew/agents/speccrew-system-designer.md +200 -0
- package/.speccrew/agents/speccrew-system-developer.md +238 -0
- package/.speccrew/agents/speccrew-task-worker.md +80 -0
- package/.speccrew/agents/speccrew-team-leader.md +92 -0
- package/.speccrew/agents/speccrew-test-manager.md +313 -0
- package/.speccrew/skills/speccrew-create-agents/SKILL.md +98 -0
- package/.speccrew/skills/speccrew-create-agents/templates/agents/designer-agent.md +54 -0
- package/.speccrew/skills/speccrew-create-agents/templates/agents/dev-agent.md +79 -0
- package/.speccrew/skills/speccrew-create-agents/templates/agents/test-agent.md +80 -0
- package/.speccrew/skills/speccrew-dev-backend/SKILL.md +205 -0
- package/.speccrew/skills/speccrew-dev-backend/templates/TASK-RECORD-TEMPLATE.md +118 -0
- package/.speccrew/skills/speccrew-dev-desktop/SKILL.md +258 -0
- package/.speccrew/skills/speccrew-dev-desktop/templates/TASK-RECORD-TEMPLATE.md +161 -0
- package/.speccrew/skills/speccrew-dev-frontend/SKILL.md +202 -0
- package/.speccrew/skills/speccrew-dev-frontend/templates/TASK-RECORD-TEMPLATE.md +115 -0
- package/.speccrew/skills/speccrew-dev-mobile/SKILL.md +200 -0
- package/.speccrew/skills/speccrew-dev-mobile/templates/TASK-RECORD-TEMPLATE.md +125 -0
- package/.speccrew/skills/speccrew-fd-api-contract/SKILL.md +73 -0
- package/.speccrew/skills/speccrew-fd-api-contract/templates/API-CONTRACT-TEMPLATE.md +96 -0
- package/.speccrew/skills/speccrew-fd-feature-design/SKILL.md +395 -0
- package/.speccrew/skills/speccrew-fd-feature-design/templates/FEATURE-SPEC-TEMPLATE.md +387 -0
- package/.speccrew/skills/speccrew-get-timestamp/SKILL.md +80 -0
- package/.speccrew/skills/speccrew-get-timestamp/scripts/get-timestamp.js +35 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/SKILL.md +1116 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/FEATURE-DETAIL-TEMPLATE-FASTAPI.md +462 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/FEATURE-DETAIL-TEMPLATE-JAVA.md +480 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/FEATURE-DETAIL-TEMPLATE-NET.md +464 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/FEATURE-DETAIL-TEMPLATE.md +480 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/MODULE-OVERVIEW-TEMPLATE.md +367 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/SKILL.md +667 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/STATUS-FORMATS.md +74 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/batch-orchestrator.js +176 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/get-next-batch.js +150 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/get-pending-features.js +106 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/mark-stale.js +249 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/process-batch-results.js +848 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/update-feature-status.js +226 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-init-features/SKILL.md +264 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-init-features/examples/features.json +34 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-init-features/scripts/generate-inventory.js +867 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-init-features/scripts/test-inventory.js +26 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-module-classify/SKILL.md +165 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-module-classify/scripts/apply-module-mapping.js +208 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-module-classify/scripts/extract-module-summary.js +180 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-module-classify/scripts/reindex-modules.js +358 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/SKILL.md +1055 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI-DESKTOP.md +303 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI-ELECTRON.md +327 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI-MINIAPP.md +292 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI-MOBILE.md +281 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI.md +324 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-style-extract/SKILL.md +270 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-style-extract/templates/COMPONENT-PATTERN-TEMPLATE.md +33 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-style-extract/templates/LAYOUT-PATTERN-TEMPLATE.md +33 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-style-extract/templates/PAGE-TYPE-TEMPLATE.md +33 -0
- package/.speccrew/skills/speccrew-knowledge-graph-query/SKILL.md +229 -0
- package/.speccrew/skills/speccrew-knowledge-graph-query/scripts/graph-query.js +549 -0
- package/.speccrew/skills/speccrew-knowledge-graph-write/SKILL.md +181 -0
- package/.speccrew/skills/speccrew-knowledge-graph-write/scripts/graph-write.js +651 -0
- package/.speccrew/skills/speccrew-knowledge-module-summarize/SKILL.md +305 -0
- package/.speccrew/skills/speccrew-knowledge-module-summarize/templates/MODULE-OVERVIEW-TEMPLATE.md +400 -0
- package/.speccrew/skills/speccrew-knowledge-system-summarize/SKILL.md +351 -0
- package/.speccrew/skills/speccrew-knowledge-system-summarize/templates/SYSTEM-OVERVIEW-TEMPLATE.md +294 -0
- package/.speccrew/skills/speccrew-knowledge-techs-dispatch/SKILL.md +683 -0
- package/.speccrew/skills/speccrew-knowledge-techs-dispatch/STATUS-FORMATS.md +550 -0
- package/.speccrew/skills/speccrew-knowledge-techs-dispatch/templates/techs-manifest-EXAMPLE.json +35 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/SKILL.md +1087 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/ARCHITECTURE-TEMPLATE.md +240 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/COLOR-SYSTEM-TEMPLATE.md +68 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/COMPONENT-LIBRARY-TEMPLATE.md +86 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-BUILD-TEMPLATE.md +466 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-DATA-TEMPLATE.md +432 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-DESIGN-TEMPLATE.md +1209 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-DEV-TEMPLATE.md +1433 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-SYSTEM-TEST-TEMPLATE.md +1052 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-UNIT-TEST-TEMPLATE.md +946 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/INDEX-TEMPLATE.md +29 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/PAGE-LAYOUTS-TEMPLATE.md +69 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/PAGE-TYPE-SUMMARY-TEMPLATE.md +74 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/TECH-STACK-TEMPLATE.md +232 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate-conventions/SKILL.md +628 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate-ui-style/SKILL.md +392 -0
- package/.speccrew/skills/speccrew-knowledge-techs-index/SKILL.md +489 -0
- package/.speccrew/skills/speccrew-knowledge-techs-index/templates/INDEX-TEMPLATE.md +243 -0
- package/.speccrew/skills/speccrew-knowledge-techs-init/SKILL.md +269 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/SKILL.md +562 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/BUSINESS-COMPONENTS-TEMPLATE.md +171 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/COMMON-COMPONENTS-TEMPLATE.md +177 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/COMPONENT-INDIVIDUAL-TEMPLATE.md +80 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/COMPONENT-LIBRARY-TEMPLATE.md +118 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/LAYOUT-INDIVIDUAL-TEMPLATE.md +97 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/LAYOUT-PATTERNS-TEMPLATE.md +208 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/NAVIGATION-PATTERNS-TEMPLATE.md +157 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/PAGE-TYPE-INDIVIDUAL-TEMPLATE.md +123 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/PAGE-TYPE-SUMMARY-TEMPLATE.md +58 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/SPACING-TEMPLATE.md +119 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/STYLE-SYSTEM-TEMPLATE.md +117 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/TYPOGRAPHY-TEMPLATE.md +107 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/UI-STYLE-GUIDE-TEMPLATE.md +171 -0
- package/.speccrew/skills/speccrew-pm-requirement-analysis/SKILL.md +434 -0
- package/.speccrew/skills/speccrew-pm-requirement-analysis/templates/BIZS-MODELING-TEMPLATE.md +332 -0
- package/.speccrew/skills/speccrew-pm-requirement-analysis/templates/PRD-TEMPLATE.md +200 -0
- package/.speccrew/skills/speccrew-pm-requirement-assess/SKILL.md +195 -0
- package/.speccrew/skills/speccrew-project-diagnosis/SKILL.md +208 -0
- package/.speccrew/skills/speccrew-project-diagnosis/templates/DIAGNOSIS-REPORT-TEMPLATE.md +202 -0
- package/.speccrew/skills/speccrew-sd-backend/SKILL.md +188 -0
- package/.speccrew/skills/speccrew-sd-backend/templates/INDEX-TEMPLATE.md +85 -0
- package/.speccrew/skills/speccrew-sd-backend/templates/SD-BACKEND-TEMPLATE.md +269 -0
- package/.speccrew/skills/speccrew-sd-desktop/SKILL.md +192 -0
- package/.speccrew/skills/speccrew-sd-desktop/templates/INDEX-TEMPLATE.md +271 -0
- package/.speccrew/skills/speccrew-sd-desktop/templates/SD-DESKTOP-TEMPLATE.md +673 -0
- package/.speccrew/skills/speccrew-sd-frontend/SKILL.md +176 -0
- package/.speccrew/skills/speccrew-sd-frontend/templates/INDEX-TEMPLATE.md +184 -0
- package/.speccrew/skills/speccrew-sd-frontend/templates/SD-FRONTEND-TEMPLATE.md +382 -0
- package/.speccrew/skills/speccrew-sd-mobile/SKILL.md +189 -0
- package/.speccrew/skills/speccrew-sd-mobile/templates/INDEX-TEMPLATE.md +219 -0
- package/.speccrew/skills/speccrew-sd-mobile/templates/SD-MOBILE-TEMPLATE.md +534 -0
- package/.speccrew/skills/speccrew-test-case-design/SKILL.md +284 -0
- package/.speccrew/skills/speccrew-test-case-design/templates/TEST-CASE-DESIGN-TEMPLATE.md +263 -0
- package/.speccrew/skills/speccrew-test-code-gen/SKILL.md +313 -0
- package/.speccrew/skills/speccrew-test-code-gen/templates/TEST-CODE-PLAN-TEMPLATE.md +180 -0
- package/.speccrew/skills/speccrew-test-execute/SKILL.md +283 -0
- package/.speccrew/skills/speccrew-test-execute/templates/BUG-REPORT-TEMPLATE.md +50 -0
- package/.speccrew/skills/speccrew-test-execute/templates/TEST-REPORT-TEMPLATE.md +57 -0
- package/.speccrew/skills/speccrew-workflow-diagnose/SKILL.md +155 -0
- package/LICENSE +21 -0
- package/README.ar.md +318 -0
- package/README.en.md +318 -0
- package/README.es.md +318 -0
- package/README.md +340 -0
- package/bin/cli.js +62 -0
- package/lib/commands/doctor.js +138 -0
- package/lib/commands/init.js +231 -0
- package/lib/commands/list.js +114 -0
- package/lib/commands/uninstall.js +117 -0
- package/lib/commands/update.js +351 -0
- package/lib/ide-adapters.js +73 -0
- package/lib/utils.js +104 -0
- package/package.json +28 -0
- package/workspace-template/docs/configs/document-templates.json +667 -0
- package/workspace-template/docs/configs/platform-mapping.json +194 -0
- package/workspace-template/docs/configs/tech-stack-mappings.json +313 -0
- package/workspace-template/docs/configs/validation-rules.json +87 -0
- package/workspace-template/docs/rules/mermaid-rule.md +114 -0
- package/workspace-template/docs/solutions/Agent/346/212/200/350/203/275/345/256/232/344/271/211+/351/234/200/346/261/202/346/226/207/346/241/243+UML/344/275/277/347/224/250/346/250/241/346/235/277/357/274/210ISA-95/345/205/255/346/256/265/345/274/217/350/236/215/345/220/210/347/211/210/357/274/211.md +586 -0
- package/workspace-template/docs/solutions/agent-knowledge-map.md +238 -0
- package/workspace-template/docs/solutions/bizs-knowledge-pipeline.md +678 -0
- package/workspace-template/docs/solutions/harness.md +410 -0
- package/workspace-template/docs/solutions/knowledge-incremental-sync-spec.md +943 -0
- package/workspace-template/docs/solutions/techs-knowledge-pipeline.md +803 -0
- package/workspace-template/docs/solutions/workspace-structure.md +318 -0
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
# Mobile System Design - {ModuleName}
|
|
2
|
+
|
|
3
|
+
> Feature Spec Reference: {FeatureSpecPath}
|
|
4
|
+
> API Contract Reference: {ApiContractPath}
|
|
5
|
+
> Platform: {PlatformId} | Framework: {Framework} | Language: {Language}
|
|
6
|
+
|
|
7
|
+
## 1. Design Goal
|
|
8
|
+
|
|
9
|
+
{Brief description of what this module implements, referencing Feature Spec function}
|
|
10
|
+
|
|
11
|
+
## 2. Screen Architecture
|
|
12
|
+
|
|
13
|
+
### 2.1 Screen/Widget Tree
|
|
14
|
+
|
|
15
|
+
<!-- AI-NOTE: ASCII tree showing screen/widget hierarchy. Adjust depth based on complexity. -->
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
MainScreen
|
|
19
|
+
├── AppBar
|
|
20
|
+
│ ├── Title
|
|
21
|
+
│ └── ActionButtons
|
|
22
|
+
├── Body
|
|
23
|
+
│ ├── ListView
|
|
24
|
+
│ │ └── ListItem (repeated)
|
|
25
|
+
│ └── FloatingActionButton
|
|
26
|
+
└── BottomNavigationBar
|
|
27
|
+
├── Tab1
|
|
28
|
+
├── Tab2
|
|
29
|
+
└── Tab3
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 2.2 Screen Summary Table
|
|
33
|
+
|
|
34
|
+
| Screen | Path | Type | Status | Description |
|
|
35
|
+
|--------|------|------|--------|-------------|
|
|
36
|
+
| {Name} | `{directory}/{file_name}` | Screen | [NEW]/[MODIFIED]/[EXISTING] | {Purpose} |
|
|
37
|
+
| {Name} | `{directory}/{file_name}` | Widget | [NEW]/[MODIFIED]/[EXISTING] | {Purpose} |
|
|
38
|
+
|
|
39
|
+
## 3. Screen Detail Design
|
|
40
|
+
|
|
41
|
+
<!-- AI-NOTE: Repeat Section 3.N for each screen. Focus on screens with [NEW] or [MODIFIED] status. -->
|
|
42
|
+
|
|
43
|
+
### 3.1 {ScreenName}
|
|
44
|
+
|
|
45
|
+
**Purpose**: {What this screen does}
|
|
46
|
+
|
|
47
|
+
**Props/Parameters**:
|
|
48
|
+
|
|
49
|
+
<!-- AI-NOTE: For Flutter: constructor params; for React Native: navigation params + props -->
|
|
50
|
+
|
|
51
|
+
| Parameter | Type | Required | Default | Description |
|
|
52
|
+
|-----------|------|----------|---------|-------------|
|
|
53
|
+
| {param} | {type} | Yes/No | {value} | {description} |
|
|
54
|
+
|
|
55
|
+
**Internal State**:
|
|
56
|
+
|
|
57
|
+
<!-- AI-NOTE: Include actual state management syntax from techs knowledge -->
|
|
58
|
+
|
|
59
|
+
| State | Type | Initial Value | Description |
|
|
60
|
+
|-------|------|--------------|-------------|
|
|
61
|
+
| {state} | {type} | {value} | {description} |
|
|
62
|
+
|
|
63
|
+
**Lifecycle**:
|
|
64
|
+
|
|
65
|
+
<!-- AI-NOTE: For Flutter: initState/dispose; for React Native: useEffect -->
|
|
66
|
+
|
|
67
|
+
- `initState` / `useEffect`: {description of initialization logic}
|
|
68
|
+
- `dispose` / `useEffect cleanup`: {description of cleanup logic}
|
|
69
|
+
|
|
70
|
+
**Pseudo-code**:
|
|
71
|
+
|
|
72
|
+
<!-- AI-NOTE: Use actual framework API syntax from techs knowledge. NOT generic code. -->
|
|
73
|
+
|
|
74
|
+
```dart
|
|
75
|
+
// AI-NOTE: Example for Flutter with Provider
|
|
76
|
+
// Adjust imports and syntax based on actual framework from techs knowledge
|
|
77
|
+
import 'package:flutter/material.dart';
|
|
78
|
+
import 'package:provider/provider.dart';
|
|
79
|
+
|
|
80
|
+
class {ScreenName} extends StatefulWidget {
|
|
81
|
+
final {ParamType} {paramName};
|
|
82
|
+
|
|
83
|
+
const {ScreenName}({Key? key, required this.{paramName}}) : super(key: key);
|
|
84
|
+
|
|
85
|
+
@override
|
|
86
|
+
State<{ScreenName}> createState() => _{ScreenName}State();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
class _{ScreenName}State extends State<{ScreenName}> {
|
|
90
|
+
// State variables
|
|
91
|
+
late {Type} {stateName};
|
|
92
|
+
|
|
93
|
+
@override
|
|
94
|
+
void initState() {
|
|
95
|
+
super.initState();
|
|
96
|
+
// Initialization logic
|
|
97
|
+
{stateName} = {initialValue};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@override
|
|
101
|
+
void dispose() {
|
|
102
|
+
// Cleanup logic
|
|
103
|
+
super.dispose();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
void handle{Action}() {
|
|
107
|
+
// Implementation logic
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@override
|
|
111
|
+
Widget build(BuildContext context) {
|
|
112
|
+
return Scaffold(
|
|
113
|
+
appBar: AppBar(title: Text('{title}')),
|
|
114
|
+
body: {bodyWidget},
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Referenced APIs**:
|
|
121
|
+
|
|
122
|
+
| API Name | Method | Path | Usage Context |
|
|
123
|
+
|----------|--------|------|--------------|
|
|
124
|
+
| {api} | GET/POST/PUT/DELETE | {path} | {when and why called} |
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
### 3.2 {ScreenName}
|
|
129
|
+
|
|
130
|
+
<!-- AI-NOTE: Repeat the same structure as 3.1 for each additional screen -->
|
|
131
|
+
|
|
132
|
+
**Purpose**: {What this screen does}
|
|
133
|
+
|
|
134
|
+
**Props/Parameters**:
|
|
135
|
+
|
|
136
|
+
| Parameter | Type | Required | Default | Description |
|
|
137
|
+
|-----------|------|----------|---------|-------------|
|
|
138
|
+
| {param} | {type} | Yes/No | {value} | {description} |
|
|
139
|
+
|
|
140
|
+
**Pseudo-code**:
|
|
141
|
+
|
|
142
|
+
```dart
|
|
143
|
+
// AI-NOTE: Use actual framework API syntax from techs knowledge
|
|
144
|
+
{implementation pseudo-code}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
### 3.3 Advanced Widget Patterns
|
|
150
|
+
|
|
151
|
+
<!-- AI-NOTE: Common patterns for conditional rendering, form validation, and pagination with pull-to-refresh -->
|
|
152
|
+
|
|
153
|
+
```dart
|
|
154
|
+
// Conditional rendering with loading/empty/error states
|
|
155
|
+
@override
|
|
156
|
+
Widget build(BuildContext context) {
|
|
157
|
+
if (_isLoading) {
|
|
158
|
+
return const Center(child: CircularProgressIndicator());
|
|
159
|
+
}
|
|
160
|
+
if (_error != null) {
|
|
161
|
+
return ErrorWidget(
|
|
162
|
+
message: _error!,
|
|
163
|
+
onRetry: () => _loadData(),
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
if (_items.isEmpty) {
|
|
167
|
+
return const EmptyStateWidget(message: 'No items found');
|
|
168
|
+
}
|
|
169
|
+
return ListView.builder(
|
|
170
|
+
itemCount: _items.length,
|
|
171
|
+
itemBuilder: (context, index) => ItemCard(item: _items[index]),
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Form validation with field-level errors
|
|
176
|
+
String? _validateField(String field, dynamic value) {
|
|
177
|
+
switch (field) {
|
|
178
|
+
case 'name':
|
|
179
|
+
if (value == null || (value as String).trim().isEmpty) {
|
|
180
|
+
return 'Name is required';
|
|
181
|
+
}
|
|
182
|
+
if (value.length > 100) return 'Name too long (max 100)';
|
|
183
|
+
return null;
|
|
184
|
+
case 'price':
|
|
185
|
+
if (value == null || value < 0) return 'Price must be non-negative';
|
|
186
|
+
return null;
|
|
187
|
+
default:
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Pagination with pull-to-refresh
|
|
193
|
+
Future<void> _loadMore() async {
|
|
194
|
+
if (_isLoadingMore || !_hasMore) return;
|
|
195
|
+
setState(() => _isLoadingMore = true);
|
|
196
|
+
try {
|
|
197
|
+
final result = await _api.fetchPage(_currentPage + 1);
|
|
198
|
+
setState(() {
|
|
199
|
+
_items.addAll(result.items);
|
|
200
|
+
_currentPage++;
|
|
201
|
+
_hasMore = result.items.isNotEmpty;
|
|
202
|
+
});
|
|
203
|
+
} catch (e) {
|
|
204
|
+
ScaffoldMessenger.of(context).showSnackBar(
|
|
205
|
+
SnackBar(content: Text('Load failed: ${e.toString()}')),
|
|
206
|
+
);
|
|
207
|
+
} finally {
|
|
208
|
+
setState(() => _isLoadingMore = false);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## 4. Navigation Design
|
|
216
|
+
|
|
217
|
+
### 4.1 Navigation Stack
|
|
218
|
+
|
|
219
|
+
**Route Definitions**:
|
|
220
|
+
|
|
221
|
+
<!-- AI-NOTE: Use actual router syntax from techs knowledge (GoRouter for Flutter, React Navigation for React Native) -->
|
|
222
|
+
|
|
223
|
+
```dart
|
|
224
|
+
// AI-NOTE: Example for Flutter GoRouter
|
|
225
|
+
// File: lib/router/app_router.dart
|
|
226
|
+
final GoRouter appRouter = GoRouter(
|
|
227
|
+
routes: [
|
|
228
|
+
GoRoute(
|
|
229
|
+
path: '/{route-path}',
|
|
230
|
+
name: '{routeName}',
|
|
231
|
+
builder: (context, state) => {ScreenName}(
|
|
232
|
+
{paramName}: state.params['{param}'],
|
|
233
|
+
),
|
|
234
|
+
),
|
|
235
|
+
],
|
|
236
|
+
);
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
**Deep Linking Configuration**:
|
|
240
|
+
|
|
241
|
+
<!-- AI-NOTE: Document deep link URL patterns and handling -->
|
|
242
|
+
|
|
243
|
+
| Deep Link | Target Screen | Parameters |
|
|
244
|
+
|-----------|--------------|------------|
|
|
245
|
+
| `app://{path}` | {ScreenName} | {param list} |
|
|
246
|
+
|
|
247
|
+
**Navigation Guards/Middleware**:
|
|
248
|
+
|
|
249
|
+
<!-- AI-NOTE: Document any auth guards or route guards -->
|
|
250
|
+
|
|
251
|
+
| Guard | Logic | Applied Routes |
|
|
252
|
+
|-------|-------|---------------|
|
|
253
|
+
| {guardName} | {description} | {route list} |
|
|
254
|
+
|
|
255
|
+
### 4.2 Navigation Flow
|
|
256
|
+
|
|
257
|
+
<!-- AI-NOTE: Use basic Mermaid flowchart syntax. No style definitions, no HTML tags, no nested subgraph, no direction keyword. -->
|
|
258
|
+
|
|
259
|
+
```mermaid
|
|
260
|
+
graph TD
|
|
261
|
+
A[HomeScreen] --> B[ModuleListScreen]
|
|
262
|
+
B --> C[DetailScreen]
|
|
263
|
+
C --> D[EditScreen]
|
|
264
|
+
C --> E[DeleteConfirmation]
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## 5. State Management
|
|
268
|
+
|
|
269
|
+
### 5.1 Store/Provider Design
|
|
270
|
+
|
|
271
|
+
**Store Module**: `{store-path}/{store-name}`
|
|
272
|
+
**Status**: [NEW]/[MODIFIED]/[EXISTING]
|
|
273
|
+
|
|
274
|
+
**State Definition**:
|
|
275
|
+
|
|
276
|
+
<!-- AI-NOTE: Use actual state management pattern from techs knowledge (Provider/Bloc/Riverpod for Flutter, Redux/MobX for React Native) -->
|
|
277
|
+
|
|
278
|
+
```dart
|
|
279
|
+
// AI-NOTE: Example for Flutter Provider
|
|
280
|
+
// File: lib/providers/{store-name}.dart
|
|
281
|
+
import 'package:flutter/foundation.dart';
|
|
282
|
+
|
|
283
|
+
class {StoreName}Provider with ChangeNotifier {
|
|
284
|
+
// State
|
|
285
|
+
{Type} _{stateField} = {initialValue};
|
|
286
|
+
|
|
287
|
+
// Getters
|
|
288
|
+
{Type} get {stateField} => _{stateField};
|
|
289
|
+
|
|
290
|
+
// Actions/Methods
|
|
291
|
+
Future<void> {actionName}({params}) async {
|
|
292
|
+
// Implementation
|
|
293
|
+
notifyListeners();
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
**Actions/Events and Effects**:
|
|
299
|
+
|
|
300
|
+
| Action/Event | Parameters | Description | API Calls |
|
|
301
|
+
|-------------|-----------|-------------|-----------|
|
|
302
|
+
| {action} | {params} | {description} | {api references} |
|
|
303
|
+
|
|
304
|
+
### 5.2 Advanced Provider Patterns
|
|
305
|
+
|
|
306
|
+
<!-- AI-NOTE: Combined data loading with error state, computed properties, and optimistic updates -->
|
|
307
|
+
|
|
308
|
+
```dart
|
|
309
|
+
// Combined data loading with error state management
|
|
310
|
+
class OrderListProvider with ChangeNotifier {
|
|
311
|
+
List<Order> _orders = [];
|
|
312
|
+
bool _isLoading = false;
|
|
313
|
+
String? _error;
|
|
314
|
+
int _currentPage = 0;
|
|
315
|
+
bool _hasMore = true;
|
|
316
|
+
|
|
317
|
+
List<Order> get orders => _orders;
|
|
318
|
+
bool get isLoading => _isLoading;
|
|
319
|
+
String? get error => _error;
|
|
320
|
+
bool get hasMore => _hasMore;
|
|
321
|
+
|
|
322
|
+
// Computed property - filtered orders
|
|
323
|
+
List<Order> get pendingOrders =>
|
|
324
|
+
_orders.where((o) => o.status == OrderStatus.pending).toList();
|
|
325
|
+
|
|
326
|
+
Future<void> loadOrders({bool refresh = false}) async {
|
|
327
|
+
if (_isLoading) return;
|
|
328
|
+
if (refresh) {
|
|
329
|
+
_currentPage = 0;
|
|
330
|
+
_hasMore = true;
|
|
331
|
+
}
|
|
332
|
+
_isLoading = true;
|
|
333
|
+
_error = null;
|
|
334
|
+
notifyListeners();
|
|
335
|
+
|
|
336
|
+
try {
|
|
337
|
+
final result = await _api.getOrders(page: _currentPage);
|
|
338
|
+
if (refresh) {
|
|
339
|
+
_orders = result.items;
|
|
340
|
+
} else {
|
|
341
|
+
_orders.addAll(result.items);
|
|
342
|
+
}
|
|
343
|
+
_hasMore = result.items.isNotEmpty;
|
|
344
|
+
_currentPage++;
|
|
345
|
+
} catch (e) {
|
|
346
|
+
_error = e.toString();
|
|
347
|
+
} finally {
|
|
348
|
+
_isLoading = false;
|
|
349
|
+
notifyListeners();
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// Optimistic update with rollback
|
|
354
|
+
Future<void> updateOrderStatus(String id, OrderStatus status) async {
|
|
355
|
+
final index = _orders.indexWhere((o) => o.id == id);
|
|
356
|
+
if (index == -1) return;
|
|
357
|
+
|
|
358
|
+
final previousStatus = _orders[index].status;
|
|
359
|
+
_orders[index] = _orders[index].copyWith(status: status);
|
|
360
|
+
notifyListeners();
|
|
361
|
+
|
|
362
|
+
try {
|
|
363
|
+
await _api.updateOrder(id, {'status': status.value});
|
|
364
|
+
} catch (e) {
|
|
365
|
+
// Rollback
|
|
366
|
+
_orders[index] = _orders[index].copyWith(status: previousStatus);
|
|
367
|
+
notifyListeners();
|
|
368
|
+
rethrow;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
## 6. API Layer
|
|
375
|
+
|
|
376
|
+
### 6.1 API Functions
|
|
377
|
+
|
|
378
|
+
<!-- AI-NOTE: Follow actual API layer patterns from conventions-dev.md. Include request/response types. -->
|
|
379
|
+
|
|
380
|
+
```dart
|
|
381
|
+
// AI-NOTE: Example for Flutter with Dio
|
|
382
|
+
// File: lib/api/{module}.dart
|
|
383
|
+
import 'package:dio/dio.dart';
|
|
384
|
+
|
|
385
|
+
class {Module}Api {
|
|
386
|
+
final Dio _dio;
|
|
387
|
+
|
|
388
|
+
{Module}Api(this._dio);
|
|
389
|
+
|
|
390
|
+
Future<{ResponseType}> {functionName}({RequestType} params) async {
|
|
391
|
+
final response = await _dio.{method}('{path}', data: params);
|
|
392
|
+
return {ResponseType}.fromJson(response.data);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### 6.2 Error Handling
|
|
398
|
+
|
|
399
|
+
| Error Code | HTTP Status | Mobile Handling | User Feedback |
|
|
400
|
+
|-----------|-------------|-----------------|---------------|
|
|
401
|
+
| {code} | {status} | {handling logic} | {message/snackbar/dialog} |
|
|
402
|
+
|
|
403
|
+
### 6.3 Caching Strategy
|
|
404
|
+
|
|
405
|
+
<!-- AI-NOTE: Document API response caching approach if applicable -->
|
|
406
|
+
|
|
407
|
+
| API | Cache Strategy | TTL | Invalidation Trigger |
|
|
408
|
+
|-----|---------------|-----|---------------------|
|
|
409
|
+
| {api} | {strategy} | {duration} | {trigger} |
|
|
410
|
+
|
|
411
|
+
### 6.4 API Error Handling & Cache Strategy
|
|
412
|
+
|
|
413
|
+
<!-- AI-NOTE: Unified error handling with token refresh, retry logic, and simple TTL cache -->
|
|
414
|
+
|
|
415
|
+
```dart
|
|
416
|
+
// Unified API error handling
|
|
417
|
+
Future<T> safeApiCall<T>(Future<T> Function() apiCall) async {
|
|
418
|
+
try {
|
|
419
|
+
return await apiCall();
|
|
420
|
+
} on DioException catch (e) {
|
|
421
|
+
if (e.response?.statusCode == 401) {
|
|
422
|
+
// Token expired - trigger refresh and retry
|
|
423
|
+
await _authProvider.refreshToken();
|
|
424
|
+
return await apiCall(); // Retry once
|
|
425
|
+
}
|
|
426
|
+
if (e.response?.statusCode == 422) {
|
|
427
|
+
// Validation error
|
|
428
|
+
throw ValidationException(e.response?.data['errors']);
|
|
429
|
+
}
|
|
430
|
+
if (e.type == DioExceptionType.connectionTimeout ||
|
|
431
|
+
e.type == DioExceptionType.receiveTimeout) {
|
|
432
|
+
throw NetworkException('Connection timeout, please check network');
|
|
433
|
+
}
|
|
434
|
+
rethrow;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// Request retry with exponential backoff
|
|
439
|
+
Future<T> withRetry<T>(Future<T> Function() fn, {int maxRetries = 3}) async {
|
|
440
|
+
for (int i = 0; i < maxRetries; i++) {
|
|
441
|
+
try {
|
|
442
|
+
return await fn();
|
|
443
|
+
} catch (e) {
|
|
444
|
+
if (i == maxRetries - 1) rethrow;
|
|
445
|
+
await Future.delayed(Duration(seconds: (1 << i))); // 1s, 2s, 4s
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
throw Exception('Unreachable');
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// Simple cache with TTL
|
|
452
|
+
final Map<String, _CacheEntry> _cache = {};
|
|
453
|
+
|
|
454
|
+
Future<List<Item>> fetchItems({bool forceRefresh = false}) async {
|
|
455
|
+
final cacheKey = 'items_list';
|
|
456
|
+
if (!forceRefresh && _cache.containsKey(cacheKey)) {
|
|
457
|
+
final entry = _cache[cacheKey]!;
|
|
458
|
+
if (DateTime.now().difference(entry.timestamp).inMinutes < 5) {
|
|
459
|
+
return entry.data as List<Item>;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
final items = await _dio.get<List<Item>>('/items');
|
|
463
|
+
_cache[cacheKey] = _CacheEntry(data: items, timestamp: DateTime.now());
|
|
464
|
+
return items;
|
|
465
|
+
}
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
## 7. Local Storage Design
|
|
469
|
+
|
|
470
|
+
### 7.1 Storage Strategy
|
|
471
|
+
|
|
472
|
+
<!-- AI-NOTE: Document storage solution: SharedPreferences, Hive, SQLite, MMKV, etc. -->
|
|
473
|
+
|
|
474
|
+
| Data Type | Storage Solution | Key/Table | Notes |
|
|
475
|
+
|-----------|-----------------|-----------|-------|
|
|
476
|
+
| {data} | {solution} | {key} | {notes} |
|
|
477
|
+
|
|
478
|
+
### 7.2 Data Schema
|
|
479
|
+
|
|
480
|
+
<!-- AI-NOTE: If using structured storage (SQLite, Hive), document schema -->
|
|
481
|
+
|
|
482
|
+
```dart
|
|
483
|
+
// AI-NOTE: Example Hive type adapter
|
|
484
|
+
@HiveType(typeId: 1)
|
|
485
|
+
class {ModelName} {
|
|
486
|
+
@HiveField(0)
|
|
487
|
+
final String id;
|
|
488
|
+
|
|
489
|
+
@HiveField(1)
|
|
490
|
+
final String name;
|
|
491
|
+
}
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
### 7.3 Sync Strategy
|
|
495
|
+
|
|
496
|
+
<!-- AI-NOTE: Document offline-first patterns if applicable -->
|
|
497
|
+
|
|
498
|
+
| Scenario | Strategy | Conflict Resolution |
|
|
499
|
+
|----------|----------|---------------------|
|
|
500
|
+
| {scenario} | {strategy} | {resolution} |
|
|
501
|
+
|
|
502
|
+
## 8. Platform-Specific Features
|
|
503
|
+
|
|
504
|
+
### 8.1 Permissions Required
|
|
505
|
+
|
|
506
|
+
| Permission | Platform | Purpose | Fallback |
|
|
507
|
+
|------------|----------|---------|----------|
|
|
508
|
+
| {permission} | iOS/Android/Both | {purpose} | {fallback behavior} |
|
|
509
|
+
|
|
510
|
+
### 8.2 Native Integration
|
|
511
|
+
|
|
512
|
+
| Feature | Implementation | Platform Channel | Notes |
|
|
513
|
+
|---------|---------------|------------------|-------|
|
|
514
|
+
| {feature} | {plugin/package} | {channel name} | {notes} |
|
|
515
|
+
|
|
516
|
+
## 9. App Lifecycle Handling
|
|
517
|
+
|
|
518
|
+
- **Background/Foreground Transitions**: {description}
|
|
519
|
+
- **State Persistence on App Kill**: {description}
|
|
520
|
+
- **Push Notification Handling**: {description for different app states}
|
|
521
|
+
|
|
522
|
+
## 10. Unit Test Points
|
|
523
|
+
|
|
524
|
+
| Test Target | Test Scenario | Expected Behavior |
|
|
525
|
+
|-------------|--------------|-------------------|
|
|
526
|
+
| {screen/widget} | {scenario description} | {expected result} |
|
|
527
|
+
| {provider/store} | {scenario description} | {expected result} |
|
|
528
|
+
| {api function} | {scenario description} | {expected result} |
|
|
529
|
+
|
|
530
|
+
---
|
|
531
|
+
|
|
532
|
+
**Document Status**: Draft / In Review / Published
|
|
533
|
+
**Last Updated**: {Date}
|
|
534
|
+
**Related Feature Spec**: [{Feature Name}]({FeatureSpecPath})
|