* Generate a summary text for tool counts.
(counts: ToolCounts)
| 71 | * Generate a summary text for tool counts. |
| 72 | */ |
| 73 | function getToolSummaryText(counts: ToolCounts): string | undefined { |
| 74 | const parts: string[] = [] |
| 75 | |
| 76 | // Use similar phrasing to collapseReadSearch.ts |
| 77 | if (counts.searches > 0) { |
| 78 | parts.push( |
| 79 | `searched ${counts.searches} ${counts.searches === 1 ? 'pattern' : 'patterns'}`, |
| 80 | ) |
| 81 | } |
| 82 | if (counts.reads > 0) { |
| 83 | parts.push(`read ${counts.reads} ${counts.reads === 1 ? 'file' : 'files'}`) |
| 84 | } |
| 85 | if (counts.writes > 0) { |
| 86 | parts.push( |
| 87 | `wrote ${counts.writes} ${counts.writes === 1 ? 'file' : 'files'}`, |
| 88 | ) |
| 89 | } |
| 90 | if (counts.commands > 0) { |
| 91 | parts.push( |
| 92 | `ran ${counts.commands} ${counts.commands === 1 ? 'command' : 'commands'}`, |
| 93 | ) |
| 94 | } |
| 95 | if (counts.other > 0) { |
| 96 | parts.push(`${counts.other} other ${counts.other === 1 ? 'tool' : 'tools'}`) |
| 97 | } |
| 98 | |
| 99 | if (parts.length === 0) { |
| 100 | return undefined |
| 101 | } |
| 102 | |
| 103 | return capitalize(parts.join(', ')) |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Count tool uses in an assistant message and add to existing counts. |
no test coverage detected