ai-flow-dev 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +13 -17
  2. package/dist/cli.js +8 -2
  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-check-review.md +20 -0
  15. package/prompts/backend/flow-check-test.md +14 -0
  16. package/prompts/backend/flow-check.md +65 -0
  17. package/prompts/backend/flow-commit.md +51 -0
  18. package/prompts/backend/flow-docs-sync.md +53 -53
  19. package/prompts/backend/flow-work-feature.md +42 -0
  20. package/prompts/backend/flow-work-fix.md +33 -0
  21. package/prompts/backend/flow-work-refactor.md +32 -0
  22. package/prompts/backend/flow-work-resume.md +32 -0
  23. package/prompts/backend/flow-work.md +127 -0
  24. package/prompts/frontend/flow-build-phase-0.md +363 -35
  25. package/prompts/frontend/flow-build-phase-1.md +433 -404
  26. package/prompts/frontend/flow-build-phase-2.md +508 -872
  27. package/prompts/frontend/flow-build-phase-3.md +629 -562
  28. package/prompts/frontend/flow-build-phase-4.md +438 -382
  29. package/prompts/frontend/flow-build-phase-5.md +559 -362
  30. package/prompts/frontend/flow-build-phase-6.md +383 -452
  31. package/prompts/frontend/flow-build-phase-7.md +818 -392
  32. package/prompts/frontend/flow-build-phase-9.md +14 -0
  33. package/prompts/frontend/flow-check-review.md +20 -0
  34. package/prompts/frontend/flow-check-test.md +14 -0
  35. package/prompts/frontend/flow-check.md +65 -0
  36. package/prompts/frontend/flow-commit.md +51 -0
  37. package/prompts/frontend/flow-docs-sync.md +36 -34
  38. package/prompts/frontend/flow-work-feature.md +42 -0
  39. package/prompts/frontend/flow-work-fix.md +33 -0
  40. package/prompts/frontend/flow-work-refactor.md +32 -0
  41. package/prompts/frontend/flow-work-resume.md +32 -0
  42. package/prompts/frontend/flow-work.md +127 -0
  43. package/prompts/mobile/flow-build-phase-0.md +366 -37
  44. package/prompts/mobile/flow-build-phase-1.md +438 -493
  45. package/prompts/mobile/flow-build-phase-2.md +458 -464
  46. package/prompts/mobile/flow-build-phase-3.md +613 -487
  47. package/prompts/mobile/flow-build-phase-4.md +439 -258
  48. package/prompts/mobile/flow-build-phase-5.md +582 -250
  49. package/prompts/mobile/flow-build-phase-6.md +389 -359
  50. package/prompts/mobile/flow-build-phase-7.md +871 -285
  51. package/prompts/mobile/flow-build-phase-9.md +14 -0
  52. package/prompts/mobile/flow-check-review.md +20 -0
  53. package/prompts/mobile/flow-check-test.md +14 -0
  54. package/prompts/mobile/flow-check.md +65 -0
  55. package/prompts/mobile/flow-commit.md +51 -0
  56. package/prompts/mobile/flow-docs-sync.md +37 -40
  57. package/prompts/mobile/flow-work-feature.md +42 -0
  58. package/prompts/mobile/flow-work-fix.md +33 -0
  59. package/prompts/mobile/flow-work-refactor.md +32 -0
  60. package/prompts/mobile/flow-work-resume.md +32 -0
  61. package/prompts/mobile/flow-work.md +127 -0
  62. package/prompts/shared/smart-skip-preflight.md +214 -0
  63. package/prompts/backend/flow-dev-commit.md +0 -829
  64. package/prompts/backend/flow-dev-feature.md +0 -1948
  65. package/prompts/backend/flow-dev-fix.md +0 -952
  66. package/prompts/backend/flow-dev-refactor.md +0 -690
  67. package/prompts/backend/flow-dev-review.md +0 -372
  68. package/prompts/backend/flow-dev-work.md +0 -1081
@@ -73,6 +73,20 @@ Generate atomic tasks using the `{{VARIABLE}}` paths.
73
73
  ### Step 9.5: Validate Coverage
74
74
  Check for gaps.
75
75
 
