ai-flow-dev 2.1.3 → 2.1.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.
Files changed (96) hide show
  1. package/README.md +25 -38
  2. package/dist/cli.js +68 -46
  3. package/dist/cli.js.map +1 -1
  4. package/package.json +5 -5
  5. package/prompts/backend/flow-build-phase-0.md +31 -63
  6. package/prompts/backend/flow-build-phase-1.md +9 -17
  7. package/prompts/backend/flow-build-phase-10.md +199 -585
  8. package/prompts/backend/flow-build-phase-2.md +152 -86
  9. package/prompts/backend/flow-build-phase-3.md +108 -68
  10. package/prompts/backend/flow-build-phase-4.md +5 -8
  11. package/prompts/backend/flow-build-phase-5.md +39 -12
  12. package/prompts/backend/flow-build-phase-6.md +29 -8
  13. package/prompts/backend/flow-build-phase-7.md +120 -40
  14. package/prompts/backend/flow-build-phase-8.md +28 -65
  15. package/prompts/backend/flow-build-phase-9.md +267 -1298
  16. package/prompts/backend/flow-build.md +881 -957
  17. package/prompts/backend/flow-dev-commit.md +27 -50
  18. package/prompts/backend/flow-dev-feature.md +1929 -2017
  19. package/prompts/backend/flow-dev-fix.md +936 -964
  20. package/prompts/backend/flow-dev-refactor.md +672 -701
  21. package/prompts/backend/flow-dev-review.md +356 -389
  22. package/prompts/backend/flow-dev-work.md +1066 -1118
  23. package/prompts/backend/flow-docs-sync.md +20 -196
  24. package/prompts/frontend/flow-build-phase-0.md +503 -484
  25. package/prompts/frontend/flow-build-phase-1.md +445 -433
  26. package/prompts/frontend/flow-build-phase-2.md +910 -957
  27. package/prompts/frontend/flow-build-phase-3.md +692 -664
  28. package/prompts/frontend/flow-build-phase-4.md +478 -463
  29. package/prompts/frontend/flow-build-phase-5.md +488 -467
  30. package/prompts/frontend/flow-build-phase-6.md +571 -550
  31. package/prompts/frontend/flow-build-phase-7.md +560 -592
  32. package/prompts/frontend/flow-build-phase-8.md +17 -42
  33. package/prompts/frontend/flow-build.md +457 -503
  34. package/prompts/frontend/flow-docs-sync.md +14 -35
  35. package/prompts/mobile/flow-build-phase-0.md +104 -97
  36. package/prompts/mobile/flow-build-phase-1.md +137 -122
  37. package/prompts/mobile/flow-build-phase-2.md +123 -130
  38. package/prompts/mobile/flow-build-phase-3.md +144 -149
  39. package/prompts/mobile/flow-build-phase-4.md +140 -132
  40. package/prompts/mobile/flow-build-phase-5.md +70 -70
  41. package/prompts/mobile/flow-build-phase-6.md +136 -134
  42. package/prompts/mobile/flow-build-phase-7.md +24 -58
  43. package/prompts/mobile/flow-build-phase-8.md +17 -42
  44. package/prompts/mobile/flow-build.md +47 -97
  45. package/prompts/mobile/flow-docs-sync.md +13 -32
  46. package/prompts/shared/mermaid-guidelines.md +106 -0
  47. package/prompts/shared/scope-levels.md +126 -0
  48. package/prompts/shared/story-points.md +65 -0
  49. package/prompts/shared/task-format.md +86 -0
  50. package/templates/AGENT.template.md +194 -15
  51. package/templates/backend/README.template.md +2 -32
  52. package/templates/backend/ai-instructions.template.md +2 -32
  53. package/templates/backend/copilot-instructions.template.md +2 -22
  54. package/templates/backend/docs/api.template.md +89 -20
  55. package/templates/backend/docs/architecture.template.md +165 -53
  56. package/templates/backend/docs/business-flows.template.md +7 -14
  57. package/templates/backend/docs/code-standards.template.md +2 -38
  58. package/templates/backend/docs/contributing.template.md +2 -16
  59. package/templates/backend/docs/data-model.template.md +125 -21
  60. package/templates/backend/docs/operations.template.md +179 -50
  61. package/templates/backend/docs/testing.template.md +2 -42
  62. package/templates/backend/project-brief.template.md +2 -28
  63. package/templates/backend/specs/configuration.template.md +2 -14
  64. package/templates/backend/specs/security.template.md +2 -32
  65. package/templates/frontend/README.template.md +2 -18
  66. package/templates/frontend/ai-instructions.template.md +2 -20
  67. package/templates/frontend/docs/api-integration.template.md +12 -30
  68. package/templates/frontend/docs/components.template.md +2 -28
  69. package/templates/frontend/docs/error-handling.template.md +11 -27
  70. package/templates/frontend/docs/operations.template.md +8 -18
  71. package/templates/frontend/docs/performance.template.md +8 -18
  72. package/templates/frontend/docs/pwa.template.md +8 -18
  73. package/templates/frontend/docs/state-management.template.md +2 -28
  74. package/templates/frontend/docs/styling.template.md +2 -26
  75. package/templates/frontend/docs/testing.template.md +2 -28
  76. package/templates/frontend/project-brief.template.md +2 -16
  77. package/templates/frontend/specs/accessibility.template.md +8 -18
  78. package/templates/frontend/specs/configuration.template.md +2 -24
  79. package/templates/frontend/specs/security.template.md +10 -24
  80. package/templates/fullstack/README.template.md +17 -47
  81. package/templates/fullstack/ai-instructions.template.md +17 -45
  82. package/templates/fullstack/project-brief.template.md +16 -42
  83. package/templates/fullstack/specs/configuration.template.md +16 -42
  84. package/templates/mobile/README.template.md +11 -29
  85. package/templates/mobile/ai-instructions.template.md +11 -27
  86. package/templates/mobile/docs/app-store.template.md +11 -29
  87. package/templates/mobile/docs/architecture.template.md +14 -38
  88. package/templates/mobile/docs/native-features.template.md +16 -44
  89. package/templates/mobile/docs/navigation.template.md +9 -23
  90. package/templates/mobile/docs/offline-strategy.template.md +10 -26
  91. package/templates/mobile/docs/permissions.template.md +9 -23
  92. package/templates/mobile/docs/state-management.template.md +12 -32
  93. package/templates/mobile/docs/testing.template.md +14 -38
  94. package/templates/mobile/project-brief.template.md +12 -30
  95. package/templates/mobile/specs/build-configuration.template.md +10 -26
  96. package/templates/mobile/specs/deployment.template.md +9 -23
