* Row count for list-shaped json results (Grep `matches`, Glob `files`). * Returns a count only when the keyed field is genuinely an array; an * error-shaped result (e.g. `{ error: "..." }`) returns undefined so the * caller falls back to a generic first-line summary rather than reporting a * fa
(entry: MakaPiToolEntry, key: string)
| 336 | * fabricated "N matches" / "N files" from an unrelated line count. |
| 337 | */ |
| 338 | function jsonArrayCount(entry: MakaPiToolEntry, key: string): number | undefined { |
| 339 | const result = entry.result; |
| 340 | if (result?.kind === 'json' && result.value !== null && typeof result.value === 'object') { |
| 341 | const rows = (result.value as Record<string, unknown>)[key]; |
| 342 | if (Array.isArray(rows)) return rows.length; |
| 343 | } |
| 344 | return undefined; |
| 345 | } |
| 346 | |
| 347 | function renderToolText(text: string, width: number): string[] { |
| 348 | return renderIndented(limitText(text, 12_000), width, 2); |
no outgoing calls
no test coverage detected