(tool: SearchableTool, namespace?: string)
| 583 | }; |
| 584 | |
| 585 | const matchesNamespace = (tool: SearchableTool, namespace?: string): boolean => { |
| 586 | if (!namespace || normalizeSearchText(namespace).length === 0) { |
| 587 | return true; |
| 588 | } |
| 589 | |
| 590 | const namespaceTokens = tokenizeSearchText(namespace); |
| 591 | if (namespaceTokens.length === 0) { |
| 592 | return true; |
| 593 | } |
| 594 | |
| 595 | const integrationTokens = tokenizeSearchText(tool.integration); |
| 596 | const pathTokens = tokenizeSearchText(tool.path); |
| 597 | |
| 598 | const isPrefixMatch = (tokens: readonly string[]): boolean => |
| 599 | namespaceTokens.every((token, index) => tokens[index] === token); |
| 600 | |
| 601 | return isPrefixMatch(integrationTokens) || isPrefixMatch(pathTokens); |
| 602 | }; |
| 603 | |
| 604 | const scoreToolMatch = (tool: SearchableTool, query: string): ToolDiscoveryResult | null => { |
| 605 | const normalizedQuery = normalizeSearchText(query); |
no test coverage detected