@@ -1,496 +1,515 @@
1
- # Phase 0: Context Discovery (Frontend)
2
-
3
- **⚡ AUTOMATED ANALYSIS - Minimal User Input Required**
4
-
5
- This phase automatically analyzes your existing frontend codebase to pre-populate answers for the build questionnaire.
6
-
1
+ # Phase 0: Context Discovery (Frontend)
2
+
3
+ **⚡ AUTOMATED ANALYSIS - Minimal User Input Required**
4
+
5
+ This phase automatically analyzes your existing frontend codebase to pre-populate answers for the build questionnaire.
7
6
  ---
8
-
9
- ## 🎯 Objective
10
-
11
- Detect the current frontend stack, architecture patterns, and configuration from existing code to:
12
-
13
- 1. **Skip redundant questions** - Don't ask what can be detected
14
- 2. **Validate assumptions** - Confirm detected patterns with user
15
- 3. **Save time** - Reduce questionnaire from ~90 min to ~40 min
16
- 4. **Maintain accuracy** - User can override any detection
17
-
7
+ ## 🎯 Objective
8
+
9
+ Detect the current frontend stack, architecture patterns, and configuration from existing code to:
10
+
11
+ 1. **Skip redundant questions** - Don't ask what can be detected
12
+ 2. **Validate assumptions** - Confirm detected patterns with user
13
+ 3. **Save time** - Reduce questionnaire from ~90 min to ~40 min
14
+ 4. **Maintain accuracy** - User can override any detection
18
15
  ---
19
-
20
- ## 📋 Detection Layers (Progressive)
21
-
22
- ### Layer 0: Cache Check (0-2 seconds)
23
-
24
- Check if `.ai-flow/cache/frontend-context.json` exists and is fresh (<7 days old).
25
-
26
- **If found:**
27
- ```json
28
- {
29
- "framework": "React",
30
- "frameworkVersion": "18.2.0",
31
- "buildTool": "Vite",
32
- "typescript": true,
33
- "stateManagement": "Zustand",
34
- "styling": "Tailwind CSS",
35
- "componentPattern": "Atomic Design",
36
- "lastAnalyzed": "2025-01-20T10:30:00Z"
37
- }
38
- ```
39
-
40
- **Action:** Ask user: "Found cached analysis from X days ago. Use it? (Y/n)"
41
-
42
- **If yes:** Skip to validation step
43
-
44
- **If no or cache doesn't exist:** Proceed to Layer 1
45
-
16
+ ## 📋 Detection Layers (Progressive)
17
+
18
+ ### Layer 0: Cache Check (0-2 seconds)
19
+
20
+ Check if `.ai-flow/cache/frontend-context.json` exists and is fresh (<7 days old).
21
+
22
+ **If found:**
23
+
24
+ ```json
25
+ {
26
+ "framework": "React",
27
+ "frameworkVersion": "18.2.0",
28
+ "buildTool": "Vite",
29
+ "typescript": true,
30
+ "stateManagement": "Zustand",
31
+ "styling": "Tailwind CSS",
32
+ "componentPattern": "Atomic Design",
33
+ "lastAnalyzed": "2025-01-20T10:30:00Z"
34
+ }
35
+ ```
36
+
37
+ **Action:** Ask user: "Found cached analysis from X days ago. Use it? (Y/n)"
38
+
39
+ **If yes:** Skip to validation step
40
+
41
+ **If no or cache doesn't exist:** Proceed to Layer 1
46
42
  ---
