@tonycasey/lisa 0.5.13
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 +42 -0
- package/dist/cli.js +390 -0
- package/dist/lib/interfaces/IDockerClient.js +2 -0
- package/dist/lib/interfaces/IMcpClient.js +2 -0
- package/dist/lib/interfaces/IServices.js +2 -0
- package/dist/lib/interfaces/ITemplateCopier.js +2 -0
- package/dist/lib/mcp.js +35 -0
- package/dist/lib/services.js +57 -0
- package/dist/package.json +36 -0
- package/dist/templates/agents/.sample.env +12 -0
- package/dist/templates/agents/docs/STORAGE_SETUP.md +161 -0
- package/dist/templates/agents/skills/common/group-id.js +193 -0
- package/dist/templates/agents/skills/init-review/SKILL.md +119 -0
- package/dist/templates/agents/skills/init-review/scripts/ai-enrich.js +258 -0
- package/dist/templates/agents/skills/init-review/scripts/init-review.js +769 -0
- package/dist/templates/agents/skills/lisa/SKILL.md +92 -0
- package/dist/templates/agents/skills/lisa/cache/.gitkeep +0 -0
- package/dist/templates/agents/skills/lisa/scripts/storage.js +374 -0
- package/dist/templates/agents/skills/memory/SKILL.md +31 -0
- package/dist/templates/agents/skills/memory/scripts/memory.js +533 -0
- package/dist/templates/agents/skills/prompt/SKILL.md +19 -0
- package/dist/templates/agents/skills/prompt/scripts/prompt.js +184 -0
- package/dist/templates/agents/skills/tasks/SKILL.md +31 -0
- package/dist/templates/agents/skills/tasks/scripts/tasks.js +489 -0
- package/dist/templates/claude/config.js +40 -0
- package/dist/templates/claude/hooks/README.md +158 -0
- package/dist/templates/claude/hooks/common/complexity-rater.js +290 -0
- package/dist/templates/claude/hooks/common/context.js +263 -0
- package/dist/templates/claude/hooks/common/group-id.js +188 -0
- package/dist/templates/claude/hooks/common/mcp-client.js +131 -0
- package/dist/templates/claude/hooks/common/transcript-parser.js +256 -0
- package/dist/templates/claude/hooks/common/zep-client.js +175 -0
- package/dist/templates/claude/hooks/session-start.js +401 -0
- package/dist/templates/claude/hooks/session-stop-worker.js +341 -0
- package/dist/templates/claude/hooks/session-stop.js +122 -0
- package/dist/templates/claude/hooks/user-prompt-submit.js +256 -0
- package/dist/templates/claude/settings.json +46 -0
- package/dist/templates/docker/.env.lisa.example +17 -0
- package/dist/templates/docker/docker-compose.graphiti.yml +45 -0
- package/dist/templates/rules/shared/clean-architecture.md +333 -0
- package/dist/templates/rules/shared/code-quality-rules.md +469 -0
- package/dist/templates/rules/shared/git-rules.md +64 -0
- package/dist/templates/rules/shared/testing-principles.md +469 -0
- package/dist/templates/rules/typescript/coding-standards.md +751 -0
- package/dist/templates/rules/typescript/testing.md +629 -0
- package/dist/templates/rules/typescript/typescript-config-guide.md +465 -0
- package/package.json +64 -0
- package/scripts/postinstall.js +710 -0
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
# Testing Principles
|
|
2
|
+
|
|
3
|
+
**Note:** These principles apply to ALL programming languages. See your language-specific rules for testing frameworks and syntax.
|
|
4
|
+
|
|
5
|
+
## Testing Pyramid
|
|
6
|
+
|
|
7
|
+
The testing pyramid guides how much testing to do at each level:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
/\
|
|
11
|
+
/ \ E2E Tests (10%)
|
|
12
|
+
/____\
|
|
13
|
+
/ \ Integration Tests (20%)
|
|
14
|
+
/________\
|
|
15
|
+
/ \ Unit Tests (70%)
|
|
16
|
+
/____________\
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Unit Tests (70%)
|
|
20
|
+
|
|
21
|
+
**What:** Test individual components in isolation
|
|
22
|
+
|
|
23
|
+
**Characteristics:**
|
|
24
|
+
- Fast (milliseconds)
|
|
25
|
+
- No external dependencies
|
|
26
|
+
- Test one thing at a time
|
|
27
|
+
- Use mocks/stubs for dependencies
|
|
28
|
+
|
|
29
|
+
**Examples:**
|
|
30
|
+
- Domain entity behavior
|
|
31
|
+
- Business logic in services
|
|
32
|
+
- Validation rules
|
|
33
|
+
- Utility functions
|
|
34
|
+
|
|
35
|
+
### Integration Tests (20%)
|
|
36
|
+
|
|
37
|
+
**What:** Test components working together
|
|
38
|
+
|
|
39
|
+
**Characteristics:**
|
|
40
|
+
- Slower (seconds)
|
|
41
|
+
- May use real dependencies (database, etc.)
|
|
42
|
+
- Test integration points
|
|
43
|
+
- Verify contracts between layers
|
|
44
|
+
|
|
45
|
+
**Examples:**
|
|
46
|
+
- Repository with real database
|
|
47
|
+
- Service with real repositories
|
|
48
|
+
- API endpoint with real database
|
|
49
|
+
- External service integration
|
|
50
|
+
|
|
51
|
+
### End-to-End Tests (10%)
|
|
52
|
+
|
|
53
|
+
**What:** Test complete user workflows
|
|
54
|
+
|
|
55
|
+
**Characteristics:**
|
|
56
|
+
- Slowest (minutes)
|
|
57
|
+
- Uses real system
|
|
58
|
+
- Tests critical user paths
|
|
59
|
+
- Brittle, expensive to maintain
|
|
60
|
+
|
|
61
|
+
**Examples:**
|
|
62
|
+
- User registration flow
|
|
63
|
+
- Checkout process
|
|
64
|
+
- Complete order workflow
|
|
65
|
+
|
|
66
|
+
## Testing Principles
|
|
67
|
+
|
|
68
|
+
### 1. Tests Should Be FIRST
|
|
69
|
+
|
|
70
|
+
- **Fast**: Run quickly (unit tests in milliseconds)
|
|
71
|
+
- **Independent**: Don't depend on other tests
|
|
72
|
+
- **Repeatable**: Same result every time
|
|
73
|
+
- **Self-Validating**: Pass or fail, no manual checking
|
|
74
|
+
- **Timely**: Written with or before the code
|
|
75
|
+
|
|
76
|
+
### 2. Arrange-Act-Assert Pattern
|
|
77
|
+
|
|
78
|
+
Structure tests in three clear phases:
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
// Arrange - Set up test data and dependencies
|
|
82
|
+
setup test data
|
|
83
|
+
create mocks
|
|
84
|
+
configure system
|
|
85
|
+
|
|
86
|
+
// Act - Execute the behavior being tested
|
|
87
|
+
result = systemUnderTest.method(input)
|
|
88
|
+
|
|
89
|
+
// Assert - Verify the outcome
|
|
90
|
+
assert result equals expected
|
|
91
|
+
assert mock was called correctly
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 3. Test Behavior, Not Implementation
|
|
95
|
+
|
|
96
|
+
**Good:** Test what the code does (public interface)
|
|
97
|
+
**Bad:** Test how it does it (internal details)
|
|
98
|
+
|
|
99
|
+
**Why:**
|
|
100
|
+
- Tests survive refactoring
|
|
101
|
+
- More maintainable
|
|
102
|
+
- Focus on contracts
|
|
103
|
+
|
|
104
|
+
### 4. One Assertion Per Test Concept
|
|
105
|
+
|
|
106
|
+
Each test should verify one logical concept.
|
|
107
|
+
|
|
108
|
+
**Not:** One assert statement per test
|
|
109
|
+
**Instead:** One logical verification per test
|
|
110
|
+
|
|
111
|
+
Multiple asserts are fine if they verify the same concept.
|
|
112
|
+
|
|
113
|
+
### 5. Meaningful Test Names
|
|
114
|
+
|
|
115
|
+
Test names should describe:
|
|
116
|
+
- What is being tested
|
|
117
|
+
- Under what conditions
|
|
118
|
+
- What the expected outcome is
|
|
119
|
+
|
|
120
|
+
**Patterns:**
|
|
121
|
+
- `methodName_givenCondition_shouldExpectedOutcome`
|
|
122
|
+
- `should_expectedOutcome_when_condition`
|
|
123
|
+
- `test_specificBehavior`
|
|
124
|
+
|
|
125
|
+
## Test Organization
|
|
126
|
+
|
|
127
|
+
### Test File Structure
|
|
128
|
+
|
|
129
|
+
Tests should mirror source code structure:
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
src/
|
|
133
|
+
└── domain/
|
|
134
|
+
└── services/
|
|
135
|
+
└── ProductService
|
|
136
|
+
|
|
137
|
+
tests/
|
|
138
|
+
└── unit/
|
|
139
|
+
└── domain/
|
|
140
|
+
└── services/
|
|
141
|
+
└── ProductService.test
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Test Suite Organization
|
|
145
|
+
|
|
146
|
+
Group related tests with clear hierarchy:
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
describe ProductService
|
|
150
|
+
describe getById
|
|
151
|
+
test should return product when exists
|
|
152
|
+
test should throw error when not found
|
|
153
|
+
test should handle invalid ID format
|
|
154
|
+
|
|
155
|
+
describe create
|
|
156
|
+
test should create product with valid data
|
|
157
|
+
test should validate required fields
|
|
158
|
+
test should throw error for duplicate SKU
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Mocking Strategies
|
|
162
|
+
|
|
163
|
+
### When to Mock
|
|
164
|
+
|
|
165
|
+
**Mock:**
|
|
166
|
+
- External dependencies (database, API, file system)
|
|
167
|
+
- Dependencies in unit tests
|
|
168
|
+
- Slow or non-deterministic operations
|
|
169
|
+
- Components you don't control
|
|
170
|
+
|
|
171
|
+
**Don't mock:**
|
|
172
|
+
- The system under test
|
|
173
|
+
- Simple value objects
|
|
174
|
+
- Domain entities (usually)
|
|
175
|
+
- Trivial dependencies
|
|
176
|
+
|
|
177
|
+
### Types of Test Doubles
|
|
178
|
+
|
|
179
|
+
1. **Dummy**: Passed but never used
|
|
180
|
+
2. **Stub**: Returns predefined values
|
|
181
|
+
3. **Spy**: Records how it was called
|
|
182
|
+
4. **Mock**: Pre-programmed with expectations
|
|
183
|
+
5. **Fake**: Working implementation (e.g., in-memory database)
|
|
184
|
+
|
|
185
|
+
### Mock Verification
|
|
186
|
+
|
|
187
|
+
Verify mocks were called correctly:
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
// Verify method was called
|
|
191
|
+
assert mock.method was called
|
|
192
|
+
|
|
193
|
+
// Verify with specific arguments
|
|
194
|
+
assert mock.method was called with (arg1, arg2)
|
|
195
|
+
|
|
196
|
+
// Verify call count
|
|
197
|
+
assert mock.method was called exactly once
|
|
198
|
+
|
|
199
|
+
// Verify order
|
|
200
|
+
assert mock.methodA was called before mock.methodB
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Testing Repositories
|
|
204
|
+
|
|
205
|
+
### Unit Tests (Mocked)
|
|
206
|
+
|
|
207
|
+
Test services using repository interfaces:
|
|
208
|
+
|
|
209
|
+
**What to test:**
|
|
210
|
+
- Business logic using the repository
|
|
211
|
+
- Error handling
|
|
212
|
+
- Edge cases
|
|
213
|
+
|
|
214
|
+
**How:**
|
|
215
|
+
- Mock the repository interface
|
|
216
|
+
- Configure return values
|
|
217
|
+
- Verify correct calls
|
|
218
|
+
|
|
219
|
+
### Integration Tests (Real Database)
|
|
220
|
+
|
|
221
|
+
Test repository implementations:
|
|
222
|
+
|
|
223
|
+
**What to test:**
|
|
224
|
+
- CRUD operations work correctly
|
|
225
|
+
- Query methods return right data
|
|
226
|
+
- Constraints are enforced
|
|
227
|
+
- Transactions work
|
|
228
|
+
|
|
229
|
+
**How:**
|
|
230
|
+
- Use test database
|
|
231
|
+
- Clean up after each test
|
|
232
|
+
- Test with real data
|
|
233
|
+
|
|
234
|
+
## Testing Services
|
|
235
|
+
|
|
236
|
+
### Test with Mocked Dependencies
|
|
237
|
+
|
|
238
|
+
Services should be tested with mocked repositories:
|
|
239
|
+
|
|
240
|
+
**Setup:**
|
|
241
|
+
1. Create mock repositories
|
|
242
|
+
2. Configure mock responses
|
|
243
|
+
3. Inject mocks into service
|
|
244
|
+
4. Test service behavior
|
|
245
|
+
|
|
246
|
+
**Verify:**
|
|
247
|
+
- Service returns correct results
|
|
248
|
+
- Service calls repositories correctly
|
|
249
|
+
- Service handles errors
|
|
250
|
+
- Service implements business logic
|
|
251
|
+
|
|
252
|
+
### Test Error Handling
|
|
253
|
+
|
|
254
|
+
Every error path should be tested:
|
|
255
|
+
|
|
256
|
+
**Scenarios:**
|
|
257
|
+
- Invalid input
|
|
258
|
+
- Not found errors
|
|
259
|
+
- Constraint violations
|
|
260
|
+
- External service failures
|
|
261
|
+
|
|
262
|
+
## Test Data Management
|
|
263
|
+
|
|
264
|
+
### Test Fixtures
|
|
265
|
+
|
|
266
|
+
Reusable test data:
|
|
267
|
+
|
|
268
|
+
**Benefits:**
|
|
269
|
+
- Consistent test data
|
|
270
|
+
- DRY principle
|
|
271
|
+
- Easy to maintain
|
|
272
|
+
|
|
273
|
+
**Approaches:**
|
|
274
|
+
- Factory functions
|
|
275
|
+
- Builder pattern
|
|
276
|
+
- Fixture files
|
|
277
|
+
|
|
278
|
+
### Test Data Builders
|
|
279
|
+
|
|
280
|
+
Use builders for complex objects:
|
|
281
|
+
|
|
282
|
+
**Benefits:**
|
|
283
|
+
- Flexible test data creation
|
|
284
|
+
- Clear test setup
|
|
285
|
+
- Easy to customize
|
|
286
|
+
|
|
287
|
+
**Pattern:**
|
|
288
|
+
```
|
|
289
|
+
builder = EntityBuilder()
|
|
290
|
+
.withProperty1(value1)
|
|
291
|
+
.withProperty2(value2)
|
|
292
|
+
|
|
293
|
+
entity = builder.build()
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### Data Cleanup
|
|
297
|
+
|
|
298
|
+
Clean up test data after tests:
|
|
299
|
+
|
|
300
|
+
**Why:**
|
|
301
|
+
- Tests remain independent
|
|
302
|
+
- Avoid side effects
|
|
303
|
+
- Fresh state for each test
|
|
304
|
+
|
|
305
|
+
**How:**
|
|
306
|
+
- Use setup/teardown hooks
|
|
307
|
+
- Clean database in integration tests
|
|
308
|
+
- Reset mocks in unit tests
|
|
309
|
+
|
|
310
|
+
## Test Coverage
|
|
311
|
+
|
|
312
|
+
### Coverage Goals
|
|
313
|
+
|
|
314
|
+
**Targets:**
|
|
315
|
+
- Critical business logic: 95%+
|
|
316
|
+
- Services and repositories: 90%+
|
|
317
|
+
- Utilities and helpers: 80%+
|
|
318
|
+
- Overall project: 80%+
|
|
319
|
+
|
|
320
|
+
### What NOT to Test
|
|
321
|
+
|
|
322
|
+
Don't waste time testing:
|
|
323
|
+
- Third-party libraries
|
|
324
|
+
- Framework code
|
|
325
|
+
- Generated code
|
|
326
|
+
- Simple getters/setters
|
|
327
|
+
- Configuration files
|
|
328
|
+
|
|
329
|
+
### Coverage vs Quality
|
|
330
|
+
|
|
331
|
+
**Remember:**
|
|
332
|
+
- 100% coverage doesn't mean bug-free
|
|
333
|
+
- Focus on meaningful tests
|
|
334
|
+
- Quality over quantity
|
|
335
|
+
- Test important paths first
|
|
336
|
+
|
|
337
|
+
## Testing Async Code
|
|
338
|
+
|
|
339
|
+
### Promises/Futures
|
|
340
|
+
|
|
341
|
+
Test asynchronous operations properly:
|
|
342
|
+
|
|
343
|
+
**Requirements:**
|
|
344
|
+
- Await async operations
|
|
345
|
+
- Handle rejections/errors
|
|
346
|
+
- Test timeout scenarios
|
|
347
|
+
- Verify async error handling
|
|
348
|
+
|
|
349
|
+
### Callbacks
|
|
350
|
+
|
|
351
|
+
If using callbacks:
|
|
352
|
+
- Use test framework support
|
|
353
|
+
- Mark test as async
|
|
354
|
+
- Call done/completion
|
|
355
|
+
- Handle timeouts
|
|
356
|
+
|
|
357
|
+
## Performance Testing
|
|
358
|
+
|
|
359
|
+
### Test Speed
|
|
360
|
+
|
|
361
|
+
**Unit tests:**
|
|
362
|
+
- Should run in milliseconds
|
|
363
|
+
- No I/O operations
|
|
364
|
+
- No network calls
|
|
365
|
+
- No database access
|
|
366
|
+
|
|
367
|
+
**Integration tests:**
|
|
368
|
+
- Should run in seconds
|
|
369
|
+
- Can use real dependencies
|
|
370
|
+
- Should still be reasonably fast
|
|
371
|
+
|
|
372
|
+
### Parallel Execution
|
|
373
|
+
|
|
374
|
+
Run tests in parallel:
|
|
375
|
+
- Speeds up test suite
|
|
376
|
+
- Tests must be independent
|
|
377
|
+
- No shared state
|
|
378
|
+
- Careful with database tests
|
|
379
|
+
|
|
380
|
+
## Common Anti-Patterns
|
|
381
|
+
|
|
382
|
+
### ❌ Testing Implementation Details
|
|
383
|
+
|
|
384
|
+
**Problem:** Tests break on refactoring
|
|
385
|
+
|
|
386
|
+
**Solution:** Test public interface and behavior
|
|
387
|
+
|
|
388
|
+
### ❌ One Giant Test
|
|
389
|
+
|
|
390
|
+
**Problem:** Hard to debug failures, tests multiple things
|
|
391
|
+
|
|
392
|
+
**Solution:** Split into focused tests
|
|
393
|
+
|
|
394
|
+
### ❌ Test Interdependence
|
|
395
|
+
|
|
396
|
+
**Problem:** Tests depend on each other's state
|
|
397
|
+
|
|
398
|
+
**Solution:** Make tests independent with setup/teardown
|
|
399
|
+
|
|
400
|
+
### ❌ Ignoring Failures
|
|
401
|
+
|
|
402
|
+
**Problem:** Commented out or skipped failing tests
|
|
403
|
+
|
|
404
|
+
**Solution:** Fix or delete, don't ignore
|
|
405
|
+
|
|
406
|
+
### ❌ No Assertions
|
|
407
|
+
|
|
408
|
+
**Problem:** Test runs but doesn't verify anything
|
|
409
|
+
|
|
410
|
+
**Solution:** Every test needs assertions
|
|
411
|
+
|
|
412
|
+
### ❌ Overuse of Mocks
|
|
413
|
+
|
|
414
|
+
**Problem:** Mocking everything, including trivial code
|
|
415
|
+
|
|
416
|
+
**Solution:** Only mock external dependencies
|
|
417
|
+
|
|
418
|
+
## Test-Driven Development (TDD)
|
|
419
|
+
|
|
420
|
+
### Red-Green-Refactor Cycle
|
|
421
|
+
|
|
422
|
+
1. **Red**: Write a failing test
|
|
423
|
+
2. **Green**: Write minimum code to pass
|
|
424
|
+
3. **Refactor**: Improve code while keeping tests green
|
|
425
|
+
|
|
426
|
+
### Benefits of TDD
|
|
427
|
+
|
|
428
|
+
- Better design (testable by default)
|
|
429
|
+
- Living documentation
|
|
430
|
+
- Confidence in changes
|
|
431
|
+
- Fewer bugs
|
|
432
|
+
|
|
433
|
+
### When to Use TDD
|
|
434
|
+
|
|
435
|
+
**Good for:**
|
|
436
|
+
- Well-understood requirements
|
|
437
|
+
- Complex business logic
|
|
438
|
+
- Critical functionality
|
|
439
|
+
- Learning new concepts
|
|
440
|
+
|
|
441
|
+
**Skip for:**
|
|
442
|
+
- Prototyping
|
|
443
|
+
- UI exploration
|
|
444
|
+
- Spike solutions
|
|
445
|
+
- Trivial code
|
|
446
|
+
|
|
447
|
+
## Testing Checklist
|
|
448
|
+
|
|
449
|
+
- [ ] Tests follow FIRST principles
|
|
450
|
+
- [ ] Test pyramid respected (70/20/10)
|
|
451
|
+
- [ ] Arrange-Act-Assert structure
|
|
452
|
+
- [ ] Meaningful test names
|
|
453
|
+
- [ ] Tests are independent
|
|
454
|
+
- [ ] One concept per test
|
|
455
|
+
- [ ] Appropriate use of mocks
|
|
456
|
+
- [ ] Error cases tested
|
|
457
|
+
- [ ] Test data cleaned up
|
|
458
|
+
- [ ] Tests run fast
|
|
459
|
+
- [ ] Coverage on critical paths
|
|
460
|
+
- [ ] Tests are maintainable
|
|
461
|
+
|
|
462
|
+
## Language-Specific Testing
|
|
463
|
+
|
|
464
|
+
For testing frameworks, assertion libraries, and syntax in your language:
|
|
465
|
+
|
|
466
|
+
- **TypeScript**: `languages/typescript/testing.md`
|
|
467
|
+
- **Python**: `languages/python/testing.md`
|
|
468
|
+
- **Go**: `languages/go/testing.md`
|
|
469
|
+
- **Java**: `languages/java/testing.md`
|