ai-flow-dev 2.2.0 → 2.2.4

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.
Files changed (74) hide show
  1. package/README.md +28 -24
  2. package/dist/cli.js +228 -418
  3. package/dist/cli.js.map +1 -1
  4. package/package.json +1 -1
  5. package/prompts/backend/flow-build-phase-0.md +286 -4
  6. package/prompts/backend/flow-build-phase-1.md +19 -0
  7. package/prompts/backend/flow-build-phase-2.md +19 -0
  8. package/prompts/backend/flow-build-phase-3.md +19 -0
  9. package/prompts/backend/flow-build-phase-4.md +19 -0
  10. package/prompts/backend/flow-build-phase-5.md +19 -0
  11. package/prompts/backend/flow-build-phase-6.md +19 -0
  12. package/prompts/backend/flow-build-phase-7.md +19 -0
  13. package/prompts/backend/flow-build-phase-9.md +14 -0
  14. package/prompts/backend/flow-build.md +2 -0
  15. package/prompts/backend/flow-check-review.md +20 -0
  16. package/prompts/backend/flow-check-test.md +14 -0
  17. package/prompts/backend/flow-check.md +67 -0
  18. package/prompts/backend/flow-commit.md +53 -0
  19. package/prompts/backend/flow-docs-sync.md +55 -53
  20. package/prompts/backend/flow-work-feature.md +42 -0
  21. package/prompts/backend/flow-work-fix.md +33 -0
  22. package/prompts/backend/flow-work-refactor.md +32 -0
  23. package/prompts/backend/flow-work-resume.md +32 -0
  24. package/prompts/backend/flow-work.md +129 -0
  25. package/prompts/frontend/flow-build-phase-0.md +363 -35
  26. package/prompts/frontend/flow-build-phase-1.md +433 -404
  27. package/prompts/frontend/flow-build-phase-2.md +508 -872
  28. package/prompts/frontend/flow-build-phase-3.md +629 -562
  29. package/prompts/frontend/flow-build-phase-4.md +438 -382
  30. package/prompts/frontend/flow-build-phase-5.md +559 -362
  31. package/prompts/frontend/flow-build-phase-6.md +383 -452
  32. package/prompts/frontend/flow-build-phase-7.md +818 -392
  33. package/prompts/frontend/flow-build-phase-9.md +14 -0
  34. package/prompts/frontend/flow-build.md +2 -0
  35. package/prompts/frontend/flow-check-review.md +20 -0
  36. package/prompts/frontend/flow-check-test.md +14 -0
  37. package/prompts/frontend/flow-check.md +67 -0
  38. package/prompts/frontend/flow-commit.md +53 -0
  39. package/prompts/frontend/flow-docs-sync.md +39 -35
  40. package/prompts/frontend/flow-work-feature.md +42 -0
  41. package/prompts/frontend/flow-work-fix.md +33 -0
  42. package/prompts/frontend/flow-work-refactor.md +32 -0
  43. package/prompts/frontend/flow-work-resume.md +32 -0
  44. package/prompts/frontend/flow-work.md +129 -0
  45. package/prompts/mobile/flow-build-phase-0.md +366 -37
  46. package/prompts/mobile/flow-build-phase-1.md +438 -493
  47. package/prompts/mobile/flow-build-phase-2.md +458 -464
  48. package/prompts/mobile/flow-build-phase-3.md +613 -487
  49. package/prompts/mobile/flow-build-phase-4.md +439 -258
  50. package/prompts/mobile/flow-build-phase-5.md +582 -250
  51. package/prompts/mobile/flow-build-phase-6.md +389 -359
  52. package/prompts/mobile/flow-build-phase-7.md +871 -285
  53. package/prompts/mobile/flow-build-phase-9.md +14 -0
  54. package/prompts/mobile/flow-build.md +2 -0
  55. package/prompts/mobile/flow-check-review.md +20 -0
  56. package/prompts/mobile/flow-check-test.md +14 -0
  57. package/prompts/mobile/flow-check.md +67 -0
  58. package/prompts/mobile/flow-commit.md +53 -0
  59. package/prompts/mobile/flow-docs-sync.md +39 -40
  60. package/prompts/mobile/flow-work-feature.md +42 -0
  61. package/prompts/mobile/flow-work-fix.md +33 -0
  62. package/prompts/mobile/flow-work-refactor.md +32 -0
  63. package/prompts/mobile/flow-work-resume.md +32 -0
  64. package/prompts/mobile/flow-work.md +129 -0
  65. package/prompts/shared/smart-skip-preflight.md +214 -0
  66. package/templates/AGENT.template.md +13 -3
  67. package/templates/backend/.clauderules.template +5 -4
  68. package/templates/backend/.cursorrules.template +1 -1
  69. package/prompts/backend/flow-dev-commit.md +0 -829
  70. package/prompts/backend/flow-dev-feature.md +0 -1948
  71. package/prompts/backend/flow-dev-fix.md +0 -952
  72. package/prompts/backend/flow-dev-refactor.md +0 -690
  73. package/prompts/backend/flow-dev-review.md +0 -372
  74. package/prompts/backend/flow-dev-work.md +0 -1081
