@prmichaelsen/remember-mcp 0.1.0
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/.env.example +65 -0
- package/AGENT.md +840 -0
- package/README.md +72 -0
- package/agent/design/.gitkeep +0 -0
- package/agent/design/access-control-result-pattern.md +458 -0
- package/agent/design/action-audit-memory-types.md +637 -0
- package/agent/design/common-template-fields.md +282 -0
- package/agent/design/complete-tool-set.md +407 -0
- package/agent/design/content-types-expansion.md +521 -0
- package/agent/design/cross-database-id-strategy.md +358 -0
- package/agent/design/default-template-library.md +423 -0
- package/agent/design/firestore-wrapper-analysis.md +606 -0
- package/agent/design/llm-provider-abstraction.md +691 -0
- package/agent/design/location-handling-architecture.md +523 -0
- package/agent/design/memory-templates-design.md +364 -0
- package/agent/design/permissions-storage-architecture.md +680 -0
- package/agent/design/relationship-storage-strategy.md +361 -0
- package/agent/design/remember-mcp-implementation-tasks.md +417 -0
- package/agent/design/remember-mcp-progress.yaml +141 -0
- package/agent/design/requirements-enhancements.md +468 -0
- package/agent/design/requirements.md +56 -0
- package/agent/design/template-storage-strategy.md +412 -0
- package/agent/design/template-suggestion-system.md +853 -0
- package/agent/design/trust-escalation-prevention.md +343 -0
- package/agent/design/trust-system-implementation.md +592 -0
- package/agent/design/user-preferences.md +683 -0
- package/agent/design/weaviate-collection-strategy.md +461 -0
- package/agent/milestones/.gitkeep +0 -0
- package/agent/milestones/milestone-1-project-foundation.md +121 -0
- package/agent/milestones/milestone-2-core-memory-system.md +150 -0
- package/agent/milestones/milestone-3-relationships-graph.md +116 -0
- package/agent/milestones/milestone-4-user-preferences.md +103 -0
- package/agent/milestones/milestone-5-template-system.md +126 -0
- package/agent/milestones/milestone-6-auth-multi-tenancy.md +124 -0
- package/agent/milestones/milestone-7-trust-permissions.md +133 -0
- package/agent/milestones/milestone-8-testing-quality.md +137 -0
- package/agent/milestones/milestone-9-deployment-documentation.md +147 -0
- package/agent/patterns/.gitkeep +0 -0
- package/agent/patterns/bootstrap.md +1271 -0
- package/agent/patterns/firebase-admin-sdk-v8-usage.md +950 -0
- package/agent/patterns/firestore-users-pattern-best-practices.md +347 -0
- package/agent/patterns/library-services.md +454 -0
- package/agent/patterns/testing-colocated.md +316 -0
- package/agent/progress.yaml +395 -0
- package/agent/tasks/.gitkeep +0 -0
- package/agent/tasks/task-1-initialize-project-structure.md +266 -0
- package/agent/tasks/task-2-install-dependencies.md +199 -0
- package/agent/tasks/task-3-setup-weaviate-client.md +330 -0
- package/agent/tasks/task-4-setup-firestore-client.md +362 -0
- package/agent/tasks/task-5-create-basic-mcp-server.md +114 -0
- package/agent/tasks/task-6-create-integration-tests.md +195 -0
- package/agent/tasks/task-7-finalize-milestone-1.md +363 -0
- package/agent/tasks/task-8-setup-utility-scripts.md +382 -0
- package/agent/tasks/task-9-create-server-factory.md +404 -0
- package/dist/config.d.ts +26 -0
- package/dist/constants/content-types.d.ts +60 -0
- package/dist/firestore/init.d.ts +14 -0
- package/dist/firestore/paths.d.ts +53 -0
- package/dist/firestore/paths.spec.d.ts +2 -0
- package/dist/server-factory.d.ts +40 -0
- package/dist/server-factory.js +1741 -0
- package/dist/server-factory.spec.d.ts +2 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.js +1690 -0
- package/dist/tools/create-memory.d.ts +94 -0
- package/dist/tools/delete-memory.d.ts +47 -0
- package/dist/tools/search-memory.d.ts +88 -0
- package/dist/types/memory.d.ts +183 -0
- package/dist/utils/logger.d.ts +7 -0
- package/dist/weaviate/client.d.ts +39 -0
- package/dist/weaviate/client.spec.d.ts +2 -0
- package/dist/weaviate/schema.d.ts +29 -0
- package/esbuild.build.js +60 -0
- package/esbuild.watch.js +25 -0
- package/jest.config.js +31 -0
- package/jest.e2e.config.js +17 -0
- package/package.json +68 -0
- package/src/.gitkeep +0 -0
- package/src/config.ts +56 -0
- package/src/constants/content-types.ts +454 -0
- package/src/firestore/init.ts +68 -0
- package/src/firestore/paths.spec.ts +75 -0
- package/src/firestore/paths.ts +124 -0
- package/src/server-factory.spec.ts +60 -0
- package/src/server-factory.ts +215 -0
- package/src/server.ts +243 -0
- package/src/tools/create-memory.ts +198 -0
- package/src/tools/delete-memory.ts +126 -0
- package/src/tools/search-memory.ts +216 -0
- package/src/types/memory.ts +276 -0
- package/src/utils/logger.ts +42 -0
- package/src/weaviate/client.spec.ts +58 -0
- package/src/weaviate/client.ts +114 -0
- package/src/weaviate/schema.ts +288 -0
- package/tsconfig.json +26 -0
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
# Task 8: Setup Utility Scripts Directory
|
|
2
|
+
|
|
3
|
+
**Milestone**: M1 - Project Foundation (Additional Task)
|
|
4
|
+
**Estimated Time**: 1 hour
|
|
5
|
+
**Dependencies**: Task 2 (Dependencies installed)
|
|
6
|
+
**Status**: Not Started
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Objective
|
|
11
|
+
|
|
12
|
+
Create a `./scripts` directory with TypeScript configuration that allows running utility scripts with `npx tsx ./scripts/script-name.ts`, with full access to src files and all installed dependencies.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Use Cases
|
|
17
|
+
|
|
18
|
+
**Utility scripts for**:
|
|
19
|
+
- Database initialization and seeding
|
|
20
|
+
- Data migration and cleanup
|
|
21
|
+
- Testing database connections
|
|
22
|
+
- Creating default templates
|
|
23
|
+
- User management operations
|
|
24
|
+
- Development and debugging tasks
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Steps
|
|
29
|
+
|
|
30
|
+
### 1. Create Scripts Directory Structure
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
mkdir -p scripts
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 2. Create Scripts TypeScript Configuration
|
|
37
|
+
|
|
38
|
+
**scripts/tsconfig.json**:
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"extends": "../tsconfig.json",
|
|
42
|
+
"compilerOptions": {
|
|
43
|
+
"module": "ESNext",
|
|
44
|
+
"moduleResolution": "bundler",
|
|
45
|
+
"target": "ES2022",
|
|
46
|
+
"lib": ["ES2022"],
|
|
47
|
+
"types": ["node"],
|
|
48
|
+
|
|
49
|
+
"outDir": "../dist/scripts",
|
|
50
|
+
"rootDir": ".",
|
|
51
|
+
|
|
52
|
+
"strict": true,
|
|
53
|
+
"esModuleInterop": true,
|
|
54
|
+
"skipLibCheck": true,
|
|
55
|
+
"forceConsistentCasingInFileNames": true,
|
|
56
|
+
"resolveJsonModule": true,
|
|
57
|
+
|
|
58
|
+
"baseUrl": "..",
|
|
59
|
+
"paths": {
|
|
60
|
+
"@/*": ["src/*"],
|
|
61
|
+
"@scripts/*": ["scripts/*"]
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"include": ["./**/*", "../src/**/*"],
|
|
65
|
+
"exclude": ["node_modules"]
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Key Features**:
|
|
70
|
+
- Extends main tsconfig.json for consistency
|
|
71
|
+
- `baseUrl: ".."` allows importing from parent directory
|
|
72
|
+
- `paths` includes both `@/*` (src) and `@scripts/*` (scripts)
|
|
73
|
+
- `include` covers both scripts and src directories
|
|
74
|
+
- `moduleResolution: "bundler"` works with tsx
|
|
75
|
+
|
|
76
|
+
### 3. Create Example Scripts
|
|
77
|
+
|
|
78
|
+
**scripts/test-weaviate.ts**:
|
|
79
|
+
```typescript
|
|
80
|
+
#!/usr/bin/env tsx
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Test Weaviate connection
|
|
84
|
+
* Usage: npx tsx scripts/test-weaviate.ts
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
import { initWeaviateClient, testWeaviateConnection } from '@/weaviate/client.js';
|
|
88
|
+
import { config } from '@/config.js';
|
|
89
|
+
|
|
90
|
+
async function main() {
|
|
91
|
+
console.log('Testing Weaviate connection...');
|
|
92
|
+
console.log('URL:', config.weaviate.url);
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
await initWeaviateClient();
|
|
96
|
+
const isConnected = await testWeaviateConnection();
|
|
97
|
+
|
|
98
|
+
if (isConnected) {
|
|
99
|
+
console.log('✅ Weaviate connection successful!');
|
|
100
|
+
process.exit(0);
|
|
101
|
+
} else {
|
|
102
|
+
console.error('❌ Weaviate connection failed');
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
} catch (error) {
|
|
106
|
+
console.error('❌ Error:', error);
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
main();
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**scripts/test-firestore.ts**:
|
|
115
|
+
```typescript
|
|
116
|
+
#!/usr/bin/env tsx
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Test Firestore connection
|
|
120
|
+
* Usage: npx tsx scripts/test-firestore.ts
|
|
121
|
+
*/
|
|
122
|
+
|
|
123
|
+
import { initFirestore } from '@/firestore/init.js';
|
|
124
|
+
import { getDocument } from '@prmichaelsen/firebase-admin-sdk-v8';
|
|
125
|
+
|
|
126
|
+
async function main() {
|
|
127
|
+
console.log('Testing Firestore connection...');
|
|
128
|
+
|
|
129
|
+
try {
|
|
130
|
+
initFirestore();
|
|
131
|
+
console.log('✅ Firestore initialized');
|
|
132
|
+
|
|
133
|
+
// Try to read a test document
|
|
134
|
+
const testDoc = await getDocument('_test', 'connection');
|
|
135
|
+
console.log('✅ Firestore connection successful!');
|
|
136
|
+
console.log('Test document:', testDoc || 'null (document does not exist)');
|
|
137
|
+
|
|
138
|
+
process.exit(0);
|
|
139
|
+
} catch (error) {
|
|
140
|
+
console.error('❌ Firestore connection failed:', error);
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
main();
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**scripts/init-default-templates.ts**:
|
|
149
|
+
```typescript
|
|
150
|
+
#!/usr/bin/env tsx
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Initialize default templates in Firestore
|
|
154
|
+
* Usage: npx tsx scripts/init-default-templates.ts
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
import { initFirestore } from '@/firestore/init.js';
|
|
158
|
+
import { setDocument } from '@prmichaelsen/firebase-admin-sdk-v8';
|
|
159
|
+
import { DEFAULT_TEMPLATES } from '@/constants/templates.js';
|
|
160
|
+
|
|
161
|
+
async function main() {
|
|
162
|
+
console.log('Initializing default templates...');
|
|
163
|
+
|
|
164
|
+
initFirestore();
|
|
165
|
+
|
|
166
|
+
for (const template of DEFAULT_TEMPLATES) {
|
|
167
|
+
console.log(`Creating template: ${template.template_name}`);
|
|
168
|
+
|
|
169
|
+
await setDocument('templates/default', template.id, {
|
|
170
|
+
...template,
|
|
171
|
+
created_at: new Date().toISOString(),
|
|
172
|
+
is_default: true,
|
|
173
|
+
is_immutable: true
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
console.log(`✅ Created: ${template.template_name}`);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
console.log(`\n✅ Initialized ${DEFAULT_TEMPLATES.length} default templates`);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
main();
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**scripts/create-user-collection.ts**:
|
|
186
|
+
```typescript
|
|
187
|
+
#!/usr/bin/env tsx
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Create Weaviate collection for a user
|
|
191
|
+
* Usage: npx tsx scripts/create-user-collection.ts <user_id>
|
|
192
|
+
*/
|
|
193
|
+
|
|
194
|
+
import { initWeaviateClient, getMemoryCollectionName, collectionExists } from '@/weaviate/client.js';
|
|
195
|
+
import { createMemoryCollection } from '@/weaviate/schema.js';
|
|
196
|
+
|
|
197
|
+
async function main() {
|
|
198
|
+
const userId = process.argv[2];
|
|
199
|
+
|
|
200
|
+
if (!userId) {
|
|
201
|
+
console.error('Usage: npx tsx scripts/create-user-collection.ts <user_id>');
|
|
202
|
+
process.exit(1);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
console.log(`Creating collection for user: ${userId}`);
|
|
206
|
+
|
|
207
|
+
await initWeaviateClient();
|
|
208
|
+
|
|
209
|
+
const collectionName = getMemoryCollectionName(userId);
|
|
210
|
+
console.log(`Collection name: ${collectionName}`);
|
|
211
|
+
|
|
212
|
+
const exists = await collectionExists(collectionName);
|
|
213
|
+
|
|
214
|
+
if (exists) {
|
|
215
|
+
console.log('⚠️ Collection already exists');
|
|
216
|
+
process.exit(0);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
await createMemoryCollection(userId);
|
|
220
|
+
console.log('✅ Collection created successfully');
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
main();
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### 4. Add Scripts to package.json
|
|
227
|
+
|
|
228
|
+
**package.json scripts section**:
|
|
229
|
+
```json
|
|
230
|
+
{
|
|
231
|
+
"scripts": {
|
|
232
|
+
"build": "node esbuild.build.js",
|
|
233
|
+
"build:watch": "node esbuild.watch.js",
|
|
234
|
+
"clean": "rm -rf dist",
|
|
235
|
+
"dev": "tsx watch src/server.ts",
|
|
236
|
+
"start": "node dist/server.js",
|
|
237
|
+
"test": "jest",
|
|
238
|
+
"test:watch": "jest --watch",
|
|
239
|
+
"test:e2e": "jest --config jest.e2e.config.js",
|
|
240
|
+
"test:e2e:watch": "jest --config jest.e2e.config.js --watch",
|
|
241
|
+
"test:all": "npm test && npm run test:e2e",
|
|
242
|
+
"lint": "eslint src/**/*.ts",
|
|
243
|
+
"typecheck": "tsc --noEmit",
|
|
244
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
245
|
+
|
|
246
|
+
"script": "tsx",
|
|
247
|
+
"script:test-weaviate": "tsx scripts/test-weaviate.ts",
|
|
248
|
+
"script:test-firestore": "tsx scripts/test-firestore.ts",
|
|
249
|
+
"script:init-templates": "tsx scripts/init-default-templates.ts",
|
|
250
|
+
"script:create-collection": "tsx scripts/create-user-collection.ts"
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### 5. Create Scripts README
|
|
256
|
+
|
|
257
|
+
**scripts/README.md**:
|
|
258
|
+
```markdown
|
|
259
|
+
# Utility Scripts
|
|
260
|
+
|
|
261
|
+
This directory contains utility scripts for development, testing, and database management.
|
|
262
|
+
|
|
263
|
+
## Running Scripts
|
|
264
|
+
|
|
265
|
+
### Direct Execution
|
|
266
|
+
\`\`\`bash
|
|
267
|
+
npx tsx scripts/script-name.ts [args]
|
|
268
|
+
\`\`\`
|
|
269
|
+
|
|
270
|
+
### Via npm Scripts
|
|
271
|
+
\`\`\`bash
|
|
272
|
+
npm run script:test-weaviate
|
|
273
|
+
npm run script:test-firestore
|
|
274
|
+
npm run script:init-templates
|
|
275
|
+
npm run script:create-collection user123
|
|
276
|
+
\`\`\`
|
|
277
|
+
|
|
278
|
+
## Available Scripts
|
|
279
|
+
|
|
280
|
+
### Database Testing
|
|
281
|
+
- **test-weaviate.ts** - Test Weaviate connection
|
|
282
|
+
- **test-firestore.ts** - Test Firestore connection
|
|
283
|
+
|
|
284
|
+
### Database Setup
|
|
285
|
+
- **init-default-templates.ts** - Initialize default template library
|
|
286
|
+
- **create-user-collection.ts** - Create Weaviate collection for a user
|
|
287
|
+
|
|
288
|
+
### Development
|
|
289
|
+
- **seed-data.ts** - Seed test data for development
|
|
290
|
+
- **clean-test-data.ts** - Clean up test data
|
|
291
|
+
|
|
292
|
+
## TypeScript Configuration
|
|
293
|
+
|
|
294
|
+
Scripts use \`scripts/tsconfig.json\` which:
|
|
295
|
+
- Extends main tsconfig.json
|
|
296
|
+
- Allows importing from src/ using @/ alias
|
|
297
|
+
- Includes both scripts/ and src/ directories
|
|
298
|
+
- Works with tsx for direct execution
|
|
299
|
+
|
|
300
|
+
## Accessing Project Code
|
|
301
|
+
|
|
302
|
+
Scripts can import from src:
|
|
303
|
+
\`\`\`typescript
|
|
304
|
+
import { initWeaviateClient } from '@/weaviate/client.js';
|
|
305
|
+
import { config } from '@/config.js';
|
|
306
|
+
import { UserPreferencesService } from '@/services/user-preferences.service.js';
|
|
307
|
+
\`\`\`
|
|
308
|
+
|
|
309
|
+
## Environment Variables
|
|
310
|
+
|
|
311
|
+
Scripts automatically load from .env file via dotenv in config.ts.
|
|
312
|
+
|
|
313
|
+
## Best Practices
|
|
314
|
+
|
|
315
|
+
1. **Add shebang**: \`#!/usr/bin/env tsx\` at top of script
|
|
316
|
+
2. **Handle errors**: Use try/catch and exit codes
|
|
317
|
+
3. **Add usage info**: Show usage if args missing
|
|
318
|
+
4. **Log progress**: Console.log for visibility
|
|
319
|
+
5. **Exit cleanly**: Use process.exit(0) for success, process.exit(1) for errors
|
|
320
|
+
\`\`\`
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## Verification
|
|
326
|
+
|
|
327
|
+
- [ ] scripts/ directory created
|
|
328
|
+
- [ ] scripts/tsconfig.json created
|
|
329
|
+
- [ ] scripts/README.md created
|
|
330
|
+
- [ ] Example scripts created (test-weaviate.ts, test-firestore.ts)
|
|
331
|
+
- [ ] Can run: `npx tsx scripts/test-weaviate.ts`
|
|
332
|
+
- [ ] Can import from src/ using @/ alias
|
|
333
|
+
- [ ] TypeScript compilation works
|
|
334
|
+
- [ ] Scripts have access to all dependencies
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
## Testing
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
# Test Weaviate connection
|
|
342
|
+
npx tsx scripts/test-weaviate.ts
|
|
343
|
+
|
|
344
|
+
# Test Firestore connection
|
|
345
|
+
npx tsx scripts/test-firestore.ts
|
|
346
|
+
|
|
347
|
+
# Create user collection
|
|
348
|
+
npx tsx scripts/create-user-collection.ts user123
|
|
349
|
+
|
|
350
|
+
# Initialize templates
|
|
351
|
+
npx tsx scripts/init-default-templates.ts
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## Benefits
|
|
357
|
+
|
|
358
|
+
1. **Development Efficiency**
|
|
359
|
+
- Quick database testing
|
|
360
|
+
- Easy data seeding
|
|
361
|
+
- Rapid prototyping
|
|
362
|
+
|
|
363
|
+
2. **Code Reuse**
|
|
364
|
+
- Access all src/ code
|
|
365
|
+
- Use existing services and utilities
|
|
366
|
+
- Share types and constants
|
|
367
|
+
|
|
368
|
+
3. **Type Safety**
|
|
369
|
+
- Full TypeScript support
|
|
370
|
+
- Same strict settings as main code
|
|
371
|
+
- Catch errors before runtime
|
|
372
|
+
|
|
373
|
+
4. **Maintainability**
|
|
374
|
+
- Scripts live with project
|
|
375
|
+
- Version controlled
|
|
376
|
+
- Documented and organized
|
|
377
|
+
|
|
378
|
+
---
|
|
379
|
+
|
|
380
|
+
## Next Task
|
|
381
|
+
|
|
382
|
+
Task 4: Set Up Firestore (using service layer pattern)
|