* Truncate output if it exceeds the maximum length
(text: string)
| 6902 | * Truncate output if it exceeds the maximum length |
| 6903 | */ |
| 6904 | private truncateOutput(text: string): string { |
| 6905 | if (text.length <= MAX_OUTPUT_LENGTH) return text; |
| 6906 | const truncated = text.slice(0, MAX_OUTPUT_LENGTH); |
| 6907 | const lastNewline = truncated.lastIndexOf('\n'); |
| 6908 | const cutPoint = lastNewline > MAX_OUTPUT_LENGTH * 0.8 ? lastNewline : MAX_OUTPUT_LENGTH; |
| 6909 | return truncated.slice(0, cutPoint) + '\n\n... (output truncated)'; |
| 6910 | } |
| 6911 | |
| 6912 | // ========================================================================= |
| 6913 | // Formatting helpers (compact by default to reduce context usage) |
no outgoing calls
no test coverage detected