@@ -1,8 +1,14 @@
1
- # Phase 0: Context Discovery (Mobile)
1
+ ## PHASE 0: Context Discovery (2-5 min)
2
2
 
3
- **⚡ AUTOMATED ANALYSIS - Minimal User Input Required**
3
+ > **Order for this phase:** ALWAYS executed FIRST if an existing project is detected. Skip ONLY for new projects.
4
+
5
+ > **📌 Scope-based behavior:**
6
+ > - **Interactive Mode:** Ask user for permission to scan files layer by layer.
7
+ > - **Autonomous Mode:** Scan all layers automatically and present the final report.
8
+
9
+ ### Objective
10
+ Efficiently analyze existing projects using a **layered, incremental approach**.
4
11
 
5
- This phase automatically analyzes your existing mobile codebase to pre-populate answers for the build questionnaire.
6
12
  ---
7
13
 
8
14
  ## 🚫 Critical Exclusion Rules
@@ -16,57 +22,366 @@ To avoid false-positive detections, **IGNORE** the following folders and files d
16
22
 
17
23
  ---
18
24
 
19
- ## 🎯 Objective
20
- Detect the current mobile stack, architecture patterns, and configuration from existing code.
25
+ ## 0.0 Check for Existing Analysis (Layer 0)
21
26
 
22
- ---
23
- ## 📋 Detection Layers (Progressive)
27
+ Check if `.ai-flow/cache/docs-analysis.json` exists and is fresh.
24
28
 
25
- ### Layer 0: Cache Check (0-2 seconds)
26
- Check if `.ai-flow/cache/mobile-context.json` exists and is fresh (<7 days old).
29
+ **If found:**
30
+ Ask user to use cached analysis or re-analyze.
27
31
 
28
- **Action:** Ask user: "Found cached analysis from X days ago. Use it? (Y/n)"
32
+ **If not found:**
33
+ Proceed to Layer 1.
29
34
 
30
35
  ---
31
- ### Layer 1: Fast Metadata Scan (10-20 seconds)
32
36
 
33
37
  // turbo
34
- **Purpose:** Detect framework, platform, build tool, TypeScript
38
+ ## Layer 1: Fast Metadata Scan (10-20 seconds)
39
+
40
+ **Purpose:** Detect framework, language, build tool, and existing AI configurations.
35
41
 
36
42
  ⭐ **Context Links:**
37
- - Node.js (React Native): [package.json](file:///package.json)
38
- - Flutter: [pubspec.yaml](file:///pubspec.yaml)
39
- - iOS: [Podfile](file:///ios/Podfile) | [Info.plist](file:///ios/App/App/Info.plist)
40
- - Android: [build.gradle](file:///android/build.gradle) | [AndroidManifest.xml](file:///android/app/src/main/AndroidManifest.xml)
41
- - Config: [app.json](file:///app.json) | [tsconfig.json](file:///tsconfig.json)
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)
48
+
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.).
42
51
 
43
- **Action:** Use your internal knowledge to detect the Framework (React Native, Flutter, Native, etc.), Platform Support, Navigation, State Management, and Storage Solution from the configuration files.
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.**
59
+
60
+ ### 0.1.2 Find AI & Documentation
61
+ - Find existing AI configs (`AGENT.md`, `.cursorrules`, etc.)
62
+ - Scan for `README.md` and existing `docs/`.
63
+
64
+ ### Layer 1 Output
65
+ Show a summary of detected Name, Language, Framework, ORM, and Documentation files.
44
66
 
45
67
  ---
46
- ### Layer 2: Structural Analysis (30-90 seconds)
47
- **Purpose:** Analyze navigation structure, component organization, and architecture patterns (Feature-based, Clean Architecture, etc.).
68
+
69
+ ## 0.2 Layer 2: Structural Analysis (30-90 seconds)
70
+
71
+ **Purpose:** Analyze directory organization and architecture patterns without reading code line-by-line.
72
+
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.
77
+
78
+ ### Layer 2 Output
79
+ Summary of Architecture Pattern, Code Structure counts (Controllers, Services, etc.), and Recommended Build Scope (MVP/Production/Enterprise).
48
80
 
49
81
  ---
50
- ### Layer 3: Selective Deep Analysis (Optional, 60-120 seconds)
51
- **Purpose:** Extract advanced patterns, permissions, and native module integrations.
82
+
83
+ ## 0.3 Layer 3: Selective Deep Analysis (1-5 minutes, OPTIONAL)
84
+
85
+ **Purpose:** Read and parse representative code files for detailed insights into API endpoints, data relationships, and security patterns.
86
+
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.
91
+
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.
52
94
 
53
95
  ---
54
- ## ✅ Validation & Confirmation
96
+
97
+ ## ✅ Validation & Synthesis
55
98
 
56
99
  ### Present Findings
57
- Show the summary report and ask for confirmation:
58
- - ✅ Platform
59
- - Framework
60
- - TypeScript/Dart
61
- - Navigation
62
- - ✅ State Management
63
- - ✅ Storage
64
- - ✅ Architecture
100
+ Show the final "🔍 BACKEND STACK DETECTED" report and ask for confirmation.
101
+
102
+ ### 💾 Cache & Pre-populate
103
+ 1. **Export:** Save results to `.ai-flow/cache/docs-analysis.json`.
104
+ 2. **Pre-populate:** Fill answers for Phases 1-7 based on detected data.
65
105
 
66
106
  ---
67
107
 
68
- ## 💾 Cache Storage
69
- Save detected context to `.ai-flow/cache/mobile-context.json` for future use.
108
+ ## 0.4 Layer 4: Documentation Audit (30-90s, CONDITIONAL)
109
+
110
+ **Trigger:** Only if `docs/` or `specs/` directories exist with content.
111
+
112
+ **Purpose:** Validate existing documentation against implemented code to detect inconsistencies.
113
+
114
+ ### 0.4.1 Ask User Permission
115
+
116
+ ```
117
+ 📚 Existing documentation detected (12 files in docs/, 3 in specs/)
118
+
119
+ Would you like to audit documentation vs code?
120
+ A) Yes, audit and show inconsistencies (recommended) ⭐
121
+ B) No, skip audit (continue to Phase 1)
122
+
123
+ > _
124
+ ```
125
+
126
+ **If user selects B:** Skip to section 0.5 (Validation & Synthesis).
127
+
128
+ ### 0.4.2 Parse Existing Documentation
129
+
130
+ **Action:** Extract documented information from:
131
+ - `docs/architecture.md` → Architecture patterns
132
+ - `docs/data-model.md` → Entities and fields
133
+ - `docs/api.md` → Endpoints and methods
134
+ - `specs/requirements.md` → Business requirements
135
+
136
+ **Save to:** `.ai-flow/cache/docs-snapshot.json`
137
+
138
+ ### 0.4.3 Compare Code vs Documentation
139
+
140
+ **Compare:**
141
+ 1. **Entities:** Schema files (Prisma, TypeORM, etc.) vs `docs/data-model.md`
142
+ 2. **Endpoints:** Controllers/Routes vs `docs/api.md`
143
+ 3. **Architecture:** Code structure vs `docs/architecture.md`
144
+ 4. **Tech Stack:** `package.json` vs documented stack
145
+
146
+ **Detect:**
147
+ - Items in code but not in docs (undocumented features)
148
+ - Items in docs but not in code (missing implementations or obsolete docs)
149
+ - Mismatches in fields, types, or patterns
150
+
151
+ ### 0.4.4 Classify Inconsistencies
152
+
153
+ **Severity Levels:**
154
+
155
+ 🔴 **CRITICAL** (Requires user decision):
156
+ - Documented entity/endpoint not implemented
157
+ - Major architectural mismatch
158
+
159
+ 🟡 **MEDIUM** (Auto-correctable with confirmation):
160
+ - Implemented endpoint not documented
161
+ - Missing fields in docs
162
+
163
+ 🟢 **LOW** (Auto-correctable):
164
+ - Obsolete fields in docs
165
+ - Outdated version numbers
166
+
167
+ ### 0.4.5 Generate Audit Summary
168
+
169
+ **Output:** Concise summary (full report saved for later).
170
+
171
+ ```
172
+ ---
173
+ 📊 Documentation Audit Summary
174
+
175
+ Consistency Score: 72%
176
+
177
+ 🔴 Critical: 2 issues
178
+ - Entity 'Category' documented but not in schema
179
+ - Endpoint POST /api/auth/register documented but missing
180
+
181
+ 🟡 Medium: 5 issues
182
+ - 3 endpoints implemented but not documented
183
+ - 2 entity fields missing in docs
184
+
185
+ 🟢 Minor: 3 issues
186
+ - 3 obsolete fields in documentation
187
+
188
+ 💡 Recommendation:
189
+ - Review critical issues before continuing
190
+ - Full audit report will be generated in Phase 8
191
+ - Auto-corrections can be applied after Phase 8
192
+ ---
193
+ ```
194
+
195
+ ### 0.4.6 Handle Critical Issues (If Any)
196
+
197
+ **If critical issues found:**
198
+
199
+ ```
200
+ ⚠️ Critical inconsistencies detected!
201
+
202
+ How would you like to proceed?
203
+ A) Continue to Phase 1 (address issues later in Phase 8) ⭐
204
+ B) Review critical issues now (interactive)
205
+ C) Cancel /flow-build (fix manually first)
206
+
207
+ > _
208
+ ```
209
+
210
+ **Option A (Recommended):** Continue to Phase 1
211
+ - Save audit data for Phase 8
212
+ - Phase 8 will offer to apply corrections
213
+
214
+ **Option B:** Interactive review now
215
+ ```
216
+ 🔴 Critical Issue 1/2: Entity 'Category'
217
+ Documented in docs/data-model.md but NOT in schema
218
+
219
+ What should we do?
220
+ A) Mark as "To Implement" (add to roadmap)
221
+ B) Mark as "Obsolete" (remove from docs in Phase 8)
222
+ C) Skip for now
223
+
224
+ > _
225
+ ```
226
+
227
+ **Option C:** Cancel
228
+ - User fixes issues manually
229
+ - Re-run `/flow-build` later
230
+
231
+ ### 0.4.7 Save Audit Data
232
+
233
+ > **📌 IMPORTANT - Phases 9-10 for Existing Projects:**
234
+ >
235
+ > If the project has **substantial functional code already implemented** (detected in Layer 1-3):
236
+ > - Set `phase9.recommendation = "SKIP"` with reason: "Project already implemented - roadmap not needed"
237
+ > - Set `phase10.recommendation = "SKIP"` with reason: "Project already implemented - user stories not needed"
238
+ >
239
+ > **Phases 9-10 are only useful for:**
240
+ > - New projects (no code yet)
241
+ > - Projects in early development (< 30% features implemented)
242
+ >
243
+ > **For existing projects**, focus on Phases 1-8 (documentation sync) instead.
244
+
245
+ **Save to:** `.ai-flow/cache/audit-data.json`
246
+
247
+ ```json
248
+ {
249
+ "auditPerformed": true,
250
+ "timestamp": "2025-12-22T16:43:00Z",
251
+ "consistencyScore": 72,
252
+ "critical": 2,
253
+ "medium": 5,
254
+ "minor": 3,
255
+ "userDecisions": {
256
+ "Category": "obsolete",
257
+ "POST /api/auth/register": "to_implement"
258
+ },
259
+ "phases": {
260
+ "phase1": {
261
+ "file": "project-brief.md",
262
+ "exists": true,
263
+ "consistencyScore": 100,
264
+ "recommendation": "SKIP",
265
+ "gaps": [],
266
+ "reason": "Complete business context documented"
267
+ },
268
+ "phase2": {
269
+ "file": "docs/data-model.md",
270
+ "exists": true,
271
+ "consistencyScore": 98,
272
+ "recommendation": "SKIP",
273
+ "gaps": [],
274
+ "reason": "All entities documented and match schema"
275
+ },
276
+ "phase3": {
277
+ "file": "docs/architecture.md",
278
+ "exists": true,
279
+ "consistencyScore": 87,
280
+ "recommendation": "HYBRID",
281
+ "gaps": ["api_versioning", "rate_limiting"],
282
+ "reason": "Architecture documented but missing 2 details"
283
+ },
284
+ "phase4": {
285
+ "file": "specs/security.md",
286
+ "exists": true,
287
+ "consistencyScore": 95,
288
+ "recommendation": "SKIP",
289
+ "gaps": [],
290
+ "reason": "Security patterns match implementation"
291
+ },
292
+ "phase5": {
293
+ "file": "docs/code-standards.md",
294
+ "exists": true,
295
+ "consistencyScore": 92,
296
+ "recommendation": "SKIP",
297
+ "gaps": [],
298
+ "reason": "Standards documented and enforced"
299
+ },
300
+ "phase6": {
301
+ "file": "docs/testing.md",
302
+ "exists": true,
303
+ "consistencyScore": 90,
304
+ "recommendation": "SKIP",
305
+ "gaps": [],
306
+ "reason": "Testing strategy documented"
307
+ },
308
+ "phase7": {
309
+ "file": "docs/deployment.md",
310
+ "exists": true,
311
+ "consistencyScore": 82,
312
+ "recommendation": "HYBRID",
313
+ "gaps": ["monitoring_strategy", "incident_runbooks"],
314
+ "reason": "Deployment documented but missing operational details"
315
+ },
316
+ "phase8": {
317
+ "file": "AGENT.md",
318
+ "exists": true,
319
+ "consistencyScore": 95,
320
+ "recommendation": "SKIP",
321
+ "gaps": [],
322
+ "reason": "Final documentation complete and up-to-date"
323
+ },
324
+ "phase9": {
325
+ "file": "docs/roadmap.md",
326
+ "exists": false,
327
+ "consistencyScore": 0,
328
+ "recommendation": "SKIP",
329
+ "gaps": [],
330
+ "reason": "Project already implemented - roadmap not needed for existing code"
331
+ },
332
+ "phase10": {
333
+ "file": "docs/user-stories/",
334
+ "exists": false,
335
+ "consistencyScore": 0,
336
+ "recommendation": "SKIP",
337
+ "gaps": [],
338
+ "reason": "Project already implemented - user stories not needed for existing features"
339
+ }
340
+ }
341
+ }
342
+ ```
343
+
344
+ **Recommendation Logic:**
345
+ - **SKIP** (≥95%): Phase can be skipped, use existing docs
346
+ - **HYBRID** (80-94%): Ask only missing questions, merge with existing docs
347
+ - **FULL** (<80% or file missing): Execute full phase with pre-filled answers
348
+
349
+ This data will be used in Phases 1-7 to:
350
+ 1. Determine if phase can be skipped
351
+ 2. Identify specific gaps to ask about
352
+ 3. Merge new answers with existing documentation
353
+
354
+ This data will be used in Phase 8 to:
355
+ 1. Generate detailed audit report
356
+ 2. Apply auto-corrections
357
+ 3. Update roadmap with "To Implement" items
358
+
359
+ ---
360
+
361
+ ## 0.5 Validation & Synthesis
362
+
363
+ ### Present Findings
364
+
365
+ Show the final report including:
366
+ 1. **🔍 BACKEND STACK DETECTED** (from Layers 1-3)
367
+ 2. **📊 Documentation Audit Summary** (from Layer 4, if executed)
368
+
369
+ Ask for confirmation to proceed to Phase 1.
370
+
371
+ ### 💾 Cache & Pre-populate
372
+
373
+ 1. **Export code analysis:** `.ai-flow/cache/docs-analysis.json`
374
+ 2. **Export audit data:** `.ai-flow/cache/audit-data.json` (if Layer 4 executed)
375
+ 3. **Pre-populate:** Fill answers for Phases 1-7 based on detected data
376
+
377
+ ### 🎯 Set Flags for Phase 8
378
+
379
+ If documentation audit was performed:
380
+ - Set flag: `auditPerformed: true`
381
+ - Phase 8 will:
382
+ - Generate detailed audit report (`docs/audit-report.md`)
383
+ - Offer to apply auto-corrections (🟡 Medium + 🟢 Low)
384
+ - Update roadmap with "To Implement" items (🔴 Critical marked as such)
70
385
 
71
386
  ---
72
387
 
@@ -74,10 +389,24 @@ Save detected context to `.ai-flow/cache/mobile-context.json` for future use.
74
389
 
75
390
  ---
76
391
 
77
- **Next Phase:** Phase 1 - Platform & Framework Selection
392
+ ### Phase Summary
393
+ - Pre-populated detected tech stack values.
394
+ - Architectural patterns identified.
395
+ - Context cached in `.ai-flow/cache/docs-analysis.json`.
396
+ - **Documentation audit completed** (if existing docs found).
397
+ - **Inconsistencies flagged** for Phase 8 resolution.
398
+
399
+ ---
400
+
401
+ **Next Phase:** Phase 1 - Discovery & Business Requirements
402
+
403
+ **What happens next:**
404
+ - Phase 1-7 will use pre-populated answers (40-60% filled)
405
+ - You'll only answer questions that couldn't be auto-detected
406
+ - Phase 8 will offer to resolve documentation inconsistencies
78
407
 
79
- Read: `.ai-flow/prompts/mobile/flow-build-phase-1.md`
408
+ Read: `.ai-flow/prompts/backend/flow-build-phase-1.md`
80
409
 
81
410
  ---
82
- _Version: 4.2 (Antigravity Optimized - Ultra-Light Edition)_
83
- _Last Updated: 2025-12-21_
411
+ _Version: 4.3 (Antigravity Optimized - With Integrated Audit)_
412
+ _Last Updated: 2025-12-22_