ai-flow-dev 2.1.3 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -38
- package/dist/cli.js +68 -46
- package/dist/cli.js.map +1 -1
- package/package.json +5 -5
- package/prompts/backend/flow-build-phase-0.md +31 -63
- package/prompts/backend/flow-build-phase-1.md +9 -17
- package/prompts/backend/flow-build-phase-10.md +199 -585
- package/prompts/backend/flow-build-phase-2.md +152 -86
- package/prompts/backend/flow-build-phase-3.md +108 -68
- package/prompts/backend/flow-build-phase-4.md +5 -8
- package/prompts/backend/flow-build-phase-5.md +39 -12
- package/prompts/backend/flow-build-phase-6.md +29 -8
- package/prompts/backend/flow-build-phase-7.md +120 -40
- package/prompts/backend/flow-build-phase-8.md +28 -65
- package/prompts/backend/flow-build-phase-9.md +267 -1298
- package/prompts/backend/flow-build.md +881 -957
- package/prompts/backend/flow-dev-commit.md +27 -50
- package/prompts/backend/flow-dev-feature.md +1929 -2017
- package/prompts/backend/flow-dev-fix.md +936 -964
- package/prompts/backend/flow-dev-refactor.md +672 -701
- package/prompts/backend/flow-dev-review.md +356 -389
- package/prompts/backend/flow-dev-work.md +1066 -1118
- package/prompts/backend/flow-docs-sync.md +20 -196
- package/prompts/frontend/flow-build-phase-0.md +503 -484
- package/prompts/frontend/flow-build-phase-1.md +445 -433
- package/prompts/frontend/flow-build-phase-2.md +910 -957
- package/prompts/frontend/flow-build-phase-3.md +692 -664
- package/prompts/frontend/flow-build-phase-4.md +478 -463
- package/prompts/frontend/flow-build-phase-5.md +488 -467
- package/prompts/frontend/flow-build-phase-6.md +571 -550
- package/prompts/frontend/flow-build-phase-7.md +560 -592
- package/prompts/frontend/flow-build-phase-8.md +17 -42
- package/prompts/frontend/flow-build.md +457 -503
- package/prompts/frontend/flow-docs-sync.md +14 -35
- package/prompts/mobile/flow-build-phase-0.md +104 -97
- package/prompts/mobile/flow-build-phase-1.md +137 -122
- package/prompts/mobile/flow-build-phase-2.md +123 -130
- package/prompts/mobile/flow-build-phase-3.md +144 -149
- package/prompts/mobile/flow-build-phase-4.md +140 -132
- package/prompts/mobile/flow-build-phase-5.md +70 -70
- package/prompts/mobile/flow-build-phase-6.md +136 -134
- package/prompts/mobile/flow-build-phase-7.md +24 -58
- package/prompts/mobile/flow-build-phase-8.md +17 -42
- package/prompts/mobile/flow-build.md +47 -97
- package/prompts/mobile/flow-docs-sync.md +13 -32
- package/prompts/shared/mermaid-guidelines.md +106 -0
- package/prompts/shared/scope-levels.md +126 -0
- package/prompts/shared/story-points.md +65 -0
- package/prompts/shared/task-format.md +86 -0
- package/templates/AGENT.template.md +194 -15
- package/templates/backend/README.template.md +2 -32
- package/templates/backend/ai-instructions.template.md +2 -32
- package/templates/backend/copilot-instructions.template.md +2 -22
- package/templates/backend/docs/api.template.md +89 -20
- package/templates/backend/docs/architecture.template.md +165 -53
- package/templates/backend/docs/business-flows.template.md +7 -14
- package/templates/backend/docs/code-standards.template.md +2 -38
- package/templates/backend/docs/contributing.template.md +2 -16
- package/templates/backend/docs/data-model.template.md +125 -21
- package/templates/backend/docs/operations.template.md +179 -50
- package/templates/backend/docs/testing.template.md +2 -42
- package/templates/backend/project-brief.template.md +2 -28
- package/templates/backend/specs/configuration.template.md +2 -14
- package/templates/backend/specs/security.template.md +2 -32
- package/templates/frontend/README.template.md +2 -18
- package/templates/frontend/ai-instructions.template.md +2 -20
- package/templates/frontend/docs/api-integration.template.md +12 -30
- package/templates/frontend/docs/components.template.md +2 -28
- package/templates/frontend/docs/error-handling.template.md +11 -27
- package/templates/frontend/docs/operations.template.md +8 -18
- package/templates/frontend/docs/performance.template.md +8 -18
- package/templates/frontend/docs/pwa.template.md +8 -18
- package/templates/frontend/docs/state-management.template.md +2 -28
- package/templates/frontend/docs/styling.template.md +2 -26
- package/templates/frontend/docs/testing.template.md +2 -28
- package/templates/frontend/project-brief.template.md +2 -16
- package/templates/frontend/specs/accessibility.template.md +8 -18
- package/templates/frontend/specs/configuration.template.md +2 -24
- package/templates/frontend/specs/security.template.md +10 -24
- package/templates/fullstack/README.template.md +17 -47
- package/templates/fullstack/ai-instructions.template.md +17 -45
- package/templates/fullstack/project-brief.template.md +16 -42
- package/templates/fullstack/specs/configuration.template.md +16 -42
- package/templates/mobile/README.template.md +11 -29
- package/templates/mobile/ai-instructions.template.md +11 -27
- package/templates/mobile/docs/app-store.template.md +11 -29
- package/templates/mobile/docs/architecture.template.md +14 -38
- package/templates/mobile/docs/native-features.template.md +16 -44
- package/templates/mobile/docs/navigation.template.md +9 -23
- package/templates/mobile/docs/offline-strategy.template.md +10 -26
- package/templates/mobile/docs/permissions.template.md +9 -23
- package/templates/mobile/docs/state-management.template.md +12 -32
- package/templates/mobile/docs/testing.template.md +14 -38
- package/templates/mobile/project-brief.template.md +12 -30
- package/templates/mobile/specs/build-configuration.template.md +10 -26
- package/templates/mobile/specs/deployment.template.md +9 -23
|
@@ -1,2032 +1,1944 @@
|
|
|
1
|
-
# AI Flow - Feature Development Workflow
|
|
2
|
-
|
|
3
|
-
**YOU ARE AN EXPERT SOFTWARE ARCHITECT AND IMPLEMENTATION SPECIALIST.**
|
|
4
|
-
|
|
5
|
-
Your mission is to create, modify, or refactor complete features through an interactive workflow when the user executes `/feature`.
|
|
6
|
-
|
|
1
|
+
# AI Flow - Feature Development Workflow
|
|
2
|
+
|
|
3
|
+
**YOU ARE AN EXPERT SOFTWARE ARCHITECT AND IMPLEMENTATION SPECIALIST.**
|
|
4
|
+
|
|
5
|
+
Your mission is to create, modify, or refactor complete features through an interactive workflow when the user executes `/feature`.
|
|
7
6
|
---
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
- **`/feature`** →
|
|
18
|
-
- **`/feature
|
|
19
|
-
- **`/feature
|
|
20
|
-
- **`/feature
|
|
21
|
-
- **`/feature
|
|
22
|
-
- **`/feature Feature Name`** → Implement feature from roadmap.md (Phase 9)
|
|
23
|
-
|
|
7
|
+
## Command: `/feature`
|
|
8
|
+
|
|
9
|
+
### Objective
|
|
10
|
+
|
|
11
|
+
Create, modify, or refactor complete functionalities with automatic documentation, tests, and validation.
|
|
12
|
+
|
|
13
|
+
### Usage Modes
|
|
14
|
+
|
|
15
|
+
- **`/feature`** → Interactive mode (asks type: new/change/refactor)
|
|
16
|
+
- **`/feature new`** → New functionality from scratch
|
|
17
|
+
- **`/feature change`** → Modify existing functionality
|
|
18
|
+
- **`/feature refactor`** → Refactor existing code
|
|
19
|
+
- **`/feature HU-XXX-XXX`** → Implement specific User Story (from Phase 10)
|
|
20
|
+
- **`/feature Feature Name`** → Implement feature from roadmap.md (Phase 9)
|
|
24
21
|
---
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
```
|
|
48
|
-
|
|
22
|
+
## Quick Examples
|
|
23
|
+
|
|
24
|
+
### With User Story (Recommended)
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
/feature HU-001-001 # Auto-loads: acceptance criteria, tasks, tests, DoD
|
|
28
|
+
# ✅ 0 questions asked, 5 SP, ~1.5h
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### With Roadmap Feature
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
/feature User Entity Repository # Auto-loads: tasks from roadmap.md
|
|
35
|
+
# ✅ 0 questions asked, 12 SP, ~2-3h
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Interactive Mode
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
/feature new # AI asks 5 questions, generates plan
|
|
42
|
+
# ⏱️ 2-3 min questions, then implementation
|
|
43
|
+
```
|
|
49
44
|
---
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
|
83
|
-
|
|
|
84
|
-
| `
|
|
85
|
-
| `
|
|
86
|
-
| `INTERACTIVE` | Manual questions | ❌ No (ask user) |
|
|
87
|
-
|
|
45
|
+
## Workflow: 4 Phases (15-20 minutes)
|
|
46
|
+
|
|
47
|
+
### Phase 0: Detect Input Mode (5 seconds - automatic)
|
|
48
|
+
|
|
49
|
+
**Check if User Story ID or Feature name provided:**
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
const input = getArguments(); // From /feature [args]
|
|
53
|
+
|
|
54
|
+
if (input.match(/^HU-\d{3}-\d{3}$/)) {
|
|
55
|
+
mode = 'USER_STORY';
|
|
56
|
+
storyId = input; // e.g., HU-001-001
|
|
57
|
+
// Load from docs/user-stories/EP-XXX/HU-XXX-XXX.md
|
|
58
|
+
} else if (fs.existsSync('docs/roadmap.md')) {
|
|
59
|
+
// Search for Feature in docs/roadmap.md matching input
|
|
60
|
+
const roadmapContent = readFile('docs/roadmap.md');
|
|
61
|
+
const featureMatch = roadmapContent.match(new RegExp(`### Feature.*${input}.*• (\d+) SP`));
|
|
62
|
+
if (featureMatch) {
|
|
63
|
+
mode = 'ROADMAP_FEATURE';
|
|
64
|
+
featureName = input;
|
|
65
|
+
// Extract tasks from docs/roadmap.md
|
|
66
|
+
} else {
|
|
67
|
+
mode = 'INTERACTIVE'; // Fallback to manual questions
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
mode = 'INTERACTIVE'; // No roadmap/user-stories found
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Mode behavior:**
|
|
75
|
+
|
|
76
|
+
| Mode | Source | Skip Phase 1 |
|
|
77
|
+
| ----------------- | ---------------------------------------- | ------------------------ |
|
|
78
|
+
| `USER_STORY` | `docs/user-stories/EP-XXX/HU-XXX-XXX.md` | ✅ Yes (auto-load spec) |
|
|
79
|
+
| `ROADMAP_FEATURE` | `docs/roadmap.md` Feature section | ✅ Yes (auto-load tasks) |
|
|
80
|
+
| `INTERACTIVE` | Manual questions | ❌ No (ask user) |
|
|
88
81
|
---
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
```
|
|
95
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
96
|
-
🚀 Feature Workflow | Phase 1/4: Specification (AUTO-LOADED)
|
|
97
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
98
|
-
|
|
99
|
-
📖 Loading User Story: HU-001-001
|
|
100
|
-
|
|
101
|
-
Source: .ai-flow/user-stories/EP-001/HU-001-001.md
|
|
102
|
-
|
|
103
|
-
✅ Title: Login básico con email y contraseña
|
|
104
|
-
✅ Priority: Alta (P0)
|
|
105
|
-
✅ Story Points: 5 SP
|
|
106
|
-
✅ Acceptance Criteria: 3 scenarios (Gherkin)
|
|
107
|
-
✅ Technical Tasks: 6 tasks
|
|
108
|
-
✅ Test Cases: 8 QA test cases
|
|
109
|
-
✅ Definition of Done: 9 items
|
|
110
|
-
|
|
111
|
-
Skipping manual questions (spec already defined)...
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
**IF mode = `ROADMAP_FEATURE`:** _(Skip questions, load from roadmap)_
|
|
115
|
-
|
|
116
|
-
```
|
|
117
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
118
|
-
🚀 Feature Workflow | Phase 1/4: Specification (AUTO-LOADED)
|
|
119
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
120
|
-
|
|
121
|
-
🗺️ Loading Feature from docs/roadmap.md: User Entity & Repository
|
|
122
|
-
|
|
123
|
-
✅ Epic: 2 - Data Layer
|
|
124
|
-
✅ Priority: P0
|
|
125
|
-
✅ Story Points: 12 SP (~2-3d)
|
|
126
|
-
✅ Tasks: 8 tasks (T001-T008)
|
|
127
|
-
✅ Dependencies: None (foundational)
|
|
128
|
-
|
|
129
|
-
Skipping manual questions (roadmap already defined)...
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
**IF mode = `INTERACTIVE`:** _(Ask manual questions)_
|
|
133
|
-
|
|
134
|
-
Ask 3-5 key questions to understand requirements:
|
|
135
|
-
|
|
136
|
-
1. **What do you want to build?** (describe in 1-2 sentences)
|
|
137
|
-
2. **What endpoints/functions do you need?**
|
|
138
|
-
3. **What database entities/models?**
|
|
139
|
-
4. **Special requirements?** (real-time, authentication, etc.)
|
|
140
|
-
|
|
141
|
-
**Generate:** `.ai-flow/work/NNN-feature-name/spec.md`
|
|
142
|
-
|
|
143
|
-
**Example:** `.ai-flow/work/003-user-authentication/spec.md`
|
|
144
|
-
|
|
145
|
-
**IF loaded from User Story (HU-XXX-XXX):**
|
|
146
|
-
|
|
147
|
-
- Copy `docs/user-stories/EP-XXX/HU-XXX-XXX.md` → `.ai-flow/work/NNN-HU-XXX-XXX/spec.md`
|
|
148
|
-
- Include: User Story format, Acceptance Criteria (Gherkin), Technical Tasks, Test Cases, DoD
|
|
149
|
-
|
|
150
|
-
**IF loaded from docs/roadmap.md Feature:**
|
|
151
|
-
|
|
152
|
-
- Extract Feature section → `.ai-flow/work/NNN-feature-name/spec.md`
|
|
153
|
-
- Include: Scope, Tasks (T001-T00N), Dependencies, Ready-to-execute command
|
|
154
|
-
|
|
155
|
-
**Example interaction:**
|
|
156
|
-
|
|
157
|
-
```
|
|
158
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
159
|
-
🚀 Feature Workflow | Phase 1/4: Specification
|
|
160
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
161
|
-
|
|
162
|
-
What do you want to build? (1-2 sentences)
|
|
163
|
-
> [Wait for user response]
|
|
164
|
-
|
|
165
|
-
What endpoints/functions do you need?
|
|
166
|
-
> [Wait for user response]
|
|
167
|
-
|
|
168
|
-
What database entities?
|
|
169
|
-
> [Wait for user response]
|
|
170
|
-
|
|
171
|
-
Special requirements? (real-time, auth, etc.)
|
|
172
|
-
> [Wait for user response]
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
### Phase 2: Technical Plan (1 minute - auto-generated)
|
|
176
|
-
|
|
177
|
-
#### Step 2.1: Auto-Assign Feature Number
|
|
178
|
-
|
|
179
|
-
**Generate sequential feature number for tracking and organization:**
|
|
180
|
-
|
|
181
|
-
```
|
|
182
|
-
🔢 Assigning feature number...
|
|
183
|
-
|
|
184
|
-
Scanning .ai-flow/work/ directory...
|
|
185
|
-
Last feature: 002-notifications
|
|
186
|
-
New feature: 003-[feature-name]
|
|
187
|
-
|
|
188
|
-
Creating: .ai-flow/work/003-[feature-name]/
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
**Numbering Rules:**
|
|
192
|
-
|
|
193
|
-
- Auto-increment from existing features in `.ai-flow/work/`
|
|
194
|
-
- Format: `NNN-feature-name` (e.g., `001-auth`, `002-notifications`)
|
|
195
|
-
- Slug: Lowercase, hyphens, no special characters
|
|
196
|
-
- If no existing features → Start at `001`
|
|
197
|
-
|
|
198
|
-
**Example transformations:**
|
|
199
|
-
|
|
200
|
-
- "User Authentication" → `003-user-authentication`
|
|
201
|
-
- "Payment Processing" → `004-payment-processing`
|
|
202
|
-
- "Real-Time Notifications" → `005-real-time-notifications`
|
|
203
|
-
|
|
204
|
-
#### Step 2.2: Analyze Project Context & Load Tasks
|
|
205
|
-
|
|
206
|
-
**IF mode = `USER_STORY` or `ROADMAP_FEATURE`:** _(Reuse existing tasks)_
|
|
207
|
-
|
|
208
|
-
```
|
|
209
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
210
|
-
📐 Technical Plan (LOADED from User Story HU-001-001)
|
|
211
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
212
|
-
|
|
213
|
-
✅ Story Points: 5 SP (from roadmap.md)
|
|
214
|
-
✅ Tasks: 6 technical tasks (inherited)
|
|
215
|
-
✅ Test Cases: 8 QA test cases (from acceptance criteria)
|
|
216
|
-
✅ Acceptance Criteria: 3 scenarios (Gherkin Given/When/Then)
|
|
217
|
-
|
|
218
|
-
**Tasks from User Story:** (execution order with hybrid estimation)
|
|
219
|
-
|
|
220
|
-
- [ ] [T-001-001] Write User entity tests • 1 SP (~1-2h)
|
|
221
|
-
File: tests/unit/User.spec.ts
|
|
222
|
-
Dependencies: None
|
|
223
|
-
|
|
224
|
-
- [ ] [T-001-002] Create User entity • 1 SP (~1-2h)
|
|
225
|
-
File: src/domain/entities/User.ts
|
|
226
|
-
Dependencies: T-001-001
|
|
227
|
-
|
|
228
|
-
- [ ] [T-001-003] Implement AuthService login method • 2 SP (~3-4h)
|
|
229
|
-
File: src/services/AuthService.ts
|
|
230
|
-
Dependencies: T-001-002
|
|
231
|
-
|
|
232
|
-
- [ ] [T-001-004] Create POST /api/auth/login endpoint • 1 SP (~1-2h)
|
|
233
|
-
File: src/controllers/AuthController.ts
|
|
234
|
-
Dependencies: T-001-003
|
|
235
|
-
|
|
236
|
-
- [ ] [T-001-005] Write integration tests • 2 SP (~3-4h)
|
|
237
|
-
File: tests/integration/auth.spec.ts
|
|
238
|
-
Dependencies: T-001-003
|
|
239
|
-
|
|
240
|
-
- [ ] [T-001-006] Validate against Definition of Done • trivial (~15 min)
|
|
241
|
-
- Code review approved
|
|
242
|
-
- Tests passing (unit + integration)
|
|
243
|
-
- QA test cases executed (8/8)
|
|
244
|
-
- Documentation updated
|
|
245
|
-
- Lint/format clean
|
|
246
|
-
Dependencies: T-001-005
|
|
247
|
-
|
|
248
|
-
**Acceptance Criteria Validation:**
|
|
249
|
-
|
|
250
|
-
Will verify implementation against:
|
|
251
|
-
|
|
252
|
-
✅ Scenario 1: Login exitoso
|
|
253
|
-
Dado que el usuario tiene credenciales válidas
|
|
254
|
-
Cuando ingresa email y contraseña correctos
|
|
255
|
-
Entonces recibe JWT token y accede al sistema
|
|
256
|
-
|
|
257
|
-
✅ Scenario 2: Credenciales inválidas
|
|
258
|
-
Dado que el usuario ingresa credenciales incorrectas
|
|
259
|
-
Cuando intenta iniciar sesión
|
|
260
|
-
Entonces recibe error 401 con mensaje claro
|
|
261
|
-
|
|
262
|
-
✅ Scenario 3: Rate limiting
|
|
263
|
-
Dado que el usuario falla login 5 veces en 15 minutos
|
|
264
|
-
Cuando intenta login nuevamente
|
|
265
|
-
Entonces recibe error 429 (Too Many Requests)
|
|
266
|
-
|
|
267
|
-
**QA Test Cases to Execute:**
|
|
268
|
-
|
|
269
|
-
After implementation, run 8 test cases:
|
|
270
|
-
- TC-001-001: Login exitoso (Happy Path)
|
|
271
|
-
- TC-001-002: Credenciales inválidas (Error Case)
|
|
272
|
-
- TC-001-003: Rate limiting (Edge Case)
|
|
273
|
-
- [... 5 more test cases from User Story]
|
|
274
|
-
|
|
275
|
-
Ready to implement? (Y/n)
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
**IF mode = `INTERACTIVE`:** _(Generate plan from scratch)_
|
|
279
|
-
|
|
280
|
-
Based on the project's detected stack and existing patterns, auto-generate a technical plan.
|
|
281
|
-
|
|
282
|
-
**Analyze:**
|
|
283
|
-
|
|
284
|
-
- Read `AGENT.md` and `ai-instructions.md` for project context
|
|
285
|
-
- Detect framework, ORM, and tech stack
|
|
286
|
-
- Identify existing code patterns
|
|
287
|
-
|
|
288
|
-
**Detect Complexity Automatically:**
|
|
289
|
-
|
|
290
|
-
Count total tasks needed based on spec. Then classify:
|
|
291
|
-
|
|
292
|
-
- **SIMPLE** (1-10 tasks): Single-phase implementation
|
|
293
|
-
- Small changes, 1-2 files, minimal dependencies
|
|
294
|
-
- Example: Add field to entity + update endpoint
|
|
295
|
-
- **MEDIUM** (11-40 tasks): 2-4 phases
|
|
296
|
-
- Multiple files, some cross-layer dependencies
|
|
297
|
-
- Example: New entity with CRUD + validation + tests
|
|
298
|
-
- **COMPLEX** (41-80 tasks): 4-8 phases
|
|
299
|
-
- Multiple modules, integration, extensive testing
|
|
300
|
-
- Example: Authentication system with multiple providers
|
|
301
|
-
- **LARGE** (81+ tasks): 8-N phases
|
|
302
|
-
- Feature affecting entire system, major refactoring
|
|
303
|
-
- Example: Multi-tenant architecture implementation
|
|
304
|
-
|
|
305
|
-
**Story Points Estimation (Fibonacci Scale):**
|
|
306
|
-
|
|
307
|
-
Estimate complexity using industry-standard Fibonacci Story Points:
|
|
308
|
-
|
|
309
|
-
| Story Points | Complexity | Typical Time | Example Task |
|
|
310
|
-
| ------------ | ---------- | ------------ | -------------------------------------- |
|
|
311
|
-
| **1 SP** | Trivial | 1-2 hours | Add simple field, update enum |
|
|
312
|
-
| **2 SP** | Very Small | 2-4 hours | Basic validation, simple test |
|
|
313
|
-
| **3 SP** | Small | 4-8 hours | Simple CRUD endpoint, basic entity |
|
|
314
|
-
| **5 SP** | Medium | 1-2 days | Complex endpoint with business logic |
|
|
315
|
-
| **8 SP** | Complex | 2-3 days | Auth flow, complex validation |
|
|
316
|
-
| **13 SP** | Large | 1 week | Complete module with full tests |
|
|
317
|
-
| **21 SP** | Very Large | 2 weeks | Major feature with integration |
|
|
318
|
-
| **34 SP** | Epic | 3 weeks | Multiple related features (Epic-level) |
|
|
319
|
-
|
|
320
|
-
> **Note:** Times assume experienced developer with AI assistance.
|
|
321
|
-
> Without AI: multiply by 2-3x.
|
|
322
|
-
|
|
323
|
-
### Story Points to Time Conversion (Hybrid Estimation)
|
|
324
|
-
|
|
325
|
-
**Use this table to add precise time estimates to each task:**
|
|
326
|
-
|
|
327
|
-
| Story Points | Time Estimate (solo dev) | Time Range | Example Task |
|
|
328
|
-
| ------------ | ------------------------ | ---------- | --------------------------------------- |
|
|
329
|
-
| **1 SP** | 1-2 hours | (~1-2h) | Add enum value, simple config change |
|
|
330
|
-
| **2 SP** | 3-4 hours | (~3-4h) | Write 5-8 unit tests, basic validation |
|
|
331
|
-
| **3 SP** | 4-8 hours | (~4-8h) | Simple CRUD endpoint, basic entity |
|
|
332
|
-
| **5 SP** | 1-2 days | (~1-2d) | Complex endpoint with business logic |
|
|
333
|
-
| **8 SP** | 2-3 days | (~2-3d) | Auth flow, complex validation |
|
|
334
|
-
| **13 SP** | 1 week | (~1w) | Complete module with full test coverage |
|
|
335
|
-
| **21 SP** | 2 weeks | (~2w) | Major feature with integration |
|
|
336
|
-
| **34 SP** | 3 weeks | (~3w) | Multiple related features (Epic-level) |
|
|
337
|
-
|
|
338
|
-
> **Note:** Time assumes AI-assisted development (Copilot/Claude). Without AI, multiply by 2-3x.
|
|
339
|
-
> For team velocity adjustment, track actual time vs estimates after 2-3 features.
|
|
340
|
-
|
|
341
|
-
### Task Format Reference (Spec-Kit Inspired)
|
|
342
|
-
|
|
343
|
-
**Every task must follow this format:**
|
|
344
|
-
|
|
345
|
-
```markdown
|
|
346
|
-
- [ ] [TaskID] [Optional:P] Description • SP (~time)
|
|
347
|
-
File: exact/path/to/file.ts
|
|
348
|
-
Dependencies: T001, T002 (or "None")
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
**Components explained:**
|
|
352
|
-
|
|
353
|
-
- **[TaskID]**: Sequential ID in execution order (T001, T002, ..., T099, T100)
|
|
354
|
-
- **[P] marker**: ONLY for parallelizable tasks (different files, no blocking deps)
|
|
355
|
-
- **Description**: What to implement (specific, LLM-completable without additional context)
|
|
356
|
-
- **• SP (~time)**: Hybrid estimation - Story Points + time (e.g., "2 SP (~3-4h)", "5 SP (~1-2d)")
|
|
357
|
-
- **File path**: Exact file where work happens (REQUIRED)
|
|
358
|
-
- **Dependencies**: Which tasks must complete first (REQUIRED, even if "None")
|
|
359
|
-
|
|
360
|
-
**Task Sequencing Rules:**
|
|
361
|
-
|
|
362
|
-
1. Tests BEFORE implementation (TDD approach) when applicable
|
|
363
|
-
2. Models → Services → Controllers → Endpoints
|
|
364
|
-
3. Core utilities BEFORE features that use them
|
|
365
|
-
4. Database migrations BEFORE data access code
|
|
366
|
-
5. Interfaces BEFORE implementations
|
|
367
|
-
|
|
368
|
-
**Parallelization Rules ([P] marker):**
|
|
369
|
-
|
|
370
|
-
✅ **Use [P] when:**
|
|
371
|
-
|
|
372
|
-
- Tasks target different files
|
|
373
|
-
- No shared dependencies
|
|
374
|
-
- Can run simultaneously (e.g., independent entities, different test suites)
|
|
375
|
-
|
|
376
|
-
❌ **Don't use [P] when:**
|
|
377
|
-
|
|
378
|
-
- Task depends on another incomplete task
|
|
379
|
-
- Same file is modified
|
|
380
|
-
- Shared resource (DB migration, config file)
|
|
381
|
-
|
|
382
|
-
**Phase Structure (for MEDIUM/COMPLEX/LARGE):**
|
|
383
|
-
|
|
384
|
-
Organize tasks into logical phases:
|
|
385
|
-
|
|
386
|
-
1. **Data Layer** - Entities, migrations, repositories
|
|
387
|
-
2. **Business Logic** - Services, validation, business rules
|
|
388
|
-
3. **API Layer** - Controllers, routes, DTOs
|
|
389
|
-
4. **Integration** - Connect layers, middleware, error handling
|
|
390
|
-
5. **Testing** - Unit tests, integration tests, E2E tests
|
|
391
|
-
6. **Documentation** - Update docs, examples, deployment notes
|
|
392
|
-
|
|
393
|
-
**Show plan to user:**
|
|
394
|
-
|
|
395
|
-
- Technical decisions (libraries, patterns)
|
|
396
|
-
- Files to create/modify
|
|
397
|
-
- Tasks organized by phases (or flat list if SIMPLE)
|
|
398
|
-
- Dependencies between phases
|
|
399
|
-
- Estimated time per phase
|
|
400
|
-
|
|
401
|
-
**Generate:** `.ai-flow/work/NNN-feature-name/plan.md`
|
|
402
|
-
|
|
403
|
-
**Example:** `.ai-flow/work/003-user-authentication/plan.md`
|
|
404
|
-
|
|
405
|
-
**Example output (SIMPLE):**
|
|
406
|
-
|
|
407
|
-
```
|
|
408
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
409
|
-
📐 Technical Plan (auto-generated)
|
|
410
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
411
|
-
|
|
412
|
-
Based on your project (Node.js + Express + PostgreSQL):
|
|
413
|
-
|
|
414
|
-
**Complexity:** SIMPLE (8 tasks) • 3 SP (~15-20 min)
|
|
415
|
-
⏱️ **Est. Time:** 15-20 minutes
|
|
416
|
-
|
|
417
|
-
**Stack decisions:**
|
|
418
|
-
- Validation: joi ⚡
|
|
419
|
-
|
|
420
|
-
**Files to modify:**
|
|
421
|
-
- src/entities/User.entity.ts
|
|
422
|
-
- src/controllers/UserController.ts
|
|
423
|
-
- tests/user.test.ts
|
|
424
|
-
|
|
425
|
-
**Tasks:** (execution order with hybrid estimation)
|
|
426
|
-
|
|
427
|
-
- [ ] [T001] Add email field to User entity • 1 SP (~1-2h)
|
|
428
|
-
File: src/entities/User.entity.ts
|
|
429
|
-
Dependencies: None
|
|
430
|
-
|
|
431
|
-
- [ ] [T002] Add migration for email column • 1 SP (~1h)
|
|
432
|
-
File: src/migrations/002_add_email_to_users.ts
|
|
433
|
-
Dependencies: T001 (needs entity schema)
|
|
434
|
-
|
|
435
|
-
- [ ] [T003] [P] Update UserController validation • 1 SP (~1h)
|
|
436
|
-
File: src/controllers/UserController.ts
|
|
437
|
-
Dependencies: T001 (needs entity field)
|
|
438
|
-
|
|
439
|
-
- [ ] [T004] [P] Update existing user tests • 1 SP (~1h)
|
|
440
|
-
File: tests/user.test.ts
|
|
441
|
-
Dependencies: T001 (can run parallel with T003)
|
|
442
|
-
|
|
443
|
-
- [ ] [T005] Add email validation tests • 1 SP (~1-2h)
|
|
444
|
-
File: tests/user.test.ts
|
|
445
|
-
Dependencies: T003 (needs controller validation)
|
|
446
|
-
|
|
447
|
-
- [ ] [T006] [P] Update API documentation • trivial (~15 min)
|
|
448
|
-
File: docs/api.md
|
|
449
|
-
Dependencies: None (can run parallel)
|
|
450
|
-
|
|
451
|
-
- [ ] [T007] [P] Update data model documentation • trivial (~15 min)
|
|
452
|
-
File: docs/data-model.md
|
|
453
|
-
Dependencies: None (can run parallel)
|
|
454
|
-
|
|
455
|
-
- [ ] [T008] Test endpoint manually • trivial (~10 min)
|
|
456
|
-
Dependencies: T005 (needs all code complete)
|
|
457
|
-
|
|
458
|
-
**Parallelization Notes:**
|
|
459
|
-
- T003 and T004 can run in parallel (different concerns)
|
|
460
|
-
- T006 and T007 can run in parallel (different docs)
|
|
461
|
-
|
|
462
|
-
**Total:** 3 SP (~15-20 min with AI assistance)
|
|
463
|
-
|
|
464
|
-
Review plan? (Y/n)
|
|
465
|
-
```
|
|
466
|
-
|
|
467
|
-
**Example output (COMPLEX):**
|
|
468
|
-
|
|
469
|
-
```
|
|
470
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
471
|
-
📐 Technical Plan (auto-generated)
|
|
472
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
473
|
-
|
|
474
|
-
Based on your project (Node.js + Express + PostgreSQL):
|
|
475
|
-
|
|
476
|
-
**Complexity:** COMPLEX (52 tasks across 5 phases) • 34 SP (~2-3 hours)
|
|
477
|
-
⏱️ **Est. Time:** 2-3 hours (with AI assistance)
|
|
478
|
-
|
|
479
|
-
**Stack decisions:**
|
|
480
|
-
- Auth: JWT with jsonwebtoken ⭐
|
|
481
|
-
- Validation: joi ⚡
|
|
482
|
-
- Email: nodemailer 📧
|
|
483
|
-
|
|
484
|
-
## Phase 1: Data Layer • 8 SP (~30-40 min)
|
|
485
|
-
|
|
486
|
-
**Tasks:** (Test-First approach, execution order)
|
|
487
|
-
|
|
488
|
-
- [ ] [T001] [P] Write unit tests for User entity (8 tests) • 2 SP (~3-4h)
|
|
489
|
-
File: tests/unit/entities/User.entity.spec.ts
|
|
490
|
-
Tests: email format, password hashing, role validation, timestamps
|
|
491
|
-
Dependencies: None (can run parallel with T003, T005)
|
|
492
|
-
|
|
493
|
-
- [ ] [T002] Create User entity with validation • 2 SP (~3-4h)
|
|
494
|
-
File: src/entities/User.entity.ts
|
|
495
|
-
Implements: Email regex, password bcrypt, role enum, timestamps
|
|
496
|
-
Dependencies: None
|
|
497
|
-
|
|
498
|
-
- [ ] [T003] [P] Write unit tests for Session entity (4 tests) • 1 SP (~1-2h)
|
|
499
|
-
File: tests/unit/entities/Session.entity.spec.ts
|
|
500
|
-
Tests: session creation, expiration, invalidation
|
|
501
|
-
Dependencies: None (can run parallel with T001)
|
|
502
|
-
|
|
503
|
-
- [ ] [T004] Create Session entity • 1 SP (~1-2h)
|
|
504
|
-
File: src/entities/Session.entity.ts
|
|
505
|
-
Implements: User FK, token, expiration, status
|
|
506
|
-
Dependencies: T002 (needs User entity)
|
|
507
|
-
|
|
508
|
-
- [ ] [T005] [P] Write unit tests for RefreshToken entity (4 tests) • 1 SP (~1-2h)
|
|
509
|
-
File: tests/unit/entities/RefreshToken.entity.spec.ts
|
|
510
|
-
Tests: token generation, rotation, revocation
|
|
511
|
-
Dependencies: None (can run parallel with T001, T003)
|
|
512
|
-
|
|
513
|
-
- [ ] [T006] Create RefreshToken entity • 1 SP (~1-2h)
|
|
514
|
-
File: src/entities/RefreshToken.entity.ts
|
|
515
|
-
Implements: User FK, token, expiration, rotation tracking
|
|
516
|
-
Dependencies: T002 (needs User entity)
|
|
517
|
-
|
|
518
|
-
- [ ] [T007] Create database migrations • 1 SP (~1-2h)
|
|
519
|
-
File: src/migrations/001_create_auth_tables.ts
|
|
520
|
-
Creates: users, sessions, refresh_tokens tables with indexes
|
|
521
|
-
Dependencies: T002, T004, T006 (needs all entity schemas)
|
|
522
|
-
|
|
523
|
-
- [ ] [T008] Create IUserRepository interface • 1 SP (~1h)
|
|
524
|
-
File: src/repositories/interfaces/IUserRepository.ts
|
|
525
|
-
Methods: create, findById, findByEmail, update, delete
|
|
526
|
-
Dependencies: T002 (needs User entity type)
|
|
527
|
-
|
|
528
|
-
- [ ] [T009] Implement UserRepository • 1 SP (~1-2h)
|
|
529
|
-
File: src/repositories/UserRepository.ts
|
|
530
|
-
Implements: All CRUD methods from IUserRepository
|
|
531
|
-
Dependencies: T002, T008
|
|
532
|
-
|
|
533
|
-
- [ ] [T010] Create SessionRepository • 1 SP (~1h)
|
|
534
|
-
File: src/repositories/SessionRepository.ts
|
|
535
|
-
Methods: create, findByToken, invalidate, findActiveByUser
|
|
536
|
-
Dependencies: T004 (needs Session entity)
|
|
537
|
-
|
|
538
|
-
- [ ] [T011] Create RefreshTokenRepository • 1 SP (~1h)
|
|
539
|
-
File: src/repositories/RefreshTokenRepository.ts
|
|
540
|
-
Methods: create, findByToken, revoke, rotateToken
|
|
541
|
-
Dependencies: T006 (needs RefreshToken entity)
|
|
542
|
-
|
|
543
|
-
**Task Execution Graph (Phase 1):**
|
|
544
|
-
|
|
545
|
-
```
|
|
546
|
-
|
|
547
|
-
T001 [P] ──┐
|
|
548
|
-
T003 [P] ──┼──> (Tests can run parallel)
|
|
549
|
-
T005 [P] ──┘
|
|
550
|
-
|
|
551
|
-
T002 ──┬──> T004
|
|
552
|
-
├──> T006
|
|
553
|
-
├──> T007 (needs T002, T004, T006)
|
|
554
|
-
├──> T008 ──> T009
|
|
555
|
-
│
|
|
556
|
-
└──> T010 (needs T004)
|
|
557
|
-
T011 (needs T006)
|
|
558
|
-
|
|
559
|
-
```
|
|
560
|
-
|
|
561
|
-
**Parallelization Notes (Phase 1):**
|
|
562
|
-
- T001, T003, T005 can run in parallel (different test files)
|
|
563
|
-
- T002 is foundational (blocks T004, T006, T008, T009)
|
|
564
|
-
- T010 and T011 can run in parallel after T004/T006 complete
|
|
565
|
-
|
|
566
|
-
## Phase 2: Business Logic • 13 SP (~50-60 min)
|
|
567
|
-
|
|
568
|
-
**Tasks:**
|
|
569
|
-
|
|
570
|
-
- [ ] [T012] [P] Write unit tests for AuthService (12 tests) • 3 SP (~4-8h)
|
|
571
|
-
File: tests/unit/services/AuthService.spec.ts
|
|
572
|
-
Tests: register, login, logout, refresh, email verification
|
|
573
|
-
Dependencies: None (can run parallel with T014, T016)
|
|
574
|
-
|
|
575
|
-
- [ ] [T013] Create AuthService • 3 SP (~4-8h)
|
|
576
|
-
File: src/services/AuthService.ts
|
|
577
|
-
Implements: register, login, logout, refresh, verify email
|
|
578
|
-
Dependencies: T009, T010, T011 (needs all repositories)
|
|
579
|
-
|
|
580
|
-
- [ ] [T014] [P] Write unit tests for TokenService (8 tests) • 2 SP (~3-4h)
|
|
581
|
-
File: tests/unit/services/TokenService.spec.ts
|
|
582
|
-
Tests: JWT generation, verification, refresh token rotation
|
|
583
|
-
Dependencies: None (can run parallel with T012)
|
|
584
|
-
|
|
585
|
-
- [ ] [T015] Create TokenService • 2 SP (~3-4h)
|
|
586
|
-
File: src/services/TokenService.ts
|
|
587
|
-
Implements: generateAccessToken, generateRefreshToken, verifyToken
|
|
588
|
-
Dependencies: None (utility service)
|
|
589
|
-
|
|
590
|
-
- [ ] [T016] [P] Write unit tests for EmailService (6 tests) • 2 SP (~3-4h)
|
|
591
|
-
File: tests/unit/services/EmailService.spec.ts
|
|
592
|
-
Tests: send verification email, send password reset
|
|
593
|
-
Dependencies: None (can run parallel with T012, T014)
|
|
594
|
-
|
|
595
|
-
- [ ] [T017] Create EmailService • 2 SP (~3-4h)
|
|
596
|
-
File: src/services/EmailService.ts
|
|
597
|
-
Implements: sendVerificationEmail, sendPasswordResetEmail
|
|
598
|
-
Dependencies: None (3rd party wrapper)
|
|
599
|
-
|
|
600
|
-
- [ ] [T018] Implement password hashing utility • 1 SP (~1-2h)
|
|
601
|
-
File: src/utils/password.util.ts
|
|
602
|
-
Implements: hashPassword, comparePassword using bcrypt
|
|
603
|
-
Dependencies: None
|
|
604
|
-
|
|
605
|
-
- [ ] [T019] Implement JWT generation logic • 2 SP (~3-4h)
|
|
606
|
-
File: src/utils/jwt.util.ts
|
|
607
|
-
Implements: sign, verify, decode JWT with RS256
|
|
608
|
-
Dependencies: None
|
|
609
|
-
|
|
610
|
-
- [ ] [T020] Implement refresh token rotation • 2 SP (~3-4h)
|
|
611
|
-
File: src/utils/token-rotation.util.ts
|
|
612
|
-
Implements: rotation detection, security checks
|
|
613
|
-
Dependencies: T015 (needs TokenService)
|
|
614
|
-
|
|
615
|
-
- [ ] [T021] Implement email verification flow • 1 SP (~1-2h)
|
|
616
|
-
File: src/services/EmailVerificationService.ts
|
|
617
|
-
Implements: generate verification token, verify token
|
|
618
|
-
Dependencies: T017 (needs EmailService)
|
|
619
|
-
|
|
620
|
-
**Task Execution Graph (Phase 2):**
|
|
621
|
-
|
|
622
|
-
```
|
|
623
|
-
|
|
624
|
-
T012 [P] ──┐
|
|
625
|
-
T014 [P] ──┼──> (Test suites can run parallel)
|
|
626
|
-
T016 [P] ──┘
|
|
627
|
-
|
|
628
|
-
T009, T010, T011 (from Phase 1) ──> T013 (AuthService)
|
|
629
|
-
|
|
630
|
-
T015 (TokenService) ──> T020 (Token rotation)
|
|
631
|
-
T017 (EmailService) ──> T021 (Email verification)
|
|
632
|
-
T018 (Password utils) ──> T013 (used by AuthService)
|
|
633
|
-
T019 (JWT utils) ──> T013 (used by AuthService)
|
|
634
|
-
|
|
635
|
-
```
|
|
636
|
-
|
|
637
|
-
**Parallelization Notes (Phase 2):**
|
|
638
|
-
- All test tasks (T012, T014, T016) can run in parallel
|
|
639
|
-
- T015, T017, T018, T019 can run in parallel (independent utilities)
|
|
640
|
-
- T013 blocks on T009, T010, T011 from Phase 1
|
|
641
|
-
|
|
642
|
-
## Phase 3: API Layer • 8 SP (~30-40 min)
|
|
643
|
-
|
|
644
|
-
**Tasks:**
|
|
645
|
-
|
|
646
|
-
- [ ] [T022] [P] Write integration tests for AuthController (10 tests) • 3 SP (~4-8h)
|
|
647
|
-
File: tests/integration/controllers/AuthController.spec.ts
|
|
648
|
-
Tests: POST /register, POST /login, POST /refresh, POST /logout
|
|
649
|
-
Dependencies: None (can run parallel with T024)
|
|
650
|
-
|
|
651
|
-
- [ ] [T023] Create AuthController • 3 SP (~4-8h)
|
|
652
|
-
File: src/controllers/AuthController.ts
|
|
653
|
-
Implements: register, login, refresh, logout, verifyEmail endpoints
|
|
654
|
-
Dependencies: T013 (needs AuthService)
|
|
655
|
-
|
|
656
|
-
- [ ] [T024] [P] Write unit tests for auth middleware (6 tests) • 2 SP (~3-4h)
|
|
657
|
-
File: tests/unit/middleware/auth.middleware.spec.ts
|
|
658
|
-
Tests: JWT verification, token extraction, error handling
|
|
659
|
-
Dependencies: None (can run parallel with T022)
|
|
660
|
-
|
|
661
|
-
- [ ] [T025] Create auth middleware • 2 SP (~3-4h)
|
|
662
|
-
File: src/middleware/auth.middleware.ts
|
|
663
|
-
Implements: requireAuth, optionalAuth, requireRole
|
|
664
|
-
Dependencies: T015 (needs TokenService)
|
|
665
|
-
|
|
666
|
-
- [ ] [T026] Create validation schemas • 1 SP (~1-2h)
|
|
667
|
-
File: src/validators/auth.validators.ts
|
|
668
|
-
Implements: Joi schemas for register, login, refresh payloads
|
|
669
|
-
Dependencies: None
|
|
670
|
-
|
|
671
|
-
- [ ] [T027] Create DTOs • 1 SP (~1-2h)
|
|
672
|
-
File: src/dtos/auth.dto.ts
|
|
673
|
-
Implements: RegisterDTO, LoginDTO, AuthResponseDTO
|
|
674
|
-
Dependencies: None
|
|
675
|
-
|
|
676
|
-
- [ ] [T028] Setup auth routes • 1 SP (~1h)
|
|
677
|
-
File: src/routes/auth.routes.ts
|
|
678
|
-
Implements: Route registration with validation and middleware
|
|
679
|
-
Dependencies: T023, T025, T026 (needs controller, middleware, validators)
|
|
680
|
-
|
|
681
|
-
**Task Execution Graph (Phase 3):**
|
|
682
|
-
|
|
683
|
-
```
|
|
684
|
-
|
|
685
|
-
T022 [P] ──┐
|
|
686
|
-
T024 [P] ──┘──> (Test suites can run parallel)
|
|
687
|
-
|
|
688
|
-
T013 (AuthService) ──> T023 (AuthController)
|
|
689
|
-
T015 (TokenService) ──> T025 (Auth middleware)
|
|
690
|
-
|
|
691
|
-
T026 (Validators) ──┐
|
|
692
|
-
T027 (DTOs) ├──> T028 (Routes)
|
|
693
|
-
T023 (Controller) ┘
|
|
694
|
-
T025 (Middleware) ─┘
|
|
695
|
-
|
|
696
|
-
```
|
|
697
|
-
|
|
698
|
-
## Phase 4: Integration • 3 SP (~15-20 min)
|
|
699
|
-
|
|
700
|
-
**Tasks:**
|
|
701
|
-
|
|
702
|
-
- [ ] [T029] Connect services to controllers • 1 SP (~1-2h)
|
|
703
|
-
File: src/app.ts
|
|
704
|
-
Implements: Dependency injection setup for controllers
|
|
705
|
-
Dependencies: T023 (needs AuthController)
|
|
706
|
-
|
|
707
|
-
- [ ] [T030] Add global error handling middleware • 1 SP (~1-2h)
|
|
708
|
-
File: src/middleware/error.middleware.ts
|
|
709
|
-
Implements: Catch all errors, format responses, log errors
|
|
710
|
-
Dependencies: None
|
|
711
|
-
|
|
712
|
-
- [ ] [T031] Configure CORS and security headers • 1 SP (~1h)
|
|
713
|
-
File: src/middleware/security.middleware.ts
|
|
714
|
-
Implements: CORS config, Helmet setup, rate limiting
|
|
715
|
-
Dependencies: None
|
|
716
|
-
|
|
717
|
-
- [ ] [T032] Register auth routes in main app • trivial (~30 min)
|
|
718
|
-
File: src/app.ts
|
|
719
|
-
Implements: app.use('/api/auth', authRoutes)
|
|
720
|
-
Dependencies: T028 (needs auth routes)
|
|
721
|
-
|
|
722
|
-
- [ ] [T033] Add environment variable validation • 1 SP (~1h)
|
|
723
|
-
File: src/config/env.validation.ts
|
|
724
|
-
Implements: Validate JWT_SECRET, DATABASE_URL, EMAIL config
|
|
725
|
-
Dependencies: None
|
|
726
|
-
|
|
727
|
-
**Task Execution Graph (Phase 4):**
|
|
728
|
-
|
|
729
|
-
```
|
|
730
|
-
|
|
731
|
-
T030, T031, T033 [P] ──> (Can run parallel - different concerns)
|
|
732
|
-
|
|
733
|
-
T028 ──> T029 ──> T032 (Sequential: routes → DI → registration)
|
|
734
|
-
|
|
735
|
-
```
|
|
736
|
-
|
|
737
|
-
## Phase 5: Testing & Docs • 2 SP (~10-15 min)
|
|
738
|
-
|
|
739
|
-
**Tasks:**
|
|
740
|
-
|
|
741
|
-
- [ ] [T034] Run full test suite and fix issues • 1 SP (~1-2h)
|
|
742
|
-
File: N/A (command: npm test)
|
|
743
|
-
Validates: All 47 tests passing, coverage ≥ 80%
|
|
744
|
-
Dependencies: T001-T033 (needs all tests written)
|
|
745
|
-
|
|
746
|
-
- [ ] [T035] Integration test for complete auth flow • 1 SP (~1-2h)
|
|
747
|
-
File: tests/integration/auth-flow.spec.ts
|
|
748
|
-
Tests: Full flow from register → login → refresh → logout
|
|
749
|
-
Dependencies: T034 (needs all individual tests passing)
|
|
750
|
-
|
|
751
|
-
- [ ] [T036] [P] Update API documentation • trivial (~20 min)
|
|
752
|
-
File: docs/api.md
|
|
753
|
-
Updates: Add 5 auth endpoints with request/response examples
|
|
754
|
-
Dependencies: None (can run parallel with T037, T038)
|
|
755
|
-
|
|
756
|
-
- [ ] [T037] [P] Update data model documentation • trivial (~15 min)
|
|
757
|
-
File: docs/data-model.md
|
|
758
|
-
Updates: Add User, Session, RefreshToken entities with relationships
|
|
759
|
-
Dependencies: None (can run parallel with T036, T038)
|
|
760
|
-
|
|
761
|
-
- [ ] [T038] [P] Update security documentation • trivial (~15 min)
|
|
762
|
-
File: specs/security.md
|
|
763
|
-
Updates: Document JWT flow, refresh token rotation, password policy
|
|
764
|
-
Dependencies: None (can run parallel with T036, T037)
|
|
765
|
-
|
|
766
|
-
- [ ] [T039] Add environment variables to .env.example • trivial (~10 min)
|
|
767
|
-
File: .env.example
|
|
768
|
-
Updates: Add JWT_SECRET, JWT_EXPIRATION, REFRESH_TOKEN_EXPIRATION
|
|
769
|
-
Dependencies: None
|
|
770
|
-
|
|
771
|
-
**Task Execution Graph (Phase 5):**
|
|
772
|
-
|
|
773
|
-
```
|
|
774
|
-
|
|
775
|
-
T001-T033 ──> T034 (Run all tests) ──> T035 (E2E flow test)
|
|
776
|
-
|
|
777
|
-
T036 [P] ──┐
|
|
778
|
-
T037 [P] ──┼──> (Documentation updates can run parallel)
|
|
779
|
-
T038 [P] ──┘
|
|
780
|
-
|
|
781
|
-
T039 (env example) ──> (Independent, can run anytime)
|
|
782
|
-
|
|
783
|
-
```
|
|
784
|
-
|
|
785
|
-
**Parallelization Notes (Phase 5):**
|
|
786
|
-
- All documentation tasks (T036, T037, T038) can run in parallel
|
|
787
|
-
- T034 must complete before T035 (E2E depends on unit/integration tests)
|
|
788
|
-
- T039 is independent and can run anytime
|
|
789
|
-
|
|
790
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
791
|
-
**Total:** 34 SP • 39 tasks • ~2-3 hours with AI assistance
|
|
792
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
793
|
-
|
|
794
|
-
**Parallelization Summary:**
|
|
795
|
-
- ✅ Phase 1: 3 test tasks parallel (T001, T003, T005)
|
|
796
|
-
- ✅ Phase 2: 3 test tasks + 4 utility tasks parallel
|
|
797
|
-
- ✅ Phase 3: 2 test tasks parallel (T022, T024)
|
|
798
|
-
- ✅ Phase 4: 3 tasks parallel (T030, T031, T033)
|
|
799
|
-
- ✅ Phase 5: 3 documentation tasks parallel (T036, T037, T038)
|
|
800
|
-
- ⚡ With 2 devs: ~40% time savings via parallelization
|
|
801
|
-
- ⚡ With 3 devs: ~50% time savings via parallelization
|
|
802
|
-
|
|
803
|
-
Review plan? (Y/n)
|
|
804
|
-
```
|
|
805
|
-
|
|
82
|
+
### Phase 1: Quick Specification (2-3 minutes or AUTO-SKIP)
|
|
83
|
+
|
|
84
|
+
**IF mode = `USER_STORY`:** _(Skip questions, load from file)_
|
|
85
|
+
|
|
86
|
+
```
|
|
806
87
|
---
|
|
807
|
-
|
|
808
|
-
### Phase 0.5: Git Branch Setup (Optional, 30 seconds)
|
|
809
|
-
|
|
810
|
-
**After user confirms plan, detect Git repository:**
|
|
811
|
-
|
|
812
|
-
```bash
|
|
813
|
-
git rev-parse --git-dir 2>/dev/null
|
|
814
|
-
```
|
|
815
|
-
|
|
816
|
-
**If NO Git repository found:**
|
|
817
|
-
|
|
818
|
-
```
|
|
819
|
-
ℹ️ No Git repository detected
|
|
820
|
-
|
|
821
|
-
Git integration is disabled for this session.
|
|
822
|
-
To enable Git features, initialize a repository first:
|
|
823
|
-
git init
|
|
824
|
-
git remote add origin <url>
|
|
825
|
-
|
|
826
|
-
Continue without Git? (Y/n)
|
|
827
|
-
```
|
|
828
|
-
|
|
829
|
-
**If Git repository detected:**
|
|
830
|
-
|
|
831
|
-
```
|
|
832
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
833
|
-
🌿 Git Integration
|
|
834
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
835
|
-
|
|
836
|
-
Git repository detected ✅
|
|
837
|
-
Current branch: main
|
|
838
|
-
Status: clean
|
|
839
|
-
|
|
840
|
-
Feature: notifications-websocket
|
|
841
|
-
Suggested branch: feature/notifications-websocket
|
|
842
|
-
|
|
843
|
-
Create new branch and enable Git integration?
|
|
844
|
-
|
|
845
|
-
A) ⭐ Yes - Create branch + auto-commit per phase (Recommended for MEDIUM/COMPLEX/LARGE)
|
|
846
|
-
B) Yes - Create branch + single commit at end (Good for SIMPLE)
|
|
847
|
-
C) Work on current branch (no branch creation)
|
|
848
|
-
D) Skip Git integration (work without commits)
|
|
849
|
-
|
|
850
|
-
Your choice (A): __
|
|
851
|
-
```
|
|
852
|
-
|
|
853
|
-
**Smart defaults based on complexity:**
|
|
854
|
-
|
|
855
|
-
- **SIMPLE** (1-10 tasks) → Suggest **Option B** (single commit at end)
|
|
856
|
-
- **MEDIUM/COMPLEX/LARGE** (11+ tasks) → Suggest **Option A** (commit per phase)
|
|
857
|
-
|
|
858
|
-
**Edge Case 1: Uncommitted Changes Detected**
|
|
859
|
-
|
|
860
|
-
```bash
|
|
861
|
-
git status --porcelain
|
|
862
|
-
```
|
|
863
|
-
|
|
864
|
-
If output is non-empty:
|
|
865
|
-
|
|
866
|
-
```
|
|
867
|
-
⚠️ Uncommitted changes detected:
|
|
868
|
-
|
|
869
|
-
M src/controllers/UserController.ts
|
|
870
|
-
M src/services/AuthService.ts
|
|
871
|
-
?? new-file.ts
|
|
872
|
-
|
|
873
|
-
Options:
|
|
874
|
-
A) Stash changes and proceed (git stash)
|
|
875
|
-
B) Commit changes first (I'll guide you)
|
|
876
|
-
C) Continue anyway (changes will be included)
|
|
877
|
-
D) Cancel workflow
|
|
878
|
-
|
|
879
|
-
Your choice (A): __
|
|
880
|
-
```
|
|
881
|
-
|
|
882
|
-
**If A selected:** `git stash && git stash list` → Show stash confirmation
|
|
883
|
-
**If B selected:** Guide conventional commit, then continue
|
|
884
|
-
**If D selected:** Exit workflow
|
|
885
|
-
|
|
886
|
-
**Edge Case 2: Already on Feature Branch**
|
|
887
|
-
|
|
888
|
-
```bash
|
|
889
|
-
git rev-parse --abbrev-ref HEAD
|
|
890
|
-
```
|
|
891
|
-
|
|
892
|
-
If result starts with `feature/`, `fix/`, or `refactor/`:
|
|
893
|
-
|
|
894
|
-
```
|
|
895
|
-
⚠️ You're currently on branch: feature/other-work
|
|
896
|
-
|
|
897
|
-
Options:
|
|
898
|
-
A) Continue on this branch (may mix work)
|
|
899
|
-
B) Create new branch from current (branch off)
|
|
900
|
-
C) Switch to main/develop first (recommended)
|
|
901
|
-
D) Skip Git integration
|
|
902
|
-
|
|
903
|
-
Your choice (C): __
|
|
904
|
-
```
|
|
905
|
-
|
|
906
|
-
**If C selected:** `git checkout main` → Then proceed with branch creation
|
|
907
|
-
|
|
908
|
-
**Edge Case 3: Branch Name Already Exists**
|
|
909
|
-
|
|
910
|
-
```bash
|
|
911
|
-
git show-ref --verify --quiet refs/heads/feature/notifications-websocket
|
|
912
|
-
```
|
|
913
|
-
|
|
914
|
-
If exists:
|
|
915
|
-
|
|
916
|
-
```
|
|
917
|
-
⚠️ Branch 'feature/notifications-websocket' already exists
|
|
918
|
-
|
|
919
|
-
Options:
|
|
920
|
-
A) Use different name (feature/notifications-websocket-v2)
|
|
921
|
-
B) Checkout existing branch (continue previous work)
|
|
922
|
-
C) Skip Git integration
|
|
923
|
-
|
|
924
|
-
Your choice (A): __
|
|
925
|
-
```
|
|
926
|
-
|
|
927
|
-
**Edge Case 4: Detached HEAD State**
|
|
928
|
-
|
|
929
|
-
```bash
|
|
930
|
-
git symbolic-ref -q HEAD || echo "detached"
|
|
931
|
-
```
|
|
932
|
-
|
|
933
|
-
If detached:
|
|
934
|
-
|
|
935
|
-
```
|
|
936
|
-
⚠️ Detached HEAD state detected
|
|
937
|
-
|
|
938
|
-
You're not on a branch. Git integration requires a branch.
|
|
939
|
-
|
|
940
|
-
Options:
|
|
941
|
-
A) Create new branch here (git checkout -b feature/notifications)
|
|
942
|
-
B) Go back to previous branch (git checkout -)
|
|
943
|
-
C) Switch to main (git checkout main)
|
|
944
|
-
D) Skip Git integration
|
|
945
|
-
|
|
946
|
-
Your choice (C): __
|
|
947
|
-
```
|
|
948
|
-
|
|
949
|
-
**Actions if user enables Git integration (Options A or B):**
|
|
950
|
-
|
|
951
|
-
1. **Create branch:**
|
|
952
|
-
|
|
953
|
-
```bash
|
|
954
|
-
git checkout -b feature/notifications-websocket
|
|
955
|
-
```
|
|
956
|
-
|
|
957
|
-
2. **Update status.json:**
|
|
958
|
-
|
|
959
|
-
```json
|
|
960
|
-
{
|
|
961
|
-
"git": {
|
|
962
|
-
"enabled": true,
|
|
963
|
-
"autoCommit": "phase" | "end", // Based on user choice A or B
|
|
964
|
-
"branchCreated": true,
|
|
965
|
-
"branchName": "feature/notifications-websocket",
|
|
966
|
-
"sourceBranch": "main",
|
|
967
|
-
"commits": [],
|
|
968
|
-
"lastCommitSha": null,
|
|
969
|
-
"uncommittedChanges": false,
|
|
970
|
-
"readyForPR": false,
|
|
971
|
-
"prSuggested": false
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
```
|
|
975
|
-
|
|
976
|
-
3. **Show confirmation:**
|
|
977
|
-
|
|
978
|
-
```
|
|
979
|
-
✅ Branch created: feature/notifications-websocket
|
|
980
|
-
📦 Git commits will be created: per phase
|
|
981
|
-
|
|
982
|
-
Proceeding to implementation...
|
|
983
|
-
```
|
|
984
|
-
|
|
985
|
-
**If user skips Git (Options C or D):**
|
|
986
|
-
|
|
987
|
-
```json
|
|
988
|
-
{
|
|
989
|
-
"git": {
|
|
990
|
-
"enabled": false
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
```
|
|
994
|
-
|
|
88
|
+
🚀 Feature Workflow | Phase 1/4: Specification (AUTO-LOADED)
|
|
995
89
|
---
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1015
|
-
|
|
1016
|
-
Recommended: Phase-by-phase (based on COMPLEX feature)
|
|
1017
|
-
|
|
1018
|
-
How do you want to proceed?
|
|
1019
|
-
|
|
1020
|
-
1. 🚀 Auto (implement all tasks automatically)
|
|
1021
|
-
2. 📋 Phase-by-phase (pause after each phase for review) ⭐ RECOMMENDED
|
|
1022
|
-
3. 🔍 Task-by-task (manual approval for each task)
|
|
1023
|
-
4. 💾 Save and resume later
|
|
1024
|
-
|
|
1025
|
-
Your choice (2): [1/2/3/4]
|
|
1026
|
-
```
|
|
1027
|
-
|
|
1028
|
-
**Note:** User can override recommended mode by typing different number, or press Enter to accept default.
|
|
1029
|
-
|
|
1030
|
-
**STEP 3.2: Execute Based on Mode**
|
|
1031
|
-
|
|
1032
|
-
#### Mode 1: Auto (Default for SIMPLE features)
|
|
1033
|
-
|
|
1034
|
-
Execute all tasks automatically with progress updates:
|
|
1035
|
-
|
|
1036
|
-
```
|
|
1037
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1038
|
-
⚙️ Implementation (Auto Mode)
|
|
1039
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1040
|
-
|
|
1041
|
-
Task 1/12: Create User entity ✅
|
|
1042
|
-
Task 2/12: Create AuthService ✅
|
|
1043
|
-
Task 3/12: Create AuthController ✅
|
|
1044
|
-
...
|
|
1045
|
-
Task 12/12: Update documentation ✅
|
|
1046
|
-
|
|
1047
|
-
All tasks completed! ✅
|
|
1048
|
-
```
|
|
1049
|
-
|
|
1050
|
-
#### Mode 2: Phase-by-phase (Recommended for COMPLEX features)
|
|
1051
|
-
|
|
1052
|
-
Execute one phase at a time, pause for review:
|
|
1053
|
-
|
|
1054
|
-
```
|
|
1055
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1056
|
-
⚙️ Implementation (Phase-by-phase Mode)
|
|
1057
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1058
|
-
|
|
1059
|
-
PHASE 1/5: Data Layer
|
|
1060
|
-
├── Task 1.1: Create User entity ✅
|
|
1061
|
-
├── Task 1.2: Create Session entity ✅
|
|
1062
|
-
├── Task 1.3: Create RefreshToken entity ✅
|
|
1063
|
-
├── Task 1.4: Create migrations ✅
|
|
1064
|
-
├── Task 1.5: Create UserRepository ✅
|
|
1065
|
-
└── ... (5 more tasks) ✅
|
|
1066
|
-
|
|
1067
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1068
|
-
✅ Phase 1 Complete (10/10 tasks)
|
|
1069
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1070
|
-
|
|
1071
|
-
📁 Files created:
|
|
1072
|
-
- src/entities/User.entity.ts
|
|
1073
|
-
- src/entities/Session.entity.ts
|
|
1074
|
-
- src/entities/RefreshToken.entity.ts
|
|
1075
|
-
- src/migrations/001_create_auth_tables.ts
|
|
1076
|
-
- src/repositories/UserRepository.ts
|
|
1077
|
-
|
|
1078
|
-
**If git.enabled === true AND git.autoCommit === "phase":**
|
|
1079
|
-
|
|
1080
|
-
**Pre-commit Validation:**
|
|
1081
|
-
|
|
1082
|
-
```
|
|
1083
|
-
|
|
1084
|
-
🔍 Running pre-commit checks...
|
|
1085
|
-
✅ Lint passed (eslint --fix applied)
|
|
1086
|
-
✅ Tests passed (24/24, +10 new tests)
|
|
1087
|
-
✅ Type check passed
|
|
1088
|
-
|
|
1089
|
-
```
|
|
1090
|
-
|
|
1091
|
-
**If validation FAILS:**
|
|
1092
|
-
|
|
1093
|
-
```
|
|
1094
|
-
|
|
1095
|
-
❌ Pre-commit checks failed:
|
|
1096
|
-
|
|
1097
|
-
Lint errors (2):
|
|
1098
|
-
|
|
1099
|
-
- src/entities/User.entity.ts:15 - Missing semicolon
|
|
1100
|
-
- src/entities/Session.entity.ts:22 - Unused import
|
|
1101
|
-
|
|
1102
|
-
Options:
|
|
1103
|
-
A) Fix issues automatically and retry
|
|
1104
|
-
B) Skip commit (continue without committing)
|
|
1105
|
-
C) Show errors and let me fix manually
|
|
1106
|
-
D) Force commit anyway (not recommended)
|
|
1107
|
-
|
|
1108
|
-
Your choice (A): \_\_
|
|
1109
|
-
|
|
1110
|
-
```
|
|
1111
|
-
|
|
1112
|
-
**If option A:** Run fixes, re-validate, continue
|
|
1113
|
-
**If option B:** Skip commit, set `uncommittedChanges: true`
|
|
1114
|
-
**If option C:** Show errors, pause workflow
|
|
1115
|
-
**If option D:** Commit with `--no-verify`
|
|
1116
|
-
|
|
1117
|
-
**If validation PASSES:**
|
|
1118
|
-
|
|
1119
|
-
```
|
|
1120
|
-
|
|
1121
|
-
📦 Creating commit for Phase 1...
|
|
1122
|
-
|
|
1123
|
-
Conventional Commit:
|
|
1124
|
-
Type: feat
|
|
1125
|
-
Scope: entities
|
|
1126
|
-
Subject: add authentication entities and migrations
|
|
1127
|
-
|
|
1128
|
-
Generated commit message:
|
|
1129
|
-
───────────────────────────────────────────────────────
|
|
1130
|
-
feat(entities): add authentication entities and migrations
|
|
1131
|
-
|
|
1132
|
-
- Create User entity with email verification
|
|
1133
|
-
- Create Session entity for active sessions tracking
|
|
1134
|
-
- Create RefreshToken entity with rotation support
|
|
1135
|
-
- Add migrations for auth tables
|
|
1136
|
-
- Add UserRepository with findByEmail method
|
|
1137
|
-
|
|
1138
|
-
Files changed: 5
|
|
1139
|
-
Lines added: 245
|
|
1140
|
-
───────────────────────────────────────────────────────
|
|
1141
|
-
|
|
1142
|
-
Commit this? (Y/n/edit): \_\_
|
|
1143
|
-
|
|
1144
|
-
````
|
|
1145
|
-
|
|
1146
|
-
**If Y:** Execute commit
|
|
1147
|
-
**If n:** Skip commit
|
|
1148
|
-
**If edit:** Allow editing commit message
|
|
1149
|
-
|
|
1150
|
-
**Execute commit:**
|
|
1151
|
-
|
|
1152
|
-
```bash
|
|
1153
|
-
git add .
|
|
1154
|
-
git commit -m "feat(entities): add authentication entities and migrations
|
|
1155
|
-
|
|
1156
|
-
- Create User entity with email verification
|
|
1157
|
-
- Create Session entity for active sessions tracking
|
|
1158
|
-
- Create RefreshToken entity with rotation support
|
|
1159
|
-
- Add migrations for auth tables
|
|
1160
|
-
- Add UserRepository with findByEmail method"
|
|
1161
|
-
````
|
|
1162
|
-
|
|
1163
|
-
**Update status.json:**
|
|
1164
|
-
|
|
1165
|
-
```json
|
|
1166
|
-
{
|
|
1167
|
-
"git": {
|
|
1168
|
-
"commits": [
|
|
1169
|
-
{
|
|
1170
|
-
"sha": "abc123def456",
|
|
1171
|
-
"type": "feat",
|
|
1172
|
-
"scope": "entities",
|
|
1173
|
-
"message": "add authentication entities and migrations",
|
|
1174
|
-
"phase": 1,
|
|
1175
|
-
"timestamp": "2025-12-04T14:30:00Z",
|
|
1176
|
-
"filesChanged": 5
|
|
1177
|
-
}
|
|
1178
|
-
],
|
|
1179
|
-
"lastCommitSha": "abc123def456",
|
|
1180
|
-
"uncommittedChanges": false
|
|
1181
|
-
}
|
|
1182
|
-
}
|
|
1183
|
-
```
|
|
1184
|
-
|
|
1185
|
-
**Show confirmation:**
|
|
1186
|
-
|
|
1187
|
-
```
|
|
1188
|
-
✅ Committed: abc123de
|
|
1189
|
-
feat(entities): add authentication entities and migrations
|
|
1190
|
-
```
|
|
1191
|
-
|
|
1192
|
-
Continue to Phase 2? (Y/n/pause)
|
|
1193
|
-
|
|
1194
|
-
> Y
|
|
1195
|
-
|
|
1196
|
-
PHASE 2/5: Business Logic
|
|
1197
|
-
├── Task 2.1: Create AuthService ✅
|
|
1198
|
-
...
|
|
1199
|
-
|
|
1200
|
-
```
|
|
1201
|
-
|
|
1202
|
-
**Options after each phase:**
|
|
1203
|
-
|
|
1204
|
-
- **Y** → Continue to next phase
|
|
1205
|
-
- **n** → Stop and allow modifications
|
|
1206
|
-
- **pause** → Save progress and exit (can resume with `/work resume`)
|
|
1207
|
-
|
|
1208
|
-
#### Mode 3: Task-by-task (Maximum control)
|
|
1209
|
-
|
|
1210
|
-
Ask confirmation before each task:
|
|
1211
|
-
|
|
1212
|
-
```
|
|
1213
|
-
|
|
1214
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1215
|
-
⚙️ Implementation (Task-by-task Mode)
|
|
1216
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1217
|
-
|
|
1218
|
-
Next task: Create User entity
|
|
1219
|
-
Files to create: src/entities/User.entity.ts
|
|
1220
|
-
|
|
1221
|
-
Proceed? (Y/n/skip/pause)
|
|
1222
|
-
|
|
1223
|
-
> Y
|
|
1224
|
-
|
|
1225
|
-
[Creates User.entity.ts]
|
|
1226
|
-
|
|
1227
|
-
✅ Task 1/12 complete
|
|
1228
|
-
|
|
1229
|
-
Next task: Create AuthService
|
|
1230
|
-
Files to create: src/services/AuthService.ts
|
|
1231
|
-
|
|
1232
|
-
Proceed? (Y/n/skip/pause)
|
|
1233
|
-
|
|
1234
|
-
> Y
|
|
1235
|
-
|
|
1236
|
-
```
|
|
1237
|
-
|
|
1238
|
-
**Options for each task:**
|
|
1239
|
-
|
|
1240
|
-
- **Y** → Execute task
|
|
1241
|
-
- **n** → Stop (allow manual work)
|
|
1242
|
-
- **skip** → Skip this task
|
|
1243
|
-
- **pause** → Save and exit
|
|
1244
|
-
|
|
1245
|
-
#### Mode 4: Save and resume later
|
|
1246
|
-
|
|
1247
|
-
Save current state and exit:
|
|
1248
|
-
|
|
1249
|
-
```
|
|
1250
|
-
|
|
1251
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1252
|
-
💾 Progress Saved
|
|
1253
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1254
|
-
|
|
1255
|
-
Current progress: 0/52 tasks (0%)
|
|
1256
|
-
Status: Ready to start
|
|
1257
|
-
|
|
1258
|
-
To resume: /work resume feature-[name]
|
|
1259
|
-
|
|
1260
|
-
```
|
|
1261
|
-
|
|
1262
|
-
**Generate:** `.ai-flow/work/NNN-feature-name/tasks.md` (with ✅ checkmarks)
|
|
1263
|
-
|
|
1264
|
-
**Example:** `.ai-flow/work/003-user-authentication/tasks.md`
|
|
1265
|
-
|
|
1266
|
-
**Implementation rules:**
|
|
1267
|
-
|
|
1268
|
-
- Follow project conventions detected in codebase
|
|
1269
|
-
- Use same code style as existing files
|
|
1270
|
-
- Write tests for all new code
|
|
1271
|
-
- Validate each task before marking complete
|
|
1272
|
-
- Update status.json after each task/phase
|
|
1273
|
-
|
|
1274
|
-
### Phase 4: Security Check + Validation + Auto-Archive (1-2 minutes)
|
|
1275
|
-
|
|
1276
|
-
**IF mode = `USER_STORY`:** *(Validate against Definition of Done)*
|
|
1277
|
-
|
|
1278
|
-
```
|
|
1279
|
-
|
|
1280
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1281
|
-
✅ Definition of Done Validation (from HU-001-001)
|
|
1282
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1283
|
-
|
|
1284
|
-
Validating User Story completion...
|
|
1285
|
-
|
|
1286
|
-
✅ Código implementado siguiendo ai-instructions.md
|
|
1287
|
-
✅ Code review aprobado (mín 1 revisor) [Simulated: Auto-approved by AI]
|
|
1288
|
-
✅ Tests unitarios escritos (cobertura > 80%) [Coverage: 92%]
|
|
1289
|
-
✅ Tests de integración pasando [8/8 passing]
|
|
1290
|
-
✅ Casos de prueba QA ejecutados y aprobados (8/8)
|
|
1291
|
-
✅ TC-001-001: Login exitoso (Happy Path)
|
|
1292
|
-
✅ TC-001-002: Credenciales inválidas (Error Case)
|
|
1293
|
-
✅ TC-001-003: Rate limiting (Edge Case)
|
|
1294
|
-
... [5 more test cases]
|
|
1295
|
-
✅ Documentación técnica actualizada (docs/api.md)
|
|
1296
|
-
✅ Sin errores de lint ni formateo
|
|
1297
|
-
⚠️ Deploy a staging exitoso [SKIP: Local development]
|
|
1298
|
-
⚠️ Product Owner aprobó la funcionalidad [SKIP: Manual step]
|
|
1299
|
-
|
|
1300
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1301
|
-
Acceptance Criteria Verification
|
|
1302
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1303
|
-
|
|
1304
|
-
✅ Scenario 1: Login exitoso
|
|
1305
|
-
Test: TC-001-001 passed
|
|
1306
|
-
Verified: JWT token returned with valid exp, user_id, role
|
|
1307
|
-
|
|
1308
|
-
✅ Scenario 2: Credenciales inválidas
|
|
1309
|
-
Test: TC-001-002 passed
|
|
1310
|
-
Verified: 401 status with clear error message
|
|
1311
|
-
|
|
1312
|
-
✅ Scenario 3: Rate limiting
|
|
1313
|
-
Test: TC-001-003 passed
|
|
1314
|
-
Verified: 429 status after 5 failed attempts in 15 minutes
|
|
1315
|
-
|
|
1316
|
-
All acceptance criteria met! ✅
|
|
1317
|
-
|
|
1318
|
-
```
|
|
1319
|
-
|
|
1320
|
-
**IF mode = `ROADMAP_FEATURE` or `INTERACTIVE`:** *(Standard security check)*
|
|
1321
|
-
|
|
1322
|
-
**Security Quick Check:**
|
|
1323
|
-
Ask 1-2 questions about production considerations:
|
|
1324
|
-
|
|
1325
|
-
- Add rate limiting?
|
|
1326
|
-
- Input validation sufficient?
|
|
1327
|
-
- Consider [specific concern] for production?
|
|
1328
|
-
|
|
1329
|
-
**Auto-Archive:**
|
|
1330
|
-
|
|
1331
|
-
1. Move work to `.ai-flow/archive/YYYY-MM/feature-[name]/`
|
|
1332
|
-
2. Update affected documentation:
|
|
1333
|
-
- `docs/api.md` (if new endpoints)
|
|
1334
|
-
- `docs/data-model.md` (if new entities)
|
|
1335
|
-
- `specs/security.md` (if auth/permissions changed)
|
|
1336
|
-
3. Generate final summary
|
|
1337
|
-
|
|
1338
|
-
**Example output:**
|
|
1339
|
-
|
|
1340
|
-
```
|
|
1341
|
-
|
|
1342
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1343
|
-
🔒 Security Quick Check
|
|
1344
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1345
|
-
|
|
1346
|
-
✅ Password hashing: bcrypt cost 12
|
|
1347
|
-
✅ JWT secret: from env variable
|
|
1348
|
-
⚠️ Consider: Rate limiting on login endpoint
|
|
1349
|
-
|
|
1350
|
-
Add rate limiting now? (Y/n)
|
|
1351
|
-
|
|
1352
|
-
```
|
|
1353
|
-
|
|
1354
|
-
**Documentation Updates:**
|
|
1355
|
-
|
|
1356
|
-
Update affected documentation files:
|
|
1357
|
-
- `docs/api.md` - Add new endpoints
|
|
1358
|
-
- `docs/data-model.md` - Add new entities
|
|
1359
|
-
- `.env.example` - Add new environment variables
|
|
1360
|
-
|
|
1361
|
-
**If git.enabled === true:**
|
|
1362
|
-
|
|
1363
|
-
**Final Documentation Commit:**
|
|
1364
|
-
|
|
1365
|
-
```
|
|
1366
|
-
|
|
1367
|
-
📦 Creating final documentation commit...
|
|
1368
|
-
|
|
1369
|
-
Conventional Commit:
|
|
1370
|
-
Type: docs
|
|
1371
|
-
Scope: api
|
|
1372
|
-
Subject: update documentation for authentication feature
|
|
1373
|
-
|
|
1374
|
-
Generated commit message:
|
|
1375
|
-
───────────────────────────────────────────────────────
|
|
1376
|
-
docs(api): update documentation for authentication feature
|
|
1377
|
-
|
|
1378
|
-
- Add 5 authentication endpoints with examples
|
|
1379
|
-
- Update data model with User, Session, RefreshToken entities
|
|
1380
|
-
- Add environment variables for JWT configuration
|
|
1381
|
-
- Document rate limiting on auth endpoints
|
|
1382
|
-
|
|
1383
|
-
Files changed: 3
|
|
1384
|
-
───────────────────────────────────────────────────────
|
|
1385
|
-
|
|
1386
|
-
Commit? (Y/n): \_\_
|
|
1387
|
-
|
|
1388
|
-
```
|
|
1389
|
-
|
|
1390
|
-
**After final commit:**
|
|
1391
|
-
|
|
1392
|
-
```
|
|
1393
|
-
|
|
1394
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1395
|
-
✅ Feature Complete!
|
|
1396
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1397
|
-
|
|
1398
|
-
**IF mode = `USER_STORY`:**
|
|
1399
|
-
|
|
1400
|
-
```
|
|
1401
|
-
Summary:
|
|
1402
|
-
|
|
1403
|
-
- User Story: HU-001-001 - Login básico con email y contraseña
|
|
1404
|
-
- Epic: EP-001 - Autenticación y Seguridad
|
|
1405
|
-
- Priority: Alta (P0)
|
|
1406
|
-
- Story Points: 5 SP (estimated) → 4.8 SP (actual)
|
|
1407
|
-
- Time: 1.5 hours (estimated: 6-8h with AI assistance)
|
|
1408
|
-
- Files: 6 created, 2 modified
|
|
1409
|
-
- Tests: 8 added (all passing ✅)
|
|
1410
|
-
|
|
1411
|
-
✅ Acceptance Criteria: 3/3 verified
|
|
1412
|
-
✅ Test Cases: 8/8 executed and passed
|
|
1413
|
-
✅ Definition of Done: 7/9 completed (2 manual steps pending)
|
|
1414
|
-
|
|
1415
|
-
Dependencies resolved:
|
|
1416
|
-
✅ Blocks: HU-001-002 (OAuth login) - Ready to start
|
|
1417
|
-
✅ Blocks: HU-002-001 (User CRUD) - Ready to start
|
|
1418
|
-
|
|
1419
|
-
📖 User Story Status: COMPLETED ✅
|
|
1420
|
-
File: .ai-flow/user-stories/EP-001/HU-001-001.md updated with completion date
|
|
1421
|
-
```
|
|
1422
|
-
|
|
1423
|
-
**IF mode = `ROADMAP_FEATURE` or `INTERACTIVE`:**
|
|
1424
|
-
|
|
1425
|
-
```
|
|
1426
|
-
Summary:
|
|
1427
|
-
|
|
1428
|
-
- Feature: JWT authentication system
|
|
1429
|
-
- Files: 28 created, 5 modified
|
|
1430
|
-
- Tests: 47 added (all passing ✅)
|
|
1431
|
-
- Time: 2.5 hours
|
|
1432
|
-
- Complexity: COMPLEX (52 tasks, 5 phases)
|
|
1433
|
-
```
|
|
1434
|
-
|
|
1435
|
-
📦 Git Summary:
|
|
1436
|
-
Branch: feature/auth-jwt-system
|
|
1437
|
-
Source: main
|
|
1438
|
-
Commits: 6
|
|
1439
|
-
|
|
1440
|
-
1. feat(entities): add authentication entities and migrations
|
|
1441
|
-
2. feat(services): implement AuthService and TokenService
|
|
1442
|
-
3. feat(api): add authentication endpoints
|
|
1443
|
-
4. feat(middleware): add JWT verification middleware
|
|
1444
|
-
5. test(auth): add comprehensive test suite
|
|
1445
|
-
6. docs(api): update documentation for authentication feature
|
|
1446
|
-
|
|
1447
|
-
All changes committed ✅
|
|
1448
|
-
Ready for Pull Request ✅
|
|
1449
|
-
|
|
1450
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1451
|
-
|
|
1452
|
-
Would you like to create a Pull Request?
|
|
1453
|
-
|
|
1454
|
-
A) Show PR command (recommended)
|
|
1455
|
-
B) No, I'll create it later
|
|
1456
|
-
|
|
1457
|
-
Your choice (A): \_\_
|
|
1458
|
-
|
|
1459
|
-
```
|
|
1460
|
-
|
|
1461
|
-
**If option A selected:**
|
|
1462
|
-
|
|
1463
|
-
```
|
|
1464
|
-
|
|
1465
|
-
To create a Pull Request, run:
|
|
1466
|
-
|
|
1467
|
-
gh pr create \
|
|
1468
|
-
--title "feat: JWT authentication system" \
|
|
1469
|
-
--body "## Summary
|
|
1470
|
-
Implements complete JWT authentication with refresh tokens, email verification, and session management.
|
|
1471
|
-
|
|
1472
|
-
## Changes
|
|
1473
|
-
|
|
1474
|
-
- **Entities:** User, Session, RefreshToken with relationships
|
|
1475
|
-
- **Services:** AuthService, TokenService, EmailService
|
|
1476
|
-
- **API:** 5 endpoints (register, login, refresh, logout, verify-email)
|
|
1477
|
-
- **Security:** bcrypt password hashing, JWT with RS256
|
|
1478
|
-
- **Tests:** 47 tests (unit + integration), 95% coverage
|
|
1479
|
-
|
|
1480
|
-
## Documentation
|
|
1481
|
-
|
|
1482
|
-
- API endpoints documented in docs/api.md
|
|
1483
|
-
- Data model updated in docs/data-model.md
|
|
1484
|
-
- Environment variables in .env.example
|
|
1485
|
-
|
|
1486
|
-
## Testing
|
|
1487
|
-
|
|
1488
|
-
- ✅ All 47 tests passing
|
|
1489
|
-
- ✅ Lint checks passed
|
|
1490
|
-
- ✅ Type checks passed
|
|
1491
|
-
- ✅ Security review completed" \
|
|
1492
|
-
--base main \
|
|
1493
|
-
--head feature/auth-jwt-system
|
|
1494
|
-
|
|
1495
|
-
Or open in browser:
|
|
1496
|
-
https://github.com/[user]/[repo]/compare/main...feature/auth-jwt-system
|
|
1497
|
-
|
|
1498
|
-
````
|
|
1499
|
-
|
|
1500
|
-
**Update status.json:**
|
|
1501
|
-
|
|
1502
|
-
```json
|
|
1503
|
-
{
|
|
1504
|
-
"git": {
|
|
1505
|
-
"readyForPR": true,
|
|
1506
|
-
"prSuggested": true
|
|
1507
|
-
}
|
|
1508
|
-
}
|
|
1509
|
-
````
|
|
1510
|
-
|
|
90
|
+
📖 Loading User Story: HU-001-001
|
|
91
|
+
|
|
92
|
+
Source: .ai-flow/user-stories/EP-001/HU-001-001.md
|
|
93
|
+
|
|
94
|
+
✅ Title: Login básico con email y contraseña
|
|
95
|
+
✅ Priority: Alta (P0)
|
|
96
|
+
✅ Story Points: 5 SP
|
|
97
|
+
✅ Acceptance Criteria: 3 scenarios (Gherkin)
|
|
98
|
+
✅ Technical Tasks: 6 tasks
|
|
99
|
+
✅ Test Cases: 8 QA test cases
|
|
100
|
+
✅ Definition of Done: 9 items
|
|
101
|
+
|
|
102
|
+
Skipping manual questions (spec already defined)...
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**IF mode = `ROADMAP_FEATURE`:** _(Skip questions, load from roadmap)_
|
|
106
|
+
|
|
107
|
+
```
|
|
1511
108
|
---
|
|
1512
|
-
|
|
1513
|
-
## Files Generated
|
|
1514
|
-
|
|
1515
|
-
### During workflow (work directory):
|
|
1516
|
-
|
|
1517
|
-
```
|
|
1518
|
-
.ai-flow/work/NNN-feature-name/
|
|
1519
|
-
├── spec.md # What is being built
|
|
1520
|
-
├── plan.md # How it will be built
|
|
1521
|
-
├── tasks.md # Checklist with ✅
|
|
1522
|
-
├── status.json # Metadata (progress, timestamps)
|
|
1523
|
-
|
|
1524
|
-
**Example:** `.ai-flow/work/003-user-authentication/`
|
|
1525
|
-
└── implementation.md # Optional implementation notes
|
|
1526
|
-
```
|
|
1527
|
-
|
|
1528
|
-
### After completion (archive):
|
|
1529
|
-
|
|
1530
|
-
```
|
|
1531
|
-
.ai-flow/archive/YYYY-MM/NNN-feature-name/
|
|
1532
|
-
├── spec.md
|
|
1533
|
-
├── plan.md
|
|
1534
|
-
├── tasks.md
|
|
1535
|
-
└── summary.md # Final summary with stats
|
|
1536
|
-
|
|
1537
|
-
**Example:** `.ai-flow/archive/2025-01/003-user-authentication/`
|
|
1538
|
-
```
|
|
1539
|
-
|
|
109
|
+
🚀 Feature Workflow | Phase 1/4: Specification (AUTO-LOADED)
|
|
1540
110
|
---
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
"updated": "2025-01-20T15:30:00Z",
|
|
1579
|
-
"lastPauseReason": "User requested pause after Phase 1",
|
|
1580
|
-
"filesCreated": ["src/entities/Notification.entity.ts", "..."],
|
|
1581
|
-
"filesModified": ["src/app.ts"],
|
|
1582
|
-
"affectedDocs": ["docs/api.md", "docs/data-model.md"],
|
|
1583
|
-
"git": {
|
|
1584
|
-
"enabled": true,
|
|
1585
|
-
"autoCommit": "phase" | "end" | "off",
|
|
1586
|
-
"branchCreated": true,
|
|
1587
|
-
"branchName": "feature/notifications-websocket",
|
|
1588
|
-
"sourceBranch": "main",
|
|
1589
|
-
"commits": [
|
|
1590
|
-
{
|
|
1591
|
-
"sha": "abc123def456",
|
|
1592
|
-
"type": "feat",
|
|
1593
|
-
"scope": "entities",
|
|
1594
|
-
"message": "add Notification entity with websocket support",
|
|
1595
|
-
"phase": 1,
|
|
1596
|
-
"timestamp": "2025-01-20T14:30:00Z",
|
|
1597
|
-
"filesChanged": 5
|
|
1598
|
-
},
|
|
1599
|
-
{
|
|
1600
|
-
"sha": "def456abc789",
|
|
1601
|
-
"type": "feat",
|
|
1602
|
-
"scope": "services",
|
|
1603
|
-
"message": "implement NotificationService with real-time delivery",
|
|
1604
|
-
"phase": 2,
|
|
1605
|
-
"timestamp": "2025-01-20T15:00:00Z",
|
|
1606
|
-
"filesChanged": 8
|
|
1607
|
-
}
|
|
1608
|
-
],
|
|
1609
|
-
"lastCommitSha": "def456abc789",
|
|
1610
|
-
"uncommittedChanges": false,
|
|
1611
|
-
"readyForPR": false,
|
|
1612
|
-
"prSuggested": false
|
|
1613
|
-
}
|
|
1614
|
-
}
|
|
1615
|
-
```
|
|
1616
|
-
|
|
111
|
+
🗺️ Loading Feature from docs/roadmap.md: User Entity & Repository
|
|
112
|
+
|
|
113
|
+
✅ Epic: 2 - Data Layer
|
|
114
|
+
✅ Priority: P0
|
|
115
|
+
✅ Story Points: 12 SP (~2-3d)
|
|
116
|
+
✅ Tasks: 8 tasks (T001-T008)
|
|
117
|
+
✅ Dependencies: None (foundational)
|
|
118
|
+
|
|
119
|
+
Skipping manual questions (roadmap already defined)...
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**IF mode = `INTERACTIVE`:** _(Ask manual questions)_
|
|
123
|
+
|
|
124
|
+
Ask 3-5 key questions to understand requirements:
|
|
125
|
+
|
|
126
|
+
1. **What do you want to build?** (describe in 1-2 sentences)
|
|
127
|
+
2. **What endpoints/functions do you need?**
|
|
128
|
+
3. **What database entities/models?**
|
|
129
|
+
4. **Special requirements?** (real-time, authentication, etc.)
|
|
130
|
+
|
|
131
|
+
**Generate:** `.ai-flow/work/NNN-feature-name/spec.md`
|
|
132
|
+
|
|
133
|
+
**Example:** `.ai-flow/work/003-user-authentication/spec.md`
|
|
134
|
+
|
|
135
|
+
**IF loaded from User Story (HU-XXX-XXX):**
|
|
136
|
+
|
|
137
|
+
- Copy `docs/user-stories/EP-XXX/HU-XXX-XXX.md` → `.ai-flow/work/NNN-HU-XXX-XXX/spec.md`
|
|
138
|
+
- Include: User Story format, Acceptance Criteria (Gherkin), Technical Tasks, Test Cases, DoD
|
|
139
|
+
|
|
140
|
+
**IF loaded from docs/roadmap.md Feature:**
|
|
141
|
+
|
|
142
|
+
- Extract Feature section → `.ai-flow/work/NNN-feature-name/spec.md`
|
|
143
|
+
- Include: Scope, Tasks (T001-T00N), Dependencies, Ready-to-execute command
|
|
144
|
+
|
|
145
|
+
**Example interaction:**
|
|
146
|
+
|
|
147
|
+
```
|
|
1617
148
|
---
|
|
1618
|
-
|
|
1619
|
-
## Git Integration
|
|
1620
|
-
|
|
1621
|
-
### Overview
|
|
1622
|
-
|
|
1623
|
-
Git integration is **optional** and **non-intrusive**. It helps isolate changes in feature branches and create atomic commits automatically per phase or at the end.
|
|
1624
|
-
|
|
1625
|
-
**Key Benefits:**
|
|
1626
|
-
|
|
1627
|
-
- ✅ Automatic branch creation with smart naming (`feature/[name]`)
|
|
1628
|
-
- ✅ Conventional Commits enforced (feat/fix/refactor/docs/test)
|
|
1629
|
-
- ✅ Pre-commit validation (lint + tests + type check)
|
|
1630
|
-
- ✅ Atomic commits per phase (MEDIUM/COMPLEX/LARGE) or single commit (SIMPLE)
|
|
1631
|
-
- ✅ Pull Request suggestion with pre-filled template
|
|
1632
|
-
- ❌ **NO automatic push** (always local only for safety)
|
|
1633
|
-
|
|
1634
|
-
### When Git is Used
|
|
1635
|
-
|
|
1636
|
-
**Branch Creation:** Optional at Phase 0.5 (after plan approval, before implementation)
|
|
1637
|
-
**Commit Points:**
|
|
1638
|
-
|
|
1639
|
-
- **SIMPLE features** (1-10 tasks): Single commit at end
|
|
1640
|
-
- **MEDIUM/COMPLEX/LARGE** (11+ tasks): Commit after each phase completion
|
|
1641
|
-
|
|
1642
|
-
### Conventional Commits Format
|
|
1643
|
-
|
|
1644
|
-
**Enforced types:**
|
|
1645
|
-
|
|
1646
|
-
- `feat` - New feature or functionality
|
|
1647
|
-
- `fix` - Bug fix
|
|
1648
|
-
- `refactor` - Code refactoring
|
|
1649
|
-
- `docs` - Documentation updates
|
|
1650
|
-
- `test` - Test additions or updates
|
|
1651
|
-
- `chore` - Maintenance tasks
|
|
1652
|
-
- `perf` - Performance improvements
|
|
1653
|
-
- `style` - Code style changes (formatting, etc.)
|
|
1654
|
-
|
|
1655
|
-
**Format:**
|
|
1656
|
-
|
|
1657
|
-
```
|
|
1658
|
-
<type>(<scope>): <subject>
|
|
1659
|
-
|
|
1660
|
-
<body>
|
|
1661
|
-
|
|
1662
|
-
<footer>
|
|
1663
|
-
```
|
|
1664
|
-
|
|
1665
|
-
**Examples:**
|
|
1666
|
-
|
|
1667
|
-
```bash
|
|
1668
|
-
# Feature with entities
|
|
1669
|
-
feat(entities): add Notification and NotificationSetting entities
|
|
1670
|
-
|
|
1671
|
-
- Create Notification entity with user relationship
|
|
1672
|
-
- Create NotificationSetting entity for preferences
|
|
1673
|
-
- Add migrations for notifications tables
|
|
1674
|
-
- Add indexes for performance
|
|
1675
|
-
|
|
1676
|
-
# Feature with services
|
|
1677
|
-
feat(services): implement NotificationService with real-time delivery
|
|
1678
|
-
|
|
1679
|
-
- NotificationService with create, read, mark as read
|
|
1680
|
-
- WebSocket integration for real-time push
|
|
1681
|
-
- Email fallback for offline users
|
|
1682
|
-
- Unit tests for all methods
|
|
1683
|
-
|
|
1684
|
-
# Documentation update
|
|
1685
|
-
docs(api): update documentation for notifications feature
|
|
1686
|
-
|
|
1687
|
-
- Add 3 notification endpoints with examples
|
|
1688
|
-
- Update data model with Notification entity
|
|
1689
|
-
- Add environment variables for WebSocket
|
|
1690
|
-
```
|
|
1691
|
-
|
|
1692
|
-
### Pre-commit Validation
|
|
1693
|
-
|
|
1694
|
-
**Runs automatically before every commit:**
|
|
1695
|
-
|
|
1696
|
-
1. **Lint check** - ESLint/Prettier/Black/etc.
|
|
1697
|
-
2. **Test execution** - Run full test suite
|
|
1698
|
-
3. **Type check** - TypeScript/MyPy (if applicable)
|
|
1699
|
-
|
|
1700
|
-
**If validation fails:**
|
|
1701
|
-
|
|
1702
|
-
- Show errors clearly with file and line numbers
|
|
1703
|
-
- Offer to auto-fix (if possible)
|
|
1704
|
-
- Allow skip or manual fix
|
|
1705
|
-
- Force commit option available (not recommended)
|
|
1706
|
-
|
|
1707
|
-
**Example validation output:**
|
|
1708
|
-
|
|
1709
|
-
```
|
|
1710
|
-
🔍 Running pre-commit checks...
|
|
1711
|
-
✅ Lint passed (eslint --fix applied)
|
|
1712
|
-
✅ Tests passed (47/47, +12 new tests)
|
|
1713
|
-
✅ Type check passed
|
|
1714
|
-
|
|
1715
|
-
Ready to commit ✅
|
|
1716
|
-
```
|
|
1717
|
-
|
|
1718
|
-
### Edge Cases Handled
|
|
1719
|
-
|
|
1720
|
-
1. ✅ **Uncommitted changes** - Stash, commit first, or continue with them
|
|
1721
|
-
2. ✅ **Already on feature branch** - Continue, branch off, or switch to main
|
|
1722
|
-
3. ✅ **Branch name conflict** - Suggest alternative name or checkout existing
|
|
1723
|
-
4. ✅ **Detached HEAD** - Prompt to create branch or switch to existing
|
|
1724
|
-
5. ✅ **No Git repository** - Disable Git integration gracefully
|
|
1725
|
-
6. ✅ **Behind remote** - Suggest pull before starting (if applicable)
|
|
1726
|
-
7. ✅ **Merge conflicts** - Pause and instruct manual resolution
|
|
1727
|
-
8. ✅ **Large changesets** - Suggest splitting commits by logical groups
|
|
1728
|
-
9. ✅ **Validation failures** - Auto-fix, skip, show errors, or force commit
|
|
1729
|
-
|
|
1730
|
-
### Workflow Example (COMPLEX Feature)
|
|
1731
|
-
|
|
1732
|
-
```
|
|
1733
|
-
1. User runs: /feature new
|
|
1734
|
-
2. Phase 1: Specification (user answers questions)
|
|
1735
|
-
3. Phase 2: Technical Plan (AI generates plan, 52 tasks, 5 phases)
|
|
1736
|
-
4. Phase 0.5: Git Setup
|
|
1737
|
-
→ Detect Git repo ✅
|
|
1738
|
-
→ Suggest: feature/auth-jwt-system
|
|
1739
|
-
→ User confirms: Create branch + commit per phase
|
|
1740
|
-
→ Branch created ✅
|
|
1741
|
-
5. Phase 3: Implementation (Phase-by-phase mode)
|
|
1742
|
-
→ Phase 1: Data Layer (10 tasks)
|
|
1743
|
-
→ Pre-commit validation ✅
|
|
1744
|
-
→ Commit: feat(entities): add authentication entities
|
|
1745
|
-
→ Phase 2: Business Logic (15 tasks)
|
|
1746
|
-
→ Pre-commit validation ✅
|
|
1747
|
-
→ Commit: feat(services): implement auth services
|
|
1748
|
-
→ ... (continue for remaining phases)
|
|
1749
|
-
6. Phase 4: Security Check + Archive
|
|
1750
|
-
→ Update documentation
|
|
1751
|
-
→ Final commit: docs(api): update auth documentation
|
|
1752
|
-
→ Show PR command: gh pr create ...
|
|
1753
|
-
7. Done! 6 commits ready for PR ✅
|
|
1754
|
-
```
|
|
1755
|
-
|
|
1756
|
-
### Configuration (Optional)
|
|
1757
|
-
|
|
1758
|
-
**File:** `.ai-flow/core/config.json`
|
|
1759
|
-
|
|
1760
|
-
```json
|
|
1761
|
-
{
|
|
1762
|
-
"git": {
|
|
1763
|
-
"enabled": true,
|
|
1764
|
-
"autoCommit": "phase", // "phase" | "end" | "off"
|
|
1765
|
-
"autoCreateBranch": true,
|
|
1766
|
-
"branchPrefix": "feature", // "feature" | "feat" | "work"
|
|
1767
|
-
"commitFormat": "conventional", // always conventional
|
|
1768
|
-
"pushAfterCommit": false, // always false
|
|
1769
|
-
"prSuggestion": true
|
|
1770
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
```
|
|
1773
|
-
|
|
1774
|
-
### Messages Style
|
|
1775
|
-
|
|
1776
|
-
**Non-intrusive, informative, brief:**
|
|
1777
|
-
|
|
1778
|
-
✅ **Good:**
|
|
1779
|
-
|
|
1780
|
-
```
|
|
1781
|
-
✅ Committed: abc123de
|
|
1782
|
-
feat(entities): add notification entities
|
|
1783
|
-
```
|
|
1784
|
-
|
|
1785
|
-
❌ **Bad:**
|
|
1786
|
-
|
|
1787
|
-
```
|
|
1788
|
-
🎉🎉🎉 COMMIT SUCCESSFUL! 🎉🎉🎉
|
|
1789
|
-
SHA: abc123def456789abcdef123456789abcdef1234
|
|
1790
|
-
Author: John Doe <john@example.com>
|
|
1791
|
-
Date: Wed Dec 4 15:30:00 2025 -0500
|
|
1792
|
-
Files changed: 5 insertions(+), 2 deletions(-)
|
|
1793
|
-
Would you like to push to remote? (Y/n)
|
|
1794
|
-
Configure CI/CD pipeline? (Y/n)
|
|
1795
|
-
Set up code review? (Y/n)
|
|
1796
|
-
...
|
|
1797
|
-
```
|
|
1798
|
-
|
|
1799
|
-
### Disabling Git Integration
|
|
1800
|
-
|
|
1801
|
-
**To work without Git:**
|
|
1802
|
-
|
|
1803
|
-
1. **During Phase 0.5:** Select option D (Skip Git integration)
|
|
1804
|
-
2. **In config:** Set `"enabled": false`
|
|
1805
|
-
3. **No Git repo:** Automatically disabled
|
|
1806
|
-
|
|
1807
|
-
**Git integration will never block your workflow.**
|
|
1808
|
-
|
|
149
|
+
🚀 Feature Workflow | Phase 1/4: Specification
|
|
1809
150
|
---
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
-
|
|
1842
|
-
-
|
|
1843
|
-
-
|
|
1844
|
-
-
|
|
1845
|
-
|
|
151
|
+
What do you want to build? (1-2 sentences)
|
|
152
|
+
> [Wait for user response]
|
|
153
|
+
|
|
154
|
+
What endpoints/functions do you need?
|
|
155
|
+
> [Wait for user response]
|
|
156
|
+
|
|
157
|
+
What database entities?
|
|
158
|
+
> [Wait for user response]
|
|
159
|
+
|
|
160
|
+
Special requirements? (real-time, auth, etc.)
|
|
161
|
+
> [Wait for user response]
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Phase 2: Technical Plan (1 minute - auto-generated)
|
|
165
|
+
|
|
166
|
+
#### Step 2.1: Auto-Assign Feature Number
|
|
167
|
+
|
|
168
|
+
**Generate sequential feature number for tracking and organization:**
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
🔢 Assigning feature number...
|
|
172
|
+
|
|
173
|
+
Scanning .ai-flow/work/ directory...
|
|
174
|
+
Last feature: 002-notifications
|
|
175
|
+
New feature: 003-[feature-name]
|
|
176
|
+
|
|
177
|
+
Creating: .ai-flow/work/003-[feature-name]/
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Numbering Rules:**
|
|
181
|
+
|
|
182
|
+
- Auto-increment from existing features in `.ai-flow/work/`
|
|
183
|
+
- Format: `NNN-feature-name` (e.g., `001-auth`, `002-notifications`)
|
|
184
|
+
- Slug: Lowercase, hyphens, no special characters
|
|
185
|
+
- If no existing features → Start at `001`
|
|
186
|
+
|
|
187
|
+
**Example transformations:**
|
|
188
|
+
|
|
189
|
+
- "User Authentication" → `003-user-authentication`
|
|
190
|
+
- "Payment Processing" → `004-payment-processing`
|
|
191
|
+
- "Real-Time Notifications" → `005-real-time-notifications`
|
|
192
|
+
|
|
193
|
+
#### Step 2.2: Analyze Project Context & Load Tasks
|
|
194
|
+
|
|
195
|
+
**IF mode = `USER_STORY` or `ROADMAP_FEATURE`:** _(Reuse existing tasks)_
|
|
196
|
+
|
|
197
|
+
```
|
|
1846
198
|
---
|
|
1847
|
-
|
|
1848
|
-
## Example Outputs
|
|
1849
|
-
|
|
1850
|
-
### Example 1: SIMPLE Feature (Auto Mode)
|
|
1851
|
-
|
|
1852
|
-
```
|
|
1853
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1854
|
-
✅ Feature Complete!
|
|
1855
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1856
|
-
|
|
1857
|
-
Complexity: SIMPLE
|
|
1858
|
-
Mode: Auto
|
|
1859
|
-
Duration: 18 minutes
|
|
1860
|
-
|
|
1861
|
-
Summary:
|
|
1862
|
-
- 8 tasks completed
|
|
1863
|
-
- 3 files modified
|
|
1864
|
-
- 5 tests passed (100% coverage)
|
|
1865
|
-
- Documentation updated
|
|
1866
|
-
|
|
1867
|
-
✏️ Files modified:
|
|
1868
|
-
- src/entities/User.entity.ts
|
|
1869
|
-
- src/controllers/UserController.ts
|
|
1870
|
-
- tests/user.test.ts
|
|
1871
|
-
|
|
1872
|
-
📚 Documentation updated:
|
|
1873
|
-
- docs/data-model.md (added email field)
|
|
1874
|
-
|
|
1875
|
-
📦 Work archived: .ai-flow/archive/2025-01/feature-user-email/
|
|
1876
|
-
|
|
1877
|
-
Next steps:
|
|
1878
|
-
1. Run tests: npm test
|
|
1879
|
-
2. Test endpoint manually
|
|
1880
|
-
```
|
|
1881
|
-
|
|
1882
|
-
### Example 2: COMPLEX Feature (Phase-by-phase Mode)
|
|
1883
|
-
|
|
1884
|
-
```
|
|
1885
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1886
|
-
✅ Feature Complete!
|
|
1887
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
1888
|
-
|
|
1889
|
-
Complexity: COMPLEX
|
|
1890
|
-
Mode: Phase-by-phase
|
|
1891
|
-
Duration: 2h 15min (across 5 phases)
|
|
1892
|
-
|
|
1893
|
-
Summary:
|
|
1894
|
-
- 52 tasks completed across 5 phases
|
|
1895
|
-
- 15 files created
|
|
1896
|
-
- 4 files modified
|
|
1897
|
-
- 48 tests passed (98% coverage)
|
|
1898
|
-
- Documentation updated
|
|
1899
|
-
|
|
1900
|
-
📁 Files created (by phase):
|
|
1901
|
-
PHASE 1 - Data Layer:
|
|
1902
|
-
- src/entities/User.entity.ts
|
|
1903
|
-
- src/entities/Session.entity.ts
|
|
1904
|
-
- src/entities/RefreshToken.entity.ts
|
|
1905
|
-
- src/repositories/UserRepository.ts
|
|
1906
|
-
- src/migrations/001_create_auth_tables.ts
|
|
1907
|
-
|
|
1908
|
-
PHASE 2 - Business Logic:
|
|
1909
|
-
- src/services/AuthService.ts
|
|
1910
|
-
- src/services/TokenService.ts
|
|
1911
|
-
- src/services/EmailService.ts
|
|
1912
|
-
|
|
1913
|
-
PHASE 3 - API Layer:
|
|
1914
|
-
- src/controllers/AuthController.ts
|
|
1915
|
-
- src/middleware/auth.middleware.ts
|
|
1916
|
-
- src/validators/auth.validators.ts
|
|
1917
|
-
|
|
1918
|
-
PHASE 4 - Integration:
|
|
1919
|
-
- src/routes/auth.routes.ts
|
|
1920
|
-
|
|
1921
|
-
PHASE 5 - Testing:
|
|
1922
|
-
- tests/unit/AuthService.test.ts
|
|
1923
|
-
- tests/integration/auth.api.test.ts
|
|
1924
|
-
|
|
1925
|
-
✏️ Files modified:
|
|
1926
|
-
- src/app.ts (registered routes)
|
|
1927
|
-
- src/routes/index.ts
|
|
1928
|
-
- package.json (added dependencies)
|
|
1929
|
-
- .env.example (added JWT variables)
|
|
1930
|
-
|
|
1931
|
-
📚 Documentation updated:
|
|
1932
|
-
- docs/api.md (added 5 auth endpoints)
|
|
1933
|
-
- docs/data-model.md (added 3 auth entities)
|
|
1934
|
-
- specs/security.md (added JWT auth flow)
|
|
1935
|
-
|
|
1936
|
-
📦 Work archived: .ai-flow/archive/2025-01/feature-user-auth/
|
|
1937
|
-
|
|
1938
|
-
Next steps:
|
|
1939
|
-
1. Run tests: npm test
|
|
1940
|
-
2. Configure JWT secrets in .env
|
|
1941
|
-
3. Start server: npm run dev
|
|
1942
|
-
4. Test auth flow manually
|
|
1943
|
-
```
|
|
1944
|
-
|
|
199
|
+
📐 Technical Plan (LOADED from User Story HU-001-001)
|
|
1945
200
|
---
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
-
|
|
1960
|
-
|
|
1961
|
-
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
-
|
|
1966
|
-
|
|
1967
|
-
-
|
|
1968
|
-
|
|
1969
|
-
-
|
|
1970
|
-
|
|
201
|
+
✅ Story Points: 5 SP (from roadmap.md)
|
|
202
|
+
✅ Tasks: 6 technical tasks (inherited)
|
|
203
|
+
✅ Test Cases: 8 QA test cases (from acceptance criteria)
|
|
204
|
+
✅ Acceptance Criteria: 3 scenarios (Gherkin Given/When/Then)
|
|
205
|
+
|
|
206
|
+
**Tasks from User Story:** (execution order with hybrid estimation)
|
|
207
|
+
|
|
208
|
+
- [ ] [T-001-001] Write User entity tests • 1 SP (~1-2h)
|
|
209
|
+
File: tests/unit/User.spec.ts
|
|
210
|
+
Dependencies: None
|
|
211
|
+
|
|
212
|
+
- [ ] [T-001-002] Create User entity • 1 SP (~1-2h)
|
|
213
|
+
File: src/domain/entities/User.ts
|
|
214
|
+
Dependencies: T-001-001
|
|
215
|
+
|
|
216
|
+
- [ ] [T-001-003] Implement AuthService login method • 2 SP (~3-4h)
|
|
217
|
+
File: src/services/AuthService.ts
|
|
218
|
+
Dependencies: T-001-002
|
|
219
|
+
|
|
220
|
+
- [ ] [T-001-004] Create POST /api/auth/login endpoint • 1 SP (~1-2h)
|
|
221
|
+
File: src/controllers/AuthController.ts
|
|
222
|
+
Dependencies: T-001-003
|
|
223
|
+
|
|
224
|
+
- [ ] [T-001-005] Write integration tests • 2 SP (~3-4h)
|
|
225
|
+
File: tests/integration/auth.spec.ts
|
|
226
|
+
Dependencies: T-001-003
|
|
227
|
+
|
|
228
|
+
- [ ] [T-001-006] Validate against Definition of Done • trivial (~15 min)
|
|
229
|
+
- Code review approved
|
|
230
|
+
- Tests passing (unit + integration)
|
|
231
|
+
- QA test cases executed (8/8)
|
|
232
|
+
- Documentation updated
|
|
233
|
+
- Lint/format clean
|
|
234
|
+
Dependencies: T-001-005
|
|
235
|
+
|
|
236
|
+
**Acceptance Criteria Validation:**
|
|
237
|
+
|
|
238
|
+
Will verify implementation against:
|
|
239
|
+
|
|
240
|
+
✅ Scenario 1: Login exitoso
|
|
241
|
+
Dado que el usuario tiene credenciales válidas
|
|
242
|
+
Cuando ingresa email y contraseña correctos
|
|
243
|
+
Entonces recibe JWT token y accede al sistema
|
|
244
|
+
|
|
245
|
+
✅ Scenario 2: Credenciales inválidas
|
|
246
|
+
Dado que el usuario ingresa credenciales incorrectas
|
|
247
|
+
Cuando intenta iniciar sesión
|
|
248
|
+
Entonces recibe error 401 con mensaje claro
|
|
249
|
+
|
|
250
|
+
✅ Scenario 3: Rate limiting
|
|
251
|
+
Dado que el usuario falla login 5 veces en 15 minutos
|
|
252
|
+
Cuando intenta login nuevamente
|
|
253
|
+
Entonces recibe error 429 (Too Many Requests)
|
|
254
|
+
|
|
255
|
+
**QA Test Cases to Execute:**
|
|
256
|
+
|
|
257
|
+
After implementation, run 8 test cases:
|
|
258
|
+
- TC-001-001: Login exitoso (Happy Path)
|
|
259
|
+
- TC-001-002: Credenciales inválidas (Error Case)
|
|
260
|
+
- TC-001-003: Rate limiting (Edge Case)
|
|
261
|
+
- [... 5 more test cases from User Story]
|
|
262
|
+
|
|
263
|
+
Ready to implement? (Y/n)
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
**IF mode = `INTERACTIVE`:** _(Generate plan from scratch)_
|
|
267
|
+
|
|
268
|
+
Based on the project's detected stack and existing patterns, auto-generate a technical plan.
|
|
269
|
+
|
|
270
|
+
**Analyze:**
|
|
271
|
+
|
|
272
|
+
- Read `AGENT.md` and `ai-instructions.md` for project context
|
|
273
|
+
- Detect framework, ORM, and tech stack
|
|
274
|
+
- Identify existing code patterns
|
|
275
|
+
|
|
276
|
+
**Detect Complexity Automatically:**
|
|
277
|
+
|
|
278
|
+
Count total tasks needed based on spec. Then classify:
|
|
279
|
+
|
|
280
|
+
- **SIMPLE** (1-10 tasks): Single-phase implementation
|
|
281
|
+
- Small changes, 1-2 files, minimal dependencies
|
|
282
|
+
- Example: Add field to entity + update endpoint
|
|
283
|
+
- **MEDIUM** (11-40 tasks): 2-4 phases
|
|
284
|
+
- Multiple files, some cross-layer dependencies
|
|
285
|
+
- Example: New entity with CRUD + validation + tests
|
|
286
|
+
- **COMPLEX** (41-80 tasks): 4-8 phases
|
|
287
|
+
- Multiple modules, integration, extensive testing
|
|
288
|
+
- Example: Authentication system with multiple providers
|
|
289
|
+
- **LARGE** (81+ tasks): 8-N phases
|
|
290
|
+
- Feature affecting entire system, major refactoring
|
|
291
|
+
- Example: Multi-tenant architecture implementation
|
|
292
|
+
|
|
293
|
+
**Story Points Estimation (Fibonacci Scale):**
|
|
294
|
+
|
|
295
|
+
> 📎 **Reference:** See [prompts/shared/story-points.md](../shared/story-points.md) for the Fibonacci scale and hybrid time estimation guidelines.
|
|
296
|
+
|
|
297
|
+
### Story Points to Time Conversion (Hybrid Estimation)
|
|
298
|
+
|
|
299
|
+
**Use the reference above to add precise time estimates to each task.**
|
|
300
|
+
| **3 SP** | 4-8 hours | (~4-8h) | Simple CRUD endpoint, basic entity |
|
|
301
|
+
| **5 SP** | 1-2 days | (~1-2d) | Complex endpoint with business logic |
|
|
302
|
+
| **8 SP** | 2-3 days | (~2-3d) | Auth flow, complex validation |
|
|
303
|
+
| **13 SP** | 1 week | (~1w) | Complete module with full test coverage |
|
|
304
|
+
| **21 SP** | 2 weeks | (~2w) | Major feature with integration |
|
|
305
|
+
| **34 SP** | 3 weeks | (~3w) | Multiple related features (Epic-level) |
|
|
306
|
+
|
|
307
|
+
> **Note:** Time assumes AI-assisted development (Copilot/Claude). Without AI, multiply by 2-3x.
|
|
308
|
+
> For team velocity adjustment, track actual time vs estimates after 2-3 features.
|
|
309
|
+
|
|
310
|
+
### Task Format Reference (Spec-Kit Inspired)
|
|
311
|
+
|
|
312
|
+
**Every task must follow this format:**
|
|
313
|
+
|
|
314
|
+
```markdown
|
|
315
|
+
- [ ] [TaskID] [Optional:P] Description • SP (~time)
|
|
316
|
+
File: exact/path/to/file.ts
|
|
317
|
+
Dependencies: T001, T002 (or "None")
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
**Task Format & Sequencing:**
|
|
321
|
+
|
|
322
|
+
> 📎 **Reference:** See [prompts/shared/task-format.md](../shared/task-format.md) for the standard task structure, sequencing rules, and parallelization guidelines.
|
|
323
|
+
|
|
324
|
+
**Parallelization Rules ([P] marker):**
|
|
325
|
+
|
|
326
|
+
✅ **Use [P] when:**
|
|
327
|
+
|
|
328
|
+
- Tasks target different files
|
|
329
|
+
- No shared dependencies
|
|
330
|
+
- Can run simultaneously (e.g., independent entities, different test suites)
|
|
331
|
+
|
|
332
|
+
❌ **Don't use [P] when:**
|
|
333
|
+
|
|
334
|
+
- Task depends on another incomplete task
|
|
335
|
+
- Same file is modified
|
|
336
|
+
- Shared resource (DB migration, config file)
|
|
337
|
+
|
|
338
|
+
**Phase Structure (for MEDIUM/COMPLEX/LARGE):**
|
|
339
|
+
|
|
340
|
+
Organize tasks into logical phases:
|
|
341
|
+
|
|
342
|
+
1. **Data Layer** - Entities, migrations, repositories
|
|
343
|
+
2. **Business Logic** - Services, validation, business rules
|
|
344
|
+
3. **API Layer** - Controllers, routes, DTOs
|
|
345
|
+
4. **Integration** - Connect layers, middleware, error handling
|
|
346
|
+
5. **Testing** - Unit tests, integration tests, E2E tests
|
|
347
|
+
6. **Documentation** - Update docs, examples, deployment notes
|
|
348
|
+
|
|
349
|
+
**Show plan to user:**
|
|
350
|
+
|
|
351
|
+
- Technical decisions (libraries, patterns)
|
|
352
|
+
- Files to create/modify
|
|
353
|
+
- Tasks organized by phases (or flat list if SIMPLE)
|
|
354
|
+
- Dependencies between phases
|
|
355
|
+
- Estimated time per phase
|
|
356
|
+
|
|
357
|
+
**Generate:** `.ai-flow/work/NNN-feature-name/plan.md`
|
|
358
|
+
|
|
359
|
+
**Example:** `.ai-flow/work/003-user-authentication/plan.md`
|
|
360
|
+
|
|
361
|
+
**Example output (SIMPLE):**
|
|
362
|
+
|
|
363
|
+
```
|
|
1971
364
|
---
|
|
1972
|
-
|
|
1973
|
-
## Common Use Cases
|
|
1974
|
-
|
|
1975
|
-
### 1. Sprint Development (with User Stories)
|
|
1976
|
-
|
|
1977
|
-
```bash
|
|
1978
|
-
/feature HU-001-001 # Login: 5 SP, 1.5h
|
|
1979
|
-
/feature HU-001-002 # OAuth: 3 SP, 1h
|
|
1980
|
-
/feature HU-002-001 # User CRUD: 8 SP, 2h
|
|
1981
|
-
# Sprint: 16 SP in 4.5h
|
|
1982
|
-
```
|
|
1983
|
-
|
|
1984
|
-
### 2. Rapid Prototyping (with roadmap)
|
|
1985
|
-
|
|
1986
|
-
```bash
|
|
1987
|
-
/feature User Entity Repository # 12 SP
|
|
1988
|
-
/feature Product Entity Repository # 8 SP
|
|
1989
|
-
/feature Order Entity Repository # 5 SP
|
|
1990
|
-
# Data layer: 25 SP in ~2 days
|
|
1991
|
-
```
|
|
1992
|
-
|
|
1993
|
-
### 3. Feature Not Planned (interactive)
|
|
1994
|
-
|
|
1995
|
-
```bash
|
|
1996
|
-
/feature new
|
|
1997
|
-
# AI asks: What to build?
|
|
1998
|
-
> Real-time notifications with WebSockets
|
|
1999
|
-
# Generates: 24 tasks, 13 SP, ~3h
|
|
2000
|
-
```
|
|
2001
|
-
|
|
2002
|
-
### 4. Bug Fix or Quick Change
|
|
2003
|
-
|
|
2004
|
-
```bash
|
|
2005
|
-
/feature change
|
|
2006
|
-
# AI asks: What to modify?
|
|
2007
|
-
> Add rate limiting to login endpoint
|
|
2008
|
-
# Updates: middleware, tests, docs (~30 min)
|
|
2009
|
-
```
|
|
2010
|
-
|
|
2011
|
-
### 5. Code Quality Improvement
|
|
2012
|
-
|
|
2013
|
-
```bash
|
|
2014
|
-
/feature refactor
|
|
2015
|
-
# AI asks: What to refactor?
|
|
2016
|
-
> Extract duplicate validation logic to shared module
|
|
2017
|
-
# Refactors: 6 files, tests pass, docs updated (~1h)
|
|
2018
|
-
```
|
|
2019
|
-
|
|
365
|
+
📐 Technical Plan (auto-generated)
|
|
2020
366
|
---
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
367
|
+
Based on your project (Node.js + Express + PostgreSQL):
|
|
368
|
+
|
|
369
|
+
**Complexity:** SIMPLE (8 tasks) • 3 SP (~15-20 min)
|
|
370
|
+
⏱️ **Est. Time:** 15-20 minutes
|
|
371
|
+
|
|
372
|
+
**Stack decisions:**
|
|
373
|
+
- Validation: joi ⚡
|
|
374
|
+
|
|
375
|
+
**Files to modify:**
|
|
376
|
+
- src/entities/User.entity.ts
|
|
377
|
+
- src/controllers/UserController.ts
|
|
378
|
+
- tests/user.test.ts
|
|
379
|
+
|
|
380
|
+
**Tasks:** (execution order with hybrid estimation)
|
|
381
|
+
|
|
382
|
+
- [ ] [T001] Add email field to User entity • 1 SP (~1-2h)
|
|
383
|
+
File: src/entities/User.entity.ts
|
|
384
|
+
Dependencies: None
|
|
385
|
+
|
|
386
|
+
- [ ] [T002] Add migration for email column • 1 SP (~1h)
|
|
387
|
+
File: src/migrations/002_add_email_to_users.ts
|
|
388
|
+
Dependencies: T001 (needs entity schema)
|
|
389
|
+
|
|
390
|
+
- [ ] [T003] [P] Update UserController validation • 1 SP (~1h)
|
|
391
|
+
File: src/controllers/UserController.ts
|
|
392
|
+
Dependencies: T001 (needs entity field)
|
|
393
|
+
|
|
394
|
+
- [ ] [T004] [P] Update existing user tests • 1 SP (~1h)
|
|
395
|
+
File: tests/user.test.ts
|
|
396
|
+
Dependencies: T001 (can run parallel with T003)
|
|
397
|
+
|
|
398
|
+
- [ ] [T005] Add email validation tests • 1 SP (~1-2h)
|
|
399
|
+
File: tests/user.test.ts
|
|
400
|
+
Dependencies: T003 (needs controller validation)
|
|
401
|
+
|
|
402
|
+
- [ ] [T006] [P] Update API documentation • trivial (~15 min)
|
|
403
|
+
File: docs/api.md
|
|
404
|
+
Dependencies: None (can run parallel)
|
|
405
|
+
|
|
406
|
+
- [ ] [T007] [P] Update data model documentation • trivial (~15 min)
|
|
407
|
+
File: docs/data-model.md
|
|
408
|
+
Dependencies: None (can run parallel)
|
|
409
|
+
|
|
410
|
+
- [ ] [T008] Test endpoint manually • trivial (~10 min)
|
|
411
|
+
Dependencies: T005 (needs all code complete)
|
|
412
|
+
|
|
413
|
+
**Parallelization Notes:**
|
|
414
|
+
- T003 and T004 can run in parallel (different concerns)
|
|
415
|
+
- T006 and T007 can run in parallel (different docs)
|
|
416
|
+
|
|
417
|
+
**Total:** 3 SP (~15-20 min with AI assistance)
|
|
418
|
+
|
|
419
|
+
Review plan? (Y/n)
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
**Example output (COMPLEX):**
|
|
423
|
+
|
|
424
|
+
```
|
|
2030
425
|
---
|
|
2031
|
-
|
|
2032
|
-
|
|
426
|
+
📐 Technical Plan (auto-generated)
|
|
427
|
+
---
|
|
428
|
+
Based on your project (Node.js + Express + PostgreSQL):
|
|
429
|
+
|
|
430
|
+
**Complexity:** COMPLEX (52 tasks across 5 phases) • 34 SP (~2-3 hours)
|
|
431
|
+
⏱️ **Est. Time:** 2-3 hours (with AI assistance)
|
|
432
|
+
|
|
433
|
+
**Stack decisions:**
|
|
434
|
+
- Auth: JWT with jsonwebtoken ⭐
|
|
435
|
+
- Validation: joi ⚡
|
|
436
|
+
- Email: nodemailer 📧
|
|
437
|
+
|
|
438
|
+
## Phase 1: Data Layer • 8 SP (~30-40 min)
|
|
439
|
+
|
|
440
|
+
**Tasks:** (Test-First approach, execution order)
|
|
441
|
+
|
|
442
|
+
- [ ] [T001] [P] Write unit tests for User entity (8 tests) • 2 SP (~3-4h)
|
|
443
|
+
File: tests/unit/entities/User.entity.spec.ts
|
|
444
|
+
Tests: email format, password hashing, role validation, timestamps
|
|
445
|
+
Dependencies: None (can run parallel with T003, T005)
|
|
446
|
+
|
|
447
|
+
- [ ] [T002] Create User entity with validation • 2 SP (~3-4h)
|
|
448
|
+
File: src/entities/User.entity.ts
|
|
449
|
+
Implements: Email regex, password bcrypt, role enum, timestamps
|
|
450
|
+
Dependencies: None
|
|
451
|
+
|
|
452
|
+
- [ ] [T003] [P] Write unit tests for Session entity (4 tests) • 1 SP (~1-2h)
|
|
453
|
+
File: tests/unit/entities/Session.entity.spec.ts
|
|
454
|
+
Tests: session creation, expiration, invalidation
|
|
455
|
+
Dependencies: None (can run parallel with T001)
|
|
456
|
+
|
|
457
|
+
- [ ] [T004] Create Session entity • 1 SP (~1-2h)
|
|
458
|
+
File: src/entities/Session.entity.ts
|
|
459
|
+
Implements: User FK, token, expiration, status
|
|
460
|
+
Dependencies: T002 (needs User entity)
|
|
461
|
+
|
|
462
|
+
- [ ] [T005] [P] Write unit tests for RefreshToken entity (4 tests) • 1 SP (~1-2h)
|
|
463
|
+
File: tests/unit/entities/RefreshToken.entity.spec.ts
|
|
464
|
+
Tests: token generation, rotation, revocation
|
|
465
|
+
Dependencies: None (can run parallel with T001, T003)
|
|
466
|
+
|
|
467
|
+
- [ ] [T006] Create RefreshToken entity • 1 SP (~1-2h)
|
|
468
|
+
File: src/entities/RefreshToken.entity.ts
|
|
469
|
+
Implements: User FK, token, expiration, rotation tracking
|
|
470
|
+
Dependencies: T002 (needs User entity)
|
|
471
|
+
|
|
472
|
+
- [ ] [T007] Create database migrations • 1 SP (~1-2h)
|
|
473
|
+
File: src/migrations/001_create_auth_tables.ts
|
|
474
|
+
Creates: users, sessions, refresh_tokens tables with indexes
|
|
475
|
+
Dependencies: T002, T004, T006 (needs all entity schemas)
|
|
476
|
+
|
|
477
|
+
- [ ] [T008] Create IUserRepository interface • 1 SP (~1h)
|
|
478
|
+
File: src/repositories/interfaces/IUserRepository.ts
|
|
479
|
+
Methods: create, findById, findByEmail, update, delete
|
|
480
|
+
Dependencies: T002 (needs User entity type)
|
|
481
|
+
|
|
482
|
+
- [ ] [T009] Implement UserRepository • 1 SP (~1-2h)
|
|
483
|
+
File: src/repositories/UserRepository.ts
|
|
484
|
+
Implements: All CRUD methods from IUserRepository
|
|
485
|
+
Dependencies: T002, T008
|
|
486
|
+
|
|
487
|
+
- [ ] [T010] Create SessionRepository • 1 SP (~1h)
|
|
488
|
+
File: src/repositories/SessionRepository.ts
|
|
489
|
+
Methods: create, findByToken, invalidate, findActiveByUser
|
|
490
|
+
Dependencies: T004 (needs Session entity)
|
|
491
|
+
|
|
492
|
+
- [ ] [T011] Create RefreshTokenRepository • 1 SP (~1h)
|
|
493
|
+
File: src/repositories/RefreshTokenRepository.ts
|
|
494
|
+
Methods: create, findByToken, revoke, rotateToken
|
|
495
|
+
Dependencies: T006 (needs RefreshToken entity)
|
|
496
|
+
|
|
497
|
+
**Task Execution Graph (Phase 1):**
|
|
498
|
+
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
T001 [P] ──┐
|
|
502
|
+
T003 [P] ──┼──> (Tests can run parallel)
|
|
503
|
+
T005 [P] ──┘
|
|
504
|
+
|
|
505
|
+
T002 ──┬──> T004
|
|
506
|
+
├──> T006
|
|
507
|
+
├──> T007 (needs T002, T004, T006)
|
|
508
|
+
├──> T008 ──> T009
|
|
509
|
+
│
|
|
510
|
+
└──> T010 (needs T004)
|
|
511
|
+
T011 (needs T006)
|
|
512
|
+
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
**Parallelization Notes (Phase 1):**
|
|
516
|
+
- T001, T003, T005 can run in parallel (different test files)
|
|
517
|
+
- T002 is foundational (blocks T004, T006, T008, T009)
|
|
518
|
+
- T010 and T011 can run in parallel after T004/T006 complete
|
|
519
|
+
|
|
520
|
+
## Phase 2: Business Logic • 13 SP (~50-60 min)
|
|
521
|
+
|
|
522
|
+
**Tasks:**
|
|
523
|
+
|
|
524
|
+
- [ ] [T012] [P] Write unit tests for AuthService (12 tests) • 3 SP (~4-8h)
|
|
525
|
+
File: tests/unit/services/AuthService.spec.ts
|
|
526
|
+
Tests: register, login, logout, refresh, email verification
|
|
527
|
+
Dependencies: None (can run parallel with T014, T016)
|
|
528
|
+
|
|
529
|
+
- [ ] [T013] Create AuthService • 3 SP (~4-8h)
|
|
530
|
+
File: src/services/AuthService.ts
|
|
531
|
+
Implements: register, login, logout, refresh, verify email
|
|
532
|
+
Dependencies: T009, T010, T011 (needs all repositories)
|
|
533
|
+
|
|
534
|
+
- [ ] [T014] [P] Write unit tests for TokenService (8 tests) • 2 SP (~3-4h)
|
|
535
|
+
File: tests/unit/services/TokenService.spec.ts
|
|
536
|
+
Tests: JWT generation, verification, refresh token rotation
|
|
537
|
+
Dependencies: None (can run parallel with T012)
|
|
538
|
+
|
|
539
|
+
- [ ] [T015] Create TokenService • 2 SP (~3-4h)
|
|
540
|
+
File: src/services/TokenService.ts
|
|
541
|
+
Implements: generateAccessToken, generateRefreshToken, verifyToken
|
|
542
|
+
Dependencies: None (utility service)
|
|
543
|
+
|
|
544
|
+
- [ ] [T016] [P] Write unit tests for EmailService (6 tests) • 2 SP (~3-4h)
|
|
545
|
+
File: tests/unit/services/EmailService.spec.ts
|
|
546
|
+
Tests: send verification email, send password reset
|
|
547
|
+
Dependencies: None (can run parallel with T012, T014)
|
|
548
|
+
|
|
549
|
+
- [ ] [T017] Create EmailService • 2 SP (~3-4h)
|
|
550
|
+
File: src/services/EmailService.ts
|
|
551
|
+
Implements: sendVerificationEmail, sendPasswordResetEmail
|
|
552
|
+
Dependencies: None (3rd party wrapper)
|
|
553
|
+
|
|
554
|
+
- [ ] [T018] Implement password hashing utility • 1 SP (~1-2h)
|
|
555
|
+
File: src/utils/password.util.ts
|
|
556
|
+
Implements: hashPassword, comparePassword using bcrypt
|
|
557
|
+
Dependencies: None
|
|
558
|
+
|
|
559
|
+
- [ ] [T019] Implement JWT generation logic • 2 SP (~3-4h)
|
|
560
|
+
File: src/utils/jwt.util.ts
|
|
561
|
+
Implements: sign, verify, decode JWT with RS256
|
|
562
|
+
Dependencies: None
|
|
563
|
+
|
|
564
|
+
- [ ] [T020] Implement refresh token rotation • 2 SP (~3-4h)
|
|
565
|
+
File: src/utils/token-rotation.util.ts
|
|
566
|
+
Implements: rotation detection, security checks
|
|
567
|
+
Dependencies: T015 (needs TokenService)
|
|
568
|
+
|
|
569
|
+
- [ ] [T021] Implement email verification flow • 1 SP (~1-2h)
|
|
570
|
+
File: src/services/EmailVerificationService.ts
|
|
571
|
+
Implements: generate verification token, verify token
|
|
572
|
+
Dependencies: T017 (needs EmailService)
|
|
573
|
+
|
|
574
|
+
**Task Execution Graph (Phase 2):**
|
|
575
|
+
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
T012 [P] ──┐
|
|
579
|
+
T014 [P] ──┼──> (Test suites can run parallel)
|
|
580
|
+
T016 [P] ──┘
|
|
581
|
+
|
|
582
|
+
T009, T010, T011 (from Phase 1) ──> T013 (AuthService)
|
|
583
|
+
|
|
584
|
+
T015 (TokenService) ──> T020 (Token rotation)
|
|
585
|
+
T017 (EmailService) ──> T021 (Email verification)
|
|
586
|
+
T018 (Password utils) ──> T013 (used by AuthService)
|
|
587
|
+
T019 (JWT utils) ──> T013 (used by AuthService)
|
|
588
|
+
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
**Parallelization Notes (Phase 2):**
|
|
592
|
+
- All test tasks (T012, T014, T016) can run in parallel
|
|
593
|
+
- T015, T017, T018, T019 can run in parallel (independent utilities)
|
|
594
|
+
- T013 blocks on T009, T010, T011 from Phase 1
|
|
595
|
+
|
|
596
|
+
## Phase 3: API Layer • 8 SP (~30-40 min)
|
|
597
|
+
|
|
598
|
+
**Tasks:**
|
|
599
|
+
|
|
600
|
+
- [ ] [T022] [P] Write integration tests for AuthController (10 tests) • 3 SP (~4-8h)
|
|
601
|
+
File: tests/integration/controllers/AuthController.spec.ts
|
|
602
|
+
Tests: POST /register, POST /login, POST /refresh, POST /logout
|
|
603
|
+
Dependencies: None (can run parallel with T024)
|
|
604
|
+
|
|
605
|
+
- [ ] [T023] Create AuthController • 3 SP (~4-8h)
|
|
606
|
+
File: src/controllers/AuthController.ts
|
|
607
|
+
Implements: register, login, refresh, logout, verifyEmail endpoints
|
|
608
|
+
Dependencies: T013 (needs AuthService)
|
|
609
|
+
|
|
610
|
+
- [ ] [T024] [P] Write unit tests for auth middleware (6 tests) • 2 SP (~3-4h)
|
|
611
|
+
File: tests/unit/middleware/auth.middleware.spec.ts
|
|
612
|
+
Tests: JWT verification, token extraction, error handling
|
|
613
|
+
Dependencies: None (can run parallel with T022)
|
|
614
|
+
|
|
615
|
+
- [ ] [T025] Create auth middleware • 2 SP (~3-4h)
|
|
616
|
+
File: src/middleware/auth.middleware.ts
|
|
617
|
+
Implements: requireAuth, optionalAuth, requireRole
|
|
618
|
+
Dependencies: T015 (needs TokenService)
|
|
619
|
+
|
|
620
|
+
- [ ] [T026] Create validation schemas • 1 SP (~1-2h)
|
|
621
|
+
File: src/validators/auth.validators.ts
|
|
622
|
+
Implements: Joi schemas for register, login, refresh payloads
|
|
623
|
+
Dependencies: None
|
|
624
|
+
|
|
625
|
+
- [ ] [T027] Create DTOs • 1 SP (~1-2h)
|
|
626
|
+
File: src/dtos/auth.dto.ts
|
|
627
|
+
Implements: RegisterDTO, LoginDTO, AuthResponseDTO
|
|
628
|
+
Dependencies: None
|
|
629
|
+
|
|
630
|
+
- [ ] [T028] Setup auth routes • 1 SP (~1h)
|
|
631
|
+
File: src/routes/auth.routes.ts
|
|
632
|
+
Implements: Route registration with validation and middleware
|
|
633
|
+
Dependencies: T023, T025, T026 (needs controller, middleware, validators)
|
|
634
|
+
|
|
635
|
+
**Task Execution Graph (Phase 3):**
|
|
636
|
+
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
T022 [P] ──┐
|
|
640
|
+
T024 [P] ──┘──> (Test suites can run parallel)
|
|
641
|
+
|
|
642
|
+
T013 (AuthService) ──> T023 (AuthController)
|
|
643
|
+
T015 (TokenService) ──> T025 (Auth middleware)
|
|
644
|
+
|
|
645
|
+
T026 (Validators) ──┐
|
|
646
|
+
T027 (DTOs) ├──> T028 (Routes)
|
|
647
|
+
T023 (Controller) ┘
|
|
648
|
+
T025 (Middleware) ─┘
|
|
649
|
+
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
## Phase 4: Integration • 3 SP (~15-20 min)
|
|
653
|
+
|
|
654
|
+
**Tasks:**
|
|
655
|
+
|
|
656
|
+
- [ ] [T029] Connect services to controllers • 1 SP (~1-2h)
|
|
657
|
+
File: src/app.ts
|
|
658
|
+
Implements: Dependency injection setup for controllers
|
|
659
|
+
Dependencies: T023 (needs AuthController)
|
|
660
|
+
|
|
661
|
+
- [ ] [T030] Add global error handling middleware • 1 SP (~1-2h)
|
|
662
|
+
File: src/middleware/error.middleware.ts
|
|
663
|
+
Implements: Catch all errors, format responses, log errors
|
|
664
|
+
Dependencies: None
|
|
665
|
+
|
|
666
|
+
- [ ] [T031] Configure CORS and security headers • 1 SP (~1h)
|
|
667
|
+
File: src/middleware/security.middleware.ts
|
|
668
|
+
Implements: CORS config, Helmet setup, rate limiting
|
|
669
|
+
Dependencies: None
|
|
670
|
+
|
|
671
|
+
- [ ] [T032] Register auth routes in main app • trivial (~30 min)
|
|
672
|
+
File: src/app.ts
|
|
673
|
+
Implements: app.use('/api/auth', authRoutes)
|
|
674
|
+
Dependencies: T028 (needs auth routes)
|
|
675
|
+
|
|
676
|
+
- [ ] [T033] Add environment variable validation • 1 SP (~1h)
|
|
677
|
+
File: src/config/env.validation.ts
|
|
678
|
+
Implements: Validate JWT_SECRET, DATABASE_URL, EMAIL config
|
|
679
|
+
Dependencies: None
|
|
680
|
+
|
|
681
|
+
**Task Execution Graph (Phase 4):**
|
|
682
|
+
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
T030, T031, T033 [P] ──> (Can run parallel - different concerns)
|
|
686
|
+
|
|
687
|
+
T028 ──> T029 ──> T032 (Sequential: routes → DI → registration)
|
|
688
|
+
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
## Phase 5: Testing & Docs • 2 SP (~10-15 min)
|
|
692
|
+
|
|
693
|
+
**Tasks:**
|
|
694
|
+
|
|
695
|
+
- [ ] [T034] Run full test suite and fix issues • 1 SP (~1-2h)
|
|
696
|
+
File: N/A (command: npm test)
|
|
697
|
+
Validates: All 47 tests passing, coverage ≥ 80%
|
|
698
|
+
Dependencies: T001-T033 (needs all tests written)
|
|
699
|
+
|
|
700
|
+
- [ ] [T035] Integration test for complete auth flow • 1 SP (~1-2h)
|
|
701
|
+
File: tests/integration/auth-flow.spec.ts
|
|
702
|
+
Tests: Full flow from register → login → refresh → logout
|
|
703
|
+
Dependencies: T034 (needs all individual tests passing)
|
|
704
|
+
|
|
705
|
+
- [ ] [T036] [P] Update API documentation • trivial (~20 min)
|
|
706
|
+
File: docs/api.md
|
|
707
|
+
Updates: Add 5 auth endpoints with request/response examples
|
|
708
|
+
Dependencies: None (can run parallel with T037, T038)
|
|
709
|
+
|
|
710
|
+
- [ ] [T037] [P] Update data model documentation • trivial (~15 min)
|
|
711
|
+
File: docs/data-model.md
|
|
712
|
+
Updates: Add User, Session, RefreshToken entities with relationships
|
|
713
|
+
Dependencies: None (can run parallel with T036, T038)
|
|
714
|
+
|
|
715
|
+
- [ ] [T038] [P] Update security documentation • trivial (~15 min)
|
|
716
|
+
File: specs/security.md
|
|
717
|
+
Updates: Document JWT flow, refresh token rotation, password policy
|
|
718
|
+
Dependencies: None (can run parallel with T036, T037)
|
|
719
|
+
|
|
720
|
+
- [ ] [T039] Add environment variables to .env.example • trivial (~10 min)
|
|
721
|
+
File: .env.example
|
|
722
|
+
Updates: Add JWT_SECRET, JWT_EXPIRATION, REFRESH_TOKEN_EXPIRATION
|
|
723
|
+
Dependencies: None
|
|
724
|
+
|
|
725
|
+
**Task Execution Graph (Phase 5):**
|
|
726
|
+
|
|
727
|
+
```
|
|
728
|
+
|
|
729
|
+
T001-T033 ──> T034 (Run all tests) ──> T035 (E2E flow test)
|
|
730
|
+
|
|
731
|
+
T036 [P] ──┐
|
|
732
|
+
T037 [P] ──┼──> (Documentation updates can run parallel)
|
|
733
|
+
T038 [P] ──┘
|
|
734
|
+
|
|
735
|
+
T039 (env example) ──> (Independent, can run anytime)
|
|
736
|
+
|
|
737
|
+
```
|
|
738
|
+
|
|
739
|
+
**Parallelization Notes (Phase 5):**
|
|
740
|
+
- All documentation tasks (T036, T037, T038) can run in parallel
|
|
741
|
+
- T034 must complete before T035 (E2E depends on unit/integration tests)
|
|
742
|
+
- T039 is independent and can run anytime
|
|
743
|
+
---
|
|
744
|
+
**Total:** 34 SP • 39 tasks • ~2-3 hours with AI assistance
|
|
745
|
+
---
|
|
746
|
+
**Parallelization Summary:**
|
|
747
|
+
- ✅ Phase 1: 3 test tasks parallel (T001, T003, T005)
|
|
748
|
+
- ✅ Phase 2: 3 test tasks + 4 utility tasks parallel
|
|
749
|
+
- ✅ Phase 3: 2 test tasks parallel (T022, T024)
|
|
750
|
+
- ✅ Phase 4: 3 tasks parallel (T030, T031, T033)
|
|
751
|
+
- ✅ Phase 5: 3 documentation tasks parallel (T036, T037, T038)
|
|
752
|
+
- ⚡ With 2 devs: ~40% time savings via parallelization
|
|
753
|
+
- ⚡ With 3 devs: ~50% time savings via parallelization
|
|
754
|
+
|
|
755
|
+
Review plan? (Y/n)
|
|
756
|
+
```
|
|
757
|
+
---
|
|
758
|
+
### Phase 0.5: Git Branch Setup (Optional, 30 seconds)
|
|
759
|
+
|
|
760
|
+
**After user confirms plan, detect Git repository:**
|
|
761
|
+
|
|
762
|
+
```bash
|
|
763
|
+
git rev-parse --git-dir 2>/dev/null
|
|
764
|
+
```
|
|
765
|
+
|
|
766
|
+
**If NO Git repository found:**
|
|
767
|
+
|
|
768
|
+
```
|
|
769
|
+
ℹ️ No Git repository detected
|
|
770
|
+
|
|
771
|
+
Git integration is disabled for this session.
|
|
772
|
+
To enable Git features, initialize a repository first:
|
|
773
|
+
git init
|
|
774
|
+
git remote add origin <url>
|
|
775
|
+
|
|
776
|
+
Continue without Git? (Y/n)
|
|
777
|
+
```
|
|
778
|
+
|
|
779
|
+
**If Git repository detected:**
|
|
780
|
+
|
|
781
|
+
```
|
|
782
|
+
---
|
|
783
|
+
🌿 Git Integration
|
|
784
|
+
---
|
|
785
|
+
Git repository detected ✅
|
|
786
|
+
Current branch: main
|
|
787
|
+
Status: clean
|
|
788
|
+
|
|
789
|
+
Feature: notifications-websocket
|
|
790
|
+
Suggested branch: feature/notifications-websocket
|
|
791
|
+
|
|
792
|
+
Create new branch and enable Git integration?
|
|
793
|
+
|
|
794
|
+
A) ⭐ Yes - Create branch + auto-commit per phase (Recommended for MEDIUM/COMPLEX/LARGE)
|
|
795
|
+
B) Yes - Create branch + single commit at end (Good for SIMPLE)
|
|
796
|
+
C) Work on current branch (no branch creation)
|
|
797
|
+
D) Skip Git integration (work without commits)
|
|
798
|
+
|
|
799
|
+
Your choice (A): __
|
|
800
|
+
```
|
|
801
|
+
|
|
802
|
+
**Smart defaults based on complexity:**
|
|
803
|
+
|
|
804
|
+
- **SIMPLE** (1-10 tasks) → Suggest **Option B** (single commit at end)
|
|
805
|
+
- **MEDIUM/COMPLEX/LARGE** (11+ tasks) → Suggest **Option A** (commit per phase)
|
|
806
|
+
|
|
807
|
+
**Edge Case 1: Uncommitted Changes Detected**
|
|
808
|
+
|
|
809
|
+
```bash
|
|
810
|
+
git status --porcelain
|
|
811
|
+
```
|
|
812
|
+
|
|
813
|
+
If output is non-empty:
|
|
814
|
+
|
|
815
|
+
```
|
|
816
|
+
⚠️ Uncommitted changes detected:
|
|
817
|
+
|
|
818
|
+
M src/controllers/UserController.ts
|
|
819
|
+
M src/services/AuthService.ts
|
|
820
|
+
?? new-file.ts
|
|
821
|
+
|
|
822
|
+
Options:
|
|
823
|
+
A) Stash changes and proceed (git stash)
|
|
824
|
+
B) Commit changes first (I'll guide you)
|
|
825
|
+
C) Continue anyway (changes will be included)
|
|
826
|
+
D) Cancel workflow
|
|
827
|
+
|
|
828
|
+
Your choice (A): __
|
|
829
|
+
```
|
|
830
|
+
|
|
831
|
+
**If A selected:** `git stash && git stash list` → Show stash confirmation
|
|
832
|
+
**If B selected:** Guide conventional commit, then continue
|
|
833
|
+
**If D selected:** Exit workflow
|
|
834
|
+
|
|
835
|
+
**Edge Case 2: Already on Feature Branch**
|
|
836
|
+
|
|
837
|
+
```bash
|
|
838
|
+
git rev-parse --abbrev-ref HEAD
|
|
839
|
+
```
|
|
840
|
+
|
|
841
|
+
If result starts with `feature/`, `fix/`, or `refactor/`:
|
|
842
|
+
|
|
843
|
+
```
|
|
844
|
+
⚠️ You're currently on branch: feature/other-work
|
|
845
|
+
|
|
846
|
+
Options:
|
|
847
|
+
A) Continue on this branch (may mix work)
|
|
848
|
+
B) Create new branch from current (branch off)
|
|
849
|
+
C) Switch to main/develop first (recommended)
|
|
850
|
+
D) Skip Git integration
|
|
851
|
+
|
|
852
|
+
Your choice (C): __
|
|
853
|
+
```
|
|
854
|
+
|
|
855
|
+
**If C selected:** `git checkout main` → Then proceed with branch creation
|
|
856
|
+
|
|
857
|
+
**Edge Case 3: Branch Name Already Exists**
|
|
858
|
+
|
|
859
|
+
```bash
|
|
860
|
+
git show-ref --verify --quiet refs/heads/feature/notifications-websocket
|
|
861
|
+
```
|
|
862
|
+
|
|
863
|
+
If exists:
|
|
864
|
+
|
|
865
|
+
```
|
|
866
|
+
⚠️ Branch 'feature/notifications-websocket' already exists
|
|
867
|
+
|
|
868
|
+
Options:
|
|
869
|
+
A) Use different name (feature/notifications-websocket-v2)
|
|
870
|
+
B) Checkout existing branch (continue previous work)
|
|
871
|
+
C) Skip Git integration
|
|
872
|
+
|
|
873
|
+
Your choice (A): __
|
|
874
|
+
```
|
|
875
|
+
|
|
876
|
+
**Edge Case 4: Detached HEAD State**
|
|
877
|
+
|
|
878
|
+
```bash
|
|
879
|
+
git symbolic-ref -q HEAD || echo "detached"
|
|
880
|
+
```
|
|
881
|
+
|
|
882
|
+
If detached:
|
|
883
|
+
|
|
884
|
+
```
|
|
885
|
+
⚠️ Detached HEAD state detected
|
|
886
|
+
|
|
887
|
+
You're not on a branch. Git integration requires a branch.
|
|
888
|
+
|
|
889
|
+
Options:
|
|
890
|
+
A) Create new branch here (git checkout -b feature/notifications)
|
|
891
|
+
B) Go back to previous branch (git checkout -)
|
|
892
|
+
C) Switch to main (git checkout main)
|
|
893
|
+
D) Skip Git integration
|
|
894
|
+
|
|
895
|
+
Your choice (C): __
|
|
896
|
+
```
|
|
897
|
+
|
|
898
|
+
**Actions if user enables Git integration (Options A or B):**
|
|
899
|
+
|
|
900
|
+
1. **Create branch:**
|
|
901
|
+
|
|
902
|
+
```bash
|
|
903
|
+
git checkout -b feature/notifications-websocket
|
|
904
|
+
```
|
|
905
|
+
|
|
906
|
+
2. **Update status.json:**
|
|
907
|
+
|
|
908
|
+
```json
|
|
909
|
+
{
|
|
910
|
+
"git": {
|
|
911
|
+
"enabled": true,
|
|
912
|
+
"autoCommit": "phase" | "end", // Based on user choice A or B
|
|
913
|
+
"branchCreated": true,
|
|
914
|
+
"branchName": "feature/notifications-websocket",
|
|
915
|
+
"sourceBranch": "main",
|
|
916
|
+
"commits": [],
|
|
917
|
+
"lastCommitSha": null,
|
|
918
|
+
"uncommittedChanges": false,
|
|
919
|
+
"readyForPR": false,
|
|
920
|
+
"prSuggested": false
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
```
|
|
924
|
+
|
|
925
|
+
3. **Show confirmation:**
|
|
926
|
+
|
|
927
|
+
```
|
|
928
|
+
✅ Branch created: feature/notifications-websocket
|
|
929
|
+
📦 Git commits will be created: per phase
|
|
930
|
+
|
|
931
|
+
Proceeding to implementation...
|
|
932
|
+
```
|
|
933
|
+
|
|
934
|
+
**If user skips Git (Options C or D):**
|
|
935
|
+
|
|
936
|
+
```json
|
|
937
|
+
{
|
|
938
|
+
"git": {
|
|
939
|
+
"enabled": false
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
```
|
|
943
|
+
---
|
|
944
|
+
### Phase 3: Progressive Implementation (10-15 minutes)
|
|
945
|
+
|
|
946
|
+
**STEP 3.1: Choose Implementation Mode**
|
|
947
|
+
|
|
948
|
+
After user confirms plan (Review plan? Y), suggest smart default based on complexity:
|
|
949
|
+
|
|
950
|
+
**Smart Defaults:**
|
|
951
|
+
|
|
952
|
+
- **SIMPLE** → Mode 1 (Auto) - Fast, no pauses needed
|
|
953
|
+
- **MEDIUM** → Mode 2 (Phase-by-phase) - Balanced control
|
|
954
|
+
- **COMPLEX/LARGE** → Mode 2 (Phase-by-phase) - Review between phases
|
|
955
|
+
|
|
956
|
+
Ask with recommended default:
|
|
957
|
+
|
|
958
|
+
```
|
|
959
|
+
---
|
|
960
|
+
⚙️ Implementation Mode
|
|
961
|
+
---
|
|
962
|
+
Recommended: Phase-by-phase (based on COMPLEX feature)
|
|
963
|
+
|
|
964
|
+
How do you want to proceed?
|
|
965
|
+
|
|
966
|
+
1. 🚀 Auto (implement all tasks automatically)
|
|
967
|
+
2. 📋 Phase-by-phase (pause after each phase for review) ⭐ RECOMMENDED
|
|
968
|
+
3. 🔍 Task-by-task (manual approval for each task)
|
|
969
|
+
4. 💾 Save and resume later
|
|
970
|
+
|
|
971
|
+
Your choice (2): [1/2/3/4]
|
|
972
|
+
```
|
|
973
|
+
|
|
974
|
+
**Note:** User can override recommended mode by typing different number, or press Enter to accept default.
|
|
975
|
+
|
|
976
|
+
**STEP 3.2: Execute Based on Mode**
|
|
977
|
+
|
|
978
|
+
#### Mode 1: Auto (Default for SIMPLE features)
|
|
979
|
+
|
|
980
|
+
Execute all tasks automatically with progress updates:
|
|
981
|
+
|
|
982
|
+
```
|
|
983
|
+
---
|
|
984
|
+
⚙️ Implementation (Auto Mode)
|
|
985
|
+
---
|
|
986
|
+
Task 1/12: Create User entity ✅
|
|
987
|
+
Task 2/12: Create AuthService ✅
|
|
988
|
+
Task 3/12: Create AuthController ✅
|
|
989
|
+
...
|
|
990
|
+
Task 12/12: Update documentation ✅
|
|
991
|
+
|
|
992
|
+
All tasks completed! ✅
|
|
993
|
+
```
|
|
994
|
+
|
|
995
|
+
#### Mode 2: Phase-by-phase (Recommended for COMPLEX features)
|
|
996
|
+
|
|
997
|
+
Execute one phase at a time, pause for review:
|
|
998
|
+
|
|
999
|
+
```
|
|
1000
|
+
---
|
|
1001
|
+
⚙️ Implementation (Phase-by-phase Mode)
|
|
1002
|
+
---
|
|
1003
|
+
PHASE 1/5: Data Layer
|
|
1004
|
+
├── Task 1.1: Create User entity ✅
|
|
1005
|
+
├── Task 1.2: Create Session entity ✅
|
|
1006
|
+
├── Task 1.3: Create RefreshToken entity ✅
|
|
1007
|
+
├── Task 1.4: Create migrations ✅
|
|
1008
|
+
├── Task 1.5: Create UserRepository ✅
|
|
1009
|
+
└── ... (5 more tasks) ✅
|
|
1010
|
+
---
|
|
1011
|
+
✅ Phase 1 Complete (10/10 tasks)
|
|
1012
|
+
---
|
|
1013
|
+
📁 Files created:
|
|
1014
|
+
- src/entities/User.entity.ts
|
|
1015
|
+
- src/entities/Session.entity.ts
|
|
1016
|
+
- src/entities/RefreshToken.entity.ts
|
|
1017
|
+
- src/migrations/001_create_auth_tables.ts
|
|
1018
|
+
- src/repositories/UserRepository.ts
|
|
1019
|
+
|
|
1020
|
+
**If git.enabled === true AND git.autoCommit === "phase":**
|
|
1021
|
+
|
|
1022
|
+
**Pre-commit Validation:**
|
|
1023
|
+
|
|
1024
|
+
```
|
|
1025
|
+
|
|
1026
|
+
🔍 Running pre-commit checks...
|
|
1027
|
+
✅ Lint passed (eslint --fix applied)
|
|
1028
|
+
✅ Tests passed (24/24, +10 new tests)
|
|
1029
|
+
✅ Type check passed
|
|
1030
|
+
|
|
1031
|
+
```
|
|
1032
|
+
|
|
1033
|
+
**If validation FAILS:**
|
|
1034
|
+
|
|
1035
|
+
```
|
|
1036
|
+
|
|
1037
|
+
❌ Pre-commit checks failed:
|
|
1038
|
+
|
|
1039
|
+
Lint errors (2):
|
|
1040
|
+
|
|
1041
|
+
- src/entities/User.entity.ts:15 - Missing semicolon
|
|
1042
|
+
- src/entities/Session.entity.ts:22 - Unused import
|
|
1043
|
+
|
|
1044
|
+
Options:
|
|
1045
|
+
A) Fix issues automatically and retry
|
|
1046
|
+
B) Skip commit (continue without committing)
|
|
1047
|
+
C) Show errors and let me fix manually
|
|
1048
|
+
D) Force commit anyway (not recommended)
|
|
1049
|
+
|
|
1050
|
+
Your choice (A): \_\_
|
|
1051
|
+
|
|
1052
|
+
```
|
|
1053
|
+
|
|
1054
|
+
**If option A:** Run fixes, re-validate, continue
|
|
1055
|
+
**If option B:** Skip commit, set `uncommittedChanges: true`
|
|
1056
|
+
**If option C:** Show errors, pause workflow
|
|
1057
|
+
**If option D:** Commit with `--no-verify`
|
|
1058
|
+
|
|
1059
|
+
**If validation PASSES:**
|
|
1060
|
+
|
|
1061
|
+
```
|
|
1062
|
+
|
|
1063
|
+
📦 Creating commit for Phase 1...
|
|
1064
|
+
|
|
1065
|
+
Conventional Commit:
|
|
1066
|
+
Type: feat
|
|
1067
|
+
Scope: entities
|
|
1068
|
+
Subject: add authentication entities and migrations
|
|
1069
|
+
|
|
1070
|
+
Generated commit message:
|
|
1071
|
+
───────────────────────────────────────────────────────
|
|
1072
|
+
feat(entities): add authentication entities and migrations
|
|
1073
|
+
|
|
1074
|
+
- Create User entity with email verification
|
|
1075
|
+
- Create Session entity for active sessions tracking
|
|
1076
|
+
- Create RefreshToken entity with rotation support
|
|
1077
|
+
- Add migrations for auth tables
|
|
1078
|
+
- Add UserRepository with findByEmail method
|
|
1079
|
+
|
|
1080
|
+
Files changed: 5
|
|
1081
|
+
Lines added: 245
|
|
1082
|
+
───────────────────────────────────────────────────────
|
|
1083
|
+
|
|
1084
|
+
Commit this? (Y/n/edit): \_\_
|
|
1085
|
+
|
|
1086
|
+
````
|
|
1087
|
+
|
|
1088
|
+
**If Y:** Execute commit
|
|
1089
|
+
**If n:** Skip commit
|
|
1090
|
+
**If edit:** Allow editing commit message
|
|
1091
|
+
|
|
1092
|
+
**Execute commit:**
|
|
1093
|
+
|
|
1094
|
+
```bash
|
|
1095
|
+
git add .
|
|
1096
|
+
git commit -m "feat(entities): add authentication entities and migrations
|
|
1097
|
+
|
|
1098
|
+
- Create User entity with email verification
|
|
1099
|
+
- Create Session entity for active sessions tracking
|
|
1100
|
+
- Create RefreshToken entity with rotation support
|
|
1101
|
+
- Add migrations for auth tables
|
|
1102
|
+
- Add UserRepository with findByEmail method"
|
|
1103
|
+
````
|
|
1104
|
+
|
|
1105
|
+
**Update status.json:**
|
|
1106
|
+
|
|
1107
|
+
```json
|
|
1108
|
+
{
|
|
1109
|
+
"git": {
|
|
1110
|
+
"commits": [
|
|
1111
|
+
{
|
|
1112
|
+
"sha": "abc123def456",
|
|
1113
|
+
"type": "feat",
|
|
1114
|
+
"scope": "entities",
|
|
1115
|
+
"message": "add authentication entities and migrations",
|
|
1116
|
+
"phase": 1,
|
|
1117
|
+
"timestamp": "2025-12-04T14:30:00Z",
|
|
1118
|
+
"filesChanged": 5
|
|
1119
|
+
}
|
|
1120
|
+
],
|
|
1121
|
+
"lastCommitSha": "abc123def456",
|
|
1122
|
+
"uncommittedChanges": false
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
```
|
|
1126
|
+
|
|
1127
|
+
**Show confirmation:**
|
|
1128
|
+
|
|
1129
|
+
```
|
|
1130
|
+
✅ Committed: abc123de
|
|
1131
|
+
feat(entities): add authentication entities and migrations
|
|
1132
|
+
```
|
|
1133
|
+
|
|
1134
|
+
Continue to Phase 2? (Y/n/pause)
|
|
1135
|
+
|
|
1136
|
+
> Y
|
|
1137
|
+
|
|
1138
|
+
PHASE 2/5: Business Logic
|
|
1139
|
+
├── Task 2.1: Create AuthService ✅
|
|
1140
|
+
...
|
|
1141
|
+
|
|
1142
|
+
```
|
|
1143
|
+
|
|
1144
|
+
**Options after each phase:**
|
|
1145
|
+
|
|
1146
|
+
- **Y** → Continue to next phase
|
|
1147
|
+
- **n** → Stop and allow modifications
|
|
1148
|
+
- **pause** → Save progress and exit (can resume with `/work resume`)
|
|
1149
|
+
|
|
1150
|
+
#### Mode 3: Task-by-task (Maximum control)
|
|
1151
|
+
|
|
1152
|
+
Ask confirmation before each task:
|
|
1153
|
+
|
|
1154
|
+
```
|
|
1155
|
+
---
|
|
1156
|
+
⚙️ Implementation (Task-by-task Mode)
|
|
1157
|
+
---
|
|
1158
|
+
Next task: Create User entity
|
|
1159
|
+
Files to create: src/entities/User.entity.ts
|
|
1160
|
+
|
|
1161
|
+
Proceed? (Y/n/skip/pause)
|
|
1162
|
+
|
|
1163
|
+
> Y
|
|
1164
|
+
|
|
1165
|
+
[Creates User.entity.ts]
|
|
1166
|
+
|
|
1167
|
+
✅ Task 1/12 complete
|
|
1168
|
+
|
|
1169
|
+
Next task: Create AuthService
|
|
1170
|
+
Files to create: src/services/AuthService.ts
|
|
1171
|
+
|
|
1172
|
+
Proceed? (Y/n/skip/pause)
|
|
1173
|
+
|
|
1174
|
+
> Y
|
|
1175
|
+
|
|
1176
|
+
```
|
|
1177
|
+
|
|
1178
|
+
**Options for each task:**
|
|
1179
|
+
|
|
1180
|
+
- **Y** → Execute task
|
|
1181
|
+
- **n** → Stop (allow manual work)
|
|
1182
|
+
- **skip** → Skip this task
|
|
1183
|
+
- **pause** → Save and exit
|
|
1184
|
+
|
|
1185
|
+
#### Mode 4: Save and resume later
|
|
1186
|
+
|
|
1187
|
+
Save current state and exit:
|
|
1188
|
+
|
|
1189
|
+
```
|
|
1190
|
+
---
|
|
1191
|
+
💾 Progress Saved
|
|
1192
|
+
---
|
|
1193
|
+
Current progress: 0/52 tasks (0%)
|
|
1194
|
+
Status: Ready to start
|
|
1195
|
+
|
|
1196
|
+
To resume: /work resume feature-[name]
|
|
1197
|
+
|
|
1198
|
+
```
|
|
1199
|
+
|
|
1200
|
+
**Generate:** `.ai-flow/work/NNN-feature-name/tasks.md` (with ✅ checkmarks)
|
|
1201
|
+
|
|
1202
|
+
**Example:** `.ai-flow/work/003-user-authentication/tasks.md`
|
|
1203
|
+
|
|
1204
|
+
**Implementation rules:**
|
|
1205
|
+
|
|
1206
|
+
- Follow project conventions detected in codebase
|
|
1207
|
+
- Use same code style as existing files
|
|
1208
|
+
- Write tests for all new code
|
|
1209
|
+
- Validate each task before marking complete
|
|
1210
|
+
- Update status.json after each task/phase
|
|
1211
|
+
|
|
1212
|
+
### Phase 4: Security Check + Validation + Auto-Archive (1-2 minutes)
|
|
1213
|
+
|
|
1214
|
+
**IF mode = `USER_STORY`:** *(Validate against Definition of Done)*
|
|
1215
|
+
|
|
1216
|
+
```
|
|
1217
|
+
---
|
|
1218
|
+
✅ Definition of Done Validation (from HU-001-001)
|
|
1219
|
+
---
|
|
1220
|
+
Validating User Story completion...
|
|
1221
|
+
|
|
1222
|
+
✅ Código implementado siguiendo ai-instructions.md
|
|
1223
|
+
✅ Code review aprobado (mín 1 revisor) [Simulated: Auto-approved by AI]
|
|
1224
|
+
✅ Tests unitarios escritos (cobertura > 80%) [Coverage: 92%]
|
|
1225
|
+
✅ Tests de integración pasando [8/8 passing]
|
|
1226
|
+
✅ Casos de prueba QA ejecutados y aprobados (8/8)
|
|
1227
|
+
✅ TC-001-001: Login exitoso (Happy Path)
|
|
1228
|
+
✅ TC-001-002: Credenciales inválidas (Error Case)
|
|
1229
|
+
✅ TC-001-003: Rate limiting (Edge Case)
|
|
1230
|
+
... [5 more test cases]
|
|
1231
|
+
✅ Documentación técnica actualizada (docs/api.md)
|
|
1232
|
+
✅ Sin errores de lint ni formateo
|
|
1233
|
+
⚠️ Deploy a staging exitoso [SKIP: Local development]
|
|
1234
|
+
⚠️ Product Owner aprobó la funcionalidad [SKIP: Manual step]
|
|
1235
|
+
---
|
|
1236
|
+
Acceptance Criteria Verification
|
|
1237
|
+
---
|
|
1238
|
+
✅ Scenario 1: Login exitoso
|
|
1239
|
+
Test: TC-001-001 passed
|
|
1240
|
+
Verified: JWT token returned with valid exp, user_id, role
|
|
1241
|
+
|
|
1242
|
+
✅ Scenario 2: Credenciales inválidas
|
|
1243
|
+
Test: TC-001-002 passed
|
|
1244
|
+
Verified: 401 status with clear error message
|
|
1245
|
+
|
|
1246
|
+
✅ Scenario 3: Rate limiting
|
|
1247
|
+
Test: TC-001-003 passed
|
|
1248
|
+
Verified: 429 status after 5 failed attempts in 15 minutes
|
|
1249
|
+
|
|
1250
|
+
All acceptance criteria met! ✅
|
|
1251
|
+
|
|
1252
|
+
```
|
|
1253
|
+
|
|
1254
|
+
**IF mode = `ROADMAP_FEATURE` or `INTERACTIVE`:** *(Standard security check)*
|
|
1255
|
+
|
|
1256
|
+
**Security Quick Check:**
|
|
1257
|
+
Ask 1-2 questions about production considerations:
|
|
1258
|
+
|
|
1259
|
+
- Add rate limiting?
|
|
1260
|
+
- Input validation sufficient?
|
|
1261
|
+
- Consider [specific concern] for production?
|
|
1262
|
+
|
|
1263
|
+
**Auto-Archive:**
|
|
1264
|
+
|
|
1265
|
+
1. Move work to `.ai-flow/archive/YYYY-MM/feature-[name]/`
|
|
1266
|
+
2. Update affected documentation:
|
|
1267
|
+
- `docs/api.md` (if new endpoints)
|
|
1268
|
+
- `docs/data-model.md` (if new entities)
|
|
1269
|
+
- `specs/security.md` (if auth/permissions changed)
|
|
1270
|
+
3. Generate final summary
|
|
1271
|
+
|
|
1272
|
+
**Example output:**
|
|
1273
|
+
|
|
1274
|
+
```
|
|
1275
|
+
---
|
|
1276
|
+
🔒 Security Quick Check
|
|
1277
|
+
---
|
|
1278
|
+
✅ Password hashing: bcrypt cost 12
|
|
1279
|
+
✅ JWT secret: from env variable
|
|
1280
|
+
⚠️ Consider: Rate limiting on login endpoint
|
|
1281
|
+
|
|
1282
|
+
Add rate limiting now? (Y/n)
|
|
1283
|
+
|
|
1284
|
+
```
|
|
1285
|
+
|
|
1286
|
+
**Documentation Updates:**
|
|
1287
|
+
|
|
1288
|
+
Update affected documentation files:
|
|
1289
|
+
- `docs/api.md` - Add new endpoints
|
|
1290
|
+
- `docs/data-model.md` - Add new entities
|
|
1291
|
+
- `.env.example` - Add new environment variables
|
|
1292
|
+
|
|
1293
|
+
**If git.enabled === true:**
|
|
1294
|
+
|
|
1295
|
+
**Final Documentation Commit:**
|
|
1296
|
+
|
|
1297
|
+
```
|
|
1298
|
+
|
|
1299
|
+
📦 Creating final documentation commit...
|
|
1300
|
+
|
|
1301
|
+
Conventional Commit:
|
|
1302
|
+
Type: docs
|
|
1303
|
+
Scope: api
|
|
1304
|
+
Subject: update documentation for authentication feature
|
|
1305
|
+
|
|
1306
|
+
Generated commit message:
|
|
1307
|
+
───────────────────────────────────────────────────────
|
|
1308
|
+
docs(api): update documentation for authentication feature
|
|
1309
|
+
|
|
1310
|
+
- Add 5 authentication endpoints with examples
|
|
1311
|
+
- Update data model with User, Session, RefreshToken entities
|
|
1312
|
+
- Add environment variables for JWT configuration
|
|
1313
|
+
- Document rate limiting on auth endpoints
|
|
1314
|
+
|
|
1315
|
+
Files changed: 3
|
|
1316
|
+
───────────────────────────────────────────────────────
|
|
1317
|
+
|
|
1318
|
+
Commit? (Y/n): \_\_
|
|
1319
|
+
|
|
1320
|
+
```
|
|
1321
|
+
|
|
1322
|
+
**After final commit:**
|
|
1323
|
+
|
|
1324
|
+
```
|
|
1325
|
+
---
|
|
1326
|
+
✅ Feature Complete!
|
|
1327
|
+
---
|
|
1328
|
+
**IF mode = `USER_STORY`:**
|
|
1329
|
+
|
|
1330
|
+
```
|
|
1331
|
+
Summary:
|
|
1332
|
+
|
|
1333
|
+
- User Story: HU-001-001 - Login básico con email y contraseña
|
|
1334
|
+
- Epic: EP-001 - Autenticación y Seguridad
|
|
1335
|
+
- Priority: Alta (P0)
|
|
1336
|
+
- Story Points: 5 SP (estimated) → 4.8 SP (actual)
|
|
1337
|
+
- Time: 1.5 hours (estimated: 6-8h with AI assistance)
|
|
1338
|
+
- Files: 6 created, 2 modified
|
|
1339
|
+
- Tests: 8 added (all passing ✅)
|
|
1340
|
+
|
|
1341
|
+
✅ Acceptance Criteria: 3/3 verified
|
|
1342
|
+
✅ Test Cases: 8/8 executed and passed
|
|
1343
|
+
✅ Definition of Done: 7/9 completed (2 manual steps pending)
|
|
1344
|
+
|
|
1345
|
+
Dependencies resolved:
|
|
1346
|
+
✅ Blocks: HU-001-002 (OAuth login) - Ready to start
|
|
1347
|
+
✅ Blocks: HU-002-001 (User CRUD) - Ready to start
|
|
1348
|
+
|
|
1349
|
+
📖 User Story Status: COMPLETED ✅
|
|
1350
|
+
File: .ai-flow/user-stories/EP-001/HU-001-001.md updated with completion date
|
|
1351
|
+
```
|
|
1352
|
+
|
|
1353
|
+
**IF mode = `ROADMAP_FEATURE` or `INTERACTIVE`:**
|
|
1354
|
+
|
|
1355
|
+
```
|
|
1356
|
+
Summary:
|
|
1357
|
+
|
|
1358
|
+
- Feature: JWT authentication system
|
|
1359
|
+
- Files: 28 created, 5 modified
|
|
1360
|
+
- Tests: 47 added (all passing ✅)
|
|
1361
|
+
- Time: 2.5 hours
|
|
1362
|
+
- Complexity: COMPLEX (52 tasks, 5 phases)
|
|
1363
|
+
```
|
|
1364
|
+
|
|
1365
|
+
📦 Git Summary:
|
|
1366
|
+
Branch: feature/auth-jwt-system
|
|
1367
|
+
Source: main
|
|
1368
|
+
Commits: 6
|
|
1369
|
+
|
|
1370
|
+
1. feat(entities): add authentication entities and migrations
|
|
1371
|
+
2. feat(services): implement AuthService and TokenService
|
|
1372
|
+
3. feat(api): add authentication endpoints
|
|
1373
|
+
4. feat(middleware): add JWT verification middleware
|
|
1374
|
+
5. test(auth): add comprehensive test suite
|
|
1375
|
+
6. docs(api): update documentation for authentication feature
|
|
1376
|
+
|
|
1377
|
+
All changes committed ✅
|
|
1378
|
+
Ready for Pull Request ✅
|
|
1379
|
+
---
|
|
1380
|
+
Would you like to create a Pull Request?
|
|
1381
|
+
|
|
1382
|
+
A) Show PR command (recommended)
|
|
1383
|
+
B) No, I'll create it later
|
|
1384
|
+
|
|
1385
|
+
Your choice (A): \_\_
|
|
1386
|
+
|
|
1387
|
+
```
|
|
1388
|
+
|
|
1389
|
+
**If option A selected:**
|
|
1390
|
+
|
|
1391
|
+
```
|
|
1392
|
+
|
|
1393
|
+
To create a Pull Request, run:
|
|
1394
|
+
|
|
1395
|
+
gh pr create \
|
|
1396
|
+
--title "feat: JWT authentication system" \
|
|
1397
|
+
--body "## Summary
|
|
1398
|
+
Implements complete JWT authentication with refresh tokens, email verification, and session management.
|
|
1399
|
+
|
|
1400
|
+
## Changes
|
|
1401
|
+
|
|
1402
|
+
- **Entities:** User, Session, RefreshToken with relationships
|
|
1403
|
+
- **Services:** AuthService, TokenService, EmailService
|
|
1404
|
+
- **API:** 5 endpoints (register, login, refresh, logout, verify-email)
|
|
1405
|
+
- **Security:** bcrypt password hashing, JWT with RS256
|
|
1406
|
+
- **Tests:** 47 tests (unit + integration), 95% coverage
|
|
1407
|
+
|
|
1408
|
+
## Documentation
|
|
1409
|
+
|
|
1410
|
+
- API endpoints documented in docs/api.md
|
|
1411
|
+
- Data model updated in docs/data-model.md
|
|
1412
|
+
- Environment variables in .env.example
|
|
1413
|
+
|
|
1414
|
+
## Testing
|
|
1415
|
+
|
|
1416
|
+
- ✅ All 47 tests passing
|
|
1417
|
+
- ✅ Lint checks passed
|
|
1418
|
+
- ✅ Type checks passed
|
|
1419
|
+
- ✅ Security review completed" \
|
|
1420
|
+
--base main \
|
|
1421
|
+
--head feature/auth-jwt-system
|
|
1422
|
+
|
|
1423
|
+
Or open in browser:
|
|
1424
|
+
https://github.com/[user]/[repo]/compare/main...feature/auth-jwt-system
|
|
1425
|
+
|
|
1426
|
+
````
|
|
1427
|
+
|
|
1428
|
+
**Update status.json:**
|
|
1429
|
+
|
|
1430
|
+
```json
|
|
1431
|
+
{
|
|
1432
|
+
"git": {
|
|
1433
|
+
"readyForPR": true,
|
|
1434
|
+
"prSuggested": true
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
````
|
|
1438
|
+
---
|
|
1439
|
+
## Files Generated
|
|
1440
|
+
|
|
1441
|
+
### During workflow (work directory):
|
|
1442
|
+
|
|
1443
|
+
```
|
|
1444
|
+
.ai-flow/work/NNN-feature-name/
|
|
1445
|
+
├── spec.md # What is being built
|
|
1446
|
+
├── plan.md # How it will be built
|
|
1447
|
+
├── tasks.md # Checklist with ✅
|
|
1448
|
+
├── status.json # Metadata (progress, timestamps)
|
|
1449
|
+
|
|
1450
|
+
**Example:** `.ai-flow/work/003-user-authentication/`
|
|
1451
|
+
└── implementation.md # Optional implementation notes
|
|
1452
|
+
```
|
|
1453
|
+
|
|
1454
|
+
### After completion (archive):
|
|
1455
|
+
|
|
1456
|
+
```
|
|
1457
|
+
.ai-flow/archive/YYYY-MM/NNN-feature-name/
|
|
1458
|
+
├── spec.md
|
|
1459
|
+
├── plan.md
|
|
1460
|
+
├── tasks.md
|
|
1461
|
+
└── summary.md # Final summary with stats
|
|
1462
|
+
|
|
1463
|
+
**Example:** `.ai-flow/archive/2025-01/003-user-authentication/`
|
|
1464
|
+
```
|
|
1465
|
+
---
|
|
1466
|
+
## status.json Schema
|
|
1467
|
+
|
|
1468
|
+
```json
|
|
1469
|
+
{
|
|
1470
|
+
"name": "feature-notifications",
|
|
1471
|
+
"type": "feature",
|
|
1472
|
+
"subtype": "new" | "change" | "refactor",
|
|
1473
|
+
"complexity": "simple" | "medium" | "complex" | "large",
|
|
1474
|
+
"status": "in_progress" | "completed" | "paused",
|
|
1475
|
+
"phase": "spec" | "plan" | "implementation" | "done",
|
|
1476
|
+
"implementationMode": "auto" | "phase-by-phase" | "task-by-task",
|
|
1477
|
+
"progress": {
|
|
1478
|
+
"completed": 12,
|
|
1479
|
+
"total": 52,
|
|
1480
|
+
"percentage": 23,
|
|
1481
|
+
"currentPhase": 2,
|
|
1482
|
+
"totalPhases": 5,
|
|
1483
|
+
"currentTask": "2.3"
|
|
1484
|
+
},
|
|
1485
|
+
"phases": [
|
|
1486
|
+
{
|
|
1487
|
+
"id": 1,
|
|
1488
|
+
"name": "Data Layer",
|
|
1489
|
+
"tasks": 10,
|
|
1490
|
+
"completed": 10,
|
|
1491
|
+
"status": "completed"
|
|
1492
|
+
},
|
|
1493
|
+
{
|
|
1494
|
+
"id": 2,
|
|
1495
|
+
"name": "Business Logic",
|
|
1496
|
+
"tasks": 15,
|
|
1497
|
+
"completed": 2,
|
|
1498
|
+
"status": "in_progress"
|
|
1499
|
+
}
|
|
1500
|
+
],
|
|
1501
|
+
"created": "2025-01-20T10:00:00Z",
|
|
1502
|
+
"updated": "2025-01-20T15:30:00Z",
|
|
1503
|
+
"lastPauseReason": "User requested pause after Phase 1",
|
|
1504
|
+
"filesCreated": ["src/entities/Notification.entity.ts", "..."],
|
|
1505
|
+
"filesModified": ["src/app.ts"],
|
|
1506
|
+
"affectedDocs": ["docs/api.md", "docs/data-model.md"],
|
|
1507
|
+
"git": {
|
|
1508
|
+
"enabled": true,
|
|
1509
|
+
"autoCommit": "phase" | "end" | "off",
|
|
1510
|
+
"branchCreated": true,
|
|
1511
|
+
"branchName": "feature/notifications-websocket",
|
|
1512
|
+
"sourceBranch": "main",
|
|
1513
|
+
"commits": [
|
|
1514
|
+
{
|
|
1515
|
+
"sha": "abc123def456",
|
|
1516
|
+
"type": "feat",
|
|
1517
|
+
"scope": "entities",
|
|
1518
|
+
"message": "add Notification entity with websocket support",
|
|
1519
|
+
"phase": 1,
|
|
1520
|
+
"timestamp": "2025-01-20T14:30:00Z",
|
|
1521
|
+
"filesChanged": 5
|
|
1522
|
+
},
|
|
1523
|
+
{
|
|
1524
|
+
"sha": "def456abc789",
|
|
1525
|
+
"type": "feat",
|
|
1526
|
+
"scope": "services",
|
|
1527
|
+
"message": "implement NotificationService with real-time delivery",
|
|
1528
|
+
"phase": 2,
|
|
1529
|
+
"timestamp": "2025-01-20T15:00:00Z",
|
|
1530
|
+
"filesChanged": 8
|
|
1531
|
+
}
|
|
1532
|
+
],
|
|
1533
|
+
"lastCommitSha": "def456abc789",
|
|
1534
|
+
"uncommittedChanges": false,
|
|
1535
|
+
"readyForPR": false,
|
|
1536
|
+
"prSuggested": false
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
```
|
|
1540
|
+
---
|
|
1541
|
+
## Git Integration
|
|
1542
|
+
|
|
1543
|
+
### Overview
|
|
1544
|
+
|
|
1545
|
+
Git integration is **optional** and **non-intrusive**. It helps isolate changes in feature branches and create atomic commits automatically per phase or at the end.
|
|
1546
|
+
|
|
1547
|
+
**Key Benefits:**
|
|
1548
|
+
|
|
1549
|
+
- ✅ Automatic branch creation with smart naming (`feature/[name]`)
|
|
1550
|
+
- ✅ Conventional Commits enforced (feat/fix/refactor/docs/test)
|
|
1551
|
+
- ✅ Pre-commit validation (lint + tests + type check)
|
|
1552
|
+
- ✅ Atomic commits per phase (MEDIUM/COMPLEX/LARGE) or single commit (SIMPLE)
|
|
1553
|
+
- ✅ Pull Request suggestion with pre-filled template
|
|
1554
|
+
- ❌ **NO automatic push** (always local only for safety)
|
|
1555
|
+
|
|
1556
|
+
### When Git is Used
|
|
1557
|
+
|
|
1558
|
+
**Branch Creation:** Optional at Phase 0.5 (after plan approval, before implementation)
|
|
1559
|
+
**Commit Points:**
|
|
1560
|
+
|
|
1561
|
+
- **SIMPLE features** (1-10 tasks): Single commit at end
|
|
1562
|
+
- **MEDIUM/COMPLEX/LARGE** (11+ tasks): Commit after each phase completion
|
|
1563
|
+
|
|
1564
|
+
### Conventional Commits Format
|
|
1565
|
+
|
|
1566
|
+
**Enforced types:**
|
|
1567
|
+
|
|
1568
|
+
- `feat` - New feature or functionality
|
|
1569
|
+
- `fix` - Bug fix
|
|
1570
|
+
- `refactor` - Code refactoring
|
|
1571
|
+
- `docs` - Documentation updates
|
|
1572
|
+
- `test` - Test additions or updates
|
|
1573
|
+
- `chore` - Maintenance tasks
|
|
1574
|
+
- `perf` - Performance improvements
|
|
1575
|
+
- `style` - Code style changes (formatting, etc.)
|
|
1576
|
+
|
|
1577
|
+
**Format:**
|
|
1578
|
+
|
|
1579
|
+
```
|
|
1580
|
+
<type>(<scope>): <subject>
|
|
1581
|
+
|
|
1582
|
+
<body>
|
|
1583
|
+
|
|
1584
|
+
<footer>
|
|
1585
|
+
```
|
|
1586
|
+
|
|
1587
|
+
**Examples:**
|
|
1588
|
+
|
|
1589
|
+
```bash
|
|
1590
|
+
# Feature with entities
|
|
1591
|
+
feat(entities): add Notification and NotificationSetting entities
|
|
1592
|
+
|
|
1593
|
+
- Create Notification entity with user relationship
|
|
1594
|
+
- Create NotificationSetting entity for preferences
|
|
1595
|
+
- Add migrations for notifications tables
|
|
1596
|
+
- Add indexes for performance
|
|
1597
|
+
|
|
1598
|
+
# Feature with services
|
|
1599
|
+
feat(services): implement NotificationService with real-time delivery
|
|
1600
|
+
|
|
1601
|
+
- NotificationService with create, read, mark as read
|
|
1602
|
+
- WebSocket integration for real-time push
|
|
1603
|
+
- Email fallback for offline users
|
|
1604
|
+
- Unit tests for all methods
|
|
1605
|
+
|
|
1606
|
+
# Documentation update
|
|
1607
|
+
docs(api): update documentation for notifications feature
|
|
1608
|
+
|
|
1609
|
+
- Add 3 notification endpoints with examples
|
|
1610
|
+
- Update data model with Notification entity
|
|
1611
|
+
- Add environment variables for WebSocket
|
|
1612
|
+
```
|
|
1613
|
+
|
|
1614
|
+
### Pre-commit Validation
|
|
1615
|
+
|
|
1616
|
+
**Runs automatically before every commit:**
|
|
1617
|
+
|
|
1618
|
+
1. **Lint check** - ESLint/Prettier/Black/etc.
|
|
1619
|
+
2. **Test execution** - Run full test suite
|
|
1620
|
+
3. **Type check** - TypeScript/MyPy (if applicable)
|
|
1621
|
+
|
|
1622
|
+
**If validation fails:**
|
|
1623
|
+
|
|
1624
|
+
- Show errors clearly with file and line numbers
|
|
1625
|
+
- Offer to auto-fix (if possible)
|
|
1626
|
+
- Allow skip or manual fix
|
|
1627
|
+
- Force commit option available (not recommended)
|
|
1628
|
+
|
|
1629
|
+
**Example validation output:**
|
|
1630
|
+
|
|
1631
|
+
```
|
|
1632
|
+
🔍 Running pre-commit checks...
|
|
1633
|
+
✅ Lint passed (eslint --fix applied)
|
|
1634
|
+
✅ Tests passed (47/47, +12 new tests)
|
|
1635
|
+
✅ Type check passed
|
|
1636
|
+
|
|
1637
|
+
Ready to commit ✅
|
|
1638
|
+
```
|
|
1639
|
+
|
|
1640
|
+
### Edge Cases Handled
|
|
1641
|
+
|
|
1642
|
+
1. ✅ **Uncommitted changes** - Stash, commit first, or continue with them
|
|
1643
|
+
2. ✅ **Already on feature branch** - Continue, branch off, or switch to main
|
|
1644
|
+
3. ✅ **Branch name conflict** - Suggest alternative name or checkout existing
|
|
1645
|
+
4. ✅ **Detached HEAD** - Prompt to create branch or switch to existing
|
|
1646
|
+
5. ✅ **No Git repository** - Disable Git integration gracefully
|
|
1647
|
+
6. ✅ **Behind remote** - Suggest pull before starting (if applicable)
|
|
1648
|
+
7. ✅ **Merge conflicts** - Pause and instruct manual resolution
|
|
1649
|
+
8. ✅ **Large changesets** - Suggest splitting commits by logical groups
|
|
1650
|
+
9. ✅ **Validation failures** - Auto-fix, skip, show errors, or force commit
|
|
1651
|
+
|
|
1652
|
+
### Workflow Example (COMPLEX Feature)
|
|
1653
|
+
|
|
1654
|
+
```
|
|
1655
|
+
1. User runs: /feature new
|
|
1656
|
+
2. Phase 1: Specification (user answers questions)
|
|
1657
|
+
3. Phase 2: Technical Plan (AI generates plan, 52 tasks, 5 phases)
|
|
1658
|
+
4. Phase 0.5: Git Setup
|
|
1659
|
+
→ Detect Git repo ✅
|
|
1660
|
+
→ Suggest: feature/auth-jwt-system
|
|
1661
|
+
→ User confirms: Create branch + commit per phase
|
|
1662
|
+
→ Branch created ✅
|
|
1663
|
+
5. Phase 3: Implementation (Phase-by-phase mode)
|
|
1664
|
+
→ Phase 1: Data Layer (10 tasks)
|
|
1665
|
+
→ Pre-commit validation ✅
|
|
1666
|
+
→ Commit: feat(entities): add authentication entities
|
|
1667
|
+
→ Phase 2: Business Logic (15 tasks)
|
|
1668
|
+
→ Pre-commit validation ✅
|
|
1669
|
+
→ Commit: feat(services): implement auth services
|
|
1670
|
+
→ ... (continue for remaining phases)
|
|
1671
|
+
6. Phase 4: Security Check + Archive
|
|
1672
|
+
→ Update documentation
|
|
1673
|
+
→ Final commit: docs(api): update auth documentation
|
|
1674
|
+
→ Show PR command: gh pr create ...
|
|
1675
|
+
7. Done! 6 commits ready for PR ✅
|
|
1676
|
+
```
|
|
1677
|
+
|
|
1678
|
+
### Configuration (Optional)
|
|
1679
|
+
|
|
1680
|
+
**File:** `.ai-flow/core/config.json`
|
|
1681
|
+
|
|
1682
|
+
```json
|
|
1683
|
+
{
|
|
1684
|
+
"git": {
|
|
1685
|
+
"enabled": true,
|
|
1686
|
+
"autoCommit": "phase", // "phase" | "end" | "off"
|
|
1687
|
+
"autoCreateBranch": true,
|
|
1688
|
+
"branchPrefix": "feature", // "feature" | "feat" | "work"
|
|
1689
|
+
"commitFormat": "conventional", // always conventional
|
|
1690
|
+
"pushAfterCommit": false, // always false
|
|
1691
|
+
"prSuggestion": true
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
```
|
|
1695
|
+
|
|
1696
|
+
### Messages Style
|
|
1697
|
+
|
|
1698
|
+
**Non-intrusive, informative, brief:**
|
|
1699
|
+
|
|
1700
|
+
✅ **Good:**
|
|
1701
|
+
|
|
1702
|
+
```
|
|
1703
|
+
✅ Committed: abc123de
|
|
1704
|
+
feat(entities): add notification entities
|
|
1705
|
+
```
|
|
1706
|
+
|
|
1707
|
+
❌ **Bad:**
|
|
1708
|
+
|
|
1709
|
+
```
|
|
1710
|
+
🎉🎉🎉 COMMIT SUCCESSFUL! 🎉🎉🎉
|
|
1711
|
+
SHA: abc123def456789abcdef123456789abcdef1234
|
|
1712
|
+
Author: John Doe <john@example.com>
|
|
1713
|
+
Date: Wed Dec 4 15:30:00 2025 -0500
|
|
1714
|
+
Files changed: 5 insertions(+), 2 deletions(-)
|
|
1715
|
+
Would you like to push to remote? (Y/n)
|
|
1716
|
+
Configure CI/CD pipeline? (Y/n)
|
|
1717
|
+
Set up code review? (Y/n)
|
|
1718
|
+
...
|
|
1719
|
+
```
|
|
1720
|
+
|
|
1721
|
+
### Disabling Git Integration
|
|
1722
|
+
|
|
1723
|
+
**To work without Git:**
|
|
1724
|
+
|
|
1725
|
+
1. **During Phase 0.5:** Select option D (Skip Git integration)
|
|
1726
|
+
2. **In config:** Set `"enabled": false`
|
|
1727
|
+
3. **No Git repo:** Automatically disabled
|
|
1728
|
+
|
|
1729
|
+
**Git integration will never block your workflow.**
|
|
1730
|
+
---
|
|
1731
|
+
## Important Rules
|
|
1732
|
+
|
|
1733
|
+
### 1. Project Context
|
|
1734
|
+
|
|
1735
|
+
**Before starting ANY work:**
|
|
1736
|
+
|
|
1737
|
+
- Read `AGENT.md` for project guidelines
|
|
1738
|
+
- Read `ai-instructions.md` for tech stack and conventions
|
|
1739
|
+
- Scan existing code to understand patterns
|
|
1740
|
+
- Follow project's existing code style
|
|
1741
|
+
|
|
1742
|
+
### 2. Continuous Validation
|
|
1743
|
+
|
|
1744
|
+
- Each task must validate before moving to next
|
|
1745
|
+
- Tests must pass before marking task complete
|
|
1746
|
+
- Spec requirements must be 100% fulfilled
|
|
1747
|
+
- No placeholders - only working code
|
|
1748
|
+
- Update status.json after each task/phase completion
|
|
1749
|
+
- In phase-by-phase mode, validate entire phase before pausing
|
|
1750
|
+
|
|
1751
|
+
### 3. Automatic Documentation
|
|
1752
|
+
|
|
1753
|
+
- Update all affected docs when archiving
|
|
1754
|
+
- Maintain consistency with existing documentation
|
|
1755
|
+
- Use same format as existing docs
|
|
1756
|
+
- Include examples in API documentation
|
|
1757
|
+
|
|
1758
|
+
### 4. Quality Standards
|
|
1759
|
+
|
|
1760
|
+
- Write tests for all new functionality
|
|
1761
|
+
- Follow SOLID principles
|
|
1762
|
+
- Handle errors appropriately
|
|
1763
|
+
- Add input validation
|
|
1764
|
+
- Consider security implications
|
|
1765
|
+
---
|
|
1766
|
+
## Example Outputs
|
|
1767
|
+
|
|
1768
|
+
### Example 1: SIMPLE Feature (Auto Mode)
|
|
1769
|
+
|
|
1770
|
+
```
|
|
1771
|
+
---
|
|
1772
|
+
✅ Feature Complete!
|
|
1773
|
+
---
|
|
1774
|
+
Complexity: SIMPLE
|
|
1775
|
+
Mode: Auto
|
|
1776
|
+
Duration: 18 minutes
|
|
1777
|
+
|
|
1778
|
+
Summary:
|
|
1779
|
+
- 8 tasks completed
|
|
1780
|
+
- 3 files modified
|
|
1781
|
+
- 5 tests passed (100% coverage)
|
|
1782
|
+
- Documentation updated
|
|
1783
|
+
|
|
1784
|
+
✏️ Files modified:
|
|
1785
|
+
- src/entities/User.entity.ts
|
|
1786
|
+
- src/controllers/UserController.ts
|
|
1787
|
+
- tests/user.test.ts
|
|
1788
|
+
|
|
1789
|
+
📚 Documentation updated:
|
|
1790
|
+
- docs/data-model.md (added email field)
|
|
1791
|
+
|
|
1792
|
+
📦 Work archived: .ai-flow/archive/2025-01/feature-user-email/
|
|
1793
|
+
|
|
1794
|
+
Next steps:
|
|
1795
|
+
1. Run tests: npm test
|
|
1796
|
+
2. Test endpoint manually
|
|
1797
|
+
```
|
|
1798
|
+
|
|
1799
|
+
### Example 2: COMPLEX Feature (Phase-by-phase Mode)
|
|
1800
|
+
|
|
1801
|
+
```
|
|
1802
|
+
---
|
|
1803
|
+
✅ Feature Complete!
|
|
1804
|
+
---
|
|
1805
|
+
Complexity: COMPLEX
|
|
1806
|
+
Mode: Phase-by-phase
|
|
1807
|
+
Duration: 2h 15min (across 5 phases)
|
|
1808
|
+
|
|
1809
|
+
Summary:
|
|
1810
|
+
- 52 tasks completed across 5 phases
|
|
1811
|
+
- 15 files created
|
|
1812
|
+
- 4 files modified
|
|
1813
|
+
- 48 tests passed (98% coverage)
|
|
1814
|
+
- Documentation updated
|
|
1815
|
+
|
|
1816
|
+
📁 Files created (by phase):
|
|
1817
|
+
PHASE 1 - Data Layer:
|
|
1818
|
+
- src/entities/User.entity.ts
|
|
1819
|
+
- src/entities/Session.entity.ts
|
|
1820
|
+
- src/entities/RefreshToken.entity.ts
|
|
1821
|
+
- src/repositories/UserRepository.ts
|
|
1822
|
+
- src/migrations/001_create_auth_tables.ts
|
|
1823
|
+
|
|
1824
|
+
PHASE 2 - Business Logic:
|
|
1825
|
+
- src/services/AuthService.ts
|
|
1826
|
+
- src/services/TokenService.ts
|
|
1827
|
+
- src/services/EmailService.ts
|
|
1828
|
+
|
|
1829
|
+
PHASE 3 - API Layer:
|
|
1830
|
+
- src/controllers/AuthController.ts
|
|
1831
|
+
- src/middleware/auth.middleware.ts
|
|
1832
|
+
- src/validators/auth.validators.ts
|
|
1833
|
+
|
|
1834
|
+
PHASE 4 - Integration:
|
|
1835
|
+
- src/routes/auth.routes.ts
|
|
1836
|
+
|
|
1837
|
+
PHASE 5 - Testing:
|
|
1838
|
+
- tests/unit/AuthService.test.ts
|
|
1839
|
+
- tests/integration/auth.api.test.ts
|
|
1840
|
+
|
|
1841
|
+
✏️ Files modified:
|
|
1842
|
+
- src/app.ts (registered routes)
|
|
1843
|
+
- src/routes/index.ts
|
|
1844
|
+
- package.json (added dependencies)
|
|
1845
|
+
- .env.example (added JWT variables)
|
|
1846
|
+
|
|
1847
|
+
📚 Documentation updated:
|
|
1848
|
+
- docs/api.md (added 5 auth endpoints)
|
|
1849
|
+
- docs/data-model.md (added 3 auth entities)
|
|
1850
|
+
- specs/security.md (added JWT auth flow)
|
|
1851
|
+
|
|
1852
|
+
📦 Work archived: .ai-flow/archive/2025-01/feature-user-auth/
|
|
1853
|
+
|
|
1854
|
+
Next steps:
|
|
1855
|
+
1. Run tests: npm test
|
|
1856
|
+
2. Configure JWT secrets in .env
|
|
1857
|
+
3. Start server: npm run dev
|
|
1858
|
+
4. Test auth flow manually
|
|
1859
|
+
```
|
|
1860
|
+
---
|
|
1861
|
+
## Mode-Specific Behaviors
|
|
1862
|
+
|
|
1863
|
+
### `/feature new` - New Functionality
|
|
1864
|
+
|
|
1865
|
+
- Start from scratch
|
|
1866
|
+
- Create all files needed
|
|
1867
|
+
- Generate comprehensive tests
|
|
1868
|
+
- Full documentation
|
|
1869
|
+
|
|
1870
|
+
### `/feature change` - Modify Existing
|
|
1871
|
+
|
|
1872
|
+
- Identify affected files first
|
|
1873
|
+
- Show delta of changes (ADDED/MODIFIED/REMOVED)
|
|
1874
|
+
- Update existing tests
|
|
1875
|
+
- Update documentation sections
|
|
1876
|
+
|
|
1877
|
+
### `/feature refactor` - Refactor Code
|
|
1878
|
+
|
|
1879
|
+
- Analyze code to refactor
|
|
1880
|
+
- Create refactoring plan
|
|
1881
|
+
- Execute incrementally
|
|
1882
|
+
- Ensure tests still pass
|
|
1883
|
+
- Update documentation only if architecture changes
|
|
1884
|
+
---
|
|
1885
|
+
## Common Use Cases
|
|
1886
|
+
|
|
1887
|
+
### 1. Sprint Development (with User Stories)
|
|
1888
|
+
|
|
1889
|
+
```bash
|
|
1890
|
+
/feature HU-001-001 # Login: 5 SP, 1.5h
|
|
1891
|
+
/feature HU-001-002 # OAuth: 3 SP, 1h
|
|
1892
|
+
/feature HU-002-001 # User CRUD: 8 SP, 2h
|
|
1893
|
+
# Sprint: 16 SP in 4.5h
|
|
1894
|
+
```
|
|
1895
|
+
|
|
1896
|
+
### 2. Rapid Prototyping (with roadmap)
|
|
1897
|
+
|
|
1898
|
+
```bash
|
|
1899
|
+
/feature User Entity Repository # 12 SP
|
|
1900
|
+
/feature Product Entity Repository # 8 SP
|
|
1901
|
+
/feature Order Entity Repository # 5 SP
|
|
1902
|
+
# Data layer: 25 SP in ~2 days
|
|
1903
|
+
```
|
|
1904
|
+
|
|
1905
|
+
### 3. Feature Not Planned (interactive)
|
|
1906
|
+
|
|
1907
|
+
```bash
|
|
1908
|
+
/feature new
|
|
1909
|
+
# AI asks: What to build?
|
|
1910
|
+
> Real-time notifications with WebSockets
|
|
1911
|
+
# Generates: 24 tasks, 13 SP, ~3h
|
|
1912
|
+
```
|
|
1913
|
+
|
|
1914
|
+
### 4. Bug Fix or Quick Change
|
|
1915
|
+
|
|
1916
|
+
```bash
|
|
1917
|
+
/feature change
|
|
1918
|
+
# AI asks: What to modify?
|
|
1919
|
+
> Add rate limiting to login endpoint
|
|
1920
|
+
# Updates: middleware, tests, docs (~30 min)
|
|
1921
|
+
```
|
|
1922
|
+
|
|
1923
|
+
### 5. Code Quality Improvement
|
|
1924
|
+
|
|
1925
|
+
```bash
|
|
1926
|
+
/feature refactor
|
|
1927
|
+
# AI asks: What to refactor?
|
|
1928
|
+
> Extract duplicate validation logic to shared module
|
|
1929
|
+
# Refactors: 6 files, tests pass, docs updated (~1h)
|
|
1930
|
+
```
|
|
1931
|
+
---
|
|
1932
|
+
## Key Benefits by Mode
|
|
1933
|
+
|
|
1934
|
+
| Mode | Setup | Validation | Best For |
|
|
1935
|
+
| --------------- | ------- | ------------- | ----------- |
|
|
1936
|
+
| **HU-XXX-XXX** | 0 min | Gherkin + DoD | Scrum teams |
|
|
1937
|
+
| **Roadmap** | 0 min | Standard | Quick impl |
|
|
1938
|
+
| **Interactive** | 2-3 min | Standard | Exploration |
|
|
1939
|
+
---
|
|
1940
|
+
**BEGIN EXECUTION when user runs `/feature`, `/feature new`, `/feature change`, or `/feature refactor`**
|
|
1941
|
+
|
|
1942
|
+
|
|
1943
|
+
|
|
1944
|
+
|