MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / withOpenCodeToolNames

Function withOpenCodeToolNames

src/mcp/opencode-tool-names.ts:39–47  ·  view source on GitHub ↗
(text: string, toolNames: readonly string[])

Source from the content-addressed store, hash-verified

37 * `codegraph explore` command never match.
38 */
39export function withOpenCodeToolNames(text: string, toolNames: readonly string[]): string {
40 if (toolNames.length === 0) return text;
41 const alternatives = [...toolNames]
42 .sort((a, b) => b.length - a.length)
43 .map((name) => name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
44 .join('|');
45 const wholeName = new RegExp(`(?<![A-Za-z0-9_])(?:${alternatives})(?![A-Za-z0-9_])`, 'g');
46 return text.replace(wholeName, (name) => openCodeToolName(name));
47}

Callers 4

renameFunction · 0.90
openCodeInstructionsFunction · 0.90

Calls 3

openCodeToolNameFunction · 0.85
mapMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected