[{"data":1,"prerenderedAt":1177,"buildId":1178},["ShallowReactive",2],{"docs:\u002Fguide\u002Fdiagnostics":3},{"page":4,"section":16,"document":17,"credits":10,"prev":1173,"next":1175},{"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},"diagnostics","\u002Fguide\u002Fdiagnostics","guide\u002Fdiagnostics.md","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.",null,[],"i-lucide-list-tree","article",true,8,"guide",{"nodes":18,"toc":1164},[19,23,31,47,254,260,279,558,586,592,606,660,682,698,736,742,757,797,810,816,819,852,870,879,890,896,899,954,959,1000,1003,1017,1030,1036,1047,1128,1131,1148,1158],[20,21,22],"p",{},"A diagnostic is one finding your command reports, such as a lint error or a config warning. You add diagnostics while the command runs, and readerly prints them once, at the end, in the shape the reader needs.",[24,25,30],"h2",{"id":26,"anchor":27},"the-record",{"label":28,"icon":29},"Section titled \"The record\"","#","The record",[20,32,33,34,38,39,46],{},"Every diagnostic is a ",[35,36,37],"code",{},"DiagnosticRecord"," from ",[40,41,43],"a",{"href":42},"https:\u002F\u002Fgithub.com\u002Floadsheet\u002Freaderly\u002Fblob\u002Fmain\u002Fsrc\u002Ftypes.ts",[35,44,45],{},"src\u002Ftypes.ts",". It follows the nostics shape and adds a location.",[48,49,50,66],"table",{},[51,52,53],"thead",{},[54,55,56,60,63],"tr",{},[57,58,59],"th",{},"Field",[57,61,62],{},"Type",[57,64,65],{},"What it holds",[67,68,69,85,103,117,131,145,159,173,192,209,224],"tbody",{},[54,70,71,77,82],{},[72,73,74],"td",{},[35,75,76],{},"severity",[72,78,79],{},[35,80,81],{},"\"error\" | \"warn\" | \"info\"",[72,83,84],{},"Required. Errors fail the run.",[54,86,87,91,96],{},[72,88,89],{},[35,90,35],{},[72,92,93],{},[35,94,95],{},"string",[72,97,98,99,102],{},"A stable rule or error code, such as ",[35,100,101],{},"ACME001",".",[54,104,105,110,114],{},[72,106,107],{},[35,108,109],{},"message",[72,111,112],{},[35,113,95],{},[72,115,116],{},"Required. One sentence about what is wrong.",[54,118,119,124,128],{},[72,120,121],{},[35,122,123],{},"why",[72,125,126],{},[35,127,95],{},[72,129,130],{},"The reason it matters.",[54,132,133,138,142],{},[72,134,135],{},[35,136,137],{},"fix",[72,139,140],{},[35,141,95],{},[72,143,144],{},"What to change.",[54,146,147,152,156],{},[72,148,149],{},[35,150,151],{},"docs",[72,153,154],{},[35,155,95],{},[72,157,158],{},"A URL that explains the code.",[54,160,161,166,170],{},[72,162,163],{},[35,164,165],{},"file",[72,167,168],{},[35,169,95],{},[72,171,172],{},"Path of the file the finding is in.",[54,174,175,184,189],{},[72,176,177,180,181],{},[35,178,179],{},"line",", ",[35,182,183],{},"column",[72,185,186],{},[35,187,188],{},"number",[72,190,191],{},"Where it starts.",[54,193,194,202,206],{},[72,195,196,180,199],{},[35,197,198],{},"endLine",[35,200,201],{},"endColumn",[72,203,204],{},[35,205,188],{},[72,207,208],{},"Where it ends. Only GitHub annotations use them.",[54,210,211,216,221],{},[72,212,213],{},[35,214,215],{},"sources",[72,217,218],{},[35,219,220],{},"string[]",[72,222,223],{},"Source locations, as nostics reports them.",[54,225,226,231,236],{},[72,227,228],{},[35,229,230],{},"data",[72,232,233],{},[35,234,235],{},"unknown",[72,237,238,239,242,243,246,247,242,250,253],{},"Anything else. ",[35,240,241],{},"json"," and ",[35,244,245],{},"jsonl"," carry it, ",[35,248,249],{},"text",[35,251,252],{},"agent"," don't print it.",[24,255,259],{"id":256,"anchor":257},"adding-diagnostics",{"label":258,"icon":29},"Section titled \"Adding diagnostics\"","Adding diagnostics",[20,261,262,180,265,242,268,271,272,274,275,278],{},[35,263,264],{},"out.error",[35,266,267],{},"out.warn",[35,269,270],{},"out.info"," take a message string or a record without ",[35,273,76],{},". ",[35,276,277],{},"out.diagnostic"," takes a full record, which helps when the severity comes from your own rule table.",[280,281,285],"pre",{"language":282,"filename":283,"class":284,"wrap":14},"ts","lint.ts","shiki shiki-themes github-light-default github-dark-default dark:github-dark-default",[35,286,288,310,311,310,313,310,358,310,387,310,398,310,409,310,419,310,429,310,439,310,449,310,459,310,469,310,479,310,484,310,524,310,539,310,553],{"class":287},"language-ts",[289,290,292,296,300,303,307],"span",{"class":179,"style":291},"display: inline",[289,293,295],{"style":294},"color:#CF222E;--shiki-dark:#FF7B72","import",[289,297,299],{"style":298},"color:#1F2328;--shiki-dark:#E6EDF3"," { createOut } ",[289,301,302],{"style":294},"from",[289,304,306],{"style":305},"color:#0A3069;--shiki-dark:#A5D6FF"," \"readerly\"",[289,308,309],{"style":298},";","\n",[289,312],{"class":179,"style":291},[289,314,315,318,321,324,328,331,335,338,342,345,347,350,353,355],{"class":179,"style":291},[289,316,317],{"style":294},"export",[289,319,320],{"style":294}," async",[289,322,323],{"style":294}," function",[289,325,327],{"style":326},"color:#8250DF;--shiki-dark:#D2A8FF"," lint",[289,329,330],{"style":298},"(",[289,332,334],{"style":333},"color:#953800;--shiki-dark:#FFA657","argv",[289,336,337],{"style":294},":",[289,339,341],{"style":340},"color:#0550AE;--shiki-dark:#79C0FF"," string",[289,343,344],{"style":298},"[])",[289,346,337],{"style":294},[289,348,349],{"style":333}," Promise",[289,351,352],{"style":298},"\u003C",[289,354,188],{"style":340},[289,356,357],{"style":298},"> {",[289,359,360,363,366,369,372,375,378,381,384],{"class":179,"style":291},[289,361,362],{"style":294},"  const",[289,364,365],{"style":340}," out",[289,367,368],{"style":294}," =",[289,370,371],{"style":326}," createOut",[289,373,374],{"style":298},"({ tool: ",[289,376,377],{"style":305},"\"acme\"",[289,379,380],{"style":298},", command: ",[289,382,383],{"style":305},"\"lint\"",[289,385,386],{"style":298},", argv });",[289,388,389,392,395],{"class":179,"style":291},[289,390,391],{"style":298},"  out.",[289,393,394],{"style":326},"error",[289,396,397],{"style":298},"({",[289,399,400,403,406],{"class":179,"style":291},[289,401,402],{"style":298},"    code: ",[289,404,405],{"style":305},"\"ACME001\"",[289,407,408],{"style":298},",",[289,410,411,414,417],{"class":179,"style":291},[289,412,413],{"style":298},"    message: ",[289,415,416],{"style":305},"\"Route handler reads process.env at module scope\"",[289,418,408],{"style":298},[289,420,421,424,427],{"class":179,"style":291},[289,422,423],{"style":298},"    why: ",[289,425,426],{"style":305},"\"The value is fixed at build time\"",[289,428,408],{"style":298},[289,430,431,434,437],{"class":179,"style":291},[289,432,433],{"style":298},"    fix: ",[289,435,436],{"style":305},"\"Read it inside the handler\"",[289,438,408],{"style":298},[289,440,441,444,447],{"class":179,"style":291},[289,442,443],{"style":298},"    docs: ",[289,445,446],{"style":305},"\"https:\u002F\u002Facme.dev\u002Frules\u002FACME001\"",[289,448,408],{"style":298},[289,450,451,454,457],{"class":179,"style":291},[289,452,453],{"style":298},"    file: ",[289,455,456],{"style":305},"\"src\u002Fapp.ts\"",[289,458,408],{"style":298},[289,460,461,464,467],{"class":179,"style":291},[289,462,463],{"style":298},"    line: ",[289,465,466],{"style":340},"14",[289,468,408],{"style":298},[289,470,471,474,477],{"class":179,"style":291},[289,472,473],{"style":298},"    column: ",[289,475,476],{"style":340},"3",[289,478,408],{"style":298},[289,480,481],{"class":179,"style":291},[289,482,483],{"style":298},"  });",[289,485,486,488,491,494,497,500,503,506,509,512,515,518,521],{"class":179,"style":291},[289,487,391],{"style":298},[289,489,490],{"style":326},"warn",[289,492,493],{"style":298},"({ code: ",[289,495,496],{"style":305},"\"ACME010\"",[289,498,499],{"style":298},", message: ",[289,501,502],{"style":305},"\"Alias shadows a workspace package\"",[289,504,505],{"style":298},", file: ",[289,507,508],{"style":305},"\"vite.config.ts\"",[289,510,511],{"style":298},", line: ",[289,513,514],{"style":340},"8",[289,516,517],{"style":298},", column: ",[289,519,520],{"style":340},"5",[289,522,523],{"style":298}," });",[289,525,526,528,531,533,536],{"class":179,"style":291},[289,527,391],{"style":298},[289,529,530],{"style":326},"info",[289,532,330],{"style":298},[289,534,535],{"style":305},"\"Cache was cold\"",[289,537,538],{"style":298},");",[289,540,541,544,547,550],{"class":179,"style":291},[289,542,543],{"style":294},"  return",[289,545,546],{"style":298}," out.",[289,548,549],{"style":326},"end",[289,551,552],{"style":298},"();",[289,554,555],{"class":179,"style":291},[289,556,557],{"style":298},"}",[20,559,560,561,180,563,242,565,567,568,571,572,576,577,579,580,180,583,585],{},"In ",[35,562,249],{},[35,564,252],{},[35,566,241],{},", nothing prints when you call them. readerly collects the records, counts them by severity and renders them when you call ",[35,569,570],{},"out.end()",", or earlier when a ",[40,573,575],{"href":574},"\u002Fguide\u002Fprompts","prompt"," needs the screen. ",[35,578,245],{}," writes each record as you add it. With ",[35,581,582],{},"--quiet",[35,584,249],{}," drops infos and logs from the report but still counts them.",[24,587,591],{"id":588,"anchor":589},"how-text-prints-them",{"label":590,"icon":29},"Section titled \"How text prints them\"","How text prints them",[20,593,594,595,598,599,605],{},"A person at a terminal gets the ",[35,596,597],{},"acme check"," example from ",[40,600,602],{"href":601},"https:\u002F\u002Fgithub.com\u002Floadsheet\u002Freaderly\u002Fblob\u002Fmain\u002Ftest\u002Fgolden",[35,603,604],{},"test\u002Fgolden"," like this, without the color:",[280,607,608],{"language":249,"class":284,"wrap":14},[35,609,611,310,616,310,621,310,626,310,631,310,636,310,641,310,646,310,651,310,655],{"class":610},"language-text",[289,612,613],{"class":179,"style":291},[289,614,615],{},"✖ 2 errors, 1 warning in 212 files (0.8s)",[289,617,618],{"class":179,"style":291},[289,619,620],{},"",[289,622,623],{"class":179,"style":291},[289,624,625],{},"error ACME001  src\u002Fapp.ts:14:3  Route handler reads process.env at module scope",[289,627,628],{"class":179,"style":291},[289,629,630],{},"├▶ why: The value is fixed at build time",[289,632,633],{"class":179,"style":291},[289,634,635],{},"╰▶ fix: Read it inside the handler",[289,637,638],{"class":179,"style":291},[289,639,640],{},"error ACME004  src\u002Fdb.ts:3:1  Top-level await in a server entry",[289,642,643],{"class":179,"style":291},[289,644,645],{},"╰▶ fix: Move the call into the plugin setup",[289,647,648],{"class":179,"style":291},[289,649,650],{},"warn  ACME010  vite.config.ts:8:5  Alias shadows a workspace package",[289,652,653],{"class":179,"style":291},[289,654,620],{},[289,656,657],{"class":179,"style":291},[289,658,659],{},"next: acme explain \u003Ccode>   (explains one code)",[20,661,662,663,666,667,670,671,674,675,678,679,102],{},"The first line is the verdict. Its glyph comes from the status: a red ",[35,664,665],{},"✖"," when the run failed, a yellow ",[35,668,669],{},"⚠"," for ",[35,672,673],{},"action_required"," or for errors and warnings in a run that didn't fail, and a green ",[35,676,677],{},"✔"," otherwise. A clean run prints ",[35,680,681],{},"✔ no problems",[20,683,684,685,180,687,180,690,693,694,697],{},"Rows are sorted errors first, then warnings, then infos. Each row starts with the severity padded to five characters (",[35,686,394],{},[35,688,689],{},"warn ",[35,691,692],{},"info ","), in red, yellow or cyan. Then come the code, the location as ",[35,695,696],{},"file:line:column"," and the message, separated by two spaces.",[20,699,700,701,704,705,180,708,711,712,715,716,718,719,722,723,726,727,730,731,735],{},"Below a row, ",[35,702,703],{},"tree()"," draws one branch per field: ",[35,706,707],{},"why:",[35,709,710],{},"fix:",", and ",[35,713,714],{},"see:"," with the ",[35,717,151],{}," URL when you pass ",[35,720,721],{},"--full",". The last branch gets ",[35,724,725],{},"╰▶",", the others ",[35,728,729],{},"├▶",". The glyphs are dim and the labels bold. See ",[40,732,734],{"href":733},"\u002Fguide\u002Fcolor","Color and glyphs"," for the full vocabulary.",[24,737,741],{"id":738,"anchor":739},"the-row-cap",{"label":740,"icon":29},"Section titled \"The row cap\"","The row cap",[20,743,744,745,748,749,752,753,756],{},"A terminal shows at most 50 rows. Set ",[35,746,747],{},"maxRows"," in ",[35,750,751],{},"createOut"," to change it. The rows past the cap collapse into one dim line with the command that shows them all. With ",[35,754,755],{},"maxRows: 3",", the person at the terminal gets:",[280,758,759],{"language":249,"class":284,"wrap":14},[35,760,761,310,766,310,770,310,774,310,778,310,782,310,787,310,792],{"class":610},[289,762,763],{"class":179,"style":291},[289,764,765],{},"✖ 1 error, 4 warnings, 1 info",[289,767,768],{"class":179,"style":291},[289,769,620],{},[289,771,772],{"class":179,"style":291},[289,773,625],{},[289,775,776],{"class":179,"style":291},[289,777,630],{},[289,779,780],{"class":179,"style":291},[289,781,635],{},[289,783,784],{"class":179,"style":291},[289,785,786],{},"warn  ACME010  packages\u002Fp1\u002Fvite.config.ts:8:5  Alias shadows a workspace package",[289,788,789],{"class":179,"style":291},[289,790,791],{},"warn  ACME010  packages\u002Fp2\u002Fvite.config.ts:8:5  Alias shadows a workspace package",[289,793,794],{"class":179,"style":291},[289,795,796],{},"… 3 more (rerun: acme lint --full)",[20,798,799,800,803,804,806,807,809],{},"The cap applies only to the ",[35,801,802],{},"terminal"," reader on ",[35,805,249],{},". CI logs, pipes and ",[35,808,721],{}," get every row.",[24,811,815],{"id":812,"anchor":813},"how-agent-prints-them",{"label":814,"icon":29},"Section titled \"How agent prints them\"","How agent prints them",[20,817,818],{},"A coding agent gets each diagnostic on one line: severity, code, location, message, and the fix as a second sentence.",[280,820,821],{"language":249,"class":284,"wrap":14},[35,822,823,310,828,310,833,310,838,310,843,310,848],{"class":610},[289,824,825],{"class":179,"style":291},[289,826,827],{},"acme check: failed. 2 errors, 1 warning in 212 files (0.8s).",[289,829,830],{"class":179,"style":291},[289,831,832],{},"error ACME001 src\u002Fapp.ts:14:3 Route handler reads process.env at module scope. fix: Read it inside the handler",[289,834,835],{"class":179,"style":291},[289,836,837],{},"error ACME004 src\u002Fdb.ts:3:1 Top-level await in a server entry. fix: Move the call into the plugin setup",[289,839,840],{"class":179,"style":291},[289,841,842],{},"warn ACME010 vite.config.ts:8:5 Alias shadows a workspace package",[289,844,845],{"class":179,"style":291},[289,846,847],{},"next: acme check --fix   (applies 2 safe fixes)",[289,849,850],{"class":179,"style":291},[289,851,659],{},[20,853,854,242,856,859,860,862,863,865,866,869],{},[35,855,707],{},[35,857,858],{},"docs:"," join the line only with ",[35,861,721],{},". With ",[35,864,721],{},", the agent gets this line for the ",[35,867,868],{},"lint"," example above:",[280,871,872],{"language":249,"class":284,"wrap":14},[35,873,874],{"class":610},[289,875,876],{"class":179,"style":291},[289,877,878],{},"error ACME001 src\u002Fapp.ts:14:3 Route handler reads process.env at module scope. why: The value is fixed at build time. fix: Read it inside the handler. docs: https:\u002F\u002Facme.dev\u002Frules\u002FACME001",[20,880,881,882,884,885,889],{},"There is no row cap in ",[35,883,252],{},". The ",[40,886,888],{"href":887},"\u002Fguide\u002Fbudget","budget"," decides how many lines fit.",[24,891,895],{"id":892,"anchor":893},"the-verdict",{"label":894,"icon":29},"Section titled \"The verdict\"","The verdict",[20,897,898],{},"The verdict is the counts, an optional summary and a status.",[900,901,902,917,938],"ul",{},[903,904,905,909,910,913,914,102],"li",{},[906,907,908],"strong",{},"Counts."," ",[35,911,912],{},"2 errors, 1 warning",". Severities with no records are left out, and a run with none says ",[35,915,916],{},"no problems",[903,918,919,922,923,926,927,930,931,933,934,937],{},[906,920,921],{},"Summary."," Text after the counts, such as ",[35,924,925],{},"in 212 files (0.8s)",". Pass ",[35,928,929],{},"summary: (result, counts) => string | undefined"," to ",[35,932,751],{},", or a string to ",[35,935,936],{},"out.end({ summary })"," for one run.",[903,939,940,909,943,946,947,926,950,953],{},[906,941,942],{},"Status.",[35,944,945],{},"failed"," when there is at least one error, else ",[35,948,949],{},"ok",[35,951,952],{},"out.end({ status })"," to decide it yourself.",[20,955,956,957,337],{},"A tool that tolerates errors can end with ",[35,958,949],{},[280,960,961],{"language":282,"filename":283,"class":284,"wrap":14},[35,962,963,310,977],{"class":287},[289,964,965,968,970,972,975],{"class":179,"style":291},[289,966,967],{"style":298},"out.",[289,969,394],{"style":326},[289,971,330],{"style":298},[289,973,974],{"style":305},"\"Unused export\"",[289,976,538],{"style":298},[289,978,979,982,984,986,989,992,995,998],{"class":179,"style":291},[289,980,981],{"style":294},"return",[289,983,546],{"style":298},[289,985,549],{"style":326},[289,987,988],{"style":298},"({ status: ",[289,990,991],{"style":305},"\"ok\"",[289,993,994],{"style":298},", summary: ",[289,996,997],{"style":305},"\"(errors tolerated)\"",[289,999,523],{"style":298},[20,1001,1002],{},"The exit code is 0, and a coding agent gets:",[280,1004,1005],{"language":249,"class":284,"wrap":14},[35,1006,1007,310,1012],{"class":610},[289,1008,1009],{"class":179,"style":291},[289,1010,1011],{},"acme lint: ok. 1 error (errors tolerated).",[289,1013,1014],{"class":179,"style":291},[289,1015,1016],{},"error Unused export",[20,1018,560,1019,1021,1022,1024,1025,1027,1028,102],{},[35,1020,249],{},", that verdict shows a yellow ",[35,1023,669],{},", because the counts still hold an error. Only a ",[35,1026,945],{}," status shows ",[35,1029,665],{},[24,1031,1035],{"id":1032,"anchor":1033},"using-tree-on-its-own",{"label":1034,"icon":29},"Section titled \"Using tree on its own\"","Using tree on its own",[20,1037,1038,38,1040,1043,1044,102],{},[35,1039,703],{},[35,1041,1042],{},"readerly\u002Ftree"," draws the same shape for any headline and branches. It returns a string with no trailing newline and no color unless you pass a ",[35,1045,1046],{},"Style",[280,1048,1050],{"language":282,"filename":1049,"class":284,"wrap":14},"explain.ts",[35,1051,1052,310,1066,310,1068,310,1078,310,1091,310,1106,310,1119,310,1124],{"class":287},[289,1053,1054,1056,1059,1061,1064],{"class":179,"style":291},[289,1055,295],{"style":294},[289,1057,1058],{"style":298}," { tree } ",[289,1060,302],{"style":294},[289,1062,1063],{"style":305}," \"readerly\u002Ftree\"",[289,1065,309],{"style":298},[289,1067],{"class":179,"style":291},[289,1069,1070,1073,1076],{"class":179,"style":291},[289,1071,1072],{"style":298},"console.",[289,1074,1075],{"style":326},"log",[289,1077,330],{"style":298},[289,1079,1080,1083,1085,1088],{"class":179,"style":291},[289,1081,1082],{"style":326},"  tree",[289,1084,330],{"style":298},[289,1086,1087],{"style":305},"\"ACME001 Route handler reads process.env\"",[289,1089,1090],{"style":298},", [",[289,1092,1093,1096,1099,1101,1103],{"class":179,"style":291},[289,1094,1095],{"style":298},"    [",[289,1097,1098],{"style":305},"\"why\"",[289,1100,180],{"style":298},[289,1102,426],{"style":305},[289,1104,1105],{"style":298},"],",[289,1107,1108,1110,1113,1115,1117],{"class":179,"style":291},[289,1109,1095],{"style":298},[289,1111,1112],{"style":305},"\"fix\"",[289,1114,180],{"style":298},[289,1116,436],{"style":305},[289,1118,1105],{"style":298},[289,1120,1121],{"class":179,"style":291},[289,1122,1123],{"style":298},"  ]),",[289,1125,1126],{"class":179,"style":291},[289,1127,538],{"style":298},[20,1129,1130],{},"It prints:",[280,1132,1133],{"language":249,"class":284,"wrap":14},[35,1134,1135,310,1140,310,1144],{"class":610},[289,1136,1137],{"class":179,"style":291},[289,1138,1139],{},"ACME001 Route handler reads process.env",[289,1141,1142],{"class":179,"style":291},[289,1143,630],{},[289,1145,1146],{"class":179,"style":291},[289,1147,635],{},[20,1149,1150,1151,38,1154,1157],{},"Pass ",[35,1152,1153],{},"createStyle(true)",[35,1155,1156],{},"readerly\u002Fcolor"," as the third argument to make the headline and labels bold and the glyphs dim.",[20,1159,1160,1161,102],{},"Next: ",[40,1162,1163],{"href":887},"Budget",[1165,1167,1168,1169,1170,1171,1172],{"id":26,"depth":1166,"text":30},2,{"id":256,"depth":1166,"text":259},{"id":588,"depth":1166,"text":591},{"id":738,"depth":1166,"text":741},{"id":812,"depth":1166,"text":815},{"id":892,"depth":1166,"text":895},{"id":1032,"depth":1166,"text":1035},{"path":733,"title":734,"description":1174},"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.",{"path":887,"title":1163,"description":1176},"How readerly fits agent output into 8,000 characters, which lines it keeps, the hidden footer, --max-chars and --full, and planBudget on its own.",1795985392648,"22ea5d7b-bce0-4e3b-bca3-1fbe3722fcf7"]