cc-mirror 1.0.4 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +168 -98
- package/dist/cc-mirror.mjs +805 -294
- package/dist/skills/multi-agent-orchestrator/SKILL.md +391 -0
- package/dist/skills/multi-agent-orchestrator/references/code-review.md +266 -0
- package/dist/skills/multi-agent-orchestrator/references/data-analysis.md +315 -0
- package/dist/skills/multi-agent-orchestrator/references/devops.md +309 -0
- package/dist/skills/multi-agent-orchestrator/references/documentation.md +310 -0
- package/dist/skills/multi-agent-orchestrator/references/domains/code-review.md +301 -0
- package/dist/skills/multi-agent-orchestrator/references/domains/data-analysis.md +347 -0
- package/dist/skills/multi-agent-orchestrator/references/domains/devops.md +340 -0
- package/dist/skills/multi-agent-orchestrator/references/domains/documentation.md +343 -0
- package/dist/skills/multi-agent-orchestrator/references/domains/project-management.md +370 -0
- package/dist/skills/multi-agent-orchestrator/references/domains/research.md +322 -0
- package/dist/skills/multi-agent-orchestrator/references/domains/software-development.md +269 -0
- package/dist/skills/multi-agent-orchestrator/references/domains/testing.md +313 -0
- package/dist/skills/multi-agent-orchestrator/references/examples.md +377 -0
- package/dist/skills/multi-agent-orchestrator/references/guide.md +327 -0
- package/dist/skills/multi-agent-orchestrator/references/patterns.md +441 -0
- package/dist/skills/multi-agent-orchestrator/references/project-management.md +345 -0
- package/dist/skills/multi-agent-orchestrator/references/research.md +285 -0
- package/dist/skills/multi-agent-orchestrator/references/software-development.md +242 -0
- package/dist/skills/multi-agent-orchestrator/references/testing.md +282 -0
- package/dist/skills/multi-agent-orchestrator/references/tools.md +454 -0
- package/dist/tui.mjs +1045 -360
- package/package.json +2 -2
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
# Testing Orchestration Patterns
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
5
|
+
│ │
|
|
6
|
+
│ Confidence through verification. │
|
|
7
|
+
│ Generate, execute, analyze — all in parallel. │
|
|
8
|
+
│ │
|
|
9
|
+
└─────────────────────────────────────────────────────────────┘
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
> **Load when**: Test generation, test execution, coverage analysis, test maintenance, E2E testing
|
|
13
|
+
> **Common patterns**: Coverage-Driven Generation, Parallel Test Suites, Broken Test Triage
|
|
14
|
+
|
|
15
|
+
## Table of Contents
|
|
16
|
+
|
|
17
|
+
1. [Test Generation](#test-generation)
|
|
18
|
+
2. [Test Execution](#test-execution)
|
|
19
|
+
3. [Coverage Analysis](#coverage-analysis)
|
|
20
|
+
4. [Test Maintenance](#test-maintenance)
|
|
21
|
+
5. [E2E Testing](#e2e-testing)
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Test Generation
|
|
26
|
+
|
|
27
|
+
### Pattern: Coverage-Driven Generation
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
User Request: "Add tests for the UserService"
|
|
31
|
+
|
|
32
|
+
Phase 1: EXPLORE
|
|
33
|
+
└─ Explore agent: Understand UserService methods, dependencies
|
|
34
|
+
|
|
35
|
+
Phase 2: FAN-OUT (Parallel test writing)
|
|
36
|
+
├─ Agent A: Unit tests for method group 1
|
|
37
|
+
├─ Agent B: Unit tests for method group 2
|
|
38
|
+
├─ Agent C: Integration tests for external dependencies
|
|
39
|
+
└─ Agent D: Edge cases and error scenarios
|
|
40
|
+
|
|
41
|
+
Phase 3: PIPELINE
|
|
42
|
+
└─ General-purpose agent: Verify tests pass, check coverage
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Pattern: Behavior-First
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
User Request: "Test the checkout flow"
|
|
49
|
+
|
|
50
|
+
Phase 1: EXPLORE
|
|
51
|
+
└─ Explore agent: Map checkout flow steps and branches
|
|
52
|
+
|
|
53
|
+
Phase 2: PIPELINE (Generate by behavior)
|
|
54
|
+
├─ General-purpose agent: Happy path tests
|
|
55
|
+
├─ General-purpose agent: Error path tests
|
|
56
|
+
└─ General-purpose agent: Edge case tests
|
|
57
|
+
|
|
58
|
+
Phase 3: BACKGROUND
|
|
59
|
+
└─ Background agent: Run tests, report results
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Pattern: Contract Testing
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
User Request: "Add API contract tests"
|
|
66
|
+
|
|
67
|
+
Phase 1: EXPLORE
|
|
68
|
+
└─ Explore agent: Document API endpoints and schemas
|
|
69
|
+
|
|
70
|
+
Phase 2: FAN-OUT
|
|
71
|
+
├─ Agent A: Request validation tests
|
|
72
|
+
├─ Agent B: Response schema tests
|
|
73
|
+
└─ Agent C: Error response tests
|
|
74
|
+
|
|
75
|
+
Phase 3: PIPELINE
|
|
76
|
+
└─ General-purpose agent: Integrate with CI, add OpenAPI validation
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Test Execution
|
|
82
|
+
|
|
83
|
+
### Pattern: Parallel Test Suites
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
User Request: "Run all tests"
|
|
87
|
+
|
|
88
|
+
Phase 1: FAN-OUT (Parallel suites)
|
|
89
|
+
├─ Background agent: Unit tests
|
|
90
|
+
├─ Background agent: Integration tests
|
|
91
|
+
├─ Background agent: E2E tests
|
|
92
|
+
└─ Background agent: Performance tests
|
|
93
|
+
|
|
94
|
+
Phase 2: REDUCE
|
|
95
|
+
└─ General-purpose agent: Aggregate results, identify failures
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Pattern: Targeted Execution
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
User Request: "Test the changes I made"
|
|
102
|
+
|
|
103
|
+
Phase 1: EXPLORE
|
|
104
|
+
└─ Explore agent: Identify changed files and affected tests
|
|
105
|
+
|
|
106
|
+
Phase 2: FAN-OUT
|
|
107
|
+
├─ Background agent: Run directly affected tests
|
|
108
|
+
└─ Background agent: Run dependent module tests
|
|
109
|
+
|
|
110
|
+
Phase 3: PIPELINE
|
|
111
|
+
└─ General-purpose agent: Report results, suggest additional tests
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Pattern: Flaky Test Detection
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
Phase 1: BACKGROUND (Multiple runs)
|
|
118
|
+
├─ Background agent: Run test suite (run 1)
|
|
119
|
+
├─ Background agent: Run test suite (run 2)
|
|
120
|
+
└─ Background agent: Run test suite (run 3)
|
|
121
|
+
|
|
122
|
+
Phase 2: REDUCE
|
|
123
|
+
└─ General-purpose agent: Compare results, identify inconsistencies
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Coverage Analysis
|
|
129
|
+
|
|
130
|
+
### Pattern: Gap Identification
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
User Request: "Improve test coverage"
|
|
134
|
+
|
|
135
|
+
Phase 1: BACKGROUND
|
|
136
|
+
└─ Background agent: Run coverage report
|
|
137
|
+
|
|
138
|
+
Phase 2: EXPLORE
|
|
139
|
+
└─ Explore agent: Identify critical uncovered paths
|
|
140
|
+
|
|
141
|
+
Phase 3: FAN-OUT (Prioritized gap filling)
|
|
142
|
+
├─ Agent A: Tests for critical uncovered module 1
|
|
143
|
+
├─ Agent B: Tests for critical uncovered module 2
|
|
144
|
+
└─ Agent C: Tests for error handlers
|
|
145
|
+
|
|
146
|
+
Phase 4: PIPELINE
|
|
147
|
+
└─ General-purpose agent: Re-run coverage, verify improvement
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Pattern: Risk-Based Coverage
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
Phase 1: EXPLORE
|
|
154
|
+
└─ Explore agent: Identify high-risk code (complexity, change frequency)
|
|
155
|
+
|
|
156
|
+
Phase 2: FAN-OUT
|
|
157
|
+
├─ Agent A: Analyze coverage of high-risk area 1
|
|
158
|
+
├─ Agent B: Analyze coverage of high-risk area 2
|
|
159
|
+
└─ Agent C: Analyze coverage of high-risk area 3
|
|
160
|
+
|
|
161
|
+
Phase 3: REDUCE
|
|
162
|
+
└─ General-purpose agent: Prioritized test improvement plan
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Test Maintenance
|
|
168
|
+
|
|
169
|
+
### Pattern: Broken Test Triage
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
User Request: "Fix failing tests"
|
|
173
|
+
|
|
174
|
+
Phase 1: BACKGROUND
|
|
175
|
+
└─ Background agent: Run tests, capture failures
|
|
176
|
+
|
|
177
|
+
Phase 2: FAN-OUT (Parallel diagnosis)
|
|
178
|
+
├─ Agent A: Diagnose failure group 1
|
|
179
|
+
├─ Agent B: Diagnose failure group 2
|
|
180
|
+
└─ Agent C: Diagnose failure group 3
|
|
181
|
+
|
|
182
|
+
Phase 3: FAN-OUT (Parallel fixes)
|
|
183
|
+
├─ Agent A: Fix test group 1
|
|
184
|
+
├─ Agent B: Fix test group 2
|
|
185
|
+
└─ Agent C: Fix test group 3
|
|
186
|
+
|
|
187
|
+
Phase 4: PIPELINE
|
|
188
|
+
└─ Background agent: Verify all tests pass
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Pattern: Test Refactoring
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+
User Request: "Clean up test duplication"
|
|
195
|
+
|
|
196
|
+
Phase 1: EXPLORE
|
|
197
|
+
└─ Explore agent: Find duplicate test patterns
|
|
198
|
+
|
|
199
|
+
Phase 2: PLAN
|
|
200
|
+
└─ Plan agent: Design shared fixtures, helpers, patterns
|
|
201
|
+
|
|
202
|
+
Phase 3: FAN-OUT
|
|
203
|
+
├─ Agent A: Extract shared fixtures
|
|
204
|
+
├─ Agent B: Refactor test file group 1
|
|
205
|
+
└─ Agent C: Refactor test file group 2
|
|
206
|
+
|
|
207
|
+
Phase 4: PIPELINE
|
|
208
|
+
└─ Background agent: Verify tests still pass
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Pattern: Mock Maintenance
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
Phase 1: EXPLORE
|
|
215
|
+
└─ Explore agent: Find outdated mocks (API changes, schema changes)
|
|
216
|
+
|
|
217
|
+
Phase 2: FAN-OUT
|
|
218
|
+
├─ Agent A: Update mock group 1
|
|
219
|
+
├─ Agent B: Update mock group 2
|
|
220
|
+
└─ Agent C: Update fixtures and factories
|
|
221
|
+
|
|
222
|
+
Phase 3: PIPELINE
|
|
223
|
+
└─ Background agent: Run affected tests
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## E2E Testing
|
|
229
|
+
|
|
230
|
+
### Pattern: User Journey Testing
|
|
231
|
+
|
|
232
|
+
```
|
|
233
|
+
User Request: "Add E2E tests for user registration"
|
|
234
|
+
|
|
235
|
+
Phase 1: EXPLORE
|
|
236
|
+
└─ Explore agent: Map registration flow, identify test scenarios
|
|
237
|
+
|
|
238
|
+
Phase 2: PIPELINE (Sequential scenarios)
|
|
239
|
+
├─ General-purpose agent: Happy path registration
|
|
240
|
+
├─ General-purpose agent: Validation error scenarios
|
|
241
|
+
├─ General-purpose agent: Duplicate email handling
|
|
242
|
+
└─ General-purpose agent: Email verification flow
|
|
243
|
+
|
|
244
|
+
Phase 3: BACKGROUND
|
|
245
|
+
└─ Background agent: Run E2E suite, capture screenshots
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Pattern: Cross-Browser Testing
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
Phase 1: FAN-OUT (Parallel browsers)
|
|
252
|
+
├─ Background agent: Run E2E in Chrome
|
|
253
|
+
├─ Background agent: Run E2E in Firefox
|
|
254
|
+
├─ Background agent: Run E2E in Safari
|
|
255
|
+
└─ Background agent: Run E2E in Edge
|
|
256
|
+
|
|
257
|
+
Phase 2: REDUCE
|
|
258
|
+
└─ General-purpose agent: Browser compatibility report
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Pattern: Visual Regression
|
|
262
|
+
|
|
263
|
+
```
|
|
264
|
+
Phase 1: BACKGROUND
|
|
265
|
+
└─ Background agent: Run visual regression tests
|
|
266
|
+
|
|
267
|
+
Phase 2: EXPLORE (If failures)
|
|
268
|
+
└─ Explore agent: Compare screenshots, identify changes
|
|
269
|
+
|
|
270
|
+
Phase 3: PIPELINE
|
|
271
|
+
└─ General-purpose agent: Categorize as bugs vs intentional changes
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## Task Management for Testing
|
|
277
|
+
|
|
278
|
+
Structure testing work as tasks with clear dependencies:
|
|
279
|
+
|
|
280
|
+
```python
|
|
281
|
+
# Create testing tasks
|
|
282
|
+
TaskCreate(subject="Identify testing scope", description="Analyze what needs testing...")
|
|
283
|
+
TaskCreate(subject="Generate unit tests", description="Tests for module A...")
|
|
284
|
+
TaskCreate(subject="Generate integration tests", description="Tests for API endpoints...")
|
|
285
|
+
TaskCreate(subject="Run test suite", description="Execute all tests, capture results...")
|
|
286
|
+
TaskCreate(subject="Fix failures", description="Address any failing tests...")
|
|
287
|
+
TaskCreate(subject="Verify all pass", description="Final test run to confirm...")
|
|
288
|
+
|
|
289
|
+
# Dependencies
|
|
290
|
+
TaskUpdate(taskId="2", addBlockedBy=["1"])
|
|
291
|
+
TaskUpdate(taskId="3", addBlockedBy=["1"])
|
|
292
|
+
TaskUpdate(taskId="4", addBlockedBy=["2", "3"])
|
|
293
|
+
TaskUpdate(taskId="5", addBlockedBy=["4"])
|
|
294
|
+
TaskUpdate(taskId="6", addBlockedBy=["5"])
|
|
295
|
+
|
|
296
|
+
# Parallel test generation
|
|
297
|
+
Task(subagent_type="general-purpose", prompt="TaskId 2: Generate unit tests...")
|
|
298
|
+
Task(subagent_type="general-purpose", prompt="TaskId 3: Generate integration tests...")
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
## Test Execution Best Practices
|
|
302
|
+
|
|
303
|
+
1. **Always run in background** for long test suites
|
|
304
|
+
2. **Parallelize independent suites** (unit, integration, e2e)
|
|
305
|
+
3. **Fail fast** - stop on first failure for quick feedback
|
|
306
|
+
4. **Capture artifacts** - screenshots, logs, coverage reports
|
|
307
|
+
5. **Report actionable results** - file:line for failures
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
```
|
|
312
|
+
─── ◈ Testing ───────────────────────────
|
|
313
|
+
```
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
# Orchestration Examples
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
5
|
+
│ │
|
|
6
|
+
│ Real-world workflows, end to end. │
|
|
7
|
+
│ See how patterns come together in practice. │
|
|
8
|
+
│ │
|
|
9
|
+
│ Each example shows: │
|
|
10
|
+
│ • What the user says │
|
|
11
|
+
│ • How you orchestrate (internal) │
|
|
12
|
+
│ • What the user experiences (external) │
|
|
13
|
+
│ │
|
|
14
|
+
└─────────────────────────────────────────────────────────────┘
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Table of Contents
|
|
18
|
+
|
|
19
|
+
1. [Review a PR](#review-a-pr)
|
|
20
|
+
2. [Implement a Feature](#implement-a-feature)
|
|
21
|
+
3. [Fix a Bug](#fix-a-bug)
|
|
22
|
+
4. [Understand a Codebase](#understand-a-codebase)
|
|
23
|
+
5. [Run Tests and Fix Failures](#run-tests-and-fix-failures)
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Review a PR
|
|
28
|
+
|
|
29
|
+
**User says:** "Review PR #123"
|
|
30
|
+
|
|
31
|
+
### Internal Analysis
|
|
32
|
+
|
|
33
|
+
- Multi-dimensional analysis needed (code quality, security, performance)
|
|
34
|
+
- Independent dimensions → **Fan-Out**
|
|
35
|
+
- Need to aggregate findings → **Map-Reduce**
|
|
36
|
+
|
|
37
|
+
### Execution
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
# Phase 1: Gather context + parallel analysis (single message)
|
|
41
|
+
Task(subagent_type="Explore", description="Get PR context",
|
|
42
|
+
prompt="Fetch PR #123 details, understand what changed and why")
|
|
43
|
+
Task(subagent_type="general-purpose", description="Review quality",
|
|
44
|
+
prompt="Review code quality: readability, patterns, maintainability")
|
|
45
|
+
Task(subagent_type="general-purpose", description="Review security",
|
|
46
|
+
prompt="Review security: injection, auth, data exposure risks")
|
|
47
|
+
Task(subagent_type="general-purpose", description="Review performance",
|
|
48
|
+
prompt="Review performance: complexity, queries, memory usage")
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### User Sees
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
Reviewing PR #123 from multiple angles...
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Summary
|
|
59
|
+
Adds user profile editing with image upload capability.
|
|
60
|
+
|
|
61
|
+
## Risk Assessment
|
|
62
|
+
- Security: Medium (file upload needs validation)
|
|
63
|
+
- Performance: Low
|
|
64
|
+
- Breaking Changes: No
|
|
65
|
+
|
|
66
|
+
## Must Fix
|
|
67
|
+
1. Missing file type validation in upload handler (line 47)
|
|
68
|
+
- Could allow malicious file uploads
|
|
69
|
+
|
|
70
|
+
## Should Fix
|
|
71
|
+
1. Add rate limiting to profile update endpoint
|
|
72
|
+
2. Consider compressing uploaded images
|
|
73
|
+
|
|
74
|
+
## Looks Good
|
|
75
|
+
- Clean component structure
|
|
76
|
+
- Good error handling in UI
|
|
77
|
+
- Tests cover happy path
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Implement a Feature
|
|
83
|
+
|
|
84
|
+
**User says:** "Add dark mode to the app"
|
|
85
|
+
|
|
86
|
+
### Internal Analysis
|
|
87
|
+
|
|
88
|
+
- Need to understand existing styling → Research first
|
|
89
|
+
- Multiple independent components → **Fan-Out** for implementation
|
|
90
|
+
- Must integrate at end → **Pipeline** finish
|
|
91
|
+
|
|
92
|
+
### Execution
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
# Phase 1: Research (Pipeline)
|
|
96
|
+
context = Task(subagent_type="Explore", description="Find styling patterns",
|
|
97
|
+
prompt="Find existing theme/styling patterns, CSS architecture")
|
|
98
|
+
|
|
99
|
+
# Phase 2: Plan
|
|
100
|
+
plan = Task(subagent_type="Plan", description="Design dark mode",
|
|
101
|
+
prompt=f"Given: {context}. Design dark mode implementation.")
|
|
102
|
+
|
|
103
|
+
# Phase 3: Implement (Fan-Out - single message)
|
|
104
|
+
Task(subagent_type="general-purpose", description="Add CSS variables",
|
|
105
|
+
prompt="Add dark theme CSS variables...")
|
|
106
|
+
Task(subagent_type="general-purpose", description="Create toggle",
|
|
107
|
+
prompt="Create theme toggle component...")
|
|
108
|
+
Task(subagent_type="general-purpose", description="Add persistence",
|
|
109
|
+
prompt="Add localStorage persistence for theme preference...")
|
|
110
|
+
|
|
111
|
+
# Phase 4: Integration (Pipeline)
|
|
112
|
+
Task(subagent_type="general-purpose", description="Wire and test",
|
|
113
|
+
prompt="Wire components together, test theme switching works")
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### User Sees
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
Adding dark mode to your app.
|
|
120
|
+
|
|
121
|
+
Exploring your codebase to understand styling patterns...
|
|
122
|
+
|
|
123
|
+
Found: Tailwind with CSS variables in globals.css, no existing theme system.
|
|
124
|
+
|
|
125
|
+
Plan:
|
|
126
|
+
1. Add CSS variables for dark theme colors
|
|
127
|
+
2. Create theme toggle component
|
|
128
|
+
3. Persist preference in localStorage
|
|
129
|
+
4. Wire up and test
|
|
130
|
+
|
|
131
|
+
Starting implementation...
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
Progress:
|
|
136
|
+
- Added dark theme variables to globals.css
|
|
137
|
+
- Created ThemeToggle component at components/theme-toggle.tsx
|
|
138
|
+
|
|
139
|
+
Working on persistence...
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
Done! Dark mode is ready:
|
|
144
|
+
- Toggle in header (components/theme-toggle.tsx)
|
|
145
|
+
- Preference saved to localStorage
|
|
146
|
+
- System preference detected on first visit
|
|
147
|
+
|
|
148
|
+
Try it: Click the moon/sun icon in the header.
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Fix a Bug
|
|
154
|
+
|
|
155
|
+
**User says:** "Users can't log in after password reset"
|
|
156
|
+
|
|
157
|
+
### Internal Analysis
|
|
158
|
+
|
|
159
|
+
- Unknown cause → Need parallel investigation
|
|
160
|
+
- Multiple hypotheses → **Fan-Out** for diagnosis
|
|
161
|
+
- May need **Speculative** if cause unclear
|
|
162
|
+
|
|
163
|
+
### Execution
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
# Phase 1: Parallel diagnosis (Fan-Out - single message)
|
|
167
|
+
Task(subagent_type="Explore", description="Check logs",
|
|
168
|
+
prompt="Search for login errors, password reset issues in logs")
|
|
169
|
+
Task(subagent_type="Explore", description="Find reset flow",
|
|
170
|
+
prompt="Find password reset implementation, trace the flow")
|
|
171
|
+
Task(subagent_type="Explore", description="Check session handling",
|
|
172
|
+
prompt="How are sessions/tokens handled after password change?")
|
|
173
|
+
|
|
174
|
+
# Phase 2: Synthesize (after results return)
|
|
175
|
+
# Identify: Password reset invalidates session but doesn't clear cookie
|
|
176
|
+
|
|
177
|
+
# Phase 3: Fix
|
|
178
|
+
Task(subagent_type="general-purpose", description="Fix session bug",
|
|
179
|
+
prompt="Clear session cookie after password reset...")
|
|
180
|
+
|
|
181
|
+
# Phase 4: Verify
|
|
182
|
+
Task(subagent_type="general-purpose", description="Add regression test",
|
|
183
|
+
prompt="Add test for login after password reset...")
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### User Sees
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
Investigating the login issue after password reset...
|
|
190
|
+
|
|
191
|
+
Checking a few things:
|
|
192
|
+
- Error logs
|
|
193
|
+
- Password reset flow
|
|
194
|
+
- Session handling
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
Found the issue: Password reset invalidates the session token in the database,
|
|
199
|
+
but the old session cookie remains in the browser. On next login attempt,
|
|
200
|
+
the invalid cookie causes auth to fail.
|
|
201
|
+
|
|
202
|
+
Fix: Clear the session cookie when password is reset.
|
|
203
|
+
|
|
204
|
+
Implementing fix...
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
Fixed in auth/password-reset.ts (line 89).
|
|
209
|
+
Added regression test in __tests__/auth.test.ts.
|
|
210
|
+
|
|
211
|
+
The flow now:
|
|
212
|
+
1. User resets password
|
|
213
|
+
2. Session cookie is cleared
|
|
214
|
+
3. User redirected to login
|
|
215
|
+
4. Fresh login works correctly
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Understand a Codebase
|
|
221
|
+
|
|
222
|
+
**User says:** "Help me understand this codebase"
|
|
223
|
+
|
|
224
|
+
### Internal Analysis
|
|
225
|
+
|
|
226
|
+
- Breadth-first exploration needed
|
|
227
|
+
- Multiple independent areas → **Fan-Out**
|
|
228
|
+
- Aggregate into overview → **Map-Reduce**
|
|
229
|
+
|
|
230
|
+
### Execution
|
|
231
|
+
|
|
232
|
+
```python
|
|
233
|
+
# Phase 1: Parallel exploration (Fan-Out - single message)
|
|
234
|
+
Task(subagent_type="Explore", description="Project structure",
|
|
235
|
+
prompt="Analyze project structure, entry points, build system")
|
|
236
|
+
Task(subagent_type="Explore", description="Core patterns",
|
|
237
|
+
prompt="Identify core architectural patterns, frameworks used")
|
|
238
|
+
Task(subagent_type="Explore", description="Data flow",
|
|
239
|
+
prompt="Trace main data flows, API structure, state management")
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### User Sees
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
Exploring the codebase...
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## Overview
|
|
250
|
+
Next.js 14 app with TypeScript, using App Router.
|
|
251
|
+
|
|
252
|
+
## Structure
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
src/
|
|
256
|
+
├── app/ # Routes and pages
|
|
257
|
+
├── components/ # React components (shadcn/ui)
|
|
258
|
+
├── lib/ # Utilities and helpers
|
|
259
|
+
├── services/ # API clients and business logic
|
|
260
|
+
└── types/ # TypeScript types
|
|
261
|
+
|
|
262
|
+
````
|
|
263
|
+
|
|
264
|
+
## Key Patterns
|
|
265
|
+
- **Data fetching**: Server components with async/await
|
|
266
|
+
- **State**: React Context for auth, Zustand for UI state
|
|
267
|
+
- **Styling**: Tailwind CSS with shadcn/ui components
|
|
268
|
+
- **API**: REST endpoints in app/api/, Prisma for database
|
|
269
|
+
|
|
270
|
+
## Entry Points
|
|
271
|
+
- `app/page.tsx` - Home page
|
|
272
|
+
- `app/api/` - API routes
|
|
273
|
+
- `middleware.ts` - Auth middleware
|
|
274
|
+
|
|
275
|
+
## Getting Started
|
|
276
|
+
```bash
|
|
277
|
+
npm install
|
|
278
|
+
npm run dev
|
|
279
|
+
````
|
|
280
|
+
|
|
281
|
+
Want me to dive deeper into any area?
|
|
282
|
+
|
|
283
|
+
````
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## Run Tests and Fix Failures
|
|
288
|
+
|
|
289
|
+
**User says:** "Run tests and fix any failures"
|
|
290
|
+
|
|
291
|
+
### Internal Analysis
|
|
292
|
+
- Long-running task → **Background** for tests
|
|
293
|
+
- Multiple failures → **Fan-Out** for fixes
|
|
294
|
+
|
|
295
|
+
### Execution
|
|
296
|
+
|
|
297
|
+
```python
|
|
298
|
+
# Phase 1: Run tests in background
|
|
299
|
+
Task(subagent_type="general-purpose", description="Run tests",
|
|
300
|
+
prompt="Run full test suite, report failures",
|
|
301
|
+
run_in_background=True)
|
|
302
|
+
|
|
303
|
+
# Continue with other work or wait
|
|
304
|
+
result = TaskOutput(task_id="...", block=True)
|
|
305
|
+
|
|
306
|
+
# Phase 2: Fix failures (Fan-Out if multiple)
|
|
307
|
+
# If 3 failures found:
|
|
308
|
+
Task(subagent_type="general-purpose", description="Fix test 1",
|
|
309
|
+
prompt="Fix failing test in auth.test.ts...")
|
|
310
|
+
Task(subagent_type="general-purpose", description="Fix test 2",
|
|
311
|
+
prompt="Fix failing test in api.test.ts...")
|
|
312
|
+
Task(subagent_type="general-purpose", description="Fix test 3",
|
|
313
|
+
prompt="Fix failing test in utils.test.ts...")
|
|
314
|
+
|
|
315
|
+
# Phase 3: Verify
|
|
316
|
+
Task(subagent_type="general-purpose", description="Re-run tests",
|
|
317
|
+
prompt="Run test suite again to verify fixes")
|
|
318
|
+
````
|
|
319
|
+
|
|
320
|
+
### User Sees
|
|
321
|
+
|
|
322
|
+
```
|
|
323
|
+
Running test suite...
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
Test Results: 47 passed, 3 failed
|
|
328
|
+
|
|
329
|
+
Failures:
|
|
330
|
+
1. auth.test.ts - "should reject expired tokens"
|
|
331
|
+
2. api.test.ts - "should handle rate limiting"
|
|
332
|
+
3. utils.test.ts - "should format dates correctly"
|
|
333
|
+
|
|
334
|
+
Fixing these now...
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
Fixed all 3 failures:
|
|
339
|
+
1. auth.test.ts - Updated mock token expiry time
|
|
340
|
+
2. api.test.ts - Added missing rate limit header in test
|
|
341
|
+
3. utils.test.ts - Fixed timezone handling in date formatter
|
|
342
|
+
|
|
343
|
+
Re-running tests...
|
|
344
|
+
|
|
345
|
+
---
|
|
346
|
+
|
|
347
|
+
All 50 tests passing.
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
---
|
|
351
|
+
|
|
352
|
+
## Key Patterns Summary
|
|
353
|
+
|
|
354
|
+
| Scenario | Pattern | Why |
|
|
355
|
+
| ----------- | ----------------------------- | ----------------------------------- |
|
|
356
|
+
| PR Review | Fan-Out → Reduce | Parallel analysis, unified output |
|
|
357
|
+
| Feature | Pipeline → Fan-Out → Pipeline | Research, parallel build, integrate |
|
|
358
|
+
| Bug Fix | Fan-Out → Pipeline | Parallel diagnosis, sequential fix |
|
|
359
|
+
| Exploration | Fan-Out → Reduce | Parallel discovery, synthesize |
|
|
360
|
+
| Tests | Background → Fan-Out | Long-running, parallel fixes |
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
```
|
|
365
|
+
┌────────────────────────────────────────┐
|
|
366
|
+
│ Remember: │
|
|
367
|
+
│ │
|
|
368
|
+
│ • Users see natural conversation │
|
|
369
|
+
│ • Pattern names stay internal │
|
|
370
|
+
│ • Results feel like magic │
|
|
371
|
+
│ │
|
|
372
|
+
└────────────────────────────────────────┘
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
```
|
|
376
|
+
─── ◈ Examples Complete ─────────────────
|
|
377
|
+
```
|