| 36 | |
| 37 | /** Format raw search matches into the familiar concise model output. */ |
| 38 | export const toModelOutput = (output: ModelOutput) => { |
| 39 | const lines = output.length === 0 ? ["No files found"] : [`Found ${output.length} matches`] |
| 40 | let current = "" |
| 41 | for (const match of output) { |
| 42 | if (current !== match.entry.path) { |
| 43 | if (current) lines.push("") |
| 44 | current = match.entry.path |
| 45 | lines.push(`${match.entry.path}:`) |
| 46 | } |
| 47 | lines.push(` Line ${match.line}: ${match.text}`) |
| 48 | } |
| 49 | return lines.join("\n") |
| 50 | } |
| 51 | |
| 52 | /** Grep leaf that defaults its filesystem root to the active Location. */ |
| 53 | const layer = Layer.effectDiscard( |