@fractalizer/mcp-search 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 (83) hide show
  1. package/README.md +408 -0
  2. package/dist/constants.d.ts +12 -0
  3. package/dist/constants.d.ts.map +1 -0
  4. package/dist/constants.js +12 -0
  5. package/dist/constants.js.map +1 -0
  6. package/dist/engine/index.d.ts +5 -0
  7. package/dist/engine/index.d.ts.map +1 -0
  8. package/dist/engine/index.js +5 -0
  9. package/dist/engine/index.js.map +1 -0
  10. package/dist/engine/tool-search-engine.d.ts +70 -0
  11. package/dist/engine/tool-search-engine.d.ts.map +1 -0
  12. package/dist/engine/tool-search-engine.js +213 -0
  13. package/dist/engine/tool-search-engine.js.map +1 -0
  14. package/dist/index.d.ts +20 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +23 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/scoring/strategy-weights.d.ts +20 -0
  19. package/dist/scoring/strategy-weights.d.ts.map +1 -0
  20. package/dist/scoring/strategy-weights.js +51 -0
  21. package/dist/scoring/strategy-weights.js.map +1 -0
  22. package/dist/strategies/category-search.strategy.d.ts +30 -0
  23. package/dist/strategies/category-search.strategy.d.ts.map +1 -0
  24. package/dist/strategies/category-search.strategy.js +81 -0
  25. package/dist/strategies/category-search.strategy.js.map +1 -0
  26. package/dist/strategies/description-search.strategy.d.ts +38 -0
  27. package/dist/strategies/description-search.strategy.d.ts.map +1 -0
  28. package/dist/strategies/description-search.strategy.js +68 -0
  29. package/dist/strategies/description-search.strategy.js.map +1 -0
  30. package/dist/strategies/fuzzy-search.strategy.d.ts +65 -0
  31. package/dist/strategies/fuzzy-search.strategy.d.ts.map +1 -0
  32. package/dist/strategies/fuzzy-search.strategy.js +158 -0
  33. package/dist/strategies/fuzzy-search.strategy.js.map +1 -0
  34. package/dist/strategies/index.d.ts +12 -0
  35. package/dist/strategies/index.d.ts.map +1 -0
  36. package/dist/strategies/index.js +11 -0
  37. package/dist/strategies/index.js.map +1 -0
  38. package/dist/strategies/name-search.strategy.d.ts +35 -0
  39. package/dist/strategies/name-search.strategy.d.ts.map +1 -0
  40. package/dist/strategies/name-search.strategy.js +99 -0
  41. package/dist/strategies/name-search.strategy.js.map +1 -0
  42. package/dist/strategies/search-strategy.interface.d.ts +28 -0
  43. package/dist/strategies/search-strategy.interface.d.ts.map +1 -0
  44. package/dist/strategies/search-strategy.interface.js +12 -0
  45. package/dist/strategies/search-strategy.interface.js.map +1 -0
  46. package/dist/strategies/weighted-combined.strategy.d.ts +37 -0
  47. package/dist/strategies/weighted-combined.strategy.d.ts.map +1 -0
  48. package/dist/strategies/weighted-combined.strategy.js +90 -0
  49. package/dist/strategies/weighted-combined.strategy.js.map +1 -0
  50. package/dist/tools/index.d.ts +7 -0
  51. package/dist/tools/index.d.ts.map +1 -0
  52. package/dist/tools/index.js +7 -0
  53. package/dist/tools/index.js.map +1 -0
  54. package/dist/tools/search-tools.definition.d.ts +18 -0
  55. package/dist/tools/search-tools.definition.d.ts.map +1 -0
  56. package/dist/tools/search-tools.definition.js +93 -0
  57. package/dist/tools/search-tools.definition.js.map +1 -0
  58. package/dist/tools/search-tools.metadata.d.ts +12 -0
  59. package/dist/tools/search-tools.metadata.d.ts.map +1 -0
  60. package/dist/tools/search-tools.metadata.js +57 -0
  61. package/dist/tools/search-tools.metadata.js.map +1 -0
  62. package/dist/tools/search-tools.schema.d.ts +31 -0
  63. package/dist/tools/search-tools.schema.d.ts.map +1 -0
  64. package/dist/tools/search-tools.schema.js +60 -0
  65. package/dist/tools/search-tools.schema.js.map +1 -0
  66. package/dist/tools/search-tools.tool.d.ts +57 -0
  67. package/dist/tools/search-tools.tool.d.ts.map +1 -0
  68. package/dist/tools/search-tools.tool.js +141 -0
  69. package/dist/tools/search-tools.tool.js.map +1 -0
  70. package/dist/tsconfig.tsbuildinfo +1 -0
  71. package/dist/types.d.ts +112 -0
  72. package/dist/types.d.ts.map +1 -0
  73. package/dist/types.js +10 -0
  74. package/dist/types.js.map +1 -0
  75. package/dist/utils/build-index-from-registry.d.ts +28 -0
  76. package/dist/utils/build-index-from-registry.d.ts.map +1 -0
  77. package/dist/utils/build-index-from-registry.js +80 -0
  78. package/dist/utils/build-index-from-registry.js.map +1 -0
  79. package/dist/utils/text-utils.d.ts +48 -0
  80. package/dist/utils/text-utils.d.ts.map +1 -0
  81. package/dist/utils/text-utils.js +50 -0
  82. package/dist/utils/text-utils.js.map +1 -0
  83. package/package.json +79 -0
