[{"data":1,"prerenderedAt":1033,"buildId":1034},["ShallowReactive",2],{"docs:\u002Fintegrations\u002Fnostics":3},{"page":4,"section":15,"document":16,"credits":9,"prev":1029,"next":9},{"id":5,"path":6,"file":7,"title":5,"sourceTitle":5,"description":8,"tagline":8,"eyebrow":9,"credits":9,"keywords":10,"icon":11,"layout":12,"sidebar":13,"toc":13,"kind":9,"group":9,"navigation":13,"order":14},"nostics","\u002Fintegrations\u002Fnostics","integrations\u002Fnostics.md","Send nostics diagnostics to createOut with nosticsReporter, or convert one with fromNostics. The bridge matches nostics by shape and doesn't depend on it.",null,[],"i-lucide-stethoscope","article",true,7,"integrations",{"nodes":17,"toc":1025},[18,47,55,76,395,402,458,464,485,488,517,550,701,707,724,820,826,892,901,990,1016],[19,20,21,25,26,30,31,34,35,38,39,42,43,46],"p",{},[22,23,5],"a",{"href":24},"https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fnostics"," defines diagnostic codes with a ",[27,28,29],"code",{},"why",", a ",[27,32,33],{},"fix"," and a docs link, and reports them through reporters. readerly's bridge turns each reported diagnostic into a ",[27,36,37],{},"DiagnosticRecord",", so ",[27,40,41],{},"createOut"," prints it for every reader. It lives in ",[27,44,45],{},"readerly\u002Fnostics"," and matches nostics by shape: readerly has no dependency on nostics.",[48,49,54],"h2",{"id":50,"anchor":51},"nosticsreporter",{"label":52,"icon":53},"Section titled \"nosticsReporter\"","#","nosticsReporter",[19,56,57,60,61,64,65,68,69,71,72,75],{},[27,58,59],{},"nosticsReporter(sink)"," returns a nostics reporter that hands each diagnostic to ",[27,62,63],{},"sink.diagnostic()",". An ",[27,66,67],{},"Out"," from ",[27,70,41],{}," is a sink. Add the reporter to ",[27,73,74],{},"defineDiagnostics",":",[77,78,82],"pre",{"language":79,"filename":80,"class":81,"wrap":13},"ts","diagnostics.ts","shiki shiki-themes github-light-default github-dark-default dark:github-dark-default",[27,83,85,108,109,108,123,108,137,108,139,108,182,108,184,108,199,108,210,108,215,108,220,108,265,108,302,108,307,108,318,108,323,108,333,108,338,108,340,108,369,108,379],{"class":84},"language-ts",[86,87,90,94,98,101,105],"span",{"class":88,"style":89},"line","display: inline",[86,91,93],{"style":92},"color:#CF222E;--shiki-dark:#FF7B72","import",[86,95,97],{"style":96},"color:#1F2328;--shiki-dark:#E6EDF3"," { defineDiagnostics } ",[86,99,100],{"style":92},"from",[86,102,104],{"style":103},"color:#0A3069;--shiki-dark:#A5D6FF"," \"nostics\"",[86,106,107],{"style":96},";","\n",[86,110,111,113,116,118,121],{"class":88,"style":89},[86,112,93],{"style":92},[86,114,115],{"style":96}," { createOut } ",[86,117,100],{"style":92},[86,119,120],{"style":103}," \"readerly\"",[86,122,107],{"style":96},[86,124,125,127,130,132,135],{"class":88,"style":89},[86,126,93],{"style":92},[86,128,129],{"style":96}," { nosticsReporter } ",[86,131,100],{"style":92},[86,133,134],{"style":103}," \"readerly\u002Fnostics\"",[86,136,107],{"style":96},[86,138],{"class":88,"style":89},[86,140,141,144,148,151,155,158,161,164,167,170,173,176,179],{"class":88,"style":89},[86,142,143],{"style":92},"const",[86,145,147],{"style":146},"color:#0550AE;--shiki-dark:#79C0FF"," out",[86,149,150],{"style":92}," =",[86,152,154],{"style":153},"color:#8250DF;--shiki-dark:#D2A8FF"," createOut",[86,156,157],{"style":96},"({ tool: ",[86,159,160],{"style":103},"\"acme\"",[86,162,163],{"style":96},", command: ",[86,165,166],{"style":103},"\"build\"",[86,168,169],{"style":96},", argv: process.argv.",[86,171,172],{"style":153},"slice",[86,174,175],{"style":96},"(",[86,177,178],{"style":146},"2",[86,180,181],{"style":96},") });",[86,183],{"class":88,"style":89},[86,185,186,188,191,193,196],{"class":88,"style":89},[86,187,143],{"style":92},[86,189,190],{"style":146}," diagnostics",[86,192,150],{"style":92},[86,194,195],{"style":153}," defineDiagnostics",[86,197,198],{"style":96},"({",[86,200,201,204,207],{"class":88,"style":89},[86,202,203],{"style":96},"  docsBase: ",[86,205,206],{"style":103},"\"https:\u002F\u002Facme.dev\u002Ferrors\"",[86,208,209],{"style":96},",",[86,211,212],{"class":88,"style":89},[86,213,214],{"style":96},"  codes: {",[86,216,217],{"class":88,"style":89},[86,218,219],{"style":96},"    ACME_E001: {",[86,221,222,225,228,231,233,236,239,241,244,247,250,253,255,258,260,263],{"class":88,"style":89},[86,223,224],{"style":153},"      why",[86,226,227],{"style":96},": (",[86,229,19],{"style":230},"color:#953800;--shiki-dark:#FFA657",[86,232,75],{"style":92},[86,234,235],{"style":96}," { ",[86,237,238],{"style":230},"name",[86,240,75],{"style":92},[86,242,243],{"style":146}," string",[86,245,246],{"style":96}," }) ",[86,248,249],{"style":92},"=>",[86,251,252],{"style":103}," `module \"${",[86,254,19],{"style":96},[86,256,257],{"style":103},".",[86,259,238],{"style":96},[86,261,262],{"style":103},"}\" failed to load`",[86,264,209],{"style":96},[86,266,267,270,272,274,276,278,280,282,284,286,288,291,293,295,297,300],{"class":88,"style":89},[86,268,269],{"style":153},"      fix",[86,271,227],{"style":96},[86,273,19],{"style":230},[86,275,75],{"style":92},[86,277,235],{"style":96},[86,279,238],{"style":230},[86,281,75],{"style":92},[86,283,243],{"style":146},[86,285,246],{"style":96},[86,287,249],{"style":92},[86,289,290],{"style":103}," `run \"npm install ${",[86,292,19],{"style":96},[86,294,257],{"style":103},[86,296,238],{"style":96},[86,298,299],{"style":103},"}\"`",[86,301,209],{"style":96},[86,303,304],{"class":88,"style":89},[86,305,306],{"style":96},"    },",[86,308,309,312,315],{"class":88,"style":89},[86,310,311],{"style":96},"    ACME_W001: { why: ",[86,313,314],{"style":103},"\"the legacy option is deprecated\"",[86,316,317],{"style":96}," },",[86,319,320],{"class":88,"style":89},[86,321,322],{"style":96},"  },",[86,324,325,328,330],{"class":88,"style":89},[86,326,327],{"style":96},"  reporters: [",[86,329,54],{"style":153},[86,331,332],{"style":96},"(out)],",[86,334,335],{"class":88,"style":89},[86,336,337],{"style":96},"});",[86,339],{"class":88,"style":89},[86,341,342,345,348,351,354,357,360,363,366],{"class":88,"style":89},[86,343,344],{"style":96},"diagnostics.",[86,346,347],{"style":153},"ACME_E001",[86,349,350],{"style":96},"({ name: ",[86,352,353],{"style":103},"\"left-pad\"",[86,355,356],{"style":96},", sources: [",[86,358,359],{"style":103},"\"src\u002Fapp.ts:12:3\"",[86,361,362],{"style":96},"] }, { method: ",[86,364,365],{"style":103},"\"error\"",[86,367,368],{"style":96}," });",[86,370,371,373,376],{"class":88,"style":89},[86,372,344],{"style":96},[86,374,375],{"style":153},"ACME_W001",[86,377,378],{"style":96},"();",[86,380,381,384,387,390,393],{"class":88,"style":89},[86,382,383],{"style":96},"process.exitCode ",[86,385,386],{"style":92},"=",[86,388,389],{"style":96}," out.",[86,391,392],{"style":153},"end",[86,394,378],{"style":96},[19,396,397,398,401],{},"The per-call ",[27,399,400],{},"method"," sets the severity, as nostics' console reporter routes it:",[403,404,405,419],"table",{},[406,407,408],"thead",{},[409,410,411,416],"tr",{},[412,413,414],"th",{},[27,415,400],{},[412,417,418],{},"Severity",[420,421,422,434,446],"tbody",{},[409,423,424,430],{},[425,426,427],"td",{},[27,428,429],{},"error",[425,431,432],{},[27,433,429],{},[409,435,436,442],{},[425,437,438,441],{},[27,439,440],{},"warn"," or none",[425,443,444],{},[27,445,440],{},[409,447,448,453],{},[425,449,450],{},[27,451,452],{},"log",[425,454,455],{},[27,456,457],{},"info",[19,459,460,461,75],{},"A coding agent gets, with exit code ",[27,462,463],{},"1",[77,465,467],{"language":466,"class":81,"wrap":13},"text",[27,468,470,108,475,108,480],{"class":469},"language-text",[86,471,472],{"class":88,"style":89},[86,473,474],{},"acme build: failed. 1 error, 1 warning.",[86,476,477],{"class":88,"style":89},[86,478,479],{},"error ACME_E001 src\u002Fapp.ts:12:3 module \"left-pad\" failed to load. fix: run \"npm install left-pad\"",[86,481,482],{"class":88,"style":89},[86,483,484],{},"warn ACME_W001 the legacy option is deprecated",[19,486,487],{},"A person at a terminal gets:",[77,489,490],{"language":466,"class":81,"wrap":13},[27,491,492,108,497,108,502,108,507,108,512],{"class":469},[86,493,494],{"class":88,"style":89},[86,495,496],{},"✖ 1 error, 1 warning",[86,498,499],{"class":88,"style":89},[86,500,501],{},"",[86,503,504],{"class":88,"style":89},[86,505,506],{},"error ACME_E001  src\u002Fapp.ts:12:3  module \"left-pad\" failed to load",[86,508,509],{"class":88,"style":89},[86,510,511],{},"╰▶ fix: run \"npm install left-pad\"",[86,513,514],{"class":88,"style":89},[86,515,516],{},"warn  ACME_W001  the legacy option is deprecated",[19,518,519,520,523,524,526,527,530,531,534,535,538,539,542,543,545,546,549],{},"The docs links from ",[27,521,522],{},"docsBase"," are in every record. ",[27,525,466],{}," shows them as a ",[27,528,529],{},"see:"," branch with ",[27,532,533],{},"--full",", ",[27,536,537],{},"agent"," as ",[27,540,541],{},"docs:"," with ",[27,544,533],{},", and ",[27,547,548],{},"json"," always:",[77,551,552],{"language":548,"class":81,"wrap":13},[27,553,555,108,560,108,573,108,585,108,608,108,630,108,642,108,654,108,666,108,678,108,686,108,691,108,696],{"class":554},"language-json",[86,556,557],{"class":88,"style":89},[86,558,559],{"style":96},"{",[86,561,562,566,569,571],{"class":88,"style":89},[86,563,565],{"style":564},"color:#116329;--shiki-dark:#7EE787","  \"severity\"",[86,567,568],{"style":96},": ",[86,570,365],{"style":103},[86,572,209],{"style":96},[86,574,575,578,580,583],{"class":88,"style":89},[86,576,577],{"style":564},"  \"code\"",[86,579,568],{"style":96},[86,581,582],{"style":103},"\"ACME_E001\"",[86,584,209],{"style":96},[86,586,587,590,592,595,598,601,603,606],{"class":88,"style":89},[86,588,589],{"style":564},"  \"message\"",[86,591,568],{"style":96},[86,593,594],{"style":103},"\"module ",[86,596,597],{"style":92},"\\\"",[86,599,600],{"style":103},"left-pad",[86,602,597],{"style":92},[86,604,605],{"style":103}," failed to load\"",[86,607,209],{"style":96},[86,609,610,613,615,618,620,623,625,628],{"class":88,"style":89},[86,611,612],{"style":564},"  \"fix\"",[86,614,568],{"style":96},[86,616,617],{"style":103},"\"run ",[86,619,597],{"style":92},[86,621,622],{"style":103},"npm install left-pad",[86,624,597],{"style":92},[86,626,627],{"style":103},"\"",[86,629,209],{"style":96},[86,631,632,635,637,640],{"class":88,"style":89},[86,633,634],{"style":564},"  \"docs\"",[86,636,568],{"style":96},[86,638,639],{"style":103},"\"https:\u002F\u002Facme.dev\u002Ferrors\u002Facme_e001\"",[86,641,209],{"style":96},[86,643,644,647,649,652],{"class":88,"style":89},[86,645,646],{"style":564},"  \"file\"",[86,648,568],{"style":96},[86,650,651],{"style":103},"\"src\u002Fapp.ts\"",[86,653,209],{"style":96},[86,655,656,659,661,664],{"class":88,"style":89},[86,657,658],{"style":564},"  \"line\"",[86,660,568],{"style":96},[86,662,663],{"style":146},"12",[86,665,209],{"style":96},[86,667,668,671,673,676],{"class":88,"style":89},[86,669,670],{"style":564},"  \"column\"",[86,672,568],{"style":96},[86,674,675],{"style":146},"3",[86,677,209],{"style":96},[86,679,680,683],{"class":88,"style":89},[86,681,682],{"style":564},"  \"sources\"",[86,684,685],{"style":96},": [",[86,687,688],{"class":88,"style":89},[86,689,690],{"style":103},"    \"src\u002Fapp.ts:12:3\"",[86,692,693],{"class":88,"style":89},[86,694,695],{"style":96},"  ]",[86,697,698],{"class":88,"style":89},[86,699,700],{"style":96},"}",[48,702,706],{"id":703,"anchor":704},"fromnostics",{"label":705,"icon":53},"Section titled \"fromNostics\"","fromNostics",[19,708,709,712,713,716,717,720,721,723],{},[27,710,711],{},"fromNostics(d, severity = \"warn\")"," converts one diagnostic: a nostics ",[27,714,715],{},"Diagnostic",", its ",[27,718,719],{},"toJSON()",", or any object of that shape. nostics has no level, so you pass the severity, and it defaults to ",[27,722,440],{}," like the console reporter.",[77,725,726],{"language":79,"class":81,"wrap":13},[27,727,728,108,741,108,754,108,756,108,791],{"class":84},[86,729,730,732,735,737,739],{"class":88,"style":89},[86,731,93],{"style":92},[86,733,734],{"style":96}," { Diagnostic } ",[86,736,100],{"style":92},[86,738,104],{"style":103},[86,740,107],{"style":96},[86,742,743,745,748,750,752],{"class":88,"style":89},[86,744,93],{"style":92},[86,746,747],{"style":96}," { fromNostics } ",[86,749,100],{"style":92},[86,751,134],{"style":103},[86,753,107],{"style":96},[86,755],{"class":88,"style":89},[86,757,758,760,763,765,768,771,774,777,780,783,785,788],{"class":88,"style":89},[86,759,143],{"style":92},[86,761,762],{"style":146}," d",[86,764,150],{"style":92},[86,766,767],{"style":92}," new",[86,769,770],{"style":153}," Diagnostic",[86,772,773],{"style":96},"({ code: ",[86,775,776],{"style":103},"\"ACME_E002\"",[86,778,779],{"style":96},", why: ",[86,781,782],{"style":103},"\"config not found\"",[86,784,356],{"style":96},[86,786,787],{"style":103},"\"acme.config.ts:4\"",[86,789,790],{"style":96},"] });",[86,792,793,796,798,800,803,805,808,810,812,815,817],{"class":88,"style":89},[86,794,795],{"style":96},"console.",[86,797,452],{"style":153},[86,799,175],{"style":96},[86,801,802],{"style":146},"JSON",[86,804,257],{"style":96},[86,806,807],{"style":153},"stringify",[86,809,175],{"style":96},[86,811,706],{"style":153},[86,813,814],{"style":96},"(d, ",[86,816,365],{"style":103},[86,818,819],{"style":96},")));",[19,821,822,823,75],{},"It prints the record, ready for ",[27,824,825],{},"out.diagnostic()",[77,827,828],{"language":548,"class":81,"wrap":13},[27,829,830],{"class":554},[86,831,832,834,837,839,841,843,846,848,850,852,855,857,859,861,864,866,869,871,874,876,879,881,884,887,889],{"class":88,"style":89},[86,833,559],{"style":96},[86,835,836],{"style":564},"\"severity\"",[86,838,75],{"style":96},[86,840,365],{"style":103},[86,842,209],{"style":96},[86,844,845],{"style":564},"\"code\"",[86,847,75],{"style":96},[86,849,776],{"style":103},[86,851,209],{"style":96},[86,853,854],{"style":564},"\"message\"",[86,856,75],{"style":96},[86,858,782],{"style":103},[86,860,209],{"style":96},[86,862,863],{"style":564},"\"file\"",[86,865,75],{"style":96},[86,867,868],{"style":103},"\"acme.config.ts\"",[86,870,209],{"style":96},[86,872,873],{"style":564},"\"line\"",[86,875,75],{"style":96},[86,877,878],{"style":146},"4",[86,880,209],{"style":96},[86,882,883],{"style":564},"\"sources\"",[86,885,886],{"style":96},":[",[86,888,787],{"style":103},[86,890,891],{"style":96},"]}",[19,893,894,895,75],{},"The mapping, from ",[22,896,898],{"href":897},"https:\u002F\u002Fgithub.com\u002Floadsheet\u002Freaderly\u002Fblob\u002Fmain\u002Fsrc\u002Fnostics.ts",[27,899,900],{},"src\u002Fnostics.ts",[403,902,903,913],{},[406,904,905],{},[409,906,907,909],{},[412,908,5],{},[412,910,911],{},[27,912,37],{},[420,914,915,928,941,954,969],{},[409,916,917,924],{},[425,918,919,921,922],{},[27,920,27],{},", else ",[27,923,238],{},[425,925,926],{},[27,927,27],{},[409,929,930,937],{},[425,931,932,921,935],{},[27,933,934],{},"message",[27,936,29],{},[425,938,939],{},[27,940,934],{},[409,942,943,950],{},[425,944,945,947,948],{},[27,946,29],{},", when it differs from ",[27,949,934],{},[425,951,952],{},[27,953,29],{},[409,955,956,966],{},[425,957,958,534,960,534,963],{},[27,959,33],{},[27,961,962],{},"docs",[27,964,965],{},"data",[425,967,968],{},"the same fields",[409,970,971,976],{},[425,972,973],{},[27,974,975],{},"sources",[425,977,978,980,981,534,984,986,987],{},[27,979,975],{},", and the first one as ",[27,982,983],{},"file",[27,985,88],{}," and ",[27,988,989],{},"column",[19,991,992,993,996,997,1000,1001,1003,1004,1007,1008,1011,1012,1015],{},"A source in ",[27,994,995],{},"file:line:column"," or ",[27,998,999],{},"file:line"," form gives the location. Any other string becomes ",[27,1002,983],{}," alone, so ",[27,1005,1006],{},"acme.config.ts"," gives ",[27,1009,1010],{},"file: \"acme.config.ts\"",". Windows paths such as ",[27,1013,1014],{},"C:\u002Fa.ts:4:2"," keep their drive letter.",[19,1017,1018,1024],{},[22,1019,1021],{"href":1020},"https:\u002F\u002Fgithub.com\u002Floadsheet\u002Freaderly\u002Fblob\u002Fmain\u002Ftest\u002Fnostics.test.ts",[27,1022,1023],{},"test\u002Fnostics.test.ts"," runs these round trips against nostics itself.",[1026,1028],{"id":50,"depth":1027,"text":54},2,{"id":703,"depth":1027,"text":706},{"path":1030,"title":1031,"description":1032},"\u002Fintegrations\u002Fmarkdown-answers","Markdown answers","Render a command's Markdown answer with @comark\u002Fansi for a person at a terminal, and pass it as is to coding agents, json and jsonl.",1795985395932,"22ea5d7b-bce0-4e3b-bca3-1fbe3722fcf7"]