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