Documentation
¶
Overview ¶
Package termsafe is the one rule for showing untrusted text on a terminal: model output, tool results, workspace files and names, provider metadata and hook output. A terminal acts on control bytes (ESC sequences can move the cursor, erase or rewrite lines, set the window title or write the clipboard), and bidi controls can reorder what a person reads, so text from outside celeste never reaches the screen with those runes live.
Sanitize untrusted text before styling it: celeste's own lipgloss and glamour styling is added afterwards and is never touched.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Line ¶
Line returns s, or s Go-quoted when showing it could act on or hide text on a terminal: invalid UTF-8 (it decodes as a printable U+FFFD), a rune UnsafeRune rejects (newlines and tabs included), or any other non-printable rune. It is for one-line fields a person must read exactly: an approval prompt's command, a server or model name, an error.
func Styled ¶
Styled is Text for text celeste composed itself that may carry its own colors around untrusted parts: a well-formed SGR sequence (ESC [ digits and separators m: color and weight; never conceal) is kept, every other ESC sequence and control is escaped as Text escapes it.
func Text ¶
Text returns multi-line text with every control made visible: newlines and tabs stay, CRLF becomes a newline, and any other C0/C1 control, DEL, ESC, bidi control, line or paragraph separator or invalid byte is written as its Go escape (\x1b, \r, \u202e, \xff). Everything else, emoji joiners included, is kept, so ordinary text reads unchanged.
func UnsafeRune ¶
UnsafeRune returns the first rune of s that could hide or forge text on a terminal (C0/C1 controls, DEL, bidi embeddings, overrides and isolates, other format runes, line and paragraph separators), or -1.
Types ¶
This section is empty.