ai-flow-dev 2.5.4 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +570 -567
  3. package/dist/cli.js +30 -2
  4. package/dist/cli.js.map +1 -1
  5. package/package.json +73 -73
  6. package/prompts/backend/flow-build-phase-0.md +535 -425
  7. package/prompts/backend/flow-build-phase-1.md +626 -626
  8. package/prompts/backend/flow-build-phase-10.md +340 -340
  9. package/prompts/backend/flow-build-phase-2.md +573 -573
  10. package/prompts/backend/flow-build-phase-3.md +834 -782
  11. package/prompts/backend/flow-build-phase-4.md +554 -554
  12. package/prompts/backend/flow-build-phase-5.md +703 -703
  13. package/prompts/backend/flow-build-phase-6.md +524 -524
  14. package/prompts/backend/flow-build-phase-7.md +1001 -1001
  15. package/prompts/backend/flow-build-phase-8.md +1407 -1407
  16. package/prompts/backend/flow-build-phase-9.md +477 -477
  17. package/prompts/backend/flow-build.md +137 -137
  18. package/prompts/backend/flow-check-review.md +20 -20
  19. package/prompts/backend/flow-check-test.md +14 -14
  20. package/prompts/backend/flow-check.md +67 -67
  21. package/prompts/backend/flow-commit.md +119 -119
  22. package/prompts/backend/flow-docs-sync.md +354 -354
  23. package/prompts/backend/flow-work-feature.md +61 -61
  24. package/prompts/backend/flow-work-fix.md +46 -46
  25. package/prompts/backend/flow-work-refactor.md +48 -48
  26. package/prompts/backend/flow-work-resume.md +34 -34
  27. package/prompts/backend/flow-work.md +1286 -1023
  28. package/prompts/desktop/flow-build-phase-0.md +359 -0
  29. package/prompts/desktop/flow-build-phase-1.md +295 -0
  30. package/prompts/desktop/flow-build-phase-10.md +357 -0
  31. package/prompts/desktop/flow-build-phase-2.md +282 -0
  32. package/prompts/desktop/flow-build-phase-3.md +291 -0
  33. package/prompts/desktop/flow-build-phase-4.md +308 -0
  34. package/prompts/desktop/flow-build-phase-5.md +269 -0
  35. package/prompts/desktop/flow-build-phase-6.md +350 -0
  36. package/prompts/desktop/flow-build-phase-7.md +297 -0
  37. package/prompts/desktop/flow-build-phase-8.md +541 -0
  38. package/prompts/desktop/flow-build-phase-9.md +439 -0
  39. package/prompts/desktop/flow-build.md +156 -0
  40. package/prompts/desktop/flow-check-review.md +20 -0
  41. package/prompts/desktop/flow-check-test.md +14 -0
  42. package/prompts/desktop/flow-check.md +67 -0
  43. package/prompts/desktop/flow-commit.md +119 -0
  44. package/prompts/desktop/flow-docs-sync.md +354 -0
  45. package/prompts/desktop/flow-work-feature.md +61 -0
  46. package/prompts/desktop/flow-work-fix.md +46 -0
  47. package/prompts/desktop/flow-work-refactor.md +48 -0
  48. package/prompts/desktop/flow-work-resume.md +34 -0
  49. package/prompts/desktop/flow-work.md +1390 -0
  50. package/prompts/frontend/flow-build-phase-0.md +425 -425
  51. package/prompts/frontend/flow-build-phase-1.md +626 -626
  52. package/prompts/frontend/flow-build-phase-10.md +33 -33
  53. package/prompts/frontend/flow-build-phase-2.md +573 -573
  54. package/prompts/frontend/flow-build-phase-3.md +782 -782
  55. package/prompts/frontend/flow-build-phase-4.md +554 -554
  56. package/prompts/frontend/flow-build-phase-5.md +703 -703
  57. package/prompts/frontend/flow-build-phase-6.md +524 -524
  58. package/prompts/frontend/flow-build-phase-7.md +1001 -1001
  59. package/prompts/frontend/flow-build-phase-8.md +872 -872
  60. package/prompts/frontend/flow-build-phase-9.md +94 -94
  61. package/prompts/frontend/flow-build.md +137 -137
  62. package/prompts/frontend/flow-check-review.md +20 -20
  63. package/prompts/frontend/flow-check-test.md +14 -14
  64. package/prompts/frontend/flow-check.md +67 -67
  65. package/prompts/frontend/flow-commit.md +119 -119
  66. package/prompts/frontend/flow-docs-sync.md +550 -550
  67. package/prompts/frontend/flow-work-feature.md +61 -61
  68. package/prompts/frontend/flow-work-fix.md +38 -38
  69. package/prompts/frontend/flow-work-refactor.md +48 -48
  70. package/prompts/frontend/flow-work-resume.md +34 -34
  71. package/prompts/frontend/flow-work.md +1320 -1027
  72. package/prompts/mobile/flow-build-phase-0.md +425 -425
  73. package/prompts/mobile/flow-build-phase-1.md +626 -626
  74. package/prompts/mobile/flow-build-phase-10.md +32 -32
  75. package/prompts/mobile/flow-build-phase-2.md +573 -573
  76. package/prompts/mobile/flow-build-phase-3.md +782 -782
  77. package/prompts/mobile/flow-build-phase-4.md +554 -554
  78. package/prompts/mobile/flow-build-phase-5.md +703 -703
  79. package/prompts/mobile/flow-build-phase-6.md +524 -524
  80. package/prompts/mobile/flow-build-phase-7.md +1001 -1001
  81. package/prompts/mobile/flow-build-phase-8.md +888 -888
  82. package/prompts/mobile/flow-build-phase-9.md +90 -90
  83. package/prompts/mobile/flow-build.md +135 -135
  84. package/prompts/mobile/flow-check-review.md +20 -20
  85. package/prompts/mobile/flow-check-test.md +14 -14
  86. package/prompts/mobile/flow-check.md +67 -67
  87. package/prompts/mobile/flow-commit.md +119 -119
  88. package/prompts/mobile/flow-docs-sync.md +620 -620
  89. package/prompts/mobile/flow-work-feature.md +61 -61
  90. package/prompts/mobile/flow-work-fix.md +46 -46
  91. package/prompts/mobile/flow-work-refactor.md +48 -48
  92. package/prompts/mobile/flow-work-resume.md +34 -34
  93. package/prompts/mobile/flow-work.md +1329 -1023
  94. package/prompts/shared/mermaid-guidelines.md +102 -102
  95. package/prompts/shared/scope-levels.md +114 -114
  96. package/prompts/shared/smart-skip-preflight.md +214 -214
  97. package/prompts/shared/story-points.md +55 -55
  98. package/prompts/shared/task-format.md +74 -74
  99. package/prompts/shared/task-summary-template.md +277 -277
  100. package/templates/AGENT.template.md +443 -443
  101. package/templates/backend/.clauderules.template +112 -112
  102. package/templates/backend/.cursorrules.template +102 -102
  103. package/templates/backend/README.template.md +2 -2
  104. package/templates/backend/ai-instructions.template.md +2 -2
  105. package/templates/backend/copilot-instructions.template.md +2 -2
  106. package/templates/backend/docs/api.template.md +320 -320
  107. package/templates/backend/docs/business-flows.template.md +97 -97
  108. package/templates/backend/docs/code-standards.template.md +2 -2
  109. package/templates/backend/docs/contributing.template.md +3 -3
  110. package/templates/backend/docs/data-model.template.md +520 -520
  111. package/templates/backend/docs/testing.template.md +2 -2
  112. package/templates/backend/project-brief.template.md +2 -2
  113. package/templates/backend/specs/configuration.template.md +2 -2
  114. package/templates/backend/specs/security.template.md +2 -2
  115. package/templates/desktop/.clauderules.template +112 -0
  116. package/templates/desktop/.cursorrules.template +102 -0
  117. package/templates/desktop/README.template.md +170 -0
  118. package/templates/desktop/ai-instructions.template.md +366 -0
  119. package/templates/desktop/copilot-instructions.template.md +140 -0
  120. package/templates/desktop/docs/docs/api.template.md +320 -0
  121. package/templates/desktop/docs/docs/architecture.template.md +724 -0
  122. package/templates/desktop/docs/docs/business-flows.template.md +102 -0
  123. package/templates/desktop/docs/docs/code-standards.template.md +792 -0
  124. package/templates/desktop/docs/docs/contributing.template.md +149 -0
  125. package/templates/desktop/docs/docs/data-model.template.md +520 -0
  126. package/templates/desktop/docs/docs/operations.template.md +720 -0
  127. package/templates/desktop/docs/docs/testing.template.md +722 -0
  128. package/templates/desktop/project-brief.template.md +150 -0
  129. package/templates/desktop/specs/specs/configuration.template.md +121 -0
  130. package/templates/desktop/specs/specs/security.template.md +392 -0
  131. package/templates/frontend/README.template.md +2 -2
  132. package/templates/frontend/ai-instructions.template.md +2 -2
  133. package/templates/frontend/docs/api-integration.template.md +362 -362
  134. package/templates/frontend/docs/components.template.md +2 -2
  135. package/templates/frontend/docs/error-handling.template.md +360 -360
  136. package/templates/frontend/docs/operations.template.md +107 -107
  137. package/templates/frontend/docs/performance.template.md +124 -124
  138. package/templates/frontend/docs/pwa.template.md +119 -119
  139. package/templates/frontend/docs/state-management.template.md +2 -2
  140. package/templates/frontend/docs/styling.template.md +2 -2
  141. package/templates/frontend/docs/testing.template.md +2 -2
  142. package/templates/frontend/project-brief.template.md +2 -2
  143. package/templates/frontend/specs/accessibility.template.md +95 -95
  144. package/templates/frontend/specs/configuration.template.md +2 -2
  145. package/templates/frontend/specs/security.template.md +175 -175
  146. package/templates/fullstack/README.template.md +252 -252
  147. package/templates/fullstack/ai-instructions.template.md +444 -444
  148. package/templates/fullstack/project-brief.template.md +157 -157
  149. package/templates/fullstack/specs/configuration.template.md +340 -340
  150. package/templates/mobile/README.template.md +167 -167
  151. package/templates/mobile/ai-instructions.template.md +196 -196
  152. package/templates/mobile/docs/app-store.template.md +135 -135
  153. package/templates/mobile/docs/architecture.template.md +63 -63
  154. package/templates/mobile/docs/native-features.template.md +94 -94
  155. package/templates/mobile/docs/navigation.template.md +59 -59
  156. package/templates/mobile/docs/offline-strategy.template.md +65 -65
  157. package/templates/mobile/docs/permissions.template.md +56 -56
  158. package/templates/mobile/docs/state-management.template.md +85 -85
  159. package/templates/mobile/docs/testing.template.md +109 -109
  160. package/templates/mobile/project-brief.template.md +69 -69
  161. package/templates/mobile/specs/build-configuration.template.md +91 -91
  162. package/templates/mobile/specs/deployment.template.md +92 -92
  163. package/templates/work.template.md +47 -47
@@ -1,425 +1,535 @@
1
- ## PHASE 0: Context Discovery (2-5 min)
2
-
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**.
11
-
12
- ---
13
-
14
- ## 🚫 Critical Exclusion Rules
15
- To avoid false-positive detections, **IGNORE** the following folders and files during all detection steps:
16
- - `.ai-flow/work/` (contains active development tasks)
17
- - `.ai-flow/archive/` (contains completed tasks)
18
- - `.agent/` (contains AI workflows)
19
- - `docs/` and `specs/` (if they contain AI Flow generated documentation)
20
- - `planning/` (if it contains AI Flow generated roadmap and user stories)
21
- - `project-brief.md`, `ai-instructions.md`, `AGENT.md`
22
-
23
- **A project is considered "Existing" only if it contains functional source code or framework configuration files OUTSIDE these excluded paths.**
24
-
25
- ---
26
-
27
- ## 0.0 Check for Existing Analysis (Layer 0)
28
-
29
- Check if `.ai-flow/cache/docs-analysis.json` exists and is fresh.
30
-
31
- **If found:**
32
- Ask user to use cached analysis or re-analyze.
33
-
34
- **If not found:**
35
- Proceed to Layer 1.
36
-
37
- ---
38
-
39
- // turbo
40
- ## ⚡ Layer 1: Fast Metadata Scan (10-20 seconds)
41
-
42
- **Purpose:** Detect framework, language, build tool, and existing AI configurations.
43
-
44
- ⭐ **Context Links:**
45
- - Node.js: [package.json](file:///package.json)
46
- - Python: [requirements.txt](file:///requirements.txt) | [pyproject.toml](file:///pyproject.toml)
47
- - PHP: [composer.json](file:///composer.json)
48
- - Go: [go.mod](file:///go.mod)
49
- - Java: [pom.xml](file:///pom.xml) | [build.gradle](file:///build.gradle)
50
-
51
- ### 0.1.1 Universal Tech Stack Detection
52
- **Action:** Use your internal knowledge to detect the language and framework by scanning the root configuration files (package.json, pyproject.toml, etc.).
53
-
54
- **Detect (but don't be limited to):**
55
- - **Node.js:** NestJS, Express, Fastify, etc.
56
- - **Python:** FastAPI, Django, Flask, etc.
57
- - **PHP:** Laravel, Symfony, etc.
58
- - **Java/Kotlin:** Spring Boot, Micronaut, Ktor, etc.
59
- - **Go:** Gin, Echo, Fiber, etc.
60
- - **C#/.NET, Ruby, Rust, Elixir.**
61
-
62
- ### 0.1.2 Find AI & Documentation
63
- - Find existing AI configs (`AGENT.md`, `.cursorrules`, etc.)
64
- - Scan for `README.md` and existing `docs/`.
65
-
66
- ### Layer 1 Output
67
- Show a summary of detected Name, Language, Framework, ORM, and Documentation files.
68
-
69
- ---
70
-
71
- ## 0.2 Layer 2: Structural Analysis (30-90 seconds)
72
-
73
- **Purpose:** Analyze directory organization and architecture patterns without reading code line-by-line.
74
-
75
- ### 0.2.1 Pattern Detection
76
- 1. **Identify Pattern:** Feature-based, Layer-based, Modular Monolith, or Hybrid.
77
- 2. **Entity Detection:** Scan for Schema/Entity files based on the detected ORM (Prisma, TypeORM, Django Models, etc.).
78
- 3. **Maturity Check:** Assess documentation and test coverage ratio.
79
-
80
- ### Layer 2 Output
81
- Summary of Architecture Pattern, Code Structure counts (Controllers, Services, etc.), and Recommended Build Scope (MVP/Production/Enterprise).
82
-
83
- ---
84
-
85
- ## 0.3 Layer 3: Selective Deep Analysis (1-5 minutes, OPTIONAL)
86
-
87
- **Purpose:** Read and parse representative code files for detailed insights into API endpoints, data relationships, and security patterns.
88
-
89
- ### 0.3.1 Areas of Analysis
90
- - **API Endpoints:** Parse routes/controllers.
91
- - **Data Model:** Map entity relationships.
92
- - **Security:** Detect auth patterns (JWT, OAuth), validation (Zod, Pydantic), and middleware.
93
-
94
- ### 0.3.2 Sampling Strategy
95
- Use stratified sampling to read only the most relevant files (e.g., core controllers and entities) to stay within context limits.
96
-
97
- ---
98
-
99
- ## ✅ Validation & Synthesis
100
-
101
- ### Present Findings
102
- Show the final "🔍 BACKEND STACK DETECTED" report and ask for confirmation.
103
-
104
- ### 💾 Cache & Pre-populate
105
-
106
- **Create directory structure (if not exists):**
107
- ```bash
108
- mkdir -p .ai-flow/cache
109
- ```
110
-
111
- 1. **Export:** Save results to `.ai-flow/cache/docs-analysis.json`.
112
- 2. **Pre-populate:** Fill answers for Phases 1-7 based on detected data.
113
-
114
- ---
115
-
116
- ## 0.4 Layer 4: Documentation Audit (30-90s, CONDITIONAL)
117
-
118
- **Trigger:** Only if `docs/` or `specs/` directories exist with content.
119
-
120
- **Purpose:** Validate existing documentation against implemented code to detect inconsistencies.
121
-
122
- ### 0.4.1 Ask User Permission
123
-
124
- ```
125
- 📚 Existing documentation detected (12 files in docs/, 3 in specs/)
126
-
127
- Would you like to audit documentation vs code?
128
- A) Yes, audit and show inconsistencies (recommended)
129
- B) No, skip audit (continue to Phase 1)
130
-
131
- > _
132
- ```
133
-
134
- **If user selects B:** Skip to section 0.5 (Validation & Synthesis).
135
-
136
- ### 0.4.2 Parse Existing Documentation
137
-
138
- **Action:** Extract documented information from:
139
- - `docs/architecture.md` → Architecture patterns
140
- - `docs/data-model.md` Entities and fields
141
- - `docs/api.md` Endpoints and methods
142
- - `specs/requirements.md` Business requirements
143
-
144
- **Save to:** `.ai-flow/cache/docs-snapshot.json`
145
-
146
- ### 0.4.3 Compare Code vs Documentation
147
-
148
- **Compare:**
149
- 1. **Entities:** Schema files (Prisma, TypeORM, etc.) vs `docs/data-model.md`
150
- 2. **Endpoints:** Controllers/Routes vs `docs/api.md`
151
- 3. **Architecture:** Code structure vs `docs/architecture.md`
152
- 4. **Tech Stack:** `package.json` vs documented stack
153
-
154
- **Detect:**
155
- - Items in code but not in docs (undocumented features)
156
- - Items in docs but not in code (missing implementations or obsolete docs)
157
- - Mismatches in fields, types, or patterns
158
-
159
- ### 0.4.4 Classify Inconsistencies
160
-
161
- **Severity Levels:**
162
-
163
- 🔴 **CRITICAL** (Requires user decision):
164
- - Documented entity/endpoint not implemented
165
- - Major architectural mismatch
166
-
167
- 🟡 **MEDIUM** (Auto-correctable with confirmation):
168
- - Implemented endpoint not documented
169
- - Missing fields in docs
170
-
171
- 🟢 **LOW** (Auto-correctable):
172
- - Obsolete fields in docs
173
- - Outdated version numbers
174
-
175
- ### 0.4.5 Generate Audit Summary
176
-
177
- **Output:** Concise summary (full report saved for later).
178
-
179
- ```
180
- ---
181
- 📊 Documentation Audit Summary
182
-
183
- Consistency Score: 72%
184
-
185
- 🔴 Critical: 2 issues
186
- - Entity 'Category' documented but not in schema
187
- - Endpoint POST /api/auth/register documented but missing
188
-
189
- 🟡 Medium: 5 issues
190
- - 3 endpoints implemented but not documented
191
- - 2 entity fields missing in docs
192
-
193
- 🟢 Minor: 3 issues
194
- - 3 obsolete fields in documentation
195
-
196
- 💡 Recommendation:
197
- - Review critical issues before continuing
198
- - Full audit report will be generated in Phase 8
199
- - Auto-corrections can be applied after Phase 8
200
- ---
201
- ```
202
-
203
- ### 0.4.6 Handle Critical Issues (If Any)
204
-
205
- **If critical issues found:**
206
-
207
- ```
208
- ⚠️ Critical inconsistencies detected!
209
-
210
- How would you like to proceed?
211
- A) Continue to Phase 1 (address issues later in Phase 8) ⭐
212
- B) Review critical issues now (interactive)
213
- C) Cancel /flow-build (fix manually first)
214
-
215
- > _
216
- ```
217
-
218
- **Option A (Recommended):** Continue to Phase 1
219
- - Save audit data for Phase 8
220
- - Phase 8 will offer to apply corrections
221
-
222
- **Option B:** Interactive review now
223
- ```
224
- 🔴 Critical Issue 1/2: Entity 'Category'
225
- Documented in docs/data-model.md but NOT in schema
226
-
227
- What should we do?
228
- A) Mark as "To Implement" (add to roadmap)
229
- B) Mark as "Obsolete" (remove from docs in Phase 8)
230
- C) Skip for now
231
-
232
- > _
233
- ```
234
-
235
- **Option C:** Cancel
236
- - User fixes issues manually
237
- - Re-run `/flow-build` later
238
-
239
- ### 0.4.7 Save Audit Data
240
-
241
- > **📌 IMPORTANT - Phases 9-10 for Existing Projects:**
242
- >
243
- > If the project has **substantial functional code already implemented** (detected in Layer 1-3):
244
- > - Set `phase9.recommendation = "SKIP"` with reason: "Project already implemented - roadmap not needed"
245
- > - Set `phase10.recommendation = "SKIP"` with reason: "Project already implemented - user stories not needed"
246
- >
247
- > **Phases 9-10 are only useful for:**
248
- > - New projects (no code yet)
249
- > - Projects in early development (< 30% features implemented)
250
- >
251
- > **For existing projects**, focus on Phases 1-8 (documentation sync) instead.
252
-
253
- **Save to:** `.ai-flow/cache/audit-data.json`
254
-
255
- ```json
256
- {
257
- "auditPerformed": true,
258
- "timestamp": "2025-12-22T16:43:00Z",
259
- "consistencyScore": 72,
260
- "critical": 2,
261
- "medium": 5,
262
- "minor": 3,
263
- "userDecisions": {
264
- "Category": "obsolete",
265
- "POST /api/auth/register": "to_implement"
266
- },
267
- "phases": {
268
- "phase1": {
269
- "file": "project-brief.md",
270
- "exists": true,
271
- "consistencyScore": 100,
272
- "recommendation": "SKIP",
273
- "gaps": [],
274
- "reason": "Complete business context documented"
275
- },
276
- "phase2": {
277
- "file": "docs/data-model.md",
278
- "exists": true,
279
- "consistencyScore": 98,
280
- "recommendation": "SKIP",
281
- "gaps": [],
282
- "reason": "All entities documented and match schema"
283
- },
284
- "phase3": {
285
- "file": "docs/architecture.md",
286
- "exists": true,
287
- "consistencyScore": 87,
288
- "recommendation": "HYBRID",
289
- "gaps": ["api_versioning", "rate_limiting"],
290
- "reason": "Architecture documented but missing 2 details"
291
- },
292
- "phase4": {
293
- "file": "specs/security.md",
294
- "exists": true,
295
- "consistencyScore": 95,
296
- "recommendation": "SKIP",
297
- "gaps": [],
298
- "reason": "Security patterns match implementation"
299
- },
300
- "phase5": {
301
- "file": "docs/code-standards.md",
302
- "exists": true,
303
- "consistencyScore": 92,
304
- "recommendation": "SKIP",
305
- "gaps": [],
306
- "reason": "Standards documented and enforced"
307
- },
308
- "phase6": {
309
- "file": "docs/testing.md",
310
- "exists": true,
311
- "consistencyScore": 90,
312
- "recommendation": "SKIP",
313
- "gaps": [],
314
- "reason": "Testing strategy documented"
315
- },
316
- "phase7": {
317
- "file": "docs/deployment.md",
318
- "exists": true,
319
- "consistencyScore": 82,
320
- "recommendation": "HYBRID",
321
- "gaps": ["monitoring_strategy", "incident_runbooks"],
322
- "reason": "Deployment documented but missing operational details"
323
- },
324
- "phase8": {
325
- "file": "AGENT.md",
326
- "exists": true,
327
- "consistencyScore": 95,
328
- "recommendation": "SKIP",
329
- "gaps": [],
330
- "reason": "Final documentation complete and up-to-date"
331
- },
332
- "phase9": {
333
- "file": "planning/roadmap.md",
334
- "exists": false,
335
- "consistencyScore": 0,
336
- "recommendation": "SKIP",
337
- "gaps": [],
338
- "reason": "Project already implemented - roadmap not needed for existing code"
339
- },
340
- "phase10": {
341
- "file": "planning/user-stories/",
342
- "exists": false,
343
- "consistencyScore": 0,
344
- "recommendation": "SKIP",
345
- "gaps": [],
346
- "reason": "Project already implemented - user stories not needed for existing features"
347
- }
348
- }
349
- }
350
- ```
351
-
352
- **Recommendation Logic:**
353
- - **SKIP** (≥95%): Phase can be skipped, use existing docs
354
- - **HYBRID** (80-94%): Ask only missing questions, merge with existing docs
355
- - **FULL** (<80% or file missing): Execute full phase with pre-filled answers
356
-
357
- This data will be used in Phases 1-7 to:
358
- 1. Determine if phase can be skipped
359
- 2. Identify specific gaps to ask about
360
- 3. Merge new answers with existing documentation
361
-
362
- This data will be used in Phase 8 to:
363
- 1. Generate detailed audit report
364
- 2. Apply auto-corrections
365
- 3. Update roadmap with "To Implement" items
366
-
367
- ---
368
-
369
- ## 0.5 Validation & Synthesis
370
-
371
- ### Present Findings
372
-
373
- Show the final report including:
374
- 1. **🔍 BACKEND STACK DETECTED** (from Layers 1-3)
375
- 2. **📊 Documentation Audit Summary** (from Layer 4, if executed)
376
-
377
- Ask for confirmation to proceed to Phase 1.
378
-
379
- ### 💾 Cache & Pre-populate
380
-
381
- **Create directory structure (if not exists):**
382
- ```bash
383
- mkdir -p .ai-flow/cache .ai-flow/work .ai-flow/archive
384
- ```
385
-
386
- 1. **Export code analysis:** `.ai-flow/cache/docs-analysis.json`
387
- 2. **Export audit data:** `.ai-flow/cache/audit-data.json` (if Layer 4 executed)
388
- 3. **Pre-populate:** Fill answers for Phases 1-7 based on detected data
389
-
390
- ### 🎯 Set Flags for Phase 8
391
-
392
- If documentation audit was performed:
393
- - Set flag: `auditPerformed: true`
394
- - Phase 8 will:
395
- - Generate detailed audit report (`docs/audit-report.md`)
396
- - Offer to apply auto-corrections (🟡 Medium + 🟢 Low)
397
- - Update roadmap with "To Implement" items (🔴 Critical marked as such)
398
-
399
- ---
400
-
401
- ✅ **Phase 0 Complete: Context Analysis Finalized**
402
-
403
- ---
404
-
405
- ### Phase Summary
406
- - Pre-populated detected tech stack values.
407
- - Architectural patterns identified.
408
- - Context cached in `.ai-flow/cache/docs-analysis.json`.
409
- - **Documentation audit completed** (if existing docs found).
410
- - **Inconsistencies flagged** for Phase 8 resolution.
411
-
412
- ---
413
-
414
- **Next Phase:** Phase 1 - Discovery & Business Requirements
415
-
416
- **What happens next:**
417
- - Phase 1-7 will use pre-populated answers (40-60% filled)
418
- - You'll only answer questions that couldn't be auto-detected
419
- - Phase 8 will offer to resolve documentation inconsistencies
420
-
421
- Read: `.ai-flow/prompts/backend/flow-build-phase-1.md`
422
-
423
- ---
424
- _Version: 4.3 (Antigravity Optimized - With Integrated Audit)_
425
- _Last Updated: 2025-12-22_
1
+ ## PHASE 0: Context Discovery (2-5 min)
2
+
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
+ >
7
+ > - **Interactive Mode:** Ask user for permission to scan files layer by layer.
8
+ > - **Autonomous Mode:** Scan all layers automatically and present the final report.
9
+
10
+ ### Objective
11
+
12
+ Efficiently analyze existing projects using a **layered, incremental approach**.
13
+
14
+ ---
15
+
16
+ ## 🚫 Critical Exclusion Rules
17
+
18
+ To avoid false-positive detections, **IGNORE** the following folders and files during all detection steps:
19
+
20
+ - `.ai-flow/work/` (contains active development tasks)
21
+ - `.ai-flow/archive/` (contains completed tasks)
22
+ - `.agent/` (contains AI workflows)
23
+ - `docs/` and `specs/` (if they contain AI Flow generated documentation)
24
+ - `planning/` (if it contains AI Flow generated roadmap and user stories)
25
+ - `project-brief.md`, `ai-instructions.md`, `AGENT.md`
26
+
27
+ **A project is considered "Existing" only if it contains functional source code or framework configuration files OUTSIDE these excluded paths.**
28
+
29
+ ---
30
+
31
+ ## 0.0 Check for Existing Analysis (Layer 0)
32
+
33
+ Check if `.ai-flow/cache/docs-analysis.json` exists and is fresh.
34
+
35
+ **If found:**
36
+ Ask user to use cached analysis or re-analyze.
37
+
38
+ **If not found:**
39
+ Proceed to Layer 1.
40
+
41
+ ---
42
+
43
+ // turbo
44
+
45
+ ## ⚡ Layer 1: Fast Metadata Scan (10-20 seconds)
46
+
47
+ **Purpose:** Detect framework, language, build tool, and existing AI configurations.
48
+
49
+ **Context Links:**
50
+
51
+ - Node.js: [package.json](file:///package.json)
52
+ - Python: [requirements.txt](file:///requirements.txt) | [pyproject.toml](file:///pyproject.toml)
53
+ - PHP: [composer.json](file:///composer.json)
54
+ - Go: [go.mod](file:///go.mod)
55
+ - Java: [pom.xml](file:///pom.xml) | [build.gradle](file:///build.gradle) | [build.xml](file:///build.xml)
56
+ - NetBeans: [nbproject/project.xml](file:///nbproject/project.xml)
57
+ - Eclipse: [.project](file:///.project) | [.classpath](file:///.classpath)
58
+
59
+ ### 0.1.1 Universal Tech Stack Detection
60
+
61
+ **Action:** Use your internal knowledge to detect the language and framework by scanning the root configuration files (package.json, pyproject.toml, etc.).
62
+
63
+ **Detect (but don't be limited to):**
64
+
65
+ - **Node.js:** NestJS, Express, Fastify, etc.
66
+ - **Python:** FastAPI, Django, Flask, etc.
67
+ - **PHP:** Laravel, Symfony, etc.
68
+ - **Java/Kotlin:** Spring Boot, Micronaut, Ktor, NetBeans (Ant), Eclipse (Maven/Gradle), etc.
69
+ - **Go:** Gin, Echo, Fiber, etc.
70
+ - **C#/.NET, Ruby, Rust, Elixir.**
71
+
72
+ **NetBeans Project Detection (Java):**
73
+
74
+ Check for NetBeans-specific markers:
75
+
76
+ - `nbproject/project.xml` - NetBeans project descriptor
77
+ - `build.xml` - Ant build configuration
78
+ - `manifest.mf` - JAR manifest file
79
+ - `src/` with Java source files
80
+ - `lib/` for dependencies (optional)
81
+
82
+ **Eclipse Project Detection (Java):**
83
+
84
+ Check for Eclipse-specific markers:
85
+
86
+ - `.project` - Eclipse project descriptor
87
+ - `.classpath` - Classpath configuration
88
+ - `.settings/` - IDE settings directory
89
+ - `pom.xml` (Maven) or `build.gradle` (Gradle)
90
+ - `src/main/java/` or `src/` for source code
91
+
92
+ **Project Type Classification:**
93
+
94
+ 1. **NetBeans Web Application:**
95
+ - Has `web/` or `WebContent/` directory
96
+ - Contains `web.xml` in `web/WEB-INF/`
97
+ - Servlets/JSP files present
98
+ - Build.xml with web-related targets
99
+
100
+ 2. **NetBeans Desktop Application:**
101
+ - Has Swing `.form` files in `src/`
102
+ - JavaFX `.fxml` files
103
+ - Main class with GUI initialization (JFrame/Application)
104
+ - No web/ directory
105
+
106
+ 3. **Eclipse Desktop Application (Swing/JavaFX):**
107
+ - Has `.project` file
108
+ - Maven/Gradle with JavaFX or Swing dependencies
109
+ - Main class with GUI initialization
110
+ - No web facets
111
+
112
+ 4. **Eclipse Desktop Application (SWT):**
113
+ - Has `.project` file
114
+ - Dependencies: `org.eclipse.swt.*`, `org.eclipse.jface.*`
115
+ - Main class extends `ApplicationWorkbenchAdvisor` or uses `Display`
116
+ - May have `.product` file (RCP)
117
+
118
+ 5. **Enterprise Application (NetBeans/Eclipse):**
119
+ - EJB configurations
120
+ - persistence.xml (JPA)
121
+ - ejb-jar.xml
122
+ - Enterprise modules
123
+
124
+ **Build System Detection:**
125
+
126
+ NetBeans:
127
+
128
+ - Default: Apache Ant (build.xml)
129
+ - Modern: Maven (pom.xml) or Gradle (build.gradle)
130
+ - Hybrid: Ant + Ivy
131
+
132
+ Eclipse:
133
+
134
+ - Default: Maven (pom.xml) or Gradle (build.gradle)
135
+ - Legacy: Ant with Eclipse compiler
136
+ - PDE: Eclipse Plugin Development
137
+
138
+ **Version Detection:**
139
+
140
+ - NetBeans: Check `nbproject/project.properties` for version
141
+ - Eclipse: Check `.project` XML for `<buildSpec>` and `<nature>` tags
142
+ - Java version: Check build config (Maven/Gradle) or project properties
143
+
144
+ ### 0.1.2 Find AI & Documentation
145
+
146
+ - Find existing AI configs (`AGENT.md`, `.cursorrules`, etc.)
147
+ - Scan for `README.md` and existing `docs/`.
148
+
149
+ ### Layer 1 Output
150
+
151
+ Show a summary of detected Name, Language, Framework, ORM, and Documentation files.
152
+
153
+ ---
154
+
155
+ ## 0.2 Layer 2: Structural Analysis (30-90 seconds)
156
+
157
+ **Purpose:** Analyze directory organization and architecture patterns without reading code line-by-line.
158
+
159
+ ### 0.2.1 Pattern Detection
160
+
161
+ 1. **Identify Pattern:** Feature-based, Layer-based, Modular Monolith, or Hybrid.
162
+ 2. **Entity Detection:** Scan for Schema/Entity files based on the detected ORM (Prisma, TypeORM, Django Models, etc.).
163
+ 3. **Maturity Check:** Assess documentation and test coverage ratio.
164
+
165
+ ### Layer 2 Output
166
+
167
+ Summary of Architecture Pattern, Code Structure counts (Controllers, Services, etc.), and Recommended Build Scope (MVP/Production/Enterprise).
168
+
169
+ ---
170
+
171
+ ## 0.3 Layer 3: Selective Deep Analysis (1-5 minutes, OPTIONAL)
172
+
173
+ **Purpose:** Read and parse representative code files for detailed insights into API endpoints, data relationships, and security patterns.
174
+
175
+ ### 0.3.1 Areas of Analysis
176
+
177
+ - **API Endpoints:** Parse routes/controllers.
178
+ - **Data Model:** Map entity relationships.
179
+ - **Security:** Detect auth patterns (JWT, OAuth), validation (Zod, Pydantic), and middleware.
180
+
181
+ ### 0.3.2 Sampling Strategy
182
+
183
+ Use stratified sampling to read only the most relevant files (e.g., core controllers and entities) to stay within context limits.
184
+
185
+ ---
186
+
187
+ ## Validation & Synthesis
188
+
189
+ ### Present Findings
190
+
191
+ Show the final "🔍 BACKEND STACK DETECTED" report and ask for confirmation.
192
+
193
+ ### 💾 Cache & Pre-populate
194
+
195
+ **Create directory structure (if not exists):**
196
+
197
+ ```bash
198
+ mkdir -p .ai-flow/cache
199
+ ```
200
+
201
+ 1. **Export:** Save results to `.ai-flow/cache/docs-analysis.json`.
202
+ 2. **Pre-populate:** Fill answers for Phases 1-7 based on detected data.
203
+
204
+ ---
205
+
206
+ ## 0.4 Layer 4: Documentation Audit (30-90s, CONDITIONAL)
207
+
208
+ **Trigger:** Only if `docs/` or `specs/` directories exist with content.
209
+
210
+ **Purpose:** Validate existing documentation against implemented code to detect inconsistencies.
211
+
212
+ ### 0.4.1 Ask User Permission
213
+
214
+ ```
215
+ 📚 Existing documentation detected (12 files in docs/, 3 in specs/)
216
+
217
+ Would you like to audit documentation vs code?
218
+ A) Yes, audit and show inconsistencies (recommended) ⭐
219
+ B) No, skip audit (continue to Phase 1)
220
+
221
+ > _
222
+ ```
223
+
224
+ **If user selects B:** Skip to section 0.5 (Validation & Synthesis).
225
+
226
+ ### 0.4.2 Parse Existing Documentation
227
+
228
+ **Action:** Extract documented information from:
229
+
230
+ - `docs/architecture.md` Architecture patterns
231
+ - `docs/data-model.md` → Entities and fields
232
+ - `docs/api.md` → Endpoints and methods
233
+ - `specs/requirements.md` → Business requirements
234
+
235
+ **Save to:** `.ai-flow/cache/docs-snapshot.json`
236
+
237
+ ### 0.4.3 Compare Code vs Documentation
238
+
239
+ **Compare:**
240
+
241
+ 1. **Entities:** Schema files (Prisma, TypeORM, etc.) vs `docs/data-model.md`
242
+ 2. **Endpoints:** Controllers/Routes vs `docs/api.md`
243
+ 3. **Architecture:** Code structure vs `docs/architecture.md`
244
+ 4. **Tech Stack:** `package.json` vs documented stack
245
+
246
+ **Detect:**
247
+
248
+ - Items in code but not in docs (undocumented features)
249
+ - Items in docs but not in code (missing implementations or obsolete docs)
250
+ - Mismatches in fields, types, or patterns
251
+
252
+ ### 0.4.4 Classify Inconsistencies
253
+
254
+ **Severity Levels:**
255
+
256
+ 🔴 **CRITICAL** (Requires user decision):
257
+
258
+ - Documented entity/endpoint not implemented
259
+ - Major architectural mismatch
260
+
261
+ 🟡 **MEDIUM** (Auto-correctable with confirmation):
262
+
263
+ - Implemented endpoint not documented
264
+ - Missing fields in docs
265
+
266
+ 🟢 **LOW** (Auto-correctable):
267
+
268
+ - Obsolete fields in docs
269
+ - Outdated version numbers
270
+
271
+ ### 0.4.5 Generate Audit Summary
272
+
273
+ **Output:** Concise summary (full report saved for later).
274
+
275
+ ```
276
+ ---
277
+ 📊 Documentation Audit Summary
278
+
279
+ Consistency Score: 72%
280
+
281
+ 🔴 Critical: 2 issues
282
+ - Entity 'Category' documented but not in schema
283
+ - Endpoint POST /api/auth/register documented but missing
284
+
285
+ 🟡 Medium: 5 issues
286
+ - 3 endpoints implemented but not documented
287
+ - 2 entity fields missing in docs
288
+
289
+ 🟢 Minor: 3 issues
290
+ - 3 obsolete fields in documentation
291
+
292
+ 💡 Recommendation:
293
+ - Review critical issues before continuing
294
+ - Full audit report will be generated in Phase 8
295
+ - Auto-corrections can be applied after Phase 8
296
+ ---
297
+ ```
298
+
299
+ ### 0.4.6 Handle Critical Issues (If Any)
300
+
301
+ **If critical issues found:**
302
+
303
+ ```
304
+ ⚠️ Critical inconsistencies detected!
305
+
306
+ How would you like to proceed?
307
+ A) Continue to Phase 1 (address issues later in Phase 8) ⭐
308
+ B) Review critical issues now (interactive)
309
+ C) Cancel /flow-build (fix manually first)
310
+
311
+ > _
312
+ ```
313
+
314
+ **Option A (Recommended):** Continue to Phase 1
315
+
316
+ - Save audit data for Phase 8
317
+ - Phase 8 will offer to apply corrections
318
+
319
+ **Option B:** Interactive review now
320
+
321
+ ```
322
+ 🔴 Critical Issue 1/2: Entity 'Category'
323
+ Documented in docs/data-model.md but NOT in schema
324
+
325
+ What should we do?
326
+ A) Mark as "To Implement" (add to roadmap)
327
+ B) Mark as "Obsolete" (remove from docs in Phase 8)
328
+ C) Skip for now
329
+
330
+ > _
331
+ ```
332
+
333
+ **Option C:** Cancel
334
+
335
+ - User fixes issues manually
336
+ - Re-run `/flow-build` later
337
+
338
+ ### 0.4.7 Save Audit Data
339
+
340
+ > **📌 IMPORTANT - Phases 9-10 for Existing Projects:**
341
+ >
342
+ > If the project has **substantial functional code already implemented** (detected in Layer 1-3):
343
+ >
344
+ > - Set `phase9.recommendation = "SKIP"` with reason: "Project already implemented - roadmap not needed"
345
+ > - Set `phase10.recommendation = "SKIP"` with reason: "Project already implemented - user stories not needed"
346
+ >
347
+ > **Phases 9-10 are only useful for:**
348
+ >
349
+ > - New projects (no code yet)
350
+ > - Projects in early development (< 30% features implemented)
351
+ >
352
+ > **For existing projects**, focus on Phases 1-8 (documentation sync) instead.
353
+
354
+ **Save to:** `.ai-flow/cache/audit-data.json`
355
+
356
+ ```json
357
+ {
358
+ "auditPerformed": true,
359
+ "timestamp": "2025-12-22T16:43:00Z",
360
+ "consistencyScore": 72,
361
+ "critical": 2,
362
+ "medium": 5,
363
+ "minor": 3,
364
+ "userDecisions": {
365
+ "Category": "obsolete",
366
+ "POST /api/auth/register": "to_implement"
367
+ },
368
+ "phases": {
369
+ "phase1": {
370
+ "file": "project-brief.md",
371
+ "exists": true,
372
+ "consistencyScore": 100,
373
+ "recommendation": "SKIP",
374
+ "gaps": [],
375
+ "reason": "Complete business context documented"
376
+ },
377
+ "phase2": {
378
+ "file": "docs/data-model.md",
379
+ "exists": true,
380
+ "consistencyScore": 98,
381
+ "recommendation": "SKIP",
382
+ "gaps": [],
383
+ "reason": "All entities documented and match schema"
384
+ },
385
+ "phase3": {
386
+ "file": "docs/architecture.md",
387
+ "exists": true,
388
+ "consistencyScore": 87,
389
+ "recommendation": "HYBRID",
390
+ "gaps": ["api_versioning", "rate_limiting"],
391
+ "reason": "Architecture documented but missing 2 details"
392
+ },
393
+ "phase4": {
394
+ "file": "specs/security.md",
395
+ "exists": true,
396
+ "consistencyScore": 95,
397
+ "recommendation": "SKIP",
398
+ "gaps": [],
399
+ "reason": "Security patterns match implementation"
400
+ },
401
+ "phase5": {
402
+ "file": "docs/code-standards.md",
403
+ "exists": true,
404
+ "consistencyScore": 92,
405
+ "recommendation": "SKIP",
406
+ "gaps": [],
407
+ "reason": "Standards documented and enforced"
408
+ },
409
+ "phase6": {
410
+ "file": "docs/testing.md",
411
+ "exists": true,
412
+ "consistencyScore": 90,
413
+ "recommendation": "SKIP",
414
+ "gaps": [],
415
+ "reason": "Testing strategy documented"
416
+ },
417
+ "phase7": {
418
+ "file": "docs/deployment.md",
419
+ "exists": true,
420
+ "consistencyScore": 82,
421
+ "recommendation": "HYBRID",
422
+ "gaps": ["monitoring_strategy", "incident_runbooks"],
423
+ "reason": "Deployment documented but missing operational details"
424
+ },
425
+ "phase8": {
426
+ "file": "AGENT.md",
427
+ "exists": true,
428
+ "consistencyScore": 95,
429
+ "recommendation": "SKIP",
430
+ "gaps": [],
431
+ "reason": "Final documentation complete and up-to-date"
432
+ },
433
+ "phase9": {
434
+ "file": "planning/roadmap.md",
435
+ "exists": false,
436
+ "consistencyScore": 0,
437
+ "recommendation": "SKIP",
438
+ "gaps": [],
439
+ "reason": "Project already implemented - roadmap not needed for existing code"
440
+ },
441
+ "phase10": {
442
+ "file": "planning/user-stories/",
443
+ "exists": false,
444
+ "consistencyScore": 0,
445
+ "recommendation": "SKIP",
446
+ "gaps": [],
447
+ "reason": "Project already implemented - user stories not needed for existing features"
448
+ }
449
+ }
450
+ }
451
+ ```
452
+
453
+ **Recommendation Logic:**
454
+
455
+ - **SKIP** (≥95%): Phase can be skipped, use existing docs
456
+ - **HYBRID** (80-94%): Ask only missing questions, merge with existing docs
457
+ - **FULL** (<80% or file missing): Execute full phase with pre-filled answers
458
+
459
+ This data will be used in Phases 1-7 to:
460
+
461
+ 1. Determine if phase can be skipped
462
+ 2. Identify specific gaps to ask about
463
+ 3. Merge new answers with existing documentation
464
+
465
+ This data will be used in Phase 8 to:
466
+
467
+ 1. Generate detailed audit report
468
+ 2. Apply auto-corrections
469
+ 3. Update roadmap with "To Implement" items
470
+
471
+ ---
472
+
473
+ ## 0.5 Validation & Synthesis
474
+
475
+ ### Present Findings
476
+
477
+ Show the final report including:
478
+
479
+ 1. **🔍 BACKEND STACK DETECTED** (from Layers 1-3)
480
+ 2. **📊 Documentation Audit Summary** (from Layer 4, if executed)
481
+
482
+ Ask for confirmation to proceed to Phase 1.
483
+
484
+ ### 💾 Cache & Pre-populate
485
+
486
+ **Create directory structure (if not exists):**
487
+
488
+ ```bash
489
+ mkdir -p .ai-flow/cache .ai-flow/work .ai-flow/archive
490
+ ```
491
+
492
+ 1. **Export code analysis:** `.ai-flow/cache/docs-analysis.json`
493
+ 2. **Export audit data:** `.ai-flow/cache/audit-data.json` (if Layer 4 executed)
494
+ 3. **Pre-populate:** Fill answers for Phases 1-7 based on detected data
495
+
496
+ ### 🎯 Set Flags for Phase 8
497
+
498
+ If documentation audit was performed:
499
+
500
+ - Set flag: `auditPerformed: true`
501
+ - Phase 8 will:
502
+ - Generate detailed audit report (`docs/audit-report.md`)
503
+ - Offer to apply auto-corrections (🟡 Medium + 🟢 Low)
504
+ - Update roadmap with "To Implement" items (🔴 Critical marked as such)
505
+
506
+ ---
507
+
508
+ ✅ **Phase 0 Complete: Context Analysis Finalized**
509
+
510
+ ---
511
+
512
+ ### Phase Summary
513
+
514
+ - Pre-populated detected tech stack values.
515
+ - Architectural patterns identified.
516
+ - Context cached in `.ai-flow/cache/docs-analysis.json`.
517
+ - **Documentation audit completed** (if existing docs found).
518
+ - **Inconsistencies flagged** for Phase 8 resolution.
519
+
520
+ ---
521
+
522
+ **Next Phase:** Phase 1 - Discovery & Business Requirements
523
+
524
+ **What happens next:**
525
+
526
+ - Phase 1-7 will use pre-populated answers (40-60% filled)
527
+ - You'll only answer questions that couldn't be auto-detected
528
+ - Phase 8 will offer to resolve documentation inconsistencies
529
+
530
+ Read: `.ai-flow/prompts/backend/flow-build-phase-1.md`
531
+
532
+ ---
533
+
534
+ _Version: 4.3 (Antigravity Optimized - With Integrated Audit)_
535
+ _Last Updated: 2025-12-22_