@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,465 @@
1
+ # TypeScript Configuration Guide
2
+ ## Avoiding Common Errors in Development
3
+
4
+ This guide documents lessons learned from resolving 300+ TypeScript errors in the ai-refactor-framework project.
5
+
6
+ ---
7
+
8
+ ## 🎯 Core Principles
9
+
10
+ ### 1. **Separate Production and Test Configurations**
11
+ ```
12
+ ✅ GOOD: Different strictness levels for different contexts
13
+ ❌ BAD: One config for everything
14
+ ```
15
+
16
+ ### 2. **Relaxed Settings During Active Development**
17
+ ```
18
+ ✅ GOOD: Enable strict mode when stabilizing for production
19
+ ❌ BAD: Ultra-strict from day one (blocks rapid iteration)
20
+ ```
21
+
22
+ ### 3. **Explicit Exclusions**
23
+ ```
24
+ ✅ GOOD: Explicitly exclude examples, tests, demos
25
+ ❌ BAD: Let TypeScript check everything
26
+ ```
27
+
28
+ ---
29
+
30
+ ## 📋 Recommended tsconfig.json Settings
31
+
32
+ ### For Main Project (src/)
33
+
34
+ ```json
35
+ {
36
+ "compilerOptions": {
37
+ // Target & Module
38
+ "target": "ES2022",
39
+ "module": "commonjs",
40
+ "lib": ["ES2022"],
41
+ "moduleResolution": "node",
42
+
43
+ // Output
44
+ "outDir": "./dist",
45
+ "sourceMap": true,
46
+ "declaration": true,
47
+
48
+ // Strictness - RELAXED for development
49
+ "strict": false, // 🔑 Master switch
50
+ "noImplicitAny": false, // 🔑 Allow 'any' during prototyping
51
+ "strictNullChecks": false, // 🔑 Don't require null checks everywhere
52
+ "strictPropertyInitialization": false, // 🔑 Don't require all properties initialized
53
+ "noUnusedLocals": false, // 🔑 Allow unused variables
54
+ "noUnusedParameters": false, // 🔑 Allow unused parameters
55
+
56
+ // Keep these enabled - they catch real bugs
57
+ "noImplicitReturns": true,
58
+ "noFallthroughCasesInSwitch": true,
59
+
60
+ // Performance
61
+ "skipLibCheck": true, // 🔑 Skip checking node_modules
62
+ "forceConsistentCasingInFileNames": true,
63
+
64
+ // Interop
65
+ "esModuleInterop": true,
66
+ "allowSyntheticDefaultImports": true,
67
+ "resolveJsonModule": true,
68
+
69
+ // Paths
70
+ "baseUrl": ".",
71
+ "paths": {
72
+ "@/*": ["src/*"]
73
+ }
74
+ },
75
+
76
+ // 🔑 Explicit include
77
+ "include": [
78
+ "src/**/*"
79
+ ],
80
+
81
+ // 🔑 Explicit exclude
82
+ "exclude": [
83
+ "node_modules",
84
+ "dist",
85
+ "**/*.test.ts",
86
+ "**/*.spec.ts",
87
+ "tests",
88
+ "examples",
89
+ "services",
90
+ "packages"
91
+ ]
92
+ }
93
+ ```
94
+
95
+ ### For Test Files (tsconfig.test.json)
96
+
97
+ ```json
98
+ {
99
+ "extends": "./tsconfig.json",
100
+ "compilerOptions": {
101
+ "rootDir": ".",
102
+ "noEmit": true,
103
+
104
+ // EXTRA RELAXED for tests
105
+ "strict": false,
106
+ "noImplicitAny": false,
107
+ "strictNullChecks": false,
108
+ "strictPropertyInitialization": false,
109
+ "noUnusedLocals": false,
110
+ "noUnusedParameters": false
111
+ },
112
+ "include": [
113
+ "src/**/*",
114
+ "tests/**/*"
115
+ ],
116
+ "exclude": [
117
+ "node_modules",
118
+ "dist"
119
+ ]
120
+ }
121
+ ```
122
+
123
+ ### For Monorepo Packages
124
+
125
+ ```json
126
+ {
127
+ "compilerOptions": {
128
+ "target": "ES2022",
129
+ "module": "commonjs",
130
+ "lib": ["ES2022"],
131
+ "outDir": "./dist",
132
+
133
+ // 🔑 KEY: No rootDir if importing from other packages
134
+ // "rootDir": "./src", ❌ CAUSES ERRORS
135
+
136
+ "strict": false,
137
+ "skipLibCheck": true,
138
+ "esModuleInterop": true,
139
+
140
+ // Paths relative to project root
141
+ "baseUrl": "../../..",
142
+ "paths": {
143
+ "@/*": ["src/*"],
144
+ "@/services/agents/base-agent/*": ["services/agents/base-agent/src/*"]
145
+ },
146
+
147
+ // Relaxed for development
148
+ "noUnusedLocals": false,
149
+ "noUnusedParameters": false,
150
+ "strictNullChecks": false,
151
+ "noImplicitAny": false
152
+ },
153
+ "include": ["src/**/*"],
154
+ "exclude": [
155
+ "node_modules",
156
+ "dist",
157
+ "**/*.test.ts",
158
+ "**/*.spec.ts",
159
+ "src/examples/**/*", // 🔑 Exclude examples
160
+ "src/tests/**/*" // 🔑 Exclude package tests
161
+ ]
162
+ }
163
+ ```
164
+
165
+ ---
166
+
167
+ ## 🚫 Settings That Cause Problems
168
+
169
+ ### ❌ AVOID During Active Development:
170
+
171
+ ```json
172
+ {
173
+ "compilerOptions": {
174
+ // These will block you constantly:
175
+ "strict": true, // ❌ Too strict for prototyping
176
+ "noImplicitAny": true, // ❌ Forces explicit types everywhere
177
+ "strictNullChecks": true, // ❌ Requires null checks everywhere
178
+ "strictPropertyInitialization": true, // ❌ Requires all props initialized
179
+ "noUnusedLocals": true, // ❌ Errors on unused variables
180
+ "noUnusedParameters": true, // ❌ Errors on unused params
181
+ "noUncheckedIndexedAccess": true, // ❌ Makes array access painful
182
+
183
+ // These cause monorepo pain:
184
+ "composite": true, // ❌ Requires project references
185
+ "rootDir": "./src" // ❌ Breaks cross-package imports
186
+ }
187
+ }
188
+ ```
189
+
190
+ ### ✅ ENABLE When Stabilizing for Production:
191
+
192
+ Once your code is working and you're ready to harden it:
193
+
194
+ ```json
195
+ {
196
+ "compilerOptions": {
197
+ "strict": true,
198
+ "noImplicitAny": true,
199
+ "strictNullChecks": true,
200
+ "noUnusedLocals": true,
201
+ "noUnusedParameters": true
202
+ }
203
+ }
204
+ ```
205
+
206
+ ---
207
+
208
+ ## 🎨 File Organization Rules
209
+
210
+ ### 1. **Example/Demo Files**
211
+
212
+ ```typescript
213
+ // ✅ ALWAYS add @ts-nocheck to examples
214
+ // @ts-nocheck - Example/demo file with intentional issues
215
+ import { Something } from './Something';
216
+
217
+ // Example code with intentional type mismatches for demonstration
218
+ ```
219
+
220
+ **Rule:** Any file in `examples/`, `demos/`, or similar should have `@ts-nocheck`
221
+
222
+ ### 2. **Test Files**
223
+
224
+ ```typescript
225
+ // ✅ Add @ts-nocheck to tests with mocks
226
+ // @ts-nocheck - Test file with mock implementations
227
+ import { MyClass } from './MyClass';
228
+
229
+ // Tests often use simplified mocks that don't match exact types
230
+ ```
231
+
232
+ **Rule:** Add `@ts-nocheck` to test files that:
233
+ - Use incomplete mocks
234
+ - Test edge cases with invalid types
235
+ - Use simplified test data structures
236
+
237
+ ### 3. **Production Code**
238
+
239
+ ```typescript
240
+ // ✅ NO @ts-nocheck in production code
241
+ // Let TypeScript catch real errors
242
+ import { Something } from './Something';
243
+
244
+ export class MyClass {
245
+ // Actual production implementation
246
+ }
247
+ ```
248
+
249
+ **Rule:** Production code should compile cleanly without `@ts-nocheck`
250
+
251
+ ---
252
+
253
+ ## 📁 Directory Structure Guidelines
254
+
255
+ ### ✅ GOOD Structure:
256
+
257
+ ```
258
+ project/
259
+ ├── src/ # Production code (checked)
260
+ │ ├── domain/
261
+ │ ├── application/
262
+ │ └── infrastructure/
263
+ ├── tests/ # Tests (relaxed checking)
264
+ │ ├── unit/
265
+ │ ├── integration/
266
+ │ └── utils/
267
+ ├── examples/ # Examples (excluded or @ts-nocheck)
268
+ ├── services/ # Monorepo packages (own tsconfig)
269
+ │ └── agents/
270
+ │ ├── base-agent/
271
+ │ │ ├── src/
272
+ │ │ ├── examples/ # Excluded
273
+ │ │ └── tsconfig.json
274
+ │ └── director-agent/
275
+ └── tsconfig.json # Main config
276
+ ```
277
+
278
+ ### Key Principles:
279
+ 1. Each major directory gets its own concerns
280
+ 2. Monorepo packages have independent tsconfig.json
281
+ 3. Test directories are separate from production
282
+ 4. Examples are isolated and excluded
283
+
284
+ ---
285
+
286
+ ## 🔧 Jest Configuration
287
+
288
+ ### jest.config.js
289
+
290
+ ```javascript
291
+ module.exports = {
292
+ preset: 'ts-jest',
293
+ testEnvironment: 'node',
294
+
295
+ // Path mappings MUST match tsconfig.json
296
+ moduleNameMapper: {
297
+ '^@/tests/(.*)$': '<rootDir>/tests/$1',
298
+ '^@/services/agents/base-agent/(.*)$': '<rootDir>/services/agents/base-agent/$1',
299
+ '^@/(.*)$': '<rootDir>/src/$1'
300
+ },
301
+
302
+ transform: {
303
+ '^.+\\.ts$': ['ts-jest', {
304
+ tsconfig: 'tsconfig.test.json' // Use relaxed config for tests
305
+ }]
306
+ },
307
+
308
+ // Setup
309
+ setupFilesAfterEnv: ['<rootDir>/tests/setup.ts'],
310
+
311
+ // Performance
312
+ testTimeout: 10000,
313
+ clearMocks: true,
314
+ restoreMocks: true
315
+ };
316
+ ```
317
+
318
+ ---
319
+
320
+ ## 🎯 When to Use @ts-nocheck
321
+
322
+ ### ✅ USE for:
323
+ - Example files demonstrating concepts
324
+ - Demo code showing before/after
325
+ - Test files with extensive mocking
326
+ - Prototype/spike code
327
+ - Generated code
328
+ - Third-party code you don't control
329
+
330
+ ### ❌ DON'T USE for:
331
+ - Production source code (src/)
332
+ - Core business logic
333
+ - Public APIs
334
+ - Library exports
335
+ - Anything users/clients interact with
336
+
337
+ ---
338
+
339
+ ## 🚀 Migration Strategy
340
+
341
+ ### If You Have Strict Settings Now:
342
+
343
+ **Phase 1: Relax for Development**
344
+ ```bash
345
+ # 1. Update tsconfig.json with relaxed settings
346
+ # 2. Fix any remaining real errors
347
+ # 3. Commit and continue development
348
+ ```
349
+
350
+ **Phase 2: Add Tests**
351
+ ```bash
352
+ # 4. Write tests with relaxed tsconfig.test.json
353
+ # 5. Add @ts-nocheck to test files as needed
354
+ # 6. Get to 80%+ test coverage
355
+ ```
356
+
357
+ **Phase 3: Harden for Production** (Optional)
358
+ ```bash
359
+ # 7. Enable strict mode in tsconfig.json
360
+ # 8. Fix errors file by file
361
+ # 9. Commit when all pass
362
+ ```
363
+
364
+ ---
365
+
366
+ ## 📊 Error Prevention Checklist
367
+
368
+ Before starting a new TypeScript project:
369
+
370
+ - [ ] Set `strict: false` in tsconfig.json
371
+ - [ ] Set `skipLibCheck: true`
372
+ - [ ] Set `noImplicitAny: false`
373
+ - [ ] Set `strictNullChecks: false`
374
+ - [ ] Add explicit `include` array
375
+ - [ ] Add explicit `exclude` array with tests/examples
376
+ - [ ] Create separate tsconfig.test.json
377
+ - [ ] Add @ts-nocheck to all example files
378
+ - [ ] Exclude examples from tsconfig
379
+ - [ ] Remove `rootDir` if doing monorepo
380
+ - [ ] Set `baseUrl` relative to project root
381
+ - [ ] Match Jest paths to tsconfig paths
382
+ - [ ] Document when to enable strict mode
383
+
384
+ ---
385
+
386
+ ## 🎓 Key Lessons Learned
387
+
388
+ ### 1. **Strictness is a Spectrum**
389
+ - Start loose, tighten gradually
390
+ - Not all code needs same strictness
391
+ - Tests can be looser than production
392
+
393
+ ### 2. **Monorepo = Complex**
394
+ - Each package needs own config
395
+ - Avoid `rootDir` with cross-package imports
396
+ - Use `skipLibCheck: true` aggressively
397
+
398
+ ### 3. **IDE vs Build**
399
+ - IDE checks everything it sees
400
+ - Build only checks what you tell it
401
+ - Use exclusions to control what IDE sees
402
+
403
+ ### 4. **@ts-nocheck is Not Evil**
404
+ - Perfect for demos and examples
405
+ - Useful for test mocks
406
+ - Prevents TypeScript from blocking you
407
+ - Just don't use in production code
408
+
409
+ ### 5. **Configuration Inheritance**
410
+ - Child configs inherit parent settings
411
+ - Sometimes inheritance causes pain
412
+ - Independent configs are clearer
413
+
414
+ ---
415
+
416
+ ## 🔍 Troubleshooting
417
+
418
+ ### Problem: "Object is possibly 'undefined'"
419
+ **Solution:** Set `strictNullChecks: false` or use optional chaining `?.`
420
+
421
+ ### Problem: "Parameter has implicit any type"
422
+ **Solution:** Set `noImplicitAny: false` or add explicit types
423
+
424
+ ### Problem: "File is not under rootDir"
425
+ **Solution:** Remove `rootDir` or set it to common ancestor
426
+
427
+ ### Problem: "Property does not exist on type"
428
+ **Solution:** Check if type definitions are correct or use `@ts-nocheck` for tests
429
+
430
+ ### Problem: "Module not found"
431
+ **Solution:** Check `paths` mapping matches both tsconfig.json and jest.config.js
432
+
433
+ ### Problem: "Too many errors in IDE"
434
+ **Solution:** Check what tsconfig the IDE is using, add exclusions
435
+
436
+ ---
437
+
438
+ ## 📚 Further Reading
439
+
440
+ - [TypeScript Handbook - tsconfig.json](https://www.typescriptlang.org/tsconfig)
441
+ - [TypeScript Deep Dive - Project Configuration](https://basarat.gitbook.io/typescript/)
442
+ - [Monorepo TypeScript Best Practices](https://turbo.build/repo/docs/handbook/linting/typescript)
443
+
444
+ ---
445
+
446
+ ## 🎉 Summary
447
+
448
+ **For Active Development:**
449
+ - Relaxed strictness
450
+ - Clear exclusions
451
+ - @ts-nocheck for examples/demos
452
+ - Separate test configuration
453
+
454
+ **For Production Hardening:**
455
+ - Enable strict mode gradually
456
+ - Fix errors file by file
457
+ - Keep tests relaxed
458
+ - Document exceptions
459
+
460
+ **Remember:** TypeScript should help you, not block you. Start loose, tighten when stable.
461
+
462
+ ---
463
+
464
+ Generated from lessons learned: 2025-01-XX
465
+ Based on fixing 300+ TypeScript errors in one session
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@tonycasey/lisa",
3
+ "version": "0.5.13",
4
+ "description": "Claude NEEDS Lisa. Plug-and-play memory for Claude Code and AI coding assistants.",
5
+ "bin": {
6
+ "lisa": "dist/cli.js",
7
+ "remember": "dist/cli.js"
8
+ },
9
+ "type": "commonjs",
10
+ "main": "dist/cli.js",
11
+ "engines": {
12
+ "node": ">=18.0.0"
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "scripts/postinstall.js"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsc -p tsconfig.json",
20
+ "build:local": "DEPLOY_AGENTS_LOCAL=1 npm run build",
21
+ "postbuild": "node scripts/postbuild-copy-templates.js && node scripts/prepare-dist-package.js && node scripts/deploy-agents.js",
22
+ "postinstall": "node scripts/postinstall.js",
23
+ "clean": "rimraf dist",
24
+ "package": "rm -f *.tgz releases/*.tgz && npm run build && mkdir -p releases && npm pack && mv *.tgz releases/",
25
+ "lint": "eslint 'src/**/*.{ts,js}'",
26
+ "test": "node --import tsx --test $(find tests/unit -name '*.test.ts' -type f)",
27
+ "test:unit": "node --import tsx --test $(find tests/unit -name '*.test.ts' -type f)",
28
+ "test:integration": "tsx --test tests/integration/**/index.ts",
29
+ "test:integration:memory": "tsx --test tests/integration/memory/index.ts",
30
+ "test:integration:tasks": "tsx --test tests/integration/tasks/index.ts",
31
+ "e2e:docker:quick": "cd tests/integration/deploy/docker && docker compose up --build",
32
+ "e2e:docker:full": "cd tests/integration/deploy/docker && docker compose --env-file ../../../../.env -f docker-compose.test.yml up --build"
33
+ },
34
+ "keywords": [
35
+ "graphiti",
36
+ "mcp",
37
+ "memory",
38
+ "hooks",
39
+ "cli"
40
+ ],
41
+ "author": "Tony Casey",
42
+ "license": "MIT",
43
+ "dependencies": {
44
+ "@anthropic-ai/claude-code": "^2.1.3",
45
+ "@inquirer/prompts": "^7.0.0",
46
+ "chalk": "^5.3.0",
47
+ "cli-table3": "^0.6.5",
48
+ "commander": "^11.1.0",
49
+ "execa": "^8.0.1",
50
+ "fs-extra": "^11.2.0",
51
+ "yaml": "^2.4.2"
52
+ },
53
+ "devDependencies": {
54
+ "@types/fs-extra": "^11.0.4",
55
+ "@types/node": "^20.12.7",
56
+ "@typescript-eslint/eslint-plugin": "^8.52.0",
57
+ "@typescript-eslint/parser": "^8.52.0",
58
+ "dotenv": "^16.4.5",
59
+ "eslint": "^8.56.0",
60
+ "rimraf": "^5.0.5",
61
+ "tsx": "^4.19.0",
62
+ "typescript": "^5.6.3"
63
+ }
64
+ }