PHP port of charmbracelet/sequin β an ANSI escape-sequence inspector. Pipe styled output through it and each escape becomes a labelled line.
composer require sugarcraft/sugar-spark$ printf '\e[31mhello\e[0m world\n' | sugarspark
ESC[31m SGR foreground red
hello
ESC[0m SGR reset
world$ printf '\e]0;new title\e\\' | sugarspark
ESC]0;new title set window title to "new title"$ printf '\e[?2026h' | sugarspark
ESC[?2026h enable synchronized outputuse SugarCraft\Spark\Inspector;
foreach (Inspector::parse("\e[1;31mboom\e[0m") as $segment) {
echo $segment->describe(), "\n";
}
// One-shot report:
echo Inspector::report($capturedTerminalOutput);- SGR β foreground / background (16, 256, 24-bit truecolor) + bold / italic / underline / blink / reverse / strikethrough / faint.
- CSI β cursor moves, erase, scroll region (DECSTBM), scroll up/down, insert/delete line/char, tab forward/backward, DECSCUSR cursor shape, DECRQM mode query, DECRPM mode reply, request cursor position, XTVERSION query, kitty keyboard query/push/pop.
- CSI ~ keys β Home / End / Delete / PgUp / PgDn / F1-F12 / bracketed paste markers.
- DEC private modes β cursor visibility, mouse modes (1000/1002/1003/ 1006/1015), focus reporting (1004), alt screen (47/1047/1049), bracketed paste (2004), synchronized output (2026), unicode grapheme mode (2027).
- OSC β title (0/2), icon (1), palette (4), cwd (7), hyperlink (8), iTerm2 (9), taskbar progress (9;4), terminal colour set (10/11/12), clipboard (52), reset terminal colour (110/111/112).
- DCS β XTVERSION reply (
>|<term> <ver>), DECRPSS, sixel. - APC β CandyZone markers (
candyzone:S/E:<id>), kitty graphics (Gβ¦). - SS3 β F1-F4 / cursor / Home / End.
- 2-byte ESC β DECSC / DECRC / keypad mode / index / reverse-index / reset.
Anything unrecognised falls back to a generic CSI/OSC/... descriptor β
nothing is silently swallowed.
cd sugar-spark && composer install && vendor/bin/phpunit