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