readerly decides color once per run, with one rule, and prints the same small set of glyphs in every tool. This page covers both.
The color rule
Section titled "The color rule"Only the text format prints color. agent, json and jsonl never print an escape code, even with --color, so an agent or a parser never has to strip one.
For text, colorDecision() in src/color.ts takes the first signal that applies:
--colorturns color on, and--no-colorturns it off. The last one given wins.FORCE_COLOR, when set, turns color off for0orfalseand on for any other value, the empty string included.NO_COLORwith any non-empty value turns color off.- When stdout is not a TTY, color is off.
TERM=dumbturns color off.- Otherwise, color is on.
The TTY in step 4 is stdout's, as detect() saw it, even for what readerly writes to stderr. Without --color or FORCE_COLOR, piping stdout to a file turns color off for the whole run.
colorDecision() returns the decision and the signal that made it, the same string --verbose prints:
import { colorDecision, colorEnabled } from "readerly/color";
colorDecision({ env: { FORCE_COLOR: "0" }, isTTY: true });
// { enabled: false, why: "FORCE_COLOR=0" }
colorDecision({ flag: true, env: { NO_COLOR: "1" }, isTTY: false });
// { enabled: true, why: "--color" }
colorEnabled({ env: { TERM: "dumb" }, isTTY: true });
// falseIn a createOut command, the result is out.profile.color, and out.profile.why.color holds the reason. Use it when you color something yourself, such as a Markdown answer you render with @comark/ansi.
Styling without a dependency
Section titled "Styling without a dependency"readerly colors text with styleText from node:util, and names styles such as red, bold and dim instead of RGB values. The terminal's theme picks the real color. createStyle(enabled) returns a function that takes a style name, or a list of them, and the text:
import { createStyle } from "readerly/color";
const style = createStyle(out.profile.color);
style("red", "✖");
style(["bold", "red"], "error");When enabled is true, it always emits escape codes, whatever stream the text ends up on. readerly has already made the decision, so styleText's own stream check is off. When enabled is false, it returns the text unchanged.
Glyphs
Section titled "Glyphs"readerly uses a small set of glyphs, and each has one meaning. A tool built on readerly uses them the same way and adds no others.
| Glyph | Color | Means | Printed by |
|---|---|---|---|
✖ | red | The run failed, or the failure that stopped it | text: the verdict line and a failure's headline |
⚠ | yellow | The run finished with errors or warnings, or needs input (action_required) | text: the verdict line |
✔ | green | The run finished clean | text: the verdict line |
├▶ | dim | A branch of the line above; more follow | text, tree() |
╰▶ | dim | The last branch | text, tree() |
… N more | dim | Rows the row cap hid, with the rerun command | text |
hidden: | none | Lines the budget dropped, with the rerun commands | agent, the last line |
next: | none | A command to run next, then its reason | text, agent |
? | none | A prompt waiting for an answer, on stderr | text at a terminal |
█ ░ | none | A progress bar, on stderr | text at a terminal |
Besides the glyphs, text colors the severity labels, error red, warn yellow and info cyan, and prints the verdict's words, each diagnostic's headline and the branch labels such as why: in bold.
Only a failed status shows ✖. A run that a tool ends with out.end({ status: "ok" }) shows ⚠ when it counted errors or warnings, and ✔ when it counted neither.
Color is never the only signal
Section titled "Color is never the only signal"A status never depends on color alone. The glyph says it, and the words say it again: ✖ 2 errors, error ACME001. With color off, in a pipe, in CI or under NO_COLOR, the output keeps every glyph and every word, so it reads the same.
The agent format goes further and drops the glyphs too. A coding agent reads acme check: failed. and error ACME001 as plain words. See Coding agents.