* Truncate output if it exceeds the maximum length
(text: string)
| 9468 | * Truncate output if it exceeds the maximum length |
| 9469 | */ |
| 9470 | private truncateOutput(text: string): string { |
| 9471 | if (text.length <= MAX_OUTPUT_LENGTH) return text; |
| 9472 | const truncated = text.slice(0, MAX_OUTPUT_LENGTH); |
| 9473 | const lastNewline = truncated.lastIndexOf('\n'); |
| 9474 | const cutPoint = lastNewline > MAX_OUTPUT_LENGTH * 0.8 ? lastNewline : MAX_OUTPUT_LENGTH; |
| 9475 | return truncated.slice(0, cutPoint) + '\n\n... (output truncated)'; |
| 9476 | } |
| 9477 | |
| 9478 | // ========================================================================= |
| 9479 | // Formatting helpers (compact by default to reduce context usage) |
no outgoing calls
no test coverage detected