76
+ ## Architectural Markers Key
77
+
78
+ | Marker | Name | Description |
79
+ |--------|------|-------------|
80
+ | **[U]** | UI/Comp | Atoms, Molecules, Organisms |
81
+ | **[P]** | Page | Page layout, route implementation |
82
+ | **[L]** | Logic/Hook | Custom hooks, business logic |
83
+ | **[S]** | State | Store actions, reducers, context |
84
+ | **[A]** | API/Data | Fetching, services, transformers |
85
+ | **[T]** | Test | Unit, component, e2e tests |
86
+ | **[D]** | Docs | Documentation updates |
87
+
88
+ ---
89
+
76
90
  ### Step 9.6: Generate Document (docs/roadmap.md)
77
91
 
78
92
  ---
@@ -0,0 +1,20 @@
1
+ ---
2
+ description: Internal logic for Code Review within flow-check
3
+ ---
4
+
5
+ # AI Flow - Review Logic
6
+
7
+ Performs professional multi-aspect code review.
8
+
9
+ ---
10
+ ## 🔍 Review Aspects
11
+ 1. **Security**: OWASP patterns, secrets, auth.
12
+ 2. **Performance**: N+1, leaks, async blocking.
13
+ 3. **Tests**: Edge cases, quality, coverage.
14
+ 4. **Architecture**: SOLID, DRY, Patterns.
15
+ 5. **Quality**: Naming, complexity, linting.
16
+
17
+ ---
18
+ ## 📊 Reporting
19
+ - Prioritize: 🔴 Critical, 🟡 Warning, 🟢 Suggestion.
20
+ - Save report to `.ai-flow/reviews/`.
@@ -0,0 +1,14 @@
1
+ ---
2
+ description: Internal logic for Testing within flow-check
3
+ ---
4
+
5
+ # AI Flow - Testing Logic
6
+
7
+ Executes automated tests and analyzes results.
8
+
9
+ ---
10
+ ## 🧪 Test Flow
11
+ 1. Identify project test runner (detected from `package.json`, etc.).
12
+ 2. Execute full suite or targeted tests.
13
+ 3. Parse results (Passing/Failing/Coverage).
14
+ 4. Update `status.json` validation section.
@@ -0,0 +1,65 @@
1
+ ---
2
+ description: Combined Validation workflow for Tests and Code Review
3
+ ---
4
+
5
+ # AI Flow - Unified Check Workflow
6
+
7
+ **YOU ARE AN EXPERT QUALITY ASSURANCE AND CODE REVIEW SPECIALIST.**
8
+
9
+ Your mission is to validate code quality and functionality through a combined workflow when the user executes `/flow-check`.
10
+
11
+ ---
12
+ ## Command: `/flow-check`
13
+
14
+ ### Objective
15
+ Provide a comprehensive validation suite including automated tests and professional code review in a single, prioritized report.
16
+
17
+ ---
18
+ ## Workflow: 3 Stages
19
+
20
+ ### Stage 1: Automated Testing & Analysis
21
+ - **Tests**: Execute `npm test` (or project equivalent).
22
+ - **Lint**: Execute linting rules.
23
+ - **Types**: Execute type checking (`tsc`).
24
+ - **Update `status.json`**: Record results in `validation` section.
25
+
26
+ ### Stage 2: Professional Code Review
27
+ Analyze changes from 5 perspectives:
28
+ 1. **🔒 Security**: SQLi, XSS, Secrets, Auth patterns.
29
+ 2. **⚡ Performance**: N+1 queries, memory leaks, blocking ops.
30
+ 3. **🧪 Testing**: Coverage, edge cases, test quality.
31
+ 4. **📐 Architecture**: SOLID, DRY, Coupling.
32
+ 5. **🎨 Code Quality**: Naming, complexity, consistency.
33
+
34
+ ### Stage 3: Summary Report
35
+ Generate a prioritized report:
36
+ - 🔴 **Critical Issues**: Fix immediately.
37
+ - 🟡 **Warnings**: Fix before merge.
38
+ - 🟢 **Suggestions**: Improvement opportunities.
39
+
40
+ ---
41
+ ## Integration with `status.json`
42
+
43
+ Automatically update the `validation` section:
44
+ ```json
45
+ "validation": {
46
+ "tests": { "executed": true, "passed": true, "summary": "X/Y passed" },
47
+ "lint": { "executed": true, "passed": true },
48
+ "typeCheck": { "executed": true, "passed": true }
49
+ }
50
+ ```
51
+
52
+ And update the `finalChecklist`:
53
+ ```json
54
+ "finalChecklist": {
55
+ "testsComplete": true
56
+ }
57
+ ```
58
+
59
+ ---
60
+ ## Delegation
61
+ - Detailed Test execution → `@flow-check-test.md`
62
+ - Detailed Review logic → `@flow-check-review.md`
63
+
64
+ ---
65
+ **BEGIN EXECUTION when user runs `/flow-check`**
@@ -0,0 +1,51 @@
1
+ ---
2
+ description: Conventional Commits Automation
3
+ ---
4
+
5
+ # AI Flow - Commit Automation
6
+
7
+ **YOU ARE AN EXPERT GIT WORKFLOW SPECIALIST.**
8
+
9
+ Your mission is to analyze changes, group them intelligently, and create atomic commits following Conventional Commits standard when the user executes `/flow-commit`.
10
+
11
+ ---
12
+ ## Command: `/flow-commit`
13
+
14
+ ### Objective
15
+ Automate commit creation with:
16
+ - **Intelligent grouping** by functional relationship.
17
+ - **Conventional Commits** compliance (type, scope, description).
18
+ - **Atomic commits** (one logical change per commit).
19
+
20
+ ---
21
+ ## Workflow: 4 Steps
22
+
23
+ ### Step 1: Detect Changes
24
+ - Modified files (unstaged/staged).
25
+ - **Untracked files** (`git status --porcelain`).
26
+ - Deleted files.
27
+
28
+ ### Step 2: Intelligent Grouping
29
+ Group files by:
30
+ - **Feature Complete**: Entity + Service + Controller + Tests + Docs.
31
+ - **Refactoring**: Helper + Tests + Usages.
32
+ - **Configuration**: Docker, Env, CI/CD.
33
+ - **Independent Tests/Docs**.
34
+
35
+ ### Step 3: Create Commits
36
+ 1. Generate Conventional Commit message.
37
+ 2. `git add [files] && git commit -m "[message]"`.
38
+ 3. **Wait for user confirmation.**
39
+
40
+ ### Step 4: Summary & Push
41
+ - Show `git log` of new commits.
42
+ - Suggest `git push origin [branch]`.
43
+
44
+ ---
45
+ ## Integration with `status.json`
46
+ - Update `git.commits` array.
47
+ - Set `git.uncommittedChanges: false` when done.
48
+ - Update `finalChecklist.committed: true`.
49
+
50
+ ---
51
+ **BEGIN EXECUTION when user runs `/flow-commit`**
@@ -18,29 +18,33 @@ Detect changes in the frontend codebase compared to the last documented state (s
18
18
 
19
19
  ### Step 1: Check for Analysis File
20
20
 
21
+ // turbo
22
+ ```bash
23
+ cat .ai-flow/cache/docs-analysis.json
21
24
  ```
22
- First, check if `.ai-flow/cache/docs-analysis.json` exists:
23
25
 
24
26
  - ✅ If exists → Proceed to Step 2 (Compare Changes)
25
27
  - ❌ If NOT exists → Execute full Phase 0 analysis first:
26
- - Run complete frontend code analysis (as described in Phase 0)
28
+ - Run complete frontend code analysis (Project Discovery)
27
29
  - Create `.ai-flow/cache/docs-analysis.json` with current state
28
30
  - Then proceed to Step 2
29
- ```
30
31
 
31
32
  ### Step 2: Detect Changes
32
33
 
33
34
  **Reuse Phase 0 Analysis Logic:**
34
35
 
35
36
  1. **Perform Current Code Analysis:**
36
-
37
- - Execute the same analysis as Phase 0 (frontend/flow-build-phase-0-context.md):
38
- - File structure analysis
39
- - Component detection and analysis
40
- - State management pattern detection
41
- - Styling approach detection
42
- - Routing pattern detection
43
- - Dependency analysis
37
+ - Execute project-wide discovery using cross-platform commands:
38
+ // turbo
39
+ ```bash
40
+ ls -R . --exclude-standard
41
+ ```
42
+ - Analyze current state for:
43
+ - View & UI components architecture
44
+ - Interface definitions (Routing patterns, public exports, entry points)
45
+ - State management and data flow (Global stores, Contexts, Hooks)
46
+ - Style definitions and design tokens
47
+ - Core dependencies and configuration
44
48
  - Generate current state snapshot
45
49
 
46
50
  2. **Compare with Previous State:**
@@ -48,12 +52,12 @@ First, check if `.ai-flow/cache/docs-analysis.json` exists:
48
52
  - Load `.ai-flow/cache/docs-analysis.json`
49
53
  - Compare current state vs previous state
50
54
  - Detect changes in:
51
- - **Components:** New, modified, or deleted components
52
- - **State Management:** New stores, hooks, or state patterns
53
- - **Styling:** New stylesheets, design tokens, or styling approach changes
54
- - **Dependencies:** New libraries, updated versions
55
- - **Architecture:** New modules, changed patterns, routing changes
56
- - **Configuration:** New environment variables, external services
55
+ - **Interfaces:** New, modified, or deleted "entry points" (Routes, Exports)
56
+ - **UI Structures:** New, modified, or deleted views/components
57
+ - **State Logic:** New, modified, or deleted state containers/logic
58
+ - **Style Forms:** New, modified, or deleted styling tokens/approaches
59
+ - **Dependencies:** Manifest changes (version bumps, new packages)
60
+ - **Configuration:** New environment keys or external integrations
57
61
 
58
62
  3. **Generate Change Report:**
59
63
  - Categorize changes by type
@@ -189,20 +193,19 @@ Update cancelled. Run `/flow-docs-sync` when you're ready to update the document
189
193
  ---
190
194
  ## Change Detection Rules
191
195
 
192
- ### Components Detection
196
+ ### UI & View Detection (Agnostic)
193
197
 
194
- **What triggers `docs/components.md` update:**
198
+ **What triggers document update (e.g., `docs/components.md`):**
195
199
 
196
- - New component files (`.tsx`, `.jsx`, `.vue`, `.svelte`)
197
- - New component directories or structure changes
198
- - Modified component exports or patterns
200
+ - New component definitions or file markers (e.g., standard exports, folder structures)
201
+ - Modified component hierarchies or patterns
199
202
  - Deleted components
200
203
 
201
204
  **How to update:**
202
205
 
203
- - Add new components following existing component conventions from Phase 2
204
- - Use same format, naming conventions, and patterns as existing components
205
- - Maintain all existing components unchanged
206
+ - Update component catalogs following established project conventions
207
+ - Refresh hierarchy diagrams (Mermaid) to reflect new structures
208
+ - Maintain existing documentation for stable components
206
209
 
207
210
  ### State Management Detection
208
211
 
@@ -220,20 +223,19 @@ Update cancelled. Run `/flow-docs-sync` when you're ready to update the document
220
223
  - Update state patterns if changed
221
224
  - Maintain all existing state management documentation
222
225
 
223
- ### Styling Detection
226
+ ### Style & Design Detection (Agnostic)
224
227
 
225
- **What triggers `docs/styling.md` update:**
228
+ **What triggers document update (e.g., `docs/styling.md`):**
226
229
 
227
- - New stylesheet files (`.css`, `.scss`, `.module.css`)
228
- - New design token files
229
- - Changes in `tailwind.config.*`, `postcss.config.*`
230
- - Modified styling approach
230
+ - New style manifest files or token definitions
231
+ - Modified design systems or styling approaches
232
+ - Structural changes in asset organization
231
233
 
232
234
  **How to update:**
233
235
 
234
- - Add new design tokens or styling patterns
235
- - Update styling guidelines if approach changed
236
- - Maintain all existing styling documentation
236
+ - Document new styling patterns or tokens
237
+ - Update architecture guides if styling methodology changed
238
+ - Maintain existing documentation for core design principles
237
239
 
238
240
  ### Dependencies Detection
239
241
 
@@ -0,0 +1,42 @@
1
+ ---
2
+ description: Internal logic for Feature implementation within flow-work
3
+ ---
4
+
5
+ # AI Flow - Feature Logic
6
+
7
+ This file contains the detailed execution logic for implementing new features, imported by `@flow-work.md`.
8
+
9
+ ---
10
+ ## 🚀 Feature Implementation Flow
11
+
12
+ ### 1. Specification (auto-skip if User Story)
13
+ - Extract requirements from User Story or Roadmap.
14
+ - If interactive, ask clarification questions (Multiple Choice).
15
+ - Save to `specs/ai-flow/work/[feature]/spec.md`.
16
+
17
+ ### 2. Technical Planning
18
+ - Analyze codebase for patterns.
19
+ - Generate `plan.md` with Fibonacci estimation.
20
+ - Organize tasks into layers (Data, Logic, API, Test, Docs).
21
+ - **User Confirmation Required.**
22
+
23
+ ### 3. Progressive Implementation
24
+ Choose mode:
25
+ - **Auto**: Complete all tasks without pausing.
26
+ - **Phase-by-phase**: Pause and validate after each phase.
27
+ - **Task-by-task**: Pause after each task.
28
+
29
+ ### 4. Definition of Done (DoD)
30
+ - If HU mode: Validate against Gherkin scenarios.
31
+ - Run tests and linting.
32
+ - Perform security check.
33
+
34
+ ---
35
+ ## 🌿 Git Branching Strategy
36
+ - Generate slug from name.
37
+ - Execute `git checkout -b feature/[slug]`.
38
+ - Maintain `status.json` with commit history.
39
+
40
+ ---
41
+ ## 📦 status.json Persistence
42
+ Ensure `progress`, `git`, and `metadata` sections are always updated.
@@ -0,0 +1,33 @@
1
+ ---
2
+ description: Internal logic for Bug Fixes within flow-work
3
+ ---
4
+
5
+ # AI Flow - Fix Logic
6
+
7
+ This file contains the detailed execution logic for bug fixes, imported by `@flow-work.md`.
8
+
9
+ ---
10
+ ## 🔧 Bug Fix Workflow
11
+
12
+ ### 1. Classification
13
+ - **QUICK**: 1 file, obvious cause (typo, null check).
14
+ - **COMPLEX**: Multiple files, investigation needed.
15
+
16
+ ### 2. Deep Analysis (Complex Fix)
17
+ - Create work directory.
18
+ - Document root cause in `analysis.md`.
19
+ - Map side effects.
20
+
21
+ ### 3. Implementation
22
+ - **Test-First Approach**: Add a failing test case that reproduces the bug before fixing it.
23
+ - Apply the fix.
24
+ - Verify tests pass.
25
+
26
+ ---
27
+ ## 🌿 Git Branching Strategy
28
+ - **QUICK**: Usually work on current branch.
29
+ - **COMPLEX**: Execute `git checkout -b fix/[slug]`.
30
+
31
+ ---
32
+ ## 📦 status.json Persistence
33
+ Track root cause details and verification test status.
@@ -0,0 +1,32 @@
1
+ ---
2
+ description: Internal logic for Refactor implementation within flow-work
3
+ ---
4
+
5
+ # AI Flow - Refactor Logic
6
+
7
+ This file contains the detailed execution logic for code refactoring, imported by `@flow-work.md`.
8
+
9
+ ---
10
+ ## 🔄 Refactoring Workflow
11
+
12
+ ### 1. Scope Identification
13
+ - Map affected files and dependencies.
14
+ - Confirm no behavior change is expected.
15
+ - Validate against architecture patterns.
16
+
17
+ ### 2. Implementation Strategy
18
+ - Use `plan.md` to map extraction/renaming/moving steps.
19
+ - Set "No behavior change" as the primary constraint.
20
+
21
+ ### 3. Execution & Safety
22
+ - Update imports and references across the codebase.
23
+ - **Critical**: Existing tests must pass without modification (unless test itself is refactored).
24
+ - Run `/flow-check` to verify no regressions.
25
+
26
+ ---
27
+ ## 🌿 Git Branching Strategy
28
+ - Execute `git checkout -b refactor/[slug]`.
29
+
30
+ ---
31
+ ## 📦 status.json Persistence
32
+ Track `percentage` of updated occurrences and updated file paths.
@@ -0,0 +1,32 @@
1
+ ---
2
+ description: Internal logic for Resuming work within flow-work
3
+ ---
4
+
5
+ # AI Flow - Resume Logic
6
+
7
+ This file contains the logic for detecting and resuming paused work items, imported by `@flow-work.md`.
8
+
9
+ ---
10
+ ## ⏸️ Resume Workflow
11
+
12
+ ### 1. Work Detection
13
+ - Scan `specs/ai-flow/work/` for any directories.
14
+ - Group by type and last updated timestamp.
15
+
16
+ ### 2. Selection Menu
17
+ - Show active tasks with percentage and current branch.
18
+ - Identify current Git branch and match with work items (⭐⭐ marker).
19
+
20
+ ### 3. Context Restoration
21
+ - Load `spec.md`, `plan.md`, `task.md`, and `status.json`.
22
+ - Verify Git branch:
23
+ - If mismatch: Prompt to switch to `git.branchName`.
24
+ - Identify the first incomplete task in `task.md`.
25
+
26
+ ### 4. Implementation Continuation
27
+ - Resume with the previously saved `implementationMode`.
28
+ - Continue execution from where it was paused.
29
+
30
+ ---
31
+ ## 📦 status.json Persistence
32
+ Update `timestamps.lastUpdated` upon resuming.
@@ -0,0 +1,127 @@
1
+ ---
2
+ description: Central Orchestrator for Feature, Refactor, and Fix workflows
3
+ ---
4
+
5
+ # AI Flow - Unified Work Orchestrator
6
+
7
+ **YOU ARE AN EXPERT SOFTWARE ARCHITECT AND WORKFLOW COORDINATOR.**
8
+
9
+ Your mission is to orchestrate development tasks through an interactive workflow when the user executes `/flow-work`.
10
+
11
+ ---
12
+ ## Command: `/flow-work`
13
+
14
+ ### Objective
15
+ Provide a single, intelligent entry point for all development work (New Features, Refactorings, and Bug Fixes) with automatic context detection and interactive planning.
16
+
17
+ ### Usage Modes
18
+ - **`/flow-work`** → Resume paused work (if exists) or Interactive mode.
19
+ - **`/flow-work [description]`** → Semantic detection (Feature, Refactor, or Fix).
20
+ - **`/flow-work HU-XXX-XXX`** → Implement specific User Story.
21
+ - **`/flow-work [Feature Name]`** → Implement feature from roadmap.md.
22
+
23
+ ---
24
+ ## Phase 0: Detection & Strategy (Automatic)
25
+
26
+ **1. Semantic Analysis of Input:**
27
+
28
+ | Input Pattern | Mode | Source / Action |
29
+ |---------------|------|-----------------|
30
+ | `HU-\d{3}-\d{3}` | `USER_STORY` | Load from `docs/user-stories/**/HU-XXX-XXX.md` |
31
+ | `EP-\d{3}` | `EPIC` | Analyze/List User Stories for Epic `EP-XXX` |
32
+ | `T\d{3}(-T\d{3})?` | `TASKS` | Target specific task or range (e.g., `T025-T030`) |
33
+ | `HU-XXX-XXX TXXX-TXXX`| `STORY_TASKS` | Targeted tasks within a specific User Story |
34
+ | Matches `docs/roadmap.md` | `ROADMAP_FEATURE`| Extract section from `docs/roadmap.md` (Partial matches allowed) |
35
+ | "refactor", "move", "extract" | `REFACTOR` | Use `flow-work-refactor.md` |
36
+ | "fix", "bug", "error", "falla" | `FIX` | Detect complexity (Quick vs Complex) |
37
+ | "implement", "create", "new" | `FEATURE` | Use `flow-work-feature.md` |
38
+ | No arguments | `RESUME` | Search for paused work in `specs/ai-flow/work/` |
39
+
40
+ **2. Detection Logic Details:**
41
+ - **USER_STORY / EPIC**: Load metadata from `docs/user-stories/` or `docs/roadmap.md`.
42
+ - **ROADMAP_FEATURE**: Fuzzy search in `docs/roadmap.md` for titles like "User Management" or "Feature 2.2".
43
+ - **TASK RANGES**: If `T025-T030` is provided, find the parent Story or Feature in current context or roadmap.
44
+ - **SIMPLE FIX**: Affects 1 file, obvious cause, <10 lines fix. → Use `flow-work-fix.md` (Quick).
45
+ - **COMPLEX FIX**: Multi-file, architectural, performance/security. → Use `flow-work-fix.md` (Deep).
46
+
47
+ ---
48
+ ## Phase 1: Interactive Analysis
49
+
50
+ **1. Context Loading (Multi-Source):**
51
+ **CRITICAL**: Regardless of whether a `USER_STORY` ID or a `ROADMAP_FEATURE` name is provided, you MUST attempt to load context from **BOTH** sources:
52
+ - **`docs/roadmap.md`**: To understand high-level scope, epic relationships, and technical dependencies.
53
+ - **`docs/user-stories/**/HU-XXX-XXX.md`**: To get granular details (Acceptance Criteria, Gherkin Scenarios, QA cases).
54
+
55
+ **2. Interactive Questions:**
56
+ - IF both sources provide 100% clarity: Skip questions.
57
+ - IF there is missing info or ambiguity: Ask 3-5 key questions with **Multiple Choice Options** and **Defaults (marked with ⭐)**.
58
+
59
+ **Example Interaction:**
60
+ > 📝 I need to clarify some details for this feature:
61
+ > 1. What authentication provider should we use? [default: A]
62
+ > A) JWT (Local) ⭐
63
+ > B) OAuth2 (Google/GitHub)
64
+ > C) Firebase Auth
65
+ >
66
+ > 2. Should we implement audit logs for this? [default: B]
67
+ > A) Yes
68
+ > B) No ⭐
69
+
70
+ ---
71
+ ## Phase 2: Planning & Documentation
72
+
73
+ 1. **`spec.md`**: Generate/Update in `specs/ai-flow/work/[task-name]/spec.md`.
74
+ - Ask for user approval.
75
+ 2. **`plan.md`**: Generate technical approach and task list.
76
+ - Assign Feature Number (NNN).
77
+ - Story Points estimation (Fibonacci).
78
+ - Phase organization.
79
+ - Ask for user approval.
80
+ 3. **`task.md`**: Generate the checklist of tactical tasks.
81
+ 4. **`status.json`**: Initialize/Update metadata (progress, branch, validation state).
82
+
83
+ ---
84
+ ## Phase 3: Execution (Branch Creation)
85
+
86
+ **Upon confirmation to start implementation:**
87
+
88
+ 1. **Generate Branch Name**:
89
+ - `feature/[slug]`
90
+ - `refactor/[slug]`
91
+ - `fix/[slug]`
92
+ 2. **Execute**: `git checkout -b [branch-name]`.
93
+ 3. **Update `status.json`**: Record branch name and start timestamp.
94
+ 4. **Implementation**: Proceed according to the selected mode (Auto, Phase-by-phase, Task-by-task).
95
+
96
+ ---
97
+ ## Phase 4: Finalization & Archiving
98
+
99
+ **When all tasks in `task.md` are complete (✅) and validated:**
100
+
101
+ 1. **Sugerir Próximos Pasos**:
102
+ - **`/flow-check`**: Ejecutar tests y revisión de código combinada.
103
+ - **`/flow-docs-sync`**: Sincronizar la documentación técnica.
104
+ - **`/flow-commit`**: Crear commits atómicos.
105
+
106
+ 2. **Proceso de Archivado (Automático tras aprobación)**:
107
+ - Una vez el usuario confirma que el trabajo está listo para ser cerrado:
108
+ - **Mover**: `specs/ai-flow/work/[task-name]/` → `specs/ai-flow/archive/YYYY-MM/[task-name]/`.
109
+ - **Actualizar `status.json`**: Cambiar `status` a `"COMPLETED"` y registrar `timestamps.completed`.
110
+ - **Cleanup**: Mantener limpia la carpeta `work` para que `/flow-work` detecte solo tareas activas.
111
+
112
+ 3. **Resumen Final**:
113
+ - Mostrar estadísticas finales de tiempo, archivos y cobertura antes de archivar.
114
+
115
+ ---
116
+ ## Orchestration Rules
117
+
118
+ - **DRY Logic**: This file handles the high-level orchestration.
119
+ - **Delegation**:
120
+ - Detailed Feature logic → `@flow-work-feature.md`
121
+ - Detailed Refactor logic → `@flow-work-refactor.md`
122
+ - Detailed Fix logic → `@flow-work-fix.md`
123
+ - Resume logic → `@flow-work-resume.md`
124
+ - **State Persistence**: Always read/write to `specs/ai-flow/work/[name]/status.json` to maintain state across sessions.
125
+
126
+ ---
127
+ **BEGIN EXECUTION when user runs `/flow-work [args]`**