47
-
48
- ### Layer 1: Fast Metadata Scan (10-20 seconds)
49
-
50
- **Purpose:** Detect framework, build tool, package manager, TypeScript
51
-
52
- #### Files to Check
53
-
54
- 1. **package.json** (REQUIRED)
55
- 2. **vite.config.* / webpack.config.* / angular.json** (build tool)
56
- 3. **tsconfig.json** (TypeScript)
57
- 4. **tailwind.config.* / postcss.config.*** (styling)
58
-
59
- #### Detection Logic
60
-
61
- ```typescript
62
- // 1. Read package.json
63
- const pkg = JSON.parse(await fs.readFile('package.json', 'utf-8'));
64
-
65
- // 2. Detect UI Framework
66
- const framework =
67
- pkg.dependencies?.react ? 'React' :
68
- pkg.dependencies?.vue ? 'Vue' :
69
- pkg.dependencies?.['@angular/core'] ? 'Angular' :
70
- pkg.dependencies?.svelte ? 'Svelte' :
71
- pkg.dependencies?.['solid-js'] ? 'Solid' :
72
- null;
73
-
74
- // 3. Detect Meta-Framework
75
- const metaFramework =
76
- pkg.dependencies?.next ? 'Next.js' :
77
- pkg.dependencies?.nuxt ? 'Nuxt' :
78
- pkg.dependencies?.['@analogjs/platform'] ? 'Analog' :
79
- pkg.dependencies?.['@sveltejs/kit'] ? 'SvelteKit' :
80
- pkg.dependencies?.['solid-start'] ? 'Solid Start' :
81
- null;
82
-
83
- // 4. Detect Build Tool
84
- const buildTool =
85
- await fs.exists('vite.config.ts') || await fs.exists('vite.config.js') ? 'Vite' :
86
- await fs.exists('webpack.config.js') ? 'Webpack' :
87
- await fs.exists('angular.json') ? 'Angular CLI' :
88
- await fs.exists('rollup.config.js') ? 'Rollup' :
89
- metaFramework ? `${metaFramework} (built-in)` :
90
- 'Unknown';
91
-
92
- // 5. Detect TypeScript
93
- const typescript = await fs.exists('tsconfig.json');
94
-
95
- // 6. Detect State Management
96
- const stateManagement =
97
- pkg.dependencies?.zustand ? 'Zustand' :
98
- pkg.dependencies?.['@reduxjs/toolkit'] ? 'Redux Toolkit' :
99
- pkg.dependencies?.pinia ? 'Pinia' :
100
- pkg.dependencies?.['@ngrx/store'] ? 'NgRx' :
101
- pkg.dependencies?.xstate ? 'XState' :
102
- null;
103
-
104
- // 7. Detect Data Fetching
105
- const dataFetching =
106
- pkg.dependencies?.['@tanstack/react-query'] || pkg.dependencies?.['@tanstack/vue-query'] ? 'TanStack Query' :
107
- pkg.dependencies?.swr ? 'SWR' :
108
- pkg.dependencies?.['@apollo/client'] ? 'Apollo Client' :
109
- pkg.dependencies?.['@urql/core'] ? 'urql' :
110
- null;
111
-
112
- // 8. Detect Styling
113
- const styling =
114
- pkg.devDependencies?.tailwindcss || pkg.dependencies?.tailwindcss ? 'Tailwind CSS' :
115
- pkg.dependencies?.['styled-components'] ? 'Styled Components' :
116
- pkg.dependencies?.['@emotion/react'] ? 'Emotion' :
117
- await fs.exists('*.module.css') ? 'CSS Modules' :
118
- pkg.dependencies?.sass || pkg.devDependencies?.sass ? 'Sass/SCSS' :
119
- null;
120
-
121
- // 9. Detect Component Library
122
- const componentLibrary =
123
- pkg.dependencies?.['@mui/material'] ? 'Material UI' :
124
- pkg.dependencies?.['@chakra-ui/react'] ? 'Chakra UI' :
125
- pkg.dependencies?.antd ? 'Ant Design' :
126
- pkg.dependencies?.vuetify ? 'Vuetify' :
127
- pkg.dependencies?.['@angular/material'] ? 'Angular Material' :
128
- pkg.dependencies?.['@shadcn/ui'] ? 'shadcn/ui' :
129
- null;
130
-
131
- // 10. Detect Testing
132
- const unitTest =
133
- pkg.devDependencies?.vitest ? 'Vitest' :
134
- pkg.devDependencies?.jest ? 'Jest' :
135
- pkg.devDependencies?.['@jest/core'] ? 'Jest' :
136
- null;
137
-
138
- const e2eTest =
139
- pkg.devDependencies?.['@playwright/test'] ? 'Playwright' :
140
- pkg.devDependencies?.cypress ? 'Cypress' :
141
- pkg.devDependencies?.puppeteer ? 'Puppeteer' :
142
- null;
143
- ```
144
-
145
- #### Layer 1 Output
146
-
147
- ```
148
- DETECTED:
149
-
150
- Framework: React 18.2.0 (with Next.js 14.0.0)
151
- Build Tool: Vite 5.0.0
152
- TypeScript: Yes
153
- State Management: Zustand 4.4.0
154
- Data Fetching: TanStack Query 5.0.0
155
- Styling: Tailwind CSS 3.3.0
156
- Component Library: None
157
- Testing: Vitest + Playwright
158
-
159
- Continue to Layer 2 for structural analysis? (Y/n)
160
- ```
161
-
43
+ ### Layer 1: Fast Metadata Scan (10-20 seconds)
44
+
45
+ **Purpose:** Detect framework, build tool, package manager, TypeScript
46
+
47
+ #### Files to Check
48
+
49
+ 1. **package.json** (REQUIRED)
50
+ 2. **vite.config._ / webpack.config._ / angular.json** (build tool)
51
+ 3. **tsconfig.json** (TypeScript)
52
+ 4. **tailwind.config._ / postcss.config._** (styling)
53
+
54
+ #### Detection Logic
55
+
56
+ ```typescript
57
+ // 1. Read package.json
58
+ const pkg = JSON.parse(await fs.readFile('package.json', 'utf-8'));
59
+
60
+ // 2. Detect UI Framework
61
+ const framework = pkg.dependencies?.react
62
+ ? 'React'
63
+ : pkg.dependencies?.vue
64
+ ? 'Vue'
65
+ : pkg.dependencies?.['@angular/core']
66
+ ? 'Angular'
67
+ : pkg.dependencies?.svelte
68
+ ? 'Svelte'
69
+ : pkg.dependencies?.['solid-js']
70
+ ? 'Solid'
71
+ : null;
72
+
73
+ // 3. Detect Meta-Framework
74
+ const metaFramework = pkg.dependencies?.next
75
+ ? 'Next.js'
76
+ : pkg.dependencies?.nuxt
77
+ ? 'Nuxt'
78
+ : pkg.dependencies?.['@analogjs/platform']
79
+ ? 'Analog'
80
+ : pkg.dependencies?.['@sveltejs/kit']
81
+ ? 'SvelteKit'
82
+ : pkg.dependencies?.['solid-start']
83
+ ? 'Solid Start'
84
+ : null;
85
+
86
+ // 4. Detect Build Tool
87
+ const buildTool =
88
+ (await fs.exists('vite.config.ts')) || (await fs.exists('vite.config.js'))
89
+ ? 'Vite'
90
+ : (await fs.exists('webpack.config.js'))
91
+ ? 'Webpack'
92
+ : (await fs.exists('angular.json'))
93
+ ? 'Angular CLI'
94
+ : (await fs.exists('rollup.config.js'))
95
+ ? 'Rollup'
96
+ : metaFramework
97
+ ? `${metaFramework} (built-in)`
98
+ : 'Unknown';
99
+
100
+ // 5. Detect TypeScript
101
+ const typescript = await fs.exists('tsconfig.json');
102
+
103
+ // 6. Detect State Management
104
+ const stateManagement = pkg.dependencies?.zustand
105
+ ? 'Zustand'
106
+ : pkg.dependencies?.['@reduxjs/toolkit']
107
+ ? 'Redux Toolkit'
108
+ : pkg.dependencies?.pinia
109
+ ? 'Pinia'
110
+ : pkg.dependencies?.['@ngrx/store']
111
+ ? 'NgRx'
112
+ : pkg.dependencies?.xstate
113
+ ? 'XState'
114
+ : null;
115
+
116
+ // 7. Detect Data Fetching
117
+ const dataFetching =
118
+ pkg.dependencies?.['@tanstack/react-query'] || pkg.dependencies?.['@tanstack/vue-query']
119
+ ? 'TanStack Query'
120
+ : pkg.dependencies?.swr
121
+ ? 'SWR'
122
+ : pkg.dependencies?.['@apollo/client']
123
+ ? 'Apollo Client'
124
+ : pkg.dependencies?.['@urql/core']
125
+ ? 'urql'
126
+ : null;
127
+
128
+ // 8. Detect Styling
129
+ const styling =
130
+ pkg.devDependencies?.tailwindcss || pkg.dependencies?.tailwindcss
131
+ ? 'Tailwind CSS'
132
+ : pkg.dependencies?.['styled-components']
133
+ ? 'Styled Components'
134
+ : pkg.dependencies?.['@emotion/react']
135
+ ? 'Emotion'
136
+ : (await fs.exists('*.module.css'))
137
+ ? 'CSS Modules'
138
+ : pkg.dependencies?.sass || pkg.devDependencies?.sass
139
+ ? 'Sass/SCSS'
140
+ : null;
141
+
142
+ // 9. Detect Component Library
143
+ const componentLibrary = pkg.dependencies?.['@mui/material']
144
+ ? 'Material UI'
145
+ : pkg.dependencies?.['@chakra-ui/react']
146
+ ? 'Chakra UI'
147
+ : pkg.dependencies?.antd
148
+ ? 'Ant Design'
149
+ : pkg.dependencies?.vuetify
150
+ ? 'Vuetify'
151
+ : pkg.dependencies?.['@angular/material']
152
+ ? 'Angular Material'
153
+ : pkg.dependencies?.['@shadcn/ui']
154
+ ? 'shadcn/ui'
155
+ : null;
156
+
157
+ // 10. Detect Testing
158
+ const unitTest = pkg.devDependencies?.vitest
159
+ ? 'Vitest'
160
+ : pkg.devDependencies?.jest
161
+ ? 'Jest'
162
+ : pkg.devDependencies?.['@jest/core']
163
+ ? 'Jest'
164
+ : null;
165
+
166
+ const e2eTest = pkg.devDependencies?.['@playwright/test']
167
+ ? 'Playwright'
168
+ : pkg.devDependencies?.cypress
169
+ ? 'Cypress'
170
+ : pkg.devDependencies?.puppeteer
171
+ ? 'Puppeteer'
172
+ : null;
173
+ ```
174
+
175
+ #### Layer 1 Output
176
+
177
+ ```
178
+ ✅ DETECTED:
179
+
180
+ Framework: React 18.2.0 (with Next.js 14.0.0)
181
+ Build Tool: Vite 5.0.0
182
+ TypeScript: Yes
183
+ State Management: Zustand 4.4.0
184
+ Data Fetching: TanStack Query 5.0.0
185
+ Styling: Tailwind CSS 3.3.0
186
+ Component Library: None
187
+ Testing: Vitest + Playwright
188
+
189
+ Continue to Layer 2 for structural analysis? (Y/n)
190
+ ```
162
191
  ---
