@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.
Files changed (48) hide show
  1. package/README.md +42 -0
  2. package/dist/cli.js +390 -0
  3. package/dist/lib/interfaces/IDockerClient.js +2 -0
  4. package/dist/lib/interfaces/IMcpClient.js +2 -0
  5. package/dist/lib/interfaces/IServices.js +2 -0
  6. package/dist/lib/interfaces/ITemplateCopier.js +2 -0
  7. package/dist/lib/mcp.js +35 -0
  8. package/dist/lib/services.js +57 -0
  9. package/dist/package.json +36 -0
  10. package/dist/templates/agents/.sample.env +12 -0
  11. package/dist/templates/agents/docs/STORAGE_SETUP.md +161 -0
  12. package/dist/templates/agents/skills/common/group-id.js +193 -0
  13. package/dist/templates/agents/skills/init-review/SKILL.md +119 -0
  14. package/dist/templates/agents/skills/init-review/scripts/ai-enrich.js +258 -0
  15. package/dist/templates/agents/skills/init-review/scripts/init-review.js +769 -0
  16. package/dist/templates/agents/skills/lisa/SKILL.md +92 -0
  17. package/dist/templates/agents/skills/lisa/cache/.gitkeep +0 -0
  18. package/dist/templates/agents/skills/lisa/scripts/storage.js +374 -0
  19. package/dist/templates/agents/skills/memory/SKILL.md +31 -0
  20. package/dist/templates/agents/skills/memory/scripts/memory.js +533 -0
  21. package/dist/templates/agents/skills/prompt/SKILL.md +19 -0
  22. package/dist/templates/agents/skills/prompt/scripts/prompt.js +184 -0
  23. package/dist/templates/agents/skills/tasks/SKILL.md +31 -0
  24. package/dist/templates/agents/skills/tasks/scripts/tasks.js +489 -0
  25. package/dist/templates/claude/config.js +40 -0
  26. package/dist/templates/claude/hooks/README.md +158 -0
  27. package/dist/templates/claude/hooks/common/complexity-rater.js +290 -0
  28. package/dist/templates/claude/hooks/common/context.js +263 -0
  29. package/dist/templates/claude/hooks/common/group-id.js +188 -0
  30. package/dist/templates/claude/hooks/common/mcp-client.js +131 -0
  31. package/dist/templates/claude/hooks/common/transcript-parser.js +256 -0
  32. package/dist/templates/claude/hooks/common/zep-client.js +175 -0
  33. package/dist/templates/claude/hooks/session-start.js +401 -0
  34. package/dist/templates/claude/hooks/session-stop-worker.js +341 -0
  35. package/dist/templates/claude/hooks/session-stop.js +122 -0
  36. package/dist/templates/claude/hooks/user-prompt-submit.js +256 -0
  37. package/dist/templates/claude/settings.json +46 -0
  38. package/dist/templates/docker/.env.lisa.example +17 -0
  39. package/dist/templates/docker/docker-compose.graphiti.yml +45 -0
  40. package/dist/templates/rules/shared/clean-architecture.md +333 -0
  41. package/dist/templates/rules/shared/code-quality-rules.md +469 -0
  42. package/dist/templates/rules/shared/git-rules.md +64 -0
  43. package/dist/templates/rules/shared/testing-principles.md +469 -0
  44. package/dist/templates/rules/typescript/coding-standards.md +751 -0
  45. package/dist/templates/rules/typescript/testing.md +629 -0
  46. package/dist/templates/rules/typescript/typescript-config-guide.md +465 -0
  47. package/package.json +64 -0
  48. package/scripts/postinstall.js +710 -0
