Documentation
¶
Overview ¶
Package termsafe strips the characters a terminal reads as commands from strings that came from somewhere untrusted.
sandbox-cli prints a lot of text the agent chose: session titles and project paths out of transcripts, filenames out of the workspace, model names out of a file the agent writes. All of it goes to the user's terminal, where an ESC is not a character but an instruction — screen clears, window titles, and on permissive terminals a clipboard write via OSC 52. A listing of what an agent did should not be able to act on the machine reading it.
This is a package rather than a helper in each caller because it was a helper in each caller: three near-identical copies existed, and an audit then found two more display paths that had none — `git status -z` filenames and the `context list` project column. One name to reach for is the difference between remembering and forgetting.
Sanitising is deliberately at the point where the value enters something the user will read, not at the point of print: a value that has been through Clean stays safe wherever it is later composed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clean ¶
Clean replaces every control character with a space and collapses the runs, so the result is a single printable line.
The ranges are C0 (which includes ESC), DEL, and C1 — everything a terminal may interpret. Printable non-ASCII is kept, because a filename or a title in any language is ordinary text and mangling it would be its own bug.
Types ¶
This section is empty.