Terminal output
Control colors and JSON output, separate result streams, and understand terminal sanitization.
LPM CLI provides human-readable output and command-specific JSON results. Use JSON for scripts that need stable fields.
lpm install --json > install.json 2> install.log
lpm install --color=never
lpm install --verboseStandard output and error
Install progress, warnings, and diagnostics go to stderr. Commands can write results or human-readable reports to stdout. Human output is intended for people; its wording and layout can change.
In JSON mode, commands with structured results write their JSON to stdout. Diagnostic and captured task logs can still appear on stderr.
Keep the streams separate when you parse a result:
lpm run build --json > build.json 2> build.logDo not combine stderr with stdout before parsing JSON. Check the process status as well as the result fields. See Exit codes.
Color controls
| Control | Behavior |
|---|---|
--color=always | Enable CLI styling, including when stdout is redirected. |
--color=never | Disable CLI color and styling. |
--color=auto | Default. Use environment settings, then stdout terminal detection. |
FORCE_COLOR=0 or FORCE_COLOR=false | Disable styling in automatic mode. |
Other nonempty FORCE_COLOR values | Enable styling in automatic mode. |
Nonempty NO_COLOR | Disable styling when FORCE_COLOR has no value. |
Explicit always or never wins. In automatic mode, nonempty FORCE_COLOR takes precedence over NO_COLOR.
Empty environment values have no effect.
NO_COLOR=1 lpm install
FORCE_COLOR=1 lpm install
lpm install --color=never > install.out 2> install.logPlain output can still contain Unicode symbols. Install spinners also require an interactive stderr stream. These controls govern CLI styling; a child program that owns its terminal output can apply its own color settings.
JSON output
JSON envelopes differ by command. Use the command page for its fields, success conditions, and captured-output rules.
When present, schema_version identifies that envelope's version. It is not a single shared version for every command.
lpm run reports task metadata, including status, duration, cache hits, and failures. Its child logs go to stderr. Tool commands such as lpm check can include failed child output inside their JSON results.
JSON serialization preserves the semantic values of included strings. It escapes control characters to produce valid JSON. It does not remove terminal commands from those strings.
This does not guarantee a complete copy of child output. A command can omit successful logs or truncate captured failures. For example, workspace tool results include failed output with a 10 MiB limit per stream.
Parse JSON before you use its fields. If your program later displays a parsed string in a terminal, sanitize that string at display time.
Some commands preserve child-process I/O instead of producing a CLI envelope. For example, lpm exec passes through the child output.
A global --json flag does not turn an arbitrary child program's output into JSON.
Human-readable fields
LPM CLI treats external text as untrusted when it places that text inside its own terminal output. This includes package metadata, project values, paths, URLs, registry messages, and task or service names.
Inline fields cannot insert a line or rewrite the current line. Newline, carriage return, tab, backspace, delete, and other raw controls become ?.
Printable Unicode remains intact.
Terminal escape sequences are removed before CLI colors, prefixes, or other formatting are added. This covers cursor movement, title changes, terminal hyperlinks, clipboard commands, and related escape-sequence families.
Multiline blocks retain line feeds and tabs when the output format permits them.
CRLF becomes LF. A lone carriage return becomes ?, so it cannot rewrite a displayed line.
Captured child output
Sanitization applies when LPM CLI captures child output and displays it as human-readable text. This includes:
- Task or service lines with CLI prefixes.
- Buffered task output and task-cache replay.
- Captured dependency lifecycle output.
- Root install-hook output redirected to stderr in JSON mode.
- Service logs displayed by the development dashboard.
Sanitization happens at the human display boundary. Task-cache data and included JSON strings can retain their original values. Dashboard service logs are sanitized before storage and display.
Direct child output
Interactive programs need direct terminal access for prompts, progress displays, and keyboard input. When a command gives a child process inherited stdin, stdout, or stderr, the child owns those streams. LPM CLI cannot sanitize bytes that it does not capture.
For example, ordinary root install hooks inherit their streams. In JSON mode, LPM CLI captures those hooks and sanitizes their stderr replay. The applicable protection therefore depends on the output path, not only the command name.
| Output path | Protection |
|---|---|
| CLI human-readable field | External inline controls and terminal commands are removed. |
| CLI multiline block | Terminal commands and rewrite controls are removed; permitted line structure remains. |
| Captured child output displayed as text | Sanitized before display. |
| Included JSON string | JSON escaping; no terminal sanitization. |
| Direct inherited child stream | Raw child output. |
Terminal sanitization protects the display. Dependency-script permissions and containment are separate controls; see Security.
Troubleshooting
| Symptom | Action |
|---|---|
| A JSON parser sees progress lines | Capture stdout and stderr separately. Check whether the command supports a CLI JSON envelope. |
| A pipe loses colors | Use --color=always for CLI styling. |
| A child still prints colors | Use the child's color option or environment configuration. |
| A captured task loses cursor movement | Run an interactive command through a path with direct child I/O, such as lpm exec. |
| More diagnostics are needed | Add --verbose; keep stderr when you save the result. |