(patterns: string[], allNames: string[])
| 135 | // NB: the real edit tool is `edit_text` (there is no `edit_file`). Protecting the phantom |
| 136 | // name left the actual editor gate-able by tool-profiling — a latent "can't edit" bug. |
| 137 | 'shell', 'read_file', 'write_file', 'edit_text', 'edit_symbol', 'multi_edit', 'ls', 'glob', 'grep', |
| 138 | ]); |
| 139 | export function expandToolPatterns(patterns: string[], allNames: string[]): string[] { |
| 140 | const out = new Set<string>(); |
| 141 | for (const raw of patterns) { |
| 142 | const p = raw.trim(); |
| 143 | if (!p) continue; |
| 144 | if (p.endsWith('*')) { |
| 145 | const prefix = p.slice(0, -1); |
| 146 | if (!prefix) continue; // bare "*" would block everything — refuse |
| 147 | for (const n of allNames) if (n.startsWith(prefix)) out.add(n); |
| 148 | } else if (allNames.includes(p)) { |
| 149 | out.add(p); |
| 150 | } |
| 151 | } |
| 152 | for (const core of NEVER_BLOCK) out.delete(core); |
| 153 | return [...out].sort(); |
| 154 | } |
| 155 |
no test coverage detected