MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / sanitizeShellOutput

Function sanitizeShellOutput

apps/kimi-code/src/tui/utils/shell-output.ts:31–43  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

29 * C0 control characters, so rendering can never crash the TUI.
30 */
31export function sanitizeShellOutput(text: string): string {
32 if (typeof text !== 'string') return '';
33 if (text.length === 0) return text;
34 try {
35 return text
36 .replace(OSC_PATTERN, '')
37 .replace(CSI_PATTERN, '')
38 .replace(ESC_SINGLE_PATTERN, '')
39 .replace(C0_CONTROL_PATTERN, '');
40 } catch {
41 return text.replace(C0_CONTROL_PATTERN, '');
42 }
43}
44
45/**
46 * Format captured stdout/stderr for the transcript. Sanitizes both streams and

Callers 3

renderTextMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected