* Truncate output if it exceeds the maximum length
(text: string)
| 9151 | * Truncate output if it exceeds the maximum length |
| 9152 | */ |
| 9153 | private truncateOutput(text: string): string { |
| 9154 | if (text.length <= MAX_OUTPUT_LENGTH) return text; |
| 9155 | const truncated = text.slice(0, MAX_OUTPUT_LENGTH); |
| 9156 | const lastNewline = truncated.lastIndexOf('\n'); |
| 9157 | const cutPoint = lastNewline > MAX_OUTPUT_LENGTH * 0.8 ? lastNewline : MAX_OUTPUT_LENGTH; |
| 9158 | return truncated.slice(0, cutPoint) + '\n\n... (output truncated)'; |
| 9159 | } |
| 9160 | |
| 9161 | // ========================================================================= |
| 9162 | // Formatting helpers (compact by default to reduce context usage) |
no outgoing calls
no test coverage detected