[{"data":1,"prerenderedAt":521,"buildId":522},["ShallowReactive",2],{"docs:\u002Fintegrations\u002Fprogress":3},{"page":4,"section":16,"document":17,"credits":10,"prev":514,"next":517},{"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},"progress","\u002Fintegrations\u002Fprogress","integrations\u002Fprogress.md","Progress","How out.progress and createProgress show a long step: a live bar on a terminal, a line every 5 seconds in CI and pipes, nothing for agents or JSON.",null,[],"i-lucide-loader","article",true,5,"integrations",{"nodes":18,"toc":508},[19,27,35,167,183,186,276,287,293,296,307,317,324,327,341,347,365,371,385,487],[20,21,22,26],"p",{},[23,24,25],"code",{},"out.progress(label)"," shows that a long step is alive, and decides per reader what that looks like. Progress goes to stderr only, so it never mixes with the answer on stdout.",[28,29,34],"h2",{"id":30,"anchor":31},"outprogress",{"label":32,"icon":33},"Section titled \"out.progress\"","#","out.progress",[36,37,40],"pre",{"language":38,"class":39,"wrap":14},"ts","shiki shiki-themes github-light-default github-dark-default dark:github-dark-default",[23,41,43,76,77,76,114,76,125,76,151,76,156],{"class":42},"language-ts",[44,45,48,52,56,59,63,66,69,73],"span",{"class":46,"style":47},"line","display: inline",[44,49,51],{"style":50},"color:#CF222E;--shiki-dark:#FF7B72","const",[44,53,55],{"style":54},"color:#0550AE;--shiki-dark:#79C0FF"," scan",[44,57,58],{"style":50}," =",[44,60,62],{"style":61},"color:#1F2328;--shiki-dark:#E6EDF3"," out.",[44,64,5],{"style":65},"color:#8250DF;--shiki-dark:#D2A8FF",[44,67,68],{"style":61},"(",[44,70,72],{"style":71},"color:#0A3069;--shiki-dark:#A5D6FF","\"Scanning files\"",[44,74,75],{"style":61},");","\n",[44,78,79,82,85,87,90,93,96,99,102,105,108,111],{"class":46,"style":47},[44,80,81],{"style":50},"for",[44,83,84],{"style":61}," (",[44,86,51],{"style":50},[44,88,89],{"style":61}," [",[44,91,92],{"style":54},"index",[44,94,95],{"style":61},", ",[44,97,98],{"style":54},"file",[44,100,101],{"style":61},"] ",[44,103,104],{"style":50},"of",[44,106,107],{"style":61}," files.",[44,109,110],{"style":65},"entries",[44,112,113],{"style":61},"()) {",[44,115,116,119,122],{"class":46,"style":47},[44,117,118],{"style":50},"  await",[44,120,121],{"style":65}," lint",[44,123,124],{"style":61},"(file);",[44,126,127,130,133,136,139,142,145,148],{"class":46,"style":47},[44,128,129],{"style":61},"  scan.",[44,131,132],{"style":65},"update",[44,134,135],{"style":61},"({ done: index ",[44,137,138],{"style":50},"+",[44,140,141],{"style":54}," 1",[44,143,144],{"style":61},", total: files.",[44,146,147],{"style":54},"length",[44,149,150],{"style":61}," });",[44,152,153],{"class":46,"style":47},[44,154,155],{"style":61},"}",[44,157,158,161,164],{"class":46,"style":47},[44,159,160],{"style":61},"scan.",[44,162,163],{"style":65},"stop",[44,165,166],{"style":61},"();",[20,168,169,172,173,176,177,179,180,182],{},[23,170,171],{},"update({ done, total, doneBytes?, totalBytes? })"," reports how far the step got. ",[23,174,175],{},"stop()"," ends it and clears the line on a terminal. Both do nothing after ",[23,178,175],{},", and ",[23,181,175],{}," is safe to call twice.",[20,184,185],{},"What each reader gets:",[187,188,189,205],"table",{},[190,191,192],"thead",{},[193,194,195,199,202],"tr",{},[196,197,198],"th",{},"Reader",[196,200,201],{},"Format",[196,203,204],{},"Progress on stderr",[206,207,208,222,234,250,262],"tbody",{},[193,209,210,214,219],{},[211,212,213],"td",{},"Terminal",[211,215,216],{},[23,217,218],{},"text",[211,220,221],{},"One line with a bar, rewritten in place",[193,223,224,227,231],{},[211,225,226],{},"CI, pipe",[211,228,229],{},[23,230,218],{},[211,232,233],{},"A plain line every 5 seconds",[193,235,236,239,247],{},[211,237,238],{},"Any",[211,240,241,243,244],{},[23,242,218],{}," with ",[23,245,246],{},"--quiet",[211,248,249],{},"Nothing",[193,251,252,255,260],{},[211,253,254],{},"Coding agent",[211,256,257],{},[23,258,259],{},"agent",[211,261,249],{},[193,263,264,266,274],{},[211,265,238],{},[211,267,268,95,271],{},[23,269,270],{},"json",[23,272,273],{},"jsonl",[211,275,249],{},[20,277,278,279,95,281,283,284,286],{},"Off ",[23,280,218],{},[23,282,132],{}," and ",[23,285,163],{}," do nothing, so the command calls them the same way for every reader.",[28,288,292],{"id":289,"anchor":290},"the-2-second-rule",{"label":291,"icon":33},"Section titled \"The 2-second rule\"","The 2-second rule",[20,294,295],{},"Nothing prints for the first 2 seconds. A step that finishes sooner shows no progress at all. If no update came by then, the label prints alone.",[20,297,298,299,302,303,306],{},"On a terminal, readerly redraws the line at most every 100 ms. With ",[23,300,301],{},"done: 100"," of ",[23,304,305],{},"400"," after 2.5 seconds, it reads:",[36,308,309],{"language":218,"class":39,"wrap":14},[23,310,312],{"class":311},"language-text",[44,313,314],{"class":46,"style":47},[44,315,316],{},"Scanning files  ████████░░░░░░░░░░░░░░░░░░░░░░  25%  ~8s left",[20,318,319,320,323],{},"The bar is up to 30 cells wide. Below 10 cells, the line drops the bar, then shortens the label. The time left appears once a second has passed since the first update and ",[23,321,322],{},"done"," has grown.",[20,325,326],{},"Off a terminal, a line prints every 5 seconds at most, with the counts. The loop above, over 400 files at 25 ms each, prints in CI:",[36,328,329],{"language":218,"class":39,"wrap":14},[23,330,331,76,336],{"class":311},[44,332,333],{"class":46,"style":47},[44,334,335],{},"Scanning files: 80 of 400 files, 20%, ~8s left",[44,337,338],{"class":46,"style":47},[44,339,340],{},"Scanning files: 280 of 400 files, 70%, ~3s left",[28,342,346],{"id":343,"anchor":344},"bytes",{"label":345,"icon":33},"Section titled \"Bytes\"","Bytes",[20,348,349,350,353,354,357,358,360,361,364],{},"With ",[23,351,352],{},"totalBytes",", the share and the time left follow ",[23,355,356],{},"doneBytes"," instead of ",[23,359,322],{},". A download with 1 of 3 files done and 120 MB of 300 MB shows ",[23,362,363],{},"40%",".",[28,366,370],{"id":367,"anchor":368},"createprogress",{"label":369,"icon":33},"Section titled \"createProgress\"","createProgress",[20,372,373,376,377,380,381,384],{},[23,374,375],{},"createProgress(label, options)"," from ",[23,378,379],{},"readerly\u002Fprogress"," is the same line without ",[23,382,383],{},"createOut",". It always prints, so you decide when to call it. Its options:",[187,386,387,400],{},[190,388,389],{},[193,390,391,394,397],{},[196,392,393],{},"Option",[196,395,396],{},"Default",[196,398,399],{},"Meaning",[206,401,402,421,436,453,466],{},[193,403,404,409,414],{},[211,405,406],{},[23,407,408],{},"stderr",[211,410,411],{},[23,412,413],{},"process.stderr",[211,415,416,417,420],{},"Where the line goes. ",[23,418,419],{},"isTTY"," picks the bar or the plain line.",[193,422,423,428,433],{},[211,424,425],{},[23,426,427],{},"now",[211,429,430],{},[23,431,432],{},"Date.now",[211,434,435],{},"The clock, in milliseconds.",[193,437,438,443,448],{},[211,439,440],{},[23,441,442],{},"shortLabel",[211,444,445],{},[23,446,447],{},"label",[211,449,450,451,364],{},"The label for a terminal too narrow for ",[23,452,447],{},[193,454,455,460,463],{},[211,456,457],{},[23,458,459],{},"intro",[211,461,462],{},"none",[211,464,465],{},"A line printed once before the first progress line, off a terminal only.",[193,467,468,473,478],{},[211,469,470],{},[23,471,472],{},"unit",[211,474,475],{},[23,476,477],{},"files",[211,479,480,481,283,483,486],{},"What ",[23,482,322],{},[23,484,485],{},"total"," count, in the plain line.",[20,488,489,491,492,283,495,498,499,507],{},[23,490,34],{}," passes its ",[23,493,494],{},"io.stderr",[23,496,497],{},"io.now",", so a ",[500,501,503,504],"a",{"href":502},"\u002Fintegrations\u002Ftesting","fake ",[23,505,506],{},"Io"," controls the clock in tests.",[509,511,512,513],{"id":30,"depth":510,"text":34},2,{"id":289,"depth":510,"text":292},{"id":343,"depth":510,"text":346},{"id":367,"depth":510,"text":370},{"path":502,"title":515,"description":516},"Testing your CLI","Test one readerly command as a terminal, a coding agent, GitHub Actions and --format json with a fake Io, prompts answered, and golden files per reader.",{"path":518,"title":519,"description":520},"\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.",1795985395582,"22ea5d7b-bce0-4e3b-bca3-1fbe3722fcf7"]