ai-flow-dev 2.1.9 → 2.2.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.
@@ -3,513 +3,82 @@
3
3
  **⚡ AUTOMATED ANALYSIS - Minimal User Input Required**
4
4
 
5
5
  This phase automatically analyzes your existing frontend codebase to pre-populate answers for the build questionnaire.
6
- ---
7
- ## 🎯 Objective
6
+ ---
8
7
 
9
- Detect the current frontend stack, architecture patterns, and configuration from existing code to:
8
+ ## 🚫 Critical Exclusion Rules
9
+ To avoid false-positive detections, **IGNORE** the following folders and files during all detection steps:
10
+ - `.ai-flow/` (contains AI Flow internal cache and prompts)
11
+ - `.agent/` (contains AI workflows)
12
+ - `docs/` and `specs/` (if they contain AI Flow generated documentation)
13
+ - `project-brief.md`, `ai-instructions.md`, `AGENT.md`
10
14
 
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
15
- ---
16
- ## 📋 Detection Layers (Progressive)
15
+ **A project is considered "Existing" only if it contains functional source code or framework configuration files OUTSIDE these excluded paths.**
17
16
 
18
- ### Layer 0: Cache Check (0-2 seconds)
17
+ ---
19
18
 
20
- Check if `.ai-flow/cache/frontend-context.json` exists and is fresh (<7 days old).
19
+ ## 🎯 Objective
20
+ Detect the current frontend stack, architecture patterns, and configuration from existing code.
21
21
 
22
- **If found:**
22
+ ---
23
+ ## 📋 Detection Layers (Progressive)
23
24
 
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
- ```
25
+ ### Layer 0: Cache Check (0-2 seconds)
26
+ Check if `.ai-flow/cache/frontend-context.json` exists and is fresh (<7 days old).
36
27
 
37
28
  **Action:** Ask user: "Found cached analysis from X days ago. Use it? (Y/n)"
38
29
 
39
- **If yes:** Skip to validation step
40
-
41
- **If no or cache doesn't exist:** Proceed to Layer 1
42
- ---
30
+ ---
43
31
  ### Layer 1: Fast Metadata Scan (10-20 seconds)
44
32
 
33
+ // turbo
45
34
  **Purpose:** Detect framework, build tool, package manager, TypeScript
46
35
 
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
- ```
36
+ **Context Links:**
37
+ - Node.js: [package.json](file:///package.json)
38
+ - React/Vue/Svelte Config: [vite.config.ts](file:///vite.config.ts) | [vite.config.js](file:///vite.config.js)
39
+ - Angular: [angular.json](file:///angular.json)
40
+ - TypeScript: [tsconfig.json](file:///tsconfig.json)
41
+ - Styling: [tailwind.config.js](file:///tailwind.config.js) | [tailwind.config.ts](file:///tailwind.config.ts)
174
42
 
175
- #### Layer 1 Output
43
+ **Action:** Use your internal knowledge to detect the UI framework (React, Vue, Angular, Svelte, Next.js, etc.), Build Tool (Vite, Webpack, etc.), State Management, and Styling from the configuration files.
176
44
 
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
- ```
191
- ---
45
+ ---
192
46
  ### Layer 2: Structural Analysis (30-90 seconds)
193
47
 
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
48
+ **Purpose:** Analyze component structure, routing, and architecture patterns (Atomic Design, Feature-based, etc.) by scanning the folder organization.
287
49
 
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
- ---
50
+ ---
304
51
  ### Layer 3: Selective Deep Analysis (Optional, 60-120 seconds)
305
52
 
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
53
+ **Purpose:** Extract advanced patterns, naming conventions, and accessibility (A11y) maturity.
388
54
 
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
- ```
410
- ---
55
+ ---
411
56
  ## ✅ Validation & Confirmation
412
57
 
413
58
  ### Present Findings
59
+ Show the summary report and ask for confirmation:
60
+ - ✅ Framework
61
+ - ✅ Build Tool
62
+ - ✅ TypeScript
63
+ - ✅ State Management
64
+ - ✅ Styling
65
+ - ✅ Architecture Pattern
414
66
 
415
- After detection, show user a summary and ask for confirmation:
416
-
417
- ```
418
- ---
419
- 🔍 FRONTEND STACK DETECTED
420
- ---
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
- ```
67
+ ---
450
68
 
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
- ```
464
- ---
465
69
  ## 💾 Cache Storage
70
+ Save detected context to `.ai-flow/cache/frontend-context.json` for future use.
466
71
 
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
496
- ---
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
- ```
508
- ---
509
- **Last Updated:** 2025-01-XX
72
+ ---
510
73
 
511
- **Version:** 1.2.0
74
+ **Phase 0 Complete: Context Analysis Finalized**
512
75
 
76
+ ---
513
77
 
78
+ **Next Phase:** Phase 1 - Discovery & UX Requirements
514
79
 
80
+ Read: `.ai-flow/prompts/frontend/flow-build-phase-1.md`
515
81
 
82
+ ---
83
+ _Version: 4.2 (Antigravity Optimized - Ultra-Light Edition)_
84
+ _Last Updated: 2025-12-21_
@@ -0,0 +1,33 @@
1
+ ## PHASE 10: Agile Planning - User Stories (Frontend) (5-10 min)
2
+
3
+ > **Order for this phase:** OPTIONAL. Executed after Phase 9 or on demand.
4
+
5
+ ### Objective
6
+ Break down technical roadmap tasks into user-centric Agile requirements (User Stories) with a focus on Frontend UX, Accessibility, and UI interactions.
7
+
8
+ ---
9
+
10
+ ## Workflow: 4 Steps
11
+
12
+ // turbo
13
+ ### Step 10.1: Load Context from Roadmap
14
+ Extract context variables and epics from `docs/roadmap.md`.
15
+
16
+ ### Step 10.2: Select Scope
17
+ Choose: All Epics, Sprint 1, or Specific Epics.
18
+
19
+ ### Step 10.3: Generate User Story Documents
20
+ Create `docs/user-stories/EP-XXX/HU-XXX-YYY.md`.
21
+
22
+ **Frontend specific Acceptance Criteria focus:**
23
+ - **UX/Interaction:** "When I click X, Y happens with a smooth transition."
24
+ - **Accessibility:** "The component must be keyboard navigable and have ARIA labels."
25
+ - **Responsiveness:** "Display 1 column on mobile, 3 columns on desktop."
26
+ - **Validation:** "Show inline error message if field is empty."
27
+
28
+ ### Step 10.4: Generate Test Cases
29
+ Create `docs/user-stories/EP-XXX/tests/TC-XXX-YYY.md`.
30
+
31
+ ---
32
+ _Version: 4.2 (Antigravity Optimized)_
33
+ _Last Updated: 2025-12-21_