163
-
164
- ### Layer 2: Structural Analysis (30-90 seconds)
165
-
166
- **Purpose:** Analyze component structure, routing, and architecture patterns
167
-
168
- #### Files to Analyze
169
-
170
- - **Component files:** `src/**/*.{jsx,tsx,vue,svelte}`
171
- - **Routes:** `src/routes/**`, `src/pages/**`, `app/**`
172
- - **Store files:** `src/store/**`, `src/state/**`
173
- - **Config files:** `src/config/**`
174
-
175
- #### Detection Patterns
176
-
177
- ```typescript
178
- // 1. Component Pattern Detection
179
- const componentPattern = detectComponentPattern(srcFiles);
180
-
181
- function detectComponentPattern(files: string[]): string {
182
- const hasAtomic = files.some(f =>
183
- f.includes('/atoms/') || f.includes('/molecules/') || f.includes('/organisms/')
184
- );
185
- const hasFeatures = files.some(f => f.includes('/features/'));
186
- const hasDomains = files.some(f => f.includes('/domains/'));
187
- const hasPages = files.some(f => f.includes('/pages/'));
188
-
189
- if (hasAtomic) return 'Atomic Design';
190
- if (hasFeatures) return 'Feature-based';
191
- if (hasDomains) return 'Domain-driven';
192
- if (hasPages) return 'Pages-based';
193
- return 'Flat';
194
- }
195
-
196
- // 2. Routing Strategy
197
- const routingStrategy = detectRouting(srcFiles);
198
-
199
- function detectRouting(files: string[]): string {
200
- const hasAppDir = files.some(f => f.startsWith('app/'));
201
- const hasPagesDir = files.some(f => f.startsWith('pages/'));
202
- const hasSrcRoutes = files.some(f => f.includes('/routes/'));
203
-
204
- if (hasAppDir) return 'App Router (Next.js 13+)';
205
- if (hasPagesDir) return 'Pages Router';
206
- if (hasSrcRoutes) return 'File-based routing';
207
-
208
- // Check for react-router/vue-router in code
209
- const hasReactRouter = files.some(f => {
210
- const content = fs.readFileSync(f, 'utf-8');
211
- return content.includes('react-router-dom');
212
- });
213
-
214
- if (hasReactRouter) return 'React Router (code-based)';
215
- return 'Unknown';
216
- }
217
-
218
- // 3. API Integration Pattern
219
- const apiPattern = detectAPIPattern(srcFiles);
220
-
221
- function detectAPIPattern(files: string[]): string {
222
- const hasApiDir = files.some(f => f.includes('/api/'));
223
- const hasServicesDir = files.some(f => f.includes('/services/'));
224
- const hasHooksDir = files.some(f => f.includes('/hooks/use') && f.includes('query'));
225
-
226
- if (hasHooksDir) return 'Custom hooks with TanStack Query';
227
- if (hasServicesDir) return 'Service layer pattern';
228
- if (hasApiDir) return 'API client pattern';
229
- return 'Unknown';
230
- }
231
-
232
- // 4. Component Examples (Extract 2-3 representative components)
233
- const componentExamples = extractComponentExamples(srcFiles);
234
-
235
- function extractComponentExamples(files: string[]): Component[] {
236
- // Find 2-3 well-structured components
237
- const candidates = files.filter(f => {
238
- const content = fs.readFileSync(f, 'utf-8');
239
- return content.includes('export') && content.length > 50 && content.length < 500;
240
- });
241
-
242
- return candidates.slice(0, 3).map(file => ({
243
- name: path.basename(file, path.extname(file)),
244
- path: file,
245
- snippet: fs.readFileSync(file, 'utf-8').slice(0, 200)
246
- }));
247
- }
248
- ```
249
-
250
- #### Layer 2 Output
251
-
252
- ```
253
- ✅ ARCHITECTURE DETECTED:
254
-
255
- Component Pattern: Atomic Design
256
- - atoms/: 12 components
257
- - molecules/: 23 components
258
- - organisms/: 8 components
259
-
260
- Routing: App Router (Next.js 13+)
261
- - app/: 15 routes
262
- - Dynamic routes: 5
263
-
264
- API Integration: Custom hooks with TanStack Query
265
- - hooks/useQuery*.ts: 8 hooks
266
- - services/api.ts: REST client
267
-
268
- Example Components:
269
- 1. atoms/Button.tsx (56 lines) - Reusable button with variants
270
- 2. molecules/UserCard.tsx (89 lines) - User card with avatar
271
- 3. organisms/ProductGrid.tsx (124 lines) - Product grid with pagination
272
-
273
- Continue to Layer 3 for deep analysis? (Y/n)
274
- ```
275
-
192
+ ### Layer 2: Structural Analysis (30-90 seconds)
193
+
194
+ **Purpose:** Analyze component structure, routing, and architecture patterns
195
+
196
+ #### Files to Analyze
197
+
198
+ - **Component files:** `src/**/*.{jsx,tsx,vue,svelte}`
199
+ - **Routes:** `src/routes/**`, `src/pages/**`, `app/**`
200
+ - **Store files:** `src/store/**`, `src/state/**`
201
+ - **Config files:** `src/config/**`
202
+
203
+ #### Detection Patterns
204
+
205
+ ```typescript
206
+ // 1. Component Pattern Detection
207
+ const componentPattern = detectComponentPattern(srcFiles);
208
+
209
+ function detectComponentPattern(files: string[]): string {
210
+ const hasAtomic = files.some(
211
+ (f) => f.includes('/atoms/') || f.includes('/molecules/') || f.includes('/organisms/')
212
+ );
213
+ const hasFeatures = files.some((f) => f.includes('/features/'));
214
+ const hasDomains = files.some((f) => f.includes('/domains/'));
215
+ const hasPages = files.some((f) => f.includes('/pages/'));
216
+
217
+ if (hasAtomic) return 'Atomic Design';
218
+ if (hasFeatures) return 'Feature-based';
219
+ if (hasDomains) return 'Domain-driven';
220
+ if (hasPages) return 'Pages-based';
221
+ return 'Flat';
222
+ }
223
+
224
+ // 2. Routing Strategy
225
+ const routingStrategy = detectRouting(srcFiles);
226
+
227
+ function detectRouting(files: string[]): string {
228
+ const hasAppDir = files.some((f) => f.startsWith('app/'));
229
+ const hasPagesDir = files.some((f) => f.startsWith('pages/'));
230
+ const hasSrcRoutes = files.some((f) => f.includes('/routes/'));
231
+
232
+ if (hasAppDir) return 'App Router (Next.js 13+)';
233
+ if (hasPagesDir) return 'Pages Router';
234
+ if (hasSrcRoutes) return 'File-based routing';
235
+
236
+ // Check for react-router/vue-router in code
237
+ const hasReactRouter = files.some((f) => {
238
+ const content = fs.readFileSync(f, 'utf-8');
239
+ return content.includes('react-router-dom');
240
+ });
241
+
242
+ if (hasReactRouter) return 'React Router (code-based)';
243
+ return 'Unknown';
244
+ }
245
+
246
+ // 3. API Integration Pattern
247
+ const apiPattern = detectAPIPattern(srcFiles);
248
+
249
+ function detectAPIPattern(files: string[]): string {
250
+ const hasApiDir = files.some((f) => f.includes('/api/'));
251
+ const hasServicesDir = files.some((f) => f.includes('/services/'));
252
+ const hasHooksDir = files.some((f) => f.includes('/hooks/use') && f.includes('query'));
253
+
254
+ if (hasHooksDir) return 'Custom hooks with TanStack Query';
255
+ if (hasServicesDir) return 'Service layer pattern';
256
+ if (hasApiDir) return 'API client pattern';
257
+ return 'Unknown';
258
+ }
259
+
260
+ // 4. Component Examples (Extract 2-3 representative components)
261
+ const componentExamples = extractComponentExamples(srcFiles);
262
+
263
+ function extractComponentExamples(files: string[]): Component[] {
264
+ // Find 2-3 well-structured components
265
+ const candidates = files.filter((f) => {
266
+ const content = fs.readFileSync(f, 'utf-8');
267
+ return content.includes('export') && content.length > 50 && content.length < 500;
268
+ });
269
+
270
+ return candidates.slice(0, 3).map((file) => ({
271
+ name: path.basename(file, path.extname(file)),
272
+ path: file,
273
+ snippet: fs.readFileSync(file, 'utf-8').slice(0, 200),
274
+ }));
275
+ }
276
+ ```
277
+
278
+ #### Layer 2 Output
279
+
280
+ ```
281
+ ✅ ARCHITECTURE DETECTED:
282
+
283
+ Component Pattern: Atomic Design
284
+ - atoms/: 12 components
285
+ - molecules/: 23 components
286
+ - organisms/: 8 components
287
+
288
+ Routing: App Router (Next.js 13+)
289
+ - app/: 15 routes
290
+ - Dynamic routes: 5
291
+
292
+ API Integration: Custom hooks with TanStack Query
293
+ - hooks/useQuery*.ts: 8 hooks
294
+ - services/api.ts: REST client
295
+
296
+ Example Components:
297
+ 1. atoms/Button.tsx (56 lines) - Reusable button with variants
298
+ 2. molecules/UserCard.tsx (89 lines) - User card with avatar
299
+ 3. organisms/ProductGrid.tsx (124 lines) - Product grid with pagination
300
+
301
+ Continue to Layer 3 for deep analysis? (Y/n)
302
+ ```
303
+ ---
304
+ ### Layer 3: Selective Deep Analysis (Optional, 60-120 seconds)
305
+
306
+ **Purpose:** Extract advanced patterns, conventions, and documentation
307
+
308
+ **Only proceed if:**
309
+
310
+ - User confirms (not automatic)
311
+ - Project is large (>50 components)
312
+ - Accuracy is critical
313
+
314
+ #### Advanced Detection
315
+
316
+ ```typescript
317
+ // 1. Naming Conventions
318
+ const namingConvention = analyzeNamingPatterns(srcFiles);
319
+
320
+ function analyzeNamingPatterns(files: string[]): NamingConvention {
321
+ const componentNames = files.map((f) => path.basename(f, path.extname(f)));
322
+
323
+ const pascalCase = componentNames.filter((n) => /^[A-Z][a-zA-Z0-9]*$/.test(n)).length;
324
+ const camelCase = componentNames.filter((n) => /^[a-z][a-zA-Z0-9]*$/.test(n)).length;
325
+ const kebabCase = componentNames.filter((n) => /^[a-z][a-z0-9-]*$/.test(n)).length;
326
+
327
+ const dominant = Math.max(pascalCase, camelCase, kebabCase);
328
+
329
+ return {
330
+ files: dominant === kebabCase ? 'kebab-case' : 'PascalCase',
331
+ components: dominant === pascalCase ? 'PascalCase' : 'camelCase',
332
+ hooks: files.some((f) => f.includes('use')) ? 'use* (hooks)' : 'N/A',
333
+ };
334
+ }
335
+
336
+ // 2. Code Quality Patterns
337
+ const qualityPatterns = analyzeQualityPatterns(srcFiles);
338
+
339
+ function analyzeQualityPatterns(files: string[]): QualityPatterns {
340
+ let hasTypeScript = 0;
341
+ let hasPropTypes = 0;
342
+ let hasTests = 0;
343
+ let hasStories = 0;
344
+
345
+ files.forEach((file) => {
346
+ if (file.endsWith('.ts') || file.endsWith('.tsx')) hasTypeScript++;
347
+ const content = fs.readFileSync(file, 'utf-8');
348
+ if (content.includes('PropTypes')) hasPropTypes++;
349
+ });
350
+
351
+ const testFiles = files.filter((f) => f.includes('.test.') || f.includes('.spec.'));
352
+ hasTests = testFiles.length;
353
+
354
+ const storyFiles = files.filter((f) => f.includes('.stories.'));
355
+ hasStories = storyFiles.length;
356
+
357
+ return {
358
+ typeScriptCoverage: (hasTypeScript / files.length) * 100,
359
+ propTypesUsage: hasPropTypes > 0,
360
+ testCoverage: `${hasTests} test files`,
361
+ storybookUsage: hasStories > 0,
362
+ };
363
+ }
364
+
365
+ // 3. Accessibility Patterns
366
+ const a11yPatterns = analyzeAccessibility(srcFiles);
367
+
368
+ function analyzeAccessibility(files: string[]): A11yPatterns {
369
+ let ariaUsage = 0;
370
+ let semanticHTML = 0;
371
+
372
+ files.forEach((file) => {
373
+ const content = fs.readFileSync(file, 'utf-8');
374
+ if (content.includes('aria-')) ariaUsage++;
375
+ if (content.includes('<button') || content.includes('<nav') || content.includes('<header')) {
376
+ semanticHTML++;
377
+ }
378
+ });
379
+
380
+ return {
381
+ ariaAttributesUsage: ariaUsage > files.length * 0.2 ? 'Frequent' : 'Rare',
382
+ semanticHTMLUsage: semanticHTML > files.length * 0.5 ? 'Good' : 'Needs improvement',
383
+ };
384
+ }
385
+ ```
386
+
387
+ #### Layer 3 Output
388
+
389
+ ```
390
+ ✅ DEEP ANALYSIS COMPLETE:
391
+
392
+ Naming Conventions:
393
+ - Files: PascalCase
394
+ - Components: PascalCase
395
+ - Hooks: use* prefix
396
+
397
+ Code Quality:
398
+ - TypeScript: 95% coverage
399
+ - PropTypes: Not used (TypeScript instead)
400
+ - Tests: 48 test files (60% coverage)
401
+ - Storybook: Yes (23 stories)
402
+
403
+ Accessibility:
404
+ - ARIA attributes: Frequent usage
405
+ - Semantic HTML: Good usage
406
+ - Recommended: WCAG 2.1 AA compliance
407
+
408
+ Analysis complete! Proceeding to validation...
409
+ ```
276
410
  ---
