MCPcopy
hub / github.com/codeaashu/claude-code / compileTermPatterns

Function compileTermPatterns

src/tools/ToolSearchTool/ToolSearchTool.ts:167–175  ·  view source on GitHub ↗

* Pre-compile word-boundary regexes for all search terms. * Called once per search instead of tools×terms×2 times.

(terms: string[])

Source from the content-addressed store, hash-verified

165 * Called once per search instead of tools×terms×2 times.
166 */
167function compileTermPatterns(terms: string[]): Map<string, RegExp> {
168 const patterns = new Map<string, RegExp>()
169 for (const term of terms) {
170 if (!patterns.has(term)) {
171 patterns.set(term, new RegExp(`\\b${escapeRegExp(term)}\\b`))
172 }
173 }
174 return patterns
175}
176
177/**
178 * Keyword-based search over tool names and descriptions.

Callers 1

searchToolsWithKeywordsFunction · 0.85

Calls 3

escapeRegExpFunction · 0.85
hasMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected