ai-flow-dev 2.1.9 → 2.2.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/README.md +26 -29
- package/dist/cli.js +10 -4
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
- package/prompts/backend/flow-build-phase-0.md +278 -1738
- package/prompts/backend/flow-build-phase-1.md +19 -0
- package/prompts/backend/flow-build-phase-10.md +1 -0
- package/prompts/backend/flow-build-phase-2.md +19 -0
- package/prompts/backend/flow-build-phase-3.md +19 -0
- package/prompts/backend/flow-build-phase-4.md +19 -0
- package/prompts/backend/flow-build-phase-5.md +19 -0
- package/prompts/backend/flow-build-phase-6.md +19 -0
- package/prompts/backend/flow-build-phase-7.md +19 -0
- package/prompts/backend/flow-build-phase-8.md +6 -7
- package/prompts/backend/flow-build-phase-9.md +15 -0
- package/prompts/backend/flow-build.md +59 -836
- package/prompts/backend/flow-check-review.md +20 -0
- package/prompts/backend/flow-check-test.md +14 -0
- package/prompts/backend/flow-check.md +65 -0
- package/prompts/backend/flow-commit.md +51 -0
- package/prompts/backend/flow-docs-sync.md +53 -53
- package/prompts/backend/flow-work-feature.md +42 -0
- package/prompts/backend/flow-work-fix.md +33 -0
- package/prompts/backend/flow-work-refactor.md +32 -0
- package/prompts/backend/flow-work-resume.md +32 -0
- package/prompts/backend/flow-work.md +127 -0
- package/prompts/frontend/flow-build-phase-0.md +323 -426
- package/prompts/frontend/flow-build-phase-1.md +433 -404
- package/prompts/frontend/flow-build-phase-10.md +33 -0
- package/prompts/frontend/flow-build-phase-2.md +508 -872
- package/prompts/frontend/flow-build-phase-3.md +629 -562
- package/prompts/frontend/flow-build-phase-4.md +438 -382
- package/prompts/frontend/flow-build-phase-5.md +559 -362
- package/prompts/frontend/flow-build-phase-6.md +383 -452
- package/prompts/frontend/flow-build-phase-7.md +818 -392
- package/prompts/frontend/flow-build-phase-8.md +27 -16
- package/prompts/frontend/flow-build-phase-9.md +94 -0
- package/prompts/frontend/flow-build.md +68 -414
- package/prompts/frontend/flow-check-review.md +20 -0
- package/prompts/frontend/flow-check-test.md +14 -0
- package/prompts/frontend/flow-check.md +65 -0
- package/prompts/frontend/flow-commit.md +51 -0
- package/prompts/frontend/flow-docs-sync.md +36 -34
- package/prompts/frontend/flow-work-feature.md +42 -0
- package/prompts/frontend/flow-work-fix.md +33 -0
- package/prompts/frontend/flow-work-refactor.md +32 -0
- package/prompts/frontend/flow-work-resume.md +32 -0
- package/prompts/frontend/flow-work.md +127 -0
- package/prompts/mobile/flow-build-phase-0.md +335 -319
- package/prompts/mobile/flow-build-phase-1.md +438 -493
- package/prompts/mobile/flow-build-phase-10.md +32 -0
- package/prompts/mobile/flow-build-phase-2.md +458 -464
- package/prompts/mobile/flow-build-phase-3.md +613 -487
- package/prompts/mobile/flow-build-phase-4.md +439 -258
- package/prompts/mobile/flow-build-phase-5.md +582 -250
- package/prompts/mobile/flow-build-phase-6.md +389 -359
- package/prompts/mobile/flow-build-phase-7.md +871 -285
- package/prompts/mobile/flow-build-phase-8.md +27 -16
- package/prompts/mobile/flow-build-phase-9.md +90 -0
- package/prompts/mobile/flow-build.md +67 -426
- package/prompts/mobile/flow-check-review.md +20 -0
- package/prompts/mobile/flow-check-test.md +14 -0
- package/prompts/mobile/flow-check.md +65 -0
- package/prompts/mobile/flow-commit.md +51 -0
- package/prompts/mobile/flow-docs-sync.md +37 -40
- package/prompts/mobile/flow-work-feature.md +42 -0
- package/prompts/mobile/flow-work-fix.md +33 -0
- package/prompts/mobile/flow-work-refactor.md +32 -0
- package/prompts/mobile/flow-work-resume.md +32 -0
- package/prompts/mobile/flow-work.md +127 -0
- package/prompts/shared/smart-skip-preflight.md +214 -0
- package/prompts/backend/flow-dev-commit.md +0 -829
- package/prompts/backend/flow-dev-feature.md +0 -1948
- package/prompts/backend/flow-dev-fix.md +0 -952
- package/prompts/backend/flow-dev-refactor.md +0 -690
- package/prompts/backend/flow-dev-review.md +0 -372
- package/prompts/backend/flow-dev-work.md +0 -1081
|
@@ -1,515 +1,412 @@
|
|
|
1
|
-
|
|
1
|
+
## PHASE 0: Context Discovery (2-5 min)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **Order for this phase:** ALWAYS executed FIRST if an existing project is detected. Skip ONLY for new projects.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
> **📌 Scope-based behavior:**
|
|
6
|
+
> - **Interactive Mode:** Ask user for permission to scan files layer by layer.
|
|
7
|
+
> - **Autonomous Mode:** Scan all layers automatically and present the final report.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
### Objective
|
|
10
|
+
Efficiently analyze existing projects using a **layered, incremental approach**.
|
|
10
11
|
|
|
11
|
-
|
|
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)
|
|
12
|
+
---
|
|
17
13
|
|
|
18
|
-
|
|
14
|
+
## 🚫 Critical Exclusion Rules
|
|
15
|
+
To avoid false-positive detections, **IGNORE** the following folders and files during all detection steps:
|
|
16
|
+
- `.ai-flow/` (contains AI Flow internal cache and prompts)
|
|
17
|
+
- `.agent/` (contains AI workflows)
|
|
18
|
+
- `docs/` and `specs/` (if they contain AI Flow generated documentation)
|
|
19
|
+
- `project-brief.md`, `ai-instructions.md`, `AGENT.md`
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
**A project is considered "Existing" only if it contains functional source code or framework configuration files OUTSIDE these excluded paths.**
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 0.0 Check for Existing Analysis (Layer 0)
|
|
26
|
+
|
|
27
|
+
Check if `.ai-flow/cache/docs-analysis.json` exists and is fresh.
|
|
21
28
|
|
|
22
29
|
**If found:**
|
|
30
|
+
Ask user to use cached analysis or re-analyze.
|
|
23
31
|
|
|
24
|
-
|
|
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
|
-
```
|
|
32
|
+
**If not found:**
|
|
33
|
+
Proceed to Layer 1.
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
**If yes:** Skip to validation step
|
|
40
|
-
|
|
41
|
-
**If no or cache doesn't exist:** Proceed to Layer 1
|
|
42
|
-
---
|
|
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
|
-
```
|
|
35
|
+
---
|
|
174
36
|
|
|
175
|
-
|
|
37
|
+
// turbo
|
|
38
|
+
## ⚡ Layer 1: Fast Metadata Scan (10-20 seconds)
|
|
176
39
|
|
|
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
|
-
---
|
|
192
|
-
### Layer 2: Structural Analysis (30-90 seconds)
|
|
40
|
+
**Purpose:** Detect framework, language, build tool, and existing AI configurations.
|
|
193
41
|
|
|
194
|
-
**
|
|
42
|
+
⭐ **Context Links:**
|
|
43
|
+
- Node.js: [package.json](file:///package.json)
|
|
44
|
+
- Python: [requirements.txt](file:///requirements.txt) | [pyproject.toml](file:///pyproject.toml)
|
|
45
|
+
- PHP: [composer.json](file:///composer.json)
|
|
46
|
+
- Go: [go.mod](file:///go.mod)
|
|
47
|
+
- Java: [pom.xml](file:///pom.xml) | [build.gradle](file:///build.gradle)
|
|
195
48
|
|
|
196
|
-
|
|
49
|
+
### 0.1.1 Universal Tech Stack Detection
|
|
50
|
+
**Action:** Use your internal knowledge to detect the language and framework by scanning the root configuration files (package.json, pyproject.toml, etc.).
|
|
197
51
|
|
|
198
|
-
|
|
199
|
-
- **
|
|
200
|
-
- **
|
|
201
|
-
- **
|
|
52
|
+
**Detect (but don't be limited to):**
|
|
53
|
+
- **Node.js:** NestJS, Express, Fastify, etc.
|
|
54
|
+
- **Python:** FastAPI, Django, Flask, etc.
|
|
55
|
+
- **PHP:** Laravel, Symfony, etc.
|
|
56
|
+
- **Java/Kotlin:** Spring Boot, Micronaut, Ktor, etc.
|
|
57
|
+
- **Go:** Gin, Echo, Fiber, etc.
|
|
58
|
+
- **C#/.NET, Ruby, Rust, Elixir.**
|
|
202
59
|
|
|
203
|
-
|
|
60
|
+
### 0.1.2 Find AI & Documentation
|
|
61
|
+
- Find existing AI configs (`AGENT.md`, `.cursorrules`, etc.)
|
|
62
|
+
- Scan for `README.md` and existing `docs/`.
|
|
204
63
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const componentPattern = detectComponentPattern(srcFiles);
|
|
64
|
+
### Layer 1 Output
|
|
65
|
+
Show a summary of detected Name, Language, Framework, ORM, and Documentation files.
|
|
208
66
|
|
|
209
|
-
|
|
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/'));
|
|
67
|
+
---
|
|
216
68
|
|
|
217
|
-
|
|
218
|
-
if (hasFeatures) return 'Feature-based';
|
|
219
|
-
if (hasDomains) return 'Domain-driven';
|
|
220
|
-
if (hasPages) return 'Pages-based';
|
|
221
|
-
return 'Flat';
|
|
222
|
-
}
|
|
69
|
+
## 0.2 Layer 2: Structural Analysis (30-90 seconds)
|
|
223
70
|
|
|
224
|
-
|
|
225
|
-
const routingStrategy = detectRouting(srcFiles);
|
|
71
|
+
**Purpose:** Analyze directory organization and architecture patterns without reading code line-by-line.
|
|
226
72
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
73
|
+
### 0.2.1 Pattern Detection
|
|
74
|
+
1. **Identify Pattern:** Feature-based, Layer-based, Modular Monolith, or Hybrid.
|
|
75
|
+
2. **Entity Detection:** Scan for Schema/Entity files based on the detected ORM (Prisma, TypeORM, Django Models, etc.).
|
|
76
|
+
3. **Maturity Check:** Assess documentation and test coverage ratio.
|
|
231
77
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
if (hasSrcRoutes) return 'File-based routing';
|
|
78
|
+
### Layer 2 Output
|
|
79
|
+
Summary of Architecture Pattern, Code Structure counts (Controllers, Services, etc.), and Recommended Build Scope (MVP/Production/Enterprise).
|
|
235
80
|
|
|
236
|
-
|
|
237
|
-
const hasReactRouter = files.some((f) => {
|
|
238
|
-
const content = fs.readFileSync(f, 'utf-8');
|
|
239
|
-
return content.includes('react-router-dom');
|
|
240
|
-
});
|
|
81
|
+
---
|
|
241
82
|
|
|
242
|
-
|
|
243
|
-
return 'Unknown';
|
|
244
|
-
}
|
|
83
|
+
## 0.3 Layer 3: Selective Deep Analysis (1-5 minutes, OPTIONAL)
|
|
245
84
|
|
|
246
|
-
|
|
247
|
-
const apiPattern = detectAPIPattern(srcFiles);
|
|
85
|
+
**Purpose:** Read and parse representative code files for detailed insights into API endpoints, data relationships, and security patterns.
|
|
248
86
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
87
|
+
### 0.3.1 Areas of Analysis
|
|
88
|
+
- **API Endpoints:** Parse routes/controllers.
|
|
89
|
+
- **Data Model:** Map entity relationships.
|
|
90
|
+
- **Security:** Detect auth patterns (JWT, OAuth), validation (Zod, Pydantic), and middleware.
|
|
253
91
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if (hasApiDir) return 'API client pattern';
|
|
257
|
-
return 'Unknown';
|
|
258
|
-
}
|
|
92
|
+
### 0.3.2 Sampling Strategy
|
|
93
|
+
Use stratified sampling to read only the most relevant files (e.g., core controllers and entities) to stay within context limits.
|
|
259
94
|
|
|
260
|
-
|
|
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
|
-
```
|
|
95
|
+
---
|
|
277
96
|
|
|
278
|
-
|
|
97
|
+
## ✅ Validation & Synthesis
|
|
279
98
|
|
|
280
|
-
|
|
281
|
-
|
|
99
|
+
### Present Findings
|
|
100
|
+
Show the final "🔍 BACKEND STACK DETECTED" report and ask for confirmation.
|
|
101
|
+
|
|
102
|
+
### 💾 Cache & Pre-populate
|
|
103
|
+
1. **Export:** Save results to `.ai-flow/cache/docs-analysis.json`.
|
|
104
|
+
2. **Pre-populate:** Fill answers for Phases 1-7 based on detected data.
|
|
282
105
|
|
|
283
|
-
|
|
284
|
-
- atoms/: 12 components
|
|
285
|
-
- molecules/: 23 components
|
|
286
|
-
- organisms/: 8 components
|
|
106
|
+
---
|
|
287
107
|
|
|
288
|
-
|
|
289
|
-
- app/: 15 routes
|
|
290
|
-
- Dynamic routes: 5
|
|
108
|
+
## 0.4 Layer 4: Documentation Audit (30-90s, CONDITIONAL)
|
|
291
109
|
|
|
292
|
-
|
|
293
|
-
- hooks/useQuery*.ts: 8 hooks
|
|
294
|
-
- services/api.ts: REST client
|
|
110
|
+
**Trigger:** Only if `docs/` or `specs/` directories exist with content.
|
|
295
111
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
3. organisms/ProductGrid.tsx (124 lines) - Product grid with pagination
|
|
112
|
+
**Purpose:** Validate existing documentation against implemented code to detect inconsistencies.
|
|
113
|
+
|
|
114
|
+
### 0.4.1 Ask User Permission
|
|
300
115
|
|
|
301
|
-
Continue to Layer 3 for deep analysis? (Y/n)
|
|
302
116
|
```
|
|
303
|
-
|
|
304
|
-
### Layer 3: Selective Deep Analysis (Optional, 60-120 seconds)
|
|
117
|
+
📚 Existing documentation detected (12 files in docs/, 3 in specs/)
|
|
305
118
|
|
|
306
|
-
|
|
119
|
+
Would you like to audit documentation vs code?
|
|
120
|
+
A) Yes, audit and show inconsistencies (recommended) ⭐
|
|
121
|
+
B) No, skip audit (continue to Phase 1)
|
|
307
122
|
|
|
308
|
-
|
|
123
|
+
> _
|
|
124
|
+
```
|
|
309
125
|
|
|
310
|
-
|
|
311
|
-
- Project is large (>50 components)
|
|
312
|
-
- Accuracy is critical
|
|
126
|
+
**If user selects B:** Skip to section 0.5 (Validation & Synthesis).
|
|
313
127
|
|
|
314
|
-
|
|
128
|
+
### 0.4.2 Parse Existing Documentation
|
|
315
129
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
130
|
+
**Action:** Extract documented information from:
|
|
131
|
+
- `docs/architecture.md` → Architecture patterns
|
|
132
|
+
- `docs/data-model.md` → Entities and fields
|
|
133
|
+
- `docs/api.md` → Endpoints and methods
|
|
134
|
+
- `specs/requirements.md` → Business requirements
|
|
319
135
|
|
|
320
|
-
|
|
321
|
-
const componentNames = files.map((f) => path.basename(f, path.extname(f)));
|
|
136
|
+
**Save to:** `.ai-flow/cache/docs-snapshot.json`
|
|
322
137
|
|
|
323
|
-
|
|
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;
|
|
138
|
+
### 0.4.3 Compare Code vs Documentation
|
|
326
139
|
|
|
327
|
-
|
|
140
|
+
**Compare:**
|
|
141
|
+
1. **Entities:** Schema files (Prisma, TypeORM, etc.) vs `docs/data-model.md`
|
|
142
|
+
2. **Endpoints:** Controllers/Routes vs `docs/api.md`
|
|
143
|
+
3. **Architecture:** Code structure vs `docs/architecture.md`
|
|
144
|
+
4. **Tech Stack:** `package.json` vs documented stack
|
|
328
145
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
};
|
|
334
|
-
}
|
|
146
|
+
**Detect:**
|
|
147
|
+
- Items in code but not in docs (undocumented features)
|
|
148
|
+
- Items in docs but not in code (missing implementations or obsolete docs)
|
|
149
|
+
- Mismatches in fields, types, or patterns
|
|
335
150
|
|
|
336
|
-
|
|
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
|
-
}
|
|
151
|
+
### 0.4.4 Classify Inconsistencies
|
|
364
152
|
|
|
365
|
-
|
|
366
|
-
const a11yPatterns = analyzeAccessibility(srcFiles);
|
|
153
|
+
**Severity Levels:**
|
|
367
154
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
155
|
+
🔴 **CRITICAL** (Requires user decision):
|
|
156
|
+
- Documented entity/endpoint not implemented
|
|
157
|
+
- Major architectural mismatch
|
|
371
158
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
if (content.includes('<button') || content.includes('<nav') || content.includes('<header')) {
|
|
376
|
-
semanticHTML++;
|
|
377
|
-
}
|
|
378
|
-
});
|
|
159
|
+
🟡 **MEDIUM** (Auto-correctable with confirmation):
|
|
160
|
+
- Implemented endpoint not documented
|
|
161
|
+
- Missing fields in docs
|
|
379
162
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
```
|
|
163
|
+
🟢 **LOW** (Auto-correctable):
|
|
164
|
+
- Obsolete fields in docs
|
|
165
|
+
- Outdated version numbers
|
|
166
|
+
|
|
167
|
+
### 0.4.5 Generate Audit Summary
|
|
386
168
|
|
|
387
|
-
|
|
169
|
+
**Output:** Concise summary (full report saved for later).
|
|
388
170
|
|
|
389
171
|
```
|
|
390
|
-
|
|
172
|
+
---
|
|
173
|
+
📊 Documentation Audit Summary
|
|
174
|
+
|
|
175
|
+
Consistency Score: 72%
|
|
391
176
|
|
|
392
|
-
|
|
393
|
-
-
|
|
394
|
-
-
|
|
395
|
-
- Hooks: use* prefix
|
|
177
|
+
🔴 Critical: 2 issues
|
|
178
|
+
- Entity 'Category' documented but not in schema
|
|
179
|
+
- Endpoint POST /api/auth/register documented but missing
|
|
396
180
|
|
|
397
|
-
|
|
398
|
-
-
|
|
399
|
-
-
|
|
400
|
-
- Tests: 48 test files (60% coverage)
|
|
401
|
-
- Storybook: Yes (23 stories)
|
|
181
|
+
🟡 Medium: 5 issues
|
|
182
|
+
- 3 endpoints implemented but not documented
|
|
183
|
+
- 2 entity fields missing in docs
|
|
402
184
|
|
|
403
|
-
|
|
404
|
-
-
|
|
405
|
-
- Semantic HTML: Good usage
|
|
406
|
-
- Recommended: WCAG 2.1 AA compliance
|
|
185
|
+
🟢 Minor: 3 issues
|
|
186
|
+
- 3 obsolete fields in documentation
|
|
407
187
|
|
|
408
|
-
|
|
188
|
+
💡 Recommendation:
|
|
189
|
+
- Review critical issues before continuing
|
|
190
|
+
- Full audit report will be generated in Phase 8
|
|
191
|
+
- Auto-corrections can be applied after Phase 8
|
|
192
|
+
---
|
|
409
193
|
```
|
|
410
|
-
---
|
|
411
|
-
## ✅ Validation & Confirmation
|
|
412
194
|
|
|
413
|
-
###
|
|
195
|
+
### 0.4.6 Handle Critical Issues (If Any)
|
|
414
196
|
|
|
415
|
-
|
|
197
|
+
**If critical issues found:**
|
|
416
198
|
|
|
417
199
|
```
|
|
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
|
-
```
|
|
200
|
+
⚠️ Critical inconsistencies detected!
|
|
434
201
|
|
|
435
|
-
|
|
202
|
+
How would you like to proceed?
|
|
203
|
+
A) Continue to Phase 1 (address issues later in Phase 8) ⭐
|
|
204
|
+
B) Review critical issues now (interactive)
|
|
205
|
+
C) Cancel /flow-build (fix manually first)
|
|
436
206
|
|
|
207
|
+
> _
|
|
437
208
|
```
|
|
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
209
|
|
|
446
|
-
|
|
210
|
+
**Option A (Recommended):** Continue to Phase 1
|
|
211
|
+
- Save audit data for Phase 8
|
|
212
|
+
- Phase 8 will offer to apply corrections
|
|
447
213
|
|
|
448
|
-
|
|
214
|
+
**Option B:** Interactive review now
|
|
449
215
|
```
|
|
216
|
+
🔴 Critical Issue 1/2: Entity 'Category'
|
|
217
|
+
Documented in docs/data-model.md but NOT in schema
|
|
450
218
|
|
|
451
|
-
|
|
219
|
+
What should we do?
|
|
220
|
+
A) Mark as "To Implement" (add to roadmap)
|
|
221
|
+
B) Mark as "Obsolete" (remove from docs in Phase 8)
|
|
222
|
+
C) Skip for now
|
|
452
223
|
|
|
224
|
+
> _
|
|
453
225
|
```
|
|
454
|
-
Please correct any incorrect detections:
|
|
455
226
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
227
|
+
**Option C:** Cancel
|
|
228
|
+
- User fixes issues manually
|
|
229
|
+
- Re-run `/flow-build` later
|
|
459
230
|
|
|
460
|
-
|
|
231
|
+
### 0.4.7 Save Audit Data
|
|
461
232
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
233
|
+
> **📌 IMPORTANT - Phases 9-10 for Existing Projects:**
|
|
234
|
+
>
|
|
235
|
+
> If the project has **substantial functional code already implemented** (detected in Layer 1-3):
|
|
236
|
+
> - Set `phase9.recommendation = "SKIP"` with reason: "Project already implemented - roadmap not needed"
|
|
237
|
+
> - Set `phase10.recommendation = "SKIP"` with reason: "Project already implemented - user stories not needed"
|
|
238
|
+
>
|
|
239
|
+
> **Phases 9-10 are only useful for:**
|
|
240
|
+
> - New projects (no code yet)
|
|
241
|
+
> - Projects in early development (< 30% features implemented)
|
|
242
|
+
>
|
|
243
|
+
> **For existing projects**, focus on Phases 1-8 (documentation sync) instead.
|
|
466
244
|
|
|
467
|
-
Save
|
|
245
|
+
**Save to:** `.ai-flow/cache/audit-data.json`
|
|
468
246
|
|
|
469
|
-
```
|
|
470
|
-
// .ai-flow/cache/frontend-context.json
|
|
247
|
+
```json
|
|
471
248
|
{
|
|
472
|
-
"
|
|
473
|
-
"
|
|
474
|
-
"
|
|
475
|
-
"
|
|
476
|
-
"
|
|
477
|
-
"
|
|
478
|
-
"
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
"
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
249
|
+
"auditPerformed": true,
|
|
250
|
+
"timestamp": "2025-12-22T16:43:00Z",
|
|
251
|
+
"consistencyScore": 72,
|
|
252
|
+
"critical": 2,
|
|
253
|
+
"medium": 5,
|
|
254
|
+
"minor": 3,
|
|
255
|
+
"userDecisions": {
|
|
256
|
+
"Category": "obsolete",
|
|
257
|
+
"POST /api/auth/register": "to_implement"
|
|
258
|
+
},
|
|
259
|
+
"phases": {
|
|
260
|
+
"phase1": {
|
|
261
|
+
"file": "project-brief.md",
|
|
262
|
+
"exists": true,
|
|
263
|
+
"consistencyScore": 100,
|
|
264
|
+
"recommendation": "SKIP",
|
|
265
|
+
"gaps": [],
|
|
266
|
+
"reason": "Complete business context documented"
|
|
267
|
+
},
|
|
268
|
+
"phase2": {
|
|
269
|
+
"file": "docs/data-model.md",
|
|
270
|
+
"exists": true,
|
|
271
|
+
"consistencyScore": 98,
|
|
272
|
+
"recommendation": "SKIP",
|
|
273
|
+
"gaps": [],
|
|
274
|
+
"reason": "All entities documented and match schema"
|
|
275
|
+
},
|
|
276
|
+
"phase3": {
|
|
277
|
+
"file": "docs/architecture.md",
|
|
278
|
+
"exists": true,
|
|
279
|
+
"consistencyScore": 87,
|
|
280
|
+
"recommendation": "HYBRID",
|
|
281
|
+
"gaps": ["api_versioning", "rate_limiting"],
|
|
282
|
+
"reason": "Architecture documented but missing 2 details"
|
|
283
|
+
},
|
|
284
|
+
"phase4": {
|
|
285
|
+
"file": "specs/security.md",
|
|
286
|
+
"exists": true,
|
|
287
|
+
"consistencyScore": 95,
|
|
288
|
+
"recommendation": "SKIP",
|
|
289
|
+
"gaps": [],
|
|
290
|
+
"reason": "Security patterns match implementation"
|
|
291
|
+
},
|
|
292
|
+
"phase5": {
|
|
293
|
+
"file": "docs/code-standards.md",
|
|
294
|
+
"exists": true,
|
|
295
|
+
"consistencyScore": 92,
|
|
296
|
+
"recommendation": "SKIP",
|
|
297
|
+
"gaps": [],
|
|
298
|
+
"reason": "Standards documented and enforced"
|
|
299
|
+
},
|
|
300
|
+
"phase6": {
|
|
301
|
+
"file": "docs/testing.md",
|
|
302
|
+
"exists": true,
|
|
303
|
+
"consistencyScore": 90,
|
|
304
|
+
"recommendation": "SKIP",
|
|
305
|
+
"gaps": [],
|
|
306
|
+
"reason": "Testing strategy documented"
|
|
307
|
+
},
|
|
308
|
+
"phase7": {
|
|
309
|
+
"file": "docs/deployment.md",
|
|
310
|
+
"exists": true,
|
|
311
|
+
"consistencyScore": 82,
|
|
312
|
+
"recommendation": "HYBRID",
|
|
313
|
+
"gaps": ["monitoring_strategy", "incident_runbooks"],
|
|
314
|
+
"reason": "Deployment documented but missing operational details"
|
|
315
|
+
},
|
|
316
|
+
"phase8": {
|
|
317
|
+
"file": "AGENT.md",
|
|
318
|
+
"exists": true,
|
|
319
|
+
"consistencyScore": 95,
|
|
320
|
+
"recommendation": "SKIP",
|
|
321
|
+
"gaps": [],
|
|
322
|
+
"reason": "Final documentation complete and up-to-date"
|
|
323
|
+
},
|
|
324
|
+
"phase9": {
|
|
325
|
+
"file": "docs/roadmap.md",
|
|
326
|
+
"exists": false,
|
|
327
|
+
"consistencyScore": 0,
|
|
328
|
+
"recommendation": "SKIP",
|
|
329
|
+
"gaps": [],
|
|
330
|
+
"reason": "Project already implemented - roadmap not needed for existing code"
|
|
331
|
+
},
|
|
332
|
+
"phase10": {
|
|
333
|
+
"file": "docs/user-stories/",
|
|
334
|
+
"exists": false,
|
|
335
|
+
"consistencyScore": 0,
|
|
336
|
+
"recommendation": "SKIP",
|
|
337
|
+
"gaps": [],
|
|
338
|
+
"reason": "Project already implemented - user stories not needed for existing features"
|
|
339
|
+
}
|
|
340
|
+
}
|
|
492
341
|
}
|
|
493
342
|
```
|
|
494
343
|
|
|
495
|
-
**
|
|
496
|
-
|
|
497
|
-
|
|
344
|
+
**Recommendation Logic:**
|
|
345
|
+
- **SKIP** (≥95%): Phase can be skipped, use existing docs
|
|
346
|
+
- **HYBRID** (80-94%): Ask only missing questions, merge with existing docs
|
|
347
|
+
- **FULL** (<80% or file missing): Execute full phase with pre-filled answers
|
|
498
348
|
|
|
499
|
-
|
|
349
|
+
This data will be used in Phases 1-7 to:
|
|
350
|
+
1. Determine if phase can be skipped
|
|
351
|
+
2. Identify specific gaps to ask about
|
|
352
|
+
3. Merge new answers with existing documentation
|
|
500
353
|
|
|
501
|
-
|
|
502
|
-
|
|
354
|
+
This data will be used in Phase 8 to:
|
|
355
|
+
1. Generate detailed audit report
|
|
356
|
+
2. Apply auto-corrections
|
|
357
|
+
3. Update roadmap with "To Implement" items
|
|
503
358
|
|
|
504
|
-
|
|
359
|
+
---
|
|
505
360
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
361
|
+
## 0.5 Validation & Synthesis
|
|
362
|
+
|
|
363
|
+
### Present Findings
|
|
364
|
+
|
|
365
|
+
Show the final report including:
|
|
366
|
+
1. **🔍 BACKEND STACK DETECTED** (from Layers 1-3)
|
|
367
|
+
2. **📊 Documentation Audit Summary** (from Layer 4, if executed)
|
|
368
|
+
|
|
369
|
+
Ask for confirmation to proceed to Phase 1.
|
|
370
|
+
|
|
371
|
+
### 💾 Cache & Pre-populate
|
|
372
|
+
|
|
373
|
+
1. **Export code analysis:** `.ai-flow/cache/docs-analysis.json`
|
|
374
|
+
2. **Export audit data:** `.ai-flow/cache/audit-data.json` (if Layer 4 executed)
|
|
375
|
+
3. **Pre-populate:** Fill answers for Phases 1-7 based on detected data
|
|
376
|
+
|
|
377
|
+
### 🎯 Set Flags for Phase 8
|
|
378
|
+
|
|
379
|
+
If documentation audit was performed:
|
|
380
|
+
- Set flag: `auditPerformed: true`
|
|
381
|
+
- Phase 8 will:
|
|
382
|
+
- Generate detailed audit report (`docs/audit-report.md`)
|
|
383
|
+
- Offer to apply auto-corrections (🟡 Medium + 🟢 Low)
|
|
384
|
+
- Update roadmap with "To Implement" items (🔴 Critical marked as such)
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
✅ **Phase 0 Complete: Context Analysis Finalized**
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
### Phase Summary
|
|
393
|
+
- Pre-populated detected tech stack values.
|
|
394
|
+
- Architectural patterns identified.
|
|
395
|
+
- Context cached in `.ai-flow/cache/docs-analysis.json`.
|
|
396
|
+
- **Documentation audit completed** (if existing docs found).
|
|
397
|
+
- **Inconsistencies flagged** for Phase 8 resolution.
|
|
510
398
|
|
|
511
|
-
|
|
399
|
+
---
|
|
512
400
|
|
|
401
|
+
**Next Phase:** Phase 1 - Discovery & Business Requirements
|
|
513
402
|
|
|
403
|
+
**What happens next:**
|
|
404
|
+
- Phase 1-7 will use pre-populated answers (40-60% filled)
|
|
405
|
+
- You'll only answer questions that couldn't be auto-detected
|
|
406
|
+
- Phase 8 will offer to resolve documentation inconsistencies
|
|
514
407
|
|
|
408
|
+
Read: `.ai-flow/prompts/backend/flow-build-phase-1.md`
|
|
515
409
|
|
|
410
|
+
---
|
|
411
|
+
_Version: 4.3 (Antigravity Optimized - With Integrated Audit)_
|
|
412
|
+
_Last Updated: 2025-12-22_
|