@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,285 +0,0 @@
1
- /**
2
- * Search Manager
3
- *
4
- * Orchestrates all search types (basic, ranked, boolean, fuzzy).
5
- * Focused on search operations only (Phase 4: Consolidate God Objects).
6
- *
7
- * @module search/SearchManager
8
- */
9
- import type { KnowledgeGraph, SearchResult, SavedSearch } from '../types/index.js';
10
- import type { GraphStorage } from '../core/GraphStorage.js';
11
- /**
12
- * Unified search manager providing access to all search types.
13
- *
14
- * Phase 4 Sprint 5: Manages search caches across all search types.
15
- */
16
- export declare class SearchManager {
17
- private basicSearch;
18
- private rankedSearch;
19
- private booleanSearcher;
20
- private fuzzySearcher;
21
- private searchSuggestions;
22
- private savedSearchManager;
23
- constructor(storage: GraphStorage, savedSearchesFilePath: string);
24
- /**
25
- * Phase 4 Sprint 5: Clear all search caches.
26
- *
27
- * Clears caches in all search types: fuzzy, boolean, and ranked token cache.
28
- * Call this when the graph has been modified to ensure fresh results.
29
- */
30
- clearAllCaches(): void;
31
- /**
32
- * Phase 4 Sprint 5: Clear fuzzy search cache.
33
- */
34
- clearFuzzyCache(): void;
35
- /**
36
- * Phase 4 Sprint 5: Clear boolean search cache.
37
- */
38
- clearBooleanCache(): void;
39
- /**
40
- * Phase 4 Sprint 5: Clear ranked search token cache.
41
- */
42
- clearRankedCache(): void;
43
- /**
44
- * Perform a simple text-based search across entity names and observations.
45
- *
46
- * This is the primary search method that searches through entity names,
47
- * observations, and types using case-insensitive substring matching.
48
- * Optionally filter by tags and importance range.
49
- *
50
- * @param query - Text to search for (case-insensitive, searches names/observations/types)
51
- * @param tags - Optional array of tags to filter results (lowercase)
52
- * @param minImportance - Optional minimum importance value (0-10)
53
- * @param maxImportance - Optional maximum importance value (0-10)
54
- * @returns KnowledgeGraph containing matching entities and their relations
55
- *
56
- * @example
57
- * ```typescript
58
- * const manager = new SearchManager(storage, savedSearchesPath);
59
- *
60
- * // Simple text search
61
- * const results = await manager.searchNodes('Alice');
62
- *
63
- * // Search with tag filter
64
- * const engineeringResults = await manager.searchNodes('project', ['engineering']);
65
- *
66
- * // Search with importance range
67
- * const importantResults = await manager.searchNodes('critical', undefined, 8, 10);
68
- *
69
- * // Combined filters
70
- * const filtered = await manager.searchNodes('bug', ['backend'], 5, 10);
71
- * ```
72
- */
73
- searchNodes(query: string, tags?: string[], minImportance?: number, maxImportance?: number): Promise<KnowledgeGraph>;
74
- /**
75
- * Open specific nodes by name.
76
- *
77
- * @param names - Array of entity names
78
- * @returns Knowledge graph with specified entities
79
- */
80
- openNodes(names: string[]): Promise<KnowledgeGraph>;
81
- /**
82
- * Search by date range.
83
- *
84
- * @param startDate - Optional start date (ISO 8601)
85
- * @param endDate - Optional end date (ISO 8601)
86
- * @param entityType - Optional entity type filter
87
- * @param tags - Optional tags filter
88
- * @returns Filtered knowledge graph
89
- */
90
- searchByDateRange(startDate?: string, endDate?: string, entityType?: string, tags?: string[]): Promise<KnowledgeGraph>;
91
- /**
92
- * Perform TF-IDF ranked search with relevance scoring.
93
- *
94
- * Uses Term Frequency-Inverse Document Frequency algorithm to rank results
95
- * by relevance to the query. Results are sorted by score (highest first).
96
- * This is ideal for finding the most relevant entities for a search query.
97
- *
98
- * @param query - Search query (analyzed for term frequency)
99
- * @param tags - Optional array of tags to filter results (lowercase)
100
- * @param minImportance - Optional minimum importance value (0-10)
101
- * @param maxImportance - Optional maximum importance value (0-10)
102
- * @param limit - Maximum number of results to return (default: 50, max: 200)
103
- * @returns Array of SearchResult objects sorted by relevance score (descending)
104
- *
105
- * @example
106
- * ```typescript
107
- * const manager = new SearchManager(storage, savedSearchesPath);
108
- *
109
- * // Basic ranked search
110
- * const results = await manager.searchNodesRanked('machine learning algorithms');
111
- * results.forEach(r => {
112
- * console.log(`${r.entity.name} (score: ${r.score})`);
113
- * });
114
- *
115
- * // Limit to top 10 most relevant results
116
- * const top10 = await manager.searchNodesRanked('database optimization', undefined, undefined, undefined, 10);
117
- *
118
- * // Ranked search with filters
119
- * const relevantImportant = await manager.searchNodesRanked(
120
- * 'security vulnerability',
121
- * ['security', 'critical'],
122
- * 8,
123
- * 10,
124
- * 20
125
- * );
126
- * ```
127
- */
128
- searchNodesRanked(query: string, tags?: string[], minImportance?: number, maxImportance?: number, limit?: number): Promise<SearchResult[]>;
129
- /**
130
- * Perform boolean search with AND, OR, NOT operators.
131
- *
132
- * Supports complex boolean logic for precise search queries.
133
- * Use AND/OR/NOT operators (case-insensitive) to combine search terms.
134
- * Parentheses are supported for grouping.
135
- *
136
- * @param query - Boolean query string (e.g., "alice AND bob", "frontend OR backend NOT legacy")
137
- * @param tags - Optional array of tags to filter results (lowercase)
138
- * @param minImportance - Optional minimum importance value (0-10)
139
- * @param maxImportance - Optional maximum importance value (0-10)
140
- * @returns KnowledgeGraph containing entities matching the boolean expression
141
- *
142
- * @example
143
- * ```typescript
144
- * const manager = new SearchManager(storage, savedSearchesPath);
145
- *
146
- * // AND operator - entities matching all terms
147
- * const both = await manager.booleanSearch('database AND performance');
148
- *
149
- * // OR operator - entities matching any term
150
- * const either = await manager.booleanSearch('frontend OR backend');
151
- *
152
- * // NOT operator - exclude terms
153
- * const excluding = await manager.booleanSearch('API NOT deprecated');
154
- *
155
- * // Complex queries with grouping
156
- * const complex = await manager.booleanSearch('(react OR vue) AND (component OR hook) NOT legacy');
157
- * ```
158
- */
159
- booleanSearch(query: string, tags?: string[], minImportance?: number, maxImportance?: number): Promise<KnowledgeGraph>;
160
- /**
161
- * Perform fuzzy search with typo tolerance.
162
- *
163
- * Uses Levenshtein distance to find entities that approximately match the query,
164
- * making it ideal for handling typos and variations in spelling.
165
- * Higher threshold values require closer matches.
166
- *
167
- * @param query - Search query (will match approximate spellings)
168
- * @param threshold - Similarity threshold from 0.0 (very lenient) to 1.0 (exact match). Default: 0.7
169
- * @param tags - Optional array of tags to filter results (lowercase)
170
- * @param minImportance - Optional minimum importance value (0-10)
171
- * @param maxImportance - Optional maximum importance value (0-10)
172
- * @returns KnowledgeGraph containing entities with similar names/observations
173
- *
174
- * @example
175
- * ```typescript
176
- * const manager = new SearchManager(storage, savedSearchesPath);
177
- *
178
- * // Find entities even with typos
179
- * const results = await manager.fuzzySearch('databse'); // Will match "database"
180
- *
181
- * // Adjust threshold for strictness
182
- * const strict = await manager.fuzzySearch('optmization', 0.9); // Requires very close match
183
- * const lenient = await manager.fuzzySearch('optmization', 0.6); // More tolerant of differences
184
- *
185
- * // Fuzzy search with filters
186
- * const filtered = await manager.fuzzySearch('secrity', 0.7, ['important'], 7, 10);
187
- * ```
188
- */
189
- fuzzySearch(query: string, threshold?: number, tags?: string[], minImportance?: number, maxImportance?: number): Promise<KnowledgeGraph>;
190
- /**
191
- * Get search suggestions for a query.
192
- *
193
- * @param query - Search query
194
- * @param maxSuggestions - Maximum suggestions to return
195
- * @returns Array of suggested terms
196
- */
197
- getSearchSuggestions(query: string, maxSuggestions?: number): Promise<string[]>;
198
- /**
199
- * Save a search query for later reuse.
200
- *
201
- * Saved searches store query parameters and can be re-executed later.
202
- * The system tracks usage count and last used timestamp automatically.
203
- *
204
- * @param search - Search parameters (name, query, and optional filters)
205
- * @returns Newly created SavedSearch object with metadata
206
- *
207
- * @example
208
- * ```typescript
209
- * const manager = new SearchManager(storage, savedSearchesPath);
210
- *
211
- * // Save a simple search
212
- * const saved = await manager.saveSearch({
213
- * name: 'High Priority Bugs',
214
- * query: 'bug',
215
- * tags: ['critical'],
216
- * minImportance: 8
217
- * });
218
- *
219
- * // Save a complex search
220
- * await manager.saveSearch({
221
- * name: 'Recent Frontend Work',
222
- * query: 'component OR hook',
223
- * tags: ['frontend', 'react'],
224
- * searchType: 'boolean'
225
- * });
226
- * ```
227
- */
228
- saveSearch(search: Omit<SavedSearch, 'createdAt' | 'useCount' | 'lastUsed'>): Promise<SavedSearch>;
229
- /**
230
- * List all saved searches.
231
- *
232
- * @returns Array of saved searches
233
- */
234
- listSavedSearches(): Promise<SavedSearch[]>;
235
- /**
236
- * Get a saved search by name.
237
- *
238
- * @param name - Search name
239
- * @returns Saved search or null
240
- */
241
- getSavedSearch(name: string): Promise<SavedSearch | null>;
242
- /**
243
- * Execute a saved search by name.
244
- *
245
- * Runs a previously saved search with its stored parameters.
246
- * Automatically updates the search's useCount and lastUsed timestamp.
247
- *
248
- * @param name - The unique name of the saved search to execute
249
- * @returns KnowledgeGraph containing the search results
250
- * @throws Error if saved search not found
251
- *
252
- * @example
253
- * ```typescript
254
- * const manager = new SearchManager(storage, savedSearchesPath);
255
- *
256
- * // Execute a saved search
257
- * const results = await manager.executeSavedSearch('High Priority Bugs');
258
- * console.log(`Found ${results.entities.length} high priority bugs`);
259
- *
260
- * // Handle missing saved search
261
- * try {
262
- * await manager.executeSavedSearch('NonExistent');
263
- * } catch (error) {
264
- * console.error('Search not found');
265
- * }
266
- * ```
267
- */
268
- executeSavedSearch(name: string): Promise<KnowledgeGraph>;
269
- /**
270
- * Delete a saved search.
271
- *
272
- * @param name - Search name
273
- * @returns True if deleted
274
- */
275
- deleteSavedSearch(name: string): Promise<boolean>;
276
- /**
277
- * Update a saved search.
278
- *
279
- * @param name - Search name
280
- * @param updates - Fields to update
281
- * @returns Updated saved search
282
- */
283
- updateSavedSearch(name: string, updates: Partial<Omit<SavedSearch, 'name' | 'createdAt' | 'useCount' | 'lastUsed'>>): Promise<SavedSearch>;
284
- }
285
- //# sourceMappingURL=SearchManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SearchManager.d.ts","sourceRoot":"","sources":["../../src/search/SearchManager.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAQ5D;;;;GAIG;AACH,qBAAa,aAAa;I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Manager
3
- *
4
- * Orchestrates all search types (basic, ranked, boolean, fuzzy).
5
- * Focused on search operations only (Phase 4: Consolidate God Objects).
6
- *
7
- * @module search/SearchManager
8
- */
9
- import { BasicSearch } from './BasicSearch.js';
10
- import { RankedSearch } from './RankedSearch.js';
11
- import { BooleanSearch } from './BooleanSearch.js';
12
- import { FuzzySearch } from './FuzzySearch.js';
13
- import { SearchSuggestions } from './SearchSuggestions.js';
14
- import { SavedSearchManager } from './SavedSearchManager.js';
15
- /**
16
- * Unified search manager providing access to all search types.
17
- *
18
- * Phase 4 Sprint 5: Manages search caches across all search types.
19
- */
20
- export class SearchManager {
21
- basicSearch;
22
- rankedSearch;
23
- booleanSearcher;
24
- fuzzySearcher;
25
- searchSuggestions;
26
- savedSearchManager;
27
- constructor(storage, savedSearchesFilePath) {
28
- this.basicSearch = new BasicSearch(storage);
29
- this.rankedSearch = new RankedSearch(storage);
30
- this.booleanSearcher = new BooleanSearch(storage);
31
- this.fuzzySearcher = new FuzzySearch(storage);
32
- this.searchSuggestions = new SearchSuggestions(storage);
33
- this.savedSearchManager = new SavedSearchManager(savedSearchesFilePath, this.basicSearch);
34
- }
35
- // ==================== Cache Management (Phase 4 Sprint 5) ====================
36
- /**
37
- * Phase 4 Sprint 5: Clear all search caches.
38
- *
39
- * Clears caches in all search types: fuzzy, boolean, and ranked token cache.
40
- * Call this when the graph has been modified to ensure fresh results.
41
- */
42
- clearAllCaches() {
43
- this.fuzzySearcher.clearCache();
44
- this.booleanSearcher.clearCache();
45
- this.rankedSearch.clearTokenCache();
46
- }
47
- /**
48
- * Phase 4 Sprint 5: Clear fuzzy search cache.
49
- */
50
- clearFuzzyCache() {
51
- this.fuzzySearcher.clearCache();
52
- }
53
- /**
54
- * Phase 4 Sprint 5: Clear boolean search cache.
55
- */
56
- clearBooleanCache() {
57
- this.booleanSearcher.clearCache();
58
- }
59
- /**
60
- * Phase 4 Sprint 5: Clear ranked search token cache.
61
- */
62
- clearRankedCache() {
63
- this.rankedSearch.clearTokenCache();
64
- }
65
- // ==================== Basic Search ====================
66
- /**
67
- * Perform a simple text-based search across entity names and observations.
68
- *
69
- * This is the primary search method that searches through entity names,
70
- * observations, and types using case-insensitive substring matching.
71
- * Optionally filter by tags and importance range.
72
- *
73
- * @param query - Text to search for (case-insensitive, searches names/observations/types)
74
- * @param tags - Optional array of tags to filter results (lowercase)
75
- * @param minImportance - Optional minimum importance value (0-10)
76
- * @param maxImportance - Optional maximum importance value (0-10)
77
- * @returns KnowledgeGraph containing matching entities and their relations
78
- *
79
- * @example
80
- * ```typescript
81
- * const manager = new SearchManager(storage, savedSearchesPath);
82
- *
83
- * // Simple text search
84
- * const results = await manager.searchNodes('Alice');
85
- *
86
- * // Search with tag filter
87
- * const engineeringResults = await manager.searchNodes('project', ['engineering']);
88
- *
89
- * // Search with importance range
90
- * const importantResults = await manager.searchNodes('critical', undefined, 8, 10);
91
- *
92
- * // Combined filters
93
- * const filtered = await manager.searchNodes('bug', ['backend'], 5, 10);
94
- * ```
95
- */
96
- async searchNodes(query, tags, minImportance, maxImportance) {
97
- return this.basicSearch.searchNodes(query, tags, minImportance, maxImportance);
98
- }
99
- /**
100
- * Open specific nodes by name.
101
- *
102
- * @param names - Array of entity names
103
- * @returns Knowledge graph with specified entities
104
- */
105
- async openNodes(names) {
106
- return this.basicSearch.openNodes(names);
107
- }
108
- /**
109
- * Search by date range.
110
- *
111
- * @param startDate - Optional start date (ISO 8601)
112
- * @param endDate - Optional end date (ISO 8601)
113
- * @param entityType - Optional entity type filter
114
- * @param tags - Optional tags filter
115
- * @returns Filtered knowledge graph
116
- */
117
- async searchByDateRange(startDate, endDate, entityType, tags) {
118
- return this.basicSearch.searchByDateRange(startDate, endDate, entityType, tags);
119
- }
120
- // ==================== Ranked Search ====================
121
- /**
122
- * Perform TF-IDF ranked search with relevance scoring.
123
- *
124
- * Uses Term Frequency-Inverse Document Frequency algorithm to rank results
125
- * by relevance to the query. Results are sorted by score (highest first).
126
- * This is ideal for finding the most relevant entities for a search query.
127
- *
128
- * @param query - Search query (analyzed for term frequency)
129
- * @param tags - Optional array of tags to filter results (lowercase)
130
- * @param minImportance - Optional minimum importance value (0-10)
131
- * @param maxImportance - Optional maximum importance value (0-10)
132
- * @param limit - Maximum number of results to return (default: 50, max: 200)
133
- * @returns Array of SearchResult objects sorted by relevance score (descending)
134
- *
135
- * @example
136
- * ```typescript
137
- * const manager = new SearchManager(storage, savedSearchesPath);
138
- *
139
- * // Basic ranked search
140
- * const results = await manager.searchNodesRanked('machine learning algorithms');
141
- * results.forEach(r => {
142
- * console.log(`${r.entity.name} (score: ${r.score})`);
143
- * });
144
- *
145
- * // Limit to top 10 most relevant results
146
- * const top10 = await manager.searchNodesRanked('database optimization', undefined, undefined, undefined, 10);
147
- *
148
- * // Ranked search with filters
149
- * const relevantImportant = await manager.searchNodesRanked(
150
- * 'security vulnerability',
151
- * ['security', 'critical'],
152
- * 8,
153
- * 10,
154
- * 20
155
- * );
156
- * ```
157
- */
158
- async searchNodesRanked(query, tags, minImportance, maxImportance, limit) {
159
- return this.rankedSearch.searchNodesRanked(query, tags, minImportance, maxImportance, limit);
160
- }
161
- // ==================== Boolean Search ====================
162
- /**
163
- * Perform boolean search with AND, OR, NOT operators.
164
- *
165
- * Supports complex boolean logic for precise search queries.
166
- * Use AND/OR/NOT operators (case-insensitive) to combine search terms.
167
- * Parentheses are supported for grouping.
168
- *
169
- * @param query - Boolean query string (e.g., "alice AND bob", "frontend OR backend NOT legacy")
170
- * @param tags - Optional array of tags to filter results (lowercase)
171
- * @param minImportance - Optional minimum importance value (0-10)
172
- * @param maxImportance - Optional maximum importance value (0-10)
173
- * @returns KnowledgeGraph containing entities matching the boolean expression
174
- *
175
- * @example
176
- * ```typescript
177
- * const manager = new SearchManager(storage, savedSearchesPath);
178
- *
179
- * // AND operator - entities matching all terms
180
- * const both = await manager.booleanSearch('database AND performance');
181
- *
182
- * // OR operator - entities matching any term
183
- * const either = await manager.booleanSearch('frontend OR backend');
184
- *
185
- * // NOT operator - exclude terms
186
- * const excluding = await manager.booleanSearch('API NOT deprecated');
187
- *
188
- * // Complex queries with grouping
189
- * const complex = await manager.booleanSearch('(react OR vue) AND (component OR hook) NOT legacy');
190
- * ```
191
- */
192
- async booleanSearch(query, tags, minImportance, maxImportance) {
193
- return this.booleanSearcher.booleanSearch(query, tags, minImportance, maxImportance);
194
- }
195
- // ==================== Fuzzy Search ====================
196
- /**
197
- * Perform fuzzy search with typo tolerance.
198
- *
199
- * Uses Levenshtein distance to find entities that approximately match the query,
200
- * making it ideal for handling typos and variations in spelling.
201
- * Higher threshold values require closer matches.
202
- *
203
- * @param query - Search query (will match approximate spellings)
204
- * @param threshold - Similarity threshold from 0.0 (very lenient) to 1.0 (exact match). Default: 0.7
205
- * @param tags - Optional array of tags to filter results (lowercase)
206
- * @param minImportance - Optional minimum importance value (0-10)
207
- * @param maxImportance - Optional maximum importance value (0-10)
208
- * @returns KnowledgeGraph containing entities with similar names/observations
209
- *
210
- * @example
211
- * ```typescript
212
- * const manager = new SearchManager(storage, savedSearchesPath);
213
- *
214
- * // Find entities even with typos
215
- * const results = await manager.fuzzySearch('databse'); // Will match "database"
216
- *
217
- * // Adjust threshold for strictness
218
- * const strict = await manager.fuzzySearch('optmization', 0.9); // Requires very close match
219
- * const lenient = await manager.fuzzySearch('optmization', 0.6); // More tolerant of differences
220
- *
221
- * // Fuzzy search with filters
222
- * const filtered = await manager.fuzzySearch('secrity', 0.7, ['important'], 7, 10);
223
- * ```
224
- */
225
- async fuzzySearch(query, threshold, tags, minImportance, maxImportance) {
226
- return this.fuzzySearcher.fuzzySearch(query, threshold, tags, minImportance, maxImportance);
227
- }
228
- // ==================== Search Suggestions ====================
229
- /**
230
- * Get search suggestions for a query.
231
- *
232
- * @param query - Search query
233
- * @param maxSuggestions - Maximum suggestions to return
234
- * @returns Array of suggested terms
235
- */
236
- async getSearchSuggestions(query, maxSuggestions) {
237
- return this.searchSuggestions.getSearchSuggestions(query, maxSuggestions);
238
- }
239
- // ==================== Saved Searches ====================
240
- /**
241
- * Save a search query for later reuse.
242
- *
243
- * Saved searches store query parameters and can be re-executed later.
244
- * The system tracks usage count and last used timestamp automatically.
245
- *
246
- * @param search - Search parameters (name, query, and optional filters)
247
- * @returns Newly created SavedSearch object with metadata
248
- *
249
- * @example
250
- * ```typescript
251
- * const manager = new SearchManager(storage, savedSearchesPath);
252
- *
253
- * // Save a simple search
254
- * const saved = await manager.saveSearch({
255
- * name: 'High Priority Bugs',
256
- * query: 'bug',
257
- * tags: ['critical'],
258
- * minImportance: 8
259
- * });
260
- *
261
- * // Save a complex search
262
- * await manager.saveSearch({
263
- * name: 'Recent Frontend Work',
264
- * query: 'component OR hook',
265
- * tags: ['frontend', 'react'],
266
- * searchType: 'boolean'
267
- * });
268
- * ```
269
- */
270
- async saveSearch(search) {
271
- return this.savedSearchManager.saveSearch(search);
272
- }
273
- /**
274
- * List all saved searches.
275
- *
276
- * @returns Array of saved searches
277
- */
278
- async listSavedSearches() {
279
- return this.savedSearchManager.listSavedSearches();
280
- }
281
- /**
282
- * Get a saved search by name.
283
- *
284
- * @param name - Search name
285
- * @returns Saved search or null
286
- */
287
- async getSavedSearch(name) {
288
- return this.savedSearchManager.getSavedSearch(name);
289
- }
290
- /**
291
- * Execute a saved search by name.
292
- *
293
- * Runs a previously saved search with its stored parameters.
294
- * Automatically updates the search's useCount and lastUsed timestamp.
295
- *
296
- * @param name - The unique name of the saved search to execute
297
- * @returns KnowledgeGraph containing the search results
298
- * @throws Error if saved search not found
299
- *
300
- * @example
301
- * ```typescript
302
- * const manager = new SearchManager(storage, savedSearchesPath);
303
- *
304
- * // Execute a saved search
305
- * const results = await manager.executeSavedSearch('High Priority Bugs');
306
- * console.log(`Found ${results.entities.length} high priority bugs`);
307
- *
308
- * // Handle missing saved search
309
- * try {
310
- * await manager.executeSavedSearch('NonExistent');
311
- * } catch (error) {
312
- * console.error('Search not found');
313
- * }
314
- * ```
315
- */
316
- async executeSavedSearch(name) {
317
- return this.savedSearchManager.executeSavedSearch(name);
318
- }
319
- /**
320
- * Delete a saved search.
321
- *
322
- * @param name - Search name
323
- * @returns True if deleted
324
- */
325
- async deleteSavedSearch(name) {
326
- return this.savedSearchManager.deleteSavedSearch(name);
327
- }
328
- /**
329
- * Update a saved search.
330
- *
331
- * @param name - Search name
332
- * @param updates - Fields to update
333
- * @returns Updated saved search
334
- */
335
- async updateSavedSearch(name, updates) {
336
- return this.savedSearchManager.updateSavedSearch(name, updates);
337
- }
338
- }
@@ -1,27 +0,0 @@
1
- /**
2
- * Search Suggestions
3
- *
4
- * Provides "did you mean?" suggestions using Levenshtein distance.
5
- *
6
- * @module search/SearchSuggestions
7
- */
8
- import type { GraphStorage } from '../core/GraphStorage.js';
9
- /**
10
- * Generates search suggestions based on entity names and types.
11
- */
12
- export declare class SearchSuggestions {
13
- private storage;
14
- constructor(storage: GraphStorage);
15
- /**
16
- * Get "did you mean?" suggestions for a query.
17
- *
18
- * Returns similar entity names and types that might be what the user intended.
19
- * Excludes exact matches (similarity < 1.0) and very dissimilar strings (similarity > 0.5).
20
- *
21
- * @param query - The search query
22
- * @param maxSuggestions - Maximum number of suggestions to return (default 5)
23
- * @returns Array of suggested entity/type names sorted by similarity
24
- */
25
- getSearchSuggestions(query: string, maxSuggestions?: number): Promise<string[]>;
26
- }
27
- //# sourceMappingURL=SearchSuggestions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SearchSuggestions.d.ts","sourceRoot":"","sources":["../../src/search/SearchSuggestions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAW5D;;GAEG;AACH,qBAAa,iBAAiB;IAChB,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,YAAY;IAEzC;;;;;;;;;OASG;IACG,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,GAAE,MAAU,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAoCzF"}