[{"data":1,"prerenderedAt":704,"buildId":705},["ShallowReactive",2],{"docs:\u002Fguide\u002Fcolor":3},{"page":4,"section":16,"document":17,"credits":10,"prev":696,"next":700},{"id":5,"path":6,"file":7,"title":8,"sourceTitle":8,"description":9,"tagline":9,"eyebrow":10,"credits":10,"keywords":11,"icon":12,"layout":13,"sidebar":14,"toc":14,"kind":10,"group":10,"navigation":14,"order":15},"color","\u002Fguide\u002Fcolor","guide\u002Fcolor.md","Color and glyphs","The one rule readerly uses to turn color on or off, which formats never print escape codes, and the glyphs and colors the text format uses.",null,[],"i-lucide-palette","article",true,7,"guide",{"nodes":18,"toc":690},[19,23,31,55,72,117,129,138,253,273,279,304,382,400,406,409,613,635,655,661,674],[20,21,22],"p",{},"readerly decides color once per run, with one rule, and prints the same small set of glyphs in every tool. This page covers both.",[24,25,30],"h2",{"id":26,"anchor":27},"the-color-rule",{"label":28,"icon":29},"Section titled \"The color rule\"","#","The color rule",[20,32,33,34,38,39,42,43,46,47,50,51,54],{},"Only the ",[35,36,37],"code",{},"text"," format prints color. ",[35,40,41],{},"agent",", ",[35,44,45],{},"json"," and ",[35,48,49],{},"jsonl"," never print an escape code, even with ",[35,52,53],{},"--color",", so an agent or a parser never has to strip one.",[20,56,57,58,42,60,63,64,71],{},"For ",[35,59,37],{},[35,61,62],{},"colorDecision()"," in ",[65,66,68],"a",{"href":67},"https:\u002F\u002Fgithub.com\u002Floadsheet\u002Freaderly\u002Fblob\u002Fmain\u002Fsrc\u002Fcolor.ts",[35,69,70],{},"src\u002Fcolor.ts"," takes the first signal that applies:",[73,74,75,85,99,105,108,114],"ol",{},[76,77,78,80,81,84],"li",{},[35,79,53],{}," turns color on, and ",[35,82,83],{},"--no-color"," turns it off. The last one given wins.",[76,86,87,90,91,94,95,98],{},[35,88,89],{},"FORCE_COLOR",", when set, turns color off for ",[35,92,93],{},"0"," or ",[35,96,97],{},"false"," and on for any other value, the empty string included.",[76,100,101,104],{},[35,102,103],{},"NO_COLOR"," with any non-empty value turns color off.",[76,106,107],{},"When stdout is not a TTY, color is off.",[76,109,110,113],{},[35,111,112],{},"TERM=dumb"," turns color off.",[76,115,116],{},"Otherwise, color is on.",[20,118,119,120,123,124,94,126,128],{},"The TTY in step 4 is stdout's, as ",[35,121,122],{},"detect()"," saw it, even for what readerly writes to stderr. Without ",[35,125,53],{},[35,127,89],{},", piping stdout to a file turns color off for the whole run.",[20,130,131,133,134,137],{},[35,132,62],{}," returns the decision and the signal that made it, the same string ",[35,135,136],{},"--verbose"," prints:",[139,140,144],"pre",{"language":141,"filename":142,"class":143,"wrap":14},"ts","color.ts","shiki shiki-themes github-light-default github-dark-default dark:github-dark-default",[35,145,147,170,171,170,173,170,195,170,201,170,203,170,224,170,229,170,231,170,248],{"class":146},"language-ts",[148,149,152,156,160,163,167],"span",{"class":150,"style":151},"line","display: inline",[148,153,155],{"style":154},"color:#CF222E;--shiki-dark:#FF7B72","import",[148,157,159],{"style":158},"color:#1F2328;--shiki-dark:#E6EDF3"," { colorDecision, colorEnabled } ",[148,161,162],{"style":154},"from",[148,164,166],{"style":165},"color:#0A3069;--shiki-dark:#A5D6FF"," \"readerly\u002Fcolor\"",[148,168,169],{"style":158},";","\n",[148,172],{"class":150,"style":151},[148,174,175,179,182,185,188,192],{"class":150,"style":151},[148,176,178],{"style":177},"color:#8250DF;--shiki-dark:#D2A8FF","colorDecision",[148,180,181],{"style":158},"({ env: { FORCE_COLOR: ",[148,183,184],{"style":165},"\"0\"",[148,186,187],{"style":158}," }, isTTY: ",[148,189,191],{"style":190},"color:#0550AE;--shiki-dark:#79C0FF","true",[148,193,194],{"style":158}," });",[148,196,197],{"class":150,"style":151},[148,198,200],{"style":199},"color:#6E7781;--shiki-dark:#8B949E","\u002F\u002F { enabled: false, why: \"FORCE_COLOR=0\" }",[148,202],{"class":150,"style":151},[148,204,205,207,210,212,215,218,220,222],{"class":150,"style":151},[148,206,178],{"style":177},[148,208,209],{"style":158},"({ flag: ",[148,211,191],{"style":190},[148,213,214],{"style":158},", env: { NO_COLOR: ",[148,216,217],{"style":165},"\"1\"",[148,219,187],{"style":158},[148,221,97],{"style":190},[148,223,194],{"style":158},[148,225,226],{"class":150,"style":151},[148,227,228],{"style":199},"\u002F\u002F { enabled: true, why: \"--color\" }",[148,230],{"class":150,"style":151},[148,232,233,236,239,242,244,246],{"class":150,"style":151},[148,234,235],{"style":177},"colorEnabled",[148,237,238],{"style":158},"({ env: { TERM: ",[148,240,241],{"style":165},"\"dumb\"",[148,243,187],{"style":158},[148,245,191],{"style":190},[148,247,194],{"style":158},[148,249,250],{"class":150,"style":151},[148,251,252],{"style":199},"\u002F\u002F false",[20,254,255,256,259,260,263,264,267,268,272],{},"In a ",[35,257,258],{},"createOut"," command, the result is ",[35,261,262],{},"out.profile.color",", and ",[35,265,266],{},"out.profile.why.color"," holds the reason. Use it when you color something yourself, such as a Markdown answer you render with ",[65,269,271],{"href":270},"\u002Fintegrations\u002Fmarkdown-answers","@comark\u002Fansi",".",[24,274,278],{"id":275,"anchor":276},"styling-without-a-dependency",{"label":277,"icon":29},"Section titled \"Styling without a dependency\"","Styling without a dependency",[20,280,281,282,285,286,289,290,42,293,46,296,299,300,303],{},"readerly colors text with ",[35,283,284],{},"styleText"," from ",[35,287,288],{},"node:util",", and names styles such as ",[35,291,292],{},"red",[35,294,295],{},"bold",[35,297,298],{},"dim"," instead of RGB values. The terminal's theme picks the real color. ",[35,301,302],{},"createStyle(enabled)"," returns a function that takes a style name, or a list of them, and the text:",[139,305,307],{"language":141,"filename":306,"class":143,"wrap":14},"style.ts",[35,308,309,170,322,170,324,170,341,170,360],{"class":146},[148,310,311,313,316,318,320],{"class":150,"style":151},[148,312,155],{"style":154},[148,314,315],{"style":158}," { createStyle } ",[148,317,162],{"style":154},[148,319,166],{"style":165},[148,321,169],{"style":158},[148,323],{"class":150,"style":151},[148,325,326,329,332,335,338],{"class":150,"style":151},[148,327,328],{"style":154},"const",[148,330,331],{"style":190}," style",[148,333,334],{"style":154}," =",[148,336,337],{"style":177}," createStyle",[148,339,340],{"style":158},"(out.profile.color);",[148,342,343,346,349,352,354,357],{"class":150,"style":151},[148,344,345],{"style":177},"style",[148,347,348],{"style":158},"(",[148,350,351],{"style":165},"\"red\"",[148,353,42],{"style":158},[148,355,356],{"style":165},"\"✖\"",[148,358,359],{"style":158},");",[148,361,362,364,367,370,372,374,377,380],{"class":150,"style":151},[148,363,345],{"style":177},[148,365,366],{"style":158},"([",[148,368,369],{"style":165},"\"bold\"",[148,371,42],{"style":158},[148,373,351],{"style":165},[148,375,376],{"style":158},"], ",[148,378,379],{"style":165},"\"error\"",[148,381,359],{"style":158},[20,383,384,385,388,389,391,392,394,395,388,397,399],{},"When ",[35,386,387],{},"enabled"," is ",[35,390,191],{},", it always emits escape codes, whatever stream the text ends up on. readerly has already made the decision, so ",[35,393,284],{},"'s own stream check is off. When ",[35,396,387],{},[35,398,97],{},", it returns the text unchanged.",[24,401,405],{"id":402,"anchor":403},"glyphs",{"label":404,"icon":29},"Section titled \"Glyphs\"","Glyphs",[20,407,408],{},"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.",[410,411,412,431],"table",{},[413,414,415],"thead",{},[416,417,418,422,425,428],"tr",{},[419,420,421],"th",{},"Glyph",[419,423,424],{},"Color",[419,426,427],{},"Means",[419,429,430],{},"Printed by",[432,433,434,452,474,491,510,528,544,562,580,597],"tbody",{},[416,435,436,442,444,447],{},[437,438,439],"td",{},[35,440,441],{},"✖",[437,443,292],{},[437,445,446],{},"The run failed, or the failure that stopped it",[437,448,449,451],{},[35,450,37],{},": the verdict line and a failure's headline",[416,453,454,459,462,469],{},[437,455,456],{},[35,457,458],{},"⚠",[437,460,461],{},"yellow",[437,463,464,465,468],{},"The run finished with errors or warnings, or needs input (",[35,466,467],{},"action_required",")",[437,470,471,473],{},[35,472,37],{},": the verdict line",[416,475,476,481,484,487],{},[437,477,478],{},[35,479,480],{},"✔",[437,482,483],{},"green",[437,485,486],{},"The run finished clean",[437,488,489,473],{},[35,490,37],{},[416,492,493,498,500,503],{},[437,494,495],{},[35,496,497],{},"├▶",[437,499,298],{},[437,501,502],{},"A branch of the line above; more follow",[437,504,505,42,507],{},[35,506,37],{},[35,508,509],{},"tree()",[416,511,512,517,519,522],{},[437,513,514],{},[35,515,516],{},"╰▶",[437,518,298],{},[437,520,521],{},"The last branch",[437,523,524,42,526],{},[35,525,37],{},[35,527,509],{},[416,529,530,535,537,540],{},[437,531,532],{},[35,533,534],{},"… N more",[437,536,298],{},[437,538,539],{},"Rows the row cap hid, with the rerun command",[437,541,542],{},[35,543,37],{},[416,545,546,551,554,557],{},[437,547,548],{},[35,549,550],{},"hidden:",[437,552,553],{},"none",[437,555,556],{},"Lines the budget dropped, with the rerun commands",[437,558,559,561],{},[35,560,41],{},", the last line",[416,563,564,569,571,574],{},[437,565,566],{},[35,567,568],{},"next:",[437,570,553],{},[437,572,573],{},"A command to run next, then its reason",[437,575,576,42,578],{},[35,577,37],{},[35,579,41],{},[416,581,582,587,589,592],{},[437,583,584],{},[35,585,586],{},"?",[437,588,553],{},[437,590,591],{},"A prompt waiting for an answer, on stderr",[437,593,594,596],{},[35,595,37],{}," at a terminal",[416,598,599,604,606,609],{},[437,600,601],{},[35,602,603],{},"█ ░",[437,605,553],{},[437,607,608],{},"A progress bar, on stderr",[437,610,611,596],{},[35,612,37],{},[20,614,615,616,618,619,622,623,626,627,630,631,634],{},"Besides the glyphs, ",[35,617,37],{}," colors the severity labels, ",[35,620,621],{},"error"," red, ",[35,624,625],{},"warn"," yellow and ",[35,628,629],{},"info"," cyan, and prints the verdict's words, each diagnostic's headline and the branch labels such as ",[35,632,633],{},"why:"," in bold.",[20,636,637,638,641,642,644,645,648,649,651,652,654],{},"Only a ",[35,639,640],{},"failed"," status shows ",[35,643,441],{},". A run that a tool ends with ",[35,646,647],{},"out.end({ status: \"ok\" })"," shows ",[35,650,458],{}," when it counted errors or warnings, and ",[35,653,480],{}," when it counted neither.",[24,656,660],{"id":657,"anchor":658},"color-is-never-the-only-signal",{"label":659,"icon":29},"Section titled \"Color is never the only signal\"","Color is never the only signal",[20,662,663,664,42,667,670,671,673],{},"A status never depends on color alone. The glyph says it, and the words say it again: ",[35,665,666],{},"✖ 2 errors",[35,668,669],{},"error ACME001",". With color off, in a pipe, in CI or under ",[35,672,103],{},", the output keeps every glyph and every word, so it reads the same.",[20,675,676,677,679,680,46,683,685,686,272],{},"The ",[35,678,41],{}," format goes further and drops the glyphs too. A coding agent reads ",[35,681,682],{},"acme check: failed.",[35,684,669],{}," as plain words. See ",[65,687,689],{"href":688},"\u002Fguide\u002Fagents","Coding agents",[691,693,694,695],{"id":26,"depth":692,"text":30},2,{"id":275,"depth":692,"text":278},{"id":402,"depth":692,"text":405},{"id":657,"depth":692,"text":660},{"path":697,"title":698,"description":699},"\u002Fguide\u002Fflags","Shared flags","The reader flags every readerly command accepts, such as --format, --full, --no-input and --verbose, what each changes, and how the rest reach your parser.",{"path":701,"title":702,"description":703},"\u002Fguide\u002Fdiagnostics","Diagnostics","The DiagnosticRecord fields, the out.error, warn, info and diagnostic calls, and how text and agent output print each finding and the verdict line.",1795985393640,"22ea5d7b-bce0-4e3b-bca3-1fbe3722fcf7"]