@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.
Files changed (95) hide show
  1. package/.env.example +65 -0
  2. package/AGENT.md +840 -0
  3. package/README.md +72 -0
  4. package/agent/design/.gitkeep +0 -0
  5. package/agent/design/access-control-result-pattern.md +458 -0
  6. package/agent/design/action-audit-memory-types.md +637 -0
  7. package/agent/design/common-template-fields.md +282 -0
  8. package/agent/design/complete-tool-set.md +407 -0
  9. package/agent/design/content-types-expansion.md +521 -0
  10. package/agent/design/cross-database-id-strategy.md +358 -0
  11. package/agent/design/default-template-library.md +423 -0
  12. package/agent/design/firestore-wrapper-analysis.md +606 -0
  13. package/agent/design/llm-provider-abstraction.md +691 -0
  14. package/agent/design/location-handling-architecture.md +523 -0
  15. package/agent/design/memory-templates-design.md +364 -0
  16. package/agent/design/permissions-storage-architecture.md +680 -0
  17. package/agent/design/relationship-storage-strategy.md +361 -0
  18. package/agent/design/remember-mcp-implementation-tasks.md +417 -0
  19. package/agent/design/remember-mcp-progress.yaml +141 -0
  20. package/agent/design/requirements-enhancements.md +468 -0
  21. package/agent/design/requirements.md +56 -0
  22. package/agent/design/template-storage-strategy.md +412 -0
  23. package/agent/design/template-suggestion-system.md +853 -0
  24. package/agent/design/trust-escalation-prevention.md +343 -0
  25. package/agent/design/trust-system-implementation.md +592 -0
  26. package/agent/design/user-preferences.md +683 -0
  27. package/agent/design/weaviate-collection-strategy.md +461 -0
  28. package/agent/milestones/.gitkeep +0 -0
  29. package/agent/milestones/milestone-1-project-foundation.md +121 -0
  30. package/agent/milestones/milestone-2-core-memory-system.md +150 -0
  31. package/agent/milestones/milestone-3-relationships-graph.md +116 -0
  32. package/agent/milestones/milestone-4-user-preferences.md +103 -0
  33. package/agent/milestones/milestone-5-template-system.md +126 -0
  34. package/agent/milestones/milestone-6-auth-multi-tenancy.md +124 -0
  35. package/agent/milestones/milestone-7-trust-permissions.md +133 -0
  36. package/agent/milestones/milestone-8-testing-quality.md +137 -0
  37. package/agent/milestones/milestone-9-deployment-documentation.md +147 -0
  38. package/agent/patterns/.gitkeep +0 -0
  39. package/agent/patterns/bootstrap.md +1271 -0
  40. package/agent/patterns/firebase-admin-sdk-v8-usage.md +950 -0
  41. package/agent/patterns/firestore-users-pattern-best-practices.md +347 -0
  42. package/agent/patterns/library-services.md +454 -0
  43. package/agent/patterns/testing-colocated.md +316 -0
  44. package/agent/progress.yaml +395 -0
  45. package/agent/tasks/.gitkeep +0 -0
  46. package/agent/tasks/task-1-initialize-project-structure.md +266 -0
  47. package/agent/tasks/task-2-install-dependencies.md +199 -0
  48. package/agent/tasks/task-3-setup-weaviate-client.md +330 -0
  49. package/agent/tasks/task-4-setup-firestore-client.md +362 -0
  50. package/agent/tasks/task-5-create-basic-mcp-server.md +114 -0
  51. package/agent/tasks/task-6-create-integration-tests.md +195 -0
  52. package/agent/tasks/task-7-finalize-milestone-1.md +363 -0
  53. package/agent/tasks/task-8-setup-utility-scripts.md +382 -0
  54. package/agent/tasks/task-9-create-server-factory.md +404 -0
  55. package/dist/config.d.ts +26 -0
  56. package/dist/constants/content-types.d.ts +60 -0
  57. package/dist/firestore/init.d.ts +14 -0
  58. package/dist/firestore/paths.d.ts +53 -0
  59. package/dist/firestore/paths.spec.d.ts +2 -0
  60. package/dist/server-factory.d.ts +40 -0
  61. package/dist/server-factory.js +1741 -0
  62. package/dist/server-factory.spec.d.ts +2 -0
  63. package/dist/server.d.ts +3 -0
  64. package/dist/server.js +1690 -0
  65. package/dist/tools/create-memory.d.ts +94 -0
  66. package/dist/tools/delete-memory.d.ts +47 -0
  67. package/dist/tools/search-memory.d.ts +88 -0
  68. package/dist/types/memory.d.ts +183 -0
  69. package/dist/utils/logger.d.ts +7 -0
  70. package/dist/weaviate/client.d.ts +39 -0
  71. package/dist/weaviate/client.spec.d.ts +2 -0
  72. package/dist/weaviate/schema.d.ts +29 -0
  73. package/esbuild.build.js +60 -0
  74. package/esbuild.watch.js +25 -0
  75. package/jest.config.js +31 -0
  76. package/jest.e2e.config.js +17 -0
  77. package/package.json +68 -0
  78. package/src/.gitkeep +0 -0
  79. package/src/config.ts +56 -0
  80. package/src/constants/content-types.ts +454 -0
  81. package/src/firestore/init.ts +68 -0
  82. package/src/firestore/paths.spec.ts +75 -0
  83. package/src/firestore/paths.ts +124 -0
  84. package/src/server-factory.spec.ts +60 -0
  85. package/src/server-factory.ts +215 -0
  86. package/src/server.ts +243 -0
  87. package/src/tools/create-memory.ts +198 -0
  88. package/src/tools/delete-memory.ts +126 -0
  89. package/src/tools/search-memory.ts +216 -0
  90. package/src/types/memory.ts +276 -0
  91. package/src/utils/logger.ts +42 -0
  92. package/src/weaviate/client.spec.ts +58 -0
  93. package/src/weaviate/client.ts +114 -0
  94. package/src/weaviate/schema.ts +288 -0
  95. package/tsconfig.json +26 -0
@@ -0,0 +1,288 @@
1
+ /**
2
+ * Weaviate schema definitions for remember-mcp
3
+ * Based on agent/design/weaviate-collection-strategy.md
4
+ */
5
+
6
+ import weaviate, { WeaviateClient } from 'weaviate-client';
7
+ import { getWeaviateClient, sanitizeUserId } from './client.js';
8
+ import { config } from '../config.js';
9
+
10
+ /**
11
+ * Create Memory collection schema for a user
12
+ *
13
+ * This collection stores BOTH memories AND relationships using doc_type discriminator.
14
+ * This unified approach enables:
15
+ * - Single query for memories with relationships
16
+ * - Semantic search across both memories and relationship observations
17
+ * - Better RAG context (LLM gets memories + connections together)
18
+ *
19
+ * @param userId - User identifier
20
+ */
21
+ export async function createMemoryCollection(userId: string): Promise<void> {
22
+ const client = getWeaviateClient();
23
+ const collectionName = `Memory_${sanitizeUserId(userId)}`;
24
+
25
+ // Check if collection already exists
26
+ const exists = await client.collections.exists(collectionName);
27
+ if (exists) {
28
+ console.log(`[Weaviate] Collection ${collectionName} already exists`);
29
+ return;
30
+ }
31
+
32
+ console.log(`[Weaviate] Creating collection ${collectionName}...`);
33
+
34
+ // Create collection with schema
35
+ await client.collections.create({
36
+ name: collectionName,
37
+
38
+ // Vectorizer configuration
39
+ vectorizers: weaviate.configure.vectorizer.text2VecOpenAI({
40
+ model: 'text-embedding-3-small',
41
+ // Vectorize both memory content and relationship observations
42
+ sourceProperties: ['content', 'observation'],
43
+ }),
44
+
45
+ properties: [
46
+ // Discriminator
47
+ {
48
+ name: 'doc_type',
49
+ dataType: 'text' as any,
50
+ description: 'Document type: "memory" or "relationship"',
51
+ },
52
+
53
+ // Core identity
54
+ {
55
+ name: 'user_id',
56
+ dataType: 'text' as any,
57
+ description: 'User who owns this document',
58
+ },
59
+
60
+ // Memory fields
61
+ {
62
+ name: 'content',
63
+ dataType: 'text' as any,
64
+ description: 'Main memory content (vectorized)',
65
+ },
66
+ {
67
+ name: 'title',
68
+ dataType: 'text' as any,
69
+ description: 'Optional short title',
70
+ },
71
+ {
72
+ name: 'summary',
73
+ dataType: 'text' as any,
74
+ description: 'Optional brief summary',
75
+ },
76
+ {
77
+ name: 'type',
78
+ dataType: 'text' as any,
79
+ description: 'Content type (note, event, person, etc.)',
80
+ },
81
+
82
+ // Scoring fields
83
+ {
84
+ name: 'weight',
85
+ dataType: 'number' as any,
86
+ description: 'Significance/priority (0-1)',
87
+ },
88
+ {
89
+ name: 'trust',
90
+ dataType: 'number' as any,
91
+ description: 'Access control level (0-1)',
92
+ },
93
+ {
94
+ name: 'confidence',
95
+ dataType: 'number' as any,
96
+ description: 'System confidence in accuracy (0-1)',
97
+ },
98
+
99
+ // Location fields (flattened for Weaviate)
100
+ {
101
+ name: 'location_gps_lat',
102
+ dataType: 'number' as any,
103
+ description: 'GPS latitude',
104
+ },
105
+ {
106
+ name: 'location_gps_lng',
107
+ dataType: 'number' as any,
108
+ description: 'GPS longitude',
109
+ },
110
+ {
111
+ name: 'location_address',
112
+ dataType: 'text' as any,
113
+ description: 'Formatted address',
114
+ },
115
+ {
116
+ name: 'location_city',
117
+ dataType: 'text' as any,
118
+ description: 'City name',
119
+ },
120
+ {
121
+ name: 'location_country',
122
+ dataType: 'text' as any,
123
+ description: 'Country name',
124
+ },
125
+ {
126
+ name: 'location_source',
127
+ dataType: 'text' as any,
128
+ description: 'Location source (gps, ip, manual, etc.)',
129
+ },
130
+
131
+ // Locale fields
132
+ {
133
+ name: 'locale_language',
134
+ dataType: 'text' as any,
135
+ description: 'Language code (e.g., en, es, fr)',
136
+ },
137
+ {
138
+ name: 'locale_timezone',
139
+ dataType: 'text' as any,
140
+ description: 'Timezone (e.g., America/Los_Angeles)',
141
+ },
142
+
143
+ // Context fields
144
+ {
145
+ name: 'context_conversation_id',
146
+ dataType: 'text' as any,
147
+ description: 'Conversation ID',
148
+ },
149
+ {
150
+ name: 'context_summary',
151
+ dataType: 'text' as any,
152
+ description: 'Brief context summary',
153
+ },
154
+ {
155
+ name: 'context_timestamp',
156
+ dataType: 'date' as any,
157
+ description: 'Context timestamp',
158
+ },
159
+
160
+ // Relationships
161
+ {
162
+ name: 'relationships',
163
+ dataType: 'text[]' as any,
164
+ description: 'Array of relationship IDs',
165
+ },
166
+
167
+ // Access tracking
168
+ {
169
+ name: 'access_count',
170
+ dataType: 'number' as any,
171
+ description: 'Total times accessed',
172
+ },
173
+ {
174
+ name: 'last_accessed_at',
175
+ dataType: 'date' as any,
176
+ description: 'Most recent access timestamp',
177
+ },
178
+
179
+ // Metadata
180
+ {
181
+ name: 'tags',
182
+ dataType: 'text[]' as any,
183
+ description: 'Tags for organization',
184
+ },
185
+ {
186
+ name: 'references',
187
+ dataType: 'text[]' as any,
188
+ description: 'Source URLs',
189
+ },
190
+ {
191
+ name: 'created_at',
192
+ dataType: 'date' as any,
193
+ description: 'Creation timestamp',
194
+ },
195
+ {
196
+ name: 'updated_at',
197
+ dataType: 'date' as any,
198
+ description: 'Last update timestamp',
199
+ },
200
+ {
201
+ name: 'version',
202
+ dataType: 'number' as any,
203
+ description: 'Version number',
204
+ },
205
+
206
+ // Template fields
207
+ {
208
+ name: 'template_id',
209
+ dataType: 'text' as any,
210
+ description: 'Template ID if using template',
211
+ },
212
+
213
+ // Relationship-specific fields
214
+ {
215
+ name: 'memory_ids',
216
+ dataType: 'text[]' as any,
217
+ description: 'Connected memory IDs (for relationships)',
218
+ },
219
+ {
220
+ name: 'relationship_type',
221
+ dataType: 'text' as any,
222
+ description: 'Relationship type (for relationships)',
223
+ },
224
+ {
225
+ name: 'observation',
226
+ dataType: 'text' as any,
227
+ description: 'Relationship observation (vectorized)',
228
+ },
229
+ {
230
+ name: 'strength',
231
+ dataType: 'number' as any,
232
+ description: 'Relationship strength (0-1)',
233
+ },
234
+
235
+ // Computed fields
236
+ {
237
+ name: 'base_weight',
238
+ dataType: 'number' as any,
239
+ description: 'User-specified weight',
240
+ },
241
+ {
242
+ name: 'computed_weight',
243
+ dataType: 'number' as any,
244
+ description: 'Calculated effective weight',
245
+ },
246
+ ],
247
+ });
248
+
249
+ console.log(`[Weaviate] Collection ${collectionName} created successfully`);
250
+ }
251
+
252
+ /**
253
+ * Ensure Memory collection exists for user (lazy creation)
254
+ */
255
+ export async function ensureMemoryCollection(userId: string): Promise<void> {
256
+ const client = getWeaviateClient();
257
+ const collectionName = `Memory_${sanitizeUserId(userId)}`;
258
+
259
+ const exists = await client.collections.exists(collectionName);
260
+
261
+ if (!exists) {
262
+ await createMemoryCollection(userId);
263
+ }
264
+ }
265
+
266
+ /**
267
+ * Get Memory collection for user
268
+ */
269
+ export function getMemoryCollection(userId: string) {
270
+ const client = getWeaviateClient();
271
+ const collectionName = `Memory_${sanitizeUserId(userId)}`;
272
+ return client.collections.get(collectionName);
273
+ }
274
+
275
+ /**
276
+ * Delete Memory collection for user (use with caution!)
277
+ */
278
+ export async function deleteMemoryCollection(userId: string): Promise<void> {
279
+ const client = getWeaviateClient();
280
+ const collectionName = `Memory_${sanitizeUserId(userId)}`;
281
+
282
+ const exists = await client.collections.exists(collectionName);
283
+
284
+ if (exists) {
285
+ await client.collections.delete(collectionName);
286
+ console.log(`[Weaviate] Collection ${collectionName} deleted`);
287
+ }
288
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ES2022",
5
+ "lib": ["ES2022"],
6
+ "moduleResolution": "node",
7
+ "esModuleInterop": true,
8
+ "allowSyntheticDefaultImports": true,
9
+ "strict": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "resolveJsonModule": true,
13
+ "outDir": "./dist",
14
+ "rootDir": "./src",
15
+ "declaration": true,
16
+ "declarationMap": true,
17
+ "sourceMap": true,
18
+ "types": ["node"],
19
+ "baseUrl": ".",
20
+ "paths": {
21
+ "@/*": ["src/*"]
22
+ }
23
+ },
24
+ "include": ["src/**/*"],
25
+ "exclude": ["node_modules", "dist", "tests"]
26
+ }