277
-
278
- ### Layer 3: Selective Deep Analysis (Optional, 60-120 seconds)
279
-
280
- **Purpose:** Extract advanced patterns, conventions, and documentation
281
-
282
- **Only proceed if:**
283
- - User confirms (not automatic)
284
- - Project is large (>50 components)
285
- - Accuracy is critical
286
-
287
- #### Advanced Detection
288
-
289
- ```typescript
290
- // 1. Naming Conventions
291
- const namingConvention = analyzeNamingPatterns(srcFiles);
292
-
293
- function analyzeNamingPatterns(files: string[]): NamingConvention {
294
- const componentNames = files.map(f => path.basename(f, path.extname(f)));
295
-
296
- const pascalCase = componentNames.filter(n => /^[A-Z][a-zA-Z0-9]*$/.test(n)).length;
297
- const camelCase = componentNames.filter(n => /^[a-z][a-zA-Z0-9]*$/.test(n)).length;
298
- const kebabCase = componentNames.filter(n => /^[a-z][a-z0-9-]*$/.test(n)).length;
299
-
300
- const dominant = Math.max(pascalCase, camelCase, kebabCase);
301
-
302
- return {
303
- files: dominant === kebabCase ? 'kebab-case' : 'PascalCase',
304
- components: dominant === pascalCase ? 'PascalCase' : 'camelCase',
305
- hooks: files.some(f => f.includes('use')) ? 'use* (hooks)' : 'N/A'
306
- };
307
- }
308
-
309
- // 2. Code Quality Patterns
310
- const qualityPatterns = analyzeQualityPatterns(srcFiles);
311
-
312
- function analyzeQualityPatterns(files: string[]): QualityPatterns {
313
- let hasTypeScript = 0;
314
- let hasPropTypes = 0;
315
- let hasTests = 0;
316
- let hasStories = 0;
317
-
318
- files.forEach(file => {
319
- if (file.endsWith('.ts') || file.endsWith('.tsx')) hasTypeScript++;
320
- const content = fs.readFileSync(file, 'utf-8');
321
- if (content.includes('PropTypes')) hasPropTypes++;
322
- });
323
-
324
- const testFiles = files.filter(f => f.includes('.test.') || f.includes('.spec.'));
325
- hasTests = testFiles.length;
326
-
327
- const storyFiles = files.filter(f => f.includes('.stories.'));
328
- hasStories = storyFiles.length;
329
-
330
- return {
331
- typeScriptCoverage: (hasTypeScript / files.length) * 100,
332
- propTypesUsage: hasPropTypes > 0,
333
- testCoverage: `${hasTests} test files`,
334
- storybookUsage: hasStories > 0
335
- };
336
- }
337
-
338
- // 3. Accessibility Patterns
339
- const a11yPatterns = analyzeAccessibility(srcFiles);
340
-
341
- function analyzeAccessibility(files: string[]): A11yPatterns {
342
- let ariaUsage = 0;
343
- let semanticHTML = 0;
344
-
345
- files.forEach(file => {
346
- const content = fs.readFileSync(file, 'utf-8');
347
- if (content.includes('aria-')) ariaUsage++;
348
- if (content.includes('<button') || content.includes('<nav') || content.includes('<header')) {
349
- semanticHTML++;
350
- }
351
- });
352
-
353
- return {
354
- ariaAttributesUsage: ariaUsage > files.length * 0.2 ? 'Frequent' : 'Rare',
355
- semanticHTMLUsage: semanticHTML > files.length * 0.5 ? 'Good' : 'Needs improvement'
356
- };
357
- }
358
- ```
359
-
360
- #### Layer 3 Output
361
-
362
- ```
363
- ✅ DEEP ANALYSIS COMPLETE:
364
-
365
- Naming Conventions:
366
- - Files: PascalCase
367
- - Components: PascalCase
368
- - Hooks: use* prefix
369
-
370
- Code Quality:
371
- - TypeScript: 95% coverage
372
- - PropTypes: Not used (TypeScript instead)
373
- - Tests: 48 test files (60% coverage)
374
- - Storybook: Yes (23 stories)
375
-
376
- Accessibility:
377
- - ARIA attributes: Frequent usage
378
- - Semantic HTML: Good usage
379
- - Recommended: WCAG 2.1 AA compliance
380
-
381
- Analysis complete! Proceeding to validation...
382
- ```
383
-
411
+ ## ✅ Validation & Confirmation
412
+
413
+ ### Present Findings
414
+
415
+ After detection, show user a summary and ask for confirmation:
416
+
417
+ ```
418
+ ---
419
+ 🔍 FRONTEND STACK DETECTED
384
420
  ---
385
-
386
- ## Validation & Confirmation
387
-
388
- ### Present Findings
389
-
390
- After detection, show user a summary and ask for confirmation:
391
-
392
- ```
393
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
394
- 🔍 FRONTEND STACK DETECTED
395
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
396
-
397
- ✅ Framework: React 18.2.0 (with Next.js 14.0.0)
398
- ✅ Build Tool: Vite 5.0.0
399
- TypeScript: Yes
400
- ✅ State Management: Zustand 4.4.0
401
- ✅ Data Fetching: TanStack Query 5.0.0
402
- Styling: Tailwind CSS 3.3.0
403
- ✅ Component Pattern: Atomic Design
404
- Testing: Vitest + Playwright
405
- Routing: App Router (Next.js 13+)
406
- Component Library: None
407
-
408
- Is this correct? (Y/n)
409
- ```
410
-
411
- ### If User Says "Yes"
412
-
413
- ```
414
- ✅ Great! I'll use these detected values.
415
-
416
- I'll still ask you questions for:
417
- - Business requirements (Phase 1)
418
- - Specific conventions and preferences
419
- - Performance targets
420
- - Deployment strategy
421
-
422
- This will reduce the questionnaire from ~90 min to ~40 min.
423
-
424
- Proceed to Phase 1? (Y/n)
425
- ```
426
-
427
- ### If User Says "No" or Makes Corrections
428
-
429
- ```
430
- Please correct any incorrect detections:
431
-
432
- 1. Framework: React 18.2.0 → (Enter new value or press Enter to keep)
433
- 2. State Management: Zustand → (Enter new value or press Enter to keep)
434
- ...
435
-
436
- (After corrections)
437
-
438
- ✅ Updated! Proceeding to Phase 1...
439
- ```
440
-
421
+ ✅ Framework: React 18.2.0 (with Next.js 14.0.0)
422
+ Build Tool: Vite 5.0.0
423
+ ✅ TypeScript: Yes
424
+ State Management: Zustand 4.4.0
425
+ ✅ Data Fetching: TanStack Query 5.0.0
426
+ Styling: Tailwind CSS 3.3.0
427
+ ✅ Component Pattern: Atomic Design
428
+ ✅ Testing: Vitest + Playwright
429
+ ✅ Routing: App Router (Next.js 13+)
430
+ Component Library: None
431
+
432
+ Is this correct? (Y/n)
433
+ ```
434
+
435
+ ### If User Says "Yes"
436
+
437
+ ```
438
+ Great! I'll use these detected values.
439
+
440
+ I'll still ask you questions for:
441
+ - Business requirements (Phase 1)
442
+ - Specific conventions and preferences
443
+ - Performance targets
444
+ - Deployment strategy
445
+
446
+ This will reduce the questionnaire from ~90 min to ~40 min.
447
+
448
+ Proceed to Phase 1? (Y/n)
449
+ ```
450
+
451
+ ### If User Says "No" or Makes Corrections
452
+
453
+ ```
454
+ Please correct any incorrect detections:
455
+
456
+ 1. Framework: React 18.2.0 → (Enter new value or press Enter to keep)
457
+ 2. State Management: Zustand → (Enter new value or press Enter to keep)
458
+ ...
459
+
460
+ (After corrections)
461
+
462
+ ✅ Updated! Proceeding to Phase 1...
463
+ ```
441
464
  ---
