Skip to content

The one and only agent harness for complex codebases. Project memory, planning, execution, and verified completion inside Codex.

499 B
Raw Blame
const ESC = String.fromCharCode(0x1b)
const CSI = String.fromCharCode(0x9b)

// Matches CSI/escape sequences (colors, cursor moves) without embedding raw
// control characters in the regex source.
const ANSI_PATTERN = new RegExp(
	`[${ESC}${CSI}][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]`,
	"g",
)

export function stripAnsi(input: string): string {
	return input.replace(ANSI_PATTERN, "")
}

export function hasAnsi(input: string): boolean {
	return stripAnsi(input) !== input
}