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