442
-
443
- ## 💾 Cache Storage
444
-
445
- Save detected context for future use:
446
-
447
- ```typescript
448
- // .ai-flow/cache/frontend-context.json
449
- {
450
- "framework": "React",
451
- "frameworkVersion": "18.2.0",
452
- "metaFramework": "Next.js",
453
- "metaFrameworkVersion": "14.0.0",
454
- "buildTool": "Vite",
455
- "buildToolVersion": "5.0.0",
456
- "typescript": true,
457
- "stateManagement": "Zustand",
458
- "dataFetching": "TanStack Query",
459
- "styling": "Tailwind CSS",
460
- "componentLibrary": null,
461
- "componentPattern": "Atomic Design",
462
- "routing": "App Router",
463
- "unitTest": "Vitest",
464
- "e2eTest": "Playwright",
465
- "namingConvention": "PascalCase",
466
- "testCoverage": 60,
467
- "a11yCompliance": "WCAG 2.1 AA",
468
- "lastAnalyzed": "2025-01-20T10:30:00Z",
469
- "projectPath": "/Users/username/my-app"
470
- }
471
- ```
472
-
473
- **Cache invalidation:** 7 days or when package.json is modified
474
-
465
+ ## 💾 Cache Storage
466
+
467
+ Save detected context for future use:
468
+
469
+ ```typescript
470
+ // .ai-flow/cache/frontend-context.json
471
+ {
472
+ "framework": "React",
473
+ "frameworkVersion": "18.2.0",
474
+ "metaFramework": "Next.js",
475
+ "metaFrameworkVersion": "14.0.0",
476
+ "buildTool": "Vite",
477
+ "buildToolVersion": "5.0.0",
478
+ "typescript": true,
479
+ "stateManagement": "Zustand",
480
+ "dataFetching": "TanStack Query",
481
+ "styling": "Tailwind CSS",
482
+ "componentLibrary": null,
483
+ "componentPattern": "Atomic Design",
484
+ "routing": "App Router",
485
+ "unitTest": "Vitest",
486
+ "e2eTest": "Playwright",
487
+ "namingConvention": "PascalCase",
488
+ "testCoverage": 60,
489
+ "a11yCompliance": "WCAG 2.1 AA",
490
+ "lastAnalyzed": "2025-01-20T10:30:00Z",
491
+ "projectPath": "/Users/username/my-app"
492
+ }
493
+ ```
494
+
495
+ **Cache invalidation:** 7 days or when package.json is modified
475
496
  ---
476
-
477
- ## 🚀 Next Steps
478
-
479
- After Phase 0 completes:
480
-
481
- ```
482
- ✅ Context analysis complete!
483
-
484
- Next: Proceed to Phase 1 (Discovery & UX)
485
-
486
- Read: .ai-flow/prompts/frontend/flow-build-phase-1-discovery.md
487
- ```
488
-
497
+ ## 🚀 Next Steps
498
+
499
+ After Phase 0 completes:
500
+
501
+ ```
502
+ ✅ Context analysis complete!
503
+
504
+ Next: Proceed to Phase 1 (Discovery & UX)
505
+
506
+ Read: .ai-flow/prompts/frontend/flow-build-phase-1-discovery.md
507
+ ```
489
508
  ---
490
-
491
- **Last Updated:** 2025-01-XX
492
-
493
- **Version:** 1.2.0
509
+ **Last Updated:** 2025-01-XX
510
+
511
+ **Version:** 1.2.0
512
+
494
513
 
495
514
 
496
515