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.
- package/README.md +14 -13
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
- package/prompts/backend/flow-build-phase-0.md +68 -1810
- package/prompts/backend/flow-build-phase-10.md +1 -0
- package/prompts/backend/flow-build-phase-8.md +6 -7
- package/prompts/backend/flow-build-phase-9.md +1 -0
- package/prompts/backend/flow-build.md +59 -836
- package/prompts/frontend/flow-build-phase-0.md +46 -477
- package/prompts/frontend/flow-build-phase-10.md +33 -0
- package/prompts/frontend/flow-build-phase-8.md +27 -16
- package/prompts/frontend/flow-build-phase-9.md +80 -0
- package/prompts/frontend/flow-build.md +68 -414
- package/prompts/mobile/flow-build-phase-0.md +47 -360
- package/prompts/mobile/flow-build-phase-10.md +32 -0
- package/prompts/mobile/flow-build-phase-8.md +27 -16
- package/prompts/mobile/flow-build-phase-9.md +76 -0
- package/prompts/mobile/flow-build.md +67 -426
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
## PHASE 0: Context Discovery (2-5 min)
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
> **Order for this phase:** ALWAYS executed FIRST if an existing project is detected. Skip ONLY for new projects.
|
|
5
4
|
|
|
6
5
|
> **📌 Scope-based behavior:**
|
|
@@ -8,1865 +7,124 @@
|
|
|
8
7
|
> - **Autonomous Mode:** Scan all layers automatically and present the final report.
|
|
9
8
|
|
|
10
9
|
### Objective
|
|
10
|
+
Efficiently analyze existing projects using a **layered, incremental approach**.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
Efficiently analyze existing projects using a **layered, incremental approach** that:
|
|
14
|
-
|
|
15
|
-
- ✅ Handles errors gracefully
|
|
16
|
-
|
|
17
|
-
> ⚠️ **CRITICAL:** DO NOT generate README.md in this phase. README.md is ONLY generated in Phase 8 (step 8.5) after framework initialization.
|
|
18
|
-
|
|
19
|
-
### 🏗️ Analysis Architecture
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
Layer 0: Cache Check (2-5 seconds) ──→ Use cached if recent
|
|
23
|
-
↓ (if no cache or outdated)
|
|
24
|
-
Layer 1: Fast Metadata Scan (10-20 seconds, ~1,000-1,500 tokens)
|
|
25
|
-
↓
|
|
26
|
-
Layer 2: Structural Analysis (30-90 seconds, ~2,000-5,000 tokens)
|
|
27
|
-
↓
|
|
28
|
-
Layer 3: Selective Deep Analysis (1-5 minutes, ~5,000-25,000 tokens, OPTIONAL)
|
|
29
|
-
↓
|
|
30
|
-
Result Synthesis & Pre-population
|
|
31
|
-
```
|
|
32
12
|
---
|
|
33
|
-
## 0.0 Check for Existing Analysis (Layer 0)
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
🔍 Checking for previous analysis...
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
**Actions:**
|
|
40
|
-
|
|
41
|
-
1. Check if `.ai-flow/cache/docs-analysis.json` exists
|
|
42
|
-
2. If exists:
|
|
43
|
-
- Read `analyzedAt` timestamp
|
|
44
|
-
- Read `filesAnalyzed` with their timestamps
|
|
45
|
-
- Compare with current project state:
|
|
46
|
-
- Check if key files modified (package.json, composer.json, pom.xml, etc.)
|
|
47
|
-
- Count files added/modified/deleted since last analysis
|
|
48
|
-
- Calculate change ratio
|
|
49
|
-
|
|
50
|
-
**If recent analysis found (< 24 hours, < 15% files changed):**
|
|
51
|
-
|
|
52
|
-
```
|
|
53
|
-
✅ Found recent analysis from [X hours/minutes] ago
|
|
54
|
-
|
|
55
|
-
Analysis Summary:
|
|
56
|
-
• Project: [Name] ([Language] + [Framework])
|
|
57
|
-
• Entities: [X] detected
|
|
58
|
-
• Endpoints: [X] detected
|
|
59
|
-
• Last analyzed: [timestamp]
|
|
60
|
-
• Files changed since: [X] files ([Y]%)
|
|
61
|
-
|
|
62
|
-
Would you like to:
|
|
63
|
-
|
|
64
|
-
A) ✅ Use cached analysis (Instant - Recommended)
|
|
65
|
-
Context usage: ~500 tokens
|
|
66
|
-
Time: 2 seconds
|
|
67
|
-
|
|
68
|
-
B) 🔄 Re-analyze project (Full analysis)
|
|
69
|
-
Context usage: ~8,000-25,000 tokens
|
|
70
|
-
Time: 2-5 minutes
|
|
71
|
-
|
|
72
|
-
C) 📊 View cached analysis details first, then decide
|
|
73
|
-
|
|
74
|
-
Your choice: __
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
**If old analysis found (> 24 hours OR > 15% files changed):**
|
|
78
|
-
|
|
79
|
-
```
|
|
80
|
-
⚠️ Found analysis from [X days/hours] ago
|
|
81
|
-
|
|
82
|
-
Detected changes:
|
|
83
|
-
• [X] files modified: [list top 5]
|
|
84
|
-
• [X] files added
|
|
85
|
-
• [X] files deleted
|
|
86
|
-
• Dependencies changed: [Yes/No]
|
|
87
|
-
|
|
88
|
-
Recommendation: Re-analyze to ensure accuracy
|
|
89
|
-
|
|
90
|
-
Would you like to:
|
|
91
|
-
|
|
92
|
-
A) 🔄 Re-analyze (Recommended)
|
|
93
|
-
B) ✅ Use cached analysis anyway
|
|
94
|
-
C) 🎯 Incremental analysis (only analyze changes)
|
|
95
|
-
|
|
96
|
-
Your choice: __
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
**If no previous analysis:**
|
|
100
|
-
|
|
101
|
-
```
|
|
102
|
-
🆕 No previous analysis found. Starting fresh analysis...
|
|
103
|
-
|
|
104
|
-
Proceeding to Layer 1...
|
|
105
|
-
```
|
|
106
|
-
---
|
|
107
|
-
## 0.1 Layer 1: Fast Metadata Scan (10-20 seconds)
|
|
108
|
-
|
|
109
|
-
```
|
|
110
|
-
⚡ Layer 1: Scanning project metadata...
|
|
111
|
-
|
|
112
|
-
[████████████████████] 100%
|
|
113
|
-
|
|
114
|
-
This quick scan identifies your tech stack without reading code files.
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### 0.1.1 Universal Language Detection
|
|
118
|
-
|
|
119
|
-
**Detect in order of market share for efficiency:**
|
|
120
|
-
|
|
121
|
-
**1. Node.js/TypeScript/JavaScript (~35% market)**
|
|
122
|
-
|
|
123
|
-
```
|
|
124
|
-
Checking for Node.js project...
|
|
125
|
-
• Looking for: package.json, yarn.lock, pnpm-lock.yaml, bun.lockb
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
- If `package.json` exists:
|
|
129
|
-
- Read `dependencies` and `devDependencies` sections only
|
|
130
|
-
- Detect framework by dependency patterns:
|
|
131
|
-
- **NestJS**: `"@nestjs/core"` present
|
|
132
|
-
- **Express**: `"express"` present
|
|
133
|
-
- **Fastify**: `"fastify"` present
|
|
134
|
-
- **Koa**: `"koa"` present
|
|
135
|
-
- **Hapi**: `"@hapi/hapi"` present
|
|
136
|
-
- **AdonisJS**: `"@adonisjs/core"` present
|
|
137
|
-
- **Next.js**: `"next"` present (API routes)
|
|
138
|
-
- **Remix**: `"@remix-run/node"` present
|
|
139
|
-
- **tRPC**: `"@trpc/server"` present
|
|
140
|
-
- Detect ORM:
|
|
141
|
-
- **Prisma**: `"prisma"` in devDependencies + check for `prisma/schema.prisma`
|
|
142
|
-
- **TypeORM**: `"typeorm"` present
|
|
143
|
-
- **Sequelize**: `"sequelize"` present
|
|
144
|
-
- **Mongoose**: `"mongoose"` present
|
|
145
|
-
- **Drizzle**: `"drizzle-orm"` present
|
|
146
|
-
- **MikroORM**: `"@mikro-orm/core"` present
|
|
147
|
-
- **Knex**: `"knex"` present
|
|
148
|
-
- Extract versions for framework and ORM
|
|
149
|
-
|
|
150
|
-
**2. Python (~25% market)**
|
|
151
|
-
|
|
152
|
-
```
|
|
153
|
-
Checking for Python project...
|
|
154
|
-
• Looking for: requirements.txt, pyproject.toml, Pipfile, poetry.lock
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
- If found:
|
|
158
|
-
- Read dependencies list
|
|
159
|
-
- Detect framework:
|
|
160
|
-
- **FastAPI**: `fastapi` present
|
|
161
|
-
- **Django**: `django` present
|
|
162
|
-
- **Django REST Framework**: `djangorestframework` present
|
|
163
|
-
- **Flask**: `flask` present
|
|
164
|
-
- **Tornado**: `tornado` present
|
|
165
|
-
- **Sanic**: `sanic` present
|
|
166
|
-
- **Starlette**: `starlette` present
|
|
167
|
-
- Detect ORM:
|
|
168
|
-
- **SQLAlchemy**: `sqlalchemy` present
|
|
169
|
-
- **Django ORM**: (builtin with Django)
|
|
170
|
-
- **Tortoise ORM**: `tortoise-orm` present
|
|
171
|
-
- **Peewee**: `peewee` present
|
|
172
|
-
- **SQLModel**: `sqlmodel` present
|
|
173
|
-
- Extract versions
|
|
174
|
-
|
|
175
|
-
**3. PHP (~15% market)**
|
|
176
|
-
|
|
177
|
-
```
|
|
178
|
-
Checking for PHP project...
|
|
179
|
-
• Looking for: composer.json, composer.lock
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
- If `composer.json` exists:
|
|
183
|
-
- Read `require` and `require-dev` sections
|
|
184
|
-
- Detect framework:
|
|
185
|
-
- **Laravel**: `"laravel/framework"` present
|
|
186
|
-
- **Symfony**: `"symfony/symfony"` or `"symfony/framework-bundle"` present
|
|
187
|
-
- **CodeIgniter**: `"codeigniter4/framework"` present
|
|
188
|
-
- **Slim**: `"slim/slim"` present
|
|
189
|
-
- **Lumen**: `"laravel/lumen-framework"` present
|
|
190
|
-
- **Yii**: `"yiisoft/yii2"` present
|
|
191
|
-
- Detect ORM:
|
|
192
|
-
- **Eloquent**: (builtin with Laravel/Lumen)
|
|
193
|
-
- **Doctrine**: `"doctrine/orm"` present
|
|
194
|
-
- **Propel**: `"propel/propel"` present
|
|
195
|
-
- Extract PHP version from `require.php` field
|
|
196
|
-
- Extract framework/ORM versions
|
|
197
|
-
|
|
198
|
-
**4. Java (~15% market)**
|
|
199
|
-
|
|
200
|
-
```
|
|
201
|
-
Checking for Java project...
|
|
202
|
-
• Looking for: pom.xml, build.gradle, build.gradle.kts
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
- If `pom.xml` exists (Maven):
|
|
206
|
-
- Parse XML for `<dependencies>`
|
|
207
|
-
- Detect framework:
|
|
208
|
-
- **Spring Boot**: `<artifactId>spring-boot-starter` present
|
|
209
|
-
- **Micronaut**: `<artifactId>micronaut-core` present
|
|
210
|
-
- **Quarkus**: `<artifactId>quarkus-core` present
|
|
211
|
-
- **Vert.x**: `<artifactId>vertx-core` present
|
|
212
|
-
- **Dropwizard**: `<artifactId>dropwizard-core` present
|
|
213
|
-
- Detect ORM:
|
|
214
|
-
- **Hibernate/JPA**: `hibernate-core` or `spring-boot-starter-data-jpa`
|
|
215
|
-
- **MyBatis**: `mybatis` present
|
|
216
|
-
- **jOOQ**: `jooq` present
|
|
217
|
-
- Extract Java version from `<maven.compiler.source>`
|
|
218
|
-
|
|
219
|
-
- If `build.gradle` or `build.gradle.kts` exists (Gradle):
|
|
220
|
-
- Parse for `dependencies { ... }`
|
|
221
|
-
- Same framework/ORM detection as Maven
|
|
222
|
-
- Extract Java version from `sourceCompatibility`
|
|
223
|
-
|
|
224
|
-
**5. C#/.NET (~8% market)**
|
|
225
|
-
|
|
226
|
-
```
|
|
227
|
-
Checking for .NET project...
|
|
228
|
-
• Looking for: *.csproj, *.sln, Program.cs, Startup.cs
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
- Glob for `*.csproj` files
|
|
232
|
-
- If found:
|
|
233
|
-
- Parse XML for `<PackageReference>` elements
|
|
234
|
-
- Detect framework:
|
|
235
|
-
- **ASP.NET Core**: `Microsoft.AspNetCore` package present
|
|
236
|
-
- **Minimal APIs**: Check for `<LangVersion>latest</LangVersion>` + ASP.NET
|
|
237
|
-
- **Nancy**: `Nancy` package present
|
|
238
|
-
- Detect ORM:
|
|
239
|
-
- **Entity Framework Core**: `Microsoft.EntityFrameworkCore` present
|
|
240
|
-
- **Dapper**: `Dapper` present
|
|
241
|
-
- **NHibernate**: `NHibernate` present
|
|
242
|
-
- Extract .NET version from `<TargetFramework>` (e.g., `net8.0`)
|
|
243
|
-
- Extract package versions
|
|
244
|
-
|
|
245
|
-
**6. Go (~5% market)**
|
|
246
13
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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`
|
|
251
20
|
|
|
252
|
-
|
|
253
|
-
- Parse for `require (...)` block
|
|
254
|
-
- Detect framework:
|
|
255
|
-
- **Gin**: `github.com/gin-gonic/gin` present
|
|
256
|
-
- **Echo**: `github.com/labstack/echo` present
|
|
257
|
-
- **Fiber**: `github.com/gofiber/fiber` present
|
|
258
|
-
- **Chi**: `github.com/go-chi/chi` present
|
|
259
|
-
- **Buffalo**: `github.com/gobuffalo/buffalo` present
|
|
260
|
-
- Detect ORM:
|
|
261
|
-
- **GORM**: `gorm.io/gorm` present
|
|
262
|
-
- **Ent**: `entgo.io/ent` present
|
|
263
|
-
- **sqlx**: `github.com/jmoiron/sqlx` present
|
|
264
|
-
- **sqlc**: `github.com/kyleconroy/sqlc` present
|
|
265
|
-
- Extract Go version from `go 1.xx` line
|
|
266
|
-
- Extract dependency versions
|
|
21
|
+
**A project is considered "Existing" only if it contains functional source code or framework configuration files OUTSIDE these excluded paths.**
|
|
267
22
|
|
|
268
|
-
**7. Ruby (~3% market)**
|
|
269
|
-
|
|
270
|
-
```
|
|
271
|
-
Checking for Ruby project...
|
|
272
|
-
• Looking for: Gemfile, Gemfile.lock
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
- If `Gemfile` exists:
|
|
276
|
-
- Parse for `gem '...'` lines
|
|
277
|
-
- Detect framework:
|
|
278
|
-
- **Ruby on Rails**: `gem 'rails'` present
|
|
279
|
-
- **Sinatra**: `gem 'sinatra'` present
|
|
280
|
-
- **Hanami**: `gem 'hanami'` present
|
|
281
|
-
- **Grape**: `gem 'grape'` present
|
|
282
|
-
- Detect ORM:
|
|
283
|
-
- **ActiveRecord**: `gem 'activerecord'` or builtin with Rails
|
|
284
|
-
- **Sequel**: `gem 'sequel'` present
|
|
285
|
-
- **ROM**: `gem 'rom'` present
|
|
286
|
-
- Extract Ruby version from `ruby '...'` line
|
|
287
|
-
- Extract gem versions
|
|
288
|
-
|
|
289
|
-
**8. Kotlin (~2% market)**
|
|
290
|
-
|
|
291
|
-
```
|
|
292
|
-
Checking for Kotlin project...
|
|
293
|
-
• Looking for: build.gradle.kts, pom.xml with kotlin plugin
|
|
294
|
-
```
|
|
295
|
-
|
|
296
|
-
- If `build.gradle.kts` exists:
|
|
297
|
-
- Check for `kotlin("jvm")` or `org.jetbrains.kotlin` plugin
|
|
298
|
-
- Detect framework:
|
|
299
|
-
- **Ktor**: `io.ktor:ktor-server-core` present
|
|
300
|
-
- **Spring Boot**: `org.springframework.boot` + kotlin present
|
|
301
|
-
- **Javalin**: `io.javalin:javalin` present
|
|
302
|
-
- **http4k**: `org.http4k` present
|
|
303
|
-
- Detect ORM:
|
|
304
|
-
- **Exposed**: `org.jetbrains.exposed` present
|
|
305
|
-
- **Hibernate**: `org.hibernate` present
|
|
306
|
-
- Extract Kotlin version
|
|
307
|
-
|
|
308
|
-
**9. Rust (~1% market)**
|
|
309
|
-
|
|
310
|
-
```
|
|
311
|
-
Checking for Rust project...
|
|
312
|
-
• Looking for: Cargo.toml, Cargo.lock
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
- If `Cargo.toml` exists:
|
|
316
|
-
- Parse TOML for `[dependencies]`
|
|
317
|
-
- Detect framework:
|
|
318
|
-
- **Actix-web**: `actix-web` present
|
|
319
|
-
- **Rocket**: `rocket` present
|
|
320
|
-
- **Axum**: `axum` present
|
|
321
|
-
- **Warp**: `warp` present
|
|
322
|
-
- Detect ORM:
|
|
323
|
-
- **Diesel**: `diesel` present
|
|
324
|
-
- **SeaORM**: `sea-orm` present
|
|
325
|
-
- **sqlx**: `sqlx` present
|
|
326
|
-
- Extract Rust version from `rust-version` field
|
|
327
|
-
|
|
328
|
-
**10. Elixir**
|
|
329
|
-
|
|
330
|
-
```
|
|
331
|
-
Checking for Elixir project...
|
|
332
|
-
• Looking for: mix.exs
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
- If `mix.exs` exists:
|
|
336
|
-
- Parse for `deps do` section
|
|
337
|
-
- Detect framework:
|
|
338
|
-
- **Phoenix**: `{:phoenix,` present
|
|
339
|
-
- Detect ORM:
|
|
340
|
-
- **Ecto**: `{:ecto,` present (usually with Phoenix)
|
|
341
|
-
- Extract Elixir version
|
|
342
|
-
|
|
343
|
-
**11. Scala**
|
|
344
|
-
|
|
345
|
-
```
|
|
346
|
-
Checking for Scala project...
|
|
347
|
-
• Looking for: build.sbt
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
- If `build.sbt` exists:
|
|
351
|
-
- Parse for `libraryDependencies`
|
|
352
|
-
- Detect framework:
|
|
353
|
-
- **Play Framework**: `"com.typesafe.play"` present
|
|
354
|
-
- **Akka HTTP**: `"com.typesafe.akka" % "akka-http"` present
|
|
355
|
-
- Detect ORM:
|
|
356
|
-
- **Slick**: `"com.typesafe.slick"` present
|
|
357
|
-
- **Quill**: `"io.getquill"` present
|
|
358
|
-
|
|
359
|
-
**12. Swift**
|
|
360
|
-
|
|
361
|
-
```
|
|
362
|
-
Checking for Swift project...
|
|
363
|
-
• Looking for: Package.swift
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
- If `Package.swift` exists:
|
|
367
|
-
- Parse for `.package(url:` lines
|
|
368
|
-
- Detect framework:
|
|
369
|
-
- **Vapor**: `"vapor/vapor"` in URL
|
|
370
|
-
- Detect ORM:
|
|
371
|
-
- **Fluent**: `"vapor/fluent"` in URL (usually with Vapor)
|
|
372
|
-
|
|
373
|
-
### 0.1.2 Find Existing AI Configurations
|
|
374
|
-
|
|
375
|
-
**Quick glob search (no file reading yet):**
|
|
376
|
-
|
|
377
|
-
- `AGENT.md`
|
|
378
|
-
- `ai-instructions.md`
|
|
379
|
-
- `.clauderules`
|
|
380
|
-
- `.cursorrules`
|
|
381
|
-
- `.clinerules`
|
|
382
|
-
- `.geminirules`
|
|
383
|
-
- `.windsurfrules`
|
|
384
|
-
- `.github/copilot-instructions.md`
|
|
385
|
-
|
|
386
|
-
**Record:** Which files exist (paths only)
|
|
387
|
-
|
|
388
|
-
### 0.1.3 Find Documentation Files
|
|
389
|
-
|
|
390
|
-
**Quick glob search:**
|
|
391
|
-
|
|
392
|
-
- `README.md`
|
|
393
|
-
- `CLAUDE.md`
|
|
394
|
-
- `CONTRIBUTING.md`
|
|
395
|
-
- `docs/*.md` (count only)
|
|
396
|
-
|
|
397
|
-
**Record:** Paths and count
|
|
398
|
-
|
|
399
|
-
### 0.1.4 Output Layer 1 Results
|
|
400
|
-
|
|
401
|
-
```
|
|
402
|
-
✅ Layer 1 Complete (15 seconds)
|
|
403
|
-
|
|
404
|
-
📦 Project Detected:
|
|
405
23
|
---
|
|
406
|
-
Name: [from package.json/composer.json/etc.]
|
|
407
|
-
Language: [TypeScript/Python/PHP/Java/etc.]
|
|
408
|
-
Version: [language version]
|
|
409
|
-
Package Manager: [npm/composer/maven/etc.]
|
|
410
|
-
---
|
|
411
|
-
🚀 Framework: [Name] v[version]
|
|
412
|
-
🗄️ ORM/Database: [Name] v[version]
|
|
413
24
|
|
|
414
|
-
|
|
415
|
-
• AI Configs: [X files found: AGENT.md, .clauderules, etc.]
|
|
416
|
-
• Docs: [X files in docs/]
|
|
417
|
-
• README: [Yes/No]
|
|
25
|
+
## 0.0 Check for Existing Analysis (Layer 0)
|
|
418
26
|
|
|
419
|
-
|
|
420
|
-
⏱️ Time Elapsed: 15s
|
|
421
|
-
---
|
|
422
|
-
Continue to Layer 2? (Structural analysis - no code reading yet)
|
|
27
|
+
Check if `.ai-flow/cache/docs-analysis.json` exists and is fresh.
|
|
423
28
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
C) 🛑 Stop here - Use only Layer 1 data
|
|
29
|
+
**If found:**
|
|
30
|
+
Ask user to use cached analysis or re-analyze.
|
|
427
31
|
|
|
428
|
-
|
|
429
|
-
|
|
32
|
+
**If not found:**
|
|
33
|
+
Proceed to Layer 1.
|
|
430
34
|
|
|
431
|
-
**Context Usage:** ~1,000-1,500 tokens
|
|
432
35
|
---
|
|
433
|
-
## 0.2 Layer 2: Structural Analysis (30-90 seconds)
|
|
434
|
-
|
|
435
|
-
```
|
|
436
|
-
🏗️ Layer 2: Analyzing project structure...
|
|
437
|
-
|
|
438
|
-
This scans directory organization and file counts without reading code.
|
|
439
|
-
```
|
|
440
|
-
|
|
441
|
-
### 0.2.1 Directory Structure Analysis
|
|
442
|
-
|
|
443
|
-
**Language-specific directory patterns:**
|
|
444
|
-
|
|
445
|
-
**Node.js/TypeScript:**
|
|
446
|
-
|
|
447
|
-
```
|
|
448
|
-
Scanning directories:
|
|
449
|
-
• src/**/* or app/**/* or lib/**/*
|
|
450
|
-
|
|
451
|
-
Counting files by pattern:
|
|
452
|
-
• Controllers: *.controller.{ts,js,tsx,jsx}
|
|
453
|
-
• Services: *.service.{ts,js}
|
|
454
|
-
• Modules: *.module.{ts,js}
|
|
455
|
-
• Entities: *.entity.{ts,js}
|
|
456
|
-
• DTOs: *.dto.{ts,js}
|
|
457
|
-
• Repositories: *.repository.{ts,js}
|
|
458
|
-
• Middleware: *.middleware.{ts,js}
|
|
459
|
-
• Guards: *.guard.{ts,js}
|
|
460
|
-
• Tests: *.spec.{ts,js}, *.test.{ts,js}
|
|
461
|
-
```
|
|
462
|
-
|
|
463
|
-
**Python:**
|
|
464
|
-
|
|
465
|
-
```
|
|
466
|
-
Scanning directories:
|
|
467
|
-
• app/**/*.py or src/**/*.py
|
|
468
|
-
|
|
469
|
-
Counting files by pattern:
|
|
470
|
-
• Views/Controllers: views.py, *_views.py, *_controller.py
|
|
471
|
-
• Models: models.py, *_models.py
|
|
472
|
-
• Serializers: serializers.py, *_serializers.py
|
|
473
|
-
• Services: *_service.py, services.py
|
|
474
|
-
• Routes: urls.py, routes.py
|
|
475
|
-
• Tests: test_*.py, *_test.py
|
|
476
|
-
```
|
|
477
|
-
|
|
478
|
-
**PHP:**
|
|
479
|
-
|
|
480
|
-
```
|
|
481
|
-
Scanning directories:
|
|
482
|
-
• app/**/*.php or src/**/*.php
|
|
483
|
-
|
|
484
|
-
Counting files by pattern:
|
|
485
|
-
• Controllers: app/Http/Controllers/**/*.php, src/Controller/**/*.php
|
|
486
|
-
• Models: app/Models/**/*.php, src/Entity/**/*.php
|
|
487
|
-
• Middleware: app/Http/Middleware/**/*.php
|
|
488
|
-
• Migrations: database/migrations/**/*.php, migrations/**/*.php
|
|
489
|
-
• Tests: tests/**/*.php
|
|
490
|
-
```
|
|
491
|
-
|
|
492
|
-
**Java:**
|
|
493
|
-
|
|
494
|
-
```
|
|
495
|
-
Scanning directories:
|
|
496
|
-
• src/main/java/**/*.java
|
|
497
|
-
|
|
498
|
-
Counting files by pattern:
|
|
499
|
-
• Controllers: **/*Controller.java
|
|
500
|
-
• Services: **/*Service.java
|
|
501
|
-
• Repositories: **/*Repository.java
|
|
502
|
-
• Entities: **/*Entity.java
|
|
503
|
-
• DTOs: **/*DTO.java, **/*Request.java, **/*Response.java
|
|
504
|
-
• Tests: src/test/java/**/*Test.java
|
|
505
|
-
```
|
|
506
|
-
|
|
507
|
-
**C#/.NET:**
|
|
508
|
-
|
|
509
|
-
```
|
|
510
|
-
Scanning directories:
|
|
511
|
-
• **/*.cs (excluding obj/, bin/)
|
|
512
|
-
|
|
513
|
-
Counting files by pattern:
|
|
514
|
-
• Controllers: **/*Controller.cs
|
|
515
|
-
• Services: **/Services/**/*.cs
|
|
516
|
-
• Models: **/Models/**/*.cs
|
|
517
|
-
• Entities: **/Entities/**/*.cs
|
|
518
|
-
• Repositories: **/*Repository.cs
|
|
519
|
-
• Tests: **/*Tests.cs, **/*Test.cs
|
|
520
|
-
```
|
|
521
36
|
|
|
522
|
-
|
|
37
|
+
// turbo
|
|
38
|
+
## ⚡ Layer 1: Fast Metadata Scan (10-20 seconds)
|
|
523
39
|
|
|
524
|
-
|
|
525
|
-
Scanning directories:
|
|
526
|
-
• **/*.go (excluding vendor/)
|
|
40
|
+
**Purpose:** Detect framework, language, build tool, and existing AI configurations.
|
|
527
41
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
```
|
|
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)
|
|
535
48
|
|
|
536
|
-
|
|
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.).
|
|
537
51
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
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.**
|
|
541
59
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
• Views: app/views/**/*.erb
|
|
546
|
-
• Migrations: db/migrate/**/*.rb
|
|
547
|
-
• Tests: spec/**/*_spec.rb, test/**/*_test.rb
|
|
548
|
-
```
|
|
60
|
+
### 0.1.2 Find AI & Documentation
|
|
61
|
+
- Find existing AI configs (`AGENT.md`, `.cursorrules`, etc.)
|
|
62
|
+
- Scan for `README.md` and existing `docs/`.
|
|
549
63
|
|
|
550
|
-
###
|
|
64
|
+
### Layer 1 Output
|
|
65
|
+
Show a summary of detected Name, Language, Framework, ORM, and Documentation files.
|
|
551
66
|
|
|
552
|
-
**Infer pattern from directory structure:**
|
|
553
|
-
|
|
554
|
-
- **Feature-based:** Directories like `src/users/`, `src/products/`, `src/orders/`
|
|
555
|
-
- **Layer-based:** Directories like `src/controllers/`, `src/services/`, `src/repositories/`
|
|
556
|
-
- **Modular Monolith:** Directories like `src/modules/users/`, `src/modules/products/`
|
|
557
|
-
- **Hybrid:** Mix of above patterns
|
|
558
|
-
|
|
559
|
-
### 0.2.3 Schema/Entity Detection (Read ONLY schema files)
|
|
560
|
-
|
|
561
|
-
**Based on detected ORM:**
|
|
562
|
-
|
|
563
|
-
**Prisma:**
|
|
564
|
-
|
|
565
|
-
- Read `prisma/schema.prisma`
|
|
566
|
-
- Extract model names only (regex: `model (\w+)`)
|
|
567
|
-
- Count total models
|
|
568
|
-
- Count relationships (count occurrences of `@relation`)
|
|
569
|
-
|
|
570
|
-
**TypeORM:**
|
|
571
|
-
|
|
572
|
-
- Glob `*.entity.{ts,js}`
|
|
573
|
-
- Extract entity names from `@Entity()` decorator (regex, no full parsing)
|
|
574
|
-
- Count entities
|
|
575
|
-
|
|
576
|
-
**Sequelize:**
|
|
577
|
-
|
|
578
|
-
- Glob `models/**/*.{ts,js}`
|
|
579
|
-
- Count model files
|
|
580
|
-
|
|
581
|
-
**Mongoose:**
|
|
582
|
-
|
|
583
|
-
- Glob `*.schema.{ts,js}` or `models/**/*.{ts,js}`
|
|
584
|
-
- Search for `new Schema(` pattern
|
|
585
|
-
- Count schemas
|
|
586
|
-
|
|
587
|
-
**Django:**
|
|
588
|
-
|
|
589
|
-
- Read `*/models.py` files
|
|
590
|
-
- Extract class names inheriting from `models.Model` (regex)
|
|
591
|
-
- Count models
|
|
592
|
-
|
|
593
|
-
**SQLAlchemy:**
|
|
594
|
-
|
|
595
|
-
- Read `**/models.py` or `**/*_model.py`
|
|
596
|
-
- Extract classes with `Base` or `db.Model` (regex)
|
|
597
|
-
- Count models
|
|
598
|
-
|
|
599
|
-
**Eloquent (Laravel):**
|
|
600
|
-
|
|
601
|
-
- Glob `app/Models/**/*.php`
|
|
602
|
-
- Count model files
|
|
603
|
-
|
|
604
|
-
**Doctrine (Symfony/PHP):**
|
|
605
|
-
|
|
606
|
-
- Glob `src/Entity/**/*.php`
|
|
607
|
-
- Count entity files
|
|
608
|
-
|
|
609
|
-
**Hibernate/JPA (Java):**
|
|
610
|
-
|
|
611
|
-
- Glob `**/*Entity.java`
|
|
612
|
-
- Count entity files
|
|
613
|
-
|
|
614
|
-
**Entity Framework (.NET):**
|
|
615
|
-
|
|
616
|
-
- Glob `**/Models/**/*.cs` or `**/Entities/**/*.cs`
|
|
617
|
-
- Count entity files
|
|
618
|
-
|
|
619
|
-
**GORM (Go):**
|
|
620
|
-
|
|
621
|
-
- Search for `type.*struct` in `models/**/*.go`
|
|
622
|
-
- Count structs
|
|
623
|
-
|
|
624
|
-
**ActiveRecord (Ruby):**
|
|
625
|
-
|
|
626
|
-
- Glob `app/models/**/*.rb`
|
|
627
|
-
- Count model files
|
|
628
|
-
|
|
629
|
-
### 0.2.4 Test Coverage Estimation
|
|
630
|
-
|
|
631
|
-
- Count test files
|
|
632
|
-
- Count source files (non-test)
|
|
633
|
-
- Calculate ratio: `test_files / source_files`
|
|
634
|
-
- Estimate coverage tier:
|
|
635
|
-
- **Low:** < 0.2 ratio (~0-30% coverage)
|
|
636
|
-
- **Medium:** 0.2-0.6 ratio (~30-60% coverage)
|
|
637
|
-
- **High:** > 0.6 ratio (~60%+ coverage)
|
|
638
|
-
|
|
639
|
-
### 0.2.5 Documentation Maturity Assessment
|
|
640
|
-
|
|
641
|
-
**Count and categorize docs:**
|
|
642
|
-
|
|
643
|
-
```
|
|
644
|
-
Checking docs/ directory...
|
|
645
|
-
• architecture.md [✅ exists / ❌ missing]
|
|
646
|
-
• api.md [✅ exists / ❌ missing]
|
|
647
|
-
• data-model.md [✅ exists / ❌ missing]
|
|
648
|
-
• security.md [✅ exists / ❌ missing]
|
|
649
|
-
• testing.md [✅ exists / ❌ missing]
|
|
650
|
-
• operations.md [✅ exists / ❌ missing]
|
|
651
|
-
• code-standards.md [✅ exists / ❌ missing]
|
|
652
|
-
• contributing.md [✅ exists / ❌ missing]
|
|
653
|
-
```
|
|
654
|
-
|
|
655
|
-
**Maturity Level:**
|
|
656
|
-
|
|
657
|
-
- 🌱 **Minimal:** 0-1 docs → Suggest **MVP or Production-Ready scope**
|
|
658
|
-
- 🌿 **Basic:** 2-4 docs → Suggest **Production-Ready scope**
|
|
659
|
-
- 🌳 **Comprehensive:** 5-7 docs → Suggest **Production-Ready or Enterprise scope**
|
|
660
|
-
- 🏢 **Enterprise:** 8+ docs → Suggest **Enterprise scope**
|
|
661
|
-
|
|
662
|
-
### 0.2.6 Output Layer 2 Results
|
|
663
|
-
|
|
664
|
-
```
|
|
665
|
-
✅ Layer 2 Complete (60 seconds)
|
|
666
|
-
|
|
667
|
-
🏛️ Architecture Pattern: [Feature-based/Layer-based/Modular/Hybrid]
|
|
668
|
-
|
|
669
|
-
📊 Code Structure:
|
|
670
67
|
---
|
|
671
|
-
[Language-specific breakdown, e.g., for Node.js:]
|
|
672
|
-
|
|
673
|
-
Controllers: [X files]
|
|
674
|
-
Services: [X files]
|
|
675
|
-
Entities: [X files]
|
|
676
|
-
DTOs: [X files]
|
|
677
|
-
Tests: [X files] → Coverage estimate: [Low/Medium/High]
|
|
678
68
|
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
Views/Controllers: [X files]
|
|
682
|
-
Models: [X files]
|
|
683
|
-
Serializers: [X files]
|
|
684
|
-
Services: [X files]
|
|
685
|
-
Tests: [X files] → Coverage estimate: [Low/Medium/High]
|
|
686
|
-
|
|
687
|
-
[etc., adapt to detected language]
|
|
688
|
-
---
|
|
689
|
-
📂 Organization:
|
|
690
|
-
[Example for Feature-based:]
|
|
691
|
-
✓ src/users/ (3 controllers, 5 services, 2 entities)
|
|
692
|
-
✓ src/products/ (2 controllers, 3 services, 1 entity)
|
|
693
|
-
✓ src/orders/ (2 controllers, 4 services, 2 entities)
|
|
69
|
+
## 0.2 Layer 2: Structural Analysis (30-90 seconds)
|
|
694
70
|
|
|
695
|
-
|
|
696
|
-
✓ src/controllers/ (7 files)
|
|
697
|
-
✓ src/services/ (12 files)
|
|
698
|
-
✓ src/entities/ (5 files)
|
|
71
|
+
**Purpose:** Analyze directory organization and architecture patterns without reading code line-by-line.
|
|
699
72
|
|
|
700
|
-
|
|
701
|
-
|
|
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.
|
|
702
77
|
|
|
703
|
-
|
|
704
|
-
|
|
78
|
+
### Layer 2 Output
|
|
79
|
+
Summary of Architecture Pattern, Code Structure counts (Controllers, Services, etc.), and Recommended Build Scope (MVP/Production/Enterprise).
|
|
705
80
|
|
|
706
|
-
💾 Context Used: ~3,500 tokens (total: ~4,700)
|
|
707
|
-
⏱️ Time Elapsed: 1m 15s
|
|
708
81
|
---
|
|
709
|
-
💡 Recommended Scope: [MVP / Production-Ready / Enterprise]
|
|
710
|
-
(Based on detected maturity level and code complexity)
|
|
711
|
-
|
|
712
|
-
Continue to Layer 3? (Deep code analysis - reads files)
|
|
713
|
-
|
|
714
|
-
A) ✅ Yes - Full deep analysis (all areas)
|
|
715
|
-
B) 🎯 Selective - Choose specific areas to analyze
|
|
716
|
-
C) ⏭️ Skip - Use Layer 1+2 data only (faster, less detailed)
|
|
717
82
|
|
|
718
|
-
Your choice: __
|
|
719
|
-
```
|
|
720
|
-
|
|
721
|
-
**Context Usage:** ~2,000-5,000 tokens (cumulative: ~3,000-6,500)
|
|
722
|
-
---
|
|
723
83
|
## 0.3 Layer 3: Selective Deep Analysis (1-5 minutes, OPTIONAL)
|
|
724
84
|
|
|
725
|
-
|
|
726
|
-
🔬 Layer 3: Performing deep code analysis...
|
|
727
|
-
|
|
728
|
-
This reads and parses actual code files for detailed insights.
|
|
729
|
-
⚠️ This will use 5,000-25,000 tokens depending on selections.
|
|
730
|
-
```
|
|
731
|
-
|
|
732
|
-
### 0.3.1 Area Selection
|
|
733
|
-
|
|
734
|
-
**If user chose "Selective", present options:**
|
|
735
|
-
|
|
736
|
-
```
|
|
737
|
-
Which areas should I analyze deeply?
|
|
738
|
-
|
|
739
|
-
Select areas (use arrow keys, space to select, enter to confirm):
|
|
740
|
-
|
|
741
|
-
[✓] API Endpoints & Routes
|
|
742
|
-
Parse controllers/routes to extract all endpoints
|
|
743
|
-
⏱️ Estimated time: 60-90 seconds
|
|
744
|
-
💾 Context cost: ~5,000-10,000 tokens
|
|
745
|
-
|
|
746
|
-
[✓] Entity Relationships & Data Model
|
|
747
|
-
Read entity/model files to map relationships
|
|
748
|
-
⏱️ Estimated time: 30-60 seconds
|
|
749
|
-
💾 Context cost: ~3,000-6,000 tokens
|
|
750
|
-
|
|
751
|
-
[✓] Security Patterns
|
|
752
|
-
Detect auth, validation, rate limiting, CORS
|
|
753
|
-
⏱️ Estimated time: 20-30 seconds
|
|
754
|
-
💾 Context cost: ~1,000-2,000 tokens
|
|
755
|
-
|
|
756
|
-
[ ] Testing Infrastructure
|
|
757
|
-
Analyze test files and patterns
|
|
758
|
-
⏱️ Estimated time: 15-20 seconds
|
|
759
|
-
💾 Context cost: ~1,000-2,000 tokens
|
|
760
|
-
|
|
761
|
-
[ ] Business Logic Patterns (Advanced)
|
|
762
|
-
Read service files for business flows
|
|
763
|
-
⏱️ Estimated time: 90-120 seconds
|
|
764
|
-
💾 Context cost: ~8,000-15,000 tokens
|
|
765
|
-
⚠️ HIGH CONTEXT USAGE
|
|
766
|
-
---
|
|
767
|
-
Total estimated: ~2-3 minutes, ~9,000-18,000 tokens
|
|
768
|
-
|
|
769
|
-
Or:
|
|
770
|
-
A) ✅ Analyze all areas (Maximum detail, ~25,000 tokens)
|
|
771
|
-
B) 📋 Use scope-based defaults:
|
|
772
|
-
- MVP scope: Only Security Patterns
|
|
773
|
-
- Production-Ready: Endpoints + Entities + Security
|
|
774
|
-
- Enterprise: All areas
|
|
775
|
-
|
|
776
|
-
Your choice: __
|
|
777
|
-
```
|
|
778
|
-
|
|
779
|
-
### 0.3.2 Smart File Sampling Strategy
|
|
780
|
-
|
|
781
|
-
**Don't read ALL files - use stratified sampling:**
|
|
782
|
-
|
|
783
|
-
```typescript
|
|
784
|
-
// Pseudo-algorithm for file sampling
|
|
785
|
-
|
|
786
|
-
function selectFilesToAnalyze(files: string[], category: string, maxFiles: number = 30) {
|
|
787
|
-
// Priority by category
|
|
788
|
-
const priorities = {
|
|
789
|
-
controllers: 10,
|
|
790
|
-
services: 9,
|
|
791
|
-
entities: 10,
|
|
792
|
-
repositories: 8,
|
|
793
|
-
dto: 7,
|
|
794
|
-
};
|
|
795
|
-
|
|
796
|
-
// Group by module/feature
|
|
797
|
-
const byModule = groupBy(files, (file) => file.split('/')[1]);
|
|
798
|
-
|
|
799
|
-
// Sample proportionally from each module
|
|
800
|
-
const samples = [];
|
|
801
|
-
const modules = Object.keys(byModule);
|
|
802
|
-
const perModule = Math.ceil(maxFiles / modules.length);
|
|
803
|
-
|
|
804
|
-
for (const module of modules) {
|
|
805
|
-
const moduleFiles = byModule[module];
|
|
806
|
-
// Take first N files from each module for diversity
|
|
807
|
-
samples.push(...moduleFiles.slice(0, perModule));
|
|
808
|
-
|
|
809
|
-
if (samples.length >= maxFiles) break;
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
return samples.slice(0, maxFiles);
|
|
813
|
-
}
|
|
814
|
-
```
|
|
815
|
-
|
|
816
|
-
**Sampling Limits by Project Size:**
|
|
817
|
-
|
|
818
|
-
- **Small (<50 files):** Analyze all
|
|
819
|
-
- **Medium (50-200 files):** Sample 40-50 files (stratified)
|
|
820
|
-
- **Large (200-500 files):** Sample 50-70 files (stratified)
|
|
821
|
-
- **Very Large (>500 files):** Sample 70-100 files (stratified)
|
|
822
|
-
|
|
823
|
-
### 0.3.3 Context Budget Management
|
|
824
|
-
|
|
825
|
-
**Monitor token usage actively:**
|
|
826
|
-
|
|
827
|
-
```
|
|
828
|
-
🎯 Context Budget Tracker
|
|
829
|
-
|
|
830
|
-
Available for analysis: 30,000 tokens
|
|
831
|
-
Reserved for phases 1-7: 140,000 tokens
|
|
832
|
-
Buffer: 10,000 tokens
|
|
833
|
-
|
|
834
|
-
Current usage:
|
|
835
|
-
[████████░░░░░░░░░░░░] 40% - 12,000 tokens used
|
|
836
|
-
|
|
837
|
-
Remaining: 18,000 tokens
|
|
838
|
-
```
|
|
839
|
-
|
|
840
|
-
**Stop if approaching limit:**
|
|
841
|
-
|
|
842
|
-
```
|
|
843
|
-
⚠️ Context budget 90% consumed (27,000/30,000 tokens)
|
|
844
|
-
|
|
845
|
-
Analyzed so far:
|
|
846
|
-
✅ 45 of 78 controller files (57%)
|
|
847
|
-
✅ 23 of 45 entity files (51%)
|
|
848
|
-
⏸️ Pausing analysis to preserve context budget
|
|
849
|
-
|
|
850
|
-
Would you like to:
|
|
851
|
-
A) 📊 Continue with remaining files (may hit limit)
|
|
852
|
-
B) ✅ Stop here and use partial analysis (recommended)
|
|
853
|
-
C) 🔄 Export current analysis and restart with fresh context
|
|
854
|
-
|
|
855
|
-
Your choice: __
|
|
856
|
-
```
|
|
857
|
-
|
|
858
|
-
### 0.3.4 Language-Specific Deep Analysis
|
|
859
|
-
|
|
860
|
-
**Node.js/TypeScript:**
|
|
861
|
-
|
|
862
|
-
**API Endpoints (NestJS):**
|
|
863
|
-
|
|
864
|
-
```typescript
|
|
865
|
-
// Sample up to 30 controller files
|
|
866
|
-
const controllerFiles = glob('**/*.controller.{ts,js}').slice(0, 30);
|
|
867
|
-
|
|
868
|
-
for (const file of controllerFiles) {
|
|
869
|
-
const content = readFile(file);
|
|
870
|
-
|
|
871
|
-
// Extract using regex (faster than full AST parsing)
|
|
872
|
-
const controllerMatch = /@Controller\(['"](.+?)['"]\)/.exec(content);
|
|
873
|
-
const basePath = controllerMatch?.[1] || '';
|
|
874
|
-
|
|
875
|
-
const routes = [
|
|
876
|
-
...content.matchAll(/@Get\(['"](.+?)['"]\)\s+(\w+)/g),
|
|
877
|
-
...content.matchAll(/@Post\(['"](.+?)['"]\)\s+(\w+)/g),
|
|
878
|
-
...content.matchAll(/@Put\(['"](.+?)['"]\)\s+(\w+)/g),
|
|
879
|
-
...content.matchAll(/@Delete\(['"](.+?)['"]\)\s+(\w+)/g),
|
|
880
|
-
...content.matchAll(/@Patch\(['"](.+?)['"]\)\s+(\w+)/g),
|
|
881
|
-
];
|
|
882
|
-
|
|
883
|
-
for (const [fullMatch, path, handlerName, method] of routes) {
|
|
884
|
-
endpoints.push({
|
|
885
|
-
method: method,
|
|
886
|
-
path: `${basePath}/${path}`,
|
|
887
|
-
handler: handlerName,
|
|
888
|
-
file: file,
|
|
889
|
-
});
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
```
|
|
893
|
-
|
|
894
|
-
**API Endpoints (Express):**
|
|
895
|
-
|
|
896
|
-
```typescript
|
|
897
|
-
const routeFiles = glob('**/routes/**/*.{ts,js}').slice(0, 20);
|
|
898
|
-
|
|
899
|
-
for (const file of routeFiles) {
|
|
900
|
-
const content = readFile(file);
|
|
901
|
-
|
|
902
|
-
const routes = [
|
|
903
|
-
...content.matchAll(/router\.(get|post|put|delete|patch)\(['"](.+?)['"],\s*(\w+)/g),
|
|
904
|
-
...content.matchAll(/app\.(get|post|put|delete|patch)\(['"](.+?)['"],\s*(\w+)/g),
|
|
905
|
-
];
|
|
906
|
-
|
|
907
|
-
for (const [, method, path, handler] of routes) {
|
|
908
|
-
endpoints.push({ method: method.toUpperCase(), path, handler, file });
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
```
|
|
912
|
-
|
|
913
|
-
**Entities (Prisma):**
|
|
914
|
-
|
|
915
|
-
```typescript
|
|
916
|
-
// Read prisma/schema.prisma
|
|
917
|
-
const schema = readFile('prisma/schema.prisma');
|
|
918
|
-
|
|
919
|
-
// Extract models
|
|
920
|
-
const models = [...schema.matchAll(/model\s+(\w+)\s*\{([^}]+)\}/gs)];
|
|
921
|
-
|
|
922
|
-
for (const [, modelName, body] of models) {
|
|
923
|
-
const fields = [...body.matchAll(/(\w+)\s+(\w+)(?:\?)?(?:\s+@(\w+))?/g)];
|
|
924
|
-
|
|
925
|
-
const entity = {
|
|
926
|
-
name: modelName,
|
|
927
|
-
fields: fields.map(([, name, type, decorator]) => ({
|
|
928
|
-
name,
|
|
929
|
-
type,
|
|
930
|
-
decorator,
|
|
931
|
-
})),
|
|
932
|
-
relationships: [...body.matchAll(/@relation\(([^)]+)\)/g)].map((m) => m[1]),
|
|
933
|
-
};
|
|
934
|
-
|
|
935
|
-
entities.push(entity);
|
|
936
|
-
}
|
|
937
|
-
```
|
|
85
|
+
**Purpose:** Read and parse representative code files for detailed insights into API endpoints, data relationships, and security patterns.
|
|
938
86
|
|
|
939
|
-
|
|
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.
|
|
940
91
|
|
|
941
|
-
|
|
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.
|
|
942
94
|
|
|
943
|
-
```python
|
|
944
|
-
# Sample router files
|
|
945
|
-
routerFiles = glob('**/*routes.py', '**/*router.py')[:20]
|
|
946
|
-
|
|
947
|
-
for file in routerFiles:
|
|
948
|
-
content = readFile(file)
|
|
949
|
-
|
|
950
|
-
# Extract routes using regex
|
|
951
|
-
routes = re.findall(r'@(?:app|router)\.(get|post|put|delete|patch)\([\'"](.+?)[\'"]\)\\s+async def\\s+(\\w+)', content)
|
|
952
|
-
|
|
953
|
-
for method, path, handler in routes:
|
|
954
|
-
endpoints.append({
|
|
955
|
-
'method': method.upper(),
|
|
956
|
-
'path': path,
|
|
957
|
-
'handler': handler,
|
|
958
|
-
'file': file
|
|
959
|
-
})
|
|
960
|
-
```
|
|
961
|
-
|
|
962
|
-
**Entities (Django):**
|
|
963
|
-
|
|
964
|
-
```python
|
|
965
|
-
# Read models.py files
|
|
966
|
-
modelFiles = glob('**/models.py')[:15]
|
|
967
|
-
|
|
968
|
-
for file in modelFiles:
|
|
969
|
-
content = readFile(file)
|
|
970
|
-
|
|
971
|
-
# Extract model classes
|
|
972
|
-
models = re.findall(r'class\\s+(\\w+)\\(models\\.Model\\):([^\\n]+(?:\\n(?!class)(?!def)[^\\n]+)*)', content)
|
|
973
|
-
|
|
974
|
-
for className, body in models:
|
|
975
|
-
fields = re.findall(r'(\\w+)\\s*=\\s*models\\.(\\w+Field)\\(([^)]*)\\)', body)
|
|
976
|
-
|
|
977
|
-
entities.append({
|
|
978
|
-
'name': className,
|
|
979
|
-
'fields': [{'name': f[0], 'type': f[1]} for f in fields],
|
|
980
|
-
'file': file
|
|
981
|
-
})
|
|
982
|
-
```
|
|
983
|
-
|
|
984
|
-
**PHP:**
|
|
985
|
-
|
|
986
|
-
**API Endpoints (Laravel):**
|
|
987
|
-
|
|
988
|
-
```php
|
|
989
|
-
// Read routes/api.php and routes/web.php
|
|
990
|
-
$routeFiles = ['routes/api.php', 'routes/web.php'];
|
|
991
|
-
|
|
992
|
-
foreach ($routeFiles as $file) {
|
|
993
|
-
$content = file_get_contents($file);
|
|
994
|
-
|
|
995
|
-
// Extract routes
|
|
996
|
-
preg_match_all('/Route::(get|post|put|delete|patch)\\([\'"](.+?)[\'"],\\s*[\'"]?([^\\)]+)[\'"]?\\)/', $content, $matches, PREG_SET_ORDER);
|
|
997
|
-
|
|
998
|
-
foreach ($matches as $match) {
|
|
999
|
-
$endpoints[] = [
|
|
1000
|
-
'method' => strtoupper($match[1]),
|
|
1001
|
-
'path' => $match[2],
|
|
1002
|
-
'handler' => $match[3],
|
|
1003
|
-
'file' => $file
|
|
1004
|
-
];
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
```
|
|
1008
|
-
|
|
1009
|
-
**Entities (Eloquent):**
|
|
1010
|
-
|
|
1011
|
-
```php
|
|
1012
|
-
// Glob app/Models/*.php
|
|
1013
|
-
$modelFiles = glob('app/Models/*.php');
|
|
1014
|
-
|
|
1015
|
-
foreach ($modelFiles as $file) {
|
|
1016
|
-
$content = file_get_contents($file);
|
|
1017
|
-
|
|
1018
|
-
// Extract class name
|
|
1019
|
-
preg_match('/class\\s+(\\w+)\\s+extends\\s+Model/', $content, $classMatch);
|
|
1020
|
-
|
|
1021
|
-
if ($classMatch) {
|
|
1022
|
-
$entities[] = [
|
|
1023
|
-
'name' => $classMatch[1],
|
|
1024
|
-
'file' => $file
|
|
1025
|
-
];
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
```
|
|
1029
|
-
|
|
1030
|
-
**Java:**
|
|
1031
|
-
|
|
1032
|
-
**API Endpoints (Spring Boot):**
|
|
1033
|
-
|
|
1034
|
-
```java
|
|
1035
|
-
// Glob **/*Controller.java (sample 25)
|
|
1036
|
-
List<String> controllerFiles = glob("**/*Controller.java").subList(0, 25);
|
|
1037
|
-
|
|
1038
|
-
for (String file : controllerFiles) {
|
|
1039
|
-
String content = readFile(file);
|
|
1040
|
-
|
|
1041
|
-
// Extract base path from @RequestMapping
|
|
1042
|
-
Matcher basePathMatcher = Pattern.compile("@RequestMapping\\([\"'](.+?)[\"']\\)").matcher(content);
|
|
1043
|
-
String basePath = basePathMatcher.find() ? basePathMatcher.group(1) : "";
|
|
1044
|
-
|
|
1045
|
-
// Extract endpoints
|
|
1046
|
-
Matcher routeMatcher = Pattern.compile("@(Get|Post|Put|Delete|Patch)Mapping\\([\"'](.+?)[\"']\\)[^{]+public[^{]+(\\w+)\\(").matcher(content);
|
|
1047
|
-
|
|
1048
|
-
while (routeMatcher.find()) {
|
|
1049
|
-
endpoints.add(new Endpoint(
|
|
1050
|
-
routeMatcher.group(1).toUpperCase(),
|
|
1051
|
-
basePath + routeMatcher.group(2),
|
|
1052
|
-
routeMatcher.group(3),
|
|
1053
|
-
file
|
|
1054
|
-
));
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
```
|
|
1058
|
-
|
|
1059
|
-
**Entities (JPA/Hibernate):**
|
|
1060
|
-
|
|
1061
|
-
```java
|
|
1062
|
-
// Glob **/*Entity.java
|
|
1063
|
-
List<String> entityFiles = glob("**/*Entity.java").subList(0, 30);
|
|
1064
|
-
|
|
1065
|
-
for (String file : entityFiles) {
|
|
1066
|
-
String content = readFile(file);
|
|
1067
|
-
|
|
1068
|
-
// Extract entity name
|
|
1069
|
-
Matcher classMatcher = Pattern.compile("@Entity[^\\n]+\\s+(?:public\\s+)?class\\s+(\\w+)").matcher(content);
|
|
1070
|
-
|
|
1071
|
-
if (classMatcher.find()) {
|
|
1072
|
-
String entityName = classMatcher.group(1);
|
|
1073
|
-
|
|
1074
|
-
// Extract fields with @Column
|
|
1075
|
-
Matcher fieldMatcher = Pattern.compile("@Column[^\\n]+\\s+private\\s+(\\w+)\\s+(\\w+)").matcher(content);
|
|
1076
|
-
|
|
1077
|
-
List<Field> fields = new ArrayList<>();
|
|
1078
|
-
while (fieldMatcher.find()) {
|
|
1079
|
-
fields.add(new Field(fieldMatcher.group(2), fieldMatcher.group(1)));
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
entities.add(new Entity(entityName, fields, file));
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
```
|
|
1086
|
-
|
|
1087
|
-
**C#/.NET:**
|
|
1088
|
-
|
|
1089
|
-
**API Endpoints (ASP.NET Core):**
|
|
1090
|
-
|
|
1091
|
-
```csharp
|
|
1092
|
-
// Glob **/*Controller.cs
|
|
1093
|
-
var controllerFiles = Directory.GetFiles(".", "*Controller.cs", SearchOption.AllDirectories).Take(25);
|
|
1094
|
-
|
|
1095
|
-
foreach (var file in controllerFiles) {
|
|
1096
|
-
var content = File.ReadAllText(file);
|
|
1097
|
-
|
|
1098
|
-
// Extract base route from [Route("...")]
|
|
1099
|
-
var baseRouteMatch = Regex.Match(content, @"\[Route\([""'](.+?)[""']\)\]");
|
|
1100
|
-
var basePath = baseRouteMatch.Success ? baseRouteMatch.Groups[1].Value : "";
|
|
1101
|
-
|
|
1102
|
-
// Extract endpoints
|
|
1103
|
-
var routeMatches = Regex.Matches(content, @"\[Http(Get|Post|Put|Delete|Patch)\([""'](.+?)[""']\)\][^\{]+public[^\{]+(\w+)\(");
|
|
1104
|
-
|
|
1105
|
-
foreach (Match match in routeMatches) {
|
|
1106
|
-
endpoints.Add(new Endpoint {
|
|
1107
|
-
Method = match.Groups[1].Value.ToUpper(),
|
|
1108
|
-
Path = basePath + "/" + match.Groups[2].Value,
|
|
1109
|
-
Handler = match.Groups[3].Value,
|
|
1110
|
-
File = file
|
|
1111
|
-
});
|
|
1112
|
-
}
|
|
1113
|
-
}
|
|
1114
|
-
```
|
|
1115
|
-
|
|
1116
|
-
**Entities (Entity Framework):**
|
|
1117
|
-
|
|
1118
|
-
```csharp
|
|
1119
|
-
// Glob **/Models/**/*.cs or **/Entities/**/*.cs
|
|
1120
|
-
var entityFiles = Directory.GetFiles(".", "*.cs", SearchOption.AllDirectories)
|
|
1121
|
-
.Where(f => f.Contains("/Models/") || f.Contains("/Entities/"))
|
|
1122
|
-
.Take(30);
|
|
1123
|
-
|
|
1124
|
-
foreach (var file in entityFiles) {
|
|
1125
|
-
var content = File.ReadAllText(file);
|
|
1126
|
-
|
|
1127
|
-
// Extract class name
|
|
1128
|
-
var classMatch = Regex.Match(content, @"public\s+class\s+(\w+)");
|
|
1129
|
-
|
|
1130
|
-
if (classMatch.Success) {
|
|
1131
|
-
var entityName = classMatch.Groups[1].Value;
|
|
1132
|
-
|
|
1133
|
-
// Extract properties
|
|
1134
|
-
var propMatches = Regex.Matches(content, @"public\s+(\w+(?:<\w+>)?)\s+(\w+)\s*\{\s*get;\s*set;");
|
|
1135
|
-
|
|
1136
|
-
var fields = propMatches.Cast<Match>()
|
|
1137
|
-
.Select(m => new Field { Name = m.Groups[2].Value, Type = m.Groups[1].Value })
|
|
1138
|
-
.ToList();
|
|
1139
|
-
|
|
1140
|
-
entities.Add(new Entity { Name = entityName, Fields = fields, File = file });
|
|
1141
|
-
}
|
|
1142
|
-
}
|
|
1143
|
-
```
|
|
1144
|
-
|
|
1145
|
-
**Go:**
|
|
1146
|
-
|
|
1147
|
-
**API Endpoints (Gin):**
|
|
1148
|
-
|
|
1149
|
-
```go
|
|
1150
|
-
// Read handler files
|
|
1151
|
-
handlerFiles := filepath.Glob("**/handlers/**/*.go")[:20]
|
|
1152
|
-
|
|
1153
|
-
for _, file := range handlerFiles {
|
|
1154
|
-
content, _ := ioutil.ReadFile(file)
|
|
1155
|
-
|
|
1156
|
-
// Extract routes using regex
|
|
1157
|
-
routeRegex := regexp.MustCompile(`router\.(GET|POST|PUT|DELETE|PATCH)\("(.+?)",\s*(\w+)`)
|
|
1158
|
-
matches := routeRegex.FindAllStringSubmatch(string(content), -1)
|
|
1159
|
-
|
|
1160
|
-
for _, match := range matches {
|
|
1161
|
-
endpoints = append(endpoints, Endpoint{
|
|
1162
|
-
Method: match[1],
|
|
1163
|
-
Path: match[2],
|
|
1164
|
-
Handler: match[3],
|
|
1165
|
-
File: file,
|
|
1166
|
-
})
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
|
-
```
|
|
1170
|
-
|
|
1171
|
-
**Entities (GORM):**
|
|
1172
|
-
|
|
1173
|
-
```go
|
|
1174
|
-
// Read model files
|
|
1175
|
-
modelFiles := filepath.Glob("**/models/**/*.go")[:20]
|
|
1176
|
-
|
|
1177
|
-
for _, file := range modelFiles {
|
|
1178
|
-
content, _ := ioutil.ReadFile(file)
|
|
1179
|
-
|
|
1180
|
-
// Extract struct definitions
|
|
1181
|
-
structRegex := regexp.MustCompile(`type\s+(\w+)\s+struct\s*\{([^}]+)\}`)
|
|
1182
|
-
matches := structRegex.FindAllStringSubmatch(string(content), -1)
|
|
1183
|
-
|
|
1184
|
-
for _, match := range matches {
|
|
1185
|
-
structName := match[1]
|
|
1186
|
-
body := match[2]
|
|
1187
|
-
|
|
1188
|
-
// Extract fields
|
|
1189
|
-
fieldRegex := regexp.MustCompile(`(\w+)\s+(\w+(?:\.\w+)?)`)
|
|
1190
|
-
fields := fieldRegex.FindAllStringSubmatch(body, -1)
|
|
1191
|
-
|
|
1192
|
-
var fieldList []Field
|
|
1193
|
-
for _, field := range fields {
|
|
1194
|
-
fieldList = append(fieldList, Field{Name: field[1], Type: field[2]})
|
|
1195
|
-
}
|
|
1196
|
-
|
|
1197
|
-
entities = append(entities, Entity{Name: structName, Fields: fieldList, File: file})
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1200
|
-
```
|
|
1201
|
-
|
|
1202
|
-
**Ruby:**
|
|
1203
|
-
|
|
1204
|
-
**API Endpoints (Rails):**
|
|
1205
|
-
|
|
1206
|
-
```ruby
|
|
1207
|
-
# Read routes.rb
|
|
1208
|
-
routes_file = 'config/routes.rb'
|
|
1209
|
-
content = File.read(routes_file)
|
|
1210
|
-
|
|
1211
|
-
# Extract resource routes
|
|
1212
|
-
resource_matches = content.scan(/resources?\s+:(\w+)/)
|
|
1213
|
-
|
|
1214
|
-
resource_matches.each do |resource|
|
|
1215
|
-
# Standard RESTful routes
|
|
1216
|
-
%w[GET POST PUT PATCH DELETE].each do |method|
|
|
1217
|
-
endpoints << {
|
|
1218
|
-
method: method,
|
|
1219
|
-
path: "/#{resource}",
|
|
1220
|
-
resource: resource,
|
|
1221
|
-
file: routes_file
|
|
1222
|
-
}
|
|
1223
|
-
end
|
|
1224
|
-
end
|
|
1225
|
-
|
|
1226
|
-
# Extract custom routes
|
|
1227
|
-
custom_matches = content.scan(/(get|post|put|patch|delete)\s+['"](.+?)['"],\s*to:\s*['"](.+?)['"]/)
|
|
1228
|
-
|
|
1229
|
-
custom_matches.each do |method, path, controller_action|
|
|
1230
|
-
endpoints << {
|
|
1231
|
-
method: method.upcase,
|
|
1232
|
-
path: path,
|
|
1233
|
-
handler: controller_action,
|
|
1234
|
-
file: routes_file
|
|
1235
|
-
}
|
|
1236
|
-
end
|
|
1237
|
-
```
|
|
1238
|
-
|
|
1239
|
-
**Entities (ActiveRecord):**
|
|
1240
|
-
|
|
1241
|
-
```ruby
|
|
1242
|
-
# Glob app/models/*.rb
|
|
1243
|
-
model_files = Dir.glob('app/models/**/*.rb')[0..20]
|
|
1244
|
-
|
|
1245
|
-
model_files.each do |file|
|
|
1246
|
-
content = File.read(file)
|
|
1247
|
-
|
|
1248
|
-
# Extract class name
|
|
1249
|
-
class_match = content.match(/class\s+(\w+)\s+<\s+(?:Application)?Record/)
|
|
1250
|
-
|
|
1251
|
-
next unless class_match
|
|
1252
|
-
|
|
1253
|
-
entity_name = class_match[1]
|
|
1254
|
-
|
|
1255
|
-
# Extract associations
|
|
1256
|
-
associations = content.scan(/(belongs_to|has_many|has_one)\s+:(\w+)/)
|
|
1257
|
-
|
|
1258
|
-
entities << {
|
|
1259
|
-
name: entity_name,
|
|
1260
|
-
associations: associations.map { |type, name| {type: type, target: name} },
|
|
1261
|
-
file: file
|
|
1262
|
-
}
|
|
1263
|
-
end
|
|
1264
|
-
```
|
|
1265
|
-
|
|
1266
|
-
**Rust:**
|
|
1267
|
-
|
|
1268
|
-
**API Endpoints (Actix):**
|
|
1269
|
-
|
|
1270
|
-
```rust
|
|
1271
|
-
// Read handler files
|
|
1272
|
-
let handler_files: Vec<_> = glob("**/handlers/**/*.rs").unwrap().take(15).collect();
|
|
1273
|
-
|
|
1274
|
-
for file in handler_files {
|
|
1275
|
-
let content = fs::read_to_string(file).unwrap();
|
|
1276
|
-
|
|
1277
|
-
// Extract routes using regex
|
|
1278
|
-
let route_regex = Regex::new(r#"#\[(get|post|put|delete|patch)\("(.+?)"\)\]\s+async\s+fn\s+(\w+)"#).unwrap();
|
|
1279
|
-
|
|
1280
|
-
for cap in route_regex.captures_iter(&content) {
|
|
1281
|
-
endpoints.push(Endpoint {
|
|
1282
|
-
method: cap[1].to_uppercase(),
|
|
1283
|
-
path: cap[2].to_string(),
|
|
1284
|
-
handler: cap[3].to_string(),
|
|
1285
|
-
file: file.to_string(),
|
|
1286
|
-
});
|
|
1287
|
-
}
|
|
1288
|
-
}
|
|
1289
|
-
```
|
|
1290
|
-
|
|
1291
|
-
**Entities (Diesel):**
|
|
1292
|
-
|
|
1293
|
-
```rust
|
|
1294
|
-
// Read schema.rs and models.rs
|
|
1295
|
-
let schema = fs::read_to_string("src/schema.rs").ok();
|
|
1296
|
-
let models = fs::read_to_string("src/models.rs").ok();
|
|
1297
|
-
|
|
1298
|
-
if let Some(schema_content) = schema {
|
|
1299
|
-
// Extract table definitions
|
|
1300
|
-
let table_regex = Regex::new(r"table!\s*\{\s*(\w+)").unwrap();
|
|
1301
|
-
|
|
1302
|
-
for cap in table_regex.captures_iter(&schema_content) {
|
|
1303
|
-
entities.push(Entity {
|
|
1304
|
-
name: cap[1].to_string(),
|
|
1305
|
-
source: "schema.rs".to_string(),
|
|
1306
|
-
});
|
|
1307
|
-
}
|
|
1308
|
-
}
|
|
1309
|
-
```
|
|
1310
|
-
|
|
1311
|
-
### 0.3.5 Security Pattern Detection
|
|
1312
|
-
|
|
1313
|
-
**Scan for security patterns across all languages:**
|
|
1314
|
-
|
|
1315
|
-
**Authentication:**
|
|
1316
|
-
|
|
1317
|
-
- JWT libraries: `jsonwebtoken`, `@nestjs/jwt`, `pyjwt`, `jjwt`, etc.
|
|
1318
|
-
- Session libraries: `express-session`, `django.contrib.sessions`
|
|
1319
|
-
- OAuth libraries: `passport`, `authlib`, `spring-security-oauth2`
|
|
1320
|
-
- Password hashing: `bcrypt`, `argon2`, `password_hash` (PHP)
|
|
1321
|
-
|
|
1322
|
-
**Validation:**
|
|
1323
|
-
|
|
1324
|
-
- `class-validator`, `joi`, `zod` (Node.js)
|
|
1325
|
-
- `pydantic`, `marshmallow` (Python)
|
|
1326
|
-
- Laravel validation rules (PHP)
|
|
1327
|
-
- Bean Validation/Hibernate Validator (Java)
|
|
1328
|
-
- Data Annotations (.NET)
|
|
1329
|
-
|
|
1330
|
-
**Rate Limiting:**
|
|
1331
|
-
|
|
1332
|
-
- `express-rate-limit`, `@nestjs/throttler`
|
|
1333
|
-
- `django-ratelimit`, `slowapi`
|
|
1334
|
-
- Bucket4j (Java)
|
|
1335
|
-
|
|
1336
|
-
**CORS:**
|
|
1337
|
-
|
|
1338
|
-
- `cors` package (Node.js)
|
|
1339
|
-
- `django-cors-headers` (Python)
|
|
1340
|
-
- Spring CORS configuration (Java)
|
|
1341
|
-
|
|
1342
|
-
**Security Headers:**
|
|
1343
|
-
|
|
1344
|
-
- `helmet` (Node.js)
|
|
1345
|
-
- `django-csp`
|
|
1346
|
-
- OWASP Java Encoder
|
|
1347
|
-
|
|
1348
|
-
**Output:**
|
|
1349
|
-
|
|
1350
|
-
```
|
|
1351
|
-
🔒 Security Analysis Results:
|
|
1352
|
-
|
|
1353
|
-
Authentication:
|
|
1354
|
-
✅ JWT detected: [@nestjs/jwt v10.1.0]
|
|
1355
|
-
✅ Password hashing: [bcrypt v5.1.0]
|
|
1356
|
-
❌ Refresh tokens: Not detected
|
|
1357
|
-
|
|
1358
|
-
Validation:
|
|
1359
|
-
✅ Input validation: [class-validator, class-transformer]
|
|
1360
|
-
✅ DTOs detected: [23 DTO files]
|
|
1361
|
-
|
|
1362
|
-
Rate Limiting:
|
|
1363
|
-
⚠️ Not detected - Recommend adding @nestjs/throttler
|
|
1364
|
-
|
|
1365
|
-
CORS:
|
|
1366
|
-
⚠️ Configuration not found in main.ts
|
|
1367
|
-
|
|
1368
|
-
Security Headers:
|
|
1369
|
-
⚠️ helmet not detected - Recommend adding for production
|
|
1370
|
-
```
|
|
1371
|
-
|
|
1372
|
-
### 0.3.6 Progress Tracking
|
|
1373
|
-
|
|
1374
|
-
**Show real-time progress during analysis:**
|
|
1375
|
-
|
|
1376
|
-
```
|
|
1377
|
-
🔬 Deep Analysis Progress:
|
|
1378
|
-
|
|
1379
|
-
[████████████████░░░░] 80% - API Endpoints
|
|
1380
|
-
✅ Analyzed 24/30 controller files
|
|
1381
|
-
✅ Found 127 endpoints
|
|
1382
|
-
⏱️ Elapsed: 75s
|
|
1383
|
-
💾 Tokens: 8,200
|
|
1384
|
-
|
|
1385
|
-
[████████████████████] 100% - Entity Relationships
|
|
1386
|
-
✅ Analyzed 18/18 entity files
|
|
1387
|
-
✅ Mapped 45 relationships
|
|
1388
|
-
⏱️ Elapsed: 45s
|
|
1389
|
-
💾 Tokens: 4,500
|
|
1390
|
-
|
|
1391
|
-
[████████████░░░░░░░░] 60% - Security Patterns
|
|
1392
|
-
⏸️ Context budget warning at 90%
|
|
1393
|
-
✅ Partial analysis: JWT auth, validation, bcrypt
|
|
1394
|
-
ℹ️ Remaining checks deferred
|
|
1395
|
-
⏱️ Elapsed: 20s
|
|
1396
|
-
💾 Tokens: 1,800
|
|
1397
95
|
---
|
|
1398
|
-
Total: 2m 20s | 14,500 tokens used
|
|
1399
|
-
Remaining context: 155,500 tokens
|
|
1400
|
-
```
|
|
1401
|
-
|
|
1402
|
-
### 0.3.7 Output Layer 3 Results
|
|
1403
96
|
|
|
1404
|
-
|
|
1405
|
-
✅ Layer 3 Complete (2m 30s)
|
|
97
|
+
## ✅ Validation & Synthesis
|
|
1406
98
|
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
By Method:
|
|
1410
|
-
GET: 58 endpoints
|
|
1411
|
-
POST: 32 endpoints
|
|
1412
|
-
PUT: 18 endpoints
|
|
1413
|
-
DELETE: 12 endpoints
|
|
1414
|
-
PATCH: 7 endpoints
|
|
1415
|
-
|
|
1416
|
-
By Module:
|
|
1417
|
-
/users: 23 endpoints
|
|
1418
|
-
/products: 18 endpoints
|
|
1419
|
-
/orders: 15 endpoints
|
|
1420
|
-
/payments: 8 endpoints
|
|
1421
|
-
/auth: 12 endpoints
|
|
1422
|
-
[+7 more modules]
|
|
99
|
+
### Present Findings
|
|
100
|
+
Show the final "🔍 BACKEND STACK DETECTED" report and ask for confirmation.
|
|
1423
101
|
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
• PUT /api/orders/:id → OrdersController.update
|
|
1428
|
-
[View full list in docs-analysis.json]
|
|
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.
|
|
1429
105
|
|
|
1430
|
-
🗄️ Database Entities: [18 detected]
|
|
1431
106
|
---
|
|
1432
|
-
Core Entities:
|
|
1433
|
-
• User (8 fields, 3 relationships)
|
|
1434
|
-
- Relationships: OneToMany → Orders, OneToMany → Reviews
|
|
1435
|
-
• Product (12 fields, 2 relationships)
|
|
1436
|
-
- Relationships: ManyToOne → Category, OneToMany → OrderItems
|
|
1437
|
-
• Order (10 fields, 4 relationships)
|
|
1438
|
-
- Relationships: ManyToOne → User, OneToMany → OrderItems, etc.
|
|
1439
107
|
|
|
1440
|
-
|
|
108
|
+
## 0.4 Proactive Suggestions
|
|
109
|
+
Generate a report of missing critical elements (e.g., "Rate Limiting Not Detected", "CORS Not Configured") and offer to address them in later phases.
|
|
1441
110
|
|
|
1442
|
-
🔒 Security Patterns:
|
|
1443
111
|
---
|
|
1444
|
-
✅ Authentication: JWT with bcrypt
|
|
1445
|
-
✅ Validation: class-validator + DTOs
|
|
1446
|
-
⚠️ Rate Limiting: Not detected
|
|
1447
|
-
⚠️ CORS: Not configured
|
|
1448
|
-
⚠️ Security Headers: helmet not found
|
|
1449
112
|
|
|
1450
|
-
|
|
1451
|
-
⏱️ Time Elapsed: 3m 45s
|
|
1452
|
-
---
|
|
1453
|
-
```
|
|
113
|
+
✅ **Phase 0 Complete: Context Analysis Finalized**
|
|
1454
114
|
|
|
1455
|
-
**Context Usage:** ~5,000-25,000 tokens (cumulative: ~8,000-31,500)
|
|
1456
115
|
---
|
|
1457
|
-
## 0.4 Proactive Improvement Suggestions
|
|
1458
|
-
|
|
1459
|
-
```
|
|
1460
|
-
💡 PROACTIVE SUGGESTIONS
|
|
1461
|
-
|
|
1462
|
-
Based on my analysis, I found opportunities for improvement:
|
|
1463
|
-
|
|
1464
|
-
🔴 HIGH PRIORITY (Security):
|
|
1465
|
-
|
|
1466
|
-
1. ⚠️ Rate Limiting Not Implemented
|
|
1467
|
-
Action: Add @nestjs/throttler middleware to protect against abuse
|
|
1468
|
-
Impact: Prevents DDoS attacks, ensures fair resource usage
|
|
1469
|
-
Estimated effort: 30 minutes
|
|
1470
|
-
|
|
1471
|
-
2. 🔐 CORS Not Configured
|
|
1472
|
-
Action: Configure CORS with explicit allowed origins in main.ts
|
|
1473
|
-
Impact: Prevents unauthorized cross-origin requests
|
|
1474
|
-
Estimated effort: 15 minutes
|
|
1475
|
-
|
|
1476
|
-
3. ⚠️ No Refresh Token Pattern
|
|
1477
|
-
Action: Implement refresh tokens alongside access tokens
|
|
1478
|
-
Impact: Improved security, better session management
|
|
1479
|
-
Estimated effort: 2-3 hours
|
|
1480
|
-
|
|
1481
|
-
🟡 MEDIUM PRIORITY (Architecture):
|
|
1482
|
-
|
|
1483
|
-
4. 📐 No Global Error Handler Detected
|
|
1484
|
-
Action: Implement centralized exception filter
|
|
1485
|
-
Impact: Consistent error responses, better debugging
|
|
1486
|
-
Estimated effort: 1 hour
|
|
1487
|
-
|
|
1488
|
-
5. 📊 Missing API Documentation
|
|
1489
|
-
Action: Add @nestjs/swagger for auto-generated API docs
|
|
1490
|
-
Impact: Better developer experience, easier testing
|
|
1491
|
-
Estimated effort: 2 hours
|
|
1492
|
-
|
|
1493
|
-
🟢 LOW PRIORITY (Performance):
|
|
1494
116
|
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
117
|
+
### Phase Summary
|
|
118
|
+
- Pre-populated detected tech stack values.
|
|
119
|
+
- Architectural patterns identified.
|
|
120
|
+
- Context cached in `.ai-flow/cache/docs-analysis.json`.
|
|
1499
121
|
|
|
1500
|
-
7. 📄 Pagination Not Detected in List Endpoints
|
|
1501
|
-
Action: Implement cursor-based or offset pagination
|
|
1502
|
-
Impact: Better performance with large datasets
|
|
1503
|
-
Estimated effort: 2-3 hours
|
|
1504
122
|
---
|
|
1505
|
-
Would you like to:
|
|
1506
|
-
|
|
1507
|
-
A) ✅ Address these during build (I'll integrate into relevant phases)
|
|
1508
|
-
- Security suggestions → Phase 4 (Security & Authentication)
|
|
1509
|
-
- Architecture suggestions → Phase 3 (System Architecture)
|
|
1510
|
-
- Performance suggestions → Phase 7 (Operations & Deployment)
|
|
1511
|
-
|
|
1512
|
-
B) 💾 Save suggestions to suggestions.md file for later
|
|
1513
|
-
|
|
1514
|
-
C) ❌ Skip suggestions and continue with standard build
|
|
1515
|
-
|
|
1516
|
-
Your choice: __
|
|
1517
|
-
```
|
|
1518
|
-
|
|
1519
|
-
**If user selects A:**
|
|
1520
|
-
|
|
1521
|
-
- Mark suggestions to be addressed in relevant phases
|
|
1522
|
-
- When reaching those phases, reference: "Earlier analysis detected X, let's configure it now"
|
|
1523
|
-
|
|
1524
|
-
**If user selects B:**
|
|
1525
|
-
|
|
1526
|
-
- Create `suggestions.md` with all recommendations formatted for reference
|
|
1527
|
-
|
|
1528
|
-
**If user selects C:**
|
|
1529
|
-
|
|
1530
|
-
- Continue without suggestions
|
|
1531
|
-
---
|
|
1532
|
-
## 0.5 Export Analysis Results
|
|
1533
|
-
|
|
1534
|
-
```
|
|
1535
|
-
💾 Export Analysis to JSON?
|
|
1536
|
-
|
|
1537
|
-
This creates .ai-flow/cache/docs-analysis.json with all detected information:
|
|
1538
|
-
• Project metadata and tech stack
|
|
1539
|
-
• Complete endpoint list with methods, paths, handlers
|
|
1540
|
-
• Full entity schemas with relationships
|
|
1541
|
-
• Architecture patterns detected
|
|
1542
|
-
• Security analysis results
|
|
1543
|
-
• Improvement suggestions
|
|
1544
|
-
|
|
1545
|
-
Benefits:
|
|
1546
|
-
✅ Skip re-analysis on future build runs
|
|
1547
|
-
✅ Share with team members
|
|
1548
|
-
✅ Track project evolution over time
|
|
1549
|
-
✅ Use for automation/CI/CD
|
|
1550
|
-
✅ Reference during development
|
|
1551
|
-
|
|
1552
|
-
A) ✅ Yes - Export full analysis (Recommended)
|
|
1553
|
-
B) ❌ No - Keep in memory only
|
|
1554
|
-
|
|
1555
|
-
Your choice: __
|
|
1556
|
-
```
|
|
1557
|
-
|
|
1558
|
-
**If A, create comprehensive JSON:**
|
|
1559
|
-
|
|
1560
|
-
```json
|
|
1561
|
-
{
|
|
1562
|
-
"version": "2.0",
|
|
1563
|
-
"analyzedAt": "2024-01-20T10:30:00Z",
|
|
1564
|
-
"layers": {
|
|
1565
|
-
"layer1": {
|
|
1566
|
-
"completedAt": "2024-01-20T10:30:15Z",
|
|
1567
|
-
"tokensUsed": 1200
|
|
1568
|
-
},
|
|
1569
|
-
"layer2": {
|
|
1570
|
-
"completedAt": "2024-01-20T10:31:30Z",
|
|
1571
|
-
"tokensUsed": 3500
|
|
1572
|
-
},
|
|
1573
|
-
"layer3": {
|
|
1574
|
-
"completedAt": "2024-01-20T10:34:00Z",
|
|
1575
|
-
"tokensUsed": 14500,
|
|
1576
|
-
"areasAnalyzed": ["endpoints", "entities", "security"]
|
|
1577
|
-
}
|
|
1578
|
-
},
|
|
1579
|
-
"project": {
|
|
1580
|
-
"name": "ecommerce-api",
|
|
1581
|
-
"language": "TypeScript",
|
|
1582
|
-
"languageVersion": "5.3.0",
|
|
1583
|
-
"packageManager": "pnpm",
|
|
1584
|
-
"framework": {
|
|
1585
|
-
"name": "NestJS",
|
|
1586
|
-
"version": "10.2.0"
|
|
1587
|
-
},
|
|
1588
|
-
"orm": {
|
|
1589
|
-
"name": "Prisma",
|
|
1590
|
-
"version": "5.7.0"
|
|
1591
|
-
}
|
|
1592
|
-
},
|
|
1593
|
-
"structure": {
|
|
1594
|
-
"pattern": "feature-based",
|
|
1595
|
-
"fileCounts": {
|
|
1596
|
-
"controllers": 12,
|
|
1597
|
-
"services": 18,
|
|
1598
|
-
"entities": 18,
|
|
1599
|
-
"dto": 45,
|
|
1600
|
-
"tests": 38
|
|
1601
|
-
},
|
|
1602
|
-
"testCoverage": "medium"
|
|
1603
|
-
},
|
|
1604
|
-
"endpoints": [
|
|
1605
|
-
{
|
|
1606
|
-
"method": "GET",
|
|
1607
|
-
"path": "/api/users/:id",
|
|
1608
|
-
"controller": "UsersController",
|
|
1609
|
-
"handler": "findOne",
|
|
1610
|
-
"file": "src/users/users.controller.ts",
|
|
1611
|
-
"line": 42
|
|
1612
|
-
}
|
|
1613
|
-
// ... 126 more
|
|
1614
|
-
],
|
|
1615
|
-
"entities": [
|
|
1616
|
-
{
|
|
1617
|
-
"name": "User",
|
|
1618
|
-
"source": "prisma",
|
|
1619
|
-
"file": "prisma/schema.prisma",
|
|
1620
|
-
"fields": [
|
|
1621
|
-
{ "name": "id", "type": "String", "required": true, "primary": true },
|
|
1622
|
-
{ "name": "email", "type": "String", "required": true, "unique": true },
|
|
1623
|
-
{ "name": "password", "type": "String", "required": true }
|
|
1624
|
-
],
|
|
1625
|
-
"relationships": [
|
|
1626
|
-
{ "type": "OneToMany", "target": "Order", "field": "orders" },
|
|
1627
|
-
{ "type": "OneToMany", "target": "Review", "field": "reviews" }
|
|
1628
|
-
]
|
|
1629
|
-
}
|
|
1630
|
-
// ... 17 more
|
|
1631
|
-
],
|
|
1632
|
-
"security": {
|
|
1633
|
-
"authentication": {
|
|
1634
|
-
"method": "JWT",
|
|
1635
|
-
"library": "@nestjs/jwt@10.1.0",
|
|
1636
|
-
"passwordHashing": "bcrypt@5.1.0"
|
|
1637
|
-
},
|
|
1638
|
-
"validation": {
|
|
1639
|
-
"libraries": ["class-validator", "class-transformer"],
|
|
1640
|
-
"dtoCount": 45
|
|
1641
|
-
},
|
|
1642
|
-
"rateLimiting": null,
|
|
1643
|
-
"cors": null,
|
|
1644
|
-
"securityHeaders": null
|
|
1645
|
-
},
|
|
1646
|
-
"documentation": {
|
|
1647
|
-
"maturity": "basic",
|
|
1648
|
-
"filesFound": ["README.md", "docs/architecture.md", "docs/api.md"]
|
|
1649
|
-
},
|
|
1650
|
-
"suggestions": [
|
|
1651
|
-
{
|
|
1652
|
-
"id": 1,
|
|
1653
|
-
"type": "security",
|
|
1654
|
-
"severity": "high",
|
|
1655
|
-
"title": "Rate Limiting Not Implemented",
|
|
1656
|
-
"description": "No rate limiting middleware detected",
|
|
1657
|
-
"recommendation": "Add @nestjs/throttler",
|
|
1658
|
-
"estimatedEffort": "30 minutes",
|
|
1659
|
-
"phase": 4
|
|
1660
|
-
}
|
|
1661
|
-
// ... more suggestions
|
|
1662
|
-
],
|
|
1663
|
-
"filesAnalyzed": {
|
|
1664
|
-
"count": 87,
|
|
1665
|
-
"paths": [
|
|
1666
|
-
"src/users/users.controller.ts",
|
|
1667
|
-
"src/products/products.controller.ts"
|
|
1668
|
-
// ... all analyzed files
|
|
1669
|
-
],
|
|
1670
|
-
"timestamps": {
|
|
1671
|
-
"src/users/users.controller.ts": "2024-01-19T15:22:00Z",
|
|
1672
|
-
"package.json": "2024-01-20T09:15:00Z"
|
|
1673
|
-
// ... all file timestamps for change detection
|
|
1674
|
-
}
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1677
|
-
```
|
|
1678
|
-
|
|
1679
|
-
```
|
|
1680
|
-
✅ Analysis exported to .ai-flow/cache/docs-analysis.json
|
|
1681
|
-
|
|
1682
|
-
File size: 142 KB
|
|
1683
|
-
Contains:
|
|
1684
|
-
• 127 endpoints
|
|
1685
|
-
• 18 entities with full schemas
|
|
1686
|
-
• 7 improvement suggestions
|
|
1687
|
-
• 87 files analyzed with timestamps
|
|
1688
|
-
|
|
1689
|
-
You can view/edit this file anytime or share with your team.
|
|
1690
|
-
```
|
|
1691
|
-
---
|
|
1692
|
-
## 0.6 Load Detected Context & Pre-populate Answers
|
|
1693
|
-
|
|
1694
|
-
**If user selected "Use detected information":**
|
|
1695
|
-
|
|
1696
|
-
```
|
|
1697
|
-
✅ Loading detected project context...
|
|
1698
|
-
|
|
1699
|
-
I'll pre-populate answers from analysis and only ask what's missing.
|
|
1700
123
|
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
Phase 1 (Business):
|
|
1704
|
-
✅ Project Name: ecommerce-api
|
|
1705
|
-
✅ Description: [from package.json]
|
|
1706
|
-
❓ Business Objectives: [NEED TO ASK]
|
|
1707
|
-
❓ Target Users: [NEED TO ASK]
|
|
1708
|
-
❓ Success Metrics: [NEED TO ASK]
|
|
1709
|
-
|
|
1710
|
-
Phase 2 (Data Architecture):
|
|
1711
|
-
✅ Database: PostgreSQL (detected via Prisma)
|
|
1712
|
-
✅ ORM: Prisma v5.7.0
|
|
1713
|
-
✅ Entities: 18 detected (User, Product, Order, Payment, etc.)
|
|
1714
|
-
✅ Relationships: 45 mapped
|
|
1715
|
-
⚠️ Need validation: Are all entities documented?
|
|
1716
|
-
❓ Data retention policies: [NEED TO ASK]
|
|
1717
|
-
|
|
1718
|
-
Phase 3 (System Architecture):
|
|
1719
|
-
✅ Framework: NestJS v10.2.0
|
|
1720
|
-
✅ Language: TypeScript v5.3.0
|
|
1721
|
-
✅ Package Manager: pnpm
|
|
1722
|
-
✅ Architecture Pattern: Feature-based modules
|
|
1723
|
-
❓ Caching Strategy: [NEED TO ASK]
|
|
1724
|
-
❓ Background Jobs: [NEED TO ASK]
|
|
1725
|
-
❓ File Storage: [NEED TO ASK]
|
|
1726
|
-
|
|
1727
|
-
Phase 4 (Security):
|
|
1728
|
-
✅ Authentication: JWT with bcrypt
|
|
1729
|
-
✅ Validation: class-validator + DTOs
|
|
1730
|
-
⚠️ Rate Limiting: Not configured (will ask to add)
|
|
1731
|
-
⚠️ CORS: Not configured (will ask to add)
|
|
1732
|
-
❓ Authorization strategy: [NEED TO ASK]
|
|
1733
|
-
❓ Compliance requirements: [NEED TO ASK]
|
|
1734
|
-
|
|
1735
|
-
Phase 5 (Code Standards):
|
|
1736
|
-
✅ Validation approach: DTOs with class-validator
|
|
1737
|
-
❓ Linting: [NEED TO ASK]
|
|
1738
|
-
❓ Formatting: [NEED TO ASK]
|
|
1739
|
-
❓ Naming conventions: [NEED TO ASK]
|
|
1740
|
-
|
|
1741
|
-
Phase 6 (Testing):
|
|
1742
|
-
✅ Test files: 38 detected
|
|
1743
|
-
✅ Coverage: Medium (~30-60%)
|
|
1744
|
-
❓ Testing strategy: [NEED TO ASK]
|
|
1745
|
-
❓ CI/CD integration: [NEED TO ASK]
|
|
1746
|
-
|
|
1747
|
-
Phase 7 (Operations):
|
|
1748
|
-
❓ Deployment target: [NEED TO ASK]
|
|
1749
|
-
❓ Environment setup: [NEED TO ASK]
|
|
1750
|
-
❓ Monitoring: [NEED TO ASK]
|
|
1751
|
-
❓ Logging: [NEED TO ASK]
|
|
1752
|
-
---
|
|
1753
|
-
📊 Analysis Summary:
|
|
1754
|
-
• Pre-populated: ~45% of answers
|
|
1755
|
-
• Need to ask: ~55% (gaps in documentation)
|
|
1756
|
-
• Estimated time savings: 40-50 minutes
|
|
1757
|
-
|
|
1758
|
-
Ready to proceed to Project Scope Selection?
|
|
1759
|
-
|
|
1760
|
-
Type 'yes' to continue: __
|
|
1761
|
-
```
|
|
1762
|
-
---
|
|
1763
|
-
## 0.7 Error Handling & Recovery
|
|
1764
|
-
|
|
1765
|
-
**If any layer fails:**
|
|
1766
|
-
|
|
1767
|
-
```
|
|
1768
|
-
❌ Layer [X] Analysis Failed
|
|
1769
|
-
|
|
1770
|
-
Error: [description]
|
|
1771
|
-
File: [problematic file if applicable]
|
|
1772
|
-
Reason: [Syntax error / Parse error / File not found / etc.]
|
|
1773
|
-
|
|
1774
|
-
Impact:
|
|
1775
|
-
✅ Layers 0-[X-1]: Completed successfully
|
|
1776
|
-
❌ Layer [X]: Partially completed (45% done)
|
|
1777
|
-
⏭️ Layers [X+1]+: Not started
|
|
1778
|
-
|
|
1779
|
-
What I was able to detect:
|
|
1780
|
-
• [List successful detections so far]
|
|
1781
|
-
|
|
1782
|
-
Would you like to:
|
|
1783
|
-
|
|
1784
|
-
A) 📊 Continue with partial analysis (Recommended)
|
|
1785
|
-
Use what was successfully detected, proceed to questionnaire
|
|
1786
|
-
|
|
1787
|
-
B) 🔄 Retry Layer [X] with reduced scope
|
|
1788
|
-
Try again with smaller file sample
|
|
1789
|
-
|
|
1790
|
-
C) ⏭️ Skip to questionnaire without analysis
|
|
1791
|
-
Answer all questions manually (no pre-population)
|
|
1792
|
-
|
|
1793
|
-
D) 🛠️ Show error details for debugging
|
|
1794
|
-
|
|
1795
|
-
Your choice: __
|
|
1796
|
-
```
|
|
1797
|
-
|
|
1798
|
-
**If individual file parsing fails:**
|
|
1799
|
-
|
|
1800
|
-
```
|
|
1801
|
-
⚠️ Skipped file: src/legacy/old-controller.ts
|
|
1802
|
-
Reason: Syntax error (malformed decorator)
|
|
1803
|
-
Impact: This file won't be included in endpoint analysis
|
|
1804
|
-
Action: Continuing with remaining files...
|
|
1805
|
-
|
|
1806
|
-
Progress: 24 of 30 files analyzed (80% success rate)
|
|
1807
|
-
```
|
|
1808
|
-
|
|
1809
|
-
**Error recovery strategies:**
|
|
1810
|
-
|
|
1811
|
-
1. **Parse errors:** Skip file, continue with others
|
|
1812
|
-
2. **File not found:** Mark as deleted, update cache
|
|
1813
|
-
3. **Out of memory:** Reduce sample size, retry
|
|
1814
|
-
4. **Context limit:** Stop analysis, use partial results
|
|
1815
|
-
5. **Network timeout:** (if remote files) Retry with backoff
|
|
1816
|
-
---
|
|
1817
|
-
### Phase 0 Output
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
```
|
|
1821
|
-
---
|
|
1822
|
-
✅ CONTEXT DISCOVERY COMPLETE
|
|
1823
|
-
---
|
|
1824
|
-
📊 Project: ecommerce-api
|
|
1825
|
-
🛠️ Stack: TypeScript 5.3 + NestJS 10.2 + Prisma 5.7 + PostgreSQL
|
|
1826
|
-
📈 Maturity: Basic documentation
|
|
1827
|
-
🎯 Recommended Scope: Production-Ready
|
|
1828
|
-
|
|
1829
|
-
Analysis Results:
|
|
1830
|
-
✅ 127 API endpoints detected across 6 modules
|
|
1831
|
-
✅ 18 database entities with 45 relationships
|
|
1832
|
-
✅ Security patterns analyzed
|
|
1833
|
-
✅ 7 improvement suggestions generated
|
|
1834
|
-
✅ Analysis exported to .ai-flow/cache/docs-analysis.json
|
|
1835
|
-
|
|
1836
|
-
Pre-population Status:
|
|
1837
|
-
• 45% of questionnaire answers populated
|
|
1838
|
-
• 55% questions still needed (business logic, ops, etc.)
|
|
1839
|
-
• Estimated time savings: 40-50 minutes
|
|
1840
|
-
|
|
1841
|
-
Performance:
|
|
1842
|
-
⏱️ Total time: 3m 45s
|
|
1843
|
-
💾 Context used: 18,700 tokens (~9% of budget)
|
|
1844
|
-
📊 Remaining: 181,300 tokens for phases 1-7
|
|
1845
|
-
|
|
1846
|
-
Next Step: Project Scope Selection
|
|
1847
|
-
---
|
|
1848
|
-
Press Enter to continue to Project Scope Selection...
|
|
1849
|
-
```
|
|
1850
|
-
---
|
|
1851
|
-
|
|
1852
|
-
## 📝 Generated Documents
|
|
1853
|
-
|
|
1854
|
-
After Phase 0, generate/update:
|
|
1855
|
-
- `.ai-flow/cache/docs-analysis.json` - Cached analysis results (if existing project)
|
|
1856
|
-
|
|
1857
|
-
---
|
|
1858
|
-
|
|
1859
|
-
**Next Phase:** Project Scope Selection (Transition to Phase 1)
|
|
124
|
+
**Next Phase:** Phase 1 - Discovery & Business Requirements
|
|
1860
125
|
|
|
1861
126
|
Read: `.ai-flow/prompts/backend/flow-build-phase-1.md`
|
|
1862
127
|
|
|
1863
128
|
---
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
**Version:** 2.1.8
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
129
|
+
_Version: 4.2 (Antigravity Optimized - Ultra-Light Edition)_
|
|
130
|
+
_Last Updated: 2025-12-21_
|