package/README.md ADDED
@@ -0,0 +1,408 @@
1
+ # @fractalizer/mcp-search
2
+
3
+ **Advanced Tool Search Engine with compile-time indexing and 5 search strategies**
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@fractalizer/mcp-search.svg)](https://www.npmjs.com/package/@fractalizer/mcp-search)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ---
9
+
10
+ ## 🎯 Purpose
11
+
12
+ **Principle:** Fast, intelligent tool discovery with compile-time indexing
13
+
14
+ **Key Features:**
15
+ - βœ… **Compile-time indexing** β€” zero runtime overhead for index generation
16
+ - βœ… **5 search strategies** β€” name, description, category, fuzzy, weighted-combined
17
+ - βœ… **LRU cache** β€” fast repeated searches
18
+ - βœ… **MCP tool included** β€” `search_tools` for Claude to discover tools
19
+
20
+ **Architecture rule:** Search depends ONLY on `@fractalizer/mcp-core`
21
+
22
+ ---
23
+
24
+ ## πŸ“¦ Installation
25
+
26
+ ```bash
27
+ npm install @fractalizer/mcp-search
28
+ ```
29
+
30
+ **Dependencies:**
31
+ - `@fractalizer/mcp-core` (BaseTool, utilities)
32
+ - `@fractalizer/mcp-infrastructure` (via core)
33
+ - `lru-cache` (caching)
34
+
35
+ ---
36
+
37
+ ## πŸ“ Structure
38
+
39
+ ```
40
+ src/
41
+ β”œβ”€β”€ engine/
42
+ β”‚ └── tool-search-engine.ts # Main search engine with LRU cache
43
+ β”œβ”€β”€ strategies/ # 5 search strategies
44
+ β”‚ β”œβ”€β”€ search-strategy.interface.ts
45
+ β”‚ β”œβ”€β”€ name-search.strategy.ts # Match by tool name
46
+ β”‚ β”œβ”€β”€ description-search.strategy.ts # Match in description
47
+ β”‚ β”œβ”€β”€ category-search.strategy.ts # Match by category
48
+ β”‚ β”œβ”€β”€ fuzzy-search.strategy.ts # Fuzzy matching
49
+ β”‚ └── weighted-combined.strategy.ts # Combine all strategies
50
+ β”œβ”€β”€ scoring/
51
+ β”‚ └── strategy-weights.ts # Configurable weights
52
+ β”œβ”€β”€ tools/ # MCP tool for search
53
+ β”‚ β”œβ”€β”€ search-tools.tool.ts
54
+ β”‚ β”œβ”€β”€ search-tools.metadata.ts # Metadata
55
+ β”‚ β”œβ”€β”€ search-tools.definition.ts
56
+ β”‚ └── search-tools.schema.ts
57
+ β”œβ”€β”€ utils/ # Utilities
58
+ β”‚ β”œβ”€β”€ build-index-from-registry.ts # Index builder
59
+ β”‚ └── text-utils.ts # Text processing
60
+ β”œβ”€β”€ constants.ts # Constants
61
+ β”œβ”€β”€ types.ts # Type definitions
62
+ └── index.ts # Public exports
63
+ ```
64
+
65
+ ---
66
+
67
+ ## πŸ”§ Core Components
68
+
69
+ ### ToolSearchEngine
70
+
71
+ **Main search engine** with LRU cache and strategy selection.
72
+
73
+ **Usage:**
74
+ ```typescript
75
+ import { ToolSearchEngine } from '@fractalizer/mcp-search';
76
+
77
+ // Create engine with tool metadata
78
+ const engine = new ToolSearchEngine(toolMetadataArray);
79
+
80
+ // Search with default strategy (weighted-combined)
81
+ const results = engine.search('find issues');
82
+
83
+ // Search with specific strategy
84
+ const nameResults = engine.search('get_issue', 'name');
85
+ const fuzzyResults = engine.search('isue', 'fuzzy');
86
+
87
+ console.log(results);
88
+ // [
89
+ // { tool: ToolMetadata, score: 0.95 },
90
+ // { tool: ToolMetadata, score: 0.78 },
91
+ // ...
92
+ // ]
93
+ ```
94
+
95
+ **Cache:**
96
+ - LRU cache with max 100 entries
97
+ - Cache key: `${query}_${strategy}`
98
+ - Automatic eviction of least recently used
99
+
100
+ ### Search Strategies
101
+
102
+ **5 strategies with different matching algorithms:**
103
+
104
+ #### 1. NameSearchStrategy
105
+ Matches query against tool name.
106
+
107
+ **Example:**
108
+ ```typescript
109
+ Query: "get_issue"
110
+ Matches: "get_issue" (exact), "get_issues" (partial)
111
+ ```
112
+
113
+ #### 2. DescriptionSearchStrategy
114
+ Matches query words in tool description.
115
+
116
+ **Example:**
117
+ ```typescript
118
+ Query: "retrieve task details"
119
+ Matches tools with descriptions containing "retrieve", "task", "details"
120
+ ```
121
+
122
+ #### 3. CategorySearchStrategy
123
+ Matches query against tool category.
124
+
125
+ **Example:**
126
+ ```typescript
127
+ Query: "api"
128
+ Matches all tools with category: "api"
129
+ ```
130
+
131
+ #### 4. FuzzySearchStrategy
132
+ Fuzzy matching using Levenshtein distance.
133
+
134
+ **Example:**
135
+ ```typescript
136
+ Query: "isue" (typo)
137
+ Matches: "issue" (distance: 1)
138
+ ```
139
+
140
+ #### 5. WeightedCombinedStrategy (Default)
141
+ Combines all strategies with configurable weights.
142
+
143
+ **Default weights:**
144
+ ```typescript
145
+ {
146
+ name: 0.4, // 40% - name match most important
147
+ description: 0.3, // 30% - description match
148
+ category: 0.2, // 20% - category match
149
+ fuzzy: 0.1, // 10% - fuzzy fallback
150
+ }
151
+ ```
152
+
153
+ **Usage:**
154
+ ```typescript
155
+ import { WeightedCombinedStrategy, STRATEGY_WEIGHTS } from '@fractalizer/mcp-search';
156
+
157
+ // Custom weights
158
+ const customWeights = {
159
+ ...STRATEGY_WEIGHTS,
160
+ fuzzy: 0.2, // Increase fuzzy matching importance
161
+ };
162
+
163
+ const strategy = new WeightedCombinedStrategy(customWeights);
164
+ ```
165
+
166
+ ---
167
+
168
+ ## πŸ› οΈ Compile-time Indexing
169
+
170
+ **Automatic index generation at build time:**
171
+
172
+ 1. **prebuild script** (in package.json):
173
+ ```json
174
+ {
175
+ "scripts": {
176
+ "prebuild": "tsx scripts/generate-tool-index.ts"
177
+ }
178
+ }
179
+ ```
180
+
181
+ 2. **Script scans** `TOOL_CLASSES` and extracts `METADATA`:
182
+ ```typescript
183
+ // scripts/generate-tool-index.ts
184
+ const TOOL_CLASSES = [
185
+ GetIssueTool,
186
+ FindIssuesTool,
187
+ // ...
188
+ ];
189
+
190
+ // Generates: src/generated-index.ts
191
+ export const TOOL_INDEX = [
192
+ { name: 'get_issue', category: 'api', description: '...' },
193
+ { name: 'find_issues', category: 'api', description: '...' },
194
+ ];
195
+ ```
196
+
197
+ 3. **Search engine** uses pre-generated index (no runtime reflection):
198
+ ```typescript
199
+ import { TOOL_INDEX } from './generated-index.js';
200
+
201
+ const engine = new ToolSearchEngine(TOOL_INDEX);
202
+ ```
203
+
204
+ **Benefits:**
205
+ - ⚑ Zero runtime overhead for index generation
206
+ - πŸ”’ Type-safe (compile-time validation)
207
+ - πŸ“¦ Smaller bundle (no reflection code)
208
+
209
+ ---
210
+
211
+ ## πŸ” MCP Tool: search_tools
212
+
213
+ **Included MCP tool** for Claude to discover available tools.
214
+
215
+ **Tool name:** `search_tools`
216
+
217
+ **Usage in Claude:**
218
+ ```
219
+ User: "What tools are available for working with issues?"
220
+ Claude uses: search_tools { query: "issues" }
221
+ ```
222
+
223
+ **Parameters:**
224
+ ```typescript
225
+ {
226
+ query: string; // Search query
227
+ strategy?: string; // Optional: 'name' | 'description' | 'category' | 'fuzzy' | 'weighted'
228
+ limit?: number; // Optional: max results (default: 10)
229
+ }
230
+ ```
231
+
232
+ **Example response:**
233
+ ```json
234
+ {
235
+ "results": [
236
+ {
237
+ "name": "get_issue",
238
+ "category": "api",
239
+ "description": "Retrieve issue details by key",
240
+ "score": 0.95
241
+ },
242
+ {
243
+ "name": "find_issues",
244
+ "category": "api",
245
+ "description": "Search issues using JQL query",
246
+ "score": 0.82
247
+ }
248
+ ]
249
+ }
250
+ ```
251
+
252
+ ---
253
+
254
+ ## 🚨 Critical Rules
255
+
256
+ ### 1. Always regenerate index after adding tools
257
+
258
+ ```bash
259
+ # Index is regenerated automatically on build
260
+ npm run build
261
+
262
+ # Or manually:
263
+ npm run prebuild
264
+ ```
265
+
266
+ ### 2. METADATA is required for all tools
267
+
268
+ ```typescript
269
+ // βœ… CORRECT
270
+ class MyTool extends BaseTool<TFacade> {
271
+ static readonly METADATA: StaticToolMetadata = {
272
+ name: 'my_tool',
273
+ category: 'api',
274
+ description: 'Tool description',
275
+ };
276
+ }
277
+
278
+ // ❌ WRONG (no METADATA)
279
+ class MyTool extends BaseTool<TFacade> {
280
+ // Search won't find this tool
281
+ }
282
+ ```
283
+
284
+ ### 3. Use WeightedCombinedStrategy for best results
285
+
286
+ ```typescript
287
+ // βœ… CORRECT (default, best accuracy)
288
+ const results = engine.search('find tasks');
289
+
290
+ // ⚠️ OK (specific strategy for special cases)
291
+ const exactMatch = engine.search('get_issue', 'name');
292
+ ```
293
+
294
+ ---
295
+
296
+ ## πŸ“– API Reference
297
+
298
+ ### Exports
299
+
300
+ ```typescript
301
+ // Engine
302
+ export { ToolSearchEngine } from './engine/tool-search-engine.js';
303
+
304
+ // Strategies
305
+ export type { SearchStrategy } from './strategies/search-strategy.interface.js';
306
+ export { NameSearchStrategy } from './strategies/name-search.strategy.js';
307
+ export { DescriptionSearchStrategy } from './strategies/description-search.strategy.js';
308
+ export { CategorySearchStrategy } from './strategies/category-search.strategy.js';
309
+ export { FuzzySearchStrategy } from './strategies/fuzzy-search.strategy.js';
310
+ export { WeightedCombinedStrategy } from './strategies/weighted-combined.strategy.js';
311
+
312
+ // Scoring
313
+ export { STRATEGY_WEIGHTS } from './scoring/strategy-weights.js';
314
+
315
+ // Tools
316
+ export { SearchToolsTool } from './tools/search-tools.tool.js';
317
+ export { SearchToolsDefinition } from './tools/search-tools.definition.js';
318
+
319
+ // Generated index
320
+ export { TOOL_INDEX } from './generated-index.js';
321
+
322
+ // Types
323
+ export type { ToolMetadata, SearchResult, StrategyWeights } from './types.js';
324
+ ```
325
+
326
+ ---
327
+
328
+ ## πŸ§ͺ Testing
329
+
330
+ **Run tests:**
331
+ ```bash
332
+ cd packages/framework/search
333
+ npm run test
334
+ ```
335
+
336
+ **With coverage:**
337
+ ```bash
338
+ npm run test:coverage
339
+ ```
340
+
341
+ **Watch mode:**
342
+ ```bash
343
+ npm run test:watch
344
+ ```
345
+
346
+ ---
347
+
348
+ ## 🎯 Advanced Usage
349
+
350
+ ### Custom Search Strategy
351
+
352
+ ```typescript
353
+ import { SearchStrategy, ToolMetadata } from '@fractalizer/mcp-search';
354
+
355
+ class CustomSearchStrategy implements SearchStrategy {
356
+ search(query: string, tools: ToolMetadata[]) {
357
+ return tools
358
+ .filter((tool) => /* custom logic */)
359
+ .map((tool) => ({
360
+ tool,
361
+ score: /* custom scoring */,
362
+ }));
363
+ }
364
+ }
365
+
366
+ // Use custom strategy
367
+ const engine = new ToolSearchEngine(TOOL_INDEX);
368
+ engine.registerStrategy('custom', new CustomSearchStrategy());
369
+ const results = engine.search('query', 'custom');
370
+ ```
371
+
372
+ ### Adjusting Weights
373
+
374
+ ```typescript
375
+ import { STRATEGY_WEIGHTS } from '@fractalizer/mcp-search';
376
+
377
+ const customWeights = {
378
+ ...STRATEGY_WEIGHTS,
379
+ name: 0.5, // Increase name importance
380
+ description: 0.3,
381
+ category: 0.1,
382
+ fuzzy: 0.1,
383
+ };
384
+
385
+ const strategy = new WeightedCombinedStrategy(customWeights);
386
+ ```
387
+
388
+ ---
389
+
390
+ ## 🀝 Contributing
391
+
392
+ See [../../.github/CONTRIBUTING.md](../../.github/CONTRIBUTING.md)
393
+
394
+ **Architecture rules:** [../../CLAUDE.md](../../CLAUDE.md)
395
+
396
+ ---
397
+
398
+ ## πŸ“„ License
399
+
400
+ MIT License
401
+
402
+ ---
403
+
404
+ ## πŸ”— Links
405
+
406
+ - **Monorepo root:** [../../README.md](../../README.md)
407
+ - **Architecture:** [../../ARCHITECTURE.md](../../ARCHITECTURE.md)
408
+ - **Core package:** [../core/README.md](../core/README.md)
@@ -0,0 +1,12 @@
1
+ /**
2
+ * ΠšΠΎΠ½ΡΡ‚Π°Π½Ρ‚Ρ‹ для систСмы поиска tools
3
+ */
4
+ /**
5
+ * Π”Π΅Ρ„ΠΎΠ»Ρ‚Π½ΠΎΠ΅ количСство Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚ΠΎΠ² поиска
6
+ */
7
+ export declare const DEFAULT_TOOL_SEARCH_LIMIT: 10;
8
+ /**
9
+ * Π”Π΅Ρ„ΠΎΠ»Ρ‚Π½Ρ‹ΠΉ ΡƒΡ€ΠΎΠ²Π΅Π½ΡŒ Π΄Π΅Ρ‚Π°Π»ΠΈΠ·Π°Ρ†ΠΈΠΈ Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚ΠΎΠ²
10
+ */
11
+ export declare const DEFAULT_TOOL_SEARCH_DETAIL_LEVEL: "name_and_description";
12
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAG,EAAW,CAAC;AAErD;;GAEG;AACH,eAAO,MAAM,gCAAgC,EAAG,sBAA+B,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * ΠšΠΎΠ½ΡΡ‚Π°Π½Ρ‚Ρ‹ для систСмы поиска tools
3
+ */
4
+ /**
5
+ * Π”Π΅Ρ„ΠΎΠ»Ρ‚Π½ΠΎΠ΅ количСство Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚ΠΎΠ² поиска
6
+ */
7
+ export const DEFAULT_TOOL_SEARCH_LIMIT = 10;
8
+ /**
9
+ * Π”Π΅Ρ„ΠΎΠ»Ρ‚Π½Ρ‹ΠΉ ΡƒΡ€ΠΎΠ²Π΅Π½ΡŒ Π΄Π΅Ρ‚Π°Π»ΠΈΠ·Π°Ρ†ΠΈΠΈ Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚ΠΎΠ²
10
+ */
11
+ export const DEFAULT_TOOL_SEARCH_DETAIL_LEVEL = 'name_and_description';
12
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAW,CAAC;AAErD;;GAEG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,sBAA+B,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Engine module exports
3
+ */
4
+ export { ToolSearchEngine } from './tool-search-engine.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Engine module exports
3
+ */
4
+ export { ToolSearchEngine } from './tool-search-engine.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Π“Π»Π°Π²Π½Ρ‹ΠΉ класс поисковой систСмы tools
3
+ *
4
+ * Responsibilities:
5
+ * - Π’Ρ‹ΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ поиска Ρ‡Π΅Ρ€Π΅Π· стратСгии
6
+ * - Π€ΠΈΠ»ΡŒΡ‚Ρ€Π°Ρ†ΠΈΡ ΠΏΠΎ катСгориям ΠΈ Ρ‚ΠΈΠΏΠ°ΠΌ
7
+ * - ΠšΠ΅ΡˆΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚ΠΎΠ²
8
+ * - Π€ΠΎΡ€ΠΌΠ°Ρ‚ΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚ΠΎΠ² ΠΏΠΎ ΡƒΡ€ΠΎΠ²Π½ΡŽ Π΄Π΅Ρ‚Π°Π»ΠΈΠ·Π°Ρ†ΠΈΠΈ
9
+ * - Lazy loading ΠΏΠΎΠ»Π½Ρ‹Ρ… ΠΌΠ΅Ρ‚Π°Π΄Π°Π½Π½Ρ‹Ρ…
10
+ */
11
+ import type { ISearchStrategy } from '../strategies/search-strategy.interface.js';
12
+ import type { SearchParams, SearchResponse, StaticToolIndex } from '../types.js';
13
+ import type { ToolRegistry } from '@fractalizer/mcp-core';
14
+ /**
15
+ * ΠŸΠΎΠΈΡΠΊΠΎΠ²Ρ‹ΠΉ Π΄Π²ΠΈΠΆΠΎΠΊ для tools
16
+ */
17
+ export declare class ToolSearchEngine {
18
+ private readonly staticIndex;
19
+ private readonly toolRegistry;
20
+ private searchStrategy;
21
+ private cache;
22
+ private lazyIndex;
23
+ /**
24
+ * ΠœΠ°ΠΊΡΠΈΠΌΠ°Π»ΡŒΠ½Ρ‹ΠΉ Ρ€Π°Π·ΠΌΠ΅Ρ€ кСша (LRU)
25
+ */
26
+ private readonly MAX_CACHE_SIZE;
27
+ constructor(staticIndex: readonly StaticToolIndex[] | null, toolRegistry: ToolRegistry, searchStrategy: ISearchStrategy);
28
+ /**
29
+ * ΠŸΠΎΠ»ΡƒΡ‡ΠΈΡ‚ΡŒ индСкс (статичСский ΠΈΠ»ΠΈ динамичСский ΠΈΠ· ToolRegistry)
30
+ */
31
+ private getIndex;
32
+ /**
33
+ * ΠŸΠΎΡΡ‚Ρ€ΠΎΠΈΡ‚ΡŒ индСкс ΠΈΠ· ToolRegistry
34
+ */
35
+ private buildIndexFromRegistry;
36
+ /**
37
+ * Π’Ρ‹ΠΏΠΎΠ»Π½ΠΈΡ‚ΡŒ поиск с ΠΊΠ΅ΡˆΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ΠΌ
38
+ */
39
+ search(params: SearchParams): SearchResponse;
40
+ /**
41
+ * Π’Ρ‹ΠΏΠΎΠ»Π½ΠΈΡ‚ΡŒ поиск Π±Π΅Π· ΠΊΠ΅ΡˆΠΈΡ€ΠΎΠ²Π°Π½ΠΈΡ
42
+ */
43
+ private performSearch;
44
+ /**
45
+ * Π€ΠΈΠ»ΡŒΡ‚Ρ€ΠΎΠ²Π°Ρ‚ΡŒ индСкс ΠΏΠΎ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Π°ΠΌ
46
+ */
47
+ private filterIndex;
48
+ /**
49
+ * Π€ΠΎΡ€ΠΌΠ°Ρ‚ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚Ρ‹ ΠΏΠΎ ΡƒΡ€ΠΎΠ²Π½ΡŽ Π΄Π΅Ρ‚Π°Π»ΠΈΠ·Π°Ρ†ΠΈΠΈ
50
+ */
51
+ private formatResults;
52
+ /**
53
+ * Π“Π΅Π½Π΅Ρ€ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ ΠΊΠ»ΡŽΡ‡ кСша ΠΈΠ· ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠ² поиска
54
+ */
55
+ private getCacheKey;
56
+ /**
57
+ * ΠžΡ‡ΠΈΡΡ‚ΠΈΡ‚ΡŒ кСш
58
+ *
59
+ * ПолСзно для тСстов ΠΈ ΠΏΡ€ΠΈ ΠΎΠ±Π½ΠΎΠ²Π»Π΅Π½ΠΈΠΈ индСкса
60
+ */
61
+ clearCache(): void;
62
+ /**
63
+ * ΠŸΠΎΠ»ΡƒΡ‡ΠΈΡ‚ΡŒ статистику кСша
64
+ */
65
+ getCacheStats(): {
66
+ size: number;
67
+ maxSize: number;
68
+ };
69
+ }
70
+ //# sourceMappingURL=tool-search-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-search-engine.d.ts","sourceRoot":"","sources":["../../src/engine/tool-search-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EAEd,eAAe,EAGhB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAI1D;;GAEG;AACH,qBAAa,gBAAgB;IAWzB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAX/B,OAAO,CAAC,cAAc,CAAkB;IACxC,OAAO,CAAC,KAAK,CAA8B;IAC3C,OAAO,CAAC,SAAS,CAAkC;IAEnD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAO;gBAGnB,WAAW,EAAE,SAAS,eAAe,EAAE,GAAG,IAAI,EAC9C,YAAY,EAAE,YAAY,EAC3C,cAAc,EAAE,eAAe;IAMjC;;OAEG;IACH,OAAO,CAAC,QAAQ;IAchB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IA+B9B;;OAEG;IACH,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,cAAc;IA2B5C;;OAEG;IACH,OAAO,CAAC,aAAa;IAiCrB;;OAEG;IACH,OAAO,CAAC,WAAW;IAgBnB;;OAEG;IACH,OAAO,CAAC,aAAa;IA6CrB;;OAEG;IACH,OAAO,CAAC,WAAW;IAUnB;;;;OAIG;IACH,UAAU,IAAI,IAAI;IAIlB;;OAEG;IACH,aAAa,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;CAMnD"}