@visulima/vis 1.0.0-alpha.10 → 1.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +185 -42
- package/LICENSE.md +586 -0
- package/README.md +26 -4
- package/dist/config/index.d.ts +1739 -0
- package/dist/config/index.js +1 -0
- package/dist/generate/index.d.ts +1 -1
- package/dist/packem_chunks/applyDefaults.js +2 -0
- package/dist/packem_chunks/bin.js +232 -60
- package/dist/packem_chunks/doctor-probe.js +2 -0
- package/dist/packem_chunks/fix.js +11 -53
- package/dist/packem_chunks/handler.js +1 -1
- package/dist/packem_chunks/handler10.js +2 -1
- package/dist/packem_chunks/handler11.js +1 -1
- package/dist/packem_chunks/handler12.js +5 -2
- package/dist/packem_chunks/handler13.js +1 -1
- package/dist/packem_chunks/handler14.js +18 -5
- package/dist/packem_chunks/handler15.js +20 -1
- package/dist/packem_chunks/handler16.js +1 -20
- package/dist/packem_chunks/handler17.js +1 -1
- package/dist/packem_chunks/handler18.js +1 -1
- package/dist/packem_chunks/handler19.js +1 -1
- package/dist/packem_chunks/handler2.js +2 -1
- package/dist/packem_chunks/handler20.js +5 -1
- package/dist/packem_chunks/handler21.js +1 -1
- package/dist/packem_chunks/handler22.js +1 -5
- package/dist/packem_chunks/handler23.js +5 -1
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler25.js +3 -5
- package/dist/packem_chunks/handler26.js +1 -1
- package/dist/packem_chunks/handler27.js +1 -3
- package/dist/packem_chunks/handler28.js +7 -1
- package/dist/packem_chunks/handler29.js +22 -6
- package/dist/packem_chunks/handler3.js +4 -2
- package/dist/packem_chunks/handler30.js +3 -23
- package/dist/packem_chunks/handler31.js +1 -3
- package/dist/packem_chunks/handler32.js +2 -2
- package/dist/packem_chunks/handler33.js +24 -23
- package/dist/packem_chunks/handler34.js +2 -2
- package/dist/packem_chunks/handler35.js +3 -19
- package/dist/packem_chunks/handler36.js +22 -428
- package/dist/packem_chunks/handler37.js +428 -22
- package/dist/packem_chunks/handler38.js +20 -20
- package/dist/packem_chunks/handler39.js +21 -21
- package/dist/packem_chunks/handler4.js +2 -4
- package/dist/packem_chunks/handler40.js +22 -3
- package/dist/packem_chunks/handler41.js +6 -10
- package/dist/packem_chunks/handler42.js +5 -153
- package/dist/packem_chunks/handler43.js +10 -42
- package/dist/packem_chunks/handler44.js +153 -3
- package/dist/packem_chunks/handler45.js +25 -27
- package/dist/packem_chunks/handler46.js +3 -0
- package/dist/packem_chunks/handler47.js +27 -0
- package/dist/packem_chunks/handler48.js +42 -0
- package/dist/packem_chunks/handler5.js +8 -2
- package/dist/packem_chunks/handler6.js +1 -13
- package/dist/packem_chunks/handler7.js +1 -8
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/handler9.js +1 -1
- package/dist/packem_chunks/heal-accept.js +10 -0
- package/dist/packem_chunks/heal.js +14 -0
- package/dist/packem_chunks/index.js +3 -3
- package/dist/packem_chunks/tar.js +3 -0
- package/dist/packem_shared/ai-analysis-hm8d2W7z.js +67 -0
- package/dist/packem_shared/{ai-cache-Bynt6Y9x.js → ai-cache-DoiF80AR.js} +1 -1
- package/dist/packem_shared/ai-fix-nn4zOE95.js +43 -0
- package/dist/packem_shared/cache-directory-CwHlJhgx.js +1 -0
- package/dist/packem_shared/dependency-scan-COr5n63B.js +2 -0
- package/dist/packem_shared/{docker-BcfqH4Av.js → docker-D6OGr5_S.js} +1 -1
- package/dist/packem_shared/{failure-log-DqYen0LC.js → failure-log-iUVLf6ts.js} +1 -1
- package/dist/packem_shared/flakiness-D9wf0t56.js +1 -0
- package/dist/packem_shared/giget-CcEy_Elm.js +2 -0
- package/dist/packem_shared/index-DH-5hsrC.js +1 -0
- package/dist/packem_shared/otel-DxDUPJJH.js +6 -0
- package/dist/packem_shared/otelPlugin-CQq6poq8.js +1 -0
- package/dist/packem_shared/registry-CkubDdiY.js +2 -0
- package/dist/packem_shared/run-summary-utils-BfBvjzhY.js +1 -0
- package/dist/packem_shared/{runtime-check-CGHal8SO.js → runtime-check-BXZ43CBW.js} +1 -1
- package/dist/packem_shared/{selectors-CfH9ZY08.js → selectors-BylODRiM.js} +1 -1
- package/dist/packem_shared/toolchain-BgBOUHII.js +5 -0
- package/dist/packem_shared/typosquats-CcZl99B1.js +1 -0
- package/dist/packem_shared/verify-Baj5mFJ7.js +1 -0
- package/dist/packem_shared/vis-update-app-D1jl0UZZ.js +1 -0
- package/index.js +54 -53
- package/package.json +34 -26
- package/schemas/project.schema.json +739 -299
- package/schemas/vis-config.schema.json +3383 -278
- package/skills/vis/SKILL.md +96 -0
- package/templates/buildkite-ci/.buildkite/pipeline.yml.tera +85 -0
- package/templates/buildkite-ci/template.yml +20 -0
- package/dist/errors/index.d.ts +0 -26
- package/dist/errors/index.js +0 -1
- package/dist/packem_chunks/config.js +0 -2
- package/dist/packem_shared/VisConfigCycleError-CAYNC7d-.js +0 -1
- package/dist/packem_shared/VisConfigError-B5LP1zRf.js +0 -1
- package/dist/packem_shared/VisConfigLoadError-CeqBSd2Z.js +0 -2
- package/dist/packem_shared/VisConfigNotFoundError-DZ9KC527.js +0 -5
- package/dist/packem_shared/VisUpdateApp-D-L4_-Iu.js +0 -1
- package/dist/packem_shared/_commonjsHelpers-D6W6KoPK.js +0 -1
- package/dist/packem_shared/ai-analysis-CGuy7dfE.js +0 -67
- package/dist/packem_shared/cache-directory-D72ZEag2.js +0 -1
- package/dist/packem_shared/catalog-BVPerCwG.js +0 -12
- package/dist/packem_shared/dependency-scan-Du0tBu64.js +0 -2
- package/dist/packem_shared/flakiness-DSIHZGBT.js +0 -1
- package/dist/packem_shared/run-summary-utils-C24Aaf9E.js +0 -1
- package/dist/packem_shared/target-merge-DNa-6eWu.js +0 -1
- package/dist/packem_shared/toolchain-DQfTQY8E.js +0 -5
- package/dist/packem_shared/typosquats-DOR8izpX.js +0 -1
|
@@ -1,42 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
`),"formatTargetList"),Vr=me(async r=>{if(r.length===0||!process.stdin.isTTY||!process.stdout.isTTY)return;const e=xr({input:process.stdin,output:process.stdout});try{process.stdout.write(`Available targets:
|
|
3
|
-
`);for(const[n,d]of r.entries())process.stdout.write(` ${String(n+1).padStart(2," ")}. ${d}
|
|
4
|
-
`);process.stdout.write(`
|
|
5
|
-
`)
|
|
6
|
-
|
|
7
|
-
`).map(x=>x.replace(/\r$/,"")):[];return!s&&(m==="running"||m==="pending")?i(u,{borderBottomTitle:v,borderColor:P,borderStyle:l,borderTopRightTitle:O,borderTopTitle:y,flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:i(u,{alignItems:"center",flexGrow:1,justifyContent:"center",children:i(o,{dimColor:!0,children:"Waiting for task output..."})})}):a(u,{borderBottomTitle:v,borderColor:t?"yellow":P,borderStyle:l,borderTopRightTitle:O,borderTopTitle:y,flexDirection:"column",flexGrow:1,children:[i(u,{flexGrow:1,flexShrink:1,paddingY:1,children:i(Et,{flexGrow:1,followOutput:!0,paddingX:2,ref:n,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:S.map((x,R)=>i(o,{children:x},String(R)))})}),t&&i(u,{flexShrink:0,justifyContent:"center",paddingX:1,children:i(o,{bold:!0,color:"yellow",children:"INTERACTIVE — keystrokes forwarded to task — Esc to exit"})})]})},"OutputPanel");var co=Object.defineProperty,Ee=M((r,e)=>co(r,"name",{value:e,configurable:!0}),"u$1");const Gt=6,Ht=8,Ut=10,uo=Ee(r=>r==="running"||r==="pending"?Ft:r==="local-cache"||r==="local-cache-kept-existing"?"Local":r==="remote-cache"?"Remote":je,"getCacheLabel"),yt=Ee((r,e)=>e[0]===r?"[1]":e[1]===r?"[2]":"","getPinLabel"),vt=Ee(({compact:r,isSelected:e,pinLabel:t,row:s})=>{const{status:n,taskId:d}=s,c=e?">":" ";let h;if(n==="running")h=a(o,{bold:!0,color:"white",children:[" ",i(Rr,{type:"dots"})," "]});else if(n==="pending")h=i(o,{bold:!0,color:"gray",children:" · "});else{const{color:p,icon:l}=Ie(n);h=a(o,{bold:!0,color:p,children:[" ",l," "]})}let m=Ft;return n!=="running"&&n!=="pending"?m=s.duration===void 0?je:we(s.duration):n==="running"&&s.elapsed!==void 0&&(m=we(s.elapsed)),a(u,{children:[i(o,{children:c}),i(u,{width:Gt,children:h}),a(u,{flexGrow:1,children:[i(o,{bold:e,inverse:e,children:d}),t?i(o,{dimColor:!0,children:` ${t}`}):null]}),!r&&i(u,{justifyContent:"flex-end",width:Ht,children:i(o,{dimColor:!ve(n),children:uo(n)})}),!r&&i(u,{justifyContent:"flex-end",width:Ut,children:i(o,{dimColor:n==="pending",children:m})})]})},"TaskListRow"),bt=Ee(({compact:r,filterActive:e,filterText:t,focused:s,headerStatus:n,parallelSlots:d=3,pinnedTaskIds:c,rows:h,scrollRef:m,selectedIndex:p,title:l})=>{const P=n==="error"?"red":n==="success"?"green":s?"white":"gray",y=h[p]?.taskId,O=h.filter(x=>x.status==="running"),v=O.length>0||h.some(x=>x.status==="pending"),S=[];if(v)for(let x=0;x<d;x++){const R=O[x];R?S.push(i(vt,{compact:r,isSelected:R.taskId===y,pinLabel:yt(R.taskId,c),row:R},`par-${R.taskId}`)):S.push(a(u,{children:[i(o,{children:" "}),i(u,{width:Gt,children:i(o,{bold:!0,color:"gray",children:" · "})}),i(o,{dimColor:!0,children:"Waiting for task..."})]},`par-empty-${String(x)}`))}return a(u,{borderColor:P,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[a(u,{flexShrink:0,gap:1,paddingX:1,children:[i(o,{bold:!0,inverse:!0,children:" VIS "}),i(o,{children:l}),!r&&a(u,{flexGrow:1,gap:0,justifyContent:"flex-end",children:[i(u,{justifyContent:"flex-end",width:Ht,children:i(o,{dimColor:!0,children:"Cache"})}),i(u,{justifyContent:"flex-end",width:Ut,children:i(o,{dimColor:!0,children:"Duration"})})]})]}),i(Et,{flexGrow:1,flexShrink:1,paddingLeft:1,paddingY:1,ref:m,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:h.map(x=>i(vt,{compact:r,isSelected:x.taskId===y,pinLabel:yt(x.taskId,c),row:x},x.taskId))}),v&&i(u,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexDirection:"column",flexShrink:0,paddingLeft:1,paddingY:1,children:S}),e&&a(u,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexShrink:0,paddingX:1,children:[i(o,{bold:!0,color:"white",children:"/ "}),i(o,{children:t}),i(o,{inverse:!0,children:" "})]})]})},"TaskListPanel");var ho=Object.defineProperty,fo=M((r,e)=>ho(r,"name",{value:e,configurable:!0}),"y");const Tt=40,Ct=10,St=100,po=fo(({autoExitSeconds:r,parallelSlots:e,projectNames:t,stdinRegistry:s,store:n,targets:d,tasks:c})=>{const{exit:h}=Mr(),{columns:m,rows:p}=jr(),l=Fr(n.subscribe,n.getSnapshot),[P,y]=mt(!1),O=$e(null),v=$e(null),S=$e(null),[x,R]=mt(!1),j=$e({list:0,splitList:0,splitOutput:0}),J=Le(()=>{l.viewMode==="list"?j.current.list=v.current?.getScrollOffset()??0:l.viewMode==="split"&&(j.current.splitList=v.current?.getScrollOffset()??0,j.current.splitOutput=S.current?.getScrollOffset()??0)},[l.viewMode]),E=Le(g=>{setTimeout(()=>{if(g==="list"){const f=j.current.list;v.current?.scrollTo(f)}else if(g==="split"){const f=j.current.splitList;f>0?v.current?.scrollTo(f):v.current?.scrollTo(Math.max(0,n.getSnapshot().selectedIndex-2)),S.current?.scrollTo(j.current.splitOutput)}},0)},[n]),Z=$e(!1);Ae(()=>{l.done&&!Z.current&&(Z.current=!0,r>0&&R(!0)),!l.done&&Z.current&&(Z.current=!1,R(!1))},[l.done,r]);const D=gt(()=>{let g=l.rows;if(l.statusFilter!=="all"&&(g=g.filter(f=>l.statusFilter==="failed"?f.status==="failure":l.statusFilter==="running"?f.status==="running"||f.status==="pending":l.statusFilter==="passed"?f.status==="success"||ve(f.status):!0)),l.filterText){const f=l.filterText.toLowerCase();g=g.filter(k=>k.taskId.toLowerCase().includes(f))}return g},[l.rows,l.filterText,l.statusFilter]),z=gt(()=>l.rows.filter(g=>g.status==="running").length,[l.rows]),ee=(D[l.selectedIndex]??null)?.taskId??null,L=l.pinnedTaskIds[0]??ee,b=L?l.rows.find(g=>g.taskId===L):null,H=L?l.outputs.get(L)??"":"",_=ze(t,d,c),N=l.done?`Completed ${_} (${we((l.endTime??Date.now())-l.startTime)})`:`Running ${_}...`,W=l.done?l.failed>0?"error":"success":"running",fe=Le(g=>{v.current?.scrollTo(Math.max(0,g-2))},[]);if(Ae(()=>{l.interactiveMode&&b?.status!=="running"&&n.setInteractiveMode(!1)},[l.interactiveMode,b?.status,n]),Ae(()=>{if(!L)return;let g=m;l.viewMode==="split"&&m>=St?g=m-Math.floor(m*.4)-2:(l.viewMode==="split"||l.viewMode==="fullscreen")&&(g=m-2);const f=Math.max(1,p-4);s.get(L)?.resize?.(g,f)},[m,p,l.viewMode,L]),pt((g,f)=>{if(f.escape){n.setInteractiveMode(!1);return}if(!L)return;const k=s.get(L);if(!k){n.setInteractiveMode(!1);return}if(f.return)k.write("\r");else if(f.upArrow)k.write("\x1B[A");else if(f.downArrow)k.write("\x1B[B");else if(f.rightArrow)k.write("\x1B[C");else if(f.leftArrow)k.write("\x1B[D");else if(f.backspace)k.write("");else if(f.delete)k.write("\x1B[3~");else if(f.tab)k.write(" ");else if(f.home)k.write("\x1B[H");else if(f.end)k.write("\x1B[F");else if(f.pageUp)k.write("\x1B[5~");else if(f.pageDown)k.write("\x1B[6~");else if(f.ctrl&&g){const re=g.toUpperCase().codePointAt(0);re!==void 0&&re>=65&&re<=90&&k.write(String.fromCodePoint(re-64))}else g&&k.write(g)},{isActive:l.interactiveMode}),pt((g,f)=>{if(g==="c"&&f.ctrl){h();return}if(!x){if(P){f.escape||g==="?"?y(!1):g==="q"?(y(!1),R(!0)):f.downArrow||g==="j"?O.current?.scrollBy(1):f.upArrow||g==="k"?O.current?.scrollBy(-1):f.pageDown?O.current?.scrollBy(5):f.pageUp?O.current?.scrollBy(-5):f.home?O.current?.scrollToTop():f.end&&O.current?.scrollToBottom();return}if(g==="?"){y(!0);return}if(g==="q"){R(!0);return}if(g==="r"&&l.done){n.requestRerun();return}if(g==="R"&&l.done){const k=D[l.selectedIndex];k?.status==="failure"&&n.requestRetry(k.taskId);return}if(g==="F"&&!l.filterActive){const k=["all","failed","running","passed"],re=k.indexOf(l.statusFilter);n.setStatusFilter(k[(re+1)%k.length]);return}if(l.filterActive){if(f.escape){n.setFilterActive(!1);return}if(f.return){n.setFilterActive(!1);return}if(f.backspace){n.setFilter(l.filterText.slice(0,-1));return}if(g&&!f.ctrl&&!f.meta){n.setFilter(l.filterText+g);return}return}if(g==="i"&&b?.status==="running"&&(l.viewMode==="fullscreen"||l.viewMode==="split"&&l.focusedPanel==="output")){n.setInteractiveMode(!0);return}if(l.viewMode==="fullscreen"){if(f.escape){n.setViewMode("split"),E("split");return}if(f.downArrow||g==="j"){S.current?.scrollBy(1);return}if(f.upArrow||g==="k"){S.current?.scrollBy(-1);return}if(f.pageDown||f.ctrl&&g==="d"){S.current?.scrollBy(12);return}if(f.pageUp||f.ctrl&&g==="u"){S.current?.scrollBy(-12);return}if(f.home){S.current?.scrollToTop();return}if(f.end){S.current?.scrollToBottom();return}return}if(l.viewMode==="split"){if(f.tab){const k=l.focusedPanel==="tasks"?"output":"tasks";n.setFocusedPanel(k);return}if(l.focusedPanel==="output"){if(f.escape){n.setFocusedPanel("tasks");return}if(f.return){J(),n.setViewMode("fullscreen");return}if(f.downArrow||g==="j"){S.current?.scrollBy(1);return}if(f.upArrow||g==="k"){S.current?.scrollBy(-1);return}if(f.pageDown||f.ctrl&&g==="d"){S.current?.scrollBy(12);return}if(f.pageUp||f.ctrl&&g==="u"){S.current?.scrollBy(-12);return}if(f.home){S.current?.scrollToTop();return}if(f.end){S.current?.scrollToBottom();return}return}if(f.escape){n.setViewMode("list"),E("list");return}if(f.return){n.setFocusedPanel("output");return}}if(l.viewMode==="list"||l.viewMode==="split"&&l.focusedPanel==="tasks"){if(f.downArrow||g==="j"){const k=Math.min(l.selectedIndex+1,Math.max(0,D.length-1));n.setSelectedIndex(k),fe(k);return}if(f.upArrow||g==="k"){const k=Math.max(l.selectedIndex-1,0);n.setSelectedIndex(k),fe(k);return}if(f.return&&l.viewMode==="list"){J(),j.current.splitList=0,j.current.splitOutput=0,n.setViewMode("split"),n.setFocusedPanel("output"),E("split");return}if(g==="/"){n.setFilterActive(!0);return}if(g==="1"&&ee){n.pinTask(0,ee);return}if(g==="2"&&ee){n.pinTask(1,ee);return}if(g==="0"){n.clearPins();return}f.escape&&l.filterText&&n.setFilter("")}}},{isActive:!l.interactiveMode}),m<Tt||p<Ct)return i(u,{alignItems:"center",height:p,justifyContent:"center",width:m,children:a(o,{color:"yellow",children:["Terminal too small (",m,"x",p,"). Minimum:"," ",Tt,"x",Ct]})});const F=a(u,{gap:1,children:[l.succeeded>0&&a(o,{bold:!0,color:"green",children:["✓"," ",l.succeeded]}),l.failed>0&&a(o,{bold:!0,color:"red",children:["✗"," ",l.failed]}),z>0&&a(o,{color:"cyan",children:["◷"," ",z]}),a(o,{dimColor:!0,children:[l.rows.length," ","total"]}),l.statusFilter!=="all"&&a(o,{color:"yellow",children:["[",l.statusFilter,"]"]})]});let te;if(l.viewMode==="fullscreen")te=[a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"Esc"}),i(o,{dimColor:!0,children:"BACK"})]},"esc"),a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"↑↓"}),i(o,{dimColor:!0,children:"SCROLL"})]},"scroll"),a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"^u ^d"}),i(o,{dimColor:!0,children:"PAGE"})]},"page"),...b?.status==="running"?[a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"i"}),i(o,{dimColor:!0,children:"INPUT"})]},"i")]:[],a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"q"}),i(o,{dimColor:!0,children:"QUIT"})]},"q")];else if(l.done){const g=D[l.selectedIndex]?.status==="failure";te=[a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"q"}),i(o,{dimColor:!0,children:"QUIT"})]},"q"),a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"r"}),i(o,{dimColor:!0,children:"RERUN"})]},"r"),...g?[a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"R"}),i(o,{dimColor:!0,children:"RETRY"})]},"R")]:[],a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"?"}),i(o,{dimColor:!0,children:"HELP"})]},"?"),a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"↑↓"}),i(o,{dimColor:!0,children:"NAV"})]},"nav"),a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"F"}),i(o,{dimColor:!0,children:"FILTER"})]},"F"),a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"⏎"}),i(o,{dimColor:!0,children:l.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else l.viewMode==="split"&&l.focusedPanel==="output"?te=[a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"q"}),i(o,{dimColor:!0,children:"QUIT"})]},"q"),a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"Esc"}),i(o,{dimColor:!0,children:"BACK"})]},"esc"),a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"↑↓"}),i(o,{dimColor:!0,children:"SCROLL"})]},"scroll"),...b?.status==="running"?[a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"i"}),i(o,{dimColor:!0,children:"INPUT"})]},"i")]:[],a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"⏎"}),i(o,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"Tab"}),i(o,{dimColor:!0,children:"PANEL"})]},"tab"),a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"?"}),i(o,{dimColor:!0,children:"HELP"})]},"?")]:te=[a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"q"}),i(o,{dimColor:!0,children:"QUIT"})]},"q"),a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"?"}),i(o,{dimColor:!0,children:"HELP"})]},"?"),a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"↑↓"}),i(o,{dimColor:!0,children:"NAV"})]},"nav"),a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"/"}),i(o,{dimColor:!0,children:"FILTER"})]},"/"),a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"F"}),i(o,{dimColor:!0,children:"STATUS"})]},"F"),a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"⏎"}),i(o,{dimColor:!0,children:l.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...l.viewMode==="split"?[a(u,{gap:1,children:[i(o,{bold:!0,color:"white",children:"Tab"}),i(o,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const K=a(u,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,justifyContent:"space-between",children:[i(u,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:te}),i(u,{flexShrink:0,paddingX:1,children:F})]}),ne=a(Er,{backgroundColor:"#1e1e1e",footer:a(o,{dimColor:!0,children:[i(o,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",i(o,{bold:!0,color:"white",children:"?"}),"/",i(o,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:O,title:"KEYBOARD SHORTCUTS",visible:P,width:52,children:[a(u,{flexDirection:"column",marginBottom:1,children:[a(u,{marginBottom:1,children:[i(o,{dimColor:!0,children:"── "}),i(o,{bold:!0,color:"white",children:"NAVIGATION"})]}),a(u,{children:[i(u,{width:24,children:a(o,{children:[a(o,{bold:!0,color:"white",children:[" ","↑","/k"]}),i(o,{dimColor:!0,children:" Move up"})]})}),a(o,{children:[a(o,{bold:!0,color:"white",children:[" ","↓","/j"]}),i(o,{dimColor:!0,children:" Move down"})]})]}),a(o,{children:[a(o,{bold:!0,color:"white",children:[" ","Tab"]}),i(o,{dimColor:!0,children:" Switch panel (split)"})]}),a(o,{children:[a(o,{bold:!0,color:"white",children:[" ","Esc"]}),i(o,{dimColor:!0,children:" Back / close"})]}),a(o,{children:[a(o,{bold:!0,color:"white",children:[" ","Enter"]}),i(o,{dimColor:!0,children:" Show output / fullscreen"})]})]}),a(u,{flexDirection:"column",marginBottom:1,children:[a(u,{marginBottom:1,children:[i(o,{dimColor:!0,children:"── "}),i(o,{bold:!0,color:"white",children:"VIEWS"})]}),a(o,{children:[a(o,{bold:!0,color:"white",children:[" ","Enter"]}),a(o,{dimColor:!0,children:[" ","List"," ","→"," ","Split"," ","→"," ","Fullscreen"]})]}),a(o,{children:[a(o,{bold:!0,color:"white",children:[" ","Esc"]}),a(o,{dimColor:!0,children:[" ","Fullscreen"," ","→"," ","Split"," ","→"," ","List"]})]})]}),a(u,{flexDirection:"column",marginBottom:1,children:[a(u,{marginBottom:1,children:[i(o,{dimColor:!0,children:"── "}),i(o,{bold:!0,color:"white",children:"ACTIONS"})]}),a(u,{children:[i(u,{width:24,children:a(o,{children:[a(o,{bold:!0,color:"white",children:[" ","/"]}),i(o,{dimColor:!0,children:" Filter by text"})]})}),a(o,{children:[a(o,{bold:!0,color:"white",children:[" ","F"]}),i(o,{dimColor:!0,children:" Filter by status"})]})]}),a(u,{children:[i(u,{width:24,children:a(o,{children:[a(o,{bold:!0,color:"white",children:[" ","1"]}),i(o,{dimColor:!0,children:"/"}),i(o,{bold:!0,color:"white",children:"2"}),i(o,{dimColor:!0,children:" Pin to output pane"})]})}),a(o,{children:[a(o,{bold:!0,color:"white",children:[" ","0"]}),i(o,{dimColor:!0,children:" Clear pins"})]})]}),a(u,{children:[i(u,{width:24,children:a(o,{children:[a(o,{bold:!0,color:"white",children:[" ","r"]}),i(o,{dimColor:!0,children:" Rerun all (done)"})]})}),a(o,{children:[a(o,{bold:!0,color:"white",children:[" ","R"]}),i(o,{dimColor:!0,children:" Retry failed task"})]})]}),a(o,{children:[a(o,{bold:!0,color:"white",children:[" ","i"]}),i(o,{dimColor:!0,children:" Interactive input (running task)"})]})]}),a(u,{flexDirection:"column",marginBottom:1,children:[a(u,{marginBottom:1,children:[i(o,{dimColor:!0,children:"── "}),i(o,{bold:!0,color:"white",children:"SCROLLING"}),i(o,{dimColor:!0,children:" (output panel)"})]}),a(u,{children:[i(u,{width:24,children:a(o,{children:[a(o,{bold:!0,color:"white",children:[" ","↑","/k"]}),i(o,{dimColor:!0,children:" Scroll up"})]})}),a(o,{children:[a(o,{bold:!0,color:"white",children:[" ","↓","/j"]}),i(o,{dimColor:!0,children:" Scroll down"})]})]}),a(u,{children:[i(u,{width:24,children:a(o,{children:[a(o,{bold:!0,color:"white",children:[" ","^u"]}),i(o,{dimColor:!0,children:" Page up"})]})}),a(o,{children:[a(o,{bold:!0,color:"white",children:[" ","^d"]}),i(o,{dimColor:!0,children:" Page down"})]})]}),a(u,{children:[i(u,{width:24,children:a(o,{children:[a(o,{bold:!0,color:"white",children:[" ","Home"]}),i(o,{dimColor:!0,children:" Top"})]})}),a(o,{children:[a(o,{bold:!0,color:"white",children:[" ","End"]}),i(o,{dimColor:!0,children:" Bottom"})]})]})]}),a(u,{flexDirection:"column",children:[a(u,{marginBottom:1,children:[i(o,{dimColor:!0,children:"── "}),i(o,{bold:!0,color:"white",children:"GENERAL"})]}),a(u,{children:[i(u,{width:24,children:a(o,{children:[a(o,{bold:!0,color:"white",children:[" ","q"]}),i(o,{dimColor:!0,children:" Quit"})]})}),a(o,{children:[a(o,{bold:!0,color:"white",children:[" ","?"]}),i(o,{dimColor:!0,children:" Toggle help"})]})]})]})]}),de=i(ar,{autoExitSeconds:r>0?r:3,onCancel:M(()=>{R(!1)},"onCancel"),visible:x});if(l.viewMode==="fullscreen")return a(u,{flexDirection:"column",height:p,width:m,children:[i(u,{flexGrow:1,children:i(kt,{duration:b?.duration??b?.elapsed,focused:!0,interactiveMode:l.interactiveMode,output:H,scrollRef:S,status:b?.status,taskId:L})}),K,de,ne]});if(l.viewMode==="split"){const g=m>=St,f=i(bt,{compact:!0,filterActive:l.filterActive,filterText:l.filterText,focused:l.focusedPanel==="tasks",headerStatus:W,parallelSlots:e,pinnedTaskIds:l.pinnedTaskIds,rows:D,scrollRef:v,selectedIndex:l.selectedIndex,title:N}),k=i(kt,{duration:b?.duration??b?.elapsed,focused:l.focusedPanel==="output",interactiveMode:l.interactiveMode,output:H,scrollRef:S,showFullscreenHint:!0,status:b?.status,taskId:L});if(g){const ke=Math.floor(m*.4);return a(u,{flexDirection:"column",height:p,width:m,children:[a(u,{flexDirection:"row",flexGrow:1,children:[i(u,{width:ke,children:f}),i(u,{flexGrow:1,children:k})]}),K,de,ne]})}const re=Math.floor(p*.45);return a(u,{flexDirection:"column",height:p,width:m,children:[i(u,{height:re,children:f}),i(u,{flexGrow:1,children:k}),K,de,ne]})}return a(u,{flexDirection:"column",height:p,width:m,children:[i(u,{flexGrow:1,children:i(bt,{filterActive:l.filterActive,filterText:l.filterText,focused:!0,headerStatus:W,parallelSlots:e,pinnedTaskIds:l.pinnedTaskIds,rows:D,scrollRef:v,selectedIndex:l.selectedIndex,title:N})}),K,de,ne]})},"VisTaskRunnerApp");var mo=Object.defineProperty,ye=M((r,e)=>mo(r,"name",{value:e,configurable:!0}),"n$3");const go=ye(r=>{const{args:e,autoExit:t=!1,outputStyle:s="normal",projectNames:n,stdinRegistry:d,tasks:c}=r,h=new Re(c),m=typeof e.parallel=="number"?e.parallel:3,p=t===!0?3:typeof t=="number"?t:0;let l,P;const y=new Promise(E=>{P=E});let O;const v=ye(()=>{O&&(clearInterval(O),O=void 0)},"cleanup"),S=ye(()=>{if(d){for(const E of d.values())E.kill?.();d.clear()}},"killAllPtyProcesses"),x=ye(()=>{v(),J(),S(),process.stdout.write("\x1B[?1049l\x1B[?25h"),l?.cleanup(),process.exit(1)},"onSignal"),R=ye(()=>{const E=h.getSnapshot(),Z=we(Date.now()-E.startTime),D=E.rows.filter(L=>L.status==="failure").map(L=>L.taskId),z=process.stdout.columns||80;process.stdout.write(`
|
|
8
|
-
`)
|
|
9
|
-
`)
|
|
10
|
-
`);const
|
|
11
|
-
`),D.length>0&&s!=="quiet")for(const L of D){const b=E.outputs.get(L);if(b?.trim()){const H=X(A.createElement(o,null,`
|
|
12
|
-
`,A.createElement(o,{bold:!0,color:"red"},` ${He} vis run ${L}`)),{columns:z});process.stdout.write(`${H}
|
|
13
|
-
|
|
14
|
-
`);const _=b.trim().split(`
|
|
15
|
-
`).map(N=>` ${N}`).join(`
|
|
16
|
-
`);process.stdout.write(`${_}
|
|
17
|
-
`)}}},"printExitSummary");let j;const J=ye(()=>{j&&(clearInterval(j),j=void 0)},"clearKeepAlive");return{lifeCycle:{endCommand(){v(),h.markDone(),j||(j=setInterval(()=>{},1e3)),process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume())},endTasks(E){h.endTasks(E)},printTaskTerminalOutput(E,Z,D){h.getSnapshot().outputs.has(E.id)||h.addOutput(E.id,D)},startCommand(){process.on("SIGINT",x),process.on("SIGTERM",x),j||(j=setInterval(()=>{},1e3)),process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume()),l=Or(A.createElement(po,{autoExitSeconds:p,parallelSlots:m,projectNames:n,stdinRegistry:d??new Map,store:h,targets:e.targets,tasks:c}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}),l.waitUntilExit().then(()=>{J(),S(),process.removeListener("SIGINT",x),process.removeListener("SIGTERM",x),R(),P()},()=>{J(),S(),process.removeListener("SIGINT",x),process.removeListener("SIGTERM",x),P()})},startTasks(E){h.startTasks(E),O||(O=setInterval(()=>{h.tick()},100))}},renderIsDone:y,store:h}},"createDynamicOutputRenderer");var wo=Object.defineProperty,Ye=M((r,e)=>wo(r,"name",{value:e,configurable:!0}),"l$1");const ko=Ye(r=>r==="quiet"?"quiet":"normal","parseOutputStyle"),yo=Ye((r,e)=>{const t=r.overrides.visOptions;return t?.outputStyle==="normal"||t?.outputStyle==="quiet"?t.outputStyle:e},"resolveTaskOutputStyle");class vo{static{M(this,"StaticOutputLifeCycle")}static{Ye(this,"StaticOutputLifeCycle")}#e;#r;#o;#i=[];#t=[];#n=new Map;#s;#l;#a=0;constructor(e){this.#e=e.projectNames,this.#r=e.args.targets,this.#o=e.tasks,this.#s=e.logReporter,this.#l=e.outputStyle??"normal"}startCommand(){this.#a=Date.now();const e=process.stdout.columns||80,t=`Running ${ze(this.#e,this.#r,this.#o)}`,s=X(A.createElement(Ne,{title:t,variant:"info"}),{columns:e});process.stdout.write(s);const n=this.#o[0],d=n?.overrides?Object.entries(n.overrides).filter(([c])=>c!=="command"):[];if(d.length>0){process.stdout.write(`
|
|
18
|
-
With additional flags:
|
|
19
|
-
`);for(const[c,h]of d)process.stdout.write(`${Kr(" ",c,h)}
|
|
20
|
-
`)}process.stdout.write(`
|
|
21
|
-
`)}startTasks(e){const t=process.stdout.columns||80;for(const s of e){const n=X(A.createElement(o,null,A.createElement(o,{dimColor:!0},">"),` ${s.id}`),{columns:t});process.stdout.write(`${n}
|
|
22
|
-
`)}}endTasks(e){const t=process.stdout.columns||80;for(const s of e){this.#n.set(s.task.id,s),s.status==="failure"?this.#i.push(s):ve(s.status)&&this.#t.push(s);const n=Nt(s.status),d=s.startTime&&s.endTime?` (${we(s.endTime-s.startTime)})`:"",c=ve(s.status)?" [cache]":"",h=X(A.createElement(o,null,n,` ${s.task.id}`,c?A.createElement(o,{color:"cyan"},c):null,d?A.createElement(o,{dimColor:!0},d):null),{columns:t});process.stdout.write(`${h}
|
|
23
|
-
`)}}printTaskTerminalOutput(e,t,s){if(!(yo(e,this.#l)==="quiet"&&(t==="success"||ve(t)))){if(this.#s){this.#s.printTaskTerminalOutput(e,t,s);return}so(e.id,t,s)}}endCommand(){const e=we(Date.now()-this.#a),t=this.#o.filter(d=>!this.#n.has(d.id)).map(d=>d.id);process.stdout.write(`
|
|
24
|
-
`);const s=process.stdout.columns||80,n=X(A.createElement(Dt,{cached:this.#t.length,failed:this.#i.length,failedIds:this.#i.map(d=>d.task.id),projectNames:this.#e,skippedIds:t.length>0?t:void 0,succeeded:this.#n.size-this.#i.length-this.#t.length,targets:this.#r,tasks:this.#o,took:e}),{columns:s});process.stdout.write(`${n}
|
|
25
|
-
`)}}var bo=Object.defineProperty,Oe=M((r,e)=>bo(r,"name",{value:e,configurable:!0}),"t");const To=Oe(()=>Pr(),"createVisHooks"),Co=Oe(async(r,e)=>{if(!(!e||e.length===0))for(const t of e){if(t.hooks)for(const[s,n]of Object.entries(t.hooks)){const d=Array.isArray(n)?n:[n];for(const c of d)r.hook(s,c)}t.setup&&await t.setup(r)}},"registerPlugins");class So{static{M(this,"HookableLifeCycle")}static{Oe(this,"HookableLifeCycle")}#e;#r;#o=new Map;constructor(e,t){this.#e=e,this.#r=t}startTasks(e){for(const t of e)this.#o.set(t.id,t),this.#i("task:before",t)}endTasks(e){for(const t of e)this.#o.delete(t.task.id),this.#i("task:after",t.task,t),t.status==="failure"?this.#i("task:failure",t.task,t):$o(t.status)&&this.#i("task:cacheHit",t.task,t)}printCacheMiss(e,t){this.#i("task:cacheMiss",e,t)}onTaskStdout(e,t){this.#i("task:stdout",e,t)}onTaskStderr(e,t){this.#i("task:stderr",e,t)}#i(e,...t){Promise.resolve(this.#e.callHook(e,...t)).catch(s=>{if(this.#r)try{this.#r(e,s)}catch{}})}}const $o=Oe(r=>r==="local-cache"||r==="local-cache-kept-existing"||r==="remote-cache","isCacheStatus");var xo=Object.defineProperty,Fe=M((r,e)=>xo(r,"name",{value:e,configurable:!0}),"o");const Io=Fe(async r=>{if(process.env.VIS_NO_SHELL_HISTORY||Lr()==="win32")return;const e=process.env.SHELL;if(!e)return;const t=Ar(e);try{if(t==="zsh"){await Ro(r);return}if(t==="bash"){await Mo(r);return}t==="fish"&&await jo(r)}catch{}},"appendToShellHistory"),Ro=Fe(async r=>{const e=process.env.HISTFILE??We(process.env.ZDOTDIR??_e(),".zsh_history"),t=`: ${Math.floor(Date.now()/1e3)}:0;${r}
|
|
26
|
-
`;await Ue(e,t)},"writeZshHistory"),Mo=Fe(async r=>{const e=process.env.HISTFILE??We(_e(),".bash_history");await Ue(e,`${r}
|
|
27
|
-
`)},"writeBashHistory"),jo=Fe(async r=>{const e=We(_e(),".local","share","fish","fish_history"),t=`- cmd: ${r.replaceAll("\\","\\\\").replaceAll(`
|
|
28
|
-
`,String.raw`\n`)}
|
|
29
|
-
when: ${Math.floor(Date.now()/1e3)}
|
|
30
|
-
`;await Ue(e,t)},"writeFishHistory");var Eo=Object.defineProperty,Be=M((r,e)=>Eo(r,"name",{value:e,configurable:!0}),"e");const Oo=Be(r=>{const{killGracePeriodMs:e=5e3,onTimeout:t,sendSignal:s,timeoutMs:n}=r;if(n<=0)return{cancel:Be(()=>{},"cancel")};const d=Math.max(e,0);let c;const h=setTimeout(()=>{t?.(),s("SIGTERM"),d>0&&(c=setTimeout(()=>{s("SIGKILL")},d))},n);return{cancel:Be(()=>{clearTimeout(h),c&&clearTimeout(c)},"cancel")}},"scheduleTimeoutKill");var Fo=Object.defineProperty,be=M((r,e)=>Fo(r,"name",{value:e,configurable:!0}),"l");const Po=[/node_modules(?:\/|$)/,/\.git(?:\/|$)/,/\.vis(?:\/|$)/,/\.task-runner(?:\/|$)/],$t=be((r,e)=>{const t=new Set,s=new Set;for(const[,c]of r){const h=c.task.hashDetails?.nodes;if(h)for(const m of Object.keys(h))t.add(m),s.add(Dr(Lt(e,m)))}const n=[...s].sort(),d=[];for(const c of n)d.some(h=>c===h||c.startsWith(`${h}/`))||d.push(c);return{directories:d,files:t}},"collectTrackedWatchTargets"),Lo=be((r,e,t)=>{const s=new Set;for(const n of r){const d=Lt(e,n);for(const c of t)if(d===c||d.startsWith(`${c}/`)){const h=Br(c,d);h.length>0&&s.add(h)}}return n=>{const d=n.replaceAll("\\","/");return s.has(d)}},"createTrackedFileFilter"),Ao=be(r=>{const e=r.replaceAll("\\","/");return Po.some(t=>t.test(e))},"shouldIgnore"),xt=be(r=>{const{debounceMs:e=150,filter:t,onChange:s,paths:n}=r,d=[];let c=new Set,h;const m=be(()=>{h=void 0;const p=[...c];c=new Set,p.length!==0&&Promise.resolve(s(p)).catch(l=>{console.error("[vis watch] onChange handler failed:",l)})},"flush");for(const p of n)try{const l=Nr(p,{recursive:!0},(P,y)=>{y&&(Ao(y)||t&&!t(y)||(c.add(y),h&&clearTimeout(h),h=setTimeout(m,e)))});d.push(l)}catch(l){console.warn(`[vis watch] unable to watch ${p}: ${l.message}`)}return{close:be(()=>{h&&clearTimeout(h);for(const p of d)try{p.close()}catch{}},"close")}},"startWatcher");var Do=Object.defineProperty,Bo=M((r,e)=>Do(r,"name",{value:e,configurable:!0}),"n$1");const No=Bo((r,e)=>{const t=e?.trim();if(!t)return{filter:void 0,tasks:[...r]};const s=t.toLowerCase();return{filter:t,tasks:r.filter(n=>n.target.project.toLowerCase().includes(s))}},"applyProjectFilter");var qo=Object.defineProperty,he=M((r,e)=>qo(r,"name",{value:e,configurable:!0}),"n");const Go=[""," Watch keybinds:"," r, Enter rerun"," a rerun all (clear filter)"," p filter by project name"," q, Ctrl+C quit"," h, ? show this help",""].join(`
|
|
31
|
-
`),Ho=he(r=>{r.write(`${Go}
|
|
32
|
-
`)},"writeHelp"),Uo=he(async(r,e)=>{e.write("filter projects (empty to cancel) > ");const t=r,s=t.isRaw===!0;if(s)try{t.setRawMode?.(!1)}catch{}return await new Promise(n=>{let d="";const c=he(h=>{d+=typeof h=="string"?h:h.toString("utf8");const m=d.indexOf(`
|
|
33
|
-
`);if(m===-1)return;const p=d.slice(0,m).replace(/\r$/,"").trim();if(r.off("data",c),s)try{t.setRawMode?.(!0)}catch{}n(p.length>0?p:void 0)},"onData");r.on("data",c)})},"defaultPromptFilter"),_o=he(r=>{const{handlers:e}=r,t=r.input??process.stdin,s=r.output??process.stdout,n=r.promptFilter??Uo;if(!t||t.isTTY===!1)return{close:he(()=>{},"close")};Ir(t);const d=t.isRaw===!0;try{t.setRawMode?.(!0)}catch{return{close:he(()=>{},"close")}}typeof t.resume=="function"&&t.resume();let c=!1;const h=he(async p=>{if(p.ctrl===!0&&p.name==="c"){await e.onQuit();return}if(!c)switch(p.name){case"?":case"h":{await e.onHelp();break}case"a":{await e.onClearFilter();break}case"p":{c=!0;try{const l=await n(t,s);l===void 0?s.write(`filter cancelled.
|
|
34
|
-
`):await e.onFilter(l)}finally{c=!1}break}case"q":{await e.onQuit();break}case"r":{await e.onRerun();break}case"return":{await e.onRerun();break}}},"dispatch"),m=he((p,l)=>{h(l).catch(P=>{s.write(`[vis watch] keybind handler failed: ${P.message}
|
|
35
|
-
`)})},"onKeypress");return t.on("keypress",m),{close:he(()=>{if(t.off("keypress",m),!d)try{t.setRawMode?.(!1)}catch{}const p=t;if(typeof p.pause=="function")try{p.pause()}catch{}},"close")}},"installKeybinds");var Wo=Object.defineProperty,C=M((r,e)=>Wo(r,"name",{value:e,configurable:!0}),"i");const Ke="VIS_AFFECTED_FILES",_t=C((r,e,t)=>t||!e?r:e.startsWith("/")?e:`${r}/${e}`,"resolveCwd"),It=C(async(r,e,t,s)=>{const n=r.map(d=>{const c=d.overrides.command;if(!c)return;const h=d.overrides.visOptions,m=_t(e,d.projectRoot,!!h?.runFromWorkspaceRoot),p=h?.envFile?jt(m,h.envFile):{},l=t&&(h?.affectedFiles==="env"||h?.affectedFiles==="both")?{[Ke]:t.join(`
|
|
36
|
-
`)}:{};return{command:c,cwd:m,env:{INIT_CWD:s,...p,...l},name:d.id}}).filter(d=>d!==void 0);n.length!==0&&await Ge(n,{killOthers:["failure"]})},"runPersistentTasks"),qe=256*1024;class Vo{static{M(this,"Me")}static{C(this,"OutputRingBuffer")}#e;#r="";#o=!1;constructor(e){this.#e=e}append(e){this.#r+=e,this.#r.length>this.#e&&(this.#r=this.#r.slice(-this.#e),this.#o=!0)}toString(){return this.#o?`[...output truncated, showing last ${Math.round(this.#e/1024)}KB...]
|
|
37
|
-
${this.#r}`:this.#r}}const Wt=C(r=>{const e=r.overrides.visOptions;if(e&&typeof e=="object")return e},"getTaskOptions"),Qe=C(r=>`'${r.replaceAll("'",String.raw`'\''`)}'`,"singleQuoteEscape"),zo=C((r,e,t)=>{if(!e||e.length===0||t===!1||t===void 0)return r;if(t==="args"||t==="both"){const s=e.map(Qe).join(" ");return`${r} ${s}`}return r},"buildAffectedFilesArgs"),Vt="visForwardedArgs",Yo=C((r,e)=>{const t=e.overrides[Vt];if(!Array.isArray(t)||t.length===0)return r;const s=t.map(Qe).join(" ");return`${r} ${s}`},"appendForwardedArgs"),Ko=C(async(r,e,t)=>{if(!e)return t();const s=r.get(e)??Promise.resolve();let n;const d=new Promise(h=>{n=h}),c=s.then(()=>d);r.set(e,c),await s;try{return await t()}finally{n(),r.get(e)===c&&r.delete(e)}},"withMutex"),Qo=C(r=>{let e=Math.max(0,Math.floor(r));return{claim(t){const s=Math.max(0,Math.min(t,e));return e-=s,s},get remaining(){return e}}},"createRetryBudget"),Xo=C((r,e,t)=>{const s=`${e}\0${typeof t=="string"?t:String(t)}`,n=r.get(s);if(n)return n;const d=jt(e,t);return r.set(s,d),d},"loadEnvFileCached"),Rt=C(r=>{const e=new Map;return async(t,s)=>{const{affectedFiles:n,currentOs:d,initCwd:c,lifeCycle:h,mutexPool:m,onOutput:p,onOutputReplace:l,retryBudget:P,stdinRegistry:y,workspaceRoot:O}=r,v=Wt(t),S=_t(O,s.cwd??t.projectRoot,v?.runFromWorkspaceRoot===!0),x=t.overrides.command;if(!x)return{code:0,terminalOutput:`No command configured for ${t.target.project}:${t.target.target}`};const R=Yo(x,t),j=zo(R,n,v?.affectedFiles),J=cr(v,d),E=J?`${J} -c ${Qe(j)}`:j,Z=v?.envFile?Xo(e,S,v.envFile):void 0,D={};n&&n.length>0&&(v?.affectedFiles==="env"||v?.affectedFiles==="both")&&(D[Ke]=n.join(`
|
|
38
|
-
`));const z={INIT_CWD:c,...Z,...s.env,...D},ee=v?.pty===!0,L=!!y,b=L||ee;b&&(t.cache=!1);const H=b?void 0:new Vo(qe),_=b?new Mt(qe):void 0;let N;const W=C(F=>{if(F.kind==="started"&&(N=F.kill,F.write&&y&&y.set(t.id,{kill:F.kill,resize:F.resize,write:F.write})),(F.kind==="stdout"||F.kind==="stderr")&&F.text!==void 0)if(F.kind==="stdout"?h?.onTaskStdout?.(t,F.text):h?.onTaskStderr?.(t,F.text),_)_.write(F.text),L&&l?.(t.id,_.toString());else{const te=`${F.text}
|
|
39
|
-
`;H.append(te),p?.(t.id,te)}F.kind==="close"&&y&&y.delete(t.id)},"onEvent"),fe=C(async()=>{const F=v?.retryCount??0,te=v?.retryDelay,K=P?P.claim(F):F,ne=typeof v?.timeout=="number"&&v.timeout>0?v.timeout:0,de=typeof v?.killGracePeriodMs=="number"&&v.killGracePeriodMs>=0?v.killGracePeriodMs:5e3;let g=!1;const f=Oo({killGracePeriodMs:de,onTimeout:C(()=>{g=!0},"onTimeout"),sendSignal:C(Te=>{N?.(Te)},"sendSignal"),timeoutMs:ne});let k;try{k=await Ge([{command:E,cwd:S,env:z,name:t.id,...b?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}],{killOthers:["failure"],onEvent:W,...K>0?{restart:{delay:te??"exponential",tries:K}}:{}})}finally{f.cancel()}const re=k.closeEvents[0],ke=_?_.toString():H.toString();return g?{code:124,terminalOutput:`${ke}
|
|
40
|
-
[timeout] Task "${t.id}" exceeded ${ne}ms budget.
|
|
41
|
-
`}:{code:re?.exitCode??1,terminalOutput:ke}},"runOnce");return m?Ko(m,v?.mutex,fe):fe()}},"createConcurrentExecutor"),Jo=C(r=>{if(!r||r.trim().length===0)return;const e=Number.parseFloat(r);return!Number.isFinite(e)||e<=0?{invalid:r}:{value:Math.floor(e)}},"parseEnvConcurrency"),Zo=C(async(r,e)=>{const t=await er(r);if(!t){e.warn("No previous run recorded yet. Run a task at least once to populate .task-runner/last-summary.json.");return}const s=(t.duration/1e3).toFixed(2);if(e.info(""),e.info(`Last run — ${t.startTime} (${s}s)`),e.info(""),e.info(` Total: ${String(t.stats.total)}`),e.info(` Succeeded: ${String(t.stats.succeeded)}`),e.info(` Cached: ${String(t.stats.cached)}`),e.info(` Failed: ${String(t.stats.failed)}`),e.info(` Skipped: ${String(t.stats.skipped)}`),e.info(""),t.stats.failed>0){const d=t.tasks.filter(c=>c.exitCode!==void 0&&c.exitCode!==0);e.info("Failed tasks:");for(const c of d){const h=c.duration??0;e.info(` × ${c.taskId} (exit ${String(c.exitCode??-1)}, ${h}ms)`)}e.info("")}const n=[...t.tasks].filter(d=>typeof d.duration=="number").sort((d,c)=>(c.duration??0)-(d.duration??0)).slice(0,5);if(n.length>0){e.info("Slowest tasks:");for(const d of n)e.info(` ${d.taskId.padEnd(40)} ${String(d.duration??0).padStart(6)}ms [${d.cacheStatus}]`);e.info("")}},"renderLastRunSummary"),gi=C(async({argument:r,logger:e,options:t,runtime:s,visConfig:n,workspaceRoot:d})=>{if(!d)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const c=d;if(t.lastDetails===!0){await Zo(c,e);return}const h=process.cwd(),m=await dr(c),{config:p,packageJsons:l,projectOptions:P,workspace:y}=ur(c,n,m),O=hr(c,y,l);let v=r[0];if(!v){const w=wt(y);if(process.stdout.isTTY&&process.stdin.isTTY){const T=await Vr(w);if(!T){e.info("No target selected.");return}v=T,await Io(`vis run ${T}`)}else{e.info("Available targets:"),e.info(""),e.info(Wr(w)),e.info(""),e.info("Usage: vis run <target>");return}}if(p.constraints&&!t.skipConstraints){const w=tr(O,p.constraints);if(w.length>0){for(const T of w)e.error(`[${T.rule}] ${T.message}`);throw new Error(`${w.length} project constraint violation(s) found. Use --skip-constraints to bypass.`)}}if(t.affected){const w=[v];t.parallel!==void 0&&w.push(`--parallel=${String(t.parallel)}`),t.cache||w.push("--no-cache"),t.query&&w.push(`--query=${String(t.query)}`),await s.runCommand("affected",{argv:w});return}const S=await Sr(v,y,process.cwd(),c),x=Gr(P),R=Hr(S.target,x);R!==S.target&&e.debug?.(`Resolved alias "${S.target}" → "${R}"`);let j=S.projects;const J=r.slice(1).map(String);if(t.projects){const w=new Set(t.projects.split(",").map(T=>T.trim()));if(j=j.filter(T=>w.has(T)),j.length===0)throw new Error(`No matching projects found for: ${String(t.projects)}`)}if(t.query&&(j=$r(j,y,t.query),j.length===0)){e.info(`Query "${String(t.query)}" matched no projects.`);return}const E=fr(),Z=process.env[Ke],D=Z?Z.split(`
|
|
42
|
-
`).filter(Boolean):void 0,z=[],ee=new Map;for(const w of j){const T=P.get(w)?.[R];if(!T)continue;const $=T.options;if(!$?.internal){if(!pr($,!!ht)){e.debug?.(`Skipping ${w}:${R} — runInCI filter`);continue}z.push(w),ee.set(w,T)}}if(z.length===0){const w=wt(y),T=Object.entries(y.projects).filter(([,$])=>$.targets?.[R]!==void 0).map(([$])=>$);if(e.error(`No projects have the "${R}" target.`),T.length>0){e.info(""),e.info(`Target "${R}" exists in these projects but was filtered out:`);for(const $ of T.slice(0,5))e.info(` - ${$}`);T.length>5&&e.info(` …and ${T.length-5} more`)}else{const $=At(R,w,3);$.length>0&&(e.info(""),e.info($.length===1?`Did you mean "${$[0]}"?`:`Did you mean one of: ${$.map(q=>`"${q}"`).join(", ")}?`)),e.info(""),e.info("Run `vis run` without arguments to see all available targets.")}return}const L=t.pty===!0;let b=z.map(w=>{const T=y.projects[w],$=ee.get(w),q={project:w,target:R},G=`${w}:${R}`,ue=L?{...$.options,pty:$.options?.pty??!0}:$.options;return{cache:$.cache,id:G,outputs:$.outputs??[],overrides:{command:$.command,...J.length>0?{[Vt]:J}:{},...ue?{visOptions:ue}:{}},parallelism:$.parallelism,projectRoot:T?.root,target:q}});const H=[],_=[];for(const w of b)Wt(w)?.persistent?(w.cache=!1,H.push(w)):_.push(w);b=_;const N=rr(t.partition);if(N&&(b=or.partitionTasks(b,N),e.info(`Partition ${N.index}/${N.total}: running ${b.length} task(s)`),b.length===0)){e.info("No tasks assigned to this partition.");return}const W=ir(b,{projectGraph:O,targetDefaults:p.targetDefaults,workspace:y});if(t.dryRun){const w=Object.keys(W.tasks).length,T=W.roots.length;e.info(`Execution plan (${String(w)} task(s), ${String(T)} root(s)):`),e.info("");const $=new Set,q=C((G,ue)=>{if($.has(G))return;$.add(G);for(const ge of W.dependencies[G]??[])q(ge,ue+1);const se=W.tasks[G],oe=" ".repeat(ue+1);e.info(`${oe}${G}${se?.cache===!1?" (no-cache)":""}`)},"walkPlan");for(const G of W.roots)q(G,0);H.length>0&&(e.info(""),e.info(` + ${String(H.length)} persistent task(s) (run after graph completes)`)),e.info("");return}await Cr(c,p.toolchain,{error:C(w=>{e.error(w)},"error"),info:C(w=>{e.info(w)},"info"),warn:C(w=>{e.warn(w)},"warn")},!!t.skipToolchain);const fe=Date.now(),F=To(),te=C((w,T)=>{const $=T instanceof Error?T.message:String(T);e.warn(`Plugin error in ${w}: ${$}`)},"onHookError");await Co(F,p.plugins);const K=typeof t.profile=="string"?t.profile:void 0,ne=C(async w=>{if(!K)return;const T=ct(w,W,fe),$=K.startsWith("/")?K:`${c}/${K}`;await nr(T,$),e.info(`Profile written to ${K}`)},"maybeWriteProfile"),de=p.taskRunnerOptions??{},g=mr(c,t.cacheDir,de.cacheDirectory,p.sharedWorktreeCache),f=gr(g,c,p.branchScopedCache),k=Jo(process.env.VIS_RUN_CONCURRENCY_LIMIT);k&&"invalid"in k&&e.warn(`VIS_RUN_CONCURRENCY_LIMIT=${k.invalid} is not a positive number; falling back to default concurrency.`);const re=k&&"value"in k?k.value:void 0,ke=t.parallel??re??3,Te={dryRun:t.dryRun??!1,parallel:ke,skipNxCache:!t.cache,summarize:t.summarize??!1,...de,cacheDirectory:f},zt=process.stdout.isTTY&&!ht,Yt=p.tui?.autoExit??!1,Xe={args:{parallel:Te.parallel,targets:[R]},autoExit:Yt,projectNames:z,tasks:b},Je=typeof t.retryBudget=="number"?t.retryBudget:void 0,Ze=Je===void 0?void 0:Qo(Je),et=new So(F,te),tt=new wr(c),rt=ko(typeof t.outputStyle=="string"?t.outputStyle.toLowerCase():void 0);if(await F.callHook("run:before",{tasks:b,workspaceRoot:c}),zt){const w=new Map,T=go({...Xe,outputStyle:rt,stdinRegistry:w}),{lifeCycle:$,store:q}=T,G=new dt([$,et,tt]),ue=Rt({affectedFiles:D,currentOs:E,initCwd:h,lifeCycle:G,mutexPool:new Map,onOutput:C((I,B)=>{q.addOutput(I,B)},"onOutput"),onOutputReplace:C((I,B)=>{q.setOutput(I,B)},"onOutputReplace"),retryBudget:Ze,stdinRegistry:w,workspaceRoot:c});let se="rerun",oe=null,ge=new Map;for(;se!=="quit";){if(se==="rerun")ge=await ut(b,Te,{lifeCycle:G,projectGraph:O,taskExecutor:ue,taskGraph:W,workspaceRoot:c});else if(se==="retry"&&oe){const I=b.find(Y=>Y.id===oe),B=I?.overrides.command;if(I&&B){const Y=I.projectRoot??c,pe=Y.startsWith("/")?Y:`${c}/${Y}`;G.startTasks?.([I]);const ie=new Mt(qe),le=(await Ge([{command:B,cwd:pe,name:I.id,ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}],{onEvent:C(U=>{U.kind==="started"&&U.write&&w.set(I.id,{kill:U.kill,resize:U.resize,write:U.write}),(U.kind==="stdout"||U.kind==="stderr")&&U.text&&(ie.write(U.text),q.setOutput(I.id,ie.toString())),U.kind==="close"&&w.delete(I.id)},"onEvent")})).closeEvents[0];G.endTasks?.([{code:le?.exitCode??1,status:le?.exitCode===0?"success":"failure",task:I,terminalOutput:q.getSnapshot().outputs.get(I.id)}])}else I&&G.endTasks?.([{code:1,status:"failure",task:I,terminalOutput:`No command configured for ${I.id}`}]);oe=null,q.markDone()}se=await new Promise(I=>{const B=q.subscribe(()=>{const Y=q.getSnapshot();Y.rerunRequested&&(q.acknowledgeRerun(),B(),I("rerun")),Y.retryTaskId&&(oe=q.acknowledgeRetry(),B(),I("retry"))});T.renderIsDone.then(()=>{B(),I("quit")},()=>{B(),I("quit")})})}await T.renderIsDone,await F.callHook("run:after",ge),await ne(ge),H.length>0&&!t.failFast&&await It(H,c,D,h)}else{const w=new Map,T=typeof t.log=="string"?t.log.toLowerCase():"",$=T==="labeled"||T==="grouped"||T==="interleaved"?T:void 0,q=$?sr($):void 0,G=new dt([new vo({...Xe,logReporter:q,outputStyle:rt}),et,tt]),ue=Rt({affectedFiles:D,currentOs:E,initCwd:h,lifeCycle:G,mutexPool:w,retryBudget:Ze,workspaceRoot:c}),se=C(async()=>{const I=Date.now(),B=await ut(b,Te,{lifeCycle:G,projectGraph:O,taskExecutor:ue,taskGraph:W,workspaceRoot:c}),Y=Date.now()-I;if(t.summarize){const ae=ct(B,W,fe);await lr(ae,c)}let pe=!1;for(const[,ae]of B)ae.status==="failure"&&(pe=!0);const ie=kr(B,Y),le=yr(c),U=vr(c,Y,le);return e.info(""),e.info(` ${ie}${U?` ${U}`:""}`),{hasFailure:pe,results:B,runHistory:le}},"runOnce"),oe=await se();await F.callHook("run:after",oe.results),await ne(oe.results);const{hasFailure:ge}=oe;if(t.watch){const I=z.map(V=>{const Q=y.projects[V]?.root;if(Q)return Q.startsWith("/")?Q:`${c}/${Q}`}).filter(V=>V!==void 0),B=b;let Y;const pe=C(V=>{const Q=No(B,V);return Y=Q.filter,b=Q.tasks,Q.tasks.length},"applyFilter");let ie=!1,le=oe.results;const U=C(()=>{const V=$t(le,c);if(V.directories.length>0&&V.files.size>0){const Q=Lo(V.files,c,V.directories);return{handle:xt({filter:Q,onChange:ot,paths:V.directories}),mode:"tracked"}}return{handle:xt({onChange:ot,paths:I}),mode:"roots"}},"buildHandle");let ae;const ot=C(async V=>{if(!ie){ie=!0;try{e.info(`Change detected in ${V.length} file(s), rerunning…`),le=(await se()).results,ae?.close(),ae=U().handle}finally{ie=!1}}},"onChangeHandler"),it=U();ae=it.handle;const Kt=it.mode==="tracked"?`Watching ${String($t(le,c).files.size)} tracked file(s)`:`Watching ${String(I.length)} project root(s)`;e.info(`${Kt} — edit a file to rerun, press h for keybinds, q to quit.`);const Pe=C(async()=>{if(!ie){ie=!0;try{if(b.length===0){e.info("No tasks match the active filter — press a to clear it.");return}le=(await se()).results,ae?.close(),ae=U().handle}finally{ie=!1}}},"triggerRerun");await new Promise(V=>{let Q=!1,nt;const st=C(()=>{lt()},"onSigint"),lt=C(()=>{Q||(Q=!0,nt?.close(),process.off("SIGINT",st),ae?.close(),V())},"exit");process.on("SIGINT",st),nt=_o({handlers:{onClearFilter:C(async()=>{const Ce=pe(void 0);e.info(`Filter cleared — running ${String(Ce)} task(s).`),await Pe()},"onClearFilter"),onFilter:C(async Ce=>{const Qt=Y,at=pe(Ce);if(at===0){e.info(`Filter "${Ce}" matched no projects — keeping previous filter.`),pe(Qt);return}e.info(`Filter "${Ce}" matched ${String(at)} task(s).`),await Pe()},"onFilter"),onHelp:C(()=>{Ho(process.stdout)},"onHelp"),onQuit:C(()=>{lt()},"onQuit"),onRerun:Pe}})});return}if(ge){if(t.flaky!==!1){const I=br(c,{minRuns:2},oe.runHistory);if(I.length>0){e.info(""),e.info("Flaky tasks (based on historical runs):"),e.info("");for(const B of Tr(I))e.info(` ${B}`);e.info("")}}throw new Error("Some tasks failed.")}H.length>0&&!t.failFast&&await It(H,c,D,h)}},"execute");export{Qo as createRetryBudget,gi as default};
|
|
1
|
+
var Dt=Object.defineProperty;var D=(e,t)=>Dt(e,"name",{value:t,configurable:!0});import{createRequire as Ot}from"node:module";import{green as we,yellow as ze,dim as b,red as Re,bold as ae,cyan as Te}from"@visulima/colorize";import{findPackageManagerSync as at}from"@visulima/package";import{join as te,isAbsolute as Ft,resolve as ct}from"@visulima/path";import{Box as h,Text as n,ScrollView as Mt,Spinner as dt,Tabs as zt,Tab as jt,ScrollBar as Et,useApp as Bt,useWindowSize as Lt,useInput as _t,Dialog as Ut,render as Vt}from"@visulima/tui";import{B as qe,an as Xe,F as Le,A as ut,u as Ht,g as ht,V as pt,S as Gt,b as Yt,U as Kt,p as u,ah as j,s as Jt,h as qt}from"./bin.js";import Xt,{useSyncExternalStore as Wt,useState as xe,useEffect as Be,useRef as We,useMemo as Pe,useCallback as Qe}from"react";import{X as ii}from"../packem_shared/xxh3-DrAUNq4n.js";import{isAccessibleSync as Fe,readJsonSync as gt,ensureDirSync as ri}from"@visulima/fs";import{findVisConfigFile as ni}from"./applyDefaults.js";import{x as et,A as ft,L as oi,F as si,T as li,I as ai,a as ci,U as di}from"./handler40.js";import{c as ui}from"../packem_shared/runtime-check-BXZ43CBW.js";import{f as hi,l as pi,s as gi}from"../packem_shared/dependency-scan-COr5n63B.js";import{jsxs as a,jsx as r,Fragment as fi}from"react/jsx-runtime";import{u as mi}from"../packem_shared/use-measured-height-DjYgUOKk.js";import{readYamlSync as yi}from"@visulima/fs/yaml";import{s as ki}from"../packem_shared/verify-Baj5mFJ7.js";const Nt=Ot(import.meta.url),Ce=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ue=D(e=>{if(typeof Ce<"u"&&Ce.versions&&Ce.versions.node){const[t,i]=Ce.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return Ce.getBuiltinModule(e)}return Nt(e)},"__cjs_getBuiltinModule"),{statSync:Qt,rmSync:Ze,writeFileSync:Zt,readFileSync:ei}=Ue("node:fs"),{homedir:ti}=Ue("node:os"),{spawnSync:mt}=Ue("node:child_process");var wi=Object.defineProperty,Ae=D((e,t)=>wi(e,"name",{value:t,configurable:!0}),"r$2");const _e=Ae(()=>te(ti(),".vis","cache","doctor"),"getCacheDirectory"),vi=1800*1e3,tt=Ae(e=>{if(!e)return"";try{return String(Qt(e).mtimeMs)}catch{return""}},"safeMtime"),bi=2,Si=Ae(e=>{const t=JSON.stringify({configMtime:tt(e.configPath),lockfileMtime:tt(e.lockfilePath),schema:bi,sections:[...e.sections].toSorted(),socketEnabled:e.socketEnabled,workspaceRoot:e.workspaceRoot});return ii(Buffer.from(t))},"buildDoctorCacheKey"),$i=Ae(e=>{const t=te(_e(),`${e}.json`);if(Fe(t))try{const i=gt(t);if(Date.now()-i.createdAt>i.ttlMs){Ze(t,{force:!0});return}return{...i.results,sections:new Set(i.results.sections)}}catch{Ze(t,{force:!0});return}},"readDoctorCache"),Ci=Ae((e,t,i=vi)=>{ri(_e());const s={createdAt:Date.now(),results:{...t,sections:[...t.sections]},ttlMs:i};Zt(te(_e(),`${e}.json`),JSON.stringify(s,void 0,2),"utf8")},"writeDoctorCache");var xi=Object.defineProperty,U=D((e,t)=>xi(e,"name",{value:t,configurable:!0}),"i$3");const Oe="orphans",Ri=U(()=>{if(process.platform!=="linux")return{id:"inotify",message:"inotify capacity check skipped (not Linux).",status:"skip"};let e;try{const t=ei("/proc/sys/fs/inotify/max_user_watches","utf8").trim(),i=Number.parseInt(t,10);Number.isFinite(i)&&i>0&&(e=i)}catch{return{id:"inotify",message:"Could not read /proc/sys/fs/inotify/max_user_watches.",status:"warn"}}return e===void 0?{id:"inotify",message:"inotify max_user_watches reported a non-numeric value.",status:"warn"}:e<65536?{detail:{maxWatches:e},id:"inotify",message:`inotify watcher limit is ${String(e)} — large monorepos can exhaust this. Bump now with \`sudo sysctl fs.inotify.max_user_watches=524288\` and persist via \`/etc/sysctl.d/99-vis.conf\` so it survives reboot.`,status:"warn"}:{detail:{maxWatches:e},id:"inotify",message:`inotify capacity OK (${String(e)} watches).`,status:"ok"}},"checkInotifyCapacity"),Ti=U(()=>{const e=!!process.stdin.isTTY,t=!!process.stdout.isTTY;return e&&t?{id:"tty",message:"Interactive TTY available — watch keybinds enabled.",status:"ok"}:!e&&!t?{id:"tty",message:"No TTY on stdin/stdout — running in CI / piped mode (keybinds disabled).",status:"skip"}:{detail:{stdin:String(e),stdout:String(t)},id:"tty",message:e?"stdin is a TTY but stdout is not — output is being captured; keybinds still work.":"stdout is a TTY but stdin is not — keybinds disabled (input is piped).",status:"skip"}},"checkTtyAvailability"),Ai=U(()=>{const e=process.pid;try{return process.platform==="win32"?wt(e):kt(e)}catch{return[]}},"listOrphanPids"),Ii=U(()=>{const e=process.pid;let t;try{t=process.platform==="win32"?wt(e):kt(e)}catch{return{id:Oe,message:"Could not enumerate processes (ps/tasklist failed).",status:"warn"}}if(t.length===0)return{id:Oe,message:"No orphaned vis/task-runner processes detected.",status:"ok"};if(t.length<=2)return{detail:{count:t.length,pids:t.join(",")},id:Oe,message:`${String(t.length)} possibly orphaned process(es) detected (PIDs: ${t.join(", ")}). Likely benign.`,status:"skip"};const i=process.platform==="win32"?t.map(s=>`taskkill /F /PID ${String(s)}`).join(" & "):`kill ${t.join(" ")}`;return{detail:{count:t.length,pids:t.join(",")},id:"orphans",message:`${String(t.length)} possibly orphaned vis/task-runner processes — run \`vis doctor --fix\` to clean them up, or kill them manually: ${i}`,status:"warn"}},"checkOrphanedRunners"),Pi=U((e={})=>{const t=e.enumerate??Ai,i=e.force===!0?"SIGKILL":"SIGTERM",s=e.kill??Mi,o=t(),l=[],c=[];for(const p of o)try{s(p,i),l.push(p)}catch(d){const $=d.code??d.message;if($==="ESRCH"){l.push(p);continue}c.push({pid:p,reason:$})}return{failed:c,killed:l}},"killOrphanedRunners"),Di=U(e=>mt("taskkill",e,{encoding:"utf8"}),"defaultTaskkillRunner"),Oi=U((e,t)=>{process.kill(e,t)},"defaultProcessKill"),Ni=U((e,t,i=Di)=>{const s=t==="SIGKILL"?["/F","/PID",String(e)]:["/PID",String(e)],o=i(s);if(o.error)throw o.error;if(typeof o.status=="number"&&o.status!==0){const l=o.status===128?"ESRCH":`taskkill exited with code ${String(o.status)}`,c=new Error(l);throw c.code=l,c}},"killViaTaskkill"),Fi=U((e,t,i=Oi)=>{i(e,t)},"killViaSignal"),Mi=U((e,t)=>{if(process.platform==="win32"){Ni(e,t);return}Fi(e,t)},"defaultKill"),yt=U((e,t)=>{const i=mt(e,t,{encoding:"utf8"});if(i.error)throw i.error;if(typeof i.status=="number"&&i.status!==0)throw new Error(`${e} exited with code ${String(i.status)}`);return typeof i.stdout=="string"?i.stdout:""},"runProcessListing"),kt=U(e=>{const t=yt("ps",["-Ao","pid=,command="]),i=[];for(const s of t.split(`
|
|
2
|
+
`)){if(s.length===0)continue;const o=/^\s*(\d+)\s+(.+)$/.exec(s);if(!o)continue;const l=Number.parseInt(o[1]??"",10),c=(o[2]??"").toLowerCase();!Number.isFinite(l)||l===e||(/(?:^|[ /])vis-native(?:\s|$|[-.])/.test(c)||/(?:^|[ /])vis\s+run\b/.test(c)||/(?:^|[ /])task-runner(?:\s|$|[-.])/.test(c))&&i.push(l)}return i},"listOrphansUnix"),wt=U(e=>{const t=yt("tasklist",["/FO","CSV","/NH"]),i=[];for(const s of t.split(/\r?\n/)){if(s.length===0)continue;const o=s.split(/","/).map(p=>p.replaceAll(/^"|"$/g,"")),l=(o[0]??"").toLowerCase(),c=Number.parseInt(o[1]??"",10);!Number.isFinite(c)||c===e||(l==="vis.exe"||l.startsWith("vis-native")||l.includes("task-runner"))&&i.push(c)}return i},"listOrphansWindows"),zi=U(()=>[Ri(),Ti(),Ii()],"runRuntimeDiagnostics");var ji=Object.defineProperty,ke=D((e,t)=>ji(e,"name",{value:t,configurable:!0}),"s$2");const ye=[{id:"dependencies",label:"Deps"},{id:"security",label:"Security"},{id:"optimization",label:"Optimize"},{id:"runtime",label:"Runtime"}],Me=["dependencies","security","optimization","runtime"],fe=ke(e=>{const t=new Map;for(const i of Me)t.set(i,[]);for(const i of e)t.get(i.section).push(i);for(const[i,s]of t)s.length===0&&t.delete(i);return t},"groupBySection"),me=ke((e,t,i,s)=>{let o=e.filter(l=>l.section===t);if(s&&(o=o.filter(l=>l.severity===s)),i){const l=i.toLowerCase();o=o.filter(c=>c.title.toLowerCase().includes(l))}return[...o]},"filterFindings"),Ei=ke(e=>{const t={dependencies:"idle",optimization:"idle",runtime:"idle",security:"idle"};for(const i of Me)e.has(i)&&(t[i]="idle");return t},"initialStatus");class it{static{D(this,"DoctorStore")}static{ke(this,"DoctorStore")}#e;#i=new Set;constructor(t=[]){const i=Array.isArray(t)?{findings:t}:t,s=i.findings??[],o=i.activeSections??new Set(Me),l=Me.find(d=>o.has(d))??"dependencies",c=me(s,l,"",void 0),p=Ei(o);if(s.length>0)for(const d of s)p[d.section]="done";this.#e={all:s,entries:c,filterActive:!1,filterText:"",filterType:l,focusedPanel:"list",grouped:fe(c),pendingAction:void 0,sectionError:{},sectionMessage:{},sectionStatus:p,selectedIndex:0,severityFilter:void 0}}getSnapshot=ke(()=>this.#e,"getSnapshot");subscribe=ke(t=>(this.#i.add(t),()=>{this.#i.delete(t)}),"subscribe");setSelectedIndex(t){const i=Math.max(0,Math.min(t,this.#e.entries.length-1));i!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:i})}setFocusedPanel(t){t!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:t})}setFilterType(t){if(t===this.#e.filterType)return;const i=me(this.#e.all,t,this.#e.filterText,this.#e.severityFilter);this.#t({...this.#e,entries:i,filterType:t,grouped:fe(i),selectedIndex:0})}setFilter(t){const i=me(this.#e.all,this.#e.filterType,t,this.#e.severityFilter);this.#t({...this.#e,entries:i,filterText:t,grouped:fe(i),selectedIndex:0})}setFilterActive(t){if(t===this.#e.filterActive)return;if(t){this.#t({...this.#e,filterActive:!0});return}const i=me(this.#e.all,this.#e.filterType,"",this.#e.severityFilter);this.#t({...this.#e,entries:i,filterActive:!1,filterText:"",grouped:fe(i),selectedIndex:0})}setPendingAction(t){this.#t({...this.#e,pendingAction:t})}setSeverityFilter(t){if(t===this.#e.severityFilter)return;const i=me(this.#e.all,this.#e.filterType,this.#e.filterText,t);this.#t({...this.#e,entries:i,grouped:fe(i),selectedIndex:0,severityFilter:t})}startSection(t,i){this.#t({...this.#e,sectionMessage:{...this.#e.sectionMessage,[t]:i},sectionStatus:{...this.#e.sectionStatus,[t]:"running"}})}completeSection(t,i){const s=[...this.#e.all,...i],o=me(s,this.#e.filterType,this.#e.filterText,this.#e.severityFilter),l={...this.#e.sectionMessage};delete l[t],this.#t({...this.#e,all:s,entries:o,grouped:fe(o),sectionMessage:l,sectionStatus:{...this.#e.sectionStatus,[t]:"done"}})}failSection(t,i){this.#t({...this.#e,sectionError:{...this.#e.sectionError,[t]:i},sectionStatus:{...this.#e.sectionStatus,[t]:"error"}})}#t(t){this.#e=t;for(const i of this.#i)try{i()}catch{}}}var Bi=Object.defineProperty,vt=D((e,t)=>Bi(e,"name",{value:t,configurable:!0}),"r$1");const rt={error:0,warn:1},Li=vt(e=>!!e.acceptedRisk,"isAcknowledged"),bt=vt(e=>{const t=[];if(e.sections.has("dependencies")){for(const i of e.outdated)t.push({entry:i,id:`outdated:${i.packageName}`,kind:"outdated",section:"dependencies",severity:"warn",subtitle:`${i.currentRange} → ${i.newRange} (${i.updateType})`,title:i.packageName});for(const i of e.duplicates)t.push({id:`duplicate:${i.name}`,kind:"duplicate",pkg:i,section:"dependencies",severity:"warn",subtitle:`${String(i.versions.length)} versions installed`,title:i.name})}if(e.sections.has("security"))for(const i of e.outdated){if(i.vulnerabilities&&i.vulnerabilities.length>0){const s=i.vulnerabilities[0],o=Li(i)?"warn":"error",l=i.vulnerabilities.length;t.push({entry:i,id:`vuln:${i.packageName}`,kind:"vulnerability",packageName:i.packageName,section:"security",severity:o,subtitle:l===1?`${s.severity} · ${s.id}`:`${String(l)} advisories · top: ${s.severity} ${s.id}`,title:i.packageName})}if(i.socketReport&&i.socketReport.alerts.length>0){const s=Math.round(i.socketReport.score.overall*100);t.push({entry:i,id:`socket:${i.packageName}`,kind:"socket",packageName:i.packageName,section:"security",severity:"warn",subtitle:`${String(i.socketReport.alerts.length)} alert${i.socketReport.alerts.length===1?"":"s"} · score ${String(s)}%`,title:i.packageName})}}if(e.sections.has("optimization"))for(const i of e.optimizations)t.push({entry:i,id:`opt:${i.packageName}`,kind:"optimization",section:"optimization",severity:"warn",subtitle:`${i.category} → ${i.replacement}`,title:i.packageName});if(e.sections.has("runtime"))for(const i of e.runtime)i.status==="warn"&&t.push({diagnostic:i,id:`runtime:${i.id}`,kind:"runtime",section:"runtime",severity:"warn",title:i.message});return t.sort((i,s)=>{if(i.section!==s.section){const o=["dependencies","security","optimization","runtime"];return o.indexOf(i.section)-o.indexOf(s.section)}return rt[i.severity]-rt[s.severity]}),t},"flattenFindings"),St={dependencies:"Dependencies",optimization:"Optimization",runtime:"Runtime",security:"Security"};var _i=Object.defineProperty,Ui=D((e,t)=>_i(e,"name",{value:t,configurable:!0}),"i$2");const Vi={error:"red",warn:"yellow"},Hi={error:"✖",warn:"⚠"},Gi={error:" ERROR ",warn:" WARN "},Yi=Ui(({children:e,hint:t,message:i,severity:s,title:o})=>{const l=Vi[s];return a(h,{borderColor:l,borderStyle:"single",flexDirection:"column",flexShrink:0,paddingX:1,children:[a(h,{gap:1,children:[r(n,{backgroundColor:l,bold:!0,color:"black",children:Gi[s]}),r(n,{bold:!0,color:l,children:Hi[s]}),r(n,{bold:!0,wrap:"truncate-end",children:o})]}),r(n,{wrap:"truncate-end",children:i}),t?r(n,{dimColor:!0,wrap:"truncate-end",children:t}):null,e]})},"ConfigBanner");var Ki=Object.defineProperty,ie=D((e,t)=>Ki(e,"name",{value:t,configurable:!0}),"d");const Ji={CRITICAL:"red",HIGH:"red",LOW:"gray",MODERATE:"yellow",UNKNOWN:"gray"},qi={critical:"red",high:"red",low:"gray",medium:"yellow"},Xi={major:"red",minor:"yellow",patch:"green"},x=ie(({children:e,label:t,width:i=14})=>a(h,{children:[r(h,{width:i,children:a(n,{dimColor:!0,children:[t,":"]})}),typeof e=="string"?r(n,{children:e}):e]}),"FieldRow"),se=ie(({children:e})=>r(h,{marginTop:1,children:r(n,{bold:!0,color:"white",children:e})}),"SectionTitle"),Wi=ie(({finding:e})=>{const{entry:t}=e,i=Xi[t.updateType]??"white";return a(h,{flexDirection:"column",children:[r(x,{label:"Current",children:t.currentRange}),a(x,{label:"Target",children:[r(n,{children:t.newRange}),a(n,{bold:!0,color:i,children:[" (",t.updateType,")"]})]}),r(x,{label:"Catalog",children:t.catalogName}),t.acceptedRisk?r(x,{label:"Risk ack",children:r(n,{dimColor:!0,children:t.acceptedRisk.reason??"(no reason recorded)"})}):null,r(se,{children:"Action"}),a(n,{dimColor:!0,children:["Run"," ",r(n,{bold:!0,color:"white",children:"vis update"})," ","to apply this change."]})]})},"OutdatedDetail"),Qi=ie(({finding:e})=>a(h,{flexDirection:"column",children:[r(x,{label:"Versions",children:r(n,{children:String(e.pkg.versions.length)})}),r(se,{children:"Installed versions"}),e.pkg.versions.map(t=>a(n,{children:[" · ",t]},t)),r(se,{children:"Action"}),a(n,{dimColor:!0,children:["Run"," ",r(n,{bold:!0,color:"white",children:"vis dedupe"})," ","to consolidate to a single resolution."]})]}),"DuplicateDetail"),Zi=ie(({finding:e})=>{const t=e.entry.vulnerabilities??[];return a(h,{flexDirection:"column",children:[r(x,{label:"Package",children:e.packageName}),r(x,{label:"Current",children:e.entry.currentRange}),r(x,{label:"Advisories",children:String(t.length)}),e.entry.acceptedRisk?r(x,{label:"Risk ack",children:r(n,{dimColor:!0,children:e.entry.acceptedRisk.reason??"(no reason recorded)"})}):null,t.map(i=>{const s=Ji[i.severity]??"gray";return a(h,{flexDirection:"column",marginTop:1,children:[a(h,{children:[r(n,{bold:!0,color:s,children:i.severity}),r(n,{children:" "}),r(n,{children:i.id}),typeof i.cvssScore=="number"?a(n,{dimColor:!0,children:[" · CVSS ",i.cvssScore.toFixed(1)]}):null]}),r(n,{wrap:"wrap",children:i.summary}),i.fixedVersions.length>0?a(n,{dimColor:!0,children:["Fixed in: ",i.fixedVersions.join(", ")]}):null,i.aliases&&i.aliases.length>0?a(n,{dimColor:!0,children:["Aliases: ",i.aliases.join(", ")]}):null]},i.id)})]})},"VulnerabilityDetail"),er=ie(({finding:e})=>{const t=e.entry.socketReport;if(!t)return r(n,{dimColor:!0,children:"No Socket report attached."});const i=Math.round(t.score.overall*100),s=qe(t.score.overall);return a(h,{flexDirection:"column",children:[r(x,{label:"Package",children:e.packageName}),r(x,{label:"Overall",children:a(n,{color:s,children:[String(i),"%"]})}),r(x,{label:"Alerts",children:String(t.alerts.length)}),e.entry.acceptedRisk?r(x,{label:"Risk ack",children:r(n,{dimColor:!0,children:e.entry.acceptedRisk.reason??"(no reason recorded)"})}):null,r(se,{children:"Score breakdown"}),Object.entries(t.score).map(([o,l])=>{if(o==="overall")return null;const c=typeof l=="number"?l:0,p=Math.round(c*100),d=qe(c);return a(h,{children:[r(h,{width:14,children:a(n,{dimColor:!0,children:[o,":"]})}),a(n,{color:d,children:[String(p),"%"]})]},o)}),r(se,{children:"Alerts"}),t.alerts.map((o,l)=>{const c=qi[o.severity]??"gray";return a(h,{flexDirection:"column",marginBottom:1,children:[a(h,{children:[r(n,{bold:!0,color:c,children:o.severity}),r(n,{children:" "}),r(n,{children:o.type})]}),o.props?r(n,{dimColor:!0,wrap:"wrap",children:JSON.stringify(o.props)}):null]},`${o.type}-${String(l)}`)})]})},"SocketDetail"),tr=ie(({finding:e})=>{const{entry:t}=e;return a(h,{flexDirection:"column",children:[r(x,{label:"Package",children:t.packageName}),r(x,{label:"Category",children:t.category}),r(x,{label:"Replacement",children:t.replacement}),t.overrideSpec?r(x,{label:"Override",children:t.overrideSpec}):null,r(x,{label:"Codemod",children:r(n,{color:t.hasCodemod?"green":"gray",children:t.hasCodemod?"available":"not available"})}),t.docUrl?r(x,{label:"Guide",children:r(n,{color:"cyan",underline:!0,children:t.docUrl})}):null,r(se,{children:"Action"}),t.hasCodemod?a(n,{dimColor:!0,children:["Run"," ",r(n,{bold:!0,color:"white",children:"vis optimize"})," ","to apply the codemod interactively."]}):t.overrideSpec?a(n,{dimColor:!0,children:["Run"," ",r(n,{bold:!0,color:"white",children:"vis optimize"})," ","to install the package override."]}):t.docUrl?r(n,{dimColor:!0,children:"No automated codemod. Open the migration guide above for the recommended alternative and steps."}):r(n,{dimColor:!0,children:"No automated codemod. Consult the package's docs or the e18e module-replacements guide for an alternative."})]})},"OptimizationDetail"),ir=ie(({finding:e})=>{const{diagnostic:t}=e,i=t.status==="warn"?"yellow":t.status==="ok"?"green":"gray";return a(h,{flexDirection:"column",children:[r(x,{label:"Check",children:t.id}),r(x,{label:"Status",children:r(n,{color:i,children:t.status})}),r(se,{children:"Message"}),r(n,{wrap:"wrap",children:t.message}),t.detail&&Object.keys(t.detail).length>0?a(fi,{children:[r(se,{children:"Details"}),Object.entries(t.detail).map(([s,o])=>a(h,{children:[r(h,{width:20,children:a(n,{dimColor:!0,children:[s,":"]})}),r(n,{children:String(o)})]},s))]}):null]})},"RuntimeDetail"),rr=ie(({finding:e,focused:t,scrollRef:i})=>{const s=t?"white":"gray";if(!e)return r(h,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:r(n,{dimColor:!0,children:"No finding selected"})});let o;switch(e.kind){case"duplicate":{o=r(Qi,{finding:e});break}case"optimization":{o=r(tr,{finding:e});break}case"outdated":{o=r(Wi,{finding:e});break}case"runtime":{o=r(ir,{finding:e});break}case"socket":{o=r(er,{finding:e});break}case"vulnerability":{o=r(Zi,{finding:e});break}default:{o=r(n,{dimColor:!0,children:"Unknown finding kind."});break}}return a(h,{borderColor:s,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[a(h,{flexShrink:0,paddingTop:1,paddingX:2,children:[r(n,{bold:!0,color:"white",children:e.title}),a(n,{dimColor:!0,children:[" ",St[e.section]]})]}),a(Mt,{flexGrow:1,flexShrink:1,paddingX:2,ref:i,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:[r(n,{}),o]})]})},"DoctorDetailPanel");var nr=Object.defineProperty,Ie=D((e,t)=>nr(e,"name",{value:t,configurable:!0}),"c$2");const $t={error:"red",warn:"yellow"},or={error:"✖",warn:"⚠"},sr=Ie(e=>e.kind==="outdated"||e.kind==="vulnerability"||e.kind==="socket"?!!e.entry.acceptedRisk:!1,"hasAcceptedRisk"),lr=Ie(({finding:e,isSelected:t})=>{const i=$t[e.severity],s=sr(e);return a(h,{flexShrink:0,height:1,children:[r(n,{children:t?">":" "}),a(n,{color:i,children:[" ",or[e.severity]," "]}),r(h,{flexGrow:1,children:r(n,{bold:t,inverse:t,wrap:"truncate",children:e.title})}),s?r(n,{color:"cyan",children:" ack"}):null,e.subtitle?a(n,{dimColor:!0,wrap:"truncate",children:[" ",e.subtitle]}):null]})},"FindingRow"),ar=Ie(({count:e,section:t})=>a(h,{flexShrink:0,height:1,marginTop:1,children:[r(n,{dimColor:!0,children:"▼ "}),r(n,{bold:!0,color:"white",children:St[t].toUpperCase()}),a(n,{dimColor:!0,children:[" (",e,")"]})]}),"SectionHeader"),cr=Ie(({count:e,label:t,status:i})=>a(n,{children:[t,i==="running"?a(n,{children:[" ",r(dt,{type:"dots"})]}):null,i==="error"?r(n,{bold:!0,color:"red",children:" ✖"}):a(n,{dimColor:!0,children:[" (",String(e),")"]})]}),"TabLabel"),dr=Ie(({elapsedMs:e,entries:t,filterActive:i,filterText:s,filterType:o,focused:l,fromCache:c=!1,grouped:p,onViewportHeightChange:d,scrollOffset:$,sectionCounts:R,sectionMessage:w,sectionStatus:A,selectedIndex:E,severityFilter:g,totalAll:I,viewportHeight:B})=>{const X=l?"white":"gray",{measuredHeight:L,ref:F}=mi(B,d);let P=0,_=0;for(const v of t)v.severity==="error"?P+=1:v.severity==="warn"&&(_+=1);const W=[];P>0&&W.push(`${String(P)} error${P===1?"":"s"}`),_>0&&W.push(`${String(_)} warn${_===1?"":"s"}`);const re=W.length>0?` (${W.join(", ")})`:"",Y=(e/1e3).toFixed(1),O=[];for(const[v,T]of p){O.push(r(ar,{count:T.length,section:v},`hdr-${v}`));for(const C of T){const H=t.indexOf(C);O.push(r(lr,{finding:C,isSelected:H===E},C.id))}}let V=0;for(const[,v]of p)V+=2+v.length;const K=V>L&&L>0;return a(h,{borderColor:X,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[a(h,{flexShrink:0,gap:1,paddingX:1,children:[r(n,{bold:!0,inverse:!0,children:" DOCTOR "}),a(n,{wrap:"truncate",children:[t.length,t.length===I?"":`/${String(I)}`," finding",t.length===1?"":"s",re]}),g?r(n,{bold:!0,color:$t[g],inverse:!0,children:` ${g.toUpperCase()} ONLY `}):null,c?r(n,{bold:!0,color:"cyan",inverse:!0,children:" CACHED "}):null,a(n,{dimColor:!0,children:[" · ",Y,"s"]})]}),r(h,{flexShrink:0,paddingX:1,paddingY:1,children:r(zt,{isFocused:l,keyMap:{next:[],previous:[],useNumbers:!1,useTab:!1},onChange:D(()=>{},"onChange"),showIndex:!1,value:o,children:ye.map(({id:v,label:T})=>r(jt,{name:v,children:r(cr,{count:R[v],label:T,status:A[v]})},v))})}),(()=>{const v=Object.keys(A).filter(T=>A[T]==="running"&&w[T]).map(T=>w[T]);return v.length===0?null:r(h,{flexShrink:0,paddingX:1,children:a(n,{dimColor:!0,wrap:"truncate",children:[r(dt,{type:"dots"})," ",v.join(" · ")]})})})(),i&&a(h,{flexShrink:0,paddingX:1,children:[r(n,{bold:!0,color:"white",children:"/ "}),r(n,{children:s}),r(n,{inverse:!0,children:" "})]}),a(h,{flexDirection:"row",flexGrow:1,overflow:"hidden",ref:F,children:[r(h,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:r(h,{flexDirection:"column",marginTop:-$,children:O.length>0?O:r(h,{marginTop:1,children:r(n,{dimColor:!0,children:"No findings match the current filter."})})})}),K&&r(h,{flexShrink:0,marginLeft:1,marginRight:1,children:r(Et,{contentHeight:V,placement:"inset",scrollOffset:$,style:"block",viewportHeight:L})})]},`list-${o}-${s}`)]})},"DoctorListPanel");var ur=Object.defineProperty,je=D((e,t)=>ur(e,"name",{value:t,configurable:!0}),"g$1");const hr=je(e=>{if(e.kind==="outdated")return{command:`vis update ${e.entry.packageName}`,description:`Update ${e.entry.packageName} to ${e.entry.newRange}`};if(e.kind==="duplicate")return{command:`vis dedupe ${e.pkg.name}`,description:`Dedupe ${e.pkg.name} (${String(e.pkg.versions.length)} versions)`}},"buildUpdateAction"),pr=je(e=>{if(e.kind==="optimization")return{command:`vis optimize ${e.entry.packageName}`,description:`Replace ${e.entry.packageName} with ${e.entry.replacement}`}},"buildOptimizeAction"),gr=je(e=>{if(e.kind!=="outdated"&&e.kind!=="vulnerability"&&e.kind!=="socket")return;const t=e.kind==="outdated"?e.entry.packageName:e.packageName,i=["// Add to vis.config.ts:","security: {"," acceptedRisks: {",` "${t}": {`,' reason: "explain why this risk is acceptable",',' expiresAt: "YYYY-MM-DD",'," },"," },","},"].join(`
|
|
3
|
+
`);return{command:i,configSnippet:i,description:`Acknowledge risk for ${t}`}},"buildAckAction"),fr=100,mr=40,yr=10,kr=je(({autoExitSeconds:e=0,banner:t,fromCache:i=!1,startedAt:s,store:o})=>{const{exit:l}=Bt(),{columns:c,rows:p}=Lt(),d=Wt(o.subscribe,o.getSnapshot),[$,R]=xe(!1),[w,A]=xe(!1),[E,g]=xe(0),[I,B]=xe(()=>Date.now());Be(()=>{const y=setInterval(()=>{B(Date.now())},1e3);return()=>{clearInterval(y)}},[]);const X=I-s,L=We(null),F=We(null),P=d.entries[d.selectedIndex]??null,_=Pe(()=>{const y={dependencies:0,optimization:0,runtime:0,security:0};for(const m of d.all)y[m.section]+=1;return y},[d.all]),W=t?t.hint?5:4:0,re=Pe(()=>{for(const y of Object.keys(d.sectionStatus))if(d.sectionStatus[y]==="running"&&d.sectionMessage[y])return 1;return 0},[d.sectionStatus,d.sectionMessage]),Y=c>=fr,O=Y?Math.max(1,p-W-2):Math.floor(p*.55),V=Pe(()=>Math.max(1,O-6-re-(d.filterActive?1:0)),[O,re,d.filterActive]),[K,v]=xe(V),T=K>0?K:V,C=Pe(()=>{let y=0;for(const[,m]of d.grouped)y+=2+m.length;return y},[d.grouped]),H=Math.max(0,C-T);Be(()=>{g(y=>Math.min(y,H))},[H]);const de=Qe(y=>{let m=0,k=0;for(const[,$e]of d.grouped){m+=2;for(let le=0;le<$e.length;le++){if(k===y)return m;m+=1,k+=1}}return m},[d.grouped]),N=Qe(y=>{const m=de(y);g(k=>m>k+T-2?Math.min(H,Math.max(0,m-T+2)):m<k+1?Math.max(0,m-1):k)},[de,T,H]);if(Be(()=>{F.current?.scrollToTop()},[P?.id]),_t((y,m)=>{if(y==="c"&&m.ctrl){l();return}if(!w){if($){m.escape||y==="?"?R(!1):y==="q"?(R(!1),A(!0)):m.downArrow||y==="j"?L.current?.scrollBy(1):(m.upArrow||y==="k")&&L.current?.scrollBy(-1);return}if(y==="?"){R(!0);return}if(y==="q"){A(!0);return}if(m.tab){o.setFocusedPanel(d.focusedPanel==="list"?"detail":"list");return}if(d.filterActive){if(m.escape||m.return){o.setFilterActive(!1);return}if(m.backspace){g(0),o.setFilter(d.filterText.slice(0,-1));return}y&&!m.ctrl&&!m.meta&&(g(0),o.setFilter(d.filterText+y));return}if(d.focusedPanel==="list"&&(m.leftArrow||m.rightArrow)){const k=ye.findIndex(le=>le.id===d.filterType),$e=m.rightArrow?(k+1)%ye.length:(k-1+ye.length)%ye.length;g(0),F.current?.scrollToTop(),o.setFilterType(ye[$e].id);return}if(d.focusedPanel==="list"){if(m.downArrow||y==="j"){const k=Math.min(d.selectedIndex+1,d.entries.length-1);o.setSelectedIndex(k),N(k);return}if(m.upArrow||y==="k"){const k=Math.max(d.selectedIndex-1,0);o.setSelectedIndex(k),N(k);return}if(m.pageDown){const k=Math.min(d.selectedIndex+10,d.entries.length-1);o.setSelectedIndex(k),N(k);return}if(m.pageUp){const k=Math.max(d.selectedIndex-10,0);o.setSelectedIndex(k),N(k);return}if(m.home){o.setSelectedIndex(0),g(0);return}if(m.end){const k=d.entries.length-1;o.setSelectedIndex(k),N(k);return}if(y==="/"){o.setFilterActive(!0);return}if(y==="e"){o.setSeverityFilter(d.severityFilter==="error"?void 0:"error"),g(0);return}if(y==="w"){o.setSeverityFilter(d.severityFilter==="warn"?void 0:"warn"),g(0);return}if(y==="u"&&P){const k=hr(P);k&&(o.setPendingAction(k),l());return}if(y==="o"&&P){const k=pr(P);k&&(o.setPendingAction(k),l());return}if(y==="a"&&P){const k=gr(P);k&&(o.setPendingAction(k),l());return}if(y==="d"){o.setFocusedPanel("detail");return}return}if(m.escape||m.leftArrow){o.setFocusedPanel("list");return}if(m.downArrow||y==="j"){F.current?.scrollBy(1);return}if(m.upArrow||y==="k"){F.current?.scrollBy(-1);return}if(m.pageDown){F.current?.scrollBy(10);return}if(m.pageUp){F.current?.scrollBy(-10);return}if(m.home){F.current?.scrollToTop();return}m.end&&F.current?.scrollToBottom()}},{isActive:!0}),c<mr||p<yr)return r(h,{alignItems:"center",height:p,justifyContent:"center",width:c,children:a(n,{color:"yellow",children:["Terminal too small (",c,"x",p,")"]})});const Q=d.focusedPanel==="detail",ee=[a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"q"}),r(n,{dimColor:!0,children:"QUIT"})]},"q"),a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"?"}),r(n,{dimColor:!0,children:"HELP"})]},"?"),a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"↑↓"}),r(n,{dimColor:!0,children:Q?"SCROLL":"NAV"})]},"nav"),Q?a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"←/Esc"}),r(n,{dimColor:!0,children:"LIST"})]},"lr"):a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"←→"}),r(n,{dimColor:!0,children:"SECTION"})]},"lr"),a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"/"}),r(n,{dimColor:!0,children:"SEARCH"})]},"search"),a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"e/w"}),r(n,{dimColor:!0,children:"SEVERITY"})]},"sev"),a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"u/o/a"}),r(n,{dimColor:!0,children:"ACTION"})]},"actions"),a(h,{gap:1,children:[r(n,{bold:!0,color:"white",children:"Tab"}),r(n,{dimColor:!0,children:"PANEL"})]},"tab")],ue=r(h,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:r(h,{gap:2,overflow:"hidden",paddingX:1,children:ee})}),he=a(Ut,{footer:a(n,{dimColor:!0,children:[r(n,{bold:!0,color:"white",children:"↑↓"})," scroll ",r(n,{bold:!0,color:"white",children:"?"}),"/",r(n,{bold:!0,color:"white",children:"Esc"})," close"]}),scrollRef:L,title:"DOCTOR — KEYBOARD SHORTCUTS",visible:$,width:56,children:[a(h,{flexDirection:"column",marginBottom:1,children:[a(h,{marginBottom:1,children:[r(n,{dimColor:!0,children:"── "}),r(n,{bold:!0,color:"white",children:"NAVIGATION"})]}),a(h,{children:[r(h,{width:26,children:a(n,{children:[r(n,{bold:!0,color:"white",children:" ↑/k "}),r(n,{dimColor:!0,children:"Move up"})]})}),a(n,{children:[r(n,{bold:!0,color:"white",children:" ↓/j "}),r(n,{dimColor:!0,children:"Move down"})]})]}),a(h,{children:[r(h,{width:26,children:a(n,{children:[r(n,{bold:!0,color:"white",children:" PgUp"}),r(n,{dimColor:!0,children:" Jump up 10"})]})}),a(n,{children:[r(n,{bold:!0,color:"white",children:" PgDn"}),r(n,{dimColor:!0,children:" Jump down 10"})]})]}),a(h,{children:[r(h,{width:26,children:a(n,{children:[r(n,{bold:!0,color:"white",children:" Home"}),r(n,{dimColor:!0,children:" Jump to top"})]})}),a(n,{children:[r(n,{bold:!0,color:"white",children:" End"}),r(n,{dimColor:!0,children:" Jump to bottom"})]})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" Tab"}),r(n,{dimColor:!0,children:" Switch panel"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" →/←"}),r(n,{dimColor:!0,children:" Section tabs (list) / Focus list (detail)"})]})]}),a(h,{flexDirection:"column",marginBottom:1,children:[a(h,{marginBottom:1,children:[r(n,{dimColor:!0,children:"── "}),r(n,{bold:!0,color:"white",children:"FILTER"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" /"}),r(n,{dimColor:!0,children:" Open text filter (Esc/Enter to close)"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" e"}),r(n,{dimColor:!0,children:" Toggle errors-only filter"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" w"}),r(n,{dimColor:!0,children:" Toggle warns-only filter"})]})]}),a(h,{flexDirection:"column",marginBottom:1,children:[a(h,{marginBottom:1,children:[r(n,{dimColor:!0,children:"── "}),r(n,{bold:!0,color:"white",children:"ACTIONS"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" u"}),r(n,{dimColor:!0,children:" Exit + suggest update / dedupe command"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" o"}),r(n,{dimColor:!0,children:" Exit + suggest optimize command"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" a"}),r(n,{dimColor:!0,children:" Exit + print risk-ack snippet"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" d"}),r(n,{dimColor:!0,children:" Focus detail panel"})]})]}),a(h,{flexDirection:"column",children:[a(h,{marginBottom:1,children:[r(n,{dimColor:!0,children:"── "}),r(n,{bold:!0,color:"white",children:"EXIT"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" q"}),r(n,{dimColor:!0,children:" Quit (with countdown)"})]}),a(n,{children:[r(n,{bold:!0,color:"white",children:" Ctrl+C"}),r(n,{dimColor:!0,children:" Quit immediately"})]})]})]}),pe=r(dr,{elapsedMs:X,entries:d.entries,filterActive:d.filterActive,filterText:d.filterText,filterType:d.filterType,focused:d.focusedPanel==="list",fromCache:i,grouped:d.grouped,onViewportHeightChange:v,scrollOffset:E,sectionCounts:_,sectionMessage:d.sectionMessage,sectionStatus:d.sectionStatus,selectedIndex:d.selectedIndex,severityFilter:d.severityFilter,totalAll:d.all.length,viewportHeight:T}),ge=t?r(Yi,{hint:t.hint,message:t.message,severity:t.severity,title:t.title}):null,Se=r(rr,{finding:P,focused:d.focusedPanel==="detail",scrollRef:F});if(Y){const y=Math.floor(c*.4);return a(h,{flexDirection:"column",height:p,width:c,children:[ge,a(h,{flexDirection:"row",flexGrow:1,children:[r(h,{flexGrow:1,children:pe}),r(h,{width:y,children:Se})]}),ue,r(Xe,{autoExitSeconds:e||3,onCancel:D(()=>{A(!1)},"onCancel"),visible:w}),he]})}return a(h,{flexDirection:"column",height:p,width:c,children:[ge,r(h,{height:O,children:pe}),r(h,{flexGrow:1,children:Se}),ue,r(Xe,{autoExitSeconds:e||3,onCancel:D(()=>{A(!1)},"onCancel"),visible:w}),he]})},"VisDoctorApp");var wr=Object.defineProperty,ve=D((e,t)=>wr(e,"name",{value:t,configurable:!0}),"n");const vr=ve(e=>e.replaceAll(/[$()+.?[\\\]^{|}]/g,String.raw`\$&`),"escapeRegex"),br=ve(e=>{const t=e.split("*").map(i=>vr(i));return new RegExp(`^${t.join(".*")}$`,"i")},"compilePattern"),Sr=ve(e=>e?e.split(",").map(t=>t.trim()).filter(t=>t.length>0).map(t=>br(t)):[],"parseFilterPatterns"),Ne=ve((e,t)=>{for(const i of t)if(i.test(e))return!0;return!1},"matchesAny"),$r=ve((e,t)=>{if(t.length===0)return e;const i=e.outdated.filter(d=>Ne(d.packageName,t)),s=e.duplicates.filter(d=>Ne(d.name,t)),o=e.optimizations.filter(d=>Ne(d.packageName,t));let l=0,c=0,p=0;for(const d of i)d.vulnerabilities&&(l+=d.vulnerabilities.length),d.socketReport&&(c+=d.socketReport.alerts.length,d.socketReport.score.overall<Le&&(p+=1));return{...e,duplicates:s,optimizations:o,outdated:i,socketIssues:{alerts:c,lowScore:p},vulnCount:l}},"applyFilter"),Ct=ve((e,t)=>t.length===0?[...e]:e.filter(i=>{if(i.kind==="runtime")return!0;const s=i.kind==="duplicate"?i.pkg.name:i.kind==="outdated"||i.kind==="optimization"?i.entry.packageName:i.packageName;return Ne(s,t)}),"filterFindingsByPattern");var Cr=Object.defineProperty,be=D((e,t)=>Cr(e,"name",{value:t,configurable:!0}),"r");const xt=["dependencies","security","optimization","runtime"],nt=be(e=>{const t=new Set;if(!e)return t;for(const i of e.split(",")){const s=i.trim().toLowerCase();xt.includes(s)&&t.add(s)}return t},"parseSectionList"),xr=be((e,t)=>{if(e!==void 0&&e!=="")return nt(e);const i=nt(t);return new Set(xt.filter(s=>!i.has(s)))},"resolveSections"),Rt=be(e=>{const t={micro:0,native:0,preferred:0,socket:0,total:e.length};for(const i of e)switch(i.category){case"micro-utility":{t.micro+=1;break}case"native":{t.native+=1;break}case"preferred":{t.preferred+=1;break}case"socket":{t.socket+=1;break}}return t},"summarizeOptimizations"),oe=be((e,t)=>{if(!e.sections.has(t))return"skip";switch(t){case"dependencies":return e.outdated.length>0||e.duplicates.length>0?"warn":"ok";case"optimization":return e.optimizations.length>0?"warn":"ok";case"runtime":return e.runtime.some(i=>i.status==="warn")?"warn":"ok";case"security":return e.vulnCount>0||e.socketIssues.alerts>0?"error":e.socketIssues.lowScore>0?"warn":"ok";default:return"ok"}},"sectionStatus"),Rr=be((e,t)=>{const i=Rt(e.optimizations),s={dependencies:oe(e,"dependencies"),optimization:oe(e,"optimization"),runtime:oe(e,"runtime"),security:oe(e,"security")},o=new Set([...Object.values(s),e.supplyChain.status]),l=o.has("error")?"error":o.has("warn")?"warn":"ok";return{dependencies:{duplicates:e.duplicates.length,installed:e.installedCount,outdated:e.outdated.length,status:s.dependencies},elapsedMs:e.elapsedMs,optimizations:{microUtilities:i.micro,native:i.native,preferred:i.preferred,socket:i.socket,status:s.optimization,total:i.total},packageManager:t,runtime:e.runtime.map(c=>({detail:c.detail,id:c.id,message:c.message,status:c.status})),runtimeStatus:s.runtime,security:{alerts:e.socketIssues.alerts,lowScorePackages:e.socketIssues.lowScore,status:s.security,vulnerabilities:e.vulnCount},status:l,supplyChain:{findings:e.supplyChain.findings.map(c=>({detail:c.detail,label:c.label,severity:c.severity})),status:e.supplyChain.status},workspaces:e.workspaceCount}},"buildJsonPayload"),ot=be((e,t)=>{const i=e.runtime.some(o=>o.status==="warn"),s=e.vulnCount>0||e.socketIssues.alerts>0;return t?s||e.outdated.length>0||e.duplicates.length>0||i:s},"shouldFail");var Tr=Object.defineProperty,Ve=D((e,t)=>Tr(e,"name",{value:t,configurable:!0}),"i");const Ar=/^(@[\w./-]+\/[\w./-]+|[\w.-]+)@(.+)$/,Ir=Ve(e=>{const t=Ar.exec(e);if(t)return{name:t[1],version:t[2]}},"parsePatchKey"),Pr=Ve((e,t)=>{let i;try{if(t==="pnpm"){const o=te(e,"pnpm-workspace.yaml");Fe(o)&&(i=yi(o)?.patchedDependencies)}else if(t==="bun"){const o=te(e,"package.json");Fe(o)&&(i=gt(o)?.patchedDependencies)}}catch{return[]}if(!i||typeof i!="object")return[];const s=[];for(const[o,l]of Object.entries(i)){if(typeof l!="string"||l.length===0)continue;const c=Ir(o);c&&s.push({name:c.name,patchFile:l,resolvedPatchFile:Ft(l)?l:ct(e,l),version:c.version})}return s},"readPatchedDependencies"),Dr=Ve(e=>{const t=[];for(const i of e)Fe(i.resolvedPatchFile)||t.push({entry:i,kind:"missing-file"});return t},"findPatchIssues");var Or=Object.defineProperty,Tt=D((e,t)=>Or(e,"name",{value:t,configurable:!0}),"a");const st=Tt(e=>e.some(t=>t.severity==="error")?"error":e.some(t=>t.severity==="warn")?"warn":"ok","rollUpStatus"),Nr=Tt((e,t={})=>{const i=[],s=e?.security;if(!s)return i.push({detail:"Use defineConfig() from '@visulima/vis/config' to apply secure defaults.",label:"No security config — running with the PM's native defaults",severity:"warn"}),{findings:i,status:st(i)};s.minimumReleaseAge===void 0?i.push({detail:"Set security.minimumReleaseAge to block packages published in the last N minutes (mitigates supply-chain attacks).",label:"minimumReleaseAge is not set",severity:"warn"}):s.minimumReleaseAge===0?i.push({detail:"New packages can be installed immediately after publishing. Consider setting a non-zero cooldown.",label:"minimumReleaseAge is explicitly 0",severity:"warn"}):i.push({label:`minimumReleaseAge: ${String(s.minimumReleaseAge)} minutes`,severity:"ok"}),s.trustPolicy===void 0||s.trustPolicy==="off"?i.push({detail:"Packages whose trust level has decreased will not be blocked. Consider 'no-downgrade'.",label:`trustPolicy: ${s.trustPolicy??"not set"}`,severity:"warn"}):i.push({label:`trustPolicy: ${s.trustPolicy}`,severity:"ok"}),s.blockExoticSubdeps===void 0||!s.blockExoticSubdeps?i.push({detail:"Transitive dependencies can pull code from git repos or tarball URLs. Set to true to block.",label:`blockExoticSubdeps: ${String(s.blockExoticSubdeps??!1)}`,severity:"warn"}):i.push({label:"blockExoticSubdeps: true",severity:"ok"});const o=s.allowBuilds?Object.keys(s.allowBuilds).length:0;if(o===0?i.push({detail:"Lifecycle scripts are blocked by default. List trusted packages here to opt them back in (e.g. esbuild, @prisma/client).",label:"allowBuilds: not configured",severity:"warn"}):i.push({label:`allowBuilds: ${String(o)} ${o===1?"entry":"entries"}`,severity:"ok"}),s.strictDepBuilds&&o===0&&i.push({detail:"All dependencies with build scripts will be blocked. Run 'vis approve-builds' to populate allowBuilds.",label:"strictDepBuilds is on but allowBuilds is empty",severity:"error"}),t.workspaceRoot){const l=ki(t.workspaceRoot);if(l.length>0){const c=[...new Set(l.map(p=>p.tool))].sort((p,d)=>p.localeCompare(d)).join(", ");i.push({detail:"Run `vis migrate verify` for the full list, then re-run `vis migrate <tool>` to clean up.",label:`${String(l.length)} leftover ${l.length===1?"reference":"references"} to ${c}`,severity:"warn"})}}if(t.workspaceRoot&&t.packageManager){const l=Pr(t.workspaceRoot,t.packageManager);if(l.length>0){const c=Dr(l);if(c.length===0)i.push({label:`patchedDependencies: ${String(l.length)} ${l.length===1?"entry":"entries"} resolved`,severity:"ok"});else for(const p of c)i.push({detail:`Referenced from ${t.packageManager==="pnpm"?"pnpm-workspace.yaml":"package.json"} but the file is not present at ${p.entry.patchFile}.`,label:`patchedDependencies: missing patch file for ${p.entry.name}@${p.entry.version}`,severity:"error"})}}return{findings:i,status:st(i)}},"buildSupplyChainPosture");var Fr=Object.defineProperty,S=D((e,t)=>Fr(e,"name",{value:t,configurable:!0}),"u");const G=S(e=>e>=1e3?`${(e/1e3).toFixed(1)}s`:`${String(Math.round(e))}ms`,"fmtDuration"),De=S(async(e,t,i,s)=>{if(!e)return i();e.start(t);const o=Date.now();try{const l=await i(),c=Date.now()-o,{status:p,summary:d}=s(l,c);return e.finish(t,p,d),l}catch(l){const c=Date.now()-o,p=l instanceof Error?l.message:String(l);throw e.finish(t,"error",`${p} (${G(c)})`),l}},"tracked"),Mr=S((e,t)=>{const i={duplicates:t.duplicates,elapsedMs:0,installedCount:0,optimizations:t.optimizations,outdated:t.outdated,runtime:t.runtime,sections:new Set([e]),socketIssues:{alerts:0,lowScore:0},supplyChain:{findings:[],status:"ok"},vulnCount:0,workspaceCount:0};return bt(i)},"buildSectionFindings"),lt=S(async e=>{const{filterPatterns:t,installed:i,progress:s,resolveCodemods:o,sections:l,store:c,visConfig:p,workspaceRoot:d}=e,$=l.has("dependencies"),R=l.has("security"),w=l.has("optimization"),A=l.has("runtime"),E=S((f,M)=>Ct(Mr(f,M),t),"sectionFindings"),g=ut(d),{packageManager:I}=at(d),B=et(te(d,"package.json"),!1),X=ft(d),L=new Set(B);for(const f of X){const M=et(te(ct(d,f),"package.json"),!1);for(const z of M)L.add(z)}const F=Ht(d),P=ht(d,I),_=pt(p?.security?.socket),W=p?.security?.socket?.acceptedRisks,re=oi(d,g.name),Y={exclude:[],ignore:[],include:[],includeLocked:!1,includePrerelease:!1,security:!0,target:"latest"},O=$?hi(d,g.name):[],V=w?si(L):[],K=w?li(L,re,g,!1):[],v=new Set(V.map(f=>f.packageName)),T=K.filter(f=>!v.has(f.packageName)),C=[...V,...T],H=A?zi():[];c&&($&&c.startSection("dependencies",P.size>0?"checking outdated catalog dependencies":"scanning duplicates"),R&&c.startSection("security",i.length>0?`scanning ${String(i.length)} packages for advisories`:"no installed packages to scan"),w&&c.startSection("optimization","matching e18e + socket overrides"),A&&c.startSection("runtime","running runtime diagnostics")),c&&A&&c.completeSection("runtime",E("runtime",{duplicates:[],optimizations:[],outdated:[],runtime:H}));const de=($||R)&&P.size>0?De(s,"outdated",()=>Gt(P,Y,F,void 0,d,_,W),(f,M)=>{const z=f.outdated.length;return{status:z>0?"warn":"ok",summary:z>0?`${String(z)} outdated · ${G(M)}`:`up to date · ${G(M)}`}}):Promise.resolve({failed:[],ignored:[],outdated:[]}),N=R&&i.length>0?De(s,"vulnerabilities",()=>Yt(i.map(f=>({name:f.name,version:f.version}))),(f,M)=>{let z=0;for(const ne of f.values())z+=ne.length;return{status:z>0?"error":"ok",summary:z>0?`${String(z)} found · ${G(M)}`:`none found · ${G(M)}`}}):Promise.resolve(new Map),Q=R&&_&&i.length>0?De(s,"socket",()=>Kt(i.map(f=>({name:f.name,version:f.version})),_),(f,M)=>{let z=0,ne=0;for(const Je of f.values())z+=Je.alerts.length,Je.score.overall<Le&&(ne+=1);const Ke=z+ne;return{status:Ke>0?"warn":"ok",summary:Ke>0?`${String(z)} alert${z===1?"":"s"}, ${String(ne)} low-score · ${G(M)}`:`clean · ${G(M)}`}}):Promise.resolve(new Map);let ee,ue,he,pe;const ge=de.catch(f=>(ee=f instanceof Error?f.message:String(f),c||u.warn(`Outdated scan failed: ${ee}`),{failed:[],ignored:[],outdated:[]})),Se=N.catch(f=>(ue=f instanceof Error?f.message:String(f),c||u.warn(`Vulnerability scan failed: ${ue}`),new Map)),y=Q.catch(f=>(he=f instanceof Error?f.message:String(f),c||u.warn(`Socket scan failed: ${he}`),new Map)),m=c&&$?ge.then(f=>{if(ee){c.failSection("dependencies",ee);return}c.completeSection("dependencies",E("dependencies",{duplicates:O,optimizations:[],outdated:f.outdated,runtime:[]}))}):void 0,k=c&&R?Promise.all([ge,Se,y]).then(([f])=>{const M=ee??ue??he;if(M){c.failSection("security",M);return}c.completeSection("security",E("security",{duplicates:[],optimizations:[],outdated:f.outdated,runtime:[]}))}):void 0,$e=(async()=>{if(o&&w&&C.length>0&&await De(s,"codemods",async()=>(await ai(C),C),(f,M)=>{const z=f.filter(ne=>ne.hasCodemod||ne.category==="socket").length;return{status:"ok",summary:`${String(z)} auto-fixable · ${G(M)}`}}).catch(f=>{pe=f instanceof Error?f.message:String(f)}),c&&w){if(pe){c.failSection("optimization",pe);return}c.completeSection("optimization",E("optimization",{duplicates:[],optimizations:C,outdated:[],runtime:[]}))}})(),[le,It,Pt]=await Promise.all([ge,Se,y]);await Promise.all([m,k,$e]);let Ge=0,Ye=0;if(R&&_)for(const f of Pt.values())Ge+=f.alerts.length,f.score.overall<Le&&(Ye+=1);let Ee=0;if(R){for(const f of le.outdated)f.vulnerabilities&&f.vulnerabilities.length>0&&(Ee+=f.vulnerabilities.length);for(const f of It.values())Ee+=f.length}return{duplicates:O,installedCount:i.length,optimizations:w?C:[],outdated:$?le.outdated:[],runtime:H,sections:l,socketIssues:{alerts:Ge,lowScore:Ye},supplyChain:Nr(p,{packageManager:I,workspaceRoot:d}),vulnCount:Ee,workspaceCount:X.length}},"streamScans"),zr=S(e=>{switch(e){case"error":return Re(j.failure);case"skip":return b(j.dash);case"warn":return ze(j.warning);default:return we(j.success)}},"sectionIcon"),ce=S((e,t)=>{const i=process.stderr.columns??80,s=Math.max(20,Math.min(i-2,60)),o=j.dash.repeat(2),l=`${zr(t)} ${ae(e)}`,c=l.replaceAll(/\[[0-9;]*m/g,"").length,p=Math.max(0,s-c-o.length-2);return`${o} ${l} ${b(j.dash.repeat(p))}`},"heading"),q=S(e=>` ${we(j.success)} ${e}`,"itemOk"),Z=S(e=>` ${ze(j.warning)} ${e}`,"itemWarn"),He=S(e=>` ${Re(j.failure)} ${e}`,"itemError"),At=S(e=>` ${b(j.dash)} ${b(e)}`,"itemSkip"),J=S((e,t,i)=>{const s=`${ae(String(e))} ${b(t)}`;return i?`${s} ${b(`(${i})`)}`:s},"countLine"),jr=S(e=>{if(e.sections.has("dependencies")){if(u.log(""),u.log(ce("Dependencies",oe(e,"dependencies"))),u.log(q(J(e.installedCount,"packages installed"))),e.outdated.length>0){const t=e.outdated.filter(l=>l.updateType==="major").length,i=e.outdated.filter(l=>l.updateType==="minor").length,s=e.outdated.filter(l=>l.updateType==="patch").length,o=[];t>0&&o.push(`${String(t)} major`),i>0&&o.push(`${String(i)} minor`),s>0&&o.push(`${String(s)} patch`),u.log(Z(J(e.outdated.length,"outdated",o.join(", "))))}else u.log(q("All dependencies up to date"));e.duplicates.length>0?u.log(Z(J(e.duplicates.length,"packages with duplicate versions"))):u.log(q("No duplicate dependencies"))}},"displayDependencies"),Er=S(e=>{e.sections.has("security")&&(u.log(""),u.log(ce("Security",oe(e,"security"))),e.vulnCount>0?u.log(He(J(e.vulnCount,`vulnerabilit${e.vulnCount===1?"y":"ies"} found`))):u.log(q("No known vulnerabilities")),e.socketIssues.alerts>0&&u.log(Z(J(e.socketIssues.alerts,`Socket.dev security alert${e.socketIssues.alerts===1?"":"s"}`))),e.socketIssues.lowScore>0&&u.log(Z(J(e.socketIssues.lowScore,`package${e.socketIssues.lowScore===1?"":"s"} with low security score`))),e.socketIssues.alerts===0&&e.socketIssues.lowScore===0&&e.vulnCount===0&&u.log(q("No security issues detected")))},"displaySecurity"),Br=S(e=>{if(!e.sections.has("optimization"))return;u.log(""),u.log(ce("Optimization",oe(e,"optimization")));const t=Rt(e.optimizations);if(t.total===0){u.log(q("No optimizations available"));return}t.native>0&&u.log(Z(J(t.native,"replaceable with native APIs"))),t.preferred>0&&u.log(Z(J(t.preferred,"with lighter alternatives"))),t.micro>0&&u.log(Z(J(t.micro,"trivial micro-utilities"))),t.socket>0&&u.log(Z(J(t.socket,"@socketregistry overrides available")))},"displayOptimization"),Lr=S(e=>{u.log(""),u.log(ce("Supply Chain",e.supplyChain.status));for(const t of e.supplyChain.findings){const i=t.severity==="ok"?q(t.label):t.severity==="error"?He(t.label):Z(t.label);u.log(i),t.detail&&u.log(` ${b(j.arrow)} ${b(t.detail)}`)}e.supplyChain.status!=="ok"&&u.log(` ${b(j.arrow)} ${b("Configure with security.* in vis.config.ts. See `vis check --security-config` for details.")}`)},"displaySupplyChain"),_r=S(e=>{if(e.sections.has("runtime")){u.log(""),u.log(ce("Runtime",oe(e,"runtime")));for(const t of e.runtime)t.status==="ok"?u.log(q(t.message)):t.status==="skip"?u.log(At(t.message)):u.log(Z(t.message))}},"displayRuntime"),Ur=S((e,t)=>{const i=e.vulnCount,s=e.runtime.filter(l=>l.status==="warn").length,o=e.outdated.length+e.duplicates.length+e.optimizations.length+s;if(t){if(i===0&&o===0)u.success(`Everything looks good! ${b(`(${G(e.elapsedMs)})`)}`);else{const l=[];i>0&&l.push(Re(`${String(i)} security`)),o>0&&l.push(ze(`${String(o)} improvement${o===1?"":"s"}`)),u.log(`${Re(j.failure)} ${l.join(", ")} ${b(`(${G(e.elapsedMs)})`)}`)}return}u.log(""),u.log(ce("Summary","ok")),i===0&&o===0?u.success(`Everything looks good! ${b(`(${G(e.elapsedMs)})`)}`):(i>0&&u.error(`${String(i)} security issue${i===1?"":"s"}`),o>0&&u.log(` ${Te(j.arrow)} ${ae(String(o))} ${b(`improvement${o===1?"":"s"} available`)} ${b(`(${G(e.elapsedMs)})`)}`))},"displaySummary"),Vr=S(e=>{const t=[];if(e.outdated.length>0&&t.push("vis update — update outdated dependencies"),(e.vulnCount>0||e.socketIssues.alerts>0)&&t.push("vis audit — detailed security analysis"),e.optimizations.length>0&&t.push("vis optimize — apply optimizations interactively"),e.duplicates.length>0&&t.push("vis dedupe — reduce duplicate versions"),t.length>0){u.log(""),u.log(ae("Next steps:"));for(const i of t)u.log(` ${b(j.arrow)} ${i}`)}u.log("")},"displayActions"),Hr=S((e,t)=>{t||(jr(e),Er(e),Br(e),_r(e),Lr(e)),Ur(e,t)},"displayResults"),Gr=S((e,t,i,s,o)=>{const l=[],c=e.has("dependencies"),p=e.has("security"),d=e.has("optimization");return(c||p)&&t>0&&l.push({id:"outdated",label:"Outdated catalog dependencies"}),p&&s>0&&l.push({id:"vulnerabilities",label:"Known vulnerabilities (OSV)"}),p&&i&&s>0&&l.push({id:"socket",label:"Socket.dev supply-chain reports"}),d&&o&&l.push({id:"codemods",label:"Codemod availability"}),l},"planScanTasks"),Yr=S(e=>{if(u.log(""),u.log(`${ae(Te("vis doctor"))} ${b("— project health check")}`),u.log(q(`Detected ${e.packageManagerName} v${e.packageManagerVersion}`)),e.workspaceCount!==void 0&&e.workspaceCount>0&&u.log(q(J(e.workspaceCount,`workspace package${e.workspaceCount===1?"":"s"}`))),e.runtimeFindings.length===0)u.log(q(`Node.js ${e.nodeVersion}`));else{for(const t of e.runtimeFindings){const i=t.severity==="error"?Re:ze;u.log(He(`Runtime: ${i(t.message)}`))}u.log(` ${b(j.arrow)} Run ${we("vis toolchain install")} to install pinned versions, or ${we("vis toolchain status")} for the per-tool breakdown.`)}u.log("")},"printBanner"),pn=S(async({logger:e,options:t,visConfig:i,visConfigError:s,workspaceRoot:o})=>{if(!o)throw new Error("Could not determine workspace root.");const l=t.format==="json"||t.json===!0,c=xr(t.only,t.skip),p=!!t.quiet,d=!!t.noProgress,$=Sr(t.filter);if(c.size===0){u.error("No sections selected. Check your --only / --skip values."),process.exitCode=2;return}const R=Date.now(),w=ut(o),A=ui(o),E=!!process.stdout.isTTY,g=!l&&E&&!Jt&&!p&&!d;!l&&!g&&Yr({nodeVersion:process.versions.node,packageManagerName:w.name,packageManagerVersion:w.version,runtimeFindings:A,workspaceCount:void 0});const I=ht(o,at(o).packageManager),B=pi(o,w.name),X=B.length,L=!!pt(i?.security?.socket),F=ft(o);if(!l&&!p&&!g){const N=F.length>0?b(` · ${String(F.length)} workspace package${F.length===1?"":"s"}`):"";u.log(`${b("·")} ${b("Found")} ${ae(String(X))} ${b(`installed package${X===1?"":"s"}`)}${N}`)}const P=s?{hint:s.file?`Continuing with default settings — fix or regenerate ${s.file} (vis init --force).`:"Continuing with default settings.",message:s.message,severity:"error",title:s.file?`Failed to load ${s.file}`:"Failed to load vis.config"}:void 0,_={bun:"bun.lock",npm:"package-lock.json",pnpm:"pnpm-lock.yaml",yarn:"yarn.lock"}[w.name],W=_?te(o,_):void 0,re=ni(o),Y=!t.noCache&&!t.fix?Si({configPath:re,lockfilePath:W,sections:c,socketEnabled:L,workspaceRoot:o}):void 0,O=Y?$i(Y):void 0,V=O!==void 0;let K,v;if(g){const N=O?new it({activeSections:c,findings:Ct(bt(O),$)}):new it({activeSections:c}),Q=Vt(Xt.createElement(kr,{banner:P,fromCache:V,startedAt:R,store:N}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0});try{K=O??await lt({filterPatterns:$,installed:B,resolveCodemods:!!t.fix,sections:c,store:N,visConfig:i,workspaceRoot:o})}catch(ee){throw Q.unmount(),ee}await Q.waitUntilExit(),v=N.getSnapshot().pendingAction}else if(O)K=O;else{const N=Gr(c,I.size,L,X,!!t.fix),Q=gi(N,{live:!l&&!p&&!d});try{K=await lt({filterPatterns:$,installed:B,progress:Q,resolveCodemods:!!t.fix,sections:c,visConfig:i,workspaceRoot:o})}finally{Q.stop()}}const T={...K,elapsedMs:Date.now()-R};if(Y&&!V)try{Ci(Y,T)}catch{}const C=$r(T,$);if(l){process.stdout.write(`${JSON.stringify(Rr(C,w.name),void 0,2)}
|
|
4
|
+
`),t.exitCode&&ot(C,!!t.strict)&&(process.exitCode=1);return}V&&!p&&u.log(`${b("·")} Cached results (use --no-cache to refresh)`),$.length>0&&!p&&u.log(`${b("·")} Filter active: ${Te(t.filter??"")}`),Hr(C,p);const H=C.runtime.some(N=>N.id===Oe&&N.status==="warn"),de=C.sections.has("optimization")&&C.optimizations.length>0;t.fix&&(de||H)?await Kr({force:!!t.fixForce,logger:e,pm:w,recoverOrphans:H,results:C,useEditorconfig:i?.editorconfig??!0,workspaceRoot:o}):p||Vr(C),v&&(process.stdout.write(`
|
|
5
|
+
`),process.stdout.write(`${ae("→ ")}${v.description}
|
|
6
|
+
`),v.configSnippet?(process.stdout.write(`
|
|
7
|
+
`),process.stdout.write(`${b(v.configSnippet)}
|
|
8
|
+
`)):process.stdout.write(` ${Te(v.command)}
|
|
9
|
+
`),process.stdout.write(`
|
|
10
|
+
`)),t.exitCode&&ot(C,!!t.strict)&&(process.exitCode=1)},"execute"),Kr=S(async e=>{const{force:t,logger:i,pm:s,recoverOrphans:o,results:l,useEditorconfig:c,workspaceRoot:p}=e;u.log(""),u.log(ce("Applying fixes","ok"));const d=l.optimizations.filter(g=>g.category==="socket"&&g.overrideSpec).map(g=>({original:g.packageName,spec:g.overrideSpec})),$=l.optimizations.filter(g=>g.category!=="socket"&&g.hasCodemod),R=l.optimizations.filter(g=>g.category!=="socket"&&!g.hasCodemod);let w=!1,A=0;const E=[];if(o){const g=Pi({force:t});if(g.killed.length>0&&(u.success(`Cleaned up ${String(g.killed.length)} orphaned process${g.killed.length===1?"":"es"} (PIDs: ${g.killed.join(", ")}).`),w=!0),g.failed.length>0){const I=t?"":" Re-run with `--fix --fix-force` to escalate to SIGKILL.";u.warn(`Could not signal ${String(g.failed.length)} orphan${g.failed.length===1?"":"s"}: ${g.failed.map(B=>`${String(B.pid)} (${B.reason})`).join(", ")}.${I}`)}}if(d.length>0){const g=ci(p,te(p,"package.json"),d,s,c);g.added.length>0&&(u.success(`Added ${String(g.added.length)} security override${g.added.length===1?"":"s"}.`),w=!0),g.updated.length>0&&(u.success(`Updated ${String(g.updated.length)} override${g.updated.length===1?"":"s"}.`),w=!0)}for(const g of $)try{const I=await di(p,g.packageName);I.filesChanged>0&&(u.success(`${g.packageName}: ${String(I.filesChanged)} file${I.filesChanged===1?"":"s"} updated`),A+=1,w=!0)}catch(I){const B=I instanceof Error?I.message:String(I);E.push({error:B,package:g.packageName}),u.warn(`${g.packageName}: codemod failed — ${B}`)}d.length>0&&(u.log(`${Te(j.arrow)} Running ${s.name} install to update lockfile…`),qt(s,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},p,i),w=!0),u.log(""),w?u.success(`Fixes applied. ${A>0?`${String(A)} codemod${A===1?"":"s"} applied.`:""}`.trim()):u.log(At("No auto-fixable items in the current run.")),E.length>0&&u.warn(`${String(E.length)} codemod${E.length===1?"":"s"} failed (run ${we("vis optimize")} for the interactive picker).`),R.length>0&&u.notice(`${String(R.length)} optimization${R.length===1?"":"s"} need manual review (no codemod). Run ${we("vis optimize")} to inspect them.`)},"runFixes");export{pn as default};
|