MCPcopy Create free account
hub / github.com/Noumena-Network/code / looksLikeFilenameDiscoveryPattern

Function looksLikeFilenameDiscoveryPattern

src/tools/GrepTool/GrepTool.ts:112–129  ·  view source on GitHub ↗
(pattern: string)

Source from the content-addressed store, hash-verified

110 'Use Glob for file or directory name discovery. Grep is for searching file contents.'
111
112function looksLikeFilenameDiscoveryPattern(pattern: string): boolean {
113 const normalized = pattern
114 .trim()
115 .replaceAll('\\.', '.')
116 .replaceAll('\\/', '/')
117 if (!normalized || /\s/.test(normalized)) {
118 return false
119 }
120
121 // Examples we want to catch:
122 // - package\.json
123 // - cli\.ts|index\.ts|main\.ts
124 // - \\.test\\.(t|j)sx?$
125 // These are filename/path lookups, not file-content searches.
126 return /^[./A-Za-z0-9_-]+(?:\|[./A-Za-z0-9_-]+)*\.(?:[A-Za-z0-9_?+*()[\]{}$|-]+)$/.test(
127 normalized,
128 )
129}
130
131function applyHeadLimit<T>(
132 items: T[],

Callers 1

validateInputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected