ai-flow-dev 2.6.0 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -21
- package/package.json +6 -6
- package/prompts/backend/flow-check-review.md +648 -12
- package/prompts/backend/flow-check-test.md +520 -8
- package/prompts/backend/flow-check.md +687 -29
- package/prompts/backend/flow-commit.md +18 -49
- package/prompts/backend/flow-finish.md +919 -0
- package/prompts/backend/flow-release.md +949 -0
- package/prompts/backend/flow-work.md +296 -221
- package/prompts/desktop/flow-check-review.md +648 -12
- package/prompts/desktop/flow-check-test.md +520 -8
- package/prompts/desktop/flow-check.md +687 -29
- package/prompts/desktop/flow-commit.md +18 -49
- package/prompts/desktop/flow-finish.md +910 -0
- package/prompts/desktop/flow-release.md +662 -0
- package/prompts/desktop/flow-work.md +398 -219
- package/prompts/frontend/flow-check-review.md +648 -12
- package/prompts/frontend/flow-check-test.md +520 -8
- package/prompts/frontend/flow-check.md +687 -29
- package/prompts/frontend/flow-commit.md +18 -49
- package/prompts/frontend/flow-finish.md +910 -0
- package/prompts/frontend/flow-release.md +519 -0
- package/prompts/frontend/flow-work-api.md +1540 -0
- package/prompts/frontend/flow-work.md +774 -218
- package/prompts/mobile/flow-check-review.md +648 -12
- package/prompts/mobile/flow-check-test.md +520 -8
- package/prompts/mobile/flow-check.md +687 -29
- package/prompts/mobile/flow-commit.md +18 -49
- package/prompts/mobile/flow-finish.md +910 -0
- package/prompts/mobile/flow-release.md +751 -0
- package/prompts/mobile/flow-work-api.md +1493 -0
- package/prompts/mobile/flow-work.md +792 -222
- package/templates/AGENT.template.md +1 -1
|
@@ -27,12 +27,95 @@ Provide a single, intelligent entry point for all development work (New Features
|
|
|
27
27
|
|
|
28
28
|
---
|
|
29
29
|
|
|
30
|
+
## Phase -1: Intent Classification (PRE-DETECTION)
|
|
31
|
+
|
|
32
|
+
**CRITICAL: Determine if this is an INFORMATIVE request vs EXECUTION request BEFORE any workflow.**
|
|
33
|
+
|
|
34
|
+
**🔍 INFORMATIVE Patterns (Answer directly, NO execution workflow):**
|
|
35
|
+
|
|
36
|
+
- **Questions:** Starts with `¿`, `how`, `why`, `what`, `when`, `cómo`, `por qué`, `qué`, `cuál`
|
|
37
|
+
- **Analysis verbs:** `explain`, `show`, `list`, `analyze`, `describe`, `compare`, `explica`, `muestra`, `analiza`, `describe`, `compara`
|
|
38
|
+
- **Report requests:** `report`, `informe`, `document`, `documenta`, `summary`, `resumen`, `generate report`, `genera informe`
|
|
39
|
+
- **Exploration:** `find`, `search`, `busca`, `encuentra`, `where is`, `dónde está`
|
|
40
|
+
- **Review requests:** `review`, `revisa`, `check`, `verifica`, `audit`, `audita`
|
|
41
|
+
|
|
42
|
+
**🛠️ EXECUTION Patterns (Enter workflow):**
|
|
43
|
+
|
|
44
|
+
- **Action verbs:** `implement`, `create`, `refactor`, `fix`, `add`, `remove`, `update`, `delete`, `build`, `develop`
|
|
45
|
+
- **Task codes:** `HU-\d{3}-\d{3}`, `EP-\d{3}`, `T\d{3}`
|
|
46
|
+
- **Imperative:** `new feature`, `nueva feature`, `crear`, `implementar`
|
|
47
|
+
|
|
48
|
+
**Detection Logic:**
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
import re
|
|
52
|
+
|
|
53
|
+
# Normalize input
|
|
54
|
+
input_lower = input.strip().lower()
|
|
55
|
+
|
|
56
|
+
# INFORMATIVE patterns (high priority)
|
|
57
|
+
informative_patterns = [
|
|
58
|
+
r'^(¿|how|why|what|when|where|cómo|por qué|qué|cuál|dónde)',
|
|
59
|
+
r'^(explain|show|list|analyze|describe|compare|explica|muestra|analiza|describe|compara)',
|
|
60
|
+
r'(report|informe|document|documenta|summary|resumen)',
|
|
61
|
+
r'(find|search|busca|encuentra)',
|
|
62
|
+
r'(review|revisa|check|verifica|audit|audita)',
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
for pattern in informative_patterns:
|
|
66
|
+
if re.search(pattern, input_lower):
|
|
67
|
+
return "INFORMATIVE" # → Jump to Phase 99
|
|
68
|
+
|
|
69
|
+
# EXECUTION patterns
|
|
70
|
+
execution_patterns = [
|
|
71
|
+
r'(HU-\d{3}-\d{3}|EP-\d{3}|T\d{3})', # Task codes
|
|
72
|
+
r'^(implement|create|refactor|fix|add|remove|update|delete|build|develop)',
|
|
73
|
+
r'(implementar|crear|nueva feature|new feature)',
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
for pattern in execution_patterns:
|
|
77
|
+
if re.search(pattern, input_lower):
|
|
78
|
+
return "EXECUTION" # → Continue to Phase 0
|
|
79
|
+
|
|
80
|
+
# Ambiguous case - ask user
|
|
81
|
+
return "AMBIGUOUS"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Action based on detection:**
|
|
85
|
+
|
|
86
|
+
**IF mode == "INFORMATIVE":**
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
🔍 Detected: Informative request (question/report/analysis)
|
|
90
|
+
|
|
91
|
+
I'll provide a detailed answer without creating work files or branches.
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
→ **Jump to Phase 99: Informative Response**
|
|
95
|
+
|
|
96
|
+
**IF mode == "EXECUTION":**
|
|
97
|
+
|
|
98
|
+
→ **Continue to Phase 0** (current workflow)
|
|
99
|
+
|
|
100
|
+
**IF mode == "AMBIGUOUS":**
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
❓ I'm not sure if this is:
|
|
104
|
+
A) A question/report request (I'll answer directly)
|
|
105
|
+
B) A task to implement (I'll create work plan and execute)
|
|
106
|
+
|
|
107
|
+
Please clarify (A/B): _
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
30
112
|
## Phase 0: Detection & Strategy (Automatic)
|
|
31
113
|
|
|
32
114
|
**1. Semantic Analysis of Input:**
|
|
33
115
|
|
|
34
116
|
| Input Pattern | Mode | Source / Action |
|
|
35
117
|
| ------------------------------ | ----------------- | -------------------------------------------------------------------- |
|
|
118
|
+
| `api\s+([a-z0-9\-_]+)` | `API_MODULE` | Invoke `.ai-flow/prompts/frontend/flow-work-api.md` analyzer |
|
|
36
119
|
| `HU-\d{3}-\d{3}` | `USER_STORY` | Load from `planning/user-stories/**/HU-XXX-XXX.md` |
|
|
37
120
|
| `EP-\d{3}` | `EPIC` | Analyze/List User Stories for Epic `EP-XXX` |
|
|
38
121
|
| `T\d{3}(-T\d{3})?` | `TASKS` | Target specific task or range (e.g., `T025-T030`) |
|
|
@@ -53,6 +136,453 @@ Provide a single, intelligent entry point for all development work (New Features
|
|
|
53
136
|
|
|
54
137
|
---
|
|
55
138
|
|
|
139
|
+
## Phase 0.1: API Module Analysis (Conditional)
|
|
140
|
+
|
|
141
|
+
**ONLY execute if `mode == "API_MODULE"`**
|
|
142
|
+
|
|
143
|
+
This phase manages API URL configuration, invokes the specialized API analyzer, and enriches workflow context with OpenAPI metadata.
|
|
144
|
+
|
|
145
|
+
**🏗️ Architecture Design:**
|
|
146
|
+
|
|
147
|
+
- **This prompt (flow-work)**: Orchestrator with state management (cache, validation, retry logic)
|
|
148
|
+
- **Sub-prompt (flow-work-api)**: Pure analyzer (stateless, receives validated URL)
|
|
149
|
+
- **Cache location**: `.ai-flow/cache/api-config.json`
|
|
150
|
+
- **Why this separation?**:
|
|
151
|
+
- Reusability: analyzer can be used from different orchestrators
|
|
152
|
+
- Testability: pure analyzers are easier to test
|
|
153
|
+
- Maintainability: state management centralized in one place
|
|
154
|
+
|
|
155
|
+
### Step 1: Load or Detect API URL (Cache Management)
|
|
156
|
+
|
|
157
|
+
**1.1. Parse User Input**
|
|
158
|
+
|
|
159
|
+
Extract module name and optional API URL override:
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
// Input examples:
|
|
163
|
+
// - "/flow-work api users"
|
|
164
|
+
// - "api organizations --api-url=http://localhost:3000/api/docs-json"
|
|
165
|
+
|
|
166
|
+
const pattern = /api\s+([a-z0-9\-_]+)(\s+--api-url=(.+))?/;
|
|
167
|
+
const match = userInput.match(pattern);
|
|
168
|
+
|
|
169
|
+
const moduleName = match[1]; // 'users', 'organizations', etc.
|
|
170
|
+
const customApiUrl = match[3]; // Optional override from user
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
**1.2. Check Cache**
|
|
174
|
+
|
|
175
|
+
```javascript
|
|
176
|
+
const cacheFile = '.ai-flow/cache/api-config.json';
|
|
177
|
+
let apiUrl = null;
|
|
178
|
+
let cacheStatus = 'none';
|
|
179
|
+
|
|
180
|
+
if (await fileExists(cacheFile)) {
|
|
181
|
+
const cache = JSON.parse(await readFile(cacheFile));
|
|
182
|
+
|
|
183
|
+
// Check if cache is recent (< 24 hours)
|
|
184
|
+
const lastVerified = new Date(cache.lastVerified);
|
|
185
|
+
const hoursSinceVerified = (Date.now() - lastVerified) / 3600000;
|
|
186
|
+
|
|
187
|
+
if (hoursSinceVerified < 24) {
|
|
188
|
+
apiUrl = cache.apiUrl;
|
|
189
|
+
cacheStatus = 'valid';
|
|
190
|
+
console.log(`✅ Using cached API URL (verified ${Math.round(hoursSinceVerified)}h ago)`);
|
|
191
|
+
console.log(` ${apiUrl}`);
|
|
192
|
+
} else {
|
|
193
|
+
apiUrl = cache.apiUrl; // Still use it, but will re-validate
|
|
194
|
+
cacheStatus = 'expired';
|
|
195
|
+
console.log(`⚠️ Cache expired (${Math.round(hoursSinceVerified)}h old), will re-validate`);
|
|
196
|
+
console.log(` ${apiUrl}`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// User override via --api-url flag takes precedence
|
|
201
|
+
if (customApiUrl) {
|
|
202
|
+
apiUrl = customApiUrl;
|
|
203
|
+
cacheStatus = 'override';
|
|
204
|
+
console.log(`🔧 Using URL override from command: ${apiUrl}`);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Default fallback
|
|
208
|
+
if (!apiUrl) {
|
|
209
|
+
apiUrl = 'http://localhost:3001/api/docs-json';
|
|
210
|
+
cacheStatus = ' default';
|
|
211
|
+
console.log(`🔗 Using default API URL: ${apiUrl}`);
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**1.3. Validate URL (Quick Test)**
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
if (cacheStatus === 'valid') {
|
|
219
|
+
// Skip validation for recent cache (trust it)
|
|
220
|
+
console.log(`⏭️ Skipping validation (cache is recent)`);
|
|
221
|
+
} else {
|
|
222
|
+
// Validate URL before invoking analyzer
|
|
223
|
+
console.log(`\n🔗 Validating API URL: ${apiUrl}`);
|
|
224
|
+
|
|
225
|
+
try {
|
|
226
|
+
const controller = new AbortController();
|
|
227
|
+
const timeoutId = setTimeout(() => controller.abort(), 5000); // 5s quick test
|
|
228
|
+
|
|
229
|
+
const response = await fetch(apiUrl, {
|
|
230
|
+
method: 'HEAD', // Just check if endpoint exists
|
|
231
|
+
signal: controller.signal,
|
|
232
|
+
headers: { Accept: 'application/json' },
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
clearTimeout(timeoutId);
|
|
236
|
+
|
|
237
|
+
if (response.ok) {
|
|
238
|
+
console.log(`✅ Connection successful`);
|
|
239
|
+
} else {
|
|
240
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
241
|
+
}
|
|
242
|
+
} catch (error) {
|
|
243
|
+
// Connection failed - prompt user
|
|
244
|
+
return await handleConnectionError(error, apiUrl, cacheFile);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
**1.4. Handle Connection Errors (Interactive)**
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
async function handleConnectionError(error: Error, attemptedUrl: string, cacheFile: string) {
|
|
253
|
+
const errorMessage =
|
|
254
|
+
error.name === 'AbortError'
|
|
255
|
+
? 'Connection timeout (backend might not be running)'
|
|
256
|
+
: error.message;
|
|
257
|
+
|
|
258
|
+
console.log(`
|
|
259
|
+
❌ Failed to connect to OpenAPI documentation
|
|
260
|
+
|
|
261
|
+
Attempted URL: ${attemptedUrl}
|
|
262
|
+
Error: ${errorMessage}
|
|
263
|
+
|
|
264
|
+
Common causes:
|
|
265
|
+
1. Backend server is not running (npm run dev / npm start)
|
|
266
|
+
2. Wrong port (check backend .env or package.json)
|
|
267
|
+
3. Different path (/api/docs vs /api/docs-json)
|
|
268
|
+
4. CORS not configured for your frontend origin
|
|
269
|
+
|
|
270
|
+
Options:
|
|
271
|
+
a) Provide correct URL ⭐
|
|
272
|
+
b) Retry current URL (if backend is starting up)
|
|
273
|
+
c) Skip API analysis (manual mode - no OpenAPI specs)
|
|
274
|
+
d) Cancel
|
|
275
|
+
|
|
276
|
+
Your choice: _
|
|
277
|
+
`);
|
|
278
|
+
|
|
279
|
+
const choice = await readUserInput();
|
|
280
|
+
|
|
281
|
+
if (choice === 'a') {
|
|
282
|
+
const newUrl = await promptForUrl(cacheFile);
|
|
283
|
+
return { apiUrl: newUrl, validated: true };
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (choice === 'b') {
|
|
287
|
+
console.log('\n⏳ Waiting 3 seconds for backend to start...');
|
|
288
|
+
await sleep(3000);
|
|
289
|
+
|
|
290
|
+
// Retry validation
|
|
291
|
+
try {
|
|
292
|
+
await fetch(attemptedUrl, { method: 'HEAD', signal: AbortSignal.timeout(5000) });
|
|
293
|
+
console.log('✅ Connection successful after retry');
|
|
294
|
+
return { apiUrl: attemptedUrl, validated: true };
|
|
295
|
+
} catch (retryError) {
|
|
296
|
+
console.log('❌ Still failing. Please check backend status.');
|
|
297
|
+
return await handleConnectionError(retryError, attemptedUrl, cacheFile);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if (choice === 'c') {
|
|
302
|
+
console.log('\n⏭️ Skipping API analysis. Switching to manual FEATURE mode...');
|
|
303
|
+
return { mode: 'FEATURE', apiUrl: null, validated: false };
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (choice === 'd') {
|
|
307
|
+
throw new Error('User cancelled operation');
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Invalid choice - ask again
|
|
311
|
+
console.log('\n❌ Invalid option. Please enter a, b, c, or d.');
|
|
312
|
+
return await handleConnectionError(error, attemptedUrl, cacheFile);
|
|
313
|
+
}
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
**1.5. Prompt for URL (with Validation)**
|
|
317
|
+
|
|
318
|
+
```typescript
|
|
319
|
+
async function promptForUrl(cacheFile: string): Promise<string> {
|
|
320
|
+
console.log(`\n📝 Enter OpenAPI Documentation URL\n
|
|
321
|
+
Common patterns:
|
|
322
|
+
NestJS: http://localhost:3000/api/docs-json
|
|
323
|
+
Express: http://localhost:3001/api-docs
|
|
324
|
+
FastAPI: http://localhost:8000/openapi.json
|
|
325
|
+
Spring: http://localhost:8080/v3/api-docs
|
|
326
|
+
|
|
327
|
+
URL: _
|
|
328
|
+
`);
|
|
329
|
+
|
|
330
|
+
const url = await readUserInput();
|
|
331
|
+
|
|
332
|
+
// Validate format
|
|
333
|
+
if (!url.startsWith('http://') && !url.startsWith('https://')) {
|
|
334
|
+
console.log('\n❌ URL must start with http:// or https://');
|
|
335
|
+
return await promptForUrl(cacheFile);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// Test URL
|
|
339
|
+
console.log(`\n🔗 Testing connection to: ${url}`);
|
|
340
|
+
|
|
341
|
+
try {
|
|
342
|
+
const response = await fetch(url, {
|
|
343
|
+
method: 'HEAD',
|
|
344
|
+
signal: AbortSignal.timeout(5000),
|
|
345
|
+
headers: { Accept: 'application/json' },
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
if (!response.ok) {
|
|
349
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
console.log(`
|
|
353
|
+
✅ Connection successful!
|
|
354
|
+
|
|
355
|
+
💾 Saving URL to cache for future commands...
|
|
356
|
+
`);
|
|
357
|
+
|
|
358
|
+
// Save to cache
|
|
359
|
+
await saveToCache(cacheFile, {
|
|
360
|
+
apiUrl: url,
|
|
361
|
+
lastVerified: new Date().toISOString(),
|
|
362
|
+
projectType: 'frontend',
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
return url;
|
|
366
|
+
} catch (error) {
|
|
367
|
+
const errorMsg = error.name === 'AbortError' ? 'Connection timeout' : error.message;
|
|
368
|
+
|
|
369
|
+
console.log(`\n❌ Failed to connect to ${url}\n Error: ${errorMsg}\n
|
|
370
|
+
Try again? (y/n): _
|
|
371
|
+
`);
|
|
372
|
+
|
|
373
|
+
const retry = await readUserInput();
|
|
374
|
+
if (retry.toLowerCase() === 'y') {
|
|
375
|
+
return await promptForUrl(cacheFile);
|
|
376
|
+
} else {
|
|
377
|
+
throw new Error('User cancelled after failed URL validation');
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
**1.6. Cache Management Functions**
|
|
384
|
+
|
|
385
|
+
```typescript
|
|
386
|
+
async function saveToCache(
|
|
387
|
+
cacheFile: string,
|
|
388
|
+
data: { apiUrl: string; lastVerified: string; projectType: string }
|
|
389
|
+
) {
|
|
390
|
+
const cacheDir = '.ai-flow/cache';
|
|
391
|
+
|
|
392
|
+
// Ensure directory exists
|
|
393
|
+
if (!(await fileExists(cacheDir))) {
|
|
394
|
+
await createDirectory(cacheDir);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// Load existing cache or create new
|
|
398
|
+
let cache: any = { history: [] };
|
|
399
|
+
if (await fileExists(cacheFile)) {
|
|
400
|
+
try {
|
|
401
|
+
cache = JSON.parse(await readFile(cacheFile));
|
|
402
|
+
} catch {
|
|
403
|
+
// Corrupted cache, start fresh
|
|
404
|
+
cache = { history: [] };
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// Update cache
|
|
409
|
+
cache.apiUrl = data.apiUrl;
|
|
410
|
+
cache.lastVerified = data.lastVerified;
|
|
411
|
+
cache.projectType = data.projectType;
|
|
412
|
+
|
|
413
|
+
// Add to history
|
|
414
|
+
cache.history = cache.history || [];
|
|
415
|
+
cache.history.unshift({
|
|
416
|
+
url: data.apiUrl,
|
|
417
|
+
timestamp: data.lastVerified,
|
|
418
|
+
status: 'success',
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
// Keep only last 10 entries
|
|
422
|
+
cache.history = cache.history.slice(0, 10);
|
|
423
|
+
|
|
424
|
+
// Save
|
|
425
|
+
await writeFile(cacheFile, JSON.stringify(cache, null, 2));
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
async function clearCache(cacheFile: string) {
|
|
429
|
+
if (await fileExists(cacheFile)) {
|
|
430
|
+
await deleteFile(cacheFile);
|
|
431
|
+
console.log('✅ API cache cleared');
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
### Step 2: Invoke API Module Analyzer
|
|
437
|
+
|
|
438
|
+
**Call sub-prompt with validated URL:**
|
|
439
|
+
|
|
440
|
+
```typescript
|
|
441
|
+
console.log(`\n🔍 Analyzing API module: ${moduleName}`);
|
|
442
|
+
console.log(`📡 Fetching OpenAPI spec from: ${apiUrl}\n`);
|
|
443
|
+
|
|
444
|
+
const analysisResult: OpenAPIAnalysisResult = await invoke_subprompt(
|
|
445
|
+
'.ai-flow/prompts/frontend/flow-work-api.md',
|
|
446
|
+
{
|
|
447
|
+
module: moduleName,
|
|
448
|
+
apiUrl: apiUrl, // Validated URL
|
|
449
|
+
}
|
|
450
|
+
);
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
**Sub-prompt responsibilities:**
|
|
454
|
+
|
|
455
|
+
- Fetch OpenAPI spec from backend
|
|
456
|
+
- Detect project stack (MUI, MRT, React Hook Form, Zod, TanStack Query, etc.)
|
|
457
|
+
- Extract all endpoints for the module
|
|
458
|
+
- Parse DTOs (Response, Create, Update)
|
|
459
|
+
- Detect field specifications with validation rules
|
|
460
|
+
- Identify relationships (foreign keys, populated entities)
|
|
461
|
+
- Detect features (pagination, search, sorting, filters)
|
|
462
|
+
- Calculate complexity (SIMPLE/MEDIUM/COMPLEX)
|
|
463
|
+
- Return structured `OpenAPIAnalysisResult` JSON
|
|
464
|
+
|
|
465
|
+
### Step 3: Handle Sub-Prompt Result
|
|
466
|
+
|
|
467
|
+
**IF `analysisResult.success === true`:**
|
|
468
|
+
|
|
469
|
+
```
|
|
470
|
+
✅ API Analysis Complete
|
|
471
|
+
|
|
472
|
+
Module: ${analysisResult.module}
|
|
473
|
+
Endpoints: ${analysisResult.endpoints.length}
|
|
474
|
+
Complexity: ${analysisResult.complexity.level}
|
|
475
|
+
|
|
476
|
+
💾 Updating cache with successful connection...
|
|
477
|
+
|
|
478
|
+
Proceeding with enriched context...
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
Store in workflow context:
|
|
482
|
+
|
|
483
|
+
```typescript
|
|
484
|
+
workflow_context.analysis = analysisResult;
|
|
485
|
+
workflow_context.mode = 'API_MODULE';
|
|
486
|
+
workflow_context.module = analysisResult.module;
|
|
487
|
+
|
|
488
|
+
// Update cache with successful analysis
|
|
489
|
+
await saveToCache(cacheFile, {
|
|
490
|
+
apiUrl: apiUrl,
|
|
491
|
+
lastVerified: new Date().toISOString(),
|
|
492
|
+
projectType: 'frontend',
|
|
493
|
+
});
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
**IF `analysisResult.success === false`:**
|
|
497
|
+
|
|
498
|
+
```
|
|
499
|
+
❌ API Analysis Failed
|
|
500
|
+
|
|
501
|
+
Error: ${analysisResult.error}
|
|
502
|
+
Details: ${analysisResult.details}
|
|
503
|
+
|
|
504
|
+
Suggestions:
|
|
505
|
+
${analysisResult.suggestions.map((s, i) => ` ${i+1}. ${s}`).join('\n')}
|
|
506
|
+
|
|
507
|
+
The API URL might have changed or the backend spec is invalid.
|
|
508
|
+
|
|
509
|
+
Options:
|
|
510
|
+
A) Update URL and retry
|
|
511
|
+
B) Clear cache and try default URL
|
|
512
|
+
C) Proceed with manual mode (no OpenAPI analysis)
|
|
513
|
+
D) Cancel
|
|
514
|
+
|
|
515
|
+
Your choice: _
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
**User selects:**
|
|
519
|
+
|
|
520
|
+
- **A**: Prompt for new URL, save to cache, retry Phase 0.1
|
|
521
|
+
- **B**: Clear cache, use default, retry Phase 0.1
|
|
522
|
+
- **C**: Switch to `FEATURE` mode, continue without OpenAPI
|
|
523
|
+
- **D**: Abort workflow
|
|
524
|
+
|
|
525
|
+
### Step 4: Enrich Workflow Context
|
|
526
|
+
|
|
527
|
+
Merge analysis into workflow context for use in subsequent phases:
|
|
528
|
+
|
|
529
|
+
```typescript
|
|
530
|
+
workflow_context = {
|
|
531
|
+
...workflow_context,
|
|
532
|
+
|
|
533
|
+
// From API analysis
|
|
534
|
+
projectStandards: analysisResult.projectStandards,
|
|
535
|
+
openapi: analysisResult.openapi,
|
|
536
|
+
endpoints: analysisResult.endpoints,
|
|
537
|
+
schemas: analysisResult.schemas,
|
|
538
|
+
fields: analysisResult.fields,
|
|
539
|
+
features: analysisResult.features,
|
|
540
|
+
relationships: analysisResult.relationships,
|
|
541
|
+
|
|
542
|
+
// For Phase 2 (work.md generation)
|
|
543
|
+
template: 'api-module', // Use specialized template
|
|
544
|
+
|
|
545
|
+
// For Phase 0.5 (complexity override)
|
|
546
|
+
complexity_override: analysisResult.complexity.level,
|
|
547
|
+
estimatedSP: analysisResult.complexity.estimatedSP,
|
|
548
|
+
estimatedHours: analysisResult.complexity.estimatedHours,
|
|
549
|
+
};
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
### Step 5: Show Analysis Summary
|
|
553
|
+
|
|
554
|
+
Present structured summary to user (condensed version):
|
|
555
|
+
|
|
556
|
+
```
|
|
557
|
+
📋 API Module Analysis Summary
|
|
558
|
+
|
|
559
|
+
📊 Module: ${moduleName}
|
|
560
|
+
🔗 API: ${apiUrl}
|
|
561
|
+
|
|
562
|
+
📐 Detected Project Stack:
|
|
563
|
+
UI: ${projectStandards.stack.ui}
|
|
564
|
+
Table: ${projectStandards.stack.table} ✅
|
|
565
|
+
Forms: ${projectStandards.stack.forms} + ${projectStandards.stack.validation} ✅
|
|
566
|
+
Data: ${projectStandards.stack.query} ✅
|
|
567
|
+
|
|
568
|
+
🔧 Endpoints: ${endpoints.length} detected
|
|
569
|
+
📦 Entity: ${schemas.response.fields.length} fields
|
|
570
|
+
🔗 Relationships: ${relationships.length}
|
|
571
|
+
🏗️ Complexity: ${complexity.level} (${complexity.estimatedHours}h estimated)
|
|
572
|
+
|
|
573
|
+
✅ All standards locked. Module will match existing patterns.
|
|
574
|
+
|
|
575
|
+
Proceeding to Phase 0.5...
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
### Step 6: Continue to Phase 0.5
|
|
579
|
+
|
|
580
|
+
With enriched context, proceed to complexity classification.
|
|
581
|
+
|
|
582
|
+
**Note**: In API_MODULE mode, complexity is already determined by the analyzer, so Phase 0.5 will use `workflow_context.complexity_override` instead of calculating it.
|
|
583
|
+
|
|
584
|
+
---
|
|
585
|
+
|
|
56
586
|
## Phase 0.5: Complexity Classification (CRITICAL)
|
|
57
587
|
|
|
58
588
|
**Analyze task scope to determine workflow:**
|
|
@@ -89,7 +619,10 @@ Provide a single, intelligent entry point for all development work (New Features
|
|
|
89
619
|
**Detection Logic:**
|
|
90
620
|
|
|
91
621
|
```python
|
|
92
|
-
|
|
622
|
+
# Special case: API_MODULE mode (complexity already determined)
|
|
623
|
+
if mode == "API_MODULE":
|
|
624
|
+
complexity = workflow_context.complexity_override # From API analyzer
|
|
625
|
+
elif files_affected == 1 and lines_changed < 20 and no_tests_needed and no_architecture_impact:
|
|
93
626
|
complexity = "SIMPLE"
|
|
94
627
|
elif files_affected <= 5 and lines_changed <= 100 and architecture_impact == "minimal":
|
|
95
628
|
complexity = "MEDIUM"
|
|
@@ -661,48 +1194,9 @@ git status --porcelain
|
|
|
661
1194
|
- All checkboxes in work.md marked complete
|
|
662
1195
|
- User explicitly requests finalization
|
|
663
1196
|
|
|
664
|
-
**CRITICAL: This phase requires EXPLICIT user confirmations at each step.**
|
|
665
|
-
|
|
666
1197
|
---
|
|
667
1198
|
|
|
668
|
-
###
|
|
669
|
-
|
|
670
|
-
```
|
|
671
|
-
🔍 Running validation...
|
|
672
|
-
```
|
|
673
|
-
|
|
674
|
-
Execute:
|
|
675
|
-
|
|
676
|
-
```bash
|
|
677
|
-
npm test # or project-specific test command
|
|
678
|
-
npm run lint # or project-specific lint command
|
|
679
|
-
```
|
|
680
|
-
|
|
681
|
-
Show results:
|
|
682
|
-
|
|
683
|
-
```
|
|
684
|
-
📊 Validation Results
|
|
685
|
-
|
|
686
|
-
Tests: [✅ Passed | ❌ Failed (N tests)]
|
|
687
|
-
Lint: [✅ Clean | ⚠️ N warnings | ❌ N errors]
|
|
688
|
-
Coverage: [X%]
|
|
689
|
-
|
|
690
|
-
Proceed with finalization?
|
|
691
|
-
|
|
692
|
-
a) Yes, continue ⭐
|
|
693
|
-
b) No, let me fix issues
|
|
694
|
-
c) Skip validation (not recommended)
|
|
695
|
-
|
|
696
|
-
Your choice: _
|
|
697
|
-
```
|
|
698
|
-
|
|
699
|
-
- **'b'**: Return to Phase 3 for fixes, END finalization
|
|
700
|
-
- **'c'**: Show warning, ask confirmation again, then continue
|
|
701
|
-
- **'a'**: Continue to Step 2
|
|
702
|
-
|
|
703
|
-
---
|
|
704
|
-
|
|
705
|
-
### Step 2: Source Documentation Update (Interactive)
|
|
1199
|
+
### Source Documentation Update (Interactive)
|
|
706
1200
|
|
|
707
1201
|
**Detect source references:**
|
|
708
1202
|
|
|
@@ -766,262 +1260,324 @@ Your choice: _
|
|
|
766
1260
|
|
|
767
1261
|
---
|
|
768
1262
|
|
|
769
|
-
|
|
1263
|
+
## ✅ Development Work Complete
|
|
770
1264
|
|
|
771
|
-
|
|
1265
|
+
Your code is ready for finalization. You have two options:
|
|
772
1266
|
|
|
773
|
-
|
|
774
|
-
git diff --stat
|
|
775
|
-
git log --oneline origin/[base-branch]..HEAD
|
|
776
|
-
```
|
|
1267
|
+
### Option A: Run Full Finalization Now (Recommended) ⭐
|
|
777
1268
|
|
|
778
|
-
|
|
1269
|
+
Execute `/flow-finish` to complete all finalization steps automatically:
|
|
779
1270
|
|
|
780
|
-
|
|
781
|
-
|
|
1271
|
+
- ✅ **Smart Validation** - Runs tests + lint only if needed (or revalidates if requested)
|
|
1272
|
+
- 📦 **Work Archiving** - Records analytics to `.ai-flow/archive/analytics.jsonl`, cleans workspace
|
|
1273
|
+
- 🤖 **AI-Powered Summaries** - Generates professional PR/Jira descriptions (~1,200 tokens)
|
|
1274
|
+
- 🚀 **Optional Push** - Pushes to remote with explicit confirmation
|
|
782
1275
|
|
|
783
|
-
|
|
784
|
-
- Branch: [branch-name]
|
|
785
|
-
- Files changed: [N]
|
|
786
|
-
- Commits: [N]
|
|
787
|
-
- Duration: [X min]
|
|
1276
|
+
**To proceed:** Type `/flow-finish` in the chat
|
|
788
1277
|
|
|
789
|
-
|
|
1278
|
+
---
|
|
790
1279
|
|
|
791
|
-
|
|
792
|
-
→ Record analytics, delete work files, clean state
|
|
1280
|
+
### Option B: Manual Finalization
|
|
793
1281
|
|
|
794
|
-
|
|
795
|
-
→ Record analytics, rename folder to [task]-completed
|
|
1282
|
+
If you prefer granular control over each step:
|
|
796
1283
|
|
|
797
|
-
|
|
798
|
-
|
|
1284
|
+
1. **Validation:** `/flow-check` - Run comprehensive validation (tests + code review)
|
|
1285
|
+
2. **Commit:** `/flow-commit` - Create conventional commit with auto-generated message
|
|
1286
|
+
3. **Archive:** Manually record analytics and clean `.ai-flow/work/[task-name]/`
|
|
1287
|
+
4. **Push:** `git push origin [branch-name]` when ready
|
|
799
1288
|
|
|
800
|
-
|
|
801
|
-
|
|
1289
|
+
---
|
|
1290
|
+
|
|
1291
|
+
**What would you like to do?**
|
|
1292
|
+
|
|
1293
|
+
```
|
|
1294
|
+
a) Run /flow-finish now ⭐ (Recommended - comprehensive automation)
|
|
1295
|
+
b) I'll handle finalization manually (granular control)
|
|
1296
|
+
c) Tell me more about what /flow-finish does
|
|
802
1297
|
|
|
803
1298
|
Your choice: _
|
|
804
1299
|
```
|
|
805
1300
|
|
|
806
|
-
**
|
|
1301
|
+
**If 'a':** Execute `/flow-finish` immediately
|
|
1302
|
+
|
|
1303
|
+
**If 'b':** Show confirmation and end workflow:
|
|
807
1304
|
|
|
808
1305
|
```
|
|
809
|
-
✅
|
|
810
|
-
```
|
|
1306
|
+
✅ Understood. Development complete.
|
|
811
1307
|
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
type: '[feature|refactor|fix]',
|
|
819
|
-
src: '[HU-001-002|roadmap-2.3|manual]',
|
|
820
|
-
dur: Math.round((completed - created) / 60000), // minutes
|
|
821
|
-
start: timestamps.created,
|
|
822
|
-
end: new Date().toISOString(),
|
|
823
|
-
tasks: progress.totalTasks,
|
|
824
|
-
sp: extract_story_points_from_work_md(),
|
|
825
|
-
commits: git.commits.length,
|
|
826
|
-
valid: validation.tests.passed && validation.lint.passed,
|
|
827
|
-
};
|
|
828
|
-
|
|
829
|
-
// IF complexity == "MEDIUM" (only work.md):
|
|
830
|
-
analytics = {
|
|
831
|
-
task: '[task-name]',
|
|
832
|
-
type: '[detected-from-folder-name]',
|
|
833
|
-
src: 'manual',
|
|
834
|
-
dur: estimate_duration_from_git_log(),
|
|
835
|
-
start: get_first_commit_timestamp(),
|
|
836
|
-
end: new Date().toISOString(),
|
|
837
|
-
tasks: count_checkboxes_in_work_md(),
|
|
838
|
-
sp: extract_story_points_from_work_md() || null,
|
|
839
|
-
commits: count_commits_in_branch(),
|
|
840
|
-
valid: validation_passed,
|
|
841
|
-
};
|
|
842
|
-
```
|
|
1308
|
+
📋 Manual finalization checklist:
|
|
1309
|
+
- [ ] Run validation: /flow-check
|
|
1310
|
+
- [ ] Commit changes: /flow-commit
|
|
1311
|
+
- [ ] Archive work folder
|
|
1312
|
+
- [ ] Push to remote
|
|
1313
|
+
- [ ] Create PR/MR
|
|
843
1314
|
|
|
844
|
-
|
|
1315
|
+
💡 Tip: You can run /flow-finish anytime to automate these steps.
|
|
845
1316
|
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
```
|
|
1317
|
+
🎉 Great work!
|
|
1318
|
+
```
|
|
849
1319
|
|
|
850
|
-
|
|
1320
|
+
**If 'c':** Show detailed explanation:
|
|
851
1321
|
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
```
|
|
1322
|
+
```
|
|
1323
|
+
📖 About /flow-finish
|
|
855
1324
|
|
|
856
|
-
|
|
1325
|
+
/flow-finish is an intelligent finalization workflow that:
|
|
857
1326
|
|
|
858
|
-
|
|
859
|
-
|
|
1327
|
+
1️⃣ **Smart Validation (Step 1)**
|
|
1328
|
+
- Detects if /flow-check was already run successfully
|
|
1329
|
+
- Only re-runs if explicitly requested or validation failed
|
|
1330
|
+
- Shows comprehensive test + lint results
|
|
860
1331
|
|
|
861
|
-
|
|
862
|
-
-
|
|
863
|
-
-
|
|
864
|
-
-
|
|
865
|
-
- Validation: [✅ Passed | ❌ Failed]
|
|
866
|
-
```
|
|
1332
|
+
2️⃣ **Smart Commit (Step 2)**
|
|
1333
|
+
- Detects uncommitted changes automatically
|
|
1334
|
+
- Runs /flow-commit only if needed
|
|
1335
|
+
- Generates conventional commit messages
|
|
867
1336
|
|
|
868
|
-
**
|
|
1337
|
+
3️⃣ **Work Archiving (Step 3)**
|
|
1338
|
+
- Extracts analytics: duration, story points, commits
|
|
1339
|
+
- Appends to .ai-flow/archive/analytics.jsonl
|
|
1340
|
+
- Deletes .ai-flow/work/[task-name]/ folder
|
|
869
1341
|
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
3. Show: `✅ Task marked complete. Files kept in: .ai-flow/work/[task]-completed/`
|
|
1342
|
+
4️⃣ **AI Summaries (Step 4)**
|
|
1343
|
+
- Reads git diff + commit history
|
|
1344
|
+
- Generates professional PR description
|
|
1345
|
+
- Generates ticket update (Jira/ClickUp/Linear)
|
|
1346
|
+
- ~1,200 tokens, markdown-formatted
|
|
876
1347
|
|
|
877
|
-
**
|
|
1348
|
+
5️⃣ **Optional Push (Step 5)**
|
|
1349
|
+
- Always asks for confirmation
|
|
1350
|
+
- Shows branch name and remote
|
|
1351
|
+
- Never pushes without explicit approval
|
|
878
1352
|
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
2. Show: `⏸️ Task paused. Resume with: /flow-work`
|
|
884
|
-
3. **END finalization**
|
|
1353
|
+
**Would you like to run it now?** (y/n): _
|
|
1354
|
+
```
|
|
1355
|
+
|
|
1356
|
+
**END WORKFLOW**
|
|
885
1357
|
|
|
886
|
-
|
|
1358
|
+
---
|
|
887
1359
|
|
|
888
|
-
|
|
889
|
-
|
|
1360
|
+
## Orchestration Rules
|
|
1361
|
+
|
|
1362
|
+
- **DRY Logic**: This file handles the high-level orchestration.
|
|
1363
|
+
- **Delegation**:
|
|
1364
|
+
- Detailed Feature logic → `@flow-work-feature.md`
|
|
1365
|
+
- Detailed Refactor logic → `@flow-work-refactor.md`
|
|
1366
|
+
- Detailed Fix logic → `@flow-work-fix.md`
|
|
1367
|
+
- Resume logic → `@flow-work-resume.md`
|
|
1368
|
+
- **State Persistence**: Always read/write to `.ai-flow/work/[name]/status.json` to maintain state across sessions.
|
|
890
1369
|
|
|
891
1370
|
---
|
|
892
1371
|
|
|
893
|
-
|
|
1372
|
+
## Phase 99: Informative Response
|
|
894
1373
|
|
|
895
|
-
**
|
|
1374
|
+
**This phase handles questions, reports, and analysis requests WITHOUT creating work files or branches.**
|
|
896
1375
|
|
|
897
|
-
|
|
898
|
-
📋 Generate ticket summary?
|
|
1376
|
+
### 1. Analyze Request Type
|
|
899
1377
|
|
|
900
|
-
|
|
1378
|
+
**Classify the informative request:**
|
|
901
1379
|
|
|
902
|
-
|
|
903
|
-
|
|
1380
|
+
- **Technical Question:** How does X work? Why do we use Y?
|
|
1381
|
+
- **Component Explanation:** Explain this component/hook/utility
|
|
1382
|
+
- **Architecture Review:** Show me the component structure/state management
|
|
1383
|
+
- **Project Report:** Generate report on bundle size/dependencies/performance
|
|
1384
|
+
- **File Location:** Where is X component? Find Y hook
|
|
1385
|
+
- **Comparison:** Compare X vs Y approach
|
|
1386
|
+
- **Best Practices:** What's the best way to do X in React/Vue/Angular?
|
|
904
1387
|
|
|
905
|
-
|
|
1388
|
+
### 2. Load Relevant Context
|
|
906
1389
|
|
|
907
|
-
|
|
1390
|
+
**Based on request type, load specific documentation:**
|
|
908
1391
|
|
|
909
|
-
|
|
910
|
-
[ -f .ai-flow/prompts/shared/task-summary-template.md ]
|
|
911
|
-
```
|
|
1392
|
+
**IF question about architecture/patterns:**
|
|
912
1393
|
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
- Last line of `analytics.jsonl`
|
|
917
|
-
- Git stats: `git diff --stat`, `git log --oneline`
|
|
918
|
-
- Branch info
|
|
919
|
-
- Populate template with real data
|
|
920
|
-
- Show formatted summary
|
|
1394
|
+
- Read `ai-instructions.md` (NEVER/ALWAYS rules)
|
|
1395
|
+
- Read `docs/architecture.md` (component structure, state management)
|
|
1396
|
+
- Search codebase for examples
|
|
921
1397
|
|
|
922
|
-
|
|
923
|
-
- Generate basic summary:
|
|
1398
|
+
**IF question about specific component:**
|
|
924
1399
|
|
|
925
|
-
|
|
926
|
-
|
|
1400
|
+
- Search codebase for component files
|
|
1401
|
+
- Read relevant specs from `specs/`
|
|
1402
|
+
- Check related hooks/utilities
|
|
927
1403
|
|
|
928
|
-
|
|
929
|
-
**Type**: [feature|refactor|fix]
|
|
930
|
-
**Duration**: [X min]
|
|
931
|
-
**Story Points**: [N]
|
|
932
|
-
**Commits**: [N]
|
|
933
|
-
**Branch**: [branch-name]
|
|
934
|
-
**Status**: ✅ Complete
|
|
1404
|
+
**IF report request:**
|
|
935
1405
|
|
|
936
|
-
|
|
937
|
-
|
|
1406
|
+
- Run appropriate analysis (bundle size, performance, dependencies)
|
|
1407
|
+
- Read relevant docs for context
|
|
1408
|
+
- Generate structured report
|
|
938
1409
|
|
|
939
|
-
|
|
940
|
-
[git log --oneline output]
|
|
941
|
-
```
|
|
1410
|
+
**IF file location request:**
|
|
942
1411
|
|
|
943
|
-
|
|
1412
|
+
- Search codebase with grep/semantic search
|
|
1413
|
+
- List relevant components with descriptions
|
|
944
1414
|
|
|
945
|
-
|
|
1415
|
+
### 3. Provide Comprehensive Answer
|
|
946
1416
|
|
|
947
|
-
|
|
948
|
-
⏭️ Skipping ticket summary
|
|
949
|
-
```
|
|
1417
|
+
**Structure your response:**
|
|
950
1418
|
|
|
951
|
-
|
|
1419
|
+
```markdown
|
|
1420
|
+
## [Question/Request]
|
|
952
1421
|
|
|
953
|
-
###
|
|
1422
|
+
### Answer
|
|
954
1423
|
|
|
955
|
-
|
|
956
|
-
|
|
1424
|
+
[Detailed explanation with code examples if relevant]
|
|
1425
|
+
|
|
1426
|
+
### Related Documentation
|
|
1427
|
+
|
|
1428
|
+
- [Link to relevant docs]
|
|
1429
|
+
- [Link to component examples]
|
|
957
1430
|
|
|
958
|
-
|
|
1431
|
+
### Additional Context
|
|
959
1432
|
|
|
960
|
-
|
|
1433
|
+
[Architecture decisions, design patterns, performance considerations]
|
|
1434
|
+
|
|
1435
|
+
### Related User Stories/Features
|
|
1436
|
+
|
|
1437
|
+
[If applicable, link to planning docs]
|
|
961
1438
|
```
|
|
962
1439
|
|
|
963
|
-
**
|
|
1440
|
+
**Guidelines:**
|
|
1441
|
+
|
|
1442
|
+
- **Be comprehensive:** Load all relevant context, don't guess
|
|
1443
|
+
- **Show examples:** Include actual code from the project
|
|
1444
|
+
- **Reference docs:** Link to `docs/`, `specs/`, `planning/`
|
|
1445
|
+
- **Explain trade-offs:** Why was X pattern chosen over Y?
|
|
1446
|
+
- **Provide sources:** Always cite where information comes from
|
|
1447
|
+
|
|
1448
|
+
### 4. Offer Follow-up Actions
|
|
1449
|
+
|
|
1450
|
+
**After answering, offer next steps:**
|
|
964
1451
|
|
|
965
|
-
```bash
|
|
966
|
-
git push origin [branch-name]
|
|
967
1452
|
```
|
|
1453
|
+
✅ Answer provided.
|
|
968
1454
|
|
|
969
|
-
|
|
1455
|
+
Would you like me to:
|
|
1456
|
+
A) Implement changes based on this analysis
|
|
1457
|
+
B) Create a work plan for improvements
|
|
1458
|
+
C) Generate a spec/doc for this
|
|
1459
|
+
D) Nothing, just the answer
|
|
970
1460
|
|
|
1461
|
+
Your choice (or just ask another question): _
|
|
971
1462
|
```
|
|
972
|
-
✅ Pushed to origin/[branch-name]
|
|
973
1463
|
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
-
|
|
977
|
-
-
|
|
1464
|
+
**IF user chooses A or B:**
|
|
1465
|
+
|
|
1466
|
+
- Return to Phase 0 with refined objective
|
|
1467
|
+
- Create appropriate work.md and proceed with execution
|
|
1468
|
+
|
|
1469
|
+
**IF user chooses C:**
|
|
1470
|
+
|
|
1471
|
+
- Create spec/doc file in appropriate location
|
|
1472
|
+
- Commit with descriptive message
|
|
1473
|
+
|
|
1474
|
+
**IF user chooses D or asks another question:**
|
|
1475
|
+
|
|
1476
|
+
- **END WORKFLOW** (no files created, no branches)
|
|
1477
|
+
|
|
1478
|
+
### 5. Example Interactions
|
|
1479
|
+
|
|
1480
|
+
**Example 1: Technical Question**
|
|
1481
|
+
|
|
1482
|
+
````
|
|
1483
|
+
User: /flow-work ¿cómo funciona el state management con Context API?
|
|
1484
|
+
|
|
1485
|
+
Agent:
|
|
1486
|
+
🔍 Detected: Informative request (question)
|
|
1487
|
+
|
|
1488
|
+
## How State Management Works in This Project
|
|
1489
|
+
|
|
1490
|
+
### Implementation
|
|
1491
|
+
|
|
1492
|
+
We use Context API with custom hooks in `src/contexts/`:
|
|
1493
|
+
- `AuthContext.tsx` - User authentication state
|
|
1494
|
+
- `ThemeContext.tsx` - Theme preferences
|
|
1495
|
+
- `AppContext.tsx` - Global app state
|
|
1496
|
+
|
|
1497
|
+
[Shows actual code from project]
|
|
1498
|
+
|
|
1499
|
+
### Pattern
|
|
1500
|
+
```typescript
|
|
1501
|
+
// Example from AuthContext.tsx
|
|
1502
|
+
const AuthProvider: FC<Props> = ({ children }) => {
|
|
1503
|
+
const [user, setUser] = useState<User | null>(null);
|
|
1504
|
+
const [loading, setLoading] = useState(true);
|
|
1505
|
+
|
|
1506
|
+
// Context value
|
|
1507
|
+
const value = { user, loading, login, logout };
|
|
1508
|
+
|
|
1509
|
+
return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
|
|
1510
|
+
};
|
|
1511
|
+
````
|
|
1512
|
+
|
|
1513
|
+
### Usage in Components
|
|
1514
|
+
|
|
1515
|
+
```typescript
|
|
1516
|
+
// Any component
|
|
1517
|
+
const { user, login, logout } = useAuth();
|
|
978
1518
|
```
|
|
979
1519
|
|
|
980
|
-
|
|
1520
|
+
### Why Context API vs Redux?
|
|
1521
|
+
|
|
1522
|
+
- Lighter weight for our use case
|
|
1523
|
+
- No external dependencies
|
|
1524
|
+
- Sufficient for current app complexity
|
|
1525
|
+
- Can migrate to Redux if state grows
|
|
1526
|
+
|
|
1527
|
+
### Related Documentation
|
|
1528
|
+
|
|
1529
|
+
- `docs/architecture.md` - State management patterns
|
|
1530
|
+
- `docs/components.md` - Component guidelines
|
|
1531
|
+
|
|
1532
|
+
Would you like me to implement any changes to this? (Y/N): \_
|
|
981
1533
|
|
|
982
1534
|
```
|
|
983
|
-
⏭️ Skipping push
|
|
984
1535
|
|
|
985
|
-
|
|
986
|
-
|
|
1536
|
+
**Example 2: Report Request**
|
|
1537
|
+
|
|
987
1538
|
```
|
|
988
1539
|
|
|
989
|
-
|
|
1540
|
+
User: /flow-work genera un informe del tamaño del bundle
|
|
990
1541
|
|
|
991
|
-
|
|
1542
|
+
Agent:
|
|
1543
|
+
🔍 Detected: Informative request (report)
|
|
992
1544
|
|
|
993
|
-
|
|
994
|
-
✅ Task Finalization Complete
|
|
1545
|
+
## Bundle Size Report
|
|
995
1546
|
|
|
996
|
-
|
|
997
|
-
- [✅|⚠️] Validation passed
|
|
998
|
-
- [✅|⏭️] Documentation updated
|
|
999
|
-
- [✅|⏭️] Task archived
|
|
1000
|
-
- [✅|⏭️] Ticket summary generated
|
|
1001
|
-
- [✅|⏭️] Pushed to remote
|
|
1547
|
+
[Runs bundle analysis]
|
|
1002
1548
|
|
|
1003
|
-
|
|
1004
|
-
Branch: [branch-name]
|
|
1005
|
-
Duration: [X min]
|
|
1006
|
-
Commits: [N]
|
|
1549
|
+
### Total Bundle Size: 245 KB (gzipped: 78 KB)
|
|
1007
1550
|
|
|
1008
|
-
|
|
1009
|
-
|
|
1551
|
+
| Asset | Size | Gzipped | % of Total |
|
|
1552
|
+
| ---------- | ------ | ------- | ---------- |
|
|
1553
|
+
| main.js | 180 KB | 58 KB | 73.5% |
|
|
1554
|
+
| vendor.js | 45 KB | 15 KB | 18.4% |
|
|
1555
|
+
| styles.css | 20 KB | 5 KB | 8.1% |
|
|
1010
1556
|
|
|
1011
|
-
|
|
1557
|
+
### Largest Dependencies
|
|
1012
1558
|
|
|
1013
|
-
|
|
1559
|
+
1. `react-dom` - 42 KB
|
|
1560
|
+
2. `axios` - 15 KB
|
|
1561
|
+
3. `date-fns` - 12 KB
|
|
1562
|
+
4. `lodash` - 8 KB (⚠️ not tree-shaken)
|
|
1014
1563
|
|
|
1015
|
-
|
|
1564
|
+
### Recommendations
|
|
1016
1565
|
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
-
|
|
1566
|
+
1. Use `lodash-es` for tree-shaking (saves ~6 KB)
|
|
1567
|
+
2. Consider lazy loading routes (saves ~30 KB initial)
|
|
1568
|
+
3. Move `date-fns` locales to dynamic imports
|
|
1569
|
+
|
|
1570
|
+
### Comparison to Target
|
|
1571
|
+
|
|
1572
|
+
- Target: <100 KB gzipped ✅
|
|
1573
|
+
- Current: 78 KB gzipped ✅
|
|
1574
|
+
- Margin: 22 KB available
|
|
1575
|
+
|
|
1576
|
+
Would you like me to create a work plan to optimize further? (Y/N): \_
|
|
1577
|
+
|
|
1578
|
+
```
|
|
1024
1579
|
|
|
1025
1580
|
---
|
|
1026
1581
|
|
|
1027
1582
|
**BEGIN EXECUTION when user runs `/flow-work [args]`**
|
|
1583
|
+
```
|