(tool: SearchableTool, namespace?: string)
| 562 | }; |
| 563 | |
| 564 | const matchesNamespace = (tool: SearchableTool, namespace?: string): boolean => { |
| 565 | if (!namespace || normalizeSearchText(namespace).length === 0) { |
| 566 | return true; |
| 567 | } |
| 568 | |
| 569 | const namespaceTokens = tokenizeSearchText(namespace); |
| 570 | if (namespaceTokens.length === 0) { |
| 571 | return true; |
| 572 | } |
| 573 | |
| 574 | const integrationTokens = tokenizeSearchText(tool.integration); |
| 575 | const pathTokens = tokenizeSearchText(tool.path); |
| 576 | |
| 577 | const isPrefixMatch = (tokens: readonly string[]): boolean => |
| 578 | namespaceTokens.every((token, index) => tokens[index] === token); |
| 579 | |
| 580 | return isPrefixMatch(integrationTokens) || isPrefixMatch(pathTokens); |
| 581 | }; |
| 582 | |
| 583 | const scoreToolMatch = (tool: SearchableTool, query: string): ToolDiscoveryResult | null => { |
| 584 | const normalizedQuery = normalizeSearchText(query); |
no test coverage detected