ai-flow-dev 1.0.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.
- package/LICENSE +21 -0
- package/README.md +408 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +791 -0
- package/dist/cli.js.map +1 -0
- package/dist/fs-utils.d.ts +2 -0
- package/dist/fs-utils.d.ts.map +1 -0
- package/dist/fs-utils.js +46 -0
- package/dist/fs-utils.js.map +1 -0
- package/package.json +71 -0
- package/prompts/backend/flow-dev-feature.md +1318 -0
- package/prompts/backend/flow-dev-fix.md +903 -0
- package/prompts/backend/flow-dev-refactor.md +715 -0
- package/prompts/backend/flow-dev-review.md +401 -0
- package/prompts/backend/flow-dev-work.md +1129 -0
- package/prompts/backend/flow-docs-gen-phase-0.md +1840 -0
- package/prompts/backend/flow-docs-gen-phase-1.md +435 -0
- package/prompts/backend/flow-docs-gen-phase-2.md +460 -0
- package/prompts/backend/flow-docs-gen-phase-3.md +684 -0
- package/prompts/backend/flow-docs-gen-phase-4.md +516 -0
- package/prompts/backend/flow-docs-gen-phase-5.md +637 -0
- package/prompts/backend/flow-docs-gen-phase-6.md +465 -0
- package/prompts/backend/flow-docs-gen-phase-7.md +1207 -0
- package/prompts/backend/flow-docs-gen.md +820 -0
- package/prompts/backend/flow-docs-sync.md +526 -0
- package/prompts/backend/flow-project-init.md +248 -0
- package/prompts/backend/flow-project-roadmap.md +1159 -0
- package/prompts/frontend/flow-docs-gen-phase-0.md +494 -0
- package/prompts/frontend/flow-docs-gen-phase-1.md +449 -0
- package/prompts/frontend/flow-docs-gen-phase-2.md +983 -0
- package/prompts/frontend/flow-docs-gen-phase-3.md +685 -0
- package/prompts/frontend/flow-docs-gen-phase-4.md +480 -0
- package/prompts/frontend/flow-docs-gen-phase-5.md +483 -0
- package/prompts/frontend/flow-docs-gen-phase-6.md +570 -0
- package/prompts/frontend/flow-docs-gen-phase-7.md +582 -0
- package/prompts/frontend/flow-docs-gen.md +413 -0
- package/prompts/frontend/flow-docs-sync.md +561 -0
- package/prompts/mobile/flow-docs-gen-phase-0.md +387 -0
- package/prompts/mobile/flow-docs-gen-phase-1.md +530 -0
- package/prompts/mobile/flow-docs-gen-phase-2.md +584 -0
- package/prompts/mobile/flow-docs-gen-phase-3.md +659 -0
- package/prompts/mobile/flow-docs-gen-phase-4.md +363 -0
- package/prompts/mobile/flow-docs-gen-phase-5.md +369 -0
- package/prompts/mobile/flow-docs-gen-phase-6.md +490 -0
- package/prompts/mobile/flow-docs-gen-phase-7.md +407 -0
- package/prompts/mobile/flow-docs-gen.md +430 -0
- package/prompts/mobile/flow-docs-sync.md +634 -0
- package/templates/backend/.clauderules.template +111 -0
- package/templates/backend/.cursorrules.template +102 -0
- package/templates/backend/.env.example.template +122 -0
- package/templates/backend/README.template.md +200 -0
- package/templates/backend/ai-instructions.template.md +354 -0
- package/templates/backend/copilot-instructions.template.md +160 -0
- package/templates/backend/docs/api.template.md +251 -0
- package/templates/backend/docs/architecture.template.md +612 -0
- package/templates/backend/docs/business-flows.template.md +109 -0
- package/templates/backend/docs/code-standards.template.md +828 -0
- package/templates/backend/docs/contributing.template.md +163 -0
- package/templates/backend/docs/data-model.template.md +416 -0
- package/templates/backend/docs/operations.template.md +591 -0
- package/templates/backend/docs/testing.template.md +762 -0
- package/templates/backend/project-brief.template.md +176 -0
- package/templates/backend/specs/configuration.template.md +133 -0
- package/templates/backend/specs/security.template.md +422 -0
- package/templates/frontend/README.template.md +121 -0
- package/templates/frontend/ai-instructions.template.md +368 -0
- package/templates/frontend/docs/api-integration.template.md +390 -0
- package/templates/frontend/docs/components.template.md +567 -0
- package/templates/frontend/docs/error-handling.template.md +385 -0
- package/templates/frontend/docs/operations.template.md +123 -0
- package/templates/frontend/docs/performance.template.md +140 -0
- package/templates/frontend/docs/pwa.template.md +135 -0
- package/templates/frontend/docs/state-management.template.md +394 -0
- package/templates/frontend/docs/styling.template.md +779 -0
- package/templates/frontend/docs/testing.template.md +736 -0
- package/templates/frontend/project-brief.template.md +55 -0
- package/templates/frontend/specs/accessibility.template.md +111 -0
- package/templates/frontend/specs/configuration.template.md +520 -0
- package/templates/frontend/specs/security.template.md +197 -0
- package/templates/fullstack/README.template.md +282 -0
- package/templates/fullstack/ai-instructions.template.md +487 -0
- package/templates/fullstack/project-brief.template.md +197 -0
- package/templates/fullstack/specs/configuration.template.md +380 -0
- package/templates/mobile/AGENT.template.md +251 -0
- package/templates/mobile/README.template.md +195 -0
- package/templates/mobile/ai-instructions.template.md +221 -0
- package/templates/mobile/docs/app-store.template.md +163 -0
- package/templates/mobile/docs/architecture.template.md +100 -0
- package/templates/mobile/docs/native-features.template.md +137 -0
- package/templates/mobile/docs/navigation.template.md +81 -0
- package/templates/mobile/docs/offline-strategy.template.md +90 -0
- package/templates/mobile/docs/permissions.template.md +70 -0
- package/templates/mobile/docs/state-management.template.md +116 -0
- package/templates/mobile/docs/testing.template.md +146 -0
- package/templates/mobile/project-brief.template.md +97 -0
- package/templates/mobile/specs/build-configuration.template.md +116 -0
- package/templates/mobile/specs/deployment.template.md +114 -0
- package/templates/shared/AGENT.template.md +252 -0
|
@@ -0,0 +1,494 @@
|
|
|
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 bootstrap questionnaire.
|
|
6
|
+
|
|
7
|
+
---
|
|
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
|
+
|
|
18
|
+
---
|
|
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
|
+
|
|
46
|
+
---
|
|
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
|
+
|
|
162
|
+
---
|
|
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
|
+
|
|
276
|
+
---
|
|
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
|
+
|
|
384
|
+
---
|
|
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
|
+
|
|
441
|
+
---
|
|
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
|
+
|
|
475
|
+
---
|
|
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-docs-gen-phase-1-discovery.md
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
---
|
|
490
|
+
|
|
491
|
+
**Last Updated:** 2025-01-XX
|
|
492
|
+
|
|
493
|
+
**Version:** 1.2.0
|
|
494
|
+
|