| 110 | 'Use Glob for file or directory name discovery. Grep is for searching file contents.' |
| 111 | |
| 112 | function 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 | |
| 131 | function applyHeadLimit<T>( |
| 132 | items: T[], |