@danielsimonjr/memory-mcp 12.2.3 → 12.5.2

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 (158) hide show
  1. package/README.md +88 -102
  2. package/dist/index.js +6 -0
  3. package/dist/server/toolDefinitions.d.ts.map +1 -1
  4. package/dist/server/toolDefinitions.js +745 -3
  5. package/dist/server/toolHandlers.d.ts +1 -9
  6. package/dist/server/toolHandlers.d.ts.map +1 -1
  7. package/dist/server/toolHandlers.js +859 -11
  8. package/package.json +9 -6
  9. package/dist/core/EntityManager.d.ts +0 -263
  10. package/dist/core/EntityManager.d.ts.map +0 -1
  11. package/dist/core/EntityManager.js +0 -478
  12. package/dist/core/GraphStorage.d.ts +0 -344
  13. package/dist/core/GraphStorage.d.ts.map +0 -1
  14. package/dist/core/GraphStorage.js +0 -708
  15. package/dist/core/GraphTraversal.d.ts +0 -136
  16. package/dist/core/GraphTraversal.d.ts.map +0 -1
  17. package/dist/core/GraphTraversal.js +0 -556
  18. package/dist/core/HierarchyManager.d.ts +0 -111
  19. package/dist/core/HierarchyManager.d.ts.map +0 -1
  20. package/dist/core/HierarchyManager.js +0 -224
  21. package/dist/core/ManagerContext.d.ts +0 -72
  22. package/dist/core/ManagerContext.d.ts.map +0 -1
  23. package/dist/core/ManagerContext.js +0 -118
  24. package/dist/core/ObservationManager.d.ts +0 -85
  25. package/dist/core/ObservationManager.d.ts.map +0 -1
  26. package/dist/core/ObservationManager.js +0 -123
  27. package/dist/core/RelationManager.d.ts +0 -131
  28. package/dist/core/RelationManager.d.ts.map +0 -1
  29. package/dist/core/RelationManager.js +0 -210
  30. package/dist/core/SQLiteStorage.d.ts +0 -354
  31. package/dist/core/SQLiteStorage.d.ts.map +0 -1
  32. package/dist/core/SQLiteStorage.js +0 -917
  33. package/dist/core/StorageFactory.d.ts +0 -45
  34. package/dist/core/StorageFactory.d.ts.map +0 -1
  35. package/dist/core/StorageFactory.js +0 -64
  36. package/dist/core/TransactionManager.d.ts +0 -259
  37. package/dist/core/TransactionManager.d.ts.map +0 -1
  38. package/dist/core/TransactionManager.js +0 -392
  39. package/dist/core/index.d.ts +0 -16
  40. package/dist/core/index.d.ts.map +0 -1
  41. package/dist/core/index.js +0 -17
  42. package/dist/features/AnalyticsManager.d.ts +0 -44
  43. package/dist/features/AnalyticsManager.d.ts.map +0 -1
  44. package/dist/features/AnalyticsManager.js +0 -223
  45. package/dist/features/ArchiveManager.d.ts +0 -121
  46. package/dist/features/ArchiveManager.d.ts.map +0 -1
  47. package/dist/features/ArchiveManager.js +0 -240
  48. package/dist/features/CompressionManager.d.ts +0 -109
  49. package/dist/features/CompressionManager.d.ts.map +0 -1
  50. package/dist/features/CompressionManager.js +0 -404
  51. package/dist/features/IOManager.d.ts +0 -221
  52. package/dist/features/IOManager.d.ts.map +0 -1
  53. package/dist/features/IOManager.js +0 -997
  54. package/dist/features/StreamingExporter.d.ts +0 -105
  55. package/dist/features/StreamingExporter.d.ts.map +0 -1
  56. package/dist/features/StreamingExporter.js +0 -150
  57. package/dist/features/TagManager.d.ts +0 -147
  58. package/dist/features/TagManager.d.ts.map +0 -1
  59. package/dist/features/TagManager.js +0 -210
  60. package/dist/features/index.d.ts +0 -12
  61. package/dist/features/index.d.ts.map +0 -1
  62. package/dist/features/index.js +0 -11
  63. package/dist/search/BasicSearch.d.ts +0 -51
  64. package/dist/search/BasicSearch.d.ts.map +0 -1
  65. package/dist/search/BasicSearch.js +0 -137
  66. package/dist/search/BooleanSearch.d.ts +0 -98
  67. package/dist/search/BooleanSearch.d.ts.map +0 -1
  68. package/dist/search/BooleanSearch.js +0 -430
  69. package/dist/search/EmbeddingService.d.ts +0 -178
  70. package/dist/search/EmbeddingService.d.ts.map +0 -1
  71. package/dist/search/EmbeddingService.js +0 -358
  72. package/dist/search/FuzzySearch.d.ts +0 -118
  73. package/dist/search/FuzzySearch.d.ts.map +0 -1
  74. package/dist/search/FuzzySearch.js +0 -312
  75. package/dist/search/RankedSearch.d.ts +0 -71
  76. package/dist/search/RankedSearch.d.ts.map +0 -1
  77. package/dist/search/RankedSearch.js +0 -238
  78. package/dist/search/SavedSearchManager.d.ts +0 -79
  79. package/dist/search/SavedSearchManager.d.ts.map +0 -1
  80. package/dist/search/SavedSearchManager.js +0 -145
  81. package/dist/search/SearchFilterChain.d.ts +0 -120
  82. package/dist/search/SearchFilterChain.d.ts.map +0 -1
  83. package/dist/search/SearchFilterChain.js +0 -185
  84. package/dist/search/SearchManager.d.ts +0 -285
  85. package/dist/search/SearchManager.d.ts.map +0 -1
  86. package/dist/search/SearchManager.js +0 -338
  87. package/dist/search/SearchSuggestions.d.ts +0 -27
  88. package/dist/search/SearchSuggestions.d.ts.map +0 -1
  89. package/dist/search/SearchSuggestions.js +0 -57
  90. package/dist/search/SemanticSearch.d.ts +0 -146
  91. package/dist/search/SemanticSearch.d.ts.map +0 -1
  92. package/dist/search/SemanticSearch.js +0 -313
  93. package/dist/search/TFIDFIndexManager.d.ts +0 -63
  94. package/dist/search/TFIDFIndexManager.d.ts.map +0 -1
  95. package/dist/search/TFIDFIndexManager.js +0 -215
  96. package/dist/search/VectorStore.d.ts +0 -235
  97. package/dist/search/VectorStore.d.ts.map +0 -1
  98. package/dist/search/VectorStore.js +0 -311
  99. package/dist/search/index.d.ts +0 -18
  100. package/dist/search/index.d.ts.map +0 -1
  101. package/dist/search/index.js +0 -21
  102. package/dist/types/index.d.ts +0 -13
  103. package/dist/types/index.d.ts.map +0 -1
  104. package/dist/types/index.js +0 -12
  105. package/dist/types/types.d.ts +0 -1234
  106. package/dist/types/types.d.ts.map +0 -1
  107. package/dist/types/types.js +0 -9
  108. package/dist/utils/compressedCache.d.ts +0 -192
  109. package/dist/utils/compressedCache.d.ts.map +0 -1
  110. package/dist/utils/compressedCache.js +0 -309
  111. package/dist/utils/compressionUtil.d.ts +0 -214
  112. package/dist/utils/compressionUtil.d.ts.map +0 -1
  113. package/dist/utils/compressionUtil.js +0 -247
  114. package/dist/utils/constants.d.ts +0 -245
  115. package/dist/utils/constants.d.ts.map +0 -1
  116. package/dist/utils/constants.js +0 -252
  117. package/dist/utils/entityUtils.d.ts +0 -321
  118. package/dist/utils/entityUtils.d.ts.map +0 -1
  119. package/dist/utils/entityUtils.js +0 -538
  120. package/dist/utils/errors.d.ts +0 -77
  121. package/dist/utils/errors.d.ts.map +0 -1
  122. package/dist/utils/errors.js +0 -121
  123. package/dist/utils/formatters.d.ts +0 -145
  124. package/dist/utils/formatters.d.ts.map +0 -1
  125. package/dist/utils/formatters.js +0 -132
  126. package/dist/utils/index.d.ts +0 -22
  127. package/dist/utils/index.d.ts.map +0 -1
  128. package/dist/utils/index.js +0 -75
  129. package/dist/utils/indexes.d.ts +0 -270
  130. package/dist/utils/indexes.d.ts.map +0 -1
  131. package/dist/utils/indexes.js +0 -526
  132. package/dist/utils/logger.d.ts +0 -24
  133. package/dist/utils/logger.d.ts.map +0 -1
  134. package/dist/utils/logger.js +0 -33
  135. package/dist/utils/parallelUtils.d.ts +0 -72
  136. package/dist/utils/parallelUtils.d.ts.map +0 -1
  137. package/dist/utils/parallelUtils.js +0 -169
  138. package/dist/utils/schemas.d.ts +0 -374
  139. package/dist/utils/schemas.d.ts.map +0 -1
  140. package/dist/utils/schemas.js +0 -484
  141. package/dist/utils/searchAlgorithms.d.ts +0 -99
  142. package/dist/utils/searchAlgorithms.d.ts.map +0 -1
  143. package/dist/utils/searchAlgorithms.js +0 -167
  144. package/dist/utils/searchCache.d.ts +0 -108
  145. package/dist/utils/searchCache.d.ts.map +0 -1
  146. package/dist/utils/searchCache.js +0 -209
  147. package/dist/utils/taskScheduler.d.ts +0 -290
  148. package/dist/utils/taskScheduler.d.ts.map +0 -1
  149. package/dist/utils/taskScheduler.js +0 -466
  150. package/dist/workers/WorkerPool.d.ts +0 -81
  151. package/dist/workers/WorkerPool.d.ts.map +0 -1
  152. package/dist/workers/WorkerPool.js +0 -121
  153. package/dist/workers/index.d.ts +0 -12
  154. package/dist/workers/index.d.ts.map +0 -1
  155. package/dist/workers/index.js +0 -9
  156. package/dist/workers/levenshteinWorker.d.ts +0 -60
  157. package/dist/workers/levenshteinWorker.d.ts.map +0 -1
  158. package/dist/workers/levenshteinWorker.js +0 -98
@@ -1,526 +0,0 @@
1
- /**
2
- * Search Indexes
3
- *
4
- * Provides O(1) lookup structures to avoid repeated linear scans.
5
- * - NameIndex: O(1) entity lookup by name
6
- * - TypeIndex: O(1) entities by type
7
- * - LowercaseCache: Pre-computed lowercase strings to avoid repeated toLowerCase()
8
- * - RelationIndex: O(1) relation lookup by entity name (from/to)
9
- * - ObservationIndex: O(1) observation word lookup by entity
10
- *
11
- * @module utils/indexes
12
- */
13
- /**
14
- * NameIndex provides O(1) entity lookup by name.
15
- *
16
- * Uses a Map internally for constant-time access.
17
- */
18
- export class NameIndex {
19
- index = new Map();
20
- /**
21
- * Build the index from an array of entities.
22
- * Clears any existing index data first.
23
- */
24
- build(entities) {
25
- this.index.clear();
26
- for (const entity of entities) {
27
- this.index.set(entity.name, entity);
28
- }
29
- }
30
- /**
31
- * Get an entity by name in O(1) time.
32
- */
33
- get(name) {
34
- return this.index.get(name);
35
- }
36
- /**
37
- * Add a single entity to the index.
38
- */
39
- add(entity) {
40
- this.index.set(entity.name, entity);
41
- }
42
- /**
43
- * Remove an entity from the index by name.
44
- */
45
- remove(name) {
46
- this.index.delete(name);
47
- }
48
- /**
49
- * Check if an entity exists in the index.
50
- */
51
- has(name) {
52
- return this.index.has(name);
53
- }
54
- /**
55
- * Get the number of entities in the index.
56
- */
57
- get size() {
58
- return this.index.size;
59
- }
60
- /**
61
- * Clear all entries from the index.
62
- */
63
- clear() {
64
- this.index.clear();
65
- }
66
- }
67
- /**
68
- * TypeIndex provides O(1) lookup of entities by type.
69
- *
70
- * Uses a Map<type, Set<entityName>> structure for efficient type queries.
71
- * Type comparisons are case-insensitive.
72
- */
73
- export class TypeIndex {
74
- index = new Map();
75
- /**
76
- * Build the index from an array of entities.
77
- * Clears any existing index data first.
78
- */
79
- build(entities) {
80
- this.index.clear();
81
- for (const entity of entities) {
82
- this.addToIndex(entity.name, entity.entityType);
83
- }
84
- }
85
- /**
86
- * Get all entity names of a given type in O(1) time.
87
- * Type comparison is case-insensitive.
88
- */
89
- getNames(entityType) {
90
- const typeLower = entityType.toLowerCase();
91
- return this.index.get(typeLower) ?? new Set();
92
- }
93
- /**
94
- * Add an entity to the type index.
95
- */
96
- add(entity) {
97
- this.addToIndex(entity.name, entity.entityType);
98
- }
99
- /**
100
- * Remove an entity from the type index.
101
- * Requires the entity type to know which bucket to remove from.
102
- */
103
- remove(entityName, entityType) {
104
- const typeLower = entityType.toLowerCase();
105
- const names = this.index.get(typeLower);
106
- if (names) {
107
- names.delete(entityName);
108
- if (names.size === 0) {
109
- this.index.delete(typeLower);
110
- }
111
- }
112
- }
113
- /**
114
- * Update an entity's type in the index.
115
- * Removes from old type and adds to new type.
116
- */
117
- updateType(entityName, oldType, newType) {
118
- this.remove(entityName, oldType);
119
- this.addToIndex(entityName, newType);
120
- }
121
- /**
122
- * Get all unique types in the index.
123
- */
124
- getTypes() {
125
- return Array.from(this.index.keys());
126
- }
127
- /**
128
- * Clear all entries from the index.
129
- */
130
- clear() {
131
- this.index.clear();
132
- }
133
- addToIndex(entityName, entityType) {
134
- const typeLower = entityType.toLowerCase();
135
- let names = this.index.get(typeLower);
136
- if (!names) {
137
- names = new Set();
138
- this.index.set(typeLower, names);
139
- }
140
- names.add(entityName);
141
- }
142
- }
143
- /**
144
- * LowercaseCache pre-computes lowercase versions of all searchable fields.
145
- *
146
- * Eliminates the need for repeated toLowerCase() calls during search,
147
- * which is expensive with many entities and observations.
148
- */
149
- export class LowercaseCache {
150
- cache = new Map();
151
- /**
152
- * Build the cache from an array of entities.
153
- * Clears any existing cache data first.
154
- */
155
- build(entities) {
156
- this.cache.clear();
157
- for (const entity of entities) {
158
- this.cache.set(entity.name, this.computeLowercase(entity));
159
- }
160
- }
161
- /**
162
- * Get pre-computed lowercase data for an entity.
163
- */
164
- get(entityName) {
165
- return this.cache.get(entityName);
166
- }
167
- /**
168
- * Add or update an entity in the cache.
169
- */
170
- set(entity) {
171
- this.cache.set(entity.name, this.computeLowercase(entity));
172
- }
173
- /**
174
- * Remove an entity from the cache.
175
- */
176
- remove(entityName) {
177
- this.cache.delete(entityName);
178
- }
179
- /**
180
- * Check if an entity exists in the cache.
181
- */
182
- has(entityName) {
183
- return this.cache.has(entityName);
184
- }
185
- /**
186
- * Clear all entries from the cache.
187
- */
188
- clear() {
189
- this.cache.clear();
190
- }
191
- /**
192
- * Get the number of entries in the cache.
193
- */
194
- get size() {
195
- return this.cache.size;
196
- }
197
- computeLowercase(entity) {
198
- return {
199
- name: entity.name.toLowerCase(),
200
- entityType: entity.entityType.toLowerCase(),
201
- observations: entity.observations.map(o => o.toLowerCase()),
202
- tags: entity.tags?.map(t => t.toLowerCase()) ?? [],
203
- };
204
- }
205
- }
206
- /**
207
- * RelationIndex provides O(1) lookup of relations by entity name.
208
- *
209
- * Maintains two separate indexes for efficient directional queries:
210
- * - fromIndex: Map from source entity name to its outgoing relations
211
- * - toIndex: Map from target entity name to its incoming relations
212
- *
213
- * This eliminates O(n) array scans when looking up relations for an entity.
214
- */
215
- export class RelationIndex {
216
- /** Index of relations by source (from) entity */
217
- fromIndex = new Map();
218
- /** Index of relations by target (to) entity */
219
- toIndex = new Map();
220
- /**
221
- * Build the index from an array of relations.
222
- * Clears any existing index data first.
223
- */
224
- build(relations) {
225
- this.fromIndex.clear();
226
- this.toIndex.clear();
227
- for (const relation of relations) {
228
- this.addToIndexes(relation);
229
- }
230
- }
231
- /**
232
- * Get all relations where the entity is the source (outgoing relations).
233
- * Returns empty array if no relations found.
234
- */
235
- getRelationsFrom(entityName) {
236
- const relations = this.fromIndex.get(entityName);
237
- return relations ? Array.from(relations) : [];
238
- }
239
- /**
240
- * Get all relations where the entity is the target (incoming relations).
241
- * Returns empty array if no relations found.
242
- */
243
- getRelationsTo(entityName) {
244
- const relations = this.toIndex.get(entityName);
245
- return relations ? Array.from(relations) : [];
246
- }
247
- /**
248
- * Get all relations involving the entity (both incoming and outgoing).
249
- * Returns empty array if no relations found.
250
- */
251
- getRelationsFor(entityName) {
252
- const fromRelations = this.fromIndex.get(entityName);
253
- const toRelations = this.toIndex.get(entityName);
254
- // Combine sets to handle self-referential relations correctly
255
- const combined = new Set();
256
- if (fromRelations) {
257
- for (const r of fromRelations) {
258
- combined.add(r);
259
- }
260
- }
261
- if (toRelations) {
262
- for (const r of toRelations) {
263
- combined.add(r);
264
- }
265
- }
266
- return Array.from(combined);
267
- }
268
- /**
269
- * Add a single relation to the index.
270
- */
271
- add(relation) {
272
- this.addToIndexes(relation);
273
- }
274
- /**
275
- * Remove a relation from the index.
276
- * Matches by from, to, and relationType.
277
- */
278
- remove(relation) {
279
- // Remove from fromIndex
280
- const fromRelations = this.fromIndex.get(relation.from);
281
- if (fromRelations) {
282
- for (const r of fromRelations) {
283
- if (r.from === relation.from && r.to === relation.to && r.relationType === relation.relationType) {
284
- fromRelations.delete(r);
285
- break;
286
- }
287
- }
288
- if (fromRelations.size === 0) {
289
- this.fromIndex.delete(relation.from);
290
- }
291
- }
292
- // Remove from toIndex
293
- const toRelations = this.toIndex.get(relation.to);
294
- if (toRelations) {
295
- for (const r of toRelations) {
296
- if (r.from === relation.from && r.to === relation.to && r.relationType === relation.relationType) {
297
- toRelations.delete(r);
298
- break;
299
- }
300
- }
301
- if (toRelations.size === 0) {
302
- this.toIndex.delete(relation.to);
303
- }
304
- }
305
- }
306
- /**
307
- * Remove all relations involving a specific entity.
308
- * Returns the relations that were removed.
309
- */
310
- removeAllForEntity(entityName) {
311
- const removed = [];
312
- // Remove outgoing relations
313
- const fromRelations = this.fromIndex.get(entityName);
314
- if (fromRelations) {
315
- for (const r of fromRelations) {
316
- removed.push(r);
317
- // Also remove from toIndex
318
- const toRels = this.toIndex.get(r.to);
319
- if (toRels) {
320
- toRels.delete(r);
321
- if (toRels.size === 0) {
322
- this.toIndex.delete(r.to);
323
- }
324
- }
325
- }
326
- this.fromIndex.delete(entityName);
327
- }
328
- // Remove incoming relations
329
- const toRelations = this.toIndex.get(entityName);
330
- if (toRelations) {
331
- for (const r of toRelations) {
332
- // Skip self-referential relations (already handled above)
333
- if (r.from === entityName)
334
- continue;
335
- removed.push(r);
336
- // Also remove from fromIndex
337
- const fromRels = this.fromIndex.get(r.from);
338
- if (fromRels) {
339
- fromRels.delete(r);
340
- if (fromRels.size === 0) {
341
- this.fromIndex.delete(r.from);
342
- }
343
- }
344
- }
345
- this.toIndex.delete(entityName);
346
- }
347
- return removed;
348
- }
349
- /**
350
- * Check if any relations exist for an entity.
351
- */
352
- hasRelations(entityName) {
353
- return this.fromIndex.has(entityName) || this.toIndex.has(entityName);
354
- }
355
- /**
356
- * Get count of outgoing relations for an entity.
357
- */
358
- getOutgoingCount(entityName) {
359
- return this.fromIndex.get(entityName)?.size ?? 0;
360
- }
361
- /**
362
- * Get count of incoming relations for an entity.
363
- */
364
- getIncomingCount(entityName) {
365
- return this.toIndex.get(entityName)?.size ?? 0;
366
- }
367
- /**
368
- * Get total count of unique relations in the index.
369
- */
370
- get size() {
371
- // Count all relations in fromIndex (each relation appears exactly once there)
372
- let count = 0;
373
- for (const relations of this.fromIndex.values()) {
374
- count += relations.size;
375
- }
376
- return count;
377
- }
378
- /**
379
- * Clear all entries from the index.
380
- */
381
- clear() {
382
- this.fromIndex.clear();
383
- this.toIndex.clear();
384
- }
385
- addToIndexes(relation) {
386
- // Add to fromIndex
387
- let fromSet = this.fromIndex.get(relation.from);
388
- if (!fromSet) {
389
- fromSet = new Set();
390
- this.fromIndex.set(relation.from, fromSet);
391
- }
392
- fromSet.add(relation);
393
- // Add to toIndex
394
- let toSet = this.toIndex.get(relation.to);
395
- if (!toSet) {
396
- toSet = new Set();
397
- this.toIndex.set(relation.to, toSet);
398
- }
399
- toSet.add(relation);
400
- }
401
- }
402
- /**
403
- * Inverted index mapping observation keywords to entity names.
404
- * Enables O(1) lookup for 'which entities mention word X?' queries.
405
- * Words are normalized to lowercase and split on whitespace/punctuation.
406
- */
407
- export class ObservationIndex {
408
- index = new Map();
409
- entityObservations = new Map();
410
- /**
411
- * Add an entity's observations to the index.
412
- * Tokenizes observations into words and creates reverse mapping.
413
- *
414
- * @param entityName - Name of the entity
415
- * @param observations - Array of observation strings
416
- */
417
- add(entityName, observations) {
418
- const entityWords = new Set();
419
- for (const observation of observations) {
420
- const words = this.tokenize(observation);
421
- for (const word of words) {
422
- entityWords.add(word);
423
- if (!this.index.has(word)) {
424
- this.index.set(word, new Set());
425
- }
426
- this.index.get(word).add(entityName);
427
- }
428
- }
429
- this.entityObservations.set(entityName, entityWords);
430
- }
431
- /**
432
- * Remove an entity from the index.
433
- * Cleans up all word mappings for this entity.
434
- *
435
- * @param entityName - Name of the entity to remove
436
- */
437
- remove(entityName) {
438
- const words = this.entityObservations.get(entityName);
439
- if (!words)
440
- return;
441
- for (const word of words) {
442
- const entities = this.index.get(word);
443
- if (entities) {
444
- entities.delete(entityName);
445
- if (entities.size === 0) {
446
- this.index.delete(word);
447
- }
448
- }
449
- }
450
- this.entityObservations.delete(entityName);
451
- }
452
- /**
453
- * Get all entities that have observations containing the given word.
454
- * Word matching is case-insensitive.
455
- *
456
- * @param word - Word to search for
457
- * @returns Set of entity names containing this word
458
- */
459
- getEntitiesWithWord(word) {
460
- return this.index.get(word.toLowerCase()) ?? new Set();
461
- }
462
- /**
463
- * Get all entities that have observations containing ANY of the given words (union).
464
- *
465
- * @param words - Array of words to search for
466
- * @returns Set of entity names containing any of the words
467
- */
468
- getEntitiesWithAnyWord(words) {
469
- const result = new Set();
470
- for (const word of words) {
471
- const entities = this.getEntitiesWithWord(word);
472
- for (const entity of entities) {
473
- result.add(entity);
474
- }
475
- }
476
- return result;
477
- }
478
- /**
479
- * Get all entities that have observations containing ALL of the given words (intersection).
480
- *
481
- * @param words - Array of words that must all be present
482
- * @returns Set of entity names containing all of the words
483
- */
484
- getEntitiesWithAllWords(words) {
485
- if (words.length === 0)
486
- return new Set();
487
- let result = new Set(this.getEntitiesWithWord(words[0]));
488
- for (let i = 1; i < words.length && result.size > 0; i++) {
489
- const wordEntities = this.getEntitiesWithWord(words[i]);
490
- result = new Set([...result].filter(e => wordEntities.has(e)));
491
- }
492
- return result;
493
- }
494
- /**
495
- * Clear all entries from the index.
496
- */
497
- clear() {
498
- this.index.clear();
499
- this.entityObservations.clear();
500
- }
501
- /**
502
- * Get statistics about the index.
503
- *
504
- * @returns Object with wordCount and entityCount
505
- */
506
- getStats() {
507
- return {
508
- wordCount: this.index.size,
509
- entityCount: this.entityObservations.size,
510
- };
511
- }
512
- /**
513
- * Tokenize text into searchable words.
514
- * Normalizes to lowercase, splits on non-alphanumeric characters,
515
- * and filters out words less than 2 characters.
516
- *
517
- * @param text - Text to tokenize
518
- * @returns Array of normalized words
519
- */
520
- tokenize(text) {
521
- return text
522
- .toLowerCase()
523
- .split(/[^a-z0-9]+/)
524
- .filter(word => word.length >= 2);
525
- }
526
- }
@@ -1,24 +0,0 @@
1
- /**
2
- * Simple logging utility for the Memory MCP Server
3
- *
4
- * Provides consistent log formatting with levels: debug, info, warn, error
5
- */
6
- export declare const logger: {
7
- /**
8
- * Debug level logging (verbose, for development)
9
- */
10
- debug: (msg: string, ...args: unknown[]) => void;
11
- /**
12
- * Info level logging (general informational messages)
13
- */
14
- info: (msg: string, ...args: unknown[]) => void;
15
- /**
16
- * Warning level logging (warnings that don't prevent operation)
17
- */
18
- warn: (msg: string, ...args: unknown[]) => void;
19
- /**
20
- * Error level logging (errors that affect functionality)
21
- */
22
- error: (msg: string, ...args: unknown[]) => void;
23
- };
24
- //# sourceMappingURL=logger.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,MAAM;IACjB;;OAEG;iBACU,MAAM,WAAW,OAAO,EAAE,KAAG,IAAI;IAM9C;;OAEG;gBACS,MAAM,WAAW,OAAO,EAAE,KAAG,IAAI;IAI7C;;OAEG;gBACS,MAAM,WAAW,OAAO,EAAE,KAAG,IAAI;IAI7C;;OAEG;iBACU,MAAM,WAAW,OAAO,EAAE,KAAG,IAAI;CAG/C,CAAC"}
@@ -1,33 +0,0 @@
1
- /**
2
- * Simple logging utility for the Memory MCP Server
3
- *
4
- * Provides consistent log formatting with levels: debug, info, warn, error
5
- */
6
- export const logger = {
7
- /**
8
- * Debug level logging (verbose, for development)
9
- */
10
- debug: (msg, ...args) => {
11
- if (process.env.LOG_LEVEL === 'debug') {
12
- console.debug(`[DEBUG] ${msg}`, ...args);
13
- }
14
- },
15
- /**
16
- * Info level logging (general informational messages)
17
- */
18
- info: (msg, ...args) => {
19
- console.log(`[INFO] ${msg}`, ...args);
20
- },
21
- /**
22
- * Warning level logging (warnings that don't prevent operation)
23
- */
24
- warn: (msg, ...args) => {
25
- console.warn(`[WARN] ${msg}`, ...args);
26
- },
27
- /**
28
- * Error level logging (errors that affect functionality)
29
- */
30
- error: (msg, ...args) => {
31
- console.error(`[ERROR] ${msg}`, ...args);
32
- },
33
- };
@@ -1,72 +0,0 @@
1
- /**
2
- * Parallel Utilities
3
- *
4
- * Utilities for parallel array operations using workerpool.
5
- * Phase 8 Sprint 3: Parallel array operations for improved performance.
6
- *
7
- * @module utils/parallelUtils
8
- */
9
- import workerpool from '@danielsimonjr/workerpool/modern';
10
- /**
11
- * Shutdown the shared worker pool and clean up resources.
12
- * Should be called when parallel utilities are no longer needed.
13
- */
14
- export declare function shutdownParallelUtils(): Promise<void>;
15
- /**
16
- * Map items in parallel using workerpool.
17
- *
18
- * Splits the array into chunks and processes each chunk in a worker thread.
19
- * Falls back to single-threaded for small arrays (< MIN_PARALLEL_SIZE).
20
- *
21
- * **Note:** The mapping function must be serializable (no closures, external variables).
22
- * Due to ESM/worker thread compatibility issues, this may fall back to single-threaded
23
- * execution in some environments (e.g., vitest test runner).
24
- *
25
- * @template T - Input item type
26
- * @template R - Output item type
27
- * @param items - Array of items to map
28
- * @param fn - Mapping function (must be serializable)
29
- * @param chunkSize - Optional chunk size (default: DEFAULT_CHUNK_SIZE)
30
- * @returns Promise resolving to array of mapped results
31
- *
32
- * @example
33
- * ```typescript
34
- * // Map numbers to their squares
35
- * const numbers = [1, 2, 3, 4, 5];
36
- * const squared = await parallelMap(numbers, (n: number) => n * n);
37
- * // Result: [1, 4, 9, 16, 25]
38
- * ```
39
- */
40
- export declare function parallelMap<T, R>(items: T[], fn: (item: T) => R, chunkSize?: number): Promise<R[]>;
41
- /**
42
- * Filter items in parallel using workerpool.
43
- *
44
- * Splits the array into chunks and processes each chunk in a worker thread.
45
- * Falls back to single-threaded for small arrays (< MIN_PARALLEL_SIZE).
46
- *
47
- * **Note:** The predicate function must be serializable (no closures, external variables).
48
- * Due to ESM/worker thread compatibility issues, this may fall back to single-threaded
49
- * execution in some environments (e.g., vitest test runner).
50
- *
51
- * @template T - Item type
52
- * @param items - Array of items to filter
53
- * @param predicate - Filter predicate (must be serializable)
54
- * @param chunkSize - Optional chunk size (default: DEFAULT_CHUNK_SIZE)
55
- * @returns Promise resolving to filtered array
56
- *
57
- * @example
58
- * ```typescript
59
- * // Filter even numbers
60
- * const numbers = [1, 2, 3, 4, 5, 6];
61
- * const evens = await parallelFilter(numbers, (n: number) => n % 2 === 0);
62
- * // Result: [2, 4, 6]
63
- * ```
64
- */
65
- export declare function parallelFilter<T>(items: T[], predicate: (item: T) => boolean, chunkSize?: number): Promise<T[]>;
66
- /**
67
- * Get statistics about the worker pool.
68
- *
69
- * @returns Pool statistics or null if pool is not initialized
70
- */
71
- export declare function getPoolStats(): workerpool.PoolStats | null;
72
- //# sourceMappingURL=parallelUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parallelUtils.d.ts","sourceRoot":"","sources":["../../src/utils/parallelUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,UAAU,MAAM,kCAAkC,CAAC;AAoC1D;;;GAGG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAK3D;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,WAAW,CAAC,CAAC,EAAE,CAAC,EACpC,KAAK,EAAE,CAAC,EAAE,EACV,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,EAClB,SAAS,GAAE,MAA2B,GACrC,OAAO,CAAC,CAAC,EAAE,CAAC,CAwCd;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,cAAc,CAAC,CAAC,EACpC,KAAK,EAAE,CAAC,EAAE,EACV,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,EAC/B,SAAS,GAAE,MAA2B,GACrC,OAAO,CAAC,CAAC,EAAE,CAAC,CAwCd;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,UAAU,CAAC,SAAS,GAAG,IAAI,CAK1D"}