@@ -0,0 +1,469 @@
1
+ # Code Quality Rules & Error Prevention Guide
2
+
3
+ This document outlines the rules and configurations that prevent common errors from creeping into the codebase during development.
4
+
5
+ ## Table of Contents
6
+ - [TypeScript Compiler Rules](#typescript-compiler-rules)
7
+ - [ESLint Rules](#eslint-rules)
8
+ - [Development Workflow](#development-workflow)
9
+ - [Error Categories Prevented](#error-categories-prevented)
10
+
11
+ ---
12
+
13
+ ## TypeScript Compiler Rules
14
+
15
+ ### Location: `tsconfig.json`
16
+
17
+ These TypeScript compiler options catch errors at compile time:
18
+
19
+ ### Type Safety Rules
20
+
21
+ ```typescript
22
+ "noImplicitAny": true
23
+ ```
24
+ **Prevents:** Using `any` type implicitly
25
+ **Example Error Caught:** Function parameters without types
26
+
27
+ ```typescript
28
+ "strictNullChecks": true
29
+ ```
30
+ **Prevents:** Null/undefined reference errors
31
+ **Example Error Caught:** Accessing properties on potentially null values
32
+
33
+ ```typescript
34
+ "strictFunctionTypes": true
35
+ ```
36
+ **Prevents:** Function type mismatch errors
37
+ **Example Error Caught:** Passing incompatible function signatures
38
+
39
+ ```typescript
40
+ "noUncheckedIndexedAccess": true
41
+ ```
42
+ **Prevents:** Array/object access without null checks
43
+ **Example Error Caught:** `array[0]` without checking if array has elements
44
+
45
+ ### Code Quality Rules
46
+
47
+ ```typescript
48
+ "noUnusedLocals": true
49
+ "noUnusedParameters": true
50
+ ```
51
+ **Prevents:** Dead code and unused imports
52
+ **Example Error Caught:** Imported but never used variables
53
+
54
+ ```typescript
55
+ "noImplicitReturns": true
56
+ ```
57
+ **Prevents:** Functions missing return statements in some code paths
58
+ **Example Error Caught:** If/else blocks where only one returns a value
59
+
60
+ ```typescript
61
+ "noFallthroughCasesInSwitch": true
62
+ ```
63
+ **Prevents:** Unintentional fall-through in switch statements
64
+ **Example Error Caught:** Missing `break` statements in case blocks
65
+
66
+ ---
67
+
68
+ ## ESLint Rules
69
+
70
+ ### Location: `.eslintrc.json`
71
+
72
+ These rules catch errors and enforce best practices:
73
+
74
+ ### Type Safety Enforcement
75
+
76
+ ```json
77
+ "@typescript-eslint/no-explicit-any": "error"
78
+ ```
79
+ **Prevents:** Using `any` type (forces proper typing)
80
+ **Example Error Caught:**
81
+ ```typescript
82
+ // ❌ Bad
83
+ function processData(data: any) { ... }
84
+
85
+ // ✅ Good
86
+ function processData(data: IMemoryItem) { ... }
87
+ ```
88
+
89
+ ```json
90
+ "@typescript-eslint/no-unsafe-assignment": "warn"
91
+ "@typescript-eslint/no-unsafe-member-access": "warn"
92
+ "@typescript-eslint/no-unsafe-call": "warn"
93
+ ```
94
+ **Prevents:** Unsafe operations on `any` typed values
95
+ **Example Error Caught:** Calling methods on variables typed as `any`
96
+
97
+ ### Async/Promise Safety
98
+
99
+ ```json
100
+ "@typescript-eslint/no-floating-promises": "error"
101
+ ```
102
+ **Prevents:** Forgetting to await promises
103
+ **Example Error Caught:**
104
+ ```typescript
105
+ // ❌ Bad
106
+ async function getData() {
107
+ fetchData(); // Promise not awaited
108
+ }
109
+
110
+ // ✅ Good
111
+ async function getData() {
112
+ await fetchData();
113
+ }
114
+ ```
115
+
116
+ ```json
117
+ "@typescript-eslint/await-thenable": "error"
118
+ ```
119
+ **Prevents:** Using await on non-promise values
120
+ **Example Error Caught:** `await someNumber`
121
+
122
+ ```json
123
+ "@typescript-eslint/no-misused-promises": "error"
124
+ ```
125
+ **Prevents:** Using promises in places that expect synchronous values
126
+ **Example Error Caught:** Passing async function to array.filter()
127
+
128
+ ### Naming Conventions
129
+
130
+ ```json
131
+ "@typescript-eslint/naming-convention": [
132
+ "error",
133
+ {
134
+ "selector": "interface",
135
+ "format": ["PascalCase"],
136
+ "prefix": ["I"]
137
+ }
138
+ ]
139
+ ```
140
+ **Prevents:** Inconsistent interface naming
141
+ **Example Error Caught:**
142
+ ```typescript
143
+ // ❌ Bad
144
+ interface MemoryItem { ... }
145
+
146
+ // ✅ Good
147
+ interface IMemoryItem { ... }
148
+ ```
149
+
150
+ ### Code Quality
151
+
152
+ ```json
153
+ "no-case-declarations": "error"
154
+ ```
155
+ **Prevents:** Variable declarations in switch case blocks without braces
156
+ **Example Error Caught:**
157
+ ```typescript
158
+ // ❌ Bad
159
+ switch (type) {
160
+ case 'memory':
161
+ const item = getMemory();
162
+ break;
163
+ }
164
+
165
+ // ✅ Good
166
+ switch (type) {
167
+ case 'memory': {
168
+ const item = getMemory();
169
+ break;
170
+ }
171
+ }
172
+ ```
173
+
174
+ ```json
175
+ "prefer-rest-params": "error"
176
+ ```
177
+ **Prevents:** Using `arguments` object instead of rest parameters
178
+ **Example Error Caught:**
179
+ ```typescript
180
+ // ❌ Bad
181
+ function log() {
182
+ console.log(arguments);
183
+ }
184
+
185
+ // ✅ Good
186
+ function log(...args: unknown[]) {
187
+ console.log(args);
188
+ }
189
+ ```
190
+
191
+ ### Test File Overrides
192
+
193
+ Test files have relaxed rules for `any` usage:
194
+ ```json
195
+ "overrides": [
196
+ {
197
+ "files": ["**/*.test.ts", "**/*.spec.ts", "**/tests/**/*.ts"],
198
+ "rules": {
199
+ "@typescript-eslint/no-explicit-any": "warn"
200
+ }
201
+ }
202
+ ]
203
+ ```
204
+
205
+ ---
206
+
207
+ ## Development Workflow
208
+
209
+ ### Pre-Commit Checks
210
+
211
+ Run before every commit:
212
+ ```bash
213
+ npm run pre-commit
214
+ ```
215
+
216
+ This runs:
217
+ 1. Type checking (`tsc --noEmit`)
218
+ 2. Linting with auto-fix (`eslint --fix`)
219
+ 3. Code formatting (`prettier --write`)
220
+
221
+ ### Continuous Validation
222
+
223
+ Run to validate everything:
224
+ ```bash
225
+ npm run validate
226
+ ```
227
+
228
+ This runs:
229
+ 1. Type checking
230
+ 2. Linting
231
+ 3. All tests
232
+
233
+ ### Individual Commands
234
+
235
+ ```bash
236
+ # Type check only
237
+ npm run type-check
238
+
239
+ # Lint only
240
+ npm run lint
241
+
242
+ # Lint with auto-fix
243
+ npm run lint:fix
244
+
245
+ # Format code
246
+ npm run format
247
+
248
+ # Build with type check
249
+ npm run build:check
250
+ ```
251
+
252
+ ---
253
+
254
+ ## Error Categories Prevented
255
+
256
+ ### 1. Import/Export Errors
257
+
258
+ **Problem:** Types imported but not re-exported from interface files
259
+
260
+ **Prevention:**
261
+ - Type checking catches missing exports
262
+ - ESLint catches unused imports
263
+
264
+ **Example:**
265
+ ```typescript
266
+ // IGuardrail.ts
267
+ import { GuardrailType } from './IGuardrailService';
268
+
269
+ // Must re-export for other files to use
270
+ export { GuardrailType };
271
+ ```
272
+
273
+ ### 2. Missing Properties
274
+
275
+ **Problem:** Interface properties not provided in fixtures/mocks
276
+
277
+ **Prevention:**
278
+ - `strictPropertyInitialization` catches missing required properties
279
+ - Type checking enforces complete object literals
280
+
281
+ **Example:**
282
+ ```typescript
283
+ interface IMemoryPattern {
284
+ id: string;
285
+ frequency: number; // Required!
286
+ metrics: { ... }; // Required!
287
+ }
288
+
289
+ // ❌ TypeScript error: Missing 'frequency' and 'metrics'
290
+ const pattern: IMemoryPattern = {
291
+ id: '123'
292
+ };
293
+ ```
294
+
295
+ ### 3. Type Mismatches
296
+
297
+ **Problem:** Wrong types passed to functions
298
+
299
+ **Prevention:**
300
+ - `strictFunctionTypes` catches parameter type mismatches
301
+ - `noImplicitAny` forces explicit typing
302
+
303
+ **Example:**
304
+ ```typescript
305
+ // ❌ Error caught at compile time
306
+ createSimpleTask({ type: 'test' }); // expects string, got object
307
+
308
+ // ✅ Correct
309
+ createSimpleTask('test');
310
+ ```
311
+
312
+ ### 4. Incomplete Mocks
313
+
314
+ **Problem:** Mock objects missing required methods
315
+
316
+ **Prevention:**
317
+ - Type checking against interface definitions
318
+ - `@typescript-eslint/no-unsafe-call` warns on missing methods
319
+
320
+ **Example:**
321
+ ```typescript
322
+ // Interface defines 18 methods
323
+ interface IGuardrailService {
324
+ analyzePatterns(...): Promise<...>;
325
+ generateGuardrails(...): Promise<...>;
326
+ // ... 16 more
327
+ }
328
+
329
+ // Mock must implement all methods or TypeScript error
330
+ const mock: IGuardrailService = {
331
+ // Must include all 18 methods
332
+ };
333
+ ```
334
+
335
+ ### 5. Array/Object Safety
336
+
337
+ **Problem:** Accessing array elements or object properties that might not exist
338
+
339
+ **Prevention:**
340
+ - `noUncheckedIndexedAccess` forces null checks
341
+
342
+ **Example:**
343
+ ```typescript
344
+ // With noUncheckedIndexedAccess
345
+ const items: string[] = [];
346
+ const first = items[0]; // Type: string | undefined
347
+
348
+ // Must check before using
349
+ if (first !== undefined) {
350
+ console.log(first.toUpperCase());
351
+ }
352
+ ```
353
+
354
+ ### 6. Async/Promise Errors
355
+
356
+ **Problem:** Forgetting to await promises or misusing async functions
357
+
358
+ **Prevention:**
359
+ - `no-floating-promises` catches unawaited promises
360
+ - `await-thenable` catches invalid await usage
361
+
362
+ **Example:**
363
+ ```typescript
364
+ // ❌ Error: Promise not handled
365
+ async function getData() {
366
+ fetchData(); // ESLint error: floating promise
367
+ }
368
+
369
+ // ✅ Correct
370
+ async function getData() {
371
+ await fetchData();
372
+ }
373
+ ```
374
+
375
+ ---
376
+
377
+ ## IDE Integration
378
+
379
+ ### VS Code Settings (`.vscode/settings.json`)
380
+
381
+ The project includes VS Code settings that:
382
+
383
+ 1. **Auto-fix on save**: Runs ESLint fixes when you save
384
+ 2. **Format on save**: Runs Prettier formatting
385
+ 3. **Organize imports**: Removes unused imports automatically
386
+ 4. **Type checking**: Shows TypeScript errors in real-time
387
+ 5. **Hide generated files**: Excludes `.d.ts` files from explorer
388
+
389
+ ### Required VS Code Extensions
390
+
391
+ - ESLint (`dbaeumer.vscode-eslint`)
392
+ - Prettier (`esbenp.prettier-vscode`)
393
+ - TypeScript and JavaScript Language Features (built-in)
394
+
395
+ ---
396
+
397
+ ## Git Hooks (Optional Setup)
398
+
399
+ To automatically run checks before commits, install husky:
400
+
401
+ ```bash
402
+ npm install --save-dev husky lint-staged
403
+ npx husky init
404
+ ```
405
+
406
+ Create `.husky/pre-commit`:
407
+ ```bash
408
+ #!/usr/bin/env sh
409
+ . "$(dirname -- "$0")/_/husky.sh"
410
+
411
+ npm run pre-commit
412
+ ```
413
+
414
+ ---
415
+
416
+ ## CI/CD Pipeline
417
+
418
+ For GitHub Actions, add `.github/workflows/ci.yml`:
419
+
420
+ ```yaml
421
+ name: CI
422
+ on: [push, pull_request]
423
+ jobs:
424
+ test:
425
+ runs-on: ubuntu-latest
426
+ steps:
427
+ - uses: actions/checkout@v3
428
+ - uses: actions/setup-node@v3
429
+ with:
430
+ node-version: '18'
431
+ - run: npm ci
432
+ - run: npm run type-check
433
+ - run: npm run lint
434
+ - run: npm test
435
+ ```
436
+
437
+ ---
438
+
439
+ ## Summary Checklist
440
+
441
+ Before committing code, ensure:
442
+
443
+ - [ ] TypeScript compiles without errors (`npm run type-check`)
444
+ - [ ] ESLint passes without errors (`npm run lint`)
445
+ - [ ] All tests pass (`npm test`)
446
+ - [ ] Code is formatted (`npm run format`)
447
+ - [ ] No `any` types in production code
448
+ - [ ] All interfaces start with `I`
449
+ - [ ] All promises are awaited
450
+ - [ ] No unused variables or imports
451
+ - [ ] Switch cases use block scope `{ }`
452
+ - [ ] Mock objects include all required methods
453
+
454
+ ---
455
+
456
+ ## Quick Reference
457
+
458
+ | Error Type | Prevention Rule | Location |
459
+ |------------|----------------|----------|
460
+ | Missing exports | Type checking | tsconfig.json |
461
+ | Any types | `no-explicit-any` | .eslintrc.json |
462
+ | Missing properties | `strictPropertyInitialization` | tsconfig.json |
463
+ | Type mismatches | `strictFunctionTypes` | tsconfig.json |
464
+ | Unawaited promises | `no-floating-promises` | .eslintrc.json |
465
+ | Unused code | `noUnusedLocals` | tsconfig.json |
466
+ | Null safety | `strictNullChecks` | tsconfig.json |
467
+ | Array bounds | `noUncheckedIndexedAccess` | tsconfig.json |
468
+ | Switch declarations | `no-case-declarations` | .eslintrc.json |
469
+ | Arguments object | `prefer-rest-params` | .eslintrc.json |
@@ -0,0 +1,64 @@
1
+ # Git Workflow Rules
2
+
3
+ ## Commit Memory Rule
4
+
5
+ **IMPORTANT:** After every successful git commit, you MUST create a milestone memory summarizing what was committed.
6
+
7
+ ### How to Create Commit Memory
8
+
9
+ After a commit succeeds, run:
10
+ ```bash
11
+ node .agents/skills/memory/scripts/memory.js add "<summary>" --cache --type milestone
12
+ ```
13
+
14
+ ### Summary Format
15
+
16
+ The summary should be concise and describe:
17
+ - What was added/changed/fixed
18
+ - Key features or improvements
19
+ - Any breaking changes
20
+
21
+ ### Examples
22
+
23
+ **Feature commit:**
24
+ ```bash
25
+ node .agents/skills/memory/scripts/memory.js add "FEATURE: Added user authentication with JWT tokens and session management" --cache --type milestone
26
+ ```
27
+
28
+ **Bug fix:**
29
+ ```bash
30
+ node .agents/skills/memory/scripts/memory.js add "FIX: Resolved race condition in database connection pooling" --cache --type milestone
31
+ ```
32
+
33
+ **Refactor:**
34
+ ```bash
35
+ node .agents/skills/memory/scripts/memory.js add "REFACTOR: Migrated API handlers to use clean architecture pattern" --cache --type milestone
36
+ ```
37
+
38
+ ### Why This Matters
39
+
40
+ - Creates a searchable history of development progress
41
+ - Helps future sessions understand what was accomplished
42
+ - Builds project context for AI assistants
43
+ - Tracks milestones and features over time
44
+
45
+ ## General Git Rules
46
+
47
+ ### Commit Messages
48
+
49
+ - Use conventional commit format: `type: description`
50
+ - Types: `feat`, `fix`, `refactor`, `docs`, `test`, `chore`
51
+ - Keep first line under 72 characters
52
+ - Add body for complex changes
53
+
54
+ ### Before Committing
55
+
56
+ - Run tests if available
57
+ - Check for linting errors
58
+ - Review staged changes with `git diff --staged`
59
+
60
+ ### Branch Hygiene
61
+
62
+ - Keep commits focused and atomic
63
+ - Don't mix unrelated changes in one commit
64
+ - Write meaningful commit messages