@visulima/vis 4.2.0 → 4.3.1

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.
Files changed (215) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/LICENSE.md +55 -129
  3. package/dist/bin.js +1 -1
  4. package/dist/binx.js +1 -1
  5. package/dist/config/index.d.ts +96 -0
  6. package/dist/packem_chunks/CONFIG_FILES.js +3 -3
  7. package/dist/packem_chunks/bloom-status.js +1 -1
  8. package/dist/packem_chunks/bloom-sync.js +1 -1
  9. package/dist/packem_chunks/cargo-plan.js +3 -0
  10. package/dist/packem_chunks/catalog.js +51 -48
  11. package/dist/packem_chunks/cli-exec.js +1 -1
  12. package/dist/packem_chunks/cli-main.js +164 -164
  13. package/dist/packem_chunks/composer-projects.js +2 -0
  14. package/dist/packem_chunks/dart-plan.js +1 -0
  15. package/dist/packem_chunks/dart-projects.js +1 -0
  16. package/dist/packem_chunks/dispatch.js +1 -1
  17. package/dist/packem_chunks/fix.js +8 -8
  18. package/dist/packem_chunks/gem-plan.js +2 -0
  19. package/dist/packem_chunks/gem-projects.js +1 -0
  20. package/dist/packem_chunks/git.js +5 -5
  21. package/dist/packem_chunks/go-plan.js +1 -0
  22. package/dist/packem_chunks/go-projects.js +2 -0
  23. package/dist/packem_chunks/gradle-plan.js +1 -0
  24. package/dist/packem_chunks/handler.js +1 -1
  25. package/dist/packem_chunks/handler10.js +3 -3
  26. package/dist/packem_chunks/handler11.js +1 -1
  27. package/dist/packem_chunks/handler12.js +2 -2
  28. package/dist/packem_chunks/handler13.js +1 -1
  29. package/dist/packem_chunks/handler14.js +1 -1
  30. package/dist/packem_chunks/handler15.js +1 -1
  31. package/dist/packem_chunks/handler16.js +1 -1
  32. package/dist/packem_chunks/handler17.js +1 -1
  33. package/dist/packem_chunks/handler18.js +1 -1
  34. package/dist/packem_chunks/handler19.js +1 -1
  35. package/dist/packem_chunks/handler2.js +1 -1
  36. package/dist/packem_chunks/handler20.js +2 -2
  37. package/dist/packem_chunks/handler21.js +1 -1
  38. package/dist/packem_chunks/handler22.js +1 -1
  39. package/dist/packem_chunks/handler23.js +1 -1
  40. package/dist/packem_chunks/handler24.js +1 -1
  41. package/dist/packem_chunks/handler26.js +1 -1
  42. package/dist/packem_chunks/handler27.js +1 -1
  43. package/dist/packem_chunks/handler28.js +1 -1
  44. package/dist/packem_chunks/handler29.js +1 -1
  45. package/dist/packem_chunks/handler3.js +1 -1
  46. package/dist/packem_chunks/handler30.js +1 -1
  47. package/dist/packem_chunks/handler39.js +6 -6
  48. package/dist/packem_chunks/handler4.js +3 -3
  49. package/dist/packem_chunks/handler5.js +2 -2
  50. package/dist/packem_chunks/handler50.js +1 -1
  51. package/dist/packem_chunks/handler51.js +1 -1
  52. package/dist/packem_chunks/handler53.js +1 -1
  53. package/dist/packem_chunks/handler54.js +2 -2
  54. package/dist/packem_chunks/handler55.js +1 -1
  55. package/dist/packem_chunks/handler58.js +2 -2
  56. package/dist/packem_chunks/handler59.js +1 -1
  57. package/dist/packem_chunks/handler6.js +7 -7
  58. package/dist/packem_chunks/handler60.js +8 -8
  59. package/dist/packem_chunks/handler61.js +1 -1
  60. package/dist/packem_chunks/handler62.js +16 -16
  61. package/dist/packem_chunks/handler63.js +2 -2
  62. package/dist/packem_chunks/handler64.js +1 -1
  63. package/dist/packem_chunks/handler65.js +3 -3
  64. package/dist/packem_chunks/handler66.js +2 -2
  65. package/dist/packem_chunks/handler67.js +3 -3
  66. package/dist/packem_chunks/handler68.js +4 -4
  67. package/dist/packem_chunks/handler69.js +3 -3
  68. package/dist/packem_chunks/handler7.js +1 -1
  69. package/dist/packem_chunks/handler70.js +5 -5
  70. package/dist/packem_chunks/handler71.js +5 -5
  71. package/dist/packem_chunks/handler72.js +2 -2
  72. package/dist/packem_chunks/handler73.js +87 -86
  73. package/dist/packem_chunks/handler74.js +1 -1
  74. package/dist/packem_chunks/handler75.js +23 -23
  75. package/dist/packem_chunks/handler76.js +6 -6
  76. package/dist/packem_chunks/handler77.js +2 -2
  77. package/dist/packem_chunks/handler78.js +19 -19
  78. package/dist/packem_chunks/handler8.js +1 -1
  79. package/dist/packem_chunks/handler9.js +1 -1
  80. package/dist/packem_chunks/heal-accept.js +1 -1
  81. package/dist/packem_chunks/heal.js +1 -1
  82. package/dist/packem_chunks/help-command.js +7 -7
  83. package/dist/packem_chunks/hex-plan.js +3 -0
  84. package/dist/packem_chunks/hex-projects.js +1 -0
  85. package/dist/packem_chunks/index2.js +52 -42
  86. package/dist/packem_chunks/index4.js +58 -802
  87. package/dist/packem_chunks/index5.js +802 -7
  88. package/dist/packem_chunks/index6.js +7 -58
  89. package/dist/packem_chunks/keys-refresh.js +1 -1
  90. package/dist/packem_chunks/lean.js +1 -1
  91. package/dist/packem_chunks/list.js +2 -2
  92. package/dist/packem_chunks/loader.js +1 -1
  93. package/dist/packem_chunks/maven-plan.js +1 -0
  94. package/dist/packem_chunks/maven-projects.js +1 -0
  95. package/dist/packem_chunks/nuget-plan.js +1 -0
  96. package/dist/packem_chunks/nuget-projects.js +1 -0
  97. package/dist/packem_chunks/orchestrator.js +33 -33
  98. package/dist/packem_chunks/prune.js +1 -1
  99. package/dist/packem_chunks/python-plan.js +3 -0
  100. package/dist/packem_chunks/python-projects.js +1 -0
  101. package/dist/packem_chunks/run.js +1 -1
  102. package/dist/packem_chunks/security.js +1 -1
  103. package/dist/packem_chunks/snapshot.js +2 -2
  104. package/dist/packem_chunks/status.js +1 -1
  105. package/dist/packem_chunks/swift-projects.js +1 -0
  106. package/dist/packem_chunks/sync.js +3 -2
  107. package/dist/packem_chunks/sync2.js +1 -1
  108. package/dist/packem_chunks/tripwire.js +2 -2
  109. package/dist/packem_chunks/ts-loader.js +5 -5
  110. package/dist/packem_chunks/verify-lockfile.js +2 -2
  111. package/dist/packem_chunks/version-resolver.js +3 -3
  112. package/dist/packem_chunks/zig-plan.js +1 -0
  113. package/dist/packem_chunks/zig-projects.js +1 -0
  114. package/dist/packem_shared/{affected-selection-M7riOi5-.js → affected-selection-D4giBK2X.js} +1 -1
  115. package/dist/packem_shared/{affected-shas-CAwpSPmP.js → affected-shas-B2V84O0g.js} +1 -1
  116. package/dist/packem_shared/{ai-analysis-DSQQDFU9.js → ai-analysis-pldoS_N4.js} +2 -2
  117. package/dist/packem_shared/{ai-fix-BTm1Z5og.js → ai-fix-BC6aIRJT.js} +4 -4
  118. package/dist/packem_shared/{augment-CBv1hwMR.js → augment-B9kSZuvW.js} +1 -1
  119. package/dist/packem_shared/{bin-Cbs_ix6l.js → bin-C1XKj-O-.js} +1 -1
  120. package/dist/packem_shared/build-scripts-CEDx_nJp.js +1 -0
  121. package/dist/packem_shared/{command-runtime-BD-4UmPB.js → command-runtime-p4IXiIf6.js} +1 -1
  122. package/dist/packem_shared/composer-DR3D-Psb.js +1 -0
  123. package/dist/packem_shared/dart-pubspec-BK_cK2EP.js +2 -0
  124. package/dist/packem_shared/dependency-scan-B8jroa1D.js +1 -0
  125. package/dist/packem_shared/{docker-1jgKW5Wd.js → docker-DXqV-07f.js} +3 -3
  126. package/dist/packem_shared/ecosystem-gate-ddru_hOg.js +6 -0
  127. package/dist/packem_shared/failure-log-D2x5BT8S.js +2 -0
  128. package/dist/packem_shared/formatBytes-BHAzNIrn-CrusHOew.js +4 -0
  129. package/dist/packem_shared/gemspec-K7N05xxc.js +3 -0
  130. package/dist/packem_shared/go-modules-BsVqtyeC.js +1 -0
  131. package/dist/packem_shared/gradle-build-CHZDHyjI.js +8 -0
  132. package/dist/packem_shared/index-BzhrR_iC.js +22 -0
  133. package/dist/packem_shared/index-Chje3u9v.js +1 -0
  134. package/dist/packem_shared/{index-Cq-J2MdB.js → index-DQ2GJzmy.js} +1 -1
  135. package/dist/packem_shared/{isAccessibleSync-DYKTrrvc-K2xhg6sV.js → isAccessibleSync-DYKTrrvc-C-_5cgwu.js} +1 -1
  136. package/dist/packem_shared/lifecycle-D6PMPor-.js +2 -0
  137. package/dist/packem_shared/lockfile-CiUtEbnt.js +1 -0
  138. package/dist/packem_shared/manifests-Du4yKlf_.js +1 -0
  139. package/dist/packem_shared/maven-pom-B0KG9kJQ.js +1 -0
  140. package/dist/packem_shared/{min-release-age-Da4V046o.js → min-release-age-JViyQuBM.js} +7 -7
  141. package/dist/packem_shared/missing-package-json-Cu5YVAot.js +1 -0
  142. package/dist/packem_shared/mix-project-RYvdZp3_.js +2 -0
  143. package/dist/packem_shared/multi-eco-lockfiles-B2X3yhyo.js +1 -0
  144. package/dist/packem_shared/{native-config-sync-CEB0rWlk.js → native-config-sync-TdTWjVgI.js} +1 -1
  145. package/dist/packem_shared/nuget-project-RApYSW_y.js +4 -0
  146. package/dist/packem_shared/{osv-bloom-BRacgzs7.js → osv-bloom-BCAX5ARR.js} +1 -1
  147. package/dist/packem_shared/package-version-Dxirp-UO.js +4 -0
  148. package/dist/packem_shared/packument-BQv4je9m.js +1 -0
  149. package/dist/packem_shared/pm-runner-CMSml1Bj.js +1 -0
  150. package/dist/packem_shared/{project-name-filter-zrdrEQbu.js → project-name-filter-D6tXD8gd.js} +1 -1
  151. package/dist/packem_shared/{provenance-CFPT_FQA.js → provenance-DNyVMxNv.js} +1 -1
  152. package/dist/packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js +1 -0
  153. package/dist/packem_shared/registry-keys-DwB3ZXS_.js +1 -0
  154. package/dist/packem_shared/{resolve-explicit-opfIkxoY.js → resolve-explicit-BPsdmuty.js} +1 -1
  155. package/dist/packem_shared/resolve-runtime-CNiHcVtx.js +1 -0
  156. package/dist/packem_shared/run-file-UBukWaha.js +1 -0
  157. package/dist/packem_shared/runtime-check-1U8HrQd9.js +1 -0
  158. package/dist/packem_shared/s1ngularity-QD2LD1sO.js +1 -0
  159. package/dist/packem_shared/{scan-progress-BGB9hIrD.js → scan-progress-CkumcBG-.js} +2 -2
  160. package/dist/packem_shared/{selectors-CjIZ3gy2.js → selectors-edwcgNl3.js} +1 -1
  161. package/dist/packem_shared/{signatures-DpqZVmmU.js → signatures-t8LbOaqr.js} +1 -1
  162. package/dist/packem_shared/spinner-ukDEdGvp.js +1 -0
  163. package/dist/packem_shared/swift-package-B6X5kzQE.js +1 -0
  164. package/dist/packem_shared/tabs--uxJGL8N.js +1 -0
  165. package/dist/packem_shared/{target-merge-hsawesT4.js → target-merge-DVJl-7Qz.js} +1 -1
  166. package/dist/packem_shared/target-options-DsHFmRZH.js +1 -0
  167. package/dist/packem_shared/toolchain-BRdpaAC4.js +5 -0
  168. package/dist/packem_shared/typosquats-8u0drCqQ.js +1 -0
  169. package/dist/packem_shared/use-measured-height-DUZyyias.js +1 -0
  170. package/dist/packem_shared/verify-B_MblU_Q.js +1 -0
  171. package/dist/packem_shared/{vis-update-app-D9KWJ9Ir.js → vis-update-app-BCIccZfA.js} +1 -1
  172. package/dist/packem_shared/{vis-user-error-Bdg9NRuJ.js → vis-user-error-75VtCwMv.js} +15 -15
  173. package/dist/packem_shared/watch-CcTketln.js +1 -0
  174. package/dist/packem_shared/watch-loop-qRn0IHPG.js +11 -0
  175. package/dist/packem_shared/{writeFileSync-DJoHk3Ks-O9zOKqeM.js → writeFileSync-DJoHk3Ks-BPRoepNw.js} +1 -1
  176. package/dist/packem_shared/zig-manifest-P7ydLEOa.js +7 -0
  177. package/dist/release/plugin-sdk.d.ts +1 -1
  178. package/dist/release/types.d.ts +133 -7
  179. package/dist/runtime/preload.js +1 -1
  180. package/index.d.ts +204 -204
  181. package/index.js +52 -52
  182. package/package.json +11 -11
  183. package/schemas/vis-config.schema.json +265 -5
  184. package/schemas/vis-release-config.schema.json +132 -5
  185. package/dist/packem_shared/advisories-BSpzRIXP.js +0 -1
  186. package/dist/packem_shared/build-scripts-BIgkWVgY.js +0 -1
  187. package/dist/packem_shared/cyclonedx-CT1rtKxV.js +0 -4
  188. package/dist/packem_shared/dependency-scan-W9b2X0a1.js +0 -1
  189. package/dist/packem_shared/failure-log-B91LvYWw.js +0 -2
  190. package/dist/packem_shared/formatBytes-BHAzNIrn-CLYsxlUj.js +0 -4
  191. package/dist/packem_shared/index-CVBR-Kit.js +0 -22
  192. package/dist/packem_shared/index-onibYJkv.js +0 -1
  193. package/dist/packem_shared/lifecycle-DDJzp-4H.js +0 -2
  194. package/dist/packem_shared/lockfile-Bi1mw9jJ.js +0 -1
  195. package/dist/packem_shared/manifests-D671Sb1T.js +0 -1
  196. package/dist/packem_shared/missing-package-json-CMoHdvmj.js +0 -1
  197. package/dist/packem_shared/package-version-C5EPMgRw.js +0 -4
  198. package/dist/packem_shared/packument-DuEV-qSE.js +0 -1
  199. package/dist/packem_shared/path-CxEa27Rz-pjheKk6v.js +0 -1
  200. package/dist/packem_shared/pm-runner-9L6ocnu2.js +0 -1
  201. package/dist/packem_shared/readJsonSync-CbryXYxN-BxKjDZnF.js +0 -1
  202. package/dist/packem_shared/registry-keys-C3EsP_s4.js +0 -1
  203. package/dist/packem_shared/resolve-runtime-lJ5L9gU4.js +0 -1
  204. package/dist/packem_shared/run-file-DZff6GqY.js +0 -1
  205. package/dist/packem_shared/runtime-check-DAbveBr_.js +0 -1
  206. package/dist/packem_shared/s1ngularity-DTvrfWIM.js +0 -1
  207. package/dist/packem_shared/spinner-BVCEMm3G.js +0 -1
  208. package/dist/packem_shared/tabs-Dz6xVpfX.js +0 -1
  209. package/dist/packem_shared/target-options-Bxb0Y5qa.js +0 -1
  210. package/dist/packem_shared/toolchain-887JoquG.js +0 -5
  211. package/dist/packem_shared/typosquats-Xv6dN4sr.js +0 -1
  212. package/dist/packem_shared/use-measured-height-BPQg2q_p.js +0 -1
  213. package/dist/packem_shared/verify-BLoaI7En.js +0 -1
  214. package/dist/packem_shared/watch-BTZw2Y8Q.js +0 -1
  215. package/dist/packem_shared/watch-loop-Cjh2wlUl.js +0 -11
@@ -1,7 +1,7 @@
1
- import{createRequire as nr}from"node:module";import{z as cr}from"../packem_shared/index-CVBR-Kit.js";import{expandAffected as ar,getChangedFiles as lr,buildEnhancedPath as dr,enforceProjectConstraints as ur,expandTokensInString as Yt,parsePartition as fr,TaskScheduler as hr,createTaskGraph as pr,reverseTaskGraph as mr,resolveTurboEnvCompat as gr,CompositeLifeCycle as Kt,defaultTaskRunner as Xt,TerminalBuffer as yt,runConcurrently as tt,createLogReporter as wr,generateRunSummary as Jt,writeRunSummary as vr,readLastRunSummary as yr,getLastRunSummaryPath as xr,writeChromeTrace as jr}from"@visulima/task-runner";import{i as Ye}from"../packem_shared/index-BjdW45xX.js";import{U as Ts,W as kr,T as br,v as Qt,X as Sr,Y as Tr,d as $r,Z as Ir,ar as Cr,as as Er,at as Rr,au as Pr,k as Mr,av as Fr}from"./cli-main.js";import{u as z,A as n,X as g,m as l,E as pe,R as J,x as Or,d as Ar,b as Lr,U as Dr}from"./catalog.js";import{V as Ke}from"../packem_shared/vis-user-error-Bdg9NRuJ.js";import{d as Br,r as _r}from"../packem_shared/lockfile-Bi1mw9jJ.js";import{e as ce,m as $s,$ as zr,n as Yr}from"../packem_shared/path-CxEa27Rz-pjheKk6v.js";import{y as Is}from"../packem_shared/index-BisalDCf.js";import{F as Kr}from"../packem_shared/failure-log-B91LvYWw.js";import{r as Xr}from"../packem_shared/command-runtime-BD-4UmPB.js";import{r as Jr}from"../packem_shared/toolchain-887JoquG.js";import{i as Qr,r as Zr,s as en,a as tn,b as sn,c as rn,d as nn,e as on,H as cn,f as an}from"../packem_shared/lifecycle-DDJzp-4H.js";import{s as ln}from"../packem_shared/affected-selection-M7riOi5-.js";import{c as es,p as dn,a as un,b as fn,r as hn,f as pn,s as mn}from"../packem_shared/project-name-filter-zrdrEQbu.js";import{p as gn,r as wn,f as vn,a as yn}from"../packem_shared/selectors-CjIZ3gy2.js";import{r as at,l as jt,d as xn,s as jn,m as kn,a as bn}from"../packem_shared/target-options-Bxb0Y5qa.js";import{T as Cs,C as Es,D as lt,E as Rs}from"../packem_shared/symbols-BXDZ_sKt.js";import{q as Cn,j as En,X as ht,F as ss}from"../packem_shared/index.server-sXNQYpsl.js";import{parseStacktrace as Rn,codeFrame as Pn}from"@visulima/error";import{originalPositionFor as Mn,sourceContentFor as Fn,loadSourceMap as On}from"@visulima/source-map";import{l as Ps}from"../packem_shared/spinner-BVCEMm3G.js";import{Q as _n,c as st}from"../packem_shared/formatBytes-BHAzNIrn-CLYsxlUj.js";import{c as rs,a as Nn,s as ns}from"../packem_shared/watch-BTZw2Y8Q.js";import gt from"./index.js";import{U as Ms}from"../packem_shared/writeFileSync-DJoHk3Ks-O9zOKqeM.js";let ir;const or=s=>(ir??=nr(import.meta.url))(s),ze=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Me=s=>{if(typeof ze<"u"&&ze.versions&&ze.versions.node){const[e,t]=ze.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return ze.getBuiltinModule(s)}return or(s)},{existsSync:De,mkdirSync:Nr,writeFileSync:xt,readFileSync:We,openSync:Gr,statSync:Zt,readSync:Wr,closeSync:Hr,mkdtempSync:qr}=Me("node:fs"),{createInterface:Vr,emitKeypressEvents:Ur}=Me("node:readline"),{isAbsolute:Sn,resolve:ts,dirname:Tn,relative:$n}=Me("node:path"),{fileURLToPath:In}=Me("node:url"),{createHash:An}=Me("node:crypto"),{mkdir:Ln,appendFile:dt}=Me("node:fs/promises"),{platform:Dn,homedir:kt,tmpdir:Bn}=Me("node:os"),{spawn:Gn}=Me("node:child_process"),Wn=27,Hn={95:"apc",80:"dcs",94:"pm",88:"sos"},qn={159:"apc",144:"dcs",158:"pm",152:"sos"},Fs=s=>s===155||s===157||s===144||s===152||s===158||s===159,Os=(s,e)=>{for(let t=e;t<s.length;t+=1){const r=s.codePointAt(t);if(r>=64&&r<=126)return t}return-1},rt=(s,e,t)=>{for(let r=e;r<s.length;r+=1){const c=s.codePointAt(r);if(c===156||t&&c===7)return r;if(c===27&&s.codePointAt(r+1)===92)return r+1}return-1},Vn=(s,e)=>{const t=s.codePointAt(e+1);if(t===91){const r=Os(s,e+2);return r===-1?void 0:{end:r,kind:"csi"}}if(t===93){const r=rt(s,e+2,!0);return r===-1?void 0:{end:r,kind:"osc"}}if(t===80||t===88||t===94||t===95){const r=rt(s,e+2,!1),c=Hn[t];return r===-1?void 0:{end:r,kind:c}}return t===void 0?void 0:{end:e+1,kind:"escape"}},Un=(s,e)=>{const t=s.codePointAt(e);if(t===155){const r=Os(s,e+1);return r===-1?void 0:{end:r,kind:"csi"}}if(t===157){const r=rt(s,e+1,!0);return r===-1?void 0:{end:r,kind:"osc"}}if(t===144||t===152||t===158||t===159){const r=rt(s,e+1,!1),c=qn[t];return r===-1?void 0:{end:r,kind:c}}},zn=s=>{if(s.includes(String.fromCodePoint(27)))return!0;for(let e=0;e<s.length;e+=1)if(Fs(s.codePointAt(e)))return!0;return!1},Yn=s=>{if(!zn(s))return s;let e="",t=0,r=0;const{length:c}=s;for(;r<c;){const o=s.codePointAt(r);let i;if(o===Wn)i=Vn(s,r);else if(Fs(o))i=Un(s,r);else{r+=1;continue}const d=i===void 0?c-1:i.end;e+=s.slice(t,r),t=d+1,r=d+1}return e+=s.slice(t),e},Kn=(s,e,t,r,c,o,i,d,u,h,f,p,a,k)=>{const S={d:r,h:c,m:o,mo:e,ms:d,s:i,w:t,y:s};return S.future=u,S.past=h,S.decimal=f,p!==void 0&&(S.unitMap=p),S.groupSeparator=a,S.placeholderSeparator=k,S},Xn={d:"d",day:"d",days:"d",h:"h",hour:"h",hours:"h",hr:"h",hrs:"h",m:"m",millisecond:"ms",milliseconds:"ms",min:"m",mins:"m",minute:"m",minutes:"m",mo:"mo",month:"mo",months:"mo",ms:"ms",s:"s",sec:"s",second:"s",seconds:"s",secs:"s",w:"w",week:"w",weeks:"w",y:"y",year:"y",years:"y",yr:"y",yrs:"y"},Jn=Kn(s=>`year${s===1?"":"s"}`,s=>`month${s===1?"":"s"}`,s=>`week${s===1?"":"s"}`,s=>`day${s===1?"":"s"}`,s=>`hour${s===1?"":"s"}`,s=>`minute${s===1?"":"s"}`,s=>`second${s===1?"":"s"}`,s=>`millisecond${s===1?"":"s"}`,"in %s","%s ago",".",Xn,",","_"),is=new WeakSet,Qn=s=>{if(is.has(s))return;const e=["y","mo","w","d","h","m","s","ms"];for(const r of e)if(!Object.hasOwn(s,r))throw new TypeError(`Missing required property: ${r}`);if(s.future!==void 0&&typeof s.future!="string")throw new TypeError("Properties future and past must be of type string");if(s.past!==void 0&&typeof s.past!="string")throw new TypeError("Properties future and past must be of type string");const t=["y","mo","w","d","h","m","s","ms"];for(const r of t)if(typeof s[r]!="string"&&typeof s[r]!="function")throw new TypeError(`Property ${r} must be of type string or function`);if(s.decimal&&typeof s.decimal!="string")throw new TypeError("Property decimal must be of type string");if(s.delimiter&&typeof s.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(s._digitReplacements&&!Array.isArray(s._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(s._numberFirst&&typeof s._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(s.unitMap&&typeof s.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(s.unitMap&&Object.values(s.unitMap).some(r=>typeof r!="string"))throw new TypeError("All values in unitMap must be of type string");is.add(s)},As=(s,e)=>{if(!Number.isFinite(s)||e<0||Number.isInteger(s))return s;const t=10**e,r=Number((s*t).toPrecision(15));return Math.trunc(r)/t},os=({unitCount:s,unitName:e},t,r)=>{let{spacer:c}=r;const{maxDecimalPoints:o}=r;let i=".";r.decimal!==void 0?i=r.decimal:t.decimal!==void 0&&(i=t.decimal);let d;"digitReplacements"in r?d=r.digitReplacements:"_digitReplacements"in t&&(d=t._digitReplacements);let u,h=s;o!==void 0&&(h=As(s,o));const f=h.toString();if(!t._hideCountIf2||s!==2)if(d){u="";for(const k of f)u+=k==="."?i:d[k]}else u=f.replace(".",i);else u="";const p=t[e];let a=p;return typeof p=="function"&&(a=p(s)),t._hideCountIf2&&s===2&&(c=""),t._numberFirst?a+c+u:u+c+a},Zn=(s,e)=>{const{units:t}=e;if(t.length===0)return[];const{unitMeasures:r}=e,c=e.largest??Number.POSITIVE_INFINITY,o={};let i,d,u,h=s;for(d=0;d<t.length;d++){i=t[d];const p=r[i];u=d===t.length-1?h/p:Math.floor(h/p),o[i]=u,h-=u*p}if(e.round){let p=c;for(d=0;d<t.length;d++)if(i=t[d],u=o[i],u!==0&&(p--,p===0)){for(let a=d+1;a<t.length;a++){const k=t[a],S=o[k];o[i]=(o[i]??0)+S*r[k]/r[i],o[k]=0}break}for(d=t.length-1;d>=0;d--){if(i=t[d],u=o[i],u===0)continue;const a=Math.round(u);if(o[i]=a,d===0)break;const k=t[d-1],S=r[k],B=Math.floor(a*r[i]/S);if(B)o[k]=(o[k]??0)+B,o[i]=0;else break}}const f=[];for(d=0;d<t.length&&f.length<c;d++){if(i=t[d],u=o[i],u&&!e.round&&f.length===c-1){let p,a=0;for(p=d+1,t.length;p<t.length;p++){const k=t[p];a+=o[k]*(e.unitMeasures[k]/e.unitMeasures[i])}u+=a,e.maxDecimalPoints!==void 0&&(u=As(u,e.maxDecimalPoints))}u&&f.push({unitCount:u,unitName:i})}return f},ei=(s,e,t)=>{const{language:r,units:c}=e;if(s.length===0){const p=c.at(-1);return os({unitCount:0,unitName:p},r,e)}const{conjunction:o,serialComma:i}=e;let d=", ";e.delimiter!==void 0?d=e.delimiter:r.delimiter!==void 0&&(d=r.delimiter);let u="";e.timeAdverb&&t!==0&&(u=r.future??"",t<0&&(u=r.past??""));const h=s.map(p=>os(p,r,e));let f;return!o||s.length===1?f=h.join(d):s.length===2?f=h.join(o):f=h.slice(0,-1).join(d)+(i?",":"")+o+(h.at(-1)??""),u&&(f=u.replace("%s",f)),f},ti=(s,e)=>{if(Number.isNaN(s))throw new TypeError("Expected a valid number");if(typeof s!="number")throw new TypeError("Expected a number for milliseconds input");const t={conjunction:"",language:Jn,round:!1,serialComma:!0,spacer:" ",timeAdverb:!1,unitMeasures:{d:864e5,h:36e5,m:6e4,mo:2629746e3,ms:1,s:1e3,w:6048e5,y:31556952e3},units:["w","d","h","m","s"],...e};Qn(t.language);const r=Math.abs(s),c=Zn(r,t);return ei(c,t,s)},Te="@voidzero-dev/vite-task-client",bt="@visulima/task-runner-client",nt=`npm:${bt}@^1`,Ls=ce(".vis",".vite-client-override-declined"),it="pnpm-workspace.yaml",si=["dependencies","devDependencies","optionalDependencies","peerDependencies"],Ds=s=>{try{return JSON.parse(We(s,"utf8"))}catch{return}},ri=s=>{const e=ce(s,it);if(De(e))try{return Is(We(e,"utf8")).toJS()?.overrides}catch{return}},ni=s=>s==="pnpm"||s==="aube"?"pnpm.overrides":s==="yarn"?"resolutions":"overrides",ii=s=>{const e=ce(s,it);try{const t=Is(We(e,"utf8"));return t.setIn(["overrides",Te],nt),xt(e,t.toString()),!0}catch{return!1}},cs=s=>s!==void 0&&si.some(e=>s[e]?.[Te]!==void 0),oi=(s,e)=>s!==void 0&&(s.pnpm?.overrides?.[Te]!==void 0||s.overrides?.[Te]!==void 0||s.resolutions?.[Te]!==void 0)||e?.[Te]!==void 0,ci=(s,e=[])=>{const t=Ds(ce(s,"package.json")),r=De(ce(s,"node_modules","@voidzero-dev","vite-task-client"));return{alreadyOverridden:oi(t,ri(s)),declined:De(ce(s,Ls)),manager:Br(s)?.manager,present:cs(t)||r||e.some(c=>cs(c))}},ai=s=>{try{const e=ce(s,Ls);Nr($s(e),{recursive:!0}),xt(e,`Declined adding the ${Te} → ${bt} override.
1
+ import{createRequire as nr}from"node:module";import{e as ce,m as Ts,$ as cr,a as ar,z as lr}from"../packem_shared/index-BzhrR_iC.js";import{expandAffected as dr,getChangedFiles as ur,buildEnhancedPath as fr,enforceProjectConstraints as hr,expandTokensInString as Yt,parsePartition as pr,TaskScheduler as mr,createTaskGraph as gr,reverseTaskGraph as wr,resolveTurboEnvCompat as vr,CompositeLifeCycle as Kt,defaultTaskRunner as Xt,TerminalBuffer as yt,runConcurrently as tt,createLogReporter as yr,generateRunSummary as Jt,writeRunSummary as xr,readLastRunSummary as jr,getLastRunSummaryPath as kr,writeChromeTrace as br}from"@visulima/task-runner";import{i as Ye}from"../packem_shared/index-BjdW45xX.js";import{U as $s,W as Sr,T as Tr,C as Qt,X as $r,Y as Ir,q as Cr,Z as Er,ar as Rr,as as Pr,at as Mr,au as Fr,j as Or,av as Ar}from"./cli-main.js";import{x as z,F as n,X as g,o as l,O as pe,R as J,C as Lr,d as Dr,b as Br,a3 as _r}from"./catalog.js";import{V as Ke}from"../packem_shared/vis-user-error-75VtCwMv.js";import{d as Nr,r as Gr}from"../packem_shared/lockfile-CiUtEbnt.js";import{y as Is}from"../packem_shared/index-BisalDCf.js";import{F as Kr}from"../packem_shared/failure-log-D2x5BT8S.js";import{r as Xr}from"../packem_shared/command-runtime-p4IXiIf6.js";import{r as Jr}from"../packem_shared/toolchain-BRdpaAC4.js";import{i as Qr,r as Zr,s as en,a as tn,b as sn,c as rn,d as nn,e as on,H as cn,f as an}from"../packem_shared/lifecycle-D6PMPor-.js";import{s as ln}from"../packem_shared/affected-selection-D4giBK2X.js";import{c as es,p as dn,a as un,b as fn,r as hn,f as pn,s as mn}from"../packem_shared/project-name-filter-D6tXD8gd.js";import{p as gn,r as wn,f as vn,a as yn}from"../packem_shared/selectors-edwcgNl3.js";import{r as at,l as jt,d as xn,s as jn,m as kn,a as bn}from"../packem_shared/target-options-DsHFmRZH.js";import{T as Cs,C as Es,D as lt,E as Rs}from"../packem_shared/symbols-BXDZ_sKt.js";import{q as Cn,j as En,X as ht,F as ss}from"../packem_shared/index.server-sXNQYpsl.js";import{parseStacktrace as Rn,codeFrame as Pn}from"@visulima/error";import{originalPositionFor as Mn,sourceContentFor as Fn,loadSourceMap as On}from"@visulima/source-map";import{l as Ps}from"../packem_shared/spinner-ukDEdGvp.js";import{Q as _n,c as st}from"../packem_shared/formatBytes-BHAzNIrn-CrusHOew.js";import{c as rs,a as Nn,s as ns}from"../packem_shared/watch-CcTketln.js";import gt from"./index.js";import{U as Ms}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";let ir;const or=s=>(ir??=nr(import.meta.url))(s),ze=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Me=s=>{if(typeof ze<"u"&&ze.versions&&ze.versions.node){const[e,t]=ze.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return ze.getBuiltinModule(s)}return or(s)},{existsSync:De,mkdirSync:Wr,writeFileSync:xt,readFileSync:We,openSync:Hr,statSync:Zt,readSync:qr,closeSync:Vr,mkdtempSync:Ur}=Me("node:fs"),{createInterface:zr,emitKeypressEvents:Yr}=Me("node:readline"),{isAbsolute:Sn,resolve:ts,dirname:Tn,relative:$n}=Me("node:path"),{fileURLToPath:In}=Me("node:url"),{createHash:An}=Me("node:crypto"),{mkdir:Ln,appendFile:dt}=Me("node:fs/promises"),{platform:Dn,homedir:kt,tmpdir:Bn}=Me("node:os"),{spawn:Gn}=Me("node:child_process"),Wn=27,Hn={95:"apc",80:"dcs",94:"pm",88:"sos"},qn={159:"apc",144:"dcs",158:"pm",152:"sos"},Fs=s=>s===155||s===157||s===144||s===152||s===158||s===159,Os=(s,e)=>{for(let t=e;t<s.length;t+=1){const r=s.codePointAt(t);if(r>=64&&r<=126)return t}return-1},rt=(s,e,t)=>{for(let r=e;r<s.length;r+=1){const c=s.codePointAt(r);if(c===156||t&&c===7)return r;if(c===27&&s.codePointAt(r+1)===92)return r+1}return-1},Vn=(s,e)=>{const t=s.codePointAt(e+1);if(t===91){const r=Os(s,e+2);return r===-1?void 0:{end:r,kind:"csi"}}if(t===93){const r=rt(s,e+2,!0);return r===-1?void 0:{end:r,kind:"osc"}}if(t===80||t===88||t===94||t===95){const r=rt(s,e+2,!1),c=Hn[t];return r===-1?void 0:{end:r,kind:c}}return t===void 0?void 0:{end:e+1,kind:"escape"}},Un=(s,e)=>{const t=s.codePointAt(e);if(t===155){const r=Os(s,e+1);return r===-1?void 0:{end:r,kind:"csi"}}if(t===157){const r=rt(s,e+1,!0);return r===-1?void 0:{end:r,kind:"osc"}}if(t===144||t===152||t===158||t===159){const r=rt(s,e+1,!1),c=qn[t];return r===-1?void 0:{end:r,kind:c}}},zn=s=>{if(s.includes(String.fromCodePoint(27)))return!0;for(let e=0;e<s.length;e+=1)if(Fs(s.codePointAt(e)))return!0;return!1},Yn=s=>{if(!zn(s))return s;let e="",t=0,r=0;const{length:c}=s;for(;r<c;){const o=s.codePointAt(r);let i;if(o===Wn)i=Vn(s,r);else if(Fs(o))i=Un(s,r);else{r+=1;continue}const d=i===void 0?c-1:i.end;e+=s.slice(t,r),t=d+1,r=d+1}return e+=s.slice(t),e},Kn=(s,e,t,r,c,o,i,d,u,h,f,p,a,k)=>{const S={d:r,h:c,m:o,mo:e,ms:d,s:i,w:t,y:s};return S.future=u,S.past=h,S.decimal=f,p!==void 0&&(S.unitMap=p),S.groupSeparator=a,S.placeholderSeparator=k,S},Xn={d:"d",day:"d",days:"d",h:"h",hour:"h",hours:"h",hr:"h",hrs:"h",m:"m",millisecond:"ms",milliseconds:"ms",min:"m",mins:"m",minute:"m",minutes:"m",mo:"mo",month:"mo",months:"mo",ms:"ms",s:"s",sec:"s",second:"s",seconds:"s",secs:"s",w:"w",week:"w",weeks:"w",y:"y",year:"y",years:"y",yr:"y",yrs:"y"},Jn=Kn(s=>`year${s===1?"":"s"}`,s=>`month${s===1?"":"s"}`,s=>`week${s===1?"":"s"}`,s=>`day${s===1?"":"s"}`,s=>`hour${s===1?"":"s"}`,s=>`minute${s===1?"":"s"}`,s=>`second${s===1?"":"s"}`,s=>`millisecond${s===1?"":"s"}`,"in %s","%s ago",".",Xn,",","_"),is=new WeakSet,Qn=s=>{if(is.has(s))return;const e=["y","mo","w","d","h","m","s","ms"];for(const r of e)if(!Object.hasOwn(s,r))throw new TypeError(`Missing required property: ${r}`);if(s.future!==void 0&&typeof s.future!="string")throw new TypeError("Properties future and past must be of type string");if(s.past!==void 0&&typeof s.past!="string")throw new TypeError("Properties future and past must be of type string");const t=["y","mo","w","d","h","m","s","ms"];for(const r of t)if(typeof s[r]!="string"&&typeof s[r]!="function")throw new TypeError(`Property ${r} must be of type string or function`);if(s.decimal&&typeof s.decimal!="string")throw new TypeError("Property decimal must be of type string");if(s.delimiter&&typeof s.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(s._digitReplacements&&!Array.isArray(s._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(s._numberFirst&&typeof s._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(s.unitMap&&typeof s.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(s.unitMap&&Object.values(s.unitMap).some(r=>typeof r!="string"))throw new TypeError("All values in unitMap must be of type string");is.add(s)},As=(s,e)=>{if(!Number.isFinite(s)||e<0||Number.isInteger(s))return s;const t=10**e,r=Number((s*t).toPrecision(15));return Math.trunc(r)/t},os=({unitCount:s,unitName:e},t,r)=>{let{spacer:c}=r;const{maxDecimalPoints:o}=r;let i=".";r.decimal!==void 0?i=r.decimal:t.decimal!==void 0&&(i=t.decimal);let d;"digitReplacements"in r?d=r.digitReplacements:"_digitReplacements"in t&&(d=t._digitReplacements);let u,h=s;o!==void 0&&(h=As(s,o));const f=h.toString();if(!t._hideCountIf2||s!==2)if(d){u="";for(const k of f)u+=k==="."?i:d[k]}else u=f.replace(".",i);else u="";const p=t[e];let a=p;return typeof p=="function"&&(a=p(s)),t._hideCountIf2&&s===2&&(c=""),t._numberFirst?a+c+u:u+c+a},Zn=(s,e)=>{const{units:t}=e;if(t.length===0)return[];const{unitMeasures:r}=e,c=e.largest??Number.POSITIVE_INFINITY,o={};let i,d,u,h=s;for(d=0;d<t.length;d++){i=t[d];const p=r[i];u=d===t.length-1?h/p:Math.floor(h/p),o[i]=u,h-=u*p}if(e.round){let p=c;for(d=0;d<t.length;d++)if(i=t[d],u=o[i],u!==0&&(p--,p===0)){for(let a=d+1;a<t.length;a++){const k=t[a],S=o[k];o[i]=(o[i]??0)+S*r[k]/r[i],o[k]=0}break}for(d=t.length-1;d>=0;d--){if(i=t[d],u=o[i],u===0)continue;const a=Math.round(u);if(o[i]=a,d===0)break;const k=t[d-1],S=r[k],B=Math.floor(a*r[i]/S);if(B)o[k]=(o[k]??0)+B,o[i]=0;else break}}const f=[];for(d=0;d<t.length&&f.length<c;d++){if(i=t[d],u=o[i],u&&!e.round&&f.length===c-1){let p,a=0;for(p=d+1,t.length;p<t.length;p++){const k=t[p];a+=o[k]*(e.unitMeasures[k]/e.unitMeasures[i])}u+=a,e.maxDecimalPoints!==void 0&&(u=As(u,e.maxDecimalPoints))}u&&f.push({unitCount:u,unitName:i})}return f},ei=(s,e,t)=>{const{language:r,units:c}=e;if(s.length===0){const p=c.at(-1);return os({unitCount:0,unitName:p},r,e)}const{conjunction:o,serialComma:i}=e;let d=", ";e.delimiter!==void 0?d=e.delimiter:r.delimiter!==void 0&&(d=r.delimiter);let u="";e.timeAdverb&&t!==0&&(u=r.future??"",t<0&&(u=r.past??""));const h=s.map(p=>os(p,r,e));let f;return!o||s.length===1?f=h.join(d):s.length===2?f=h.join(o):f=h.slice(0,-1).join(d)+(i?",":"")+o+(h.at(-1)??""),u&&(f=u.replace("%s",f)),f},ti=(s,e)=>{if(Number.isNaN(s))throw new TypeError("Expected a valid number");if(typeof s!="number")throw new TypeError("Expected a number for milliseconds input");const t={conjunction:"",language:Jn,round:!1,serialComma:!0,spacer:" ",timeAdverb:!1,unitMeasures:{d:864e5,h:36e5,m:6e4,mo:2629746e3,ms:1,s:1e3,w:6048e5,y:31556952e3},units:["w","d","h","m","s"],...e};Qn(t.language);const r=Math.abs(s),c=Zn(r,t);return ei(c,t,s)},Te="@voidzero-dev/vite-task-client",bt="@visulima/task-runner-client",nt=`npm:${bt}@^1`,Ls=ce(".vis",".vite-client-override-declined"),it="pnpm-workspace.yaml",si=["dependencies","devDependencies","optionalDependencies","peerDependencies"],Ds=s=>{try{return JSON.parse(We(s,"utf8"))}catch{return}},ri=s=>{const e=ce(s,it);if(De(e))try{return Is(We(e,"utf8")).toJS()?.overrides}catch{return}},ni=s=>s==="pnpm"||s==="aube"?"pnpm.overrides":s==="yarn"?"resolutions":"overrides",ii=s=>{const e=ce(s,it);try{const t=Is(We(e,"utf8"));return t.setIn(["overrides",Te],nt),xt(e,t.toString()),!0}catch{return!1}},cs=s=>s!==void 0&&si.some(e=>s[e]?.[Te]!==void 0),oi=(s,e)=>s!==void 0&&(s.pnpm?.overrides?.[Te]!==void 0||s.overrides?.[Te]!==void 0||s.resolutions?.[Te]!==void 0)||e?.[Te]!==void 0,ci=(s,e=[])=>{const t=Ds(ce(s,"package.json")),r=De(ce(s,"node_modules","@voidzero-dev","vite-task-client"));return{alreadyOverridden:oi(t,ri(s)),declined:De(ce(s,Ls)),manager:Nr(s)?.manager,present:cs(t)||r||e.some(c=>cs(c))}},ai=s=>{try{const e=ce(s,Ls);Wr(Ts(e),{recursive:!0}),xt(e,`Declined adding the ${Te} → ${bt} override.
2
2
  Delete this file to be asked again.
3
3
  `)}catch{}},li=(s,e="npm")=>{const t=`${e} install`;if((e==="pnpm"||e==="aube")&&De(ce(s,it))&&ii(s))return{file:it,installCommand:t};const r=ce(s,"package.json"),c=Ds(r);if(!c)return;const o=ni(e);o==="pnpm.overrides"?(c.pnpm??={},c.pnpm.overrides??={},c.pnpm.overrides[Te]=nt):(c[o]??={},c[o][Te]=nt);try{xt(r,`${JSON.stringify(c,void 0,4)}
4
- `)}catch{return}return{file:"package.json",installCommand:t}},di=async(s,e)=>{const t=ci(s,e.projectManifests);if(!t.present||t.alreadyOverridden||t.declined)return!1;const r=Vr({input:process.stdin,output:process.stdout});try{e.logger.info(`Detected ${Te}. Its cache hints no-op under @visulima/task-runner unless aliased to ${bt} (a drop-in replacement).`);const c=await new Promise(i=>{r.question("Add the override now? [y/N] ",i)});if(!/^y(?:es)?$/i.test(c.trim()))return ai(s),e.logger.info("Skipped. Delete .vis/.vite-client-override-declined to be asked again."),!1;const o=li(s,t.manager);return o===void 0?(e.logger.warn("Could not write the override automatically — add it manually (see @visulima/task-runner-client README)."),!1):(e.logger.info(`Added "${Te}": "${nt}" to ${o.file}. Run \`${o.installCommand}\` to apply it.`),!0)}finally{r.close()}},ui=({interactive:s,taskPty:e,workspacePty:t})=>e===!0?!0:e===!1?!1:s&&t!==!1,fi=s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),hi=(s,e,t)=>{const r=new Set,c=[];if(s===void 0||s.trim()==="")return{skipTaskIds:r,unmatchedPatterns:c};const o=[...t],i=new Set(o),d=new Map;for(const u of o){const h=u.lastIndexOf(":");if(h===-1)continue;const f=u.slice(h+1),p=d.get(f);p===void 0?d.set(f,[u]):p.push(u)}for(const u of fi(s)){if(u.startsWith("~:"))throw new Error(`--skip-cache does not support the closest-project selector "~:" (received "${u}"). Use \`pkg:target\`, \`:target\`, or \`#tag:target\`.`);if(i.has(u)){r.add(u);continue}const h=gn(u);if(!h){c.push(u);continue}let f=!1;switch(h.kind){case"all":{const p=d.get(h.target)??[];for(const a of p)r.add(a),f=!0;break}case"project":{const p=h.projects?.[0];if(p!==void 0){const a=`${p}:${h.target}`;i.has(a)&&(r.add(a),f=!0)}break}case"tag":{const{tag:p}=h;if(p!==void 0){const a=d.get(h.target)??[];for(const k of a){const S=k.slice(0,k.lastIndexOf(":"));e.projects[S]?.tags?.includes(p)===!0&&(r.add(k),f=!0)}}break}}f||c.push(u)}return{skipTaskIds:r,unmatchedPatterns:c}},pi=/\$(?:\{([A-Z_]\w*)(:-[^}]*)?\}|([A-Z_]\w*))/gi,mi=new Set(["0","!","#","$","*","-","?","@","_"]),gi=s=>{const e=new Map;for(const t of s.matchAll(pi)){const r=t[1],c=t[3],o=t[2],i=r??c;if(i===void 0||mi.has(i))continue;const d=o!==void 0,u=e.get(i);u===void 0?e.set(i,d):u&&!d&&e.set(i,!1)}return[...e.entries()].map(([t,r])=>({hasDefault:r,name:t}))},wi=s=>{const{command:e,processEnv:t,taskEnv:r,taskId:c}=s,o=gi(e);if(o.length===0)return;const i=[];for(const{hasDefault:d,name:u}of o){if(d)continue;const h=r[u],f=t[u];h===void 0&&f===void 0&&i.push(u)}if(i.length!==0)return{missing:i.toSorted(),taskId:c}},vi=s=>{const e=s.missing.map(t=>`$${t}`).join(", ");return`Strict env: ${s.taskId} references unset variable${s.missing.length===1?"":"s"} ${e}. Set ${s.missing.length===1?"it":"them"} in the task env, an envFile, or the parent shell — or opt out with options.strictEnv: false.`},yi=64*1024,as=256,xi=new RegExp("[\x1B›]\\[[0-?]*[ -/]*[@-~]","g"),pt=s=>s.replaceAll(xi,"").replaceAll("\r","");class ls{#e=[];#r=new Set;#s=new Map;#n=new Map;constructor(e=[]){for(const t of e)this.#n.set(t,{id:t,status:"pending",tailLines:[]});this.#e=[...e],this.#i()}getSnapshot=()=>this.#s;subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});getIds(){return this.#e}getState(e){return this.#n.get(e)}getDockState(){let e=!1,t=!1;for(const r of this.#n.values())r.status==="crashed"||r.status==="failed"?e=!0:(r.status==="pending"||r.status==="starting")&&(t=!0);return e?"crash":t?"boot":"ready"}registerService(e){this.#n.has(e)||(this.#n.set(e,{id:e,status:"pending",tailLines:[]}),this.#e=[...this.#e,e],this.#o())}markStarting(e){this.#t(e,t=>({...t,errorMessage:void 0,startedAt:t.startedAt??Date.now(),status:"starting"}))}markStarted(e,t){this.#t(e,r=>({...r,startedAt:r.startedAt??Date.now(),status:r.status==="ready"?"ready":"starting"}))}markReady(e,t){this.#t(e,r=>({...r,errorMessage:void 0,port:t.port,readyAt:Date.now(),status:"ready"}))}markFailed(e,t,r){const c=r?.message;this.#t(e,o=>({...o,errorMessage:pt(c??t),status:"failed"}))}markCrashed(e,t){const r=t.slice(-as).map(c=>pt(c));this.#t(e,c=>({...c,errorMessage:r.length>0?r[r.length-1]:"process exited",status:"crashed",tailLines:r}))}appendLog(e,t){const r=t.split(`
4
+ `)}catch{return}return{file:"package.json",installCommand:t}},di=async(s,e)=>{const t=ci(s,e.projectManifests);if(!t.present||t.alreadyOverridden||t.declined)return!1;const r=zr({input:process.stdin,output:process.stdout});try{e.logger.info(`Detected ${Te}. Its cache hints no-op under @visulima/task-runner unless aliased to ${bt} (a drop-in replacement).`);const c=await new Promise(i=>{r.question("Add the override now? [y/N] ",i)});if(!/^y(?:es)?$/i.test(c.trim()))return ai(s),e.logger.info("Skipped. Delete .vis/.vite-client-override-declined to be asked again."),!1;const o=li(s,t.manager);return o===void 0?(e.logger.warn("Could not write the override automatically — add it manually (see @visulima/task-runner-client README)."),!1):(e.logger.info(`Added "${Te}": "${nt}" to ${o.file}. Run \`${o.installCommand}\` to apply it.`),!0)}finally{r.close()}},ui=({interactive:s,taskPty:e,workspacePty:t})=>e===!0?!0:e===!1?!1:s&&t!==!1,fi=s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),hi=(s,e,t)=>{const r=new Set,c=[];if(s===void 0||s.trim()==="")return{skipTaskIds:r,unmatchedPatterns:c};const o=[...t],i=new Set(o),d=new Map;for(const u of o){const h=u.lastIndexOf(":");if(h===-1)continue;const f=u.slice(h+1),p=d.get(f);p===void 0?d.set(f,[u]):p.push(u)}for(const u of fi(s)){if(u.startsWith("~:"))throw new Error(`--skip-cache does not support the closest-project selector "~:" (received "${u}"). Use \`pkg:target\`, \`:target\`, or \`#tag:target\`.`);if(i.has(u)){r.add(u);continue}const h=gn(u);if(!h){c.push(u);continue}let f=!1;switch(h.kind){case"all":{const p=d.get(h.target)??[];for(const a of p)r.add(a),f=!0;break}case"project":{const p=h.projects?.[0];if(p!==void 0){const a=`${p}:${h.target}`;i.has(a)&&(r.add(a),f=!0)}break}case"tag":{const{tag:p}=h;if(p!==void 0){const a=d.get(h.target)??[];for(const k of a){const S=k.slice(0,k.lastIndexOf(":"));e.projects[S]?.tags?.includes(p)===!0&&(r.add(k),f=!0)}}break}}f||c.push(u)}return{skipTaskIds:r,unmatchedPatterns:c}},pi=/\$(?:\{([A-Z_]\w*)(:-[^}]*)?\}|([A-Z_]\w*))/gi,mi=new Set(["0","!","#","$","*","-","?","@","_"]),gi=s=>{const e=new Map;for(const t of s.matchAll(pi)){const r=t[1],c=t[3],o=t[2],i=r??c;if(i===void 0||mi.has(i))continue;const d=o!==void 0,u=e.get(i);u===void 0?e.set(i,d):u&&!d&&e.set(i,!1)}return[...e.entries()].map(([t,r])=>({hasDefault:r,name:t}))},wi=s=>{const{command:e,processEnv:t,taskEnv:r,taskId:c}=s,o=gi(e);if(o.length===0)return;const i=[];for(const{hasDefault:d,name:u}of o){if(d)continue;const h=r[u],f=t[u];h===void 0&&f===void 0&&i.push(u)}if(i.length!==0)return{missing:i.toSorted(),taskId:c}},vi=s=>{const e=s.missing.map(t=>`$${t}`).join(", ");return`Strict env: ${s.taskId} references unset variable${s.missing.length===1?"":"s"} ${e}. Set ${s.missing.length===1?"it":"them"} in the task env, an envFile, or the parent shell — or opt out with options.strictEnv: false.`},yi=64*1024,as=256,xi=new RegExp("[\x1B›]\\[[0-?]*[ -/]*[@-~]","g"),pt=s=>s.replaceAll(xi,"").replaceAll("\r","");class ls{#e=[];#r=new Set;#s=new Map;#n=new Map;constructor(e=[]){for(const t of e)this.#n.set(t,{id:t,status:"pending",tailLines:[]});this.#e=[...e],this.#i()}getSnapshot=()=>this.#s;subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});getIds(){return this.#e}getState(e){return this.#n.get(e)}getDockState(){let e=!1,t=!1;for(const r of this.#n.values())r.status==="crashed"||r.status==="failed"?e=!0:(r.status==="pending"||r.status==="starting")&&(t=!0);return e?"crash":t?"boot":"ready"}registerService(e){this.#n.has(e)||(this.#n.set(e,{id:e,status:"pending",tailLines:[]}),this.#e=[...this.#e,e],this.#o())}markStarting(e){this.#t(e,t=>({...t,errorMessage:void 0,startedAt:t.startedAt??Date.now(),status:"starting"}))}markStarted(e,t){this.#t(e,r=>({...r,startedAt:r.startedAt??Date.now(),status:r.status==="ready"?"ready":"starting"}))}markReady(e,t){this.#t(e,r=>({...r,errorMessage:void 0,port:t.port,readyAt:Date.now(),status:"ready"}))}markFailed(e,t,r){const c=r?.message;this.#t(e,o=>({...o,errorMessage:pt(c??t),status:"failed"}))}markCrashed(e,t){const r=t.slice(-as).map(c=>pt(c));this.#t(e,c=>({...c,errorMessage:r.length>0?r[r.length-1]:"process exited",status:"crashed",tailLines:r}))}appendLog(e,t){const r=t.split(`
5
5
  `).map(c=>pt(c)).filter(c=>c.length>0);r.length!==0&&this.#t(e,c=>{const o=[...c.tailLines,...r];for(;o.length>as;)o.shift();let i=0;for(let d=o.length-1;d>=0;d--)if(i+=o[d].length+1,i>yi){o.splice(0,d+1);break}return{...c,lastLine:r[r.length-1],tailLines:o}})}abortBoot(e){let t=!1;const r=new Map(this.#n);for(const[c,o]of r)(o.status==="pending"||o.status==="starting")&&(r.set(c,{...o,errorMessage:e,status:"failed"}),t=!0);t&&(this.#n=r,this.#i(),this.#o())}#t(e,t){const r=this.#n.get(e);r&&(this.#n.set(e,t(r)),this.#i(),this.#o())}#i(){this.#s=new Map(this.#n)}#o(){for(const e of this.#r)try{e()}catch{}}}const ji=(s,e)=>{if(s===e)return!0;if(!s||!e||s.length!==e.length)return!1;for(const[t,r]of s.entries())if(!Object.is(r,e[t]))return!1;return!0},ds=({children:s,deps:e,onRender:t,style:r,width:c})=>{const o=z.useRef(null),i=z.useRef(!1),d=z.useRef(e),u=z.useRef(s),h=z.useRef(t);h.current=t;let f=!1;e!==void 0?ji(d.current,e)||(f=!0,d.current=e):s!==u.current&&(f=!0,u.current=s),f&&(i.current=!1,o.current&&(o.current.cachedRender=void 0)),z.useLayoutEffect(()=>{const a=o.current;a&&(a.internal_onRendered=()=>{i.current=!0,h.current?.(a)})}),z.useEffect(()=>()=>{const a=o.current;a&&(a.cachedRender=void 0,a.internal_onRendered=void 0)},[]);const p=z.useMemo(()=>({...r,width:c}),[r,c]);return n.jsx("ink-static-render",{ref:o,style:p,children:i.current?null:s()})},ki=s=>Array.isArray(s)?`[${s.join(",")}]`:typeof s=="object"&&s!==null?JSON.stringify(s):String(s),bi=(s,e,t)=>e==="_"?`${s}${Array.isArray(t)?t.join(" "):String(t)}`:`${s}--${e}=${ki(t)}`,St=(s,e,t)=>{const r=new Set(new Set(t.map(a=>a.target.target))),c=new Set(new Set(t.map(a=>a.target.project))),o=e.filter(a=>r.has(a)),i=s.filter(a=>c.has(a)),d=t.length-i.length*o.length,u=o.length===1?"target":"targets",h=o.join(", "),f=i.length===1?`project ${i[0]}`:`${i.length} projects`;let p=`${u} ${h} for ${f}`;return d>0&&(p+=` and ${d} ${d===1?"task":"tasks"} ${d===1?"it depends":"they depend"} on`),p},Si={error:"red",info:"white",success:"green"},wt=({children:s,title:e,variant:t})=>{const r=Si[t];return n.jsxs(g,{flexDirection:"column",children:[n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,inverse:!0,children:" VIS "}),n.jsx(l,{bold:!0,color:r,children:"•"}),n.jsx(l,{children:e})]}),s]})},Bs=({cached:s,failed:e,failedIds:t,projectNames:r,retriedIds:c,skippedIds:o,succeeded:i,targets:d,tasks:u,took:h})=>{const f=St(r,d,u),p=c??[];if(e===0&&(!o||o.length===0)){const a=s>0?` (${s} read from cache)`:"";return n.jsx(ds,{children:()=>n.jsx(wt,{title:`Successfully ran ${f}`,variant:"success",children:n.jsxs(g,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[n.jsxs(l,{children:[n.jsx(l,{color:"green",children:Cs})," ",i+s," tasks completed",a?n.jsx(l,{dimColor:!0,children:a}):null,n.jsx(l,{dimColor:!0,children:` · Took ${h}`})]}),p.length>0&&n.jsxs(g,{flexDirection:"column",marginTop:1,children:[n.jsxs(l,{children:[n.jsx(l,{color:"yellow",children:"↻"})," ",n.jsx(l,{color:"yellow",children:String(p.length)})," task",p.length===1?"":"s"," succeeded after retry:"]}),p.map(k=>n.jsxs(l,{children:[" ",n.jsx(l,{color:"yellow",children:"↻"})," ",k]},k))]})]})})})}return n.jsx(ds,{children:()=>n.jsx(wt,{title:`Ran ${f}`,variant:"error",children:n.jsxs(g,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[o&&o.length>0&&n.jsxs(g,{flexDirection:"column",children:[n.jsxs(l,{dimColor:!0,children:[o.length," ","task",o.length===1?"":"s"," ","skipped (dependency failed or --bail)"]}),o.map(a=>n.jsxs(l,{dimColor:!0,children:[" - ",a]},a)),n.jsx(l,{})]}),e>0&&n.jsxs(g,{flexDirection:"column",children:[n.jsxs(l,{children:[n.jsx(l,{color:"red",children:String(e)})," ","task",e===1?"":"s"," ","failed:"]}),t.map(a=>n.jsxs(l,{children:[" ",n.jsx(l,{color:"red",children:Es})," ",a]},a)),n.jsx(l,{})]}),p.length>0&&n.jsxs(g,{flexDirection:"column",children:[n.jsxs(l,{children:[n.jsx(l,{color:"yellow",children:String(p.length)})," ","task",p.length===1?"":"s"," ","finished after retry:"]}),p.map(a=>n.jsxs(l,{children:[" ",n.jsx(l,{color:"yellow",children:"↻"})," ",a]},a)),n.jsx(l,{})]}),n.jsx(l,{dimColor:!0,children:` Took ${h}`})]})})})};class ot{#e;#r=new Set;#s=new Map;constructor(e,t){this.#e={autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,filterActive:!1,filterText:"",focusedPanel:"tasks",interactiveMode:!1,outputs:new Map,pinnedTaskIds:[null,null],rerunRequested:!1,retriedIds:[],retryTaskId:null,rows:e.map(r=>({persistent:!!r.overrides.visOptions?.persistent,status:"pending",taskId:r.id})),running:0,selectedIndex:0,startTime:Date.now(),statusFilter:"all",succeeded:0,totalTasks:t??e.length,viewMode:"list"}}getSnapshot=()=>this.#e;subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});startTasks(e){const t=[...this.#e.rows];for(const r of e){const c=t.findIndex(o=>o.taskId===r.id);c!==-1&&(t[c]={...t[c],elapsed:0,status:"running"},this.#s.set(r.id,process.hrtime()))}this.#t({...this.#e,rows:t,running:this.#e.running+e.length})}endTasks(e){const t=[...this.#e.rows];let{cached:r,completed:c,failed:o,succeeded:i}=this.#e;const d=new Map(this.#e.outputs),u=[...this.#e.retriedIds];for(const p of e){const a=t.findIndex(k=>k.taskId===p.task.id);switch(a!==-1&&(t[a]={...t[a],duration:p.startTime&&p.endTime?p.endTime-p.startTime:void 0,retryAttempts:p.retryAttempts,status:p.status}),p.retryAttempts&&p.retryAttempts>0&&u.push(p.task.id),c++,p.status){case"failure":{o++;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{r++;break}case"success":{i++;break}}p.terminalOutput&&!d.has(p.task.id)&&d.set(p.task.id,p.terminalOutput),this.#s.delete(p.task.id)}let{selectedIndex:h}=this.#e;if(o>this.#e.failed){const p=t.findIndex(a=>a.status==="failure");p!==-1&&(h=p)}const f=Math.max(0,this.#e.running-e.length);this.#t({...this.#e,cached:r,completed:c,failed:o,outputs:d,retriedIds:u,rows:t,running:f,selectedIndex:h,succeeded:i})}static#n=256*1024;addOutput(e,t){if(!t.trim())return;let r=(this.#e.outputs.get(e)??"")+t;r.length>ot.#n&&(r=r.slice(-ot.#n)),this.#e.outputs.set(e,r),this.#t({...this.#e})}setOutput(e,t){this.#e.outputs.set(e,t),this.#t({...this.#e})}markDone(){this.#t({...this.#e,done:!0,endTime:Date.now()})}unmarkDone(){this.#t({...this.#e,autoExitCountdown:null,done:!1,endTime:null})}tick(){if(this.#s.size===0)return;let e=!1;const t=[...this.#e.rows];for(let r=0;r<t.length;r++){const c=t[r];if(c.status==="running"){const o=this.#s.get(c.taskId);if(o){const i=process.hrtime(o),d=i[0]*1e3+i[1]/1e6;t[r]={...c,elapsed:d},e=!0}}}e&&this.#t({...this.#e,rows:t})}setSelectedIndex(e){e!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:e})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:e})}setFilter(e){this.#t({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#t({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:0})}pinTask(e,t){const r=[...this.#e.pinnedTaskIds];r[e]=t,this.#t({...this.#e,pinnedTaskIds:r})}clearPins(){this.#t({...this.#e,pinnedTaskIds:[null,null]})}requestRetry(e){const t=[...this.#e.rows],r=t.findIndex(d=>d.taskId===e);let{completed:c,failed:o,succeeded:i}=this.#e;if(r!==-1){const d=t[r].status;d==="failure"?(o=Math.max(0,o-1),c=Math.max(0,c-1)):d==="success"&&(i=Math.max(0,i-1),c=Math.max(0,c-1)),t[r]={...t[r],elapsed:0,retryAttempts:void 0,status:"running"},this.#s.set(e,process.hrtime())}this.#t({...this.#e,completed:c,done:!1,endTime:null,failed:o,interactiveMode:!1,retriedIds:this.#e.retriedIds.filter(d=>d!==e),retryTaskId:e,rows:t,succeeded:i})}acknowledgeRetry(){const e=this.#e.retryTaskId;return e&&this.#t({...this.#e,retryTaskId:null}),e}setInteractiveMode(e){e!==this.#e.interactiveMode&&this.#t({...this.#e,interactiveMode:e})}setViewMode(e){e!==this.#e.viewMode&&this.#t({...this.#e,viewMode:e})}setStatusFilter(e){this.#t({...this.#e,selectedIndex:0,statusFilter:e})}requestRerun(){this.#s.clear(),this.#t({...this.#e,autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,interactiveMode:!1,outputs:new Map,rerunRequested:!0,retriedIds:[],rows:this.#e.rows.map(e=>({persistent:e.persistent,status:"pending",taskId:e.taskId})),running:0,startTime:Date.now(),succeeded:0,viewMode:"list"})}acknowledgeRerun(){this.#e.rerunRequested&&this.#t({...this.#e,rerunRequested:!1})}#t(e){this.#e=e;for(const t of this.#r)try{t()}catch{}}}const Ti=s=>Yn(s),$i=/^(?<name>(?:[A-Z][\w$]*)?(?:Error|Exception))(?::[ \t](?<message>.*))?$/,Ii=/^\s*at\s+/,Ci=s=>{const e=s.split(`
6
6
  `);let t;for(let r=0;r<e.length;r++){const c=$i.exec(e[r].trim());if(!c)continue;const o=[];for(let i=r+1;i<e.length&&i<=r+200;i++){const d=e[i];if(Ii.test(d))o.push(d.trim());else{if(o.length>0)break;if(d.trim()!=="")break}}if(o.length>0){const i=c.groups?.name??"Error",d=c.groups?.message??"";t={message:d,name:i,stack:`${i}: ${d}
7
7
  ${o.map(u=>` ${u}`).join(`
@@ -10,9 +10,9 @@ ${o.map(u=>` ${u}`).join(`
10
10
  ${p}
11
11
  ${s}`}catch{return s}},Mi={delimiter:" ",language:{d:()=>" d",future:"in %s",h:()=>" h",m:()=>" m",mo:()=>" mo",ms:()=>" ms",past:"%s ago",s:()=>" s",w:()=>" w",y:()=>" y"},largest:2,round:!0,spacer:"",units:["h","m","s","ms"]},Be=s=>ti(s,Mi),Ge=s=>s==="local-cache"||s==="local-cache-kept-existing"||s==="remote-cache",He=s=>{switch(s){case"failure":return{color:"red",icon:Es};case"local-cache":case"local-cache-kept-existing":case"remote-cache":case"success":return{color:"green",icon:Cs};case"skipped":return{color:"gray",icon:lt};default:return{color:"gray",icon:"?"}}},Xe=s=>{const{color:e,icon:t}=He(s);return pe(J.createElement(l,{color:e},t),{columns:10}).trim()},Fi=s=>{const{color:e,icon:t}=He(s);switch(s){case"local-cache":case"local-cache-kept-existing":case"remote-cache":return pe(J.createElement(l,null,J.createElement(l,{color:e},t)," ",J.createElement(l,{color:"cyan"},"[cache]")),{columns:30}).trim();case"skipped":return pe(J.createElement(l,null,J.createElement(l,{dimColor:!0},t)," ",J.createElement(l,{dimColor:!0},"[skipped]")),{columns:30}).trim();default:return pe(J.createElement(l,{color:e},t),{columns:10}).trim()}},Oi=s=>s==="azure"||s==="buildkite"||s==="github"||s==="gitlab"||s==="off"?s:process.env.GITHUB_ACTIONS==="true"?"github":process.env.GITLAB_CI==="true"?"gitlab":process.env.BUILDKITE==="true"?"buildkite":process.env.TF_BUILD?.toLowerCase()==="true"?"azure":"off",Ai=s=>{const e=s.replaceAll(/\W+/g,"_"),t=An("sha256").update(s).digest("hex").slice(0,6);return`${e}_${t}`},Li=(s,e,t,r="auto")=>{const c=t.trim();if(!c)return;const o=`
12
12
  `,i=Oi(r);if(i==="github"){process.stdout.write(`::group::${Xe(e)} ${s}${o}`),process.stdout.write(c+o),process.stdout.write(`::endgroup::${o}`);return}if(i==="gitlab"){const p=Math.floor(Date.now()/1e3),a=Ai(s),k=e==="failure"?"":"[collapsed=true]",S="\x1B[0K";process.stdout.write(`${S}section_start:${String(p)}:${a}${k}\r${S}${Xe(e)} ${s}${o}`),process.stdout.write(c+o);const B=Math.floor(Date.now()/1e3);process.stdout.write(`${S}section_end:${String(B)}:${a}\r${S}${o}`);return}if(i==="buildkite"){const p=e==="failure"?"+++":"---";process.stdout.write(`${p} ${Xe(e)} ${s}${o}`),process.stdout.write(c+o);return}if(i==="azure"){process.stdout.write(`##[group]${Xe(e)} ${s}${o}`),process.stdout.write(c+o),process.stdout.write(`##[endgroup]${o}`);return}const d=process.stdout.columns||80,u=pe(J.createElement(l,{dimColor:!0},lt.repeat(d)),{columns:d}).trim(),h=Fi(e),f=pe(J.createElement(l,{bold:!0},s),{columns:d}).trim();process.stdout.write(`${u}${o}`),process.stdout.write(`${h} ${f}${o}`),process.stdout.write(c+o),process.stdout.write(`${u}${o}`)},Di=s=>s==="running"?{color:"white",icon:"•"}:s==="pending"?{color:"gray",icon:"·"}:He(s),Bi=({autoScroll:s,focused:e,interactiveMode:t,showFullscreenHint:r,statusValue:c,supportsInteractive:o,taskId:i})=>{if(!i)return;if(t)return"Esc cancel | Enter send";const d=s?"":" PAUSED (f resume)",u=o?" i INPUT":"";return e&&c==="running"&&r?`⏎ FULLSCREEN${u} f FOLLOW${d}`:e&&c==="running"?`f FOLLOW${u}${d}`:e&&r?`<enter> full screen${d}`:e?d||void 0:"<tab> or <enter> to focus"},fs=({autoScroll:s=!0,duration:e,focused:t,interactiveMode:r,output:c,scrollRef:o,showFullscreenHint:i,status:d,supportsInteractive:u=!0,taskId:h})=>{const f=d??"pending",{icon:p}=Di(f),a=t?"bold":"single",k=f==="failure"?"red":f==="success"||Ge(f)?t?"green":"gray":f==="running"?t?"white":"cyan":t?"white":"gray",S=h?`${p} ${h}`:void 0,B=e===void 0?void 0:Be(e),q=Bi({autoScroll:s,focused:t,interactiveMode:r??!1,showFullscreenHint:i??!1,statusValue:f,supportsInteractive:u,taskId:h});if(!h)return n.jsxs(g,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",paddingX:2,paddingY:1,children:[n.jsx(l,{dimColor:!0,children:"Select a task to view output"}),n.jsx(l,{dimColor:!0,children:"Press Enter or 1/2 to pin"})]});const b=[];if(c)for(const T of c.split(`
13
- `))b.push(T.endsWith("\r")?T.slice(0,-1):T);return!c&&(f==="running"||f==="pending")?n.jsx(g,{borderBottomTitle:q,borderColor:k,borderStyle:a,borderTopRightTitle:B,borderTopTitle:S,flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:n.jsx(g,{alignItems:"center",flexGrow:1,justifyContent:"center",children:n.jsx(l,{dimColor:!0,children:"Waiting for task output…"})})}):n.jsxs(g,{borderBottomTitle:q,borderColor:r?"yellow":k,borderStyle:a,borderTopRightTitle:B,borderTopTitle:S,flexDirection:"column",flexGrow:1,children:[n.jsx(g,{flexGrow:1,flexShrink:1,paddingY:1,children:n.jsx(Ts,{flexGrow:1,followOutput:s,paddingX:2,ref:o,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:n.jsx(l,{children:b.join(`
14
- `)})})}),r&&n.jsx(g,{flexShrink:0,justifyContent:"center",paddingX:1,children:n.jsx(l,{bold:!0,color:"yellow",children:"INTERACTIVE | keystrokes forwarded to task | Esc to exit"})})]})},_i={crashed:"✖",failed:"✖",pending:"·",ready:"●",starting:"•"},Gs=s=>s==="ready"?"green":s==="crashed"||s==="failed"?"red":s==="starting"?"cyan":"gray",Ni=({status:s})=>s==="starting"?n.jsx(l,{color:"cyan",children:n.jsx(Ps,{type:"dots"})}):n.jsx(l,{bold:!0,color:Gs(s),children:_i[s]}),Gi=({active:s,focused:e,state:t})=>{const r=e&&s,c=r?">":" ",o=t.status==="ready"?t.port?`running, port ${String(t.port)}`:"running":t.status==="failed"||t.status==="crashed"?t.errorMessage??"exited":t.lastLine??"booting…";return n.jsxs(g,{flexDirection:"row",flexShrink:0,overflow:"hidden",children:[n.jsx(l,{children:c}),n.jsx(l,{children:" "}),n.jsx(g,{flexShrink:0,width:3,children:n.jsx(Ni,{status:t.status})}),n.jsx(g,{flexGrow:0,flexShrink:0,width:28,children:n.jsx(l,{bold:r,inverse:r,children:t.id})}),n.jsx(g,{flexGrow:1,flexShrink:1,overflow:"hidden",children:n.jsxs(l,{color:Gs(t.status),dimColor:t.status!=="crashed"&&t.status!=="failed",wrap:"truncate-end",children:[" ",o]})})]})},Wi=({states:s})=>{const e=[];for(const r of s)r.status==="ready"&&e.push(r.id);const t=e.join(", ");return n.jsxs(g,{paddingX:1,children:[n.jsxs(l,{bold:!0,color:"green",children:["● ","Services"]}),n.jsxs(l,{children:[" ",String(e.length)," / ",String(s.length)," running"]}),t.length>0&&n.jsxs(l,{dimColor:!0,children:[" ",t]}),n.jsx(l,{dimColor:!0,children:" [Tab ↓]"})]})},Hi=({states:s})=>{const e=s.find(t=>t.status==="crashed"||t.status==="failed");return e?n.jsxs(g,{flexDirection:"column",paddingX:1,children:[n.jsxs(l,{bold:!0,color:"red",children:["✖ ","Service crashed:"," ",e.id]}),e.tailLines.slice(-3).map((t,r)=>n.jsxs(l,{color:"red",dimColor:!0,children:[" ",t]},`crash-${String(r)}`))]}):n.jsx(n.Fragment,{})},qi=({activeIndex:s,focused:e,store:t})=>{const r=z.useSyncExternalStore(t.subscribe,t.getSnapshot),c=t.getIds();if(c.length===0)return n.jsx(n.Fragment,{});const o=c.map(f=>r.get(f)).filter(f=>f!==void 0),i=t.getDockState(),d=i==="crash"?"red":i==="ready"?"gray":e?"white":"cyan",u=i==="crash"?"Services (crashed)":i==="ready"?"Services":"Services (starting)",h=e?i==="crash"?"↑↓ select Enter logs R retry Esc back":"↑↓ select Enter logs Esc back":"Tab to focus services";return i==="ready"&&!e?n.jsx(g,{borderColor:d,borderStyle:"single",flexDirection:"row",flexShrink:0,children:n.jsx(Wi,{states:o})}):n.jsxs(g,{borderBottomTitle:h,borderColor:d,borderStyle:e?"bold":"single",borderTopTitle:u,flexDirection:"column",flexGrow:2,flexShrink:0,minHeight:6,paddingX:1,children:[i==="crash"&&n.jsx(Hi,{states:o}),o.map((f,p)=>n.jsx(Gi,{active:p===s,focused:e,state:f},f.id))]})},Ws=6,Hs=8,qs=12,Vi=s=>s==="running"||s==="pending"?Rs:s==="local-cache"||s==="local-cache-kept-existing"?"Local":s==="remote-cache"?"Remote":lt,hs=(s,e)=>e[0]===s?"[1]":e[1]===s?"[2]":"",ps=({compact:s,focused:e,isSelected:t,pinLabel:r,row:c})=>{const{persistent:o,status:i,taskId:d}=c,u=e&&t,h=u?">":" ",f=i==="running"&&o===!0;let p;if(f)p=n.jsx(l,{bold:!0,color:"green",children:" ● "});else if(i==="running")p=n.jsxs(l,{bold:!0,color:"white",children:[" ",n.jsx(Ps,{type:"dots"})," "]});else if(i==="pending")p=n.jsx(l,{bold:!0,color:"gray",children:" · "});else{const{color:k,icon:S}=He(i);p=n.jsxs(l,{bold:!0,color:k,children:[" ",S," "]})}let a=Rs;return f?a="running":i!=="running"&&i!=="pending"?a=c.duration===void 0?lt:Be(c.duration):i==="running"&&c.elapsed!==void 0&&(a=Be(c.elapsed)),n.jsxs(g,{children:[n.jsx(l,{children:h}),n.jsx(g,{width:Ws,children:p}),n.jsxs(g,{flexGrow:1,children:[n.jsx(l,{bold:u,inverse:u,children:d}),r?n.jsx(l,{dimColor:!0,children:` ${r}`}):null]}),!s&&n.jsx(g,{justifyContent:"flex-end",width:Hs,children:n.jsx(l,{dimColor:!Ge(i),children:Vi(i)})}),!s&&n.jsx(g,{justifyContent:"flex-end",width:qs,children:n.jsx(l,{color:f?"green":void 0,dimColor:i==="pending"||f,children:a})})]})},ms=({compact:s,filterActive:e,filterText:t,focused:r,headerStatus:c,parallelSlots:o=3,pinnedTaskIds:i,rows:d,scrollRef:u,selectedIndex:h,title:f})=>{const p=c==="error"?"red":c==="success"?"green":r?"white":"gray",a=d[h]?.taskId,k=[];let S=0;for(const T of d)T.status==="running"?k.push(T):T.status==="pending"&&(S+=1);const B=Math.min(o,k.length+S),q=B>1,b=[];if(q)for(let T=0;T<B;T++){const I=k[T];I?b.push(n.jsx(ps,{compact:s,focused:r,isSelected:I.taskId===a,pinLabel:hs(I.taskId,i),row:I},`par-${I.taskId}`)):b.push(n.jsxs(g,{children:[n.jsx(l,{children:" "}),n.jsx(g,{width:Ws,children:n.jsx(l,{bold:!0,color:"gray",children:" · "})}),n.jsx(l,{dimColor:!0,children:"Waiting for task..."})]},`par-empty-${String(T)}`))}return n.jsxs(g,{borderColor:p,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[n.jsxs(g,{flexShrink:0,paddingX:1,children:[n.jsx(l,{bold:!0,inverse:!0,children:" VIS "}),n.jsx(l,{children:` ${f}`}),!s&&n.jsxs(g,{flexGrow:1,gap:0,justifyContent:"flex-end",children:[n.jsx(g,{justifyContent:"flex-end",width:Hs,children:n.jsx(l,{dimColor:!0,children:"Cache"})}),n.jsx(g,{justifyContent:"flex-end",width:qs,children:n.jsx(l,{dimColor:!0,children:"Duration"})})]})]}),n.jsx(Ts,{flexGrow:1,flexShrink:1,paddingX:1,paddingY:1,ref:u,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:d.map(T=>n.jsx(ps,{compact:s,focused:r,isSelected:T.taskId===a,pinLabel:hs(T.taskId,i),row:T},T.taskId))}),q&&n.jsx(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexDirection:"column",flexShrink:0,paddingX:1,paddingY:1,children:b}),e&&n.jsxs(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexShrink:0,paddingX:1,children:[n.jsx(l,{bold:!0,color:"white",children:"/ "}),n.jsx(l,{children:t}),n.jsx(l,{inverse:!0,children:" "})]})]})},gs=40,ws=10,vs=100,Ui=Object.freeze([]),zi=({autoExitSeconds:s,onRetryService:e,parallelSlots:t,projectNames:r,serviceDockStore:c,stdinRegistry:o,store:i,targets:d,tasks:u})=>{const{exit:h}=kr(),{columns:f,rows:p}=br(),a=z.useSyncExternalStore(i.subscribe,i.getSnapshot),k=z.useCallback(C=>c?c.subscribe(C):()=>{},[c]);z.useSyncExternalStore(k,()=>c?c.getDockState():"ready");const S=c?c.getIds():Ui,B=S.length>0,[q,b]=z.useState(0),[T,I]=z.useState(null),j=z.useSyncExternalStore(k,()=>T&&c?c.getState(T):void 0),[M,w]=z.useState(!1),F=z.useRef(null),_=z.useRef(null),$=z.useRef(null),[N,X]=z.useState(!1),[ae,Q]=z.useState(!0),K=z.useRef({list:0,splitList:0,splitOutput:0}),se=z.useCallback(()=>{a.viewMode==="list"?K.current.list=_.current?.getScrollOffset()??0:a.viewMode==="split"&&(K.current.splitList=_.current?.getScrollOffset()??0,K.current.splitOutput=$.current?.getScrollOffset()??0)},[a.viewMode]),le=z.useCallback(C=>{setTimeout(()=>{if(C==="list"){const x=K.current.list;_.current?.scrollTo(x)}else if(C==="split"){const x=K.current.splitList;x>0?_.current?.scrollTo(x):_.current?.scrollTo(Math.max(0,i.getSnapshot().selectedIndex-2)),$.current?.scrollTo(K.current.splitOutput)}},0)},[i]),de=z.useRef(!1);z.useEffect(()=>{a.done&&!de.current&&(de.current=!0,s>0&&a.failed===0&&X(!0)),!a.done&&de.current&&(de.current=!1,X(!1))},[a.done,a.failed,s]);const ie=z.useMemo(()=>{const C=S.length>0?new Set(S):null,x=a.filterText?a.filterText.toLowerCase():null,E=[];for(const re of a.rows)C?.has(re.taskId)||a.statusFilter==="failed"&&re.status!=="failure"||a.statusFilter==="running"&&re.status!=="running"&&re.status!=="pending"||a.statusFilter==="passed"&&re.status!=="success"&&!Ge(re.status)||x&&!re.taskId.toLowerCase().includes(x)||E.push(re);return E},[a.rows,a.filterText,a.statusFilter,S]),H=(ie[a.selectedIndex]??null)?.taskId??null,G=T?null:a.pinnedTaskIds[0]??H,Z=G?a.rows.find(C=>C.taskId===G):null,me=j??null,ke=T?(me?.tailLines??[]).join(`
15
- `):G?a.outputs.get(G)??"":"",P=z.useMemo(()=>Z?.status==="failure"&&ke?Ns(ke,{color:!process.env.NO_COLOR,cwd:process.cwd()}):ke,[Z?.status,ke]),ge=T??G,Ee=T?me?.status==="crashed"||me?.status==="failed"?"failure":"running":Z?.status,Fe=St(r,d,u),_e=a.done?`Completed ${Fe} (${Be((a.endTime??Date.now())-a.startTime)})`:`Running ${Fe}...`,Oe=a.done?a.failed>0?"error":"success":"running",te=z.useCallback(C=>{_.current?.scrollTo(Math.max(0,C-2))},[]);if(z.useEffect(()=>{a.interactiveMode&&Z?.status!=="running"&&i.setInteractiveMode(!1)},[a.interactiveMode,Z?.status,i]),z.useEffect(()=>{if(!G)return;let C=f;a.viewMode==="split"&&f>=vs?C=f-Math.floor(f*.4)-2:(a.viewMode==="split"||a.viewMode==="fullscreen")&&(C=f-2);const x=Math.max(1,p-4);o.get(G)?.resize?.(C,x)},[f,p,a.viewMode,G]),Qt((C,x)=>{if(x.escape){i.setInteractiveMode(!1);return}if(!G)return;const E=o.get(G);if(!E){i.setInteractiveMode(!1);return}if(x.return)E.write("\r");else if(x.upArrow)E.write("\x1B[A");else if(x.downArrow)E.write("\x1B[B");else if(x.rightArrow)E.write("\x1B[C");else if(x.leftArrow)E.write("\x1B[D");else if(x.backspace)E.write("");else if(x.delete)E.write("\x1B[3~");else if(x.tab)E.write(" ");else if(x.home)E.write("\x1B[H");else if(x.end)E.write("\x1B[F");else if(x.pageUp)E.write("\x1B[5~");else if(x.pageDown)E.write("\x1B[6~");else if(x.ctrl&&C){const re=C.toUpperCase().codePointAt(0);re!==void 0&&re>=65&&re<=90&&E.write(String.fromCodePoint(re-64))}else C&&E.write(C)},{isActive:a.interactiveMode}),Qt((C,x)=>{if(C==="c"&&x.ctrl){h();return}if(!N){if(M){x.escape||C==="?"?w(!1):C==="q"?(w(!1),X(!0)):x.downArrow||C==="j"?F.current?.scrollBy(1):x.upArrow||C==="k"?F.current?.scrollBy(-1):x.pageDown?F.current?.scrollBy(5):x.pageUp?F.current?.scrollBy(-5):x.home?F.current?.scrollToTop():x.end&&F.current?.scrollToBottom();return}if(C==="?"){w(!0);return}if(C==="q"){X(!0);return}if(C==="r"&&a.done){i.requestRerun();return}if(C==="R"&&a.done){const E=ie[a.selectedIndex];E?.status==="failure"&&i.requestRetry(E.taskId);return}if(C==="F"&&!a.filterActive){const E=["all","failed","running","passed"],re=E.indexOf(a.statusFilter);i.setStatusFilter(E[(re+1)%E.length]);return}if(a.filterActive){if(x.escape){i.setFilterActive(!1);return}if(x.return){i.setFilterActive(!1);return}if(x.backspace){i.setFilter(a.filterText.slice(0,-1));return}if(C&&!x.ctrl&&!x.meta){i.setFilter(a.filterText+C);return}return}if(C==="i"&&Z?.status==="running"&&(a.viewMode==="fullscreen"||a.viewMode==="split"&&a.focusedPanel==="output")){i.setInteractiveMode(!0);return}if(a.viewMode==="fullscreen"){if(x.escape){i.setViewMode("split"),le("split");return}if(C==="f"){const E=!ae;Q(E),E&&$.current?.scrollToBottom();return}if(x.downArrow||C==="j"){Q(!1),$.current?.scrollBy(1);return}if(x.upArrow||C==="k"){Q(!1),$.current?.scrollBy(-1);return}if(x.pageDown||x.ctrl&&C==="d"){Q(!1),$.current?.scrollBy(12);return}if(x.pageUp||x.ctrl&&C==="u"){Q(!1),$.current?.scrollBy(-12);return}if(x.home){Q(!1),$.current?.scrollToTop();return}if(x.end){Q(!0),$.current?.scrollToBottom();return}return}if(a.focusedPanel==="dock"&&B&&c){if(x.tab){I(null),i.setFocusedPanel("tasks");return}if(x.escape){i.setFocusedPanel("tasks"),I(null),a.viewMode==="split"&&(i.setViewMode("list"),le("list"));return}if(x.downArrow||C==="j"){b(E=>Math.min(E+1,S.length-1));return}if(x.upArrow||C==="k"){b(E=>Math.max(E-1,0));return}if(x.return){const E=S[q];E&&(I(E),Q(!0),se(),K.current.splitList=0,K.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),le("split"));return}if((C==="r"||C==="R")&&e){const E=S[q],re=E?c.getState(E)?.status:void 0;if(E&&(re==="crashed"||re==="failed")){const Ie=e(E);Ie instanceof Promise&&Ie.catch(()=>{})}return}return}if(a.viewMode==="split"){if(x.tab){a.focusedPanel==="tasks"?i.setFocusedPanel("output"):B?i.setFocusedPanel("dock"):(I(null),i.setFocusedPanel("tasks"));return}if(a.focusedPanel==="output"){if(x.escape){if(T&&B){I(null),i.setViewMode("list"),i.setFocusedPanel("dock"),le("list");return}I(null),i.setFocusedPanel("tasks");return}if(x.return){se(),i.setViewMode("fullscreen");return}if(C==="f"){const E=!ae;Q(E),E&&$.current?.scrollToBottom();return}if(x.downArrow||C==="j"){Q(!1),$.current?.scrollBy(1);return}if(x.upArrow||C==="k"){Q(!1),$.current?.scrollBy(-1);return}if(x.pageDown||x.ctrl&&C==="d"){Q(!1),$.current?.scrollBy(12);return}if(x.pageUp||x.ctrl&&C==="u"){Q(!1),$.current?.scrollBy(-12);return}if(x.home){Q(!1),$.current?.scrollToTop();return}if(x.end){Q(!0),$.current?.scrollToBottom();return}return}if(x.escape){i.setViewMode("list"),le("list");return}if(x.return){i.setFocusedPanel("output");return}}if(a.viewMode==="list"||a.viewMode==="split"&&a.focusedPanel==="tasks"){if(x.tab&&a.viewMode==="list"&&B){i.setFocusedPanel("dock");return}if(x.downArrow||C==="j"){const E=Math.min(a.selectedIndex+1,Math.max(0,ie.length-1));i.setSelectedIndex(E),te(E);return}if(x.upArrow||C==="k"){const E=Math.max(a.selectedIndex-1,0);i.setSelectedIndex(E),te(E);return}if(x.return&&a.viewMode==="list"){Q(!0),se(),K.current.splitList=0,K.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),le("split");return}if(C==="/"){i.setFilterActive(!0);return}if(C==="1"&&H){i.pinTask(0,H);return}if(C==="2"&&H){i.pinTask(1,H);return}if(C==="0"){i.clearPins();return}x.escape&&a.filterText&&i.setFilter("")}}},{isActive:!a.interactiveMode}),f<gs||p<ws)return n.jsx(g,{alignItems:"center",height:p,justifyContent:"center",width:f,children:n.jsxs(l,{color:"yellow",children:["Terminal too small (",f,"x",p,"). Minimum:"," ",gs,"x",ws]})});const Ae=n.jsxs(g,{gap:1,children:[a.succeeded>0&&n.jsxs(l,{bold:!0,color:"green",children:["✓"," ",a.succeeded]}),a.cached>0&&n.jsxs(l,{dimColor:!0,children:["✓"," ",a.cached]}),a.failed>0&&n.jsxs(l,{bold:!0,color:"red",children:["✗"," ",a.failed]}),a.running>0&&n.jsxs(l,{color:"cyan",children:["◷"," ",a.running]}),n.jsxs(l,{dimColor:!0,children:[a.totalTasks," ","total"]}),a.statusFilter!=="all"&&n.jsxs(l,{color:"yellow",children:["[",a.statusFilter,"]"]})]});let ve;if(a.viewMode==="fullscreen")ve=[n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"Esc"}),n.jsx(l,{dimColor:!0,children:"BACK"})]},"esc"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"↑↓"}),n.jsx(l,{dimColor:!0,children:"SCROLL"})]},"scroll"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"^u ^d"}),n.jsx(l,{dimColor:!0,children:"PAGE"})]},"page"),...Z?.status==="running"?[n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"i"}),n.jsx(l,{dimColor:!0,children:"INPUT"})]},"i")]:[],n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"q"}),n.jsx(l,{dimColor:!0,children:"QUIT"})]},"q")];else if(a.done){const C=ie[a.selectedIndex]?.status==="failure";ve=[n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"q"}),n.jsx(l,{dimColor:!0,children:"QUIT"})]},"q"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"r"}),n.jsx(l,{dimColor:!0,children:"RERUN"})]},"r"),...C?[n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"R"}),n.jsx(l,{dimColor:!0,children:"RETRY"})]},"R")]:[],n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"?"}),n.jsx(l,{dimColor:!0,children:"HELP"})]},"?"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"↑↓"}),n.jsx(l,{dimColor:!0,children:"NAV"})]},"nav"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"F"}),n.jsx(l,{dimColor:!0,children:"FILTER"})]},"F"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"⏎"}),n.jsx(l,{dimColor:!0,children:a.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else a.viewMode==="split"&&a.focusedPanel==="output"?ve=[n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"q"}),n.jsx(l,{dimColor:!0,children:"QUIT"})]},"q"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"Esc"}),n.jsx(l,{dimColor:!0,children:"BACK"})]},"esc"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"↑↓"}),n.jsx(l,{dimColor:!0,children:"SCROLL"})]},"scroll"),...Z?.status==="running"?[n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"i"}),n.jsx(l,{dimColor:!0,children:"INPUT"})]},"i")]:[],n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"⏎"}),n.jsx(l,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"Tab"}),n.jsx(l,{dimColor:!0,children:"PANEL"})]},"tab"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"?"}),n.jsx(l,{dimColor:!0,children:"HELP"})]},"?")]:ve=[n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"q"}),n.jsx(l,{dimColor:!0,children:"QUIT"})]},"q"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"?"}),n.jsx(l,{dimColor:!0,children:"HELP"})]},"?"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"↑↓"}),n.jsx(l,{dimColor:!0,children:"NAV"})]},"nav"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"/"}),n.jsx(l,{dimColor:!0,children:"FILTER"})]},"/"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"F"}),n.jsx(l,{dimColor:!0,children:"STATUS"})]},"F"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"⏎"}),n.jsx(l,{dimColor:!0,children:a.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...a.viewMode==="split"?[n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"Tab"}),n.jsx(l,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const he=n.jsxs(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,justifyContent:"space-between",children:[n.jsx(g,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:ve}),n.jsx(g,{flexShrink:0,paddingX:1,children:Ae})]}),ye=n.jsxs(Sr,{backgroundColor:"#1e1e1e",footer:n.jsxs(l,{dimColor:!0,children:[n.jsx(l,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",n.jsx(l,{bold:!0,color:"white",children:"?"}),"/",n.jsx(l,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:F,title:"KEYBOARD SHORTCUTS",visible:M,width:52,children:[n.jsxs(g,{flexDirection:"column",marginBottom:1,children:[n.jsxs(g,{marginBottom:1,children:[n.jsx(l,{dimColor:!0,children:"── "}),n.jsx(l,{bold:!0,color:"white",children:"NAVIGATION"})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","↑","/k"]}),n.jsx(l,{dimColor:!0,children:" Move up"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","↓","/j"]}),n.jsx(l,{dimColor:!0,children:" Move down"})]})]}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","Tab"]}),n.jsx(l,{dimColor:!0,children:" Switch panel (split)"})]}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","Esc"]}),n.jsx(l,{dimColor:!0,children:" Back / close"})]}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","Enter"]}),n.jsx(l,{dimColor:!0,children:" Show output / fullscreen"})]})]}),n.jsxs(g,{flexDirection:"column",marginBottom:1,children:[n.jsxs(g,{marginBottom:1,children:[n.jsx(l,{dimColor:!0,children:"── "}),n.jsx(l,{bold:!0,color:"white",children:"VIEWS"})]}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","Enter"]}),n.jsxs(l,{dimColor:!0,children:[" ","List"," ","→"," ","Split"," ","→"," ","Fullscreen"]})]}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","Esc"]}),n.jsxs(l,{dimColor:!0,children:[" ","Fullscreen"," ","→"," ","Split"," ","→"," ","List"]})]})]}),n.jsxs(g,{flexDirection:"column",marginBottom:1,children:[n.jsxs(g,{marginBottom:1,children:[n.jsx(l,{dimColor:!0,children:"── "}),n.jsx(l,{bold:!0,color:"white",children:"ACTIONS"})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","/"]}),n.jsx(l,{dimColor:!0,children:" Filter by text"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","F"]}),n.jsx(l,{dimColor:!0,children:" Filter by status"})]})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","1"]}),n.jsx(l,{dimColor:!0,children:"/"}),n.jsx(l,{bold:!0,color:"white",children:"2"}),n.jsx(l,{dimColor:!0,children:" Pin to output pane"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","0"]}),n.jsx(l,{dimColor:!0,children:" Clear pins"})]})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","r"]}),n.jsx(l,{dimColor:!0,children:" Rerun all (done)"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","R"]}),n.jsx(l,{dimColor:!0,children:" Retry failed task"})]})]}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","i"]}),n.jsx(l,{dimColor:!0,children:" Interactive input (running task)"})]})]}),n.jsxs(g,{flexDirection:"column",marginBottom:1,children:[n.jsxs(g,{marginBottom:1,children:[n.jsx(l,{dimColor:!0,children:"── "}),n.jsx(l,{bold:!0,color:"white",children:"SCROLLING"}),n.jsx(l,{dimColor:!0,children:" (output panel)"})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","↑","/k"]}),n.jsx(l,{dimColor:!0,children:" Scroll up"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","↓","/j"]}),n.jsx(l,{dimColor:!0,children:" Scroll down"})]})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","^u"]}),n.jsx(l,{dimColor:!0,children:" Page up"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","^d"]}),n.jsx(l,{dimColor:!0,children:" Page down"})]})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","Home"]}),n.jsx(l,{dimColor:!0,children:" Top"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","End"]}),n.jsx(l,{dimColor:!0,children:" Bottom (resume follow)"})]})]}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","f"]}),n.jsx(l,{dimColor:!0,children:" Toggle auto-scroll (tail mode)"})]})]}),n.jsxs(g,{flexDirection:"column",children:[n.jsxs(g,{marginBottom:1,children:[n.jsx(l,{dimColor:!0,children:"── "}),n.jsx(l,{bold:!0,color:"white",children:"GENERAL"})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","q"]}),n.jsx(l,{dimColor:!0,children:" Quit"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","?"]}),n.jsx(l,{dimColor:!0,children:" Toggle help"})]})]})]})]}),xe=n.jsx(Tr,{autoExitSeconds:s>0?s:3,onCancel:()=>{X(!1)},visible:N}),$e=B&&c?n.jsx(qi,{activeIndex:q,focused:a.focusedPanel==="dock",store:c}):null;if(a.viewMode==="fullscreen")return n.jsxs(g,{flexDirection:"column",height:p,width:f,children:[n.jsx(g,{flexGrow:1,children:n.jsx(fs,{autoScroll:ae,duration:Z?.duration??Z?.elapsed,focused:!0,interactiveMode:a.interactiveMode,output:P,scrollRef:$,status:Ee,supportsInteractive:!T,taskId:ge})}),$e,he,xe,ye]});if(a.viewMode==="split"){const C=f>=vs,x=n.jsx(ms,{compact:!0,filterActive:a.filterActive,filterText:a.filterText,focused:a.focusedPanel==="tasks",headerStatus:Oe,parallelSlots:t,pinnedTaskIds:a.pinnedTaskIds,rows:ie,scrollRef:_,selectedIndex:a.selectedIndex,title:_e}),E=n.jsx(fs,{autoScroll:ae,duration:Z?.duration??Z?.elapsed,focused:a.focusedPanel==="output",interactiveMode:a.interactiveMode,output:P,scrollRef:$,showFullscreenHint:!0,status:Ee,supportsInteractive:!T,taskId:ge});if(C){const Ie=Math.floor(f*.4);return n.jsxs(g,{flexDirection:"column",height:p,width:f,children:[n.jsxs(g,{flexDirection:"row",flexGrow:1,children:[n.jsx(g,{width:Ie,children:x}),n.jsx(g,{flexGrow:1,children:E})]}),$e,he,xe,ye]})}const re=Math.floor(p*.45);return n.jsxs(g,{flexDirection:"column",height:p,width:f,children:[n.jsx(g,{height:re,children:x}),n.jsx(g,{flexGrow:1,children:E}),$e,he,xe,ye]})}return n.jsxs(g,{flexDirection:"column",height:p,width:f,children:[n.jsx(g,{flexGrow:1,children:n.jsx(ms,{filterActive:a.filterActive,filterText:a.filterText,focused:a.focusedPanel!=="dock",headerStatus:Oe,parallelSlots:t,pinnedTaskIds:a.pinnedTaskIds,rows:ie,scrollRef:_,selectedIndex:a.selectedIndex,title:_e})}),$e,he,xe,ye]})},Yi=s=>{const{args:e,autoExit:t=!1,onRetryService:r,outputStyle:c="normal",projectNames:o,serviceDockStore:i,stdinRegistry:d,tasks:u,totalTaskCount:h}=s,f=new ot(u,h),p=typeof e.parallel=="number"?e.parallel:3,a=t===!0?3:typeof t=="number"?t:0;let k,S;const B=new Promise($=>{S=$});let q;const b=()=>{q&&(clearInterval(q),q=void 0)},T=()=>{if(process.stdin.isTTY&&typeof process.stdin.setRawMode=="function")try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause(),process.stdin.unref()},I=()=>{if(d){for(const $ of d.values())$.kill?.();d.clear()}},j=()=>{b(),F(),I(),T(),process.stdout.write("\x1B[?1049l\x1B[?25h"),k?.cleanup(),process.exit(1)},M=()=>{const $=f.getSnapshot(),N=Be(Date.now()-$.startTime),X=$.rows.filter(K=>K.status==="failure").map(K=>K.taskId),ae=process.stdout.columns||80;process.stdout.write(`
13
+ `))b.push(T.endsWith("\r")?T.slice(0,-1):T);return!c&&(f==="running"||f==="pending")?n.jsx(g,{borderBottomTitle:q,borderColor:k,borderStyle:a,borderTopRightTitle:B,borderTopTitle:S,flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:n.jsx(g,{alignItems:"center",flexGrow:1,justifyContent:"center",children:n.jsx(l,{dimColor:!0,children:"Waiting for task output…"})})}):n.jsxs(g,{borderBottomTitle:q,borderColor:r?"yellow":k,borderStyle:a,borderTopRightTitle:B,borderTopTitle:S,flexDirection:"column",flexGrow:1,children:[n.jsx(g,{flexGrow:1,flexShrink:1,paddingY:1,children:n.jsx($s,{flexGrow:1,followOutput:s,paddingX:2,ref:o,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:n.jsx(l,{children:b.join(`
14
+ `)})})}),r&&n.jsx(g,{flexShrink:0,justifyContent:"center",paddingX:1,children:n.jsx(l,{bold:!0,color:"yellow",children:"INTERACTIVE | keystrokes forwarded to task | Esc to exit"})})]})},_i={crashed:"✖",failed:"✖",pending:"·",ready:"●",starting:"•"},Gs=s=>s==="ready"?"green":s==="crashed"||s==="failed"?"red":s==="starting"?"cyan":"gray",Ni=({status:s})=>s==="starting"?n.jsx(l,{color:"cyan",children:n.jsx(Ps,{type:"dots"})}):n.jsx(l,{bold:!0,color:Gs(s),children:_i[s]}),Gi=({active:s,focused:e,state:t})=>{const r=e&&s,c=r?">":" ",o=t.status==="ready"?t.port?`running, port ${String(t.port)}`:"running":t.status==="failed"||t.status==="crashed"?t.errorMessage??"exited":t.lastLine??"booting…";return n.jsxs(g,{flexDirection:"row",flexShrink:0,overflow:"hidden",children:[n.jsx(l,{children:c}),n.jsx(l,{children:" "}),n.jsx(g,{flexShrink:0,width:3,children:n.jsx(Ni,{status:t.status})}),n.jsx(g,{flexGrow:0,flexShrink:0,width:28,children:n.jsx(l,{bold:r,inverse:r,children:t.id})}),n.jsx(g,{flexGrow:1,flexShrink:1,overflow:"hidden",children:n.jsxs(l,{color:Gs(t.status),dimColor:t.status!=="crashed"&&t.status!=="failed",wrap:"truncate-end",children:[" ",o]})})]})},Wi=({states:s})=>{const e=[];for(const r of s)r.status==="ready"&&e.push(r.id);const t=e.join(", ");return n.jsxs(g,{paddingX:1,children:[n.jsxs(l,{bold:!0,color:"green",children:["● ","Services"]}),n.jsxs(l,{children:[" ",String(e.length)," / ",String(s.length)," running"]}),t.length>0&&n.jsxs(l,{dimColor:!0,children:[" ",t]}),n.jsx(l,{dimColor:!0,children:" [Tab ↓]"})]})},Hi=({states:s})=>{const e=s.find(t=>t.status==="crashed"||t.status==="failed");return e?n.jsxs(g,{flexDirection:"column",paddingX:1,children:[n.jsxs(l,{bold:!0,color:"red",children:["✖ ","Service crashed:"," ",e.id]}),e.tailLines.slice(-3).map((t,r)=>n.jsxs(l,{color:"red",dimColor:!0,children:[" ",t]},`crash-${String(r)}`))]}):n.jsx(n.Fragment,{})},qi=({activeIndex:s,focused:e,store:t})=>{const r=z.useSyncExternalStore(t.subscribe,t.getSnapshot),c=t.getIds();if(c.length===0)return n.jsx(n.Fragment,{});const o=c.map(f=>r.get(f)).filter(f=>f!==void 0),i=t.getDockState(),d=i==="crash"?"red":i==="ready"?"gray":e?"white":"cyan",u=i==="crash"?"Services (crashed)":i==="ready"?"Services":"Services (starting)",h=e?i==="crash"?"↑↓ select Enter logs R retry Esc back":"↑↓ select Enter logs Esc back":"Tab to focus services";return i==="ready"&&!e?n.jsx(g,{borderColor:d,borderStyle:"single",flexDirection:"row",flexShrink:0,children:n.jsx(Wi,{states:o})}):n.jsxs(g,{borderBottomTitle:h,borderColor:d,borderStyle:e?"bold":"single",borderTopTitle:u,flexDirection:"column",flexGrow:2,flexShrink:0,minHeight:6,paddingX:1,children:[i==="crash"&&n.jsx(Hi,{states:o}),o.map((f,p)=>n.jsx(Gi,{active:p===s,focused:e,state:f},f.id))]})},Ws=6,Hs=8,qs=12,Vi=s=>s==="running"||s==="pending"?Rs:s==="local-cache"||s==="local-cache-kept-existing"?"Local":s==="remote-cache"?"Remote":lt,hs=(s,e)=>e[0]===s?"[1]":e[1]===s?"[2]":"",ps=({compact:s,focused:e,isSelected:t,pinLabel:r,row:c})=>{const{persistent:o,status:i,taskId:d}=c,u=e&&t,h=u?">":" ",f=i==="running"&&o===!0;let p;if(f)p=n.jsx(l,{bold:!0,color:"green",children:" ● "});else if(i==="running")p=n.jsxs(l,{bold:!0,color:"white",children:[" ",n.jsx(Ps,{type:"dots"})," "]});else if(i==="pending")p=n.jsx(l,{bold:!0,color:"gray",children:" · "});else{const{color:k,icon:S}=He(i);p=n.jsxs(l,{bold:!0,color:k,children:[" ",S," "]})}let a=Rs;return f?a="running":i!=="running"&&i!=="pending"?a=c.duration===void 0?lt:Be(c.duration):i==="running"&&c.elapsed!==void 0&&(a=Be(c.elapsed)),n.jsxs(g,{children:[n.jsx(l,{children:h}),n.jsx(g,{width:Ws,children:p}),n.jsxs(g,{flexGrow:1,children:[n.jsx(l,{bold:u,inverse:u,children:d}),r?n.jsx(l,{dimColor:!0,children:` ${r}`}):null]}),!s&&n.jsx(g,{justifyContent:"flex-end",width:Hs,children:n.jsx(l,{dimColor:!Ge(i),children:Vi(i)})}),!s&&n.jsx(g,{justifyContent:"flex-end",width:qs,children:n.jsx(l,{color:f?"green":void 0,dimColor:i==="pending"||f,children:a})})]})},ms=({compact:s,filterActive:e,filterText:t,focused:r,headerStatus:c,parallelSlots:o=3,pinnedTaskIds:i,rows:d,scrollRef:u,selectedIndex:h,title:f})=>{const p=c==="error"?"red":c==="success"?"green":r?"white":"gray",a=d[h]?.taskId,k=[];let S=0;for(const T of d)T.status==="running"?k.push(T):T.status==="pending"&&(S+=1);const B=Math.min(o,k.length+S),q=B>1,b=[];if(q)for(let T=0;T<B;T++){const I=k[T];I?b.push(n.jsx(ps,{compact:s,focused:r,isSelected:I.taskId===a,pinLabel:hs(I.taskId,i),row:I},`par-${I.taskId}`)):b.push(n.jsxs(g,{children:[n.jsx(l,{children:" "}),n.jsx(g,{width:Ws,children:n.jsx(l,{bold:!0,color:"gray",children:" · "})}),n.jsx(l,{dimColor:!0,children:"Waiting for task..."})]},`par-empty-${String(T)}`))}return n.jsxs(g,{borderColor:p,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[n.jsxs(g,{flexShrink:0,paddingX:1,children:[n.jsx(l,{bold:!0,inverse:!0,children:" VIS "}),n.jsx(l,{children:` ${f}`}),!s&&n.jsxs(g,{flexGrow:1,gap:0,justifyContent:"flex-end",children:[n.jsx(g,{justifyContent:"flex-end",width:Hs,children:n.jsx(l,{dimColor:!0,children:"Cache"})}),n.jsx(g,{justifyContent:"flex-end",width:qs,children:n.jsx(l,{dimColor:!0,children:"Duration"})})]})]}),n.jsx($s,{flexGrow:1,flexShrink:1,paddingX:1,paddingY:1,ref:u,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:d.map(T=>n.jsx(ps,{compact:s,focused:r,isSelected:T.taskId===a,pinLabel:hs(T.taskId,i),row:T},T.taskId))}),q&&n.jsx(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexDirection:"column",flexShrink:0,paddingX:1,paddingY:1,children:b}),e&&n.jsxs(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexShrink:0,paddingX:1,children:[n.jsx(l,{bold:!0,color:"white",children:"/ "}),n.jsx(l,{children:t}),n.jsx(l,{inverse:!0,children:" "})]})]})},gs=40,ws=10,vs=100,Ui=Object.freeze([]),zi=({autoExitSeconds:s,onRetryService:e,parallelSlots:t,projectNames:r,serviceDockStore:c,stdinRegistry:o,store:i,targets:d,tasks:u})=>{const{exit:h}=Sr(),{columns:f,rows:p}=Tr(),a=z.useSyncExternalStore(i.subscribe,i.getSnapshot),k=z.useCallback(C=>c?c.subscribe(C):()=>{},[c]);z.useSyncExternalStore(k,()=>c?c.getDockState():"ready");const S=c?c.getIds():Ui,B=S.length>0,[q,b]=z.useState(0),[T,I]=z.useState(null),j=z.useSyncExternalStore(k,()=>T&&c?c.getState(T):void 0),[M,w]=z.useState(!1),F=z.useRef(null),_=z.useRef(null),$=z.useRef(null),[N,X]=z.useState(!1),[ae,Q]=z.useState(!0),K=z.useRef({list:0,splitList:0,splitOutput:0}),se=z.useCallback(()=>{a.viewMode==="list"?K.current.list=_.current?.getScrollOffset()??0:a.viewMode==="split"&&(K.current.splitList=_.current?.getScrollOffset()??0,K.current.splitOutput=$.current?.getScrollOffset()??0)},[a.viewMode]),le=z.useCallback(C=>{setTimeout(()=>{if(C==="list"){const x=K.current.list;_.current?.scrollTo(x)}else if(C==="split"){const x=K.current.splitList;x>0?_.current?.scrollTo(x):_.current?.scrollTo(Math.max(0,i.getSnapshot().selectedIndex-2)),$.current?.scrollTo(K.current.splitOutput)}},0)},[i]),de=z.useRef(!1);z.useEffect(()=>{a.done&&!de.current&&(de.current=!0,s>0&&a.failed===0&&X(!0)),!a.done&&de.current&&(de.current=!1,X(!1))},[a.done,a.failed,s]);const ie=z.useMemo(()=>{const C=S.length>0?new Set(S):null,x=a.filterText?a.filterText.toLowerCase():null,E=[];for(const re of a.rows)C?.has(re.taskId)||a.statusFilter==="failed"&&re.status!=="failure"||a.statusFilter==="running"&&re.status!=="running"&&re.status!=="pending"||a.statusFilter==="passed"&&re.status!=="success"&&!Ge(re.status)||x&&!re.taskId.toLowerCase().includes(x)||E.push(re);return E},[a.rows,a.filterText,a.statusFilter,S]),H=(ie[a.selectedIndex]??null)?.taskId??null,G=T?null:a.pinnedTaskIds[0]??H,Z=G?a.rows.find(C=>C.taskId===G):null,me=j??null,ke=T?(me?.tailLines??[]).join(`
15
+ `):G?a.outputs.get(G)??"":"",P=z.useMemo(()=>Z?.status==="failure"&&ke?Ns(ke,{color:!process.env.NO_COLOR,cwd:process.cwd()}):ke,[Z?.status,ke]),ge=T??G,Ee=T?me?.status==="crashed"||me?.status==="failed"?"failure":"running":Z?.status,Fe=St(r,d,u),_e=a.done?`Completed ${Fe} (${Be((a.endTime??Date.now())-a.startTime)})`:`Running ${Fe}...`,Oe=a.done?a.failed>0?"error":"success":"running",te=z.useCallback(C=>{_.current?.scrollTo(Math.max(0,C-2))},[]);if(z.useEffect(()=>{a.interactiveMode&&Z?.status!=="running"&&i.setInteractiveMode(!1)},[a.interactiveMode,Z?.status,i]),z.useEffect(()=>{if(!G)return;let C=f;a.viewMode==="split"&&f>=vs?C=f-Math.floor(f*.4)-2:(a.viewMode==="split"||a.viewMode==="fullscreen")&&(C=f-2);const x=Math.max(1,p-4);o.get(G)?.resize?.(C,x)},[f,p,a.viewMode,G]),Qt((C,x)=>{if(x.escape){i.setInteractiveMode(!1);return}if(!G)return;const E=o.get(G);if(!E){i.setInteractiveMode(!1);return}if(x.return)E.write("\r");else if(x.upArrow)E.write("\x1B[A");else if(x.downArrow)E.write("\x1B[B");else if(x.rightArrow)E.write("\x1B[C");else if(x.leftArrow)E.write("\x1B[D");else if(x.backspace)E.write("");else if(x.delete)E.write("\x1B[3~");else if(x.tab)E.write(" ");else if(x.home)E.write("\x1B[H");else if(x.end)E.write("\x1B[F");else if(x.pageUp)E.write("\x1B[5~");else if(x.pageDown)E.write("\x1B[6~");else if(x.ctrl&&C){const re=C.toUpperCase().codePointAt(0);re!==void 0&&re>=65&&re<=90&&E.write(String.fromCodePoint(re-64))}else C&&E.write(C)},{isActive:a.interactiveMode}),Qt((C,x)=>{if(C==="c"&&x.ctrl){h();return}if(!N){if(M){x.escape||C==="?"?w(!1):C==="q"?(w(!1),X(!0)):x.downArrow||C==="j"?F.current?.scrollBy(1):x.upArrow||C==="k"?F.current?.scrollBy(-1):x.pageDown?F.current?.scrollBy(5):x.pageUp?F.current?.scrollBy(-5):x.home?F.current?.scrollToTop():x.end&&F.current?.scrollToBottom();return}if(C==="?"){w(!0);return}if(C==="q"){X(!0);return}if(C==="r"&&a.done){i.requestRerun();return}if(C==="R"&&a.done){const E=ie[a.selectedIndex];E?.status==="failure"&&i.requestRetry(E.taskId);return}if(C==="F"&&!a.filterActive){const E=["all","failed","running","passed"],re=E.indexOf(a.statusFilter);i.setStatusFilter(E[(re+1)%E.length]);return}if(a.filterActive){if(x.escape){i.setFilterActive(!1);return}if(x.return){i.setFilterActive(!1);return}if(x.backspace){i.setFilter(a.filterText.slice(0,-1));return}if(C&&!x.ctrl&&!x.meta){i.setFilter(a.filterText+C);return}return}if(C==="i"&&Z?.status==="running"&&(a.viewMode==="fullscreen"||a.viewMode==="split"&&a.focusedPanel==="output")){i.setInteractiveMode(!0);return}if(a.viewMode==="fullscreen"){if(x.escape){i.setViewMode("split"),le("split");return}if(C==="f"){const E=!ae;Q(E),E&&$.current?.scrollToBottom();return}if(x.downArrow||C==="j"){Q(!1),$.current?.scrollBy(1);return}if(x.upArrow||C==="k"){Q(!1),$.current?.scrollBy(-1);return}if(x.pageDown||x.ctrl&&C==="d"){Q(!1),$.current?.scrollBy(12);return}if(x.pageUp||x.ctrl&&C==="u"){Q(!1),$.current?.scrollBy(-12);return}if(x.home){Q(!1),$.current?.scrollToTop();return}if(x.end){Q(!0),$.current?.scrollToBottom();return}return}if(a.focusedPanel==="dock"&&B&&c){if(x.tab){I(null),i.setFocusedPanel("tasks");return}if(x.escape){i.setFocusedPanel("tasks"),I(null),a.viewMode==="split"&&(i.setViewMode("list"),le("list"));return}if(x.downArrow||C==="j"){b(E=>Math.min(E+1,S.length-1));return}if(x.upArrow||C==="k"){b(E=>Math.max(E-1,0));return}if(x.return){const E=S[q];E&&(I(E),Q(!0),se(),K.current.splitList=0,K.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),le("split"));return}if((C==="r"||C==="R")&&e){const E=S[q],re=E?c.getState(E)?.status:void 0;if(E&&(re==="crashed"||re==="failed")){const Ie=e(E);Ie instanceof Promise&&Ie.catch(()=>{})}return}return}if(a.viewMode==="split"){if(x.tab){a.focusedPanel==="tasks"?i.setFocusedPanel("output"):B?i.setFocusedPanel("dock"):(I(null),i.setFocusedPanel("tasks"));return}if(a.focusedPanel==="output"){if(x.escape){if(T&&B){I(null),i.setViewMode("list"),i.setFocusedPanel("dock"),le("list");return}I(null),i.setFocusedPanel("tasks");return}if(x.return){se(),i.setViewMode("fullscreen");return}if(C==="f"){const E=!ae;Q(E),E&&$.current?.scrollToBottom();return}if(x.downArrow||C==="j"){Q(!1),$.current?.scrollBy(1);return}if(x.upArrow||C==="k"){Q(!1),$.current?.scrollBy(-1);return}if(x.pageDown||x.ctrl&&C==="d"){Q(!1),$.current?.scrollBy(12);return}if(x.pageUp||x.ctrl&&C==="u"){Q(!1),$.current?.scrollBy(-12);return}if(x.home){Q(!1),$.current?.scrollToTop();return}if(x.end){Q(!0),$.current?.scrollToBottom();return}return}if(x.escape){i.setViewMode("list"),le("list");return}if(x.return){i.setFocusedPanel("output");return}}if(a.viewMode==="list"||a.viewMode==="split"&&a.focusedPanel==="tasks"){if(x.tab&&a.viewMode==="list"&&B){i.setFocusedPanel("dock");return}if(x.downArrow||C==="j"){const E=Math.min(a.selectedIndex+1,Math.max(0,ie.length-1));i.setSelectedIndex(E),te(E);return}if(x.upArrow||C==="k"){const E=Math.max(a.selectedIndex-1,0);i.setSelectedIndex(E),te(E);return}if(x.return&&a.viewMode==="list"){Q(!0),se(),K.current.splitList=0,K.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),le("split");return}if(C==="/"){i.setFilterActive(!0);return}if(C==="1"&&H){i.pinTask(0,H);return}if(C==="2"&&H){i.pinTask(1,H);return}if(C==="0"){i.clearPins();return}x.escape&&a.filterText&&i.setFilter("")}}},{isActive:!a.interactiveMode}),f<gs||p<ws)return n.jsx(g,{alignItems:"center",height:p,justifyContent:"center",width:f,children:n.jsxs(l,{color:"yellow",children:["Terminal too small (",f,"x",p,"). Minimum:"," ",gs,"x",ws]})});const Ae=n.jsxs(g,{gap:1,children:[a.succeeded>0&&n.jsxs(l,{bold:!0,color:"green",children:["✓"," ",a.succeeded]}),a.cached>0&&n.jsxs(l,{dimColor:!0,children:["✓"," ",a.cached]}),a.failed>0&&n.jsxs(l,{bold:!0,color:"red",children:["✗"," ",a.failed]}),a.running>0&&n.jsxs(l,{color:"cyan",children:["◷"," ",a.running]}),n.jsxs(l,{dimColor:!0,children:[a.totalTasks," ","total"]}),a.statusFilter!=="all"&&n.jsxs(l,{color:"yellow",children:["[",a.statusFilter,"]"]})]});let ve;if(a.viewMode==="fullscreen")ve=[n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"Esc"}),n.jsx(l,{dimColor:!0,children:"BACK"})]},"esc"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"↑↓"}),n.jsx(l,{dimColor:!0,children:"SCROLL"})]},"scroll"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"^u ^d"}),n.jsx(l,{dimColor:!0,children:"PAGE"})]},"page"),...Z?.status==="running"?[n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"i"}),n.jsx(l,{dimColor:!0,children:"INPUT"})]},"i")]:[],n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"q"}),n.jsx(l,{dimColor:!0,children:"QUIT"})]},"q")];else if(a.done){const C=ie[a.selectedIndex]?.status==="failure";ve=[n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"q"}),n.jsx(l,{dimColor:!0,children:"QUIT"})]},"q"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"r"}),n.jsx(l,{dimColor:!0,children:"RERUN"})]},"r"),...C?[n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"R"}),n.jsx(l,{dimColor:!0,children:"RETRY"})]},"R")]:[],n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"?"}),n.jsx(l,{dimColor:!0,children:"HELP"})]},"?"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"↑↓"}),n.jsx(l,{dimColor:!0,children:"NAV"})]},"nav"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"F"}),n.jsx(l,{dimColor:!0,children:"FILTER"})]},"F"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"⏎"}),n.jsx(l,{dimColor:!0,children:a.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else a.viewMode==="split"&&a.focusedPanel==="output"?ve=[n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"q"}),n.jsx(l,{dimColor:!0,children:"QUIT"})]},"q"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"Esc"}),n.jsx(l,{dimColor:!0,children:"BACK"})]},"esc"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"↑↓"}),n.jsx(l,{dimColor:!0,children:"SCROLL"})]},"scroll"),...Z?.status==="running"?[n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"i"}),n.jsx(l,{dimColor:!0,children:"INPUT"})]},"i")]:[],n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"⏎"}),n.jsx(l,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"Tab"}),n.jsx(l,{dimColor:!0,children:"PANEL"})]},"tab"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"?"}),n.jsx(l,{dimColor:!0,children:"HELP"})]},"?")]:ve=[n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"q"}),n.jsx(l,{dimColor:!0,children:"QUIT"})]},"q"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"?"}),n.jsx(l,{dimColor:!0,children:"HELP"})]},"?"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"↑↓"}),n.jsx(l,{dimColor:!0,children:"NAV"})]},"nav"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"/"}),n.jsx(l,{dimColor:!0,children:"FILTER"})]},"/"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"F"}),n.jsx(l,{dimColor:!0,children:"STATUS"})]},"F"),n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"⏎"}),n.jsx(l,{dimColor:!0,children:a.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...a.viewMode==="split"?[n.jsxs(g,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"Tab"}),n.jsx(l,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const he=n.jsxs(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,justifyContent:"space-between",children:[n.jsx(g,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:ve}),n.jsx(g,{flexShrink:0,paddingX:1,children:Ae})]}),ye=n.jsxs($r,{backgroundColor:"#1e1e1e",footer:n.jsxs(l,{dimColor:!0,children:[n.jsx(l,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",n.jsx(l,{bold:!0,color:"white",children:"?"}),"/",n.jsx(l,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:F,title:"KEYBOARD SHORTCUTS",visible:M,width:52,children:[n.jsxs(g,{flexDirection:"column",marginBottom:1,children:[n.jsxs(g,{marginBottom:1,children:[n.jsx(l,{dimColor:!0,children:"── "}),n.jsx(l,{bold:!0,color:"white",children:"NAVIGATION"})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","↑","/k"]}),n.jsx(l,{dimColor:!0,children:" Move up"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","↓","/j"]}),n.jsx(l,{dimColor:!0,children:" Move down"})]})]}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","Tab"]}),n.jsx(l,{dimColor:!0,children:" Switch panel (split)"})]}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","Esc"]}),n.jsx(l,{dimColor:!0,children:" Back / close"})]}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","Enter"]}),n.jsx(l,{dimColor:!0,children:" Show output / fullscreen"})]})]}),n.jsxs(g,{flexDirection:"column",marginBottom:1,children:[n.jsxs(g,{marginBottom:1,children:[n.jsx(l,{dimColor:!0,children:"── "}),n.jsx(l,{bold:!0,color:"white",children:"VIEWS"})]}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","Enter"]}),n.jsxs(l,{dimColor:!0,children:[" ","List"," ","→"," ","Split"," ","→"," ","Fullscreen"]})]}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","Esc"]}),n.jsxs(l,{dimColor:!0,children:[" ","Fullscreen"," ","→"," ","Split"," ","→"," ","List"]})]})]}),n.jsxs(g,{flexDirection:"column",marginBottom:1,children:[n.jsxs(g,{marginBottom:1,children:[n.jsx(l,{dimColor:!0,children:"── "}),n.jsx(l,{bold:!0,color:"white",children:"ACTIONS"})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","/"]}),n.jsx(l,{dimColor:!0,children:" Filter by text"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","F"]}),n.jsx(l,{dimColor:!0,children:" Filter by status"})]})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","1"]}),n.jsx(l,{dimColor:!0,children:"/"}),n.jsx(l,{bold:!0,color:"white",children:"2"}),n.jsx(l,{dimColor:!0,children:" Pin to output pane"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","0"]}),n.jsx(l,{dimColor:!0,children:" Clear pins"})]})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","r"]}),n.jsx(l,{dimColor:!0,children:" Rerun all (done)"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","R"]}),n.jsx(l,{dimColor:!0,children:" Retry failed task"})]})]}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","i"]}),n.jsx(l,{dimColor:!0,children:" Interactive input (running task)"})]})]}),n.jsxs(g,{flexDirection:"column",marginBottom:1,children:[n.jsxs(g,{marginBottom:1,children:[n.jsx(l,{dimColor:!0,children:"── "}),n.jsx(l,{bold:!0,color:"white",children:"SCROLLING"}),n.jsx(l,{dimColor:!0,children:" (output panel)"})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","↑","/k"]}),n.jsx(l,{dimColor:!0,children:" Scroll up"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","↓","/j"]}),n.jsx(l,{dimColor:!0,children:" Scroll down"})]})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","^u"]}),n.jsx(l,{dimColor:!0,children:" Page up"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","^d"]}),n.jsx(l,{dimColor:!0,children:" Page down"})]})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","Home"]}),n.jsx(l,{dimColor:!0,children:" Top"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","End"]}),n.jsx(l,{dimColor:!0,children:" Bottom (resume follow)"})]})]}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","f"]}),n.jsx(l,{dimColor:!0,children:" Toggle auto-scroll (tail mode)"})]})]}),n.jsxs(g,{flexDirection:"column",children:[n.jsxs(g,{marginBottom:1,children:[n.jsx(l,{dimColor:!0,children:"── "}),n.jsx(l,{bold:!0,color:"white",children:"GENERAL"})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","q"]}),n.jsx(l,{dimColor:!0,children:" Quit"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","?"]}),n.jsx(l,{dimColor:!0,children:" Toggle help"})]})]})]})]}),xe=n.jsx(Ir,{autoExitSeconds:s>0?s:3,onCancel:()=>{X(!1)},visible:N}),$e=B&&c?n.jsx(qi,{activeIndex:q,focused:a.focusedPanel==="dock",store:c}):null;if(a.viewMode==="fullscreen")return n.jsxs(g,{flexDirection:"column",height:p,width:f,children:[n.jsx(g,{flexGrow:1,children:n.jsx(fs,{autoScroll:ae,duration:Z?.duration??Z?.elapsed,focused:!0,interactiveMode:a.interactiveMode,output:P,scrollRef:$,status:Ee,supportsInteractive:!T,taskId:ge})}),$e,he,xe,ye]});if(a.viewMode==="split"){const C=f>=vs,x=n.jsx(ms,{compact:!0,filterActive:a.filterActive,filterText:a.filterText,focused:a.focusedPanel==="tasks",headerStatus:Oe,parallelSlots:t,pinnedTaskIds:a.pinnedTaskIds,rows:ie,scrollRef:_,selectedIndex:a.selectedIndex,title:_e}),E=n.jsx(fs,{autoScroll:ae,duration:Z?.duration??Z?.elapsed,focused:a.focusedPanel==="output",interactiveMode:a.interactiveMode,output:P,scrollRef:$,showFullscreenHint:!0,status:Ee,supportsInteractive:!T,taskId:ge});if(C){const Ie=Math.floor(f*.4);return n.jsxs(g,{flexDirection:"column",height:p,width:f,children:[n.jsxs(g,{flexDirection:"row",flexGrow:1,children:[n.jsx(g,{width:Ie,children:x}),n.jsx(g,{flexGrow:1,children:E})]}),$e,he,xe,ye]})}const re=Math.floor(p*.45);return n.jsxs(g,{flexDirection:"column",height:p,width:f,children:[n.jsx(g,{height:re,children:x}),n.jsx(g,{flexGrow:1,children:E}),$e,he,xe,ye]})}return n.jsxs(g,{flexDirection:"column",height:p,width:f,children:[n.jsx(g,{flexGrow:1,children:n.jsx(ms,{filterActive:a.filterActive,filterText:a.filterText,focused:a.focusedPanel!=="dock",headerStatus:Oe,parallelSlots:t,pinnedTaskIds:a.pinnedTaskIds,rows:ie,scrollRef:_,selectedIndex:a.selectedIndex,title:_e})}),$e,he,xe,ye]})},Yi=s=>{const{args:e,autoExit:t=!1,onRetryService:r,outputStyle:c="normal",projectNames:o,serviceDockStore:i,stdinRegistry:d,tasks:u,totalTaskCount:h}=s,f=new ot(u,h),p=typeof e.parallel=="number"?e.parallel:3,a=t===!0?3:typeof t=="number"?t:0;let k,S;const B=new Promise($=>{S=$});let q;const b=()=>{q&&(clearInterval(q),q=void 0)},T=()=>{if(process.stdin.isTTY&&typeof process.stdin.setRawMode=="function")try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause(),process.stdin.unref()},I=()=>{if(d){for(const $ of d.values())$.kill?.();d.clear()}},j=()=>{b(),F(),I(),T(),process.stdout.write("\x1B[?1049l\x1B[?25h"),k?.cleanup(),process.exit(1)},M=()=>{const $=f.getSnapshot(),N=Be(Date.now()-$.startTime),X=$.rows.filter(K=>K.status==="failure").map(K=>K.taskId),ae=process.stdout.columns||80;process.stdout.write(`
16
16
  `);for(const K of $.rows){const{persistent:se,status:le,taskId:de}=K,ie=le==="running"||le==="pending",we=He(le),H=ie&&se?"■":we.icon,G=ie&&se?"gray":we.color;let Z="";switch(le){case"local-cache":case"local-cache-kept-existing":{Z=" [local cache]";break}case"remote-cache":{Z=" [remote cache]";break}case"skipped":{Z=" [skipped]";break}default:{ie&&se?Z=" [stopped]":ie&&(Z=" [skipped]");break}}const me=K.retryAttempts&&K.retryAttempts>0?` [retried ${K.retryAttempts}x]`:"",ke=pe(J.createElement(l,null," ",J.createElement(l,{color:G},H),` vis run ${de}`,Z?J.createElement(l,{dimColor:!0},` ${Z}`):null,me?J.createElement(l,{color:"yellow"},me):null),{columns:ae});process.stdout.write(`${ke}
17
17
  `)}process.stdout.write(`
18
18
  `);const Q=pe(J.createElement(Bs,{cached:$.cached,failed:$.failed,failedIds:X,projectNames:o,retriedIds:$.retriedIds.length>0?$.retriedIds:void 0,succeeded:$.succeeded,targets:e.targets,tasks:u,took:N}),{columns:ae});if(process.stdout.write(`${Q}
@@ -25,7 +25,7 @@ ${s}`}catch{return s}},Mi={delimiter:" ",language:{d:()=>" d",future:"in %s",h:(
25
25
  `)}}};let w;const F=()=>{w&&(clearInterval(w),w=void 0)};return{lifeCycle:{endCommand(){b(),f.markDone(),w||(w=setInterval(()=>{},1e3))},endTasks($){f.endTasks($)},printCacheDisabledByTask($){f.addOutput($.id,`ⓘ caching disabled by task via disableCache()
26
26
  `)},printEmptyFingerprintWarning($,N){f.addOutput($.id,`ⓘ caching skipped — ${N}
27
27
  `)},printSelfModifyingSkip($,N){f.addOutput($.id,`ⓘ caching skipped — task modified its own input${N.length===1?"":"s"} (${N.join(", ")})
28
- `)},printTaskTerminalOutput($,N,X){f.getSnapshot().outputs.has($.id)||f.addOutput($.id,X)},startCommand(){process.on("SIGINT",j),process.on("SIGTERM",j),w||(w=setInterval(()=>{},1e3)),k=$r(J.createElement(zi,{autoExitSeconds:a,onRetryService:r,parallelSlots:p,projectNames:o,serviceDockStore:i,stdinRegistry:d??new Map,store:f,targets:e.targets,tasks:u}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}),k.waitUntilExit().then(()=>{F(),I(),T(),process.removeListener("SIGINT",j),process.removeListener("SIGTERM",j),M(),S()}).catch(()=>{F(),I(),T(),process.removeListener("SIGINT",j),process.removeListener("SIGTERM",j),S()})},startTasks($){f.startTasks($),q||(q=setInterval(()=>{f.tick()},100))}},renderIsDone:B,store:f}},Ki=s=>s==="quiet"?"quiet":"normal",Xi=(s,e)=>typeof s=="string"?Ki(s.toLowerCase()):e===!0?"quiet":"normal",Ji=(s,e)=>{const t=s.overrides.visOptions;return t?.outputStyle==="normal"||t?.outputStyle==="quiet"?t.outputStyle:e};class Qi{#e;#r;#s;#n=[];#t=[];#i=[];#o=new Map;#c;#a;#l;#u=0;constructor(e){this.#e=e.projectNames,this.#r=e.args.targets,this.#s=e.tasks,this.#c=e.logReporter,this.#a=e.outputStyle??"normal",this.#l=e.ciGrouping??"auto"}startCommand(){this.#u=Date.now();const e=process.stdout.columns||80,t=`Running ${St(this.#e,this.#r,this.#s)}`,r=pe(J.createElement(wt,{title:t,variant:"info"}),{columns:e});process.stdout.write(r);const c=this.#s[0],o=c?.overrides?Object.entries(c.overrides).filter(([i])=>i!=="command"):[];if(o.length>0){process.stdout.write(`
28
+ `)},printTaskTerminalOutput($,N,X){f.getSnapshot().outputs.has($.id)||f.addOutput($.id,X)},startCommand(){process.on("SIGINT",j),process.on("SIGTERM",j),w||(w=setInterval(()=>{},1e3)),k=Cr(J.createElement(zi,{autoExitSeconds:a,onRetryService:r,parallelSlots:p,projectNames:o,serviceDockStore:i,stdinRegistry:d??new Map,store:f,targets:e.targets,tasks:u}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}),k.waitUntilExit().then(()=>{F(),I(),T(),process.removeListener("SIGINT",j),process.removeListener("SIGTERM",j),M(),S()}).catch(()=>{F(),I(),T(),process.removeListener("SIGINT",j),process.removeListener("SIGTERM",j),S()})},startTasks($){f.startTasks($),q||(q=setInterval(()=>{f.tick()},100))}},renderIsDone:B,store:f}},Ki=s=>s==="quiet"?"quiet":"normal",Xi=(s,e)=>typeof s=="string"?Ki(s.toLowerCase()):e===!0?"quiet":"normal",Ji=(s,e)=>{const t=s.overrides.visOptions;return t?.outputStyle==="normal"||t?.outputStyle==="quiet"?t.outputStyle:e};class Qi{#e;#r;#s;#n=[];#t=[];#i=[];#o=new Map;#c;#a;#l;#u=0;constructor(e){this.#e=e.projectNames,this.#r=e.args.targets,this.#s=e.tasks,this.#c=e.logReporter,this.#a=e.outputStyle??"normal",this.#l=e.ciGrouping??"auto"}startCommand(){this.#u=Date.now();const e=process.stdout.columns||80,t=`Running ${St(this.#e,this.#r,this.#s)}`,r=pe(J.createElement(wt,{title:t,variant:"info"}),{columns:e});process.stdout.write(r);const c=this.#s[0],o=c?.overrides?Object.entries(c.overrides).filter(([i])=>i!=="command"):[];if(o.length>0){process.stdout.write(`
29
29
  With additional flags:
30
30
  `);for(const[i,d]of o)process.stdout.write(`${bi(" ",i,d)}
31
31
  `)}process.stdout.write(`
@@ -34,23 +34,23 @@ ${s}`}catch{return s}},Mi={delimiter:" ",language:{d:()=>" d",future:"in %s",h:(
34
34
  `)}}#d(e){const t=process.stdout.columns||80,r=pe(J.createElement(l,{dimColor:!0},` ⓘ ${e}`),{columns:t});process.stdout.write(`${r}
35
35
  `)}printCacheDisabledByTask(e){this.#d(`${e.id}: caching disabled by task via disableCache()`)}printSelfModifyingSkip(e,t){this.#d(`${e.id}: caching skipped — task modified its own input${t.length===1?"":"s"} (${t.join(", ")})`)}printEmptyFingerprintWarning(e,t){this.#d(`${e.id}: caching skipped — ${t}`)}printTaskTerminalOutput(e,t,r){if(Ji(e,this.#a)==="quiet"&&(t==="success"||Ge(t)))return;const c=t==="failure"?Ns(r,{color:!process.env.NO_COLOR,cwd:process.cwd()}):r;if(this.#c){this.#c.printTaskTerminalOutput(e,t,c);return}Li(e.id,t,c,this.#l)}endCommand(){const e=Be(Date.now()-this.#u),t=this.#s.filter(o=>!this.#o.has(o.id)).map(o=>o.id);process.stdout.write(`
36
36
  `);const r=process.stdout.columns||80,c=pe(J.createElement(Bs,{cached:this.#t.length,failed:this.#n.length,failedIds:this.#n.map(o=>o.task.id),projectNames:this.#e,retriedIds:this.#i.length>0?this.#i.map(o=>o.task.id):void 0,skippedIds:t.length>0?t:void 0,succeeded:this.#o.size-this.#n.length-this.#t.length,targets:this.#r,tasks:this.#s,took:e}),{columns:r});process.stdout.write(`${c}
37
- `)}}const Zi=async s=>{if(process.env.VIS_NO_SHELL_HISTORY)return;if(Dn()==="win32"){try{await so(s)}catch{}return}const e=process.env.SHELL;if(!e)return;const t=zr(e);try{if(t==="zsh"){await eo(s);return}if(t==="bash"){await to(s);return}t==="fish"&&await ro(s)}catch{}},Tt=s=>s.replaceAll(/[\u0000-\u001F\u007F]/gu," ").trimEnd(),eo=async s=>{const e=process.env.HISTFILE??ce(process.env.ZDOTDIR??kt(),".zsh_history"),t=`: ${Math.floor(Date.now()/1e3)}:0;${Tt(s)}
37
+ `)}}const Zi=async s=>{if(process.env.VIS_NO_SHELL_HISTORY)return;if(Dn()==="win32"){try{await so(s)}catch{}return}const e=process.env.SHELL;if(!e)return;const t=cr(e);try{if(t==="zsh"){await eo(s);return}if(t==="bash"){await to(s);return}t==="fish"&&await ro(s)}catch{}},Tt=s=>s.replaceAll(/[\u0000-\u001F\u007F]/gu," ").trimEnd(),eo=async s=>{const e=process.env.HISTFILE??ce(process.env.ZDOTDIR??kt(),".zsh_history"),t=`: ${Math.floor(Date.now()/1e3)}:0;${Tt(s)}
38
38
  `;await dt(e,t)},to=async s=>{const e=process.env.HISTFILE??ce(kt(),".bash_history");await dt(e,`${Tt(s)}
39
- `)},so=async s=>{const e=process.env.VIS_PSREADLINE_HISTORY,t=process.env.APPDATA;if(e===void 0&&(t===void 0||t===""))return;const r=e??ce(t,"Microsoft","Windows","PowerShell","PSReadLine","ConsoleHost_history.txt");await Ln($s(r),{recursive:!0}),await dt(r,`${Tt(s)}\r
39
+ `)},so=async s=>{const e=process.env.VIS_PSREADLINE_HISTORY,t=process.env.APPDATA;if(e===void 0&&(t===void 0||t===""))return;const r=e??ce(t,"Microsoft","Windows","PowerShell","PSReadLine","ConsoleHost_history.txt");await Ln(Ts(r),{recursive:!0}),await dt(r,`${Tt(s)}\r
40
40
  `)},ro=async s=>{const e=ce(kt(),".local","share","fish","fish_history"),r=`- cmd: ${s.replaceAll("\\","\\\\").replaceAll(`
41
41
  `,String.raw`\n`).replaceAll("\r",String.raw`\r`)}
42
42
  when: ${Math.floor(Date.now()/1e3)}
43
43
  `;await dt(e,r)},no=s=>{const{killGracePeriodMs:e=5e3,onTimeout:t,sendSignal:r,timeoutMs:c}=s;if(c<=0)return{cancel:()=>{}};const o=Math.max(e,0);let i;const d=setTimeout(()=>{t?.(),r("SIGTERM"),o>0&&(i=setTimeout(()=>{r("SIGKILL")},o))},c);return{cancel:()=>{clearTimeout(d),i&&clearTimeout(i)}}},io=(s,e)=>{const t=e?.trim();if(!t)return{filter:void 0,tasks:[...s]};const r=t.toLowerCase();return{filter:t,tasks:s.filter(c=>c.target.project.toLowerCase().includes(r))}},oo=[""," Watch keybinds:"," r, Enter rerun"," a rerun all (clear filter)"," p filter by project name"," q, Ctrl+C quit"," h, ? show this help",""].join(`
44
44
  `),co=s=>{s.write(`${oo}
45
45
  `)},ao=async(s,e)=>{e.write("filter projects (empty to cancel) > ");const t=s,r=t.isRaw===!0;if(r)try{t.setRawMode?.(!1)}catch{}return await new Promise(c=>{let o="";const i=d=>{o+=typeof d=="string"?d:d.toString("utf8");const u=o.indexOf(`
46
- `);if(u===-1)return;const h=o.slice(0,u).replace(/\r$/,"").trim();if(s.off("data",i),r)try{t.setRawMode?.(!0)}catch{}c(h.length>0?h:void 0)};s.on("data",i)})},lo=s=>{const{handlers:e}=s,t=s.input??process.stdin,r=s.output??process.stdout,c=s.promptFilter??ao;if(!t||t.isTTY===!1)return{close:()=>{}};Ur(t);const o=t.isRaw===!0;try{t.setRawMode?.(!0)}catch{return{close:()=>{}}}typeof t.resume=="function"&&t.resume();let i=!1;const d=async f=>{if(f.ctrl===!0&&f.name==="c"){await e.onQuit();return}if(!i)switch(f.name){case"?":case"h":{await e.onHelp();break}case"a":{await e.onClearFilter();break}case"p":{i=!0;try{const p=await c(t,r);p===void 0?r.write(`filter cancelled.
46
+ `);if(u===-1)return;const h=o.slice(0,u).replace(/\r$/,"").trim();if(s.off("data",i),r)try{t.setRawMode?.(!0)}catch{}c(h.length>0?h:void 0)};s.on("data",i)})},lo=s=>{const{handlers:e}=s,t=s.input??process.stdin,r=s.output??process.stdout,c=s.promptFilter??ao;if(!t||t.isTTY===!1)return{close:()=>{}};Yr(t);const o=t.isRaw===!0;try{t.setRawMode?.(!0)}catch{return{close:()=>{}}}typeof t.resume=="function"&&t.resume();let i=!1;const d=async f=>{if(f.ctrl===!0&&f.name==="c"){await e.onQuit();return}if(!i)switch(f.name){case"?":case"h":{await e.onHelp();break}case"a":{await e.onClearFilter();break}case"p":{i=!0;try{const p=await c(t,r);p===void 0?r.write(`filter cancelled.
47
47
  `):await e.onFilter(p)}finally{i=!1}break}case"q":{await e.onQuit();break}case"r":{await e.onRerun();break}case"return":{await e.onRerun();break}}},u=(f,p)=>{d(p).catch(a=>{r.write(`[vis watch] keybind handler failed: ${a.message}
48
- `)})},h=t;return h.on("keypress",u),{close:()=>{if(h.off("keypress",u),!o)try{t.setRawMode?.(!1)}catch{}const f=t;if(typeof f.pause=="function")try{f.pause()}catch{}}}},uo=s=>{const e=s.overrides.visOptions;return e&&typeof e=="object"?e:void 0},fo=async s=>{const{initialTasks:e,probe:t,registeredEntries:r,taskGraph:c,visVersion:o}=s,i=new Map,d=new Map,u=new Map;for(const w of r)if(Qr(w.pid)){if(w.visVersion!==o){d.set(w.id,w);continue}i.set(w.id,w)}if(t){const w=[...i.values()],F=await Promise.all(w.map(async _=>{try{return[_.id,await t(_)]}catch{return[_.id,!1]}}));for(const[_,$]of F)if(!$){const N=i.get(_);i.delete(_),N&&u.set(_,N)}}const h=new Set(e.map(w=>w.id)),f=new Set,p=[],a=[],k=new Set;for(const w of Object.values(c.dependencies))for(const F of w)k.add(F);for(const[w,F]of Object.entries(c.tasks)){if(!uo(F)?.service)continue;if(i.has(w)){f.add(w),a.push(i.get(w));continue}if(h.has(w)||!k.has(w))continue;const N=d.get(w),X=u.get(w);let ae;N?ae=`Service ${w} is registered with vis ${N.visVersion}, but this invocation is vis ${o}. Restart with \`vis service restart ${w}\` to pick up the new version.`:X?ae=`Service ${w} is registered (PID ${String(X.pid)}) but failed its readiness probe — the wrapper process is alive but the underlying server is not responding. Run \`vis service restart ${w}\` to recover.`:ae=`Target depends on the service ${w}, which is not running. Run \`vis service start ${w}\` first, or invoke \`${w}\` directly.`,p.push({message:ae,targetId:w})}if(f.size===0)return{diagnostics:p,initialTasks:e,satisfiedServices:a,serviceDependentsByServiceId:new Map,serviceEnvByTaskId:new Map,taskGraph:c};const S=new Map,B=w=>{const F=new Set,_=[...c.dependencies[w]??[]],$=new Set;for(;_.length>0;){const N=_.pop();if(!$.has(N)){$.add(N),f.has(N)&&F.add(N);for(const X of c.dependencies[N]??[])$.has(X)||_.push(X)}}return[...F].sort()},q=new Map;for(const w of Object.keys(c.dependencies)){if(f.has(w))continue;const F=B(w);if(F.length===0)continue;const _={};for(const $ of F){const N=i.get($);if(!N)continue;Object.assign(_,N.env);const X=q.get($);X?X.push(w):q.set($,[w])}Object.keys(_).length>0&&S.set(w,_)}for(const w of q.values())w.sort();const b={};for(const[w,F]of Object.entries(c.tasks))f.has(w)||(b[w]=F);const T={};for(const[w,F]of Object.entries(c.dependencies))f.has(w)||(T[w]=F.filter(_=>!f.has(_)));const I=new Map;for(const w of Object.keys(b))I.set(w,0);for(const w of Object.values(T))for(const F of w)I.has(F)&&I.set(F,(I.get(F)??0)+1);const j=[];for(const w of c.roots)!f.has(w)&&b[w]&&j.push(w);for(const[w,F]of I)F===0&&!j.includes(w)&&b[w]&&j.push(w);const M=e.filter(w=>!f.has(w.id));return{diagnostics:p,initialTasks:M,satisfiedServices:a,serviceDependentsByServiceId:q,serviceEnvByTaskId:S,taskGraph:{dependencies:T,roots:j,tasks:b}}},ho=s=>s.startsWith("./")||s.startsWith("../")||s.startsWith("/")||s.startsWith("**"),po=s=>{let e=s.trim();if(e==="")return;let t=!1,r=!1,c=!1;e.startsWith("...")&&(t=!0,e=e.slice(3),e.startsWith("^")&&(c=!0,e=e.slice(1))),e.endsWith("...")&&(r=!0,e=e.slice(0,-3),e.endsWith("^")&&(c=!0,e=e.slice(0,-1)));let o;const i=/\[([^\]]*)\]$/.exec(e);i&&(o=i[1]??"",e=e.slice(0,i.index));let d=e.trim(),u=!1;return d.startsWith("{")&&d.endsWith("}")&&d.length>=2?(d=d.slice(1,-1),u=!0):ho(d)&&(u=!0),{changedSince:o,excludeSelf:c,includeDependencies:r,includeDependents:t,isPath:u,pattern:d}},vt=s=>{let e=s.replaceAll("\\","/");return e.startsWith("./")&&(e=e.slice(2)),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e},mo=(s,e,t)=>s===""?!1:gt(s,e)?!0:t!==void 0&&gt(s,t),go=(s,e)=>{if(e===void 0||e==="")return!1;const t=vt(s),r=vt(e);return gt(t,r)},wo=(s,e,t)=>{const{affected:r,downstream:c,upstream:o}=ar(s,t,{downstream:e.includeDependents?"deep":"none",upstream:e.includeDependencies?"deep":"none"});if(!e.excludeSelf)return r;const i=new Set([...c,...o]);for(const d of s)i.delete(d);return i},vo=async(s,e)=>{const{packageNameByProject:t,projectGraph:r}=e,c=Object.keys(r.nodes);let o=new Set;if(s.pattern!=="")for(const i of c)s.isPath?go(s.pattern,r.nodes[i]?.data.root)&&o.add(i):mo(s.pattern,i,t?.get(i))&&o.add(i);if(s.changedSince!==void 0){const i=s.changedSince===""?e.defaultBase??"main":s.changedSince,d=e.changedProjectsForRef??yo(e),u=new Set(await d(i));o=s.pattern===""?u:new Set([...o].filter(h=>u.has(h)))}return!s.includeDependents&&!s.includeDependencies?o:wo(o,s,r)},yo=s=>async e=>{const{projectGraph:t,workspaceRoot:r}=s;if(!r)return[];let c;try{c=await lr(r,e,"HEAD")}catch(i){const d=i instanceof Error?i.message:String(i);throw new Error(`vis run --filter: invalid changed-since ref "${e}" (${d})`,{cause:i})}const o=new Set;for(const[i,d]of Object.entries(t.nodes)){const u=vt(d.data.root??i);if(!(u===""||u==="."))for(const h of c){const f=Yr(r,h).replaceAll("\\","/");if(f===u||f.startsWith(`${u}/`)){o.add(i);break}}}return[...o]},xo=async(s,e)=>{const t=new Set;for(const r of s)for(const c of await vo(r,e))t.add(c);return[...t]},jo=async(s,e)=>{const t=[];for(const r of s){const c=po(r);c&&t.push(c)}return xo(t,e)},et="[[VIS_BOOT]]",ko=250,bo=1e3,ys=3,So=s=>{try{return process.kill(s,0),!0}catch{return!1}},xs=s=>{try{const e=We(s,"utf8").trim(),t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:null}catch{return null}};class To{#e;#r;#s;#n;#t=new Map;#i=new Map;#o=new Map;#c=new Map;#a=new Set;constructor(e){this.#e=e.indexToId,this.#r=new Map(e.services),this.#s=e.sink,this.#n=e.workspaceRoot}onProcessEvent=e=>{if(e.kind!=="stdout"&&e.kind!=="stderr")return;const t=this.#e.get(e.index);t===void 0||e.text===void 0||this.onTaskOutput(t,e.text)};onTaskOutput(e,t){if(!this.#r.has(e))return;const o=((this.#t.get(e)??"")+t).split(`
48
+ `)})},h=t;return h.on("keypress",u),{close:()=>{if(h.off("keypress",u),!o)try{t.setRawMode?.(!1)}catch{}const f=t;if(typeof f.pause=="function")try{f.pause()}catch{}}}},uo=s=>{const e=s.overrides.visOptions;return e&&typeof e=="object"?e:void 0},fo=async s=>{const{initialTasks:e,probe:t,registeredEntries:r,taskGraph:c,visVersion:o}=s,i=new Map,d=new Map,u=new Map;for(const w of r)if(Qr(w.pid)){if(w.visVersion!==o){d.set(w.id,w);continue}i.set(w.id,w)}if(t){const w=[...i.values()],F=await Promise.all(w.map(async _=>{try{return[_.id,await t(_)]}catch{return[_.id,!1]}}));for(const[_,$]of F)if(!$){const N=i.get(_);i.delete(_),N&&u.set(_,N)}}const h=new Set(e.map(w=>w.id)),f=new Set,p=[],a=[],k=new Set;for(const w of Object.values(c.dependencies))for(const F of w)k.add(F);for(const[w,F]of Object.entries(c.tasks)){if(!uo(F)?.service)continue;if(i.has(w)){f.add(w),a.push(i.get(w));continue}if(h.has(w)||!k.has(w))continue;const N=d.get(w),X=u.get(w);let ae;N?ae=`Service ${w} is registered with vis ${N.visVersion}, but this invocation is vis ${o}. Restart with \`vis service restart ${w}\` to pick up the new version.`:X?ae=`Service ${w} is registered (PID ${String(X.pid)}) but failed its readiness probe — the wrapper process is alive but the underlying server is not responding. Run \`vis service restart ${w}\` to recover.`:ae=`Target depends on the service ${w}, which is not running. Run \`vis service start ${w}\` first, or invoke \`${w}\` directly.`,p.push({message:ae,targetId:w})}if(f.size===0)return{diagnostics:p,initialTasks:e,satisfiedServices:a,serviceDependentsByServiceId:new Map,serviceEnvByTaskId:new Map,taskGraph:c};const S=new Map,B=w=>{const F=new Set,_=[...c.dependencies[w]??[]],$=new Set;for(;_.length>0;){const N=_.pop();if(!$.has(N)){$.add(N),f.has(N)&&F.add(N);for(const X of c.dependencies[N]??[])$.has(X)||_.push(X)}}return[...F].sort()},q=new Map;for(const w of Object.keys(c.dependencies)){if(f.has(w))continue;const F=B(w);if(F.length===0)continue;const _={};for(const $ of F){const N=i.get($);if(!N)continue;Object.assign(_,N.env);const X=q.get($);X?X.push(w):q.set($,[w])}Object.keys(_).length>0&&S.set(w,_)}for(const w of q.values())w.sort();const b={};for(const[w,F]of Object.entries(c.tasks))f.has(w)||(b[w]=F);const T={};for(const[w,F]of Object.entries(c.dependencies))f.has(w)||(T[w]=F.filter(_=>!f.has(_)));const I=new Map;for(const w of Object.keys(b))I.set(w,0);for(const w of Object.values(T))for(const F of w)I.has(F)&&I.set(F,(I.get(F)??0)+1);const j=[];for(const w of c.roots)!f.has(w)&&b[w]&&j.push(w);for(const[w,F]of I)F===0&&!j.includes(w)&&b[w]&&j.push(w);const M=e.filter(w=>!f.has(w.id));return{diagnostics:p,initialTasks:M,satisfiedServices:a,serviceDependentsByServiceId:q,serviceEnvByTaskId:S,taskGraph:{dependencies:T,roots:j,tasks:b}}},ho=s=>s.startsWith("./")||s.startsWith("../")||s.startsWith("/")||s.startsWith("**"),po=s=>{let e=s.trim();if(e==="")return;let t=!1,r=!1,c=!1;e.startsWith("...")&&(t=!0,e=e.slice(3),e.startsWith("^")&&(c=!0,e=e.slice(1))),e.endsWith("...")&&(r=!0,e=e.slice(0,-3),e.endsWith("^")&&(c=!0,e=e.slice(0,-1)));let o;const i=/\[([^\]]*)\]$/.exec(e);i&&(o=i[1]??"",e=e.slice(0,i.index));let d=e.trim(),u=!1;return d.startsWith("{")&&d.endsWith("}")&&d.length>=2?(d=d.slice(1,-1),u=!0):ho(d)&&(u=!0),{changedSince:o,excludeSelf:c,includeDependencies:r,includeDependents:t,isPath:u,pattern:d}},vt=s=>{let e=s.replaceAll("\\","/");return e.startsWith("./")&&(e=e.slice(2)),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e},mo=(s,e,t)=>s===""?!1:gt(s,e)?!0:t!==void 0&&gt(s,t),go=(s,e)=>{if(e===void 0||e==="")return!1;const t=vt(s),r=vt(e);return gt(t,r)},wo=(s,e,t)=>{const{affected:r,downstream:c,upstream:o}=dr(s,t,{downstream:e.includeDependents?"deep":"none",upstream:e.includeDependencies?"deep":"none"});if(!e.excludeSelf)return r;const i=new Set([...c,...o]);for(const d of s)i.delete(d);return i},vo=async(s,e)=>{const{packageNameByProject:t,projectGraph:r}=e,c=Object.keys(r.nodes);let o=new Set;if(s.pattern!=="")for(const i of c)s.isPath?go(s.pattern,r.nodes[i]?.data.root)&&o.add(i):mo(s.pattern,i,t?.get(i))&&o.add(i);if(s.changedSince!==void 0){const i=s.changedSince===""?e.defaultBase??"main":s.changedSince,d=e.changedProjectsForRef??yo(e),u=new Set(await d(i));o=s.pattern===""?u:new Set([...o].filter(h=>u.has(h)))}return!s.includeDependents&&!s.includeDependencies?o:wo(o,s,r)},yo=s=>async e=>{const{projectGraph:t,workspaceRoot:r}=s;if(!r)return[];let c;try{c=await ur(r,e,"HEAD")}catch(i){const d=i instanceof Error?i.message:String(i);throw new Error(`vis run --filter: invalid changed-since ref "${e}" (${d})`,{cause:i})}const o=new Set;for(const[i,d]of Object.entries(t.nodes)){const u=vt(d.data.root??i);if(!(u===""||u==="."))for(const h of c){const f=ar(r,h).replaceAll("\\","/");if(f===u||f.startsWith(`${u}/`)){o.add(i);break}}}return[...o]},xo=async(s,e)=>{const t=new Set;for(const r of s)for(const c of await vo(r,e))t.add(c);return[...t]},jo=async(s,e)=>{const t=[];for(const r of s){const c=po(r);c&&t.push(c)}return xo(t,e)},et="[[VIS_BOOT]]",ko=250,bo=1e3,ys=3,So=s=>{try{return process.kill(s,0),!0}catch{return!1}},xs=s=>{try{const e=We(s,"utf8").trim(),t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:null}catch{return null}};class To{#e;#r;#s;#n;#t=new Map;#i=new Map;#o=new Map;#c=new Map;#a=new Set;constructor(e){this.#e=e.indexToId,this.#r=new Map(e.services),this.#s=e.sink,this.#n=e.workspaceRoot}onProcessEvent=e=>{if(e.kind!=="stdout"&&e.kind!=="stderr")return;const t=this.#e.get(e.index);t===void 0||e.text===void 0||this.onTaskOutput(t,e.text)};onTaskOutput(e,t){if(!this.#r.has(e))return;const o=((this.#t.get(e)??"")+t).split(`
49
49
  `),i=o.pop()??"";this.#t.set(e,i);for(const d of o)this.#l(e,d)}notifyRegistryStarting(e){this.#s.starting(e)}notifyRegistryStarted(e,t){this.#s.started(e,t)}onRegistryTaskStarted(e){this.#r.get(e)?.mode==="registry"&&this.notifyRegistryStarting(e)}async onRegistryTaskClosed(e,t,r){if(this.#r.get(e)?.mode!=="registry")return;if(r||t!==0){this.notifyRegistryFailed(e,"exit-code",{exitCode:t,killed:r});return}const o=await Zr(this.#n,e);if(!o){this.notifyRegistryFailed(e,"missing-registry-entry");return}const{config:i}=o,d=i.readiness?.tcp?.port??i.port??0,u=i.readiness?.tcp?.host??"127.0.0.1";this.notifyRegistryReady(e,{host:u,logFile:o.logFile,pid:o.pid,port:d})}notifyRegistryReady(e,t){this.#s.ready(e,{host:t.host,port:t.port}),this.#h(e,t.logFile),t.pid!==null&&this.#p(e,t.pid)}notifyRegistryFailed(e,t,r){this.#s.failed(e,t,r)}async retry(e){const t=this.#r.get(e);if(t){if(this.#f(e),this.#t.delete(e),this.#i.delete(e),this.#s.starting(e),t.mode==="registry"){await this.#y(e,t.registry);return}t.mode==="ephemeral"&&this.#v(e,t.ephemeral)}}async dispose(){for(const e of[...this.#o.keys(),...this.#c.keys()])this.#f(e);this.#a.size>0&&(await Promise.race([Promise.all(this.#a),new Promise(e=>{setTimeout(e,2e3)})]),this.#a.clear()),this.#t.clear(),this.#i.clear()}#l(e,t){if(t.startsWith(et)){this.#u(e,t.slice(et.length));return}const r=this.#i.get(e)??[];r.push(t),r.length>ys&&r.shift(),this.#i.set(e,r),this.#s.log(e,`${t}
50
50
  `)}#u(e,t){let r;try{r=JSON.parse(t)}catch{this.#s.log(e,`${et+t}
51
51
  `);return}switch(r.event){case"failed":{const c=typeof r.reason=="string"?r.reason:"unknown",o={};for(const[i,d]of Object.entries(r))i!=="event"&&i!=="id"&&i!=="reason"&&(o[i]=d);this.#s.failed(e,c,o);break}case"ready":{const c=typeof r.host=="string"?r.host:"127.0.0.1",o=typeof r.port=="number"?r.port:0;this.#s.ready(e,{host:c,port:o}),this.#d(e);break}case"started":{const c=typeof r.pid=="number"?r.pid:null;this.#s.started(e,c);break}default:this.#s.log(e,`${et+t}
52
- `)}}#d(e){const t=this.#r.get(e);if(t?.ephemeral===void 0)return;this.#h(e,t.ephemeral.logFile);const r=xs(t.ephemeral.pidFile);r!==null&&this.#p(e,r)}#h(e,t){if(this.#o.has(e)||!De(t))return;const r=Gr(t,"r"),c=(()=>{try{return Zt(t).size}catch{return 0}})(),o={fd:r,logFile:t,pollTimer:setInterval(()=>{this.#g(e)},ko),position:c};this.#o.set(e,o)}#g(e){const t=this.#o.get(e);if(t)try{const r=Zt(t.logFile);if(r.size<=t.position)return;const c=Buffer.alloc(r.size-t.position),o=Wr(t.fd,c,0,c.length,t.position);if(o>0){t.position+=o;const i=c.subarray(0,o).toString("utf8");for(const d of i.split(`
53
- `))d.length!==0&&this.#w(e,d);this.#s.log(e,i)}}catch{}}#w(e,t){const r=this.#i.get(e)??[];for(r.push(t);r.length>ys;)r.shift();this.#i.set(e,r)}#p(e,t){if(this.#c.has(e))return;const r={pid:t,timer:setInterval(()=>{if(!So(t)){const c=[...this.#i.get(e)??[]];this.#f(e),this.#s.crashed(e,c)}},bo)};this.#c.set(e,r)}#f(e){const t=this.#o.get(e);if(t){clearInterval(t.pollTimer);try{Hr(t.fd)}catch{}this.#o.delete(e)}const r=this.#c.get(e);r&&(clearInterval(r.timer),this.#c.delete(e))}#v(e,t){if(t===void 0)return;const r=xs(t.pidFile);if(r!==null)try{process.kill(-r,"SIGTERM")}catch{}const c=Gn("node",[t.scriptPath,t.configFile],{cwd:t.cwd,stdio:["ignore","pipe","pipe"]});c.stdout.on("data",i=>{this.#m(e,i)}),c.stderr.on("data",i=>{this.#m(e,i)}),c.on("error",i=>{this.#s.failed(e,"respawn-error",{message:i.message})});const o=new Promise(i=>{const d=()=>{this.#a.delete(o),i()};c.once("exit",d),c.once("error",d)});this.#a.add(o)}#m(e,t){const o=((this.#t.get(e)??"")+t.toString("utf8")).split(`
52
+ `)}}#d(e){const t=this.#r.get(e);if(t?.ephemeral===void 0)return;this.#h(e,t.ephemeral.logFile);const r=xs(t.ephemeral.pidFile);r!==null&&this.#p(e,r)}#h(e,t){if(this.#o.has(e)||!De(t))return;const r=Hr(t,"r"),c=(()=>{try{return Zt(t).size}catch{return 0}})(),o={fd:r,logFile:t,pollTimer:setInterval(()=>{this.#g(e)},ko),position:c};this.#o.set(e,o)}#g(e){const t=this.#o.get(e);if(t)try{const r=Zt(t.logFile);if(r.size<=t.position)return;const c=Buffer.alloc(r.size-t.position),o=qr(t.fd,c,0,c.length,t.position);if(o>0){t.position+=o;const i=c.subarray(0,o).toString("utf8");for(const d of i.split(`
53
+ `))d.length!==0&&this.#w(e,d);this.#s.log(e,i)}}catch{}}#w(e,t){const r=this.#i.get(e)??[];for(r.push(t);r.length>ys;)r.shift();this.#i.set(e,r)}#p(e,t){if(this.#c.has(e))return;const r={pid:t,timer:setInterval(()=>{if(!So(t)){const c=[...this.#i.get(e)??[]];this.#f(e),this.#s.crashed(e,c)}},bo)};this.#c.set(e,r)}#f(e){const t=this.#o.get(e);if(t){clearInterval(t.pollTimer);try{Vr(t.fd)}catch{}this.#o.delete(e)}const r=this.#c.get(e);r&&(clearInterval(r.timer),this.#c.delete(e))}#v(e,t){if(t===void 0)return;const r=xs(t.pidFile);if(r!==null)try{process.kill(-r,"SIGTERM")}catch{}const c=Gn("node",[t.scriptPath,t.configFile],{cwd:t.cwd,stdio:["ignore","pipe","pipe"]});c.stdout.on("data",i=>{this.#m(e,i)}),c.stderr.on("data",i=>{this.#m(e,i)}),c.on("error",i=>{this.#s.failed(e,"respawn-error",{message:i.message})});const o=new Promise(i=>{const d=()=>{this.#a.delete(o),i()};c.once("exit",d),c.once("error",d)});this.#a.add(o)}#m(e,t){const o=((this.#t.get(e)??"")+t.toString("utf8")).split(`
54
54
  `),i=o.pop()??"";this.#t.set(e,i);for(const d of o)this.#l(e,d)}async#y(e,t){if(t!==void 0){try{await en({id:e,workspaceRoot:this.#n})}catch{}try{const r=await tn({command:t.command,config:t.config,cwd:t.cwd,env:t.env,id:e,workspaceRoot:this.#n}),c=t.config.readiness?.tcp?.port??t.config.port??0,o=t.config.readiness?.tcp?.host??"127.0.0.1";this.#s.started(e,r.entry.pid),this.notifyRegistryReady(e,{host:o,logFile:r.entry.logFile,pid:r.entry.pid,port:c})}catch(r){const c=r instanceof Error?r.message:String(r);this.#s.failed(e,"retry-failed",{message:c})}}}}const $o=s=>{const e=s.overrides.visOptions;return e&&typeof e=="object"?e:void 0},Vs=(s,e,t)=>{const r=[],c=[];for(const o of e){const i=t.tasks[o];if(!i){c.push({id:o,reason:"task not in graph"});continue}const d=i.overrides.command;if(!d){c.push({id:o,reason:"no command resolved"});continue}const u=$o(i);if(!u?.service){c.push({id:o,reason:"no service config"});continue}const h=at(s,i.projectRoot,!!u.runFromWorkspaceRoot),{envFile:f}=u,p=f===void 0||f===!1?{}:jt(h,f),a=u.service.env??{};r.push({command:d,config:u.service,cwd:h,env:{...p,...a},id:o})}return{services:r,skipped:c}},Io=(s,e)=>{const t=new Set(s),r=new Map;for(const i of s){const d=(e.dependencies[i]??[]).filter(u=>t.has(u));r.set(i,new Set(d))}const c=[],o=new Set;for(;r.size>0;){const i=[];for(const[d,u]of r){for(const h of u)o.has(h)&&u.delete(h);u.size===0&&i.push(d)}i.length===0&&i.push(...r.keys());for(const d of i)o.add(d),r.delete(d);i.sort(),c.push({ids:i})}return c},Co=(s,e)=>{const t=[];for(const r of Io(s,e))t.push(...r.ids);return t},Eo=String.raw`import { spawn } from "node:child_process";
55
55
  import { closeSync, openSync, readFileSync, readSync, statSync, writeFileSync } from "node:fs";
56
56
  import { createConnection } from "node:net";
@@ -165,25 +165,25 @@ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
165
165
  try { process.kill(-child.pid, "SIGTERM"); } catch {}
166
166
  process.exit(1);
167
167
  })();
168
- `,Ro=()=>{const s=qr(ce(Bn(),"vis-services-")),e=ce(s,"bootstrap.mjs");return Ms(e,Eo),{runDir:s,scriptPath:e}},Us=(s,e,t)=>{const r=t.replaceAll(/[^\w-]/g,"_");return{configFile:ce(s,`${r}.json`),logFile:ce(s,`${r}.log`),pidFile:ce(s,`${r}.pid`),scriptPath:e}},Po=s=>{const{paths:e,service:t}=s,r=t.config.readiness?.tcp?.port??t.config.port;if(typeof r!="number")throw new TypeError(`Service ${t.id} has no TCP readiness port — declare \`service.port\` or \`service.readiness.tcp.port\`.`);const c={...t.env,PATH:dr(t.cwd,t.env)};return{command:t.command,cwd:t.cwd,env:c,host:t.config.readiness?.tcp?.host??"127.0.0.1",id:t.id,logFile:e.logFile,pidFile:e.pidFile,port:r,timeoutMs:t.config.readiness?.tcp?.timeoutMs??3e4}},Mo=s=>`node ${JSON.stringify(s.scriptPath)} ${JSON.stringify(s.configFile)}`,Fo=s=>{const{id:e,visBin:t,workspaceRoot:r}=s;return`node ${JSON.stringify(t)} service start ${JSON.stringify(e)} --cwd ${JSON.stringify(r)}`},Oo=s=>{const{missingServiceIds:e,mode:t,taskGraph:r,visBin:c,workspaceRoot:o}=s,{services:i,skipped:d}=Vs(o,e,r);if(i.length===0)return{chain:[],ephemeralPidFiles:[],runDir:void 0,serviceEnvByTaskId:new Map,skipped:d};const u=Co(i.map(b=>b.id),r),h=new Map(i.map(b=>[b.id,b])),f=[],p=[];if(t==="ephemeral")for(const b of u){const T=h.get(b);T&&p.push({id:b,payload:Po({paths:{logFile:"",pidFile:""},service:T})})}let a;t==="ephemeral"&&(a=Ro());let k;for(const b of u){const T=h.get(b),I=r.tasks[b];if(!T||!I)continue;let j;if(t==="ephemeral"){const M=Us(a.runDir,a.scriptPath,b),F={...p.find(_=>_.id===b).payload,logFile:M.logFile,pidFile:M.pidFile};Ms(M.configFile,JSON.stringify(F)),j=Mo(M),f.push(M.pidFile)}else j=Fo({id:b,visBin:c,workspaceRoot:o});if(I.overrides={...I.overrides,command:j},I.cache=!1,r.tasks[b]=I,k!==void 0){const M=r.dependencies[b]??[];M.includes(k)||(r.dependencies[b]=[...M,k])}k=b}const S=new Set(u),B=new Map,q=b=>{const T=new Set,I=[...r.dependencies[b]??[]],j=new Set;for(;I.length>0;){const M=I.pop();if(!j.has(M)){j.add(M),S.has(M)&&T.add(M);for(const w of r.dependencies[M]??[])j.has(w)||I.push(w)}}return[...T].sort()};for(const b of Object.keys(r.dependencies)){if(S.has(b))continue;const T=q(b);if(T.length===0)continue;const I={};for(const j of T){const M=h.get(j);M?.config.env&&Object.assign(I,M.config.env)}Object.keys(I).length>0&&B.set(b,I)}return{chain:u,ephemeralPidFiles:f,runDir:a?.runDir,serviceEnvByTaskId:B,skipped:d}},Ao=new Set(["auto","ephemeral","off","persistent"]),Lo=s=>s.cli!==void 0?"cli":s.config===void 0?"default":"config",Do=s=>{const{cli:e,config:t,isCi:r,isPersistentTarget:c,isTty:o,target:i}=s;if(e!==void 0&&!Ao.has(e))throw new Error(`--services: expected one of auto|ephemeral|persistent|off, got "${e}"`);const d=e??t??(o&&!r?"auto":"off");return d==="off"?"off":d==="ephemeral"?"ephemeral":d==="persistent"?"registry":c||i==="dev"?"ephemeral":"registry"},zs=s=>s.replace(/^--?/u,""),Bo=new Set(["0","1","false","no","true","yes"]),_o=s=>!s.startsWith("-")||/^-(?:\d|\.\d)/u.test(s),js=(s,e,t,r,c,o)=>{if(r!==void 0)return s.set(e,r),0;const i=c[o+1];return(t?.type??"string")==="boolean"?i!==void 0&&Bo.has(i.toLowerCase())?(s.set(e,i.toLowerCase()),1):(s.set(e,"true"),0):i!==void 0&&_o(i)?(s.set(e,i),1):(s.set(e,"true"),0)},No=(s,e)=>{const t=s.type??"string";if(t==="number"){const r=e.trim(),c=Number(r);return r===""||!Number.isFinite(c)?{error:`--${s.name} expects a number, got "${e}"`}:{value:c}}if(t==="boolean")return["1","true","yes"].includes(e.toLowerCase())?{value:!0}:["0","false","no"].includes(e.toLowerCase())?{value:!1}:{error:`--${s.name} expects a boolean, got "${e}"`};if(t==="enum"){const r=s.choices??[];return r.includes(e)?{value:e}:{error:`--${s.name} must be one of [${r.join(", ")}], got "${e}"`}}return{value:e}},Go=s=>{const e=[],t=new Set;for(const r of s){const c=r.name||"<unnamed>";(!r.name||!/^[a-zA-Z][\w-]*$/u.test(r.name))&&e.push(`argument name "${c}" is empty or invalid (start with a letter; use letters, digits, '-', '_')`),t.has(r.name)&&e.push(`duplicate argument name "${c}"`),t.add(r.name),r.alias!==void 0&&r.alias.length!==1&&e.push(`argument "${c}" alias "${r.alias}" must be a single character`);const o=r.type??"string";if(o==="enum"&&(r.choices===void 0||r.choices.length===0)&&e.push(`argument "${c}" has type "enum" but declares no choices`),r.default!==void 0){const i=typeof r.default;o==="number"&&i==="number"||o==="boolean"&&i==="boolean"||(o==="string"||o==="enum")&&i==="string"?o==="enum"&&r.choices&&!r.choices.includes(r.default)&&e.push(`argument "${c}" default "${String(r.default)}" is not one of its choices`):e.push(`argument "${c}" default ${JSON.stringify(r.default)} does not match type "${o}"`)}}return e},Wo=(s,e)=>{const t=new Map,r=new Map;for(const h of s)t.set(h.name,h),h.alias&&r.set(h.alias,h);const c=new Map,o=[];for(let h=0;h<e.length;h+=1){const f=e[h];if(f==="--"){o.push(...e.slice(h+1));break}if(f.startsWith("--no-")){c.set(zs(f.slice(5)),"false");continue}const p=/^--([^=]+)(?:=(.*))?$/su.exec(f);if(p){const S=p[1];h+=js(c,S,t.get(S),p[2],e,h);continue}const a=/^-([^=-])(?:=(.*))?$/su.exec(f),k=a?.[1];if(a&&k!==void 0){const S=r.get(k);h+=js(c,S?.name??k,S,a[2],e,h);continue}o.push(f)}const i={},d=[];let u=0;for(const h of s){let f=c.get(h.name);if(f===void 0&&h.positional&&u<o.length&&(f=o[u],u+=1),f===void 0){h.default!==void 0?i[h.name]=h.default:h.required&&d.push(`missing required argument --${h.name}`);continue}const{error:p,value:a}=No(h,f);p?d.push(p):a!==void 0&&(i[h.name]=a)}return{errors:d,values:i}},Ho=s=>`VIS_ARG_${zs(s).replaceAll(/[^a-zA-Z0-9]+/gu,"_").toUpperCase()}`,qo=s=>{const e={};for(const[t,r]of Object.entries(s))e[Ho(t)]=String(r);return e},mt=(s,e,t)=>{const r=[`Usage: vis run ${s} [-- <args>]`];if(e&&r.push("",e),t.length===0)return r.join(`
168
+ `,Ro=()=>{const s=Ur(ce(Bn(),"vis-services-")),e=ce(s,"bootstrap.mjs");return Ms(e,Eo),{runDir:s,scriptPath:e}},Us=(s,e,t)=>{const r=t.replaceAll(/[^\w-]/g,"_");return{configFile:ce(s,`${r}.json`),logFile:ce(s,`${r}.log`),pidFile:ce(s,`${r}.pid`),scriptPath:e}},Po=s=>{const{paths:e,service:t}=s,r=t.config.readiness?.tcp?.port??t.config.port;if(typeof r!="number")throw new TypeError(`Service ${t.id} has no TCP readiness port — declare \`service.port\` or \`service.readiness.tcp.port\`.`);const c={...t.env,PATH:fr(t.cwd,t.env)};return{command:t.command,cwd:t.cwd,env:c,host:t.config.readiness?.tcp?.host??"127.0.0.1",id:t.id,logFile:e.logFile,pidFile:e.pidFile,port:r,timeoutMs:t.config.readiness?.tcp?.timeoutMs??3e4}},Mo=s=>`node ${JSON.stringify(s.scriptPath)} ${JSON.stringify(s.configFile)}`,Fo=s=>{const{id:e,visBin:t,workspaceRoot:r}=s;return`node ${JSON.stringify(t)} service start ${JSON.stringify(e)} --cwd ${JSON.stringify(r)}`},Oo=s=>{const{missingServiceIds:e,mode:t,taskGraph:r,visBin:c,workspaceRoot:o}=s,{services:i,skipped:d}=Vs(o,e,r);if(i.length===0)return{chain:[],ephemeralPidFiles:[],runDir:void 0,serviceEnvByTaskId:new Map,skipped:d};const u=Co(i.map(b=>b.id),r),h=new Map(i.map(b=>[b.id,b])),f=[],p=[];if(t==="ephemeral")for(const b of u){const T=h.get(b);T&&p.push({id:b,payload:Po({paths:{logFile:"",pidFile:""},service:T})})}let a;t==="ephemeral"&&(a=Ro());let k;for(const b of u){const T=h.get(b),I=r.tasks[b];if(!T||!I)continue;let j;if(t==="ephemeral"){const M=Us(a.runDir,a.scriptPath,b),F={...p.find(_=>_.id===b).payload,logFile:M.logFile,pidFile:M.pidFile};Ms(M.configFile,JSON.stringify(F)),j=Mo(M),f.push(M.pidFile)}else j=Fo({id:b,visBin:c,workspaceRoot:o});if(I.overrides={...I.overrides,command:j},I.cache=!1,r.tasks[b]=I,k!==void 0){const M=r.dependencies[b]??[];M.includes(k)||(r.dependencies[b]=[...M,k])}k=b}const S=new Set(u),B=new Map,q=b=>{const T=new Set,I=[...r.dependencies[b]??[]],j=new Set;for(;I.length>0;){const M=I.pop();if(!j.has(M)){j.add(M),S.has(M)&&T.add(M);for(const w of r.dependencies[M]??[])j.has(w)||I.push(w)}}return[...T].sort()};for(const b of Object.keys(r.dependencies)){if(S.has(b))continue;const T=q(b);if(T.length===0)continue;const I={};for(const j of T){const M=h.get(j);M?.config.env&&Object.assign(I,M.config.env)}Object.keys(I).length>0&&B.set(b,I)}return{chain:u,ephemeralPidFiles:f,runDir:a?.runDir,serviceEnvByTaskId:B,skipped:d}},Ao=new Set(["auto","ephemeral","off","persistent"]),Lo=s=>s.cli!==void 0?"cli":s.config===void 0?"default":"config",Do=s=>{const{cli:e,config:t,isCi:r,isPersistentTarget:c,isTty:o,target:i}=s;if(e!==void 0&&!Ao.has(e))throw new Error(`--services: expected one of auto|ephemeral|persistent|off, got "${e}"`);const d=e??t??(o&&!r?"auto":"off");return d==="off"?"off":d==="ephemeral"?"ephemeral":d==="persistent"?"registry":c||i==="dev"?"ephemeral":"registry"},zs=s=>s.replace(/^--?/u,""),Bo=new Set(["0","1","false","no","true","yes"]),_o=s=>!s.startsWith("-")||/^-(?:\d|\.\d)/u.test(s),js=(s,e,t,r,c,o)=>{if(r!==void 0)return s.set(e,r),0;const i=c[o+1];return(t?.type??"string")==="boolean"?i!==void 0&&Bo.has(i.toLowerCase())?(s.set(e,i.toLowerCase()),1):(s.set(e,"true"),0):i!==void 0&&_o(i)?(s.set(e,i),1):(s.set(e,"true"),0)},No=(s,e)=>{const t=s.type??"string";if(t==="number"){const r=e.trim(),c=Number(r);return r===""||!Number.isFinite(c)?{error:`--${s.name} expects a number, got "${e}"`}:{value:c}}if(t==="boolean")return["1","true","yes"].includes(e.toLowerCase())?{value:!0}:["0","false","no"].includes(e.toLowerCase())?{value:!1}:{error:`--${s.name} expects a boolean, got "${e}"`};if(t==="enum"){const r=s.choices??[];return r.includes(e)?{value:e}:{error:`--${s.name} must be one of [${r.join(", ")}], got "${e}"`}}return{value:e}},Go=s=>{const e=[],t=new Set;for(const r of s){const c=r.name||"<unnamed>";(!r.name||!/^[a-zA-Z][\w-]*$/u.test(r.name))&&e.push(`argument name "${c}" is empty or invalid (start with a letter; use letters, digits, '-', '_')`),t.has(r.name)&&e.push(`duplicate argument name "${c}"`),t.add(r.name),r.alias!==void 0&&r.alias.length!==1&&e.push(`argument "${c}" alias "${r.alias}" must be a single character`);const o=r.type??"string";if(o==="enum"&&(r.choices===void 0||r.choices.length===0)&&e.push(`argument "${c}" has type "enum" but declares no choices`),r.default!==void 0){const i=typeof r.default;o==="number"&&i==="number"||o==="boolean"&&i==="boolean"||(o==="string"||o==="enum")&&i==="string"?o==="enum"&&r.choices&&!r.choices.includes(r.default)&&e.push(`argument "${c}" default "${String(r.default)}" is not one of its choices`):e.push(`argument "${c}" default ${JSON.stringify(r.default)} does not match type "${o}"`)}}return e},Wo=(s,e)=>{const t=new Map,r=new Map;for(const h of s)t.set(h.name,h),h.alias&&r.set(h.alias,h);const c=new Map,o=[];for(let h=0;h<e.length;h+=1){const f=e[h];if(f==="--"){o.push(...e.slice(h+1));break}if(f.startsWith("--no-")){c.set(zs(f.slice(5)),"false");continue}const p=/^--([^=]+)(?:=(.*))?$/su.exec(f);if(p){const S=p[1];h+=js(c,S,t.get(S),p[2],e,h);continue}const a=/^-([^=-])(?:=(.*))?$/su.exec(f),k=a?.[1];if(a&&k!==void 0){const S=r.get(k);h+=js(c,S?.name??k,S,a[2],e,h);continue}o.push(f)}const i={},d=[];let u=0;for(const h of s){let f=c.get(h.name);if(f===void 0&&h.positional&&u<o.length&&(f=o[u],u+=1),f===void 0){h.default!==void 0?i[h.name]=h.default:h.required&&d.push(`missing required argument --${h.name}`);continue}const{error:p,value:a}=No(h,f);p?d.push(p):a!==void 0&&(i[h.name]=a)}return{errors:d,values:i}},Ho=s=>`VIS_ARG_${zs(s).replaceAll(/[^a-zA-Z0-9]+/gu,"_").toUpperCase()}`,qo=s=>{const e={};for(const[t,r]of Object.entries(s))e[Ho(t)]=String(r);return e},mt=(s,e,t)=>{const r=[`Usage: vis run ${s} [-- <args>]`];if(e&&r.push("",e),t.length===0)return r.join(`
169
169
  `);r.push("","Arguments:");const c=t.map(i=>{const d=i.positional?`<${i.name}>`:`--${i.name}`,u=i.alias?`, -${i.alias}`:"";return{left:`${d}${u}`,right:i}}),o=Math.max(...c.map(i=>i.left.length));for(const{left:i,right:d}of c){const u=[],h=d.type??"string";u.push(h==="enum"?`enum(${(d.choices??[]).join("|")})`:h),d.required&&u.push("required"),d.default!==void 0&&u.push(`default: ${String(d.default)}`);const f=`${d.description??""}${d.description?" ":""}[${u.join(", ")}]`;r.push(` ${i.padEnd(o)} ${f}`)}return r.join(`
170
170
  `)},Vo=(s,e,t,r)=>{if(!t||t.length===0)return{env:{},kind:"ok"};const c=Go(t);if(c.length>0)return{errors:c.map(i=>`invalid \`arguments\` schema for "${s}": ${i}`),help:mt(s,e,t),kind:"invalid"};if(r.includes("--help")||r.includes("-h"))return{kind:"help",text:mt(s,e,t)};const o=Wo(t,r);return o.errors.length>0?{errors:o.errors,help:mt(s,e,t),kind:"invalid"}:{env:qo(o.values),kind:"ok"}},$t="VIS_AFFECTED_FILES",Uo=2e3,ks=async(s,e,t,r,c,o)=>{const i=s.map(j=>{const M=j.overrides.command;if(!M)return;const w=j.overrides.visOptions,F=at(e,j.projectRoot,!!w?.runFromWorkspaceRoot),_=w?.envFile?jt(F,w.envFile):{},$=t&&(w?.affectedFiles==="env"||w?.affectedFiles==="both")?{[$t]:t.join(`
171
171
  `)}:{},N=o?.get(j.id)??{},X=ui({interactive:!!c,taskPty:j.pty,workspacePty:w?.pty});return{command:M,cwd:F,env:{INIT_CWD:r,..._,...N,...$,...j.overrides[Ct]},name:j.id,...X?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}}).filter(j=>j!==void 0);if(i.length===0)return;if(!c){await tt(i,{killOthers:["failure"],onEvent:()=>{}});return}const{abortSignal:d,lifeCycle:u,stdinRegistry:h,store:f}=c,p=i.map(j=>s.find(M=>M.id===j.name)).filter(Boolean),a=j=>i[j]?.stdin==="pty",k=new Map,S=j=>{if(!a(j))return;let M=k.get(j);return M||(M=new yt(ct),k.set(j,M)),M};f.unmarkDone(),u.startTasks?.(p);const B=new Map,q=new Map;let b;const T=()=>{for(const j of q.values())try{j("SIGTERM")}catch{}b||(b=setTimeout(()=>{for(const j of q.values())try{j("SIGKILL")}catch{}q.clear()},2e3),b.unref?.())};let I;d&&(I=()=>{T()},d.then(()=>{I?.()}).catch(()=>{I?.()}));try{await tt(i,{killOthers:["failure"],onEvent:j=>{const M=p[j.index];if(M)switch(j.kind){case"close":{const w=B.get(M.id)??Date.now(),F=j.killed||j.exitCode===0?"success":"failure";u.endTasks?.([{code:j.exitCode??0,endTime:Date.now(),startTime:w,status:F,task:M,terminalOutput:f.getSnapshot().outputs.get(M.id)??""}]),q.delete(j.index),h?.delete(M.id);break}case"error":{if(j.message){const w=S(j.index);w?(w.write(`${j.message}
172
172
  `),f.setOutput(M.id,w.toString())):f.addOutput(M.id,`${j.message}
173
173
  `)}break}case"started":{B.set(M.id,Date.now()),j.kill&&q.set(j.index,j.kill),j.write&&h&&h.set(M.id,{kill:j.kill,resize:j.resize,write:j.write});break}case"stderr":case"stdout":{if(j.text){const w=S(j.index);w?(w.write(j.text),f.setOutput(M.id,w.toString())):f.addOutput(M.id,`${j.text}
174
- `)}break}default:}}})}finally{b&&(clearTimeout(b),b=void 0),f.markDone()}},bs=s=>{try{return process.kill(-s,0),!0}catch{try{return process.kill(s,0),!0}catch{return!1}}},zo=s=>{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,s)},Yo=s=>{const{extraPids:e=[],pidFiles:t,runDir:r}=s,c=[],o=i=>{try{process.kill(-i,"SIGTERM")}catch{try{process.kill(i,"SIGTERM")}catch{}}};for(const i of t){let d;try{const u=cr(i),h=Number.parseInt(u.trim(),10);d=Number.isFinite(h)&&h>0?h:void 0}catch{continue}d!==void 0&&(c.push(d),o(d))}for(const i of e)!Number.isFinite(i)||i<=0||(c.push(i),o(i));if(c.length>0){const u=Date.now()+1500;for(;Date.now()<u;){let h=!0;for(const f of c)if(bs(f)){h=!1;break}if(h)break;zo(100)}for(const h of c)if(bs(h))try{process.kill(-h,"SIGKILL")}catch{try{process.kill(h,"SIGKILL")}catch{}}}r&&Dr(r)},ct=256*1024;class Ko{#e;#r="";#s=!1;constructor(e){this.#e=e}append(e){this.#r+=e,this.#r.length>this.#e&&(this.#r=this.#r.slice(-this.#e),this.#s=!0)}toString(){return this.#s?`[...output truncated, showing last ${Math.round(this.#e/1024)}KB...]
174
+ `)}break}default:}}})}finally{b&&(clearTimeout(b),b=void 0),f.markDone()}},bs=s=>{try{return process.kill(-s,0),!0}catch{try{return process.kill(s,0),!0}catch{return!1}}},zo=s=>{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,s)},Yo=s=>{const{extraPids:e=[],pidFiles:t,runDir:r}=s,c=[],o=i=>{try{process.kill(-i,"SIGTERM")}catch{try{process.kill(i,"SIGTERM")}catch{}}};for(const i of t){let d;try{const u=lr(i),h=Number.parseInt(u.trim(),10);d=Number.isFinite(h)&&h>0?h:void 0}catch{continue}d!==void 0&&(c.push(d),o(d))}for(const i of e)!Number.isFinite(i)||i<=0||(c.push(i),o(i));if(c.length>0){const u=Date.now()+1500;for(;Date.now()<u;){let h=!0;for(const f of c)if(bs(f)){h=!1;break}if(h)break;zo(100)}for(const h of c)if(bs(h))try{process.kill(-h,"SIGKILL")}catch{try{process.kill(h,"SIGKILL")}catch{}}}r&&_r(r)},ct=256*1024;class Ko{#e;#r="";#s=!1;constructor(e){this.#e=e}append(e){this.#r+=e,this.#r.length>this.#e&&(this.#r=this.#r.slice(-this.#e),this.#s=!0)}toString(){return this.#s?`[...output truncated, showing last ${Math.round(this.#e/1024)}KB...]
175
175
  ${this.#r}`:this.#r}}const Ys=s=>{const e=s.overrides.visOptions;if(e&&typeof e=="object")return e},Xo=s=>`'${s.replaceAll("'",String.raw`'\''`)}'`,It=s=>process.platform==="win32"?s.length>0&&!/[\s"&|<>^()%!]/.test(s)?s:`"${s.replaceAll('"','""')}"`:Xo(s),Jo=(s,e,t)=>{if(!e||e.length===0||t===!1||t===void 0)return s;if(t==="args"||t==="both"){const r=e.map(c=>It(c)).join(" ");return`${s} ${r}`}return s},Ks="visForwardedArgs",Ct="visTaskArgEnv",Qo=(s,e)=>{const t=e.overrides[Ks];if(!Array.isArray(t)||t.length===0)return s;const r=t.map(c=>It(c)).join(" ");return`${s} ${r}`},Zo=async(s,e,t)=>{if(!e)return t();const r=s.get(e)??Promise.resolve();let c;const o=new Promise(d=>{c=d}),i=r.then(()=>o);s.set(e,i),await r;try{return await t()}finally{c(),s.get(e)===i&&s.delete(e)}},ec=s=>{let e=Math.max(0,Math.floor(s));return{claim(t){const r=Math.max(0,Math.min(t,e));return e-=r,r},get remaining(){return e}}},tc=(s,e,t)=>{const r=`${e}\0${typeof t=="string"?t:String(t)}`,c=s.get(r);if(c)return c;const o=jt(e,t);return s.set(r,o),o},Ss=s=>{const e=new Map;return async(t,r)=>{const{affectedFiles:c,currentOs:o,hooks:i,initCwd:d,lifeCycle:u,mutexPool:h,onOutput:f,onOutputReplace:p,retryBudget:a,serviceEnvByTaskId:k,serviceEventBridge:S,stdinRegistry:B,strictEnv:q,taskSlots:b,workspaceRoot:T}=s,I=Ys(t),j=at(T,r.cwd??t.projectRoot,I?.runFromWorkspaceRoot===!0),M=t.overrides.command;if(!M)return{code:0,terminalOutput:`No command configured for ${t.target.project}:${t.target.target}`};const w=Qo(M,t),F=Jo(w,c,I?.affectedFiles),_=bn(I,o),$=I?.shellArgs,N=$&&$.length>0?$.join(" "):"-c",X=_?`${_} ${N} ${It(F)}`:F,ae=I?.envFile?tc(e,j,I.envFile):void 0,Q={};c&&c.length>0&&(I?.affectedFiles==="env"||I?.affectedFiles==="both")&&(Q[$t]=c.join(`
176
176
  `));const K=k?.get(t.id),se={INIT_CWD:d,VIS_TASK_SLOTS:String(b),...ae,...K,...r.env,...Q,...t.overrides[Ct]};if(I?.strictEnv??q??!1){const P=wi({command:F,processEnv:process.env,taskEnv:se,taskId:t.id});if(P){const ge=vi(P);return u?.onTaskStderr?.(t,ge),{code:1,terminalOutput:ge}}}const de=I?.pty===!0,ie=!!B,we=t.pty===!0?!0:t.pty===!1?!1:ie||de;we&&(t.cache=!1);const H=we?void 0:new Ko(ct),G=we?new yt(ct):void 0;let Z;const me=P=>{if(P.kind==="started"&&(Z=P.kill,P.write&&B&&B.set(t.id,{kill:P.kill,resize:P.resize,write:P.write}),S?.onRegistryTaskStarted(t.id)),(P.kind==="stdout"||P.kind==="stderr")&&P.text!==void 0)if(P.kind==="stdout"?u?.onTaskStdout?.(t,P.text):u?.onTaskStderr?.(t,P.text),G)G.write(P.text),ie&&p?.(t.id,G.toString()),S&&S.onTaskOutput(t.id,P.text);else{const ge=`${P.text}
177
177
  `;H.append(ge),f?.(t.id,ge)}P.kind==="close"&&(B&&B.delete(t.id),S&&S.onRegistryTaskClosed(t.id,P.exitCode??0,!!P.killed).catch(()=>{}))},ke=async()=>{const P=I?.retryCount??0,ge=I?.retryDelay,Ee=a?a.claim(P):P,Fe=typeof I?.timeout=="number"&&I.timeout>0?I.timeout:0,_e=typeof I?.killGracePeriodMs=="number"&&I.killGracePeriodMs>=0?I.killGracePeriodMs:5e3;let Oe=!1,te=0;const Ae=no({killGracePeriodMs:_e,onTimeout:()=>{Oe=!0},sendSignal:xe=>{Z?.(xe)},timeoutMs:Fe});let ve;try{ve=await tt([{command:X,cwd:j,env:se,name:t.id,...we?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}],{killOthers:["failure"],onEvent:me,...Ee>0?{restart:{delay:ge??"exponential",onRetry:async(xe,$e,C)=>{te=xe,i&&await i.callHook("task:retry",t,xe,C)},tries:Ee}}:{}})}finally{Ae.cancel()}const he=ve.closeEvents[0],ye=G?G.toString():H.toString();return Oe?{code:124,retryAttempts:te,terminalOutput:`${ye}
178
178
  [timeout] Task "${t.id}" exceeded ${Fe}ms budget.
179
- `}:{code:he?.exitCode??1,retryAttempts:te,terminalOutput:ye}};return h?Zo(h,I?.mutex,ke):ke()}},sc=s=>{if(!s||s.trim().length===0)return;const e=Number.parseFloat(s);return!Number.isFinite(e)||e<=0?{invalid:s}:{value:Math.floor(e)}},rc=async(s,e)=>{const t=await yr(s,{dataDirectory:st(s)});if(!t){e.warn(`No previous run recorded yet. Run a task at least once to populate ${xr(s,{dataDirectory:st(s)})}.`);return}const r=(t.duration/1e3).toFixed(2);if(e.info(""),e.info(`Last run — ${t.startTime} (${r}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 o=t.tasks.filter(i=>i.exitCode!==void 0&&i.exitCode!==0);e.info("Failed tasks:");for(const i of o){const d=i.duration??0;e.info(` × ${i.taskId} (exit ${String(i.exitCode??-1)}, ${d}ms)`)}e.info("")}const c=[...t.tasks].filter(o=>typeof o.duration=="number").sort((o,i)=>(i.duration??0)-(o.duration??0)).slice(0,5);if(c.length>0){e.info("Slowest tasks:");for(const o of c)e.info(` ${o.taskId.padEnd(40)} ${String(o.duration??0).padStart(6)}ms [${o.cacheStatus}]`);e.info("")}},nc=s=>{if(!(s===void 0||s==="")){if(s!=="read"&&s!=="write"&&s!=="readwrite")throw new Error(`--cache-mode must be one of: read, write, readwrite (received "${s}")`);return s}},ic=s=>{if(!(s===void 0||s==="")){if(s!=="http"&&s!=="reapi")throw new Error(`--cache-backend must be one of: http, reapi (received "${s}")`);return s}},oc=s=>{if(!(s===void 0||s==="")){if(s!=="declared"&&s!=="trace")throw new Error(`--hash-mode must be one of: declared, trace (received "${s}")`);return s}},Oc=async({argument:s,logger:e,options:t,visConfig:r,workspaceRoot:c})=>{if(!c)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const o=c;if(Xr({logger:e,options:t,visConfig:r},o),_n(o),t.lastDetails){await rc(o,e);return}const i=process.cwd(),d=await Or(o),{config:u,fileOwners:h,packageJsons:f,projectOptions:p,workspace:a}=Ar(o,r,d),k=Lr(o,a,f);let S=s[0];if(!S){const m=es(a);if(process.stdout.isTTY&&process.stdin.isTTY){const v=await dn(m);if(!v){e.info("No target selected.");return}S=v,await Zi(`vis run ${v}`)}else throw e.info("Available targets:"),e.info(""),e.info(un(m)),e.info(""),new Ke("Missing target. Usage: vis run <target>")}if(u.constraints&&!t.skipConstraints){const m=ur(k,u.constraints);if(m.length>0){for(const v of m)e.error(`[${v.rule}] ${v.message}`);throw new Error(`${m.length} project constraint violation(s) found. Use --skip-constraints to bypass.`)}}if(!t.affected){const m=t.uncommitted?"--uncommitted":"--no-uncommitted",v=[["--base",t.base],["--head",t.head],["--downstream",t.downstream],["--upstream",t.upstream],[m,t.uncommitted]].filter(([,y])=>y!==void 0).map(([y])=>y);if(v.length>0)throw new Ke(`${v.join(", ")} ${v.length===1?"requires":"require"} --affected.
179
+ `}:{code:he?.exitCode??1,retryAttempts:te,terminalOutput:ye}};return h?Zo(h,I?.mutex,ke):ke()}},sc=s=>{if(!s||s.trim().length===0)return;const e=Number.parseFloat(s);return!Number.isFinite(e)||e<=0?{invalid:s}:{value:Math.floor(e)}},rc=async(s,e)=>{const t=await jr(s,{dataDirectory:st(s)});if(!t){e.warn(`No previous run recorded yet. Run a task at least once to populate ${kr(s,{dataDirectory:st(s)})}.`);return}const r=(t.duration/1e3).toFixed(2);if(e.info(""),e.info(`Last run — ${t.startTime} (${r}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 o=t.tasks.filter(i=>i.exitCode!==void 0&&i.exitCode!==0);e.info("Failed tasks:");for(const i of o){const d=i.duration??0;e.info(` × ${i.taskId} (exit ${String(i.exitCode??-1)}, ${d}ms)`)}e.info("")}const c=[...t.tasks].filter(o=>typeof o.duration=="number").sort((o,i)=>(i.duration??0)-(o.duration??0)).slice(0,5);if(c.length>0){e.info("Slowest tasks:");for(const o of c)e.info(` ${o.taskId.padEnd(40)} ${String(o.duration??0).padStart(6)}ms [${o.cacheStatus}]`);e.info("")}},nc=s=>{if(!(s===void 0||s==="")){if(s!=="read"&&s!=="write"&&s!=="readwrite")throw new Error(`--cache-mode must be one of: read, write, readwrite (received "${s}")`);return s}},ic=s=>{if(!(s===void 0||s==="")){if(s!=="http"&&s!=="reapi")throw new Error(`--cache-backend must be one of: http, reapi (received "${s}")`);return s}},oc=s=>{if(!(s===void 0||s==="")){if(s!=="declared"&&s!=="trace")throw new Error(`--hash-mode must be one of: declared, trace (received "${s}")`);return s}},Fc=async({argument:s,logger:e,options:t,visConfig:r,workspaceRoot:c})=>{if(!c)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const o=c;if(Xr({logger:e,options:t,visConfig:r},o),_n(o),t.lastDetails){await rc(o,e);return}const i=process.cwd(),d=await Lr(o,r),{config:u,fileOwners:h,packageJsons:f,projectOptions:p,workspace:a}=Dr(o,r,d),k=Br(o,a,f);let S=s[0];if(!S){const m=es(a);if(process.stdout.isTTY&&process.stdin.isTTY){const v=await dn(m);if(!v){e.info("No target selected.");return}S=v,await Zi(`vis run ${v}`)}else throw e.info("Available targets:"),e.info(""),e.info(un(m)),e.info(""),new Ke("Missing target. Usage: vis run <target>")}if(u.constraints&&!t.skipConstraints){const m=hr(k,u.constraints);if(m.length>0){for(const v of m)e.error(`[${v.rule}] ${v.message}`);throw new Error(`${m.length} project constraint violation(s) found. Use --skip-constraints to bypass.`)}}if(!t.affected){const m=t.uncommitted?"--uncommitted":"--no-uncommitted",v=[["--base",t.base],["--head",t.head],["--downstream",t.downstream],["--upstream",t.upstream],[m,t.uncommitted]].filter(([,y])=>y!==void 0).map(([y])=>y);if(v.length>0)throw new Ke(`${v.join(", ")} ${v.length===1?"requires":"require"} --affected.
180
180
  Did you mean: vis run ${S} --affected ${v.map(y=>y.includes("uncommitted")?y:`${y}=…`).join(" ")}
181
181
  Or use the dedicated command: vis affected ${S} …`)}const B=await wn(S,a,process.cwd(),o),q=fn(p),b=hn(B.target,q);b!==B.target&&e.debug?.(`Resolved alias "${B.target}" → "${b}"`);let T=B.projects;const I=s.slice(1).map(String);if(t.projects!==void 0&&(T=pn(T,String(t.projects),Object.keys(a.projects))),t.filter&&t.filter.length>0){const m=new Map;for(const[R,W]of f)m.set(R,W.name);const v=await jo(t.filter,{defaultBase:r?.defaultBase,packageNameByProject:m,projectGraph:k,workspaceRoot:o}),y=new Set(v);if(T=T.filter(R=>y.has(R)),T.length===0){e.info(`Filter ${t.filter.map(R=>`"${R}"`).join(", ")} matched no projects.`);return}}if(t.query&&(T=vn(T,a,t.query),T.length===0)){e.info(`Query "${String(t.query)}" matched no projects.`);return}if(t.tag&&t.tag.length>0&&(T=yn(T,a,t.tag),T.length===0)){e.info(`Tag filter ${t.tag.map(m=>`"${m}"`).join(", ")} matched no projects.`);return}let j;if(t.affected){const m=await ln({base:t.base,downstream:t.downstream,head:t.head,uncommitted:t.uncommitted,upstream:t.upstream},{fileOwners:h,projectGraph:k,projects:a.projects,workspaceRoot:o},{affectedIgnore:r?.affectedIgnore,defaultBase:r?.defaultBase});for(const R of m.notes)e.info(`▸ ${R}`);if(m.changedFiles.length===0){e.info("No files changed. Nothing to run.");return}const v=new Set(m.affectedProjects);if(T=T.filter(R=>v.has(R)),T.length===0){e.info("No projects affected by the changes.");return}const y=new Set(m.ignoredFiles);j=m.changedFiles.filter(R=>!y.has(R)),e.info(`Affected projects: ${T.join(", ")}`)}const M=xn(),w=process.env[$t],F=j??(w?w.split(`
182
- `).filter(Boolean):void 0),_=(typeof t.runnerTags=="string"?t.runnerTags:process.env.VIS_RUNNER_TAGS)??void 0,$=_?new Set(_.split(",").map(m=>m.trim()).filter(Boolean)):void 0,N=[],X=new Map;for(const m of T){const y=p.get(m)?.[b];if(!y)continue;const R=y.options;if(!R?.internal){if(!jn(R,!!Ye)){e.debug?.(`Skipping ${m}:${b} — runInCI filter`);continue}if(!kn(R,$)){e.debug?.(`Skipping ${m}:${b} — runner-tags filter`);continue}N.push(m),X.set(m,y)}}if(N.length===0){const m=es(a),v=Object.entries(a.projects).filter(([,y])=>y.targets?.[b]!==void 0).map(([y])=>y);if(e.error(`No projects have the "${b}" target.`),v.length>0){e.info(""),e.info(`Target "${b}" exists in these projects but was filtered out:`);for(const y of v.slice(0,5))e.info(` - ${y}`);v.length>5&&e.info(` …and ${v.length-5} more`)}else{const y=mn(b,m,3);y.length>0&&(e.info(""),e.info(y.length===1?`Did you mean "${y[0]}"?`:`Did you mean one of: ${y.map(R=>`"${R}"`).join(", ")}?`)),e.info(""),e.info("Run `vis run` without arguments to see all available targets.")}return}const ae=t.pty,Q=N.map(m=>({project:m,schema:X.get(m)?.arguments})).filter(m=>Array.isArray(m.schema)&&m.schema.length>0),K=new Map;for(const{project:m,schema:v}of Q){const y=JSON.stringify(v),R=K.get(y)??[];R.push(m),K.set(y,R)}if(K.size>1){const m=[...K.values()].map(v=>v.join(", ")).join(" | ");throw new Error(`Target "${b}" declares conflicting \`arguments\` schemas across projects (${m}). Run a single project (e.g. \`vis run ${Q[0]?.project}:${b}\` or --projects=<name>) so the argument contract is unambiguous.`)}const se=Q[0]?.schema,le=X.get(Q[0]?.project??N[0])?.description,de=Vo(b,le,se,I);if(de.kind==="help"){e.info(de.text);return}if(de.kind==="invalid"){e.info(`Invalid arguments for "${b}":`);for(const m of de.errors)e.info(` ✖ ${m}`);throw e.info(""),e.info(de.help),new Error(`Invalid arguments for target "${b}"`)}const ie=de.env,we=oc(t.hashMode);let H=N.map(m=>{const v=a.projects[m],y=X.get(m),R={project:m,target:b},W=`${m}:${b}`,ee=ae?{...y.options,pty:y.options?.pty??!0}:y.options,D=y.command?Yt(y.command,{affectedFiles:F,projectRoot:v?.root}):y.command,A=v?.root&&v.root.length>0?v.root:".",Y=(y.outputs??[]).map(V=>typeof V!="string"?V:V.replaceAll("{projectRoot}",A).replaceAll("{projectName}",m));return{cache:y.cache,hashMode:we??y.hashMode,id:W,outputs:Y,overrides:{command:D,...I.length>0?{[Ks]:I}:{},...Object.keys(ie).length>0?{[Ct]:ie}:{},...ee?{visOptions:ee}:{}},parallelism:y.parallelism,projectRoot:v?.root,target:R}});const G=[],Z=[];for(const m of H)Ys(m)?.persistent?(m.cache=!1,G.push(m)):Z.push(m);H=Z;const me=fr(t.partition);if(me&&(H=hr.partitionTasks(H,me),e.info(`Partition ${me.index}/${me.total}: running ${H.length} task(s)`),H.length===0)){e.info("No tasks assigned to this partition.");return}const ke=new Set([...H,...G].map(m=>m.id));let P=pr([...H,...G],{onCycleBroken:m=>{e.warn(`Ignoring dev-only dependency cycle (build order is ambiguous): ${m.join(" → ")}`)},onUnmatchedProjectSelector:m=>{e.warn(`dependsOn.projects entry "${m}" matched no project — that dependency edge was not created.`)},projectGraph:k,targetDefaults:u.tasks,workspace:a});for(const[m,v]of Object.entries(P.tasks)){const y=v.target.project,R=v.target.target,W=p.get(y)?.[R];if(!W){ke.has(m)||e.warn(`${R} required via dependsOn but no command is configured for ${y} — skipping (no-op).`);continue}const ee=a.projects[y];let D=!1;const A={...v.overrides};A.visOptions===void 0&&W.options&&(A.visOptions=W.options,D=!0),A.command===void 0&&W.command&&(A.command=Yt(W.command,{affectedFiles:F,projectRoot:ee?.root}),D=!0),D&&(v.overrides=A,P.tasks[m]=v)}if(typeof t.skipCache=="string"&&t.skipCache.trim()!=="")if(t.cache){const m=hi(t.skipCache,a,Object.keys(P.tasks));for(const v of m.skipTaskIds){const y=P.tasks[v];y!==void 0&&(y.cache=!1)}m.unmatchedPatterns.length>0&&e.warn(`--skip-cache: no tasks matched ${m.unmatchedPatterns.map(v=>`"${v}"`).join(", ")}`),m.skipTaskIds.size>0&&e.debug?.(`--skip-cache: bypassing cache for ${String(m.skipTaskIds.size)} task(s)`)}else e.debug?.("--skip-cache ignored: --no-cache already disables caching for the whole run");await Jr(o,u.toolchain,{error:m=>{e.error(m)},info:m=>{e.info(m)},warn:m=>{e.warn(m)}},!!t.skipToolchain);const ge=t.preflight!==!1&&u.preflight?.lockfile!==!1,Ee=_r(o,Ye,{warn:m=>{e.warn(m)}},{skip:!ge});if(!Ee.shouldContinue)throw new Error(`${Ee.formattedMessage??"preflight: lockfile drift detected"} (pass --no-preflight to bypass)`);ge&&!Ye&&process.stdin.isTTY&&process.stdout.isTTY&&await di(o,{interactive:!0,logger:{info:m=>{e.info(m)},warn:m=>{e.warn(m)}},projectManifests:[...f.values()]});const Fe=process.env.VIS_VERSION??"0.0.0",_e=t.dryRun?void 0:async m=>{try{return await sn(m.config,{timeoutMs:Uo}),!0}catch{return!1}},Oe=await rn(o),te=await fo({initialTasks:[...H,...G],probe:_e,registeredEntries:Oe,taskGraph:P,visVersion:Fe}),Ae=[];let ve,he=0;const ye=[],xe=new Map;let $e=[];const C=new Set;let x=null,E=null;if(te.diagnostics.length>0){const m=!!(process.stdout.isTTY&&process.stdin.isTTY),v=t.dryRun?"off":Do({cli:t.services,config:u.run?.services,isCi:!!Ye,isPersistentTarget:G.length>0,isTty:m,target:b});if(v==="off"){for(const V of te.diagnostics)e.error(V.message);const A=Lo({cli:t.services,config:u.run?.services}),Y=[];throw t.dryRun?Y.push("`--dry-run` never starts services; drop it to let vis boot them."):A==="default"?Y.push("vis only auto-starts service deps in an interactive terminal by default (this run is CI or non-TTY).","Pass `--services=ephemeral` to boot them for this run, or set `run.services` in vis.config.ts."):A==="cli"?Y.push("`--services=off` was passed; use `--services=ephemeral` to boot them for this run."):Y.push('`run.services: "off"` is set in vis.config.ts; override it with `--services=ephemeral`.'),new Ke([`${te.diagnostics.length} service dependency error(s) — start the missing services or invoke them directly.`,...Y].join(`
183
- `))}const y=te.diagnostics.map(A=>A.targetId),R=v,W=R==="registry"?Vs(o,y,P):void 0,ee=process.argv[1]??"vis",D=Oo({missingServiceIds:y,mode:R,taskGraph:P,visBin:ee,workspaceRoot:o});if(D.skipped.length>0){for(const{id:A,reason:Y}of D.skipped)e.error(`Cannot auto-start ${A}: ${Y}`);throw new Ke(`${D.skipped.length} service(s) cannot be auto-started — invoke them directly or add a service config.`)}Ae.push(...D.ephemeralPidFiles),ve=D.runDir,$e=D.chain;for(const A of D.chain)C.add(A);if(R==="registry"&&(he=D.chain.length,ye.push(...D.chain)),D.chain.length>0){const A=new ls(D.chain),Y=new Map;if(R==="ephemeral"&&D.runDir)for(const V of D.chain){const O=Us(D.runDir,`${D.runDir}/bootstrap.mjs`,V);Y.set(V,{ephemeral:{configFile:O.configFile,cwd:o,logFile:O.logFile,pidFile:O.pidFile,scriptPath:O.scriptPath},mode:"ephemeral"})}else if(R==="registry"&&W)for(const V of W.services)Y.set(V.id,{mode:"registry",registry:{command:V.command,config:V.config,cwd:V.cwd,env:V.env}});if(Y.size>0){const V=new To({indexToId:new Map,services:Y,sink:{crashed:(O,L)=>{A.markCrashed(O,L)},failed:(O,L,U)=>{A.markFailed(O,L,U)},log:(O,L)=>{A.appendLog(O,L)},ready:(O,L)=>{A.markReady(O,L)},started:(O,L)=>{A.markStarted(O,L),R==="registry"&&L!==null&&xe.set(O,L)},starting:O=>{A.markStarting(O)}},workspaceRoot:o});x=A,E=V}}for(const[A,Y]of D.serviceEnvByTaskId){const V=te.serviceEnvByTaskId.get(A)??{};te.serviceEnvByTaskId.set(A,{...V,...Y})}}const re=new Set(G.map(m=>m.id));if(H=te.initialTasks.filter(m=>!re.has(m.id)),P=te.taskGraph,$e.length>0&&(H=[...$e.map(v=>P.tasks[v]).filter(v=>v!==void 0),...H]),G.length>0){const m=new Set(G.map(ee=>ee.id)),v={};for(const[ee,D]of Object.entries(P.tasks))m.has(ee)||(v[ee]=D);const y={};for(const[ee,D]of Object.entries(P.dependencies))m.has(ee)||(y[ee]=D.filter(A=>!m.has(A)));const R=new Set;for(const ee of Object.values(y))for(const D of ee)R.add(D);const W=Object.keys(v).filter(ee=>!R.has(ee));P={dependencies:y,roots:W,tasks:v}}const{serviceEnvByTaskId:Ie}=te;if(te.satisfiedServices.length>0){const m=te.satisfiedServices.map(v=>v.id).join(", ");if(e.debug?.(`Auto-attached to running services: ${m}`),x)for(const v of te.satisfiedServices)x.registerService(v.id);else x=new ls(te.satisfiedServices.map(v=>v.id));for(const v of te.satisfiedServices){const y=v.config.readiness?.tcp?.port??v.config.port??0,R=v.config.readiness?.tcp?.host??"127.0.0.1";x.markReady(v.id,{host:R,port:y})}}if(t.reverse&&(P=mr(P),e.debug?.(`Reversed task graph: ${String(P.roots.length)} new root(s) (originally leaves)`)),t.dryRun){const m=Object.keys(P.tasks).length,v=P.roots.length;e.info(`Execution plan (${String(m)} task(s), ${String(v)} root(s)):`),e.info("");const y=new Set,R=(W,ee)=>{if(y.has(W))return;y.add(W);for(const V of P.dependencies[W]??[])R(V,ee+1);const D=P.tasks[W],A=" ".repeat(ee+1),Y=`${D?.cache===!1?" (no-cache)":""}${D?.hashMode==="trace"?" (trace)":""}`;e.info(`${A}${W}${Y}`)};for(const W of P.roots)R(W,0);for(const W of Object.keys(P.tasks))R(W,0);G.length>0&&(e.info(""),e.info(` + ${String(G.length)} persistent task(s) (run after graph completes)`)),e.info("");return}const Et=Date.now(),Ce=nn(),Rt=(m,v)=>{const y=v instanceof Error?v.message:String(v);e.warn(`Plugin error in ${m}: ${y}`)};await on(Ce,u.plugins);const qe=typeof t.profile=="string"?t.profile:void 0,Pt=async m=>{if(!qe)return;const v=Jt(m,P,Et),y=qe.startsWith("/")?qe:`${o}/${qe}`;await jr(v,y),e.info(`Profile written to ${qe}`)},Je=u.taskRunner??{},Xs=Ir(o,t.cacheDir,Je.cacheDirectory,u.sharedWorktreeCache),Js=Cr(Xs,o,u.branchScopedCache),Ne=sc(process.env.VIS_RUN_CONCURRENCY_LIMIT);Ne&&"invalid"in Ne&&e.warn(`VIS_RUN_CONCURRENCY_LIMIT=${Ne.invalid} is not a positive number; falling back to default concurrency.`);const Qs=Ne&&"value"in Ne?Ne.value:void 0,ut=t.parallel??Qs??3,Mt=t.strictEnv??u.strictEnv??!1,Ft=new Set,Le={dryRun:t.dryRun??!1,parallel:ut,skipNxCache:!t.cache,summarize:t.summarize??!1,...Je,cacheDirectory:Js,dataDirectory:Je.dataDirectory??st(o),namedInputs:u.namedInputs,onDiagnostic:(m,v)=>{Ft.has(m)||(Ft.add(m),e.warn(v))},onFingerprint:async(m,v)=>{await Ce.callHook("task:fingerprint",m,v)}},Ot=gr(Je.remoteCache);if(Ot){const m=nc(t.cacheMode),v=ic(t.cacheBackend);if(Le.remoteCache={...Ot,...m?{mode:m}:{},...v?{backend:v}:{}},Le.remoteCache.attestation){const{expectedIdentity:y,requireOnDownload:R}=Le.remoteCache.attestation;if(!(y!==void 0&&("github"in y&&typeof y.github?.ref=="string"&&typeof y.github.repo=="string"&&typeof y.github.workflow=="string"||"oidcIssuer"in y&&typeof y.oidcIssuer=="string"&&(typeof y.san=="string"||typeof y.sanRegex=="string"))))throw new Error("[vis run] remoteCache.attestation requires a pinned keyless signer via `expectedIdentity`. Use one of:\n • { github: { repo, workflow, ref } } (GitHub Actions — recommended)\n • { oidcIssuer, san } (literal identity; vis regex-escapes + anchors it)\n • { oidcIssuer, sanRegex } (advanced: raw regex, you own anchoring)\nWithout it, verification is integrity-only — use `remoteCache.signing` (HMAC) for that instead.");"sanRegex"in y&&(!y.sanRegex.startsWith("^")||!y.sanRegex.endsWith("$"))&&e.warn("[vis run] remoteCache.attestation.expectedIdentity.sanRegex is not anchored (^…$). sigstore matches it as a regex; an unanchored value is substring-matched and weakens the identity pin. Prefer the literal `san` form unless you need a pattern.");const{installCommandFor:ee,isSigstoreInstalled:D}=await import("./loader.js");D()||e.warn(`[vis run] remoteCache.attestation is configured but the optional \`sigstore\` package is not installed. Cache uploads will be unsigned and signed entries can't be verified until you install it:
184
- ${ee(o)}`);const{buildCacheAttestationHooks:A}=await import("./cache-attestation.js");Le.remoteCache.attestation=A({expectedIdentity:y,onReject:(Y,V)=>{e.warn(`[vis run] remote cache entry ${Y.slice(0,12)} rejected: attestation ${V}. Treating as a cache miss.`)},onVerifyFailure:Y=>{e.warn(`[vis run] attestation verification failed: ${Y}`)},requireOnDownload:R,workspaceRoot:o})}}else(t.cacheMode||t.cacheBackend)&&e.warn("[vis run] --cache-mode and --cache-backend require a `remoteCache` block in vis.config.ts (or TURBO_API env); ignoring.");const Zs=process.stdout.isTTY&&!Ye,er=r?.run?.quietOnSuccess===!0,tr=u.tui?.autoExit??(er?3:!1),At={args:{parallel:Le.parallel,targets:[b]},autoExit:tr,projectNames:N,tasks:[...H,...G],totalTaskCount:Object.keys(P.tasks).length+G.length},Lt=typeof t.retryBudget=="number"?t.retryBudget:void 0,Dt=Lt===void 0?void 0:ec(Lt),Bt=new cn(Ce,Rt),_t=new Kr(o),Nt=Xi(t.outputStyle,r?.run?.quietOnSuccess);if(te.satisfiedServices.length>0)for(const m of te.satisfiedServices){const v=te.serviceDependentsByServiceId.get(m.id)??[];try{await Ce.callHook("service:attach",m,v)}catch(y){Rt("service:attach",y)}}await Ce.callHook("run:before",{tasks:H,workspaceRoot:o});const Ve=t.stopServices;let Gt=!1;const Wt=()=>{if(Gt)return;Gt=!0,E&&E.dispose().catch(()=>{});const m=Ve?[...xe.values()]:void 0;Yo({extraPids:m,pidFiles:Ae,runDir:ve})},Qe=()=>{Wt()},Ht=Ae.length>0||ve!==void 0||Ve&&ye.length>0;Ht&&(process.on("SIGINT",Qe),process.on("SIGTERM",Qe));try{if(Zs){const m=new Map,v=Yi({...At,onRetryService:E?O=>E.retry(O):void 0,outputStyle:Nt,serviceDockStore:x,stdinRegistry:m}),{lifeCycle:y,store:R}=v,W=new Kt([y,Bt,_t]),D=Ss({affectedFiles:F,currentOs:M,hooks:Ce,initCwd:i,lifeCycle:W,mutexPool:new Map,onOutput:(O,L)=>{E&&C.has(O)?E.onTaskOutput(O,L):R.addOutput(O,L)},onOutputReplace:(O,L)=>{R.setOutput(O,L)},retryBudget:Dt,serviceEnvByTaskId:Ie,serviceEventBridge:E??void 0,stdinRegistry:m,strictEnv:Mt,taskSlots:ut,workspaceRoot:o});let A="rerun",Y=null,V=new Map;for(;A!=="quit";){if(A==="rerun"){if(V=await Xt(H,Le,{lifeCycle:W,projectGraph:k,taskExecutor:D,taskGraph:P,workspaceRoot:o}),G.length>0&&!t.failFast){const O=new Promise(L=>{const U=R.subscribe(()=>{const oe=R.getSnapshot();(oe.rerunRequested||oe.retryTaskId)&&(U(),L())});v.renderIsDone.then(()=>{U(),L()}).catch(()=>{U(),L()})});await ks(G,o,F,i,{abortSignal:O,lifeCycle:W,stdinRegistry:m,store:R},Ie)}}else if(A==="retry"&&Y){const O=H.find(U=>U.id===Y),L=O?.overrides.command;if(O&&L){const U=at(o,O.projectRoot,!1);W.startTasks?.([O]);const oe=new yt(ct),fe=(await tt([{command:L,cwd:U,name:O.id,ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}],{onEvent:ne=>{ne.kind==="started"&&ne.write&&m.set(O.id,{kill:ne.kill,resize:ne.resize,write:ne.write}),(ne.kind==="stdout"||ne.kind==="stderr")&&ne.text&&(oe.write(ne.text),R.setOutput(O.id,oe.toString())),ne.kind==="close"&&m.delete(O.id)}})).closeEvents[0];W.endTasks?.([{code:fe?.exitCode??1,status:fe?.exitCode===0?"success":"failure",task:O,terminalOutput:R.getSnapshot().outputs.get(O.id)}])}else O&&W.endTasks?.([{code:1,status:"failure",task:O,terminalOutput:`No command configured for ${O.id}`}]);Y=null,R.markDone()}A=await new Promise(O=>{const L=R.subscribe(()=>{const U=R.getSnapshot();U.rerunRequested&&(R.acknowledgeRerun(),L(),O("rerun")),U.retryTaskId&&(Y=R.acknowledgeRetry(),L(),O("retry"))});v.renderIsDone.then(()=>{L(),O("quit")}).catch(()=>{L(),O("quit")})})}await v.renderIsDone,await Ce.callHook("run:after",V),await Pt(V),he>0&&(e.info(""),Ve?e.info(`${String(he)} service(s) stopped (--stop-services).`):e.info(`${String(he)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))}else{const m=new Map,v=typeof t.log=="string"?t.log.toLowerCase():"",y=v==="labeled"||v==="grouped"||v==="interleaved"?v:void 0,R=y?wr(y):void 0,W=new Kt([new Qi({...At,ciGrouping:r?.run?.ciGrouping??"auto",logReporter:R,outputStyle:Nt}),Bt,_t]),ee=Ss({affectedFiles:F,currentOs:M,hooks:Ce,initCwd:i,lifeCycle:W,mutexPool:m,retryBudget:Dt,serviceEnvByTaskId:Ie,serviceEventBridge:E??void 0,strictEnv:Mt,taskSlots:ut,workspaceRoot:o}),D=async()=>{const L=Date.now(),U=await Xt(H,Le,{lifeCycle:W,projectGraph:k,taskExecutor:ee,taskGraph:P,workspaceRoot:o}),oe=Date.now()-L;if(t.summarize){const je=Jt(U,P,Et);await vr(je,o,{dataDirectory:st(o)})}let be=!1;for(const[,je]of U)je.status==="failure"&&(be=!0);const fe=Er(U,oe),ne=Rr(o),Re=Pr(o,oe,ne);return e.info(""),e.info(` ${fe}${Re?` ${Re}`:""}`),{hasFailure:be,results:U,runHistory:ne}},A=await D();await Ce.callHook("run:after",A.results),await Pt(A.results);const{hasFailure:Y}=A;if(t.watch){const L=N.map(ue=>{const Pe=a.projects[ue]?.root;if(Pe)return Pe.startsWith("/")?Pe:`${o}/${Pe}`}).filter(ue=>ue!==void 0),U=H;let oe;const be=ue=>{const Se=io(U,ue);return oe=Se.filter,H=Se.tasks,Se.tasks.length};let fe=!1,ne=A.results;const Re=()=>{const ue=rs(ne,o);if(ue.directories.length>0&&ue.files.size>0){const Se=Nn(ue.files,o,ue.directories);return{handle:ns({filter:Se,onChange:Ze,paths:ue.directories}),mode:"tracked"}}return{handle:ns({onChange:Ze,paths:L}),mode:"roots"}};let je;const Ze=async ue=>{if(!fe){fe=!0;try{e.info(`Change detected in ${ue.length} file(s), rerunning…`),ne=(await D()).results,je?.close(),je=Re().handle}finally{fe=!1}}},qt=Re();je=qt.handle;const sr=qt.mode==="tracked"?`Watching ${String(rs(ne,o).files.size)} tracked file(s)`:`Watching ${String(L.length)} project root(s)`;e.info(`${sr} — edit a file to rerun, press h for keybinds, q to quit.`);const ft=async()=>{if(!fe){fe=!0;try{if(H.length===0){e.info("No tasks match the active filter — press a to clear it.");return}ne=(await D()).results,je?.close(),je=Re().handle}finally{fe=!1}}};await new Promise(ue=>{let Se=!1,Pe;const Vt=()=>{Ut()},Ut=()=>{Se||(Se=!0,Pe?.close(),process.off("SIGINT",Vt),je?.close(),ue())};process.on("SIGINT",Vt),Pe=lo({handlers:{onClearFilter:async()=>{const Ue=be(void 0);e.info(`Filter cleared — running ${String(Ue)} task(s).`),await ft()},onFilter:async Ue=>{const rr=oe,zt=be(Ue);if(zt===0){e.info(`Filter "${Ue}" matched no projects — keeping previous filter.`),be(rr);return}e.info(`Filter "${Ue}" matched ${String(zt)} task(s).`),await ft()},onHelp:()=>{co(process.stdout)},onQuit:()=>{Ut()},onRerun:ft}})});return}if(t.flaky){const L=Mr(o,{minRuns:2},A.runHistory);if(L.length>0){e.info(""),e.info("Flaky tasks (based on historical runs):"),e.info("");for(const U of Fr(L))e.info(` ${U}`);e.info("")}}const V=[];for(const[L,U]of A.results)U.retryAttempts&&U.retryAttempts>0&&V.push(L);const O=t.failOnRetry&&V.length>0;if(O){const U=V.slice(0,5),oe=V.length-U.length,be=oe>0?`${U.join(", ")}, and ${String(oe)} more`:U.join(", ");e.warn(""),e.warn(`--fail-on-retry: ${String(V.length)} task(s) succeeded only after retry: ${be}`)}if(Y||O){const L=O&&!Y?"Some tasks succeeded only after retry (--fail-on-retry).":"Some tasks failed.",U=2e3,oe=[];for(const[be,fe]of A.results){if(fe.status!=="failure")continue;const ne=fe.terminalOutput??"",Re=ne.length>U?`…${ne.slice(-U)}`:ne,je=fe.code??"?";oe.push(` ${be} (exit ${String(je)}):
182
+ `).filter(Boolean):void 0),_=(typeof t.runnerTags=="string"?t.runnerTags:process.env.VIS_RUNNER_TAGS)??void 0,$=_?new Set(_.split(",").map(m=>m.trim()).filter(Boolean)):void 0,N=[],X=new Map;for(const m of T){const y=p.get(m)?.[b];if(!y)continue;const R=y.options;if(!R?.internal){if(!jn(R,!!Ye)){e.debug?.(`Skipping ${m}:${b} — runInCI filter`);continue}if(!kn(R,$)){e.debug?.(`Skipping ${m}:${b} — runner-tags filter`);continue}N.push(m),X.set(m,y)}}if(N.length===0){const m=es(a),v=Object.entries(a.projects).filter(([,y])=>y.targets?.[b]!==void 0).map(([y])=>y);if(e.error(`No projects have the "${b}" target.`),v.length>0){e.info(""),e.info(`Target "${b}" exists in these projects but was filtered out:`);for(const y of v.slice(0,5))e.info(` - ${y}`);v.length>5&&e.info(` …and ${v.length-5} more`)}else{const y=mn(b,m,3);y.length>0&&(e.info(""),e.info(y.length===1?`Did you mean "${y[0]}"?`:`Did you mean one of: ${y.map(R=>`"${R}"`).join(", ")}?`)),e.info(""),e.info("Run `vis run` without arguments to see all available targets.")}return}const ae=t.pty,Q=N.map(m=>({project:m,schema:X.get(m)?.arguments})).filter(m=>Array.isArray(m.schema)&&m.schema.length>0),K=new Map;for(const{project:m,schema:v}of Q){const y=JSON.stringify(v),R=K.get(y)??[];R.push(m),K.set(y,R)}if(K.size>1){const m=[...K.values()].map(v=>v.join(", ")).join(" | ");throw new Error(`Target "${b}" declares conflicting \`arguments\` schemas across projects (${m}). Run a single project (e.g. \`vis run ${Q[0]?.project}:${b}\` or --projects=<name>) so the argument contract is unambiguous.`)}const se=Q[0]?.schema,le=X.get(Q[0]?.project??N[0])?.description,de=Vo(b,le,se,I);if(de.kind==="help"){e.info(de.text);return}if(de.kind==="invalid"){e.info(`Invalid arguments for "${b}":`);for(const m of de.errors)e.info(` ✖ ${m}`);throw e.info(""),e.info(de.help),new Error(`Invalid arguments for target "${b}"`)}const ie=de.env,we=oc(t.hashMode);let H=N.map(m=>{const v=a.projects[m],y=X.get(m),R={project:m,target:b},W=`${m}:${b}`,ee=ae?{...y.options,pty:y.options?.pty??!0}:y.options,D=y.command?Yt(y.command,{affectedFiles:F,projectRoot:v?.root}):y.command,A=v?.root&&v.root.length>0?v.root:".",Y=(y.outputs??[]).map(V=>typeof V!="string"?V:V.replaceAll("{projectRoot}",A).replaceAll("{projectName}",m));return{cache:y.cache,hashMode:we??y.hashMode,id:W,outputs:Y,overrides:{command:D,...I.length>0?{[Ks]:I}:{},...Object.keys(ie).length>0?{[Ct]:ie}:{},...ee?{visOptions:ee}:{}},parallelism:y.parallelism,projectRoot:v?.root,target:R}});const G=[],Z=[];for(const m of H)Ys(m)?.persistent?(m.cache=!1,G.push(m)):Z.push(m);H=Z;const me=pr(t.partition);if(me&&(H=mr.partitionTasks(H,me),e.info(`Partition ${me.index}/${me.total}: running ${H.length} task(s)`),H.length===0)){e.info("No tasks assigned to this partition.");return}const ke=new Set([...H,...G].map(m=>m.id));let P=gr([...H,...G],{onCycleBroken:m=>{e.warn(`Ignoring dev-only dependency cycle (build order is ambiguous): ${m.join(" → ")}`)},onUnmatchedProjectSelector:m=>{e.warn(`dependsOn.projects entry "${m}" matched no project — that dependency edge was not created.`)},projectGraph:k,targetDefaults:u.tasks,workspace:a});for(const[m,v]of Object.entries(P.tasks)){const y=v.target.project,R=v.target.target,W=p.get(y)?.[R];if(!W){ke.has(m)||e.warn(`${R} required via dependsOn but no command is configured for ${y} — skipping (no-op).`);continue}const ee=a.projects[y];let D=!1;const A={...v.overrides};A.visOptions===void 0&&W.options&&(A.visOptions=W.options,D=!0),A.command===void 0&&W.command&&(A.command=Yt(W.command,{affectedFiles:F,projectRoot:ee?.root}),D=!0),D&&(v.overrides=A,P.tasks[m]=v)}if(typeof t.skipCache=="string"&&t.skipCache.trim()!=="")if(t.cache){const m=hi(t.skipCache,a,Object.keys(P.tasks));for(const v of m.skipTaskIds){const y=P.tasks[v];y!==void 0&&(y.cache=!1)}m.unmatchedPatterns.length>0&&e.warn(`--skip-cache: no tasks matched ${m.unmatchedPatterns.map(v=>`"${v}"`).join(", ")}`),m.skipTaskIds.size>0&&e.debug?.(`--skip-cache: bypassing cache for ${String(m.skipTaskIds.size)} task(s)`)}else e.debug?.("--skip-cache ignored: --no-cache already disables caching for the whole run");await Jr(o,u.toolchain,{error:m=>{e.error(m)},info:m=>{e.info(m)},warn:m=>{e.warn(m)}},!!t.skipToolchain);const ge=t.preflight!==!1&&u.preflight?.lockfile!==!1,Ee=Gr(o,Ye,{warn:m=>{e.warn(m)}},{skip:!ge});if(!Ee.shouldContinue)throw new Error(`${Ee.formattedMessage??"preflight: lockfile drift detected"} (pass --no-preflight to bypass)`);ge&&!Ye&&process.stdin.isTTY&&process.stdout.isTTY&&await di(o,{interactive:!0,logger:{info:m=>{e.info(m)},warn:m=>{e.warn(m)}},projectManifests:[...f.values()]});const Fe=process.env.VIS_VERSION??"0.0.0",_e=t.dryRun?void 0:async m=>{try{return await sn(m.config,{timeoutMs:Uo}),!0}catch{return!1}},Oe=await rn(o),te=await fo({initialTasks:[...H,...G],probe:_e,registeredEntries:Oe,taskGraph:P,visVersion:Fe}),Ae=[];let ve,he=0;const ye=[],xe=new Map;let $e=[];const C=new Set;let x=null,E=null;if(te.diagnostics.length>0){const m=!!(process.stdout.isTTY&&process.stdin.isTTY),v=t.dryRun?"off":Do({cli:t.services,config:u.run?.services,isCi:!!Ye,isPersistentTarget:G.length>0,isTty:m,target:b});if(v==="off"){for(const V of te.diagnostics)e.error(V.message);const A=Lo({cli:t.services,config:u.run?.services}),Y=[];throw t.dryRun?Y.push("`--dry-run` never starts services; drop it to let vis boot them."):A==="default"?Y.push("vis only auto-starts service deps in an interactive terminal by default (this run is CI or non-TTY).","Pass `--services=ephemeral` to boot them for this run, or set `run.services` in vis.config.ts."):A==="cli"?Y.push("`--services=off` was passed; use `--services=ephemeral` to boot them for this run."):Y.push('`run.services: "off"` is set in vis.config.ts; override it with `--services=ephemeral`.'),new Ke([`${te.diagnostics.length} service dependency error(s) — start the missing services or invoke them directly.`,...Y].join(`
183
+ `))}const y=te.diagnostics.map(A=>A.targetId),R=v,W=R==="registry"?Vs(o,y,P):void 0,ee=process.argv[1]??"vis",D=Oo({missingServiceIds:y,mode:R,taskGraph:P,visBin:ee,workspaceRoot:o});if(D.skipped.length>0){for(const{id:A,reason:Y}of D.skipped)e.error(`Cannot auto-start ${A}: ${Y}`);throw new Ke(`${D.skipped.length} service(s) cannot be auto-started — invoke them directly or add a service config.`)}Ae.push(...D.ephemeralPidFiles),ve=D.runDir,$e=D.chain;for(const A of D.chain)C.add(A);if(R==="registry"&&(he=D.chain.length,ye.push(...D.chain)),D.chain.length>0){const A=new ls(D.chain),Y=new Map;if(R==="ephemeral"&&D.runDir)for(const V of D.chain){const O=Us(D.runDir,`${D.runDir}/bootstrap.mjs`,V);Y.set(V,{ephemeral:{configFile:O.configFile,cwd:o,logFile:O.logFile,pidFile:O.pidFile,scriptPath:O.scriptPath},mode:"ephemeral"})}else if(R==="registry"&&W)for(const V of W.services)Y.set(V.id,{mode:"registry",registry:{command:V.command,config:V.config,cwd:V.cwd,env:V.env}});if(Y.size>0){const V=new To({indexToId:new Map,services:Y,sink:{crashed:(O,L)=>{A.markCrashed(O,L)},failed:(O,L,U)=>{A.markFailed(O,L,U)},log:(O,L)=>{A.appendLog(O,L)},ready:(O,L)=>{A.markReady(O,L)},started:(O,L)=>{A.markStarted(O,L),R==="registry"&&L!==null&&xe.set(O,L)},starting:O=>{A.markStarting(O)}},workspaceRoot:o});x=A,E=V}}for(const[A,Y]of D.serviceEnvByTaskId){const V=te.serviceEnvByTaskId.get(A)??{};te.serviceEnvByTaskId.set(A,{...V,...Y})}}const re=new Set(G.map(m=>m.id));if(H=te.initialTasks.filter(m=>!re.has(m.id)),P=te.taskGraph,$e.length>0&&(H=[...$e.map(v=>P.tasks[v]).filter(v=>v!==void 0),...H]),G.length>0){const m=new Set(G.map(ee=>ee.id)),v={};for(const[ee,D]of Object.entries(P.tasks))m.has(ee)||(v[ee]=D);const y={};for(const[ee,D]of Object.entries(P.dependencies))m.has(ee)||(y[ee]=D.filter(A=>!m.has(A)));const R=new Set;for(const ee of Object.values(y))for(const D of ee)R.add(D);const W=Object.keys(v).filter(ee=>!R.has(ee));P={dependencies:y,roots:W,tasks:v}}const{serviceEnvByTaskId:Ie}=te;if(te.satisfiedServices.length>0){const m=te.satisfiedServices.map(v=>v.id).join(", ");if(e.debug?.(`Auto-attached to running services: ${m}`),x)for(const v of te.satisfiedServices)x.registerService(v.id);else x=new ls(te.satisfiedServices.map(v=>v.id));for(const v of te.satisfiedServices){const y=v.config.readiness?.tcp?.port??v.config.port??0,R=v.config.readiness?.tcp?.host??"127.0.0.1";x.markReady(v.id,{host:R,port:y})}}if(t.reverse&&(P=wr(P),e.debug?.(`Reversed task graph: ${String(P.roots.length)} new root(s) (originally leaves)`)),t.dryRun){const m=Object.keys(P.tasks).length,v=P.roots.length;e.info(`Execution plan (${String(m)} task(s), ${String(v)} root(s)):`),e.info("");const y=new Set,R=(W,ee)=>{if(y.has(W))return;y.add(W);for(const V of P.dependencies[W]??[])R(V,ee+1);const D=P.tasks[W],A=" ".repeat(ee+1),Y=`${D?.cache===!1?" (no-cache)":""}${D?.hashMode==="trace"?" (trace)":""}`;e.info(`${A}${W}${Y}`)};for(const W of P.roots)R(W,0);for(const W of Object.keys(P.tasks))R(W,0);G.length>0&&(e.info(""),e.info(` + ${String(G.length)} persistent task(s) (run after graph completes)`)),e.info("");return}const Et=Date.now(),Ce=nn(),Rt=(m,v)=>{const y=v instanceof Error?v.message:String(v);e.warn(`Plugin error in ${m}: ${y}`)};await on(Ce,u.plugins);const qe=typeof t.profile=="string"?t.profile:void 0,Pt=async m=>{if(!qe)return;const v=Jt(m,P,Et),y=qe.startsWith("/")?qe:`${o}/${qe}`;await br(v,y),e.info(`Profile written to ${qe}`)},Je=u.taskRunner??{},Xs=Er(o,t.cacheDir,Je.cacheDirectory,u.sharedWorktreeCache),Js=Rr(Xs,o,u.branchScopedCache),Ne=sc(process.env.VIS_RUN_CONCURRENCY_LIMIT);Ne&&"invalid"in Ne&&e.warn(`VIS_RUN_CONCURRENCY_LIMIT=${Ne.invalid} is not a positive number; falling back to default concurrency.`);const Qs=Ne&&"value"in Ne?Ne.value:void 0,ut=t.parallel??Qs??3,Mt=t.strictEnv??u.strictEnv??!1,Ft=new Set,Le={dryRun:t.dryRun??!1,parallel:ut,skipNxCache:!t.cache,summarize:t.summarize??!1,...Je,cacheDirectory:Js,dataDirectory:Je.dataDirectory??st(o),namedInputs:u.namedInputs,onDiagnostic:(m,v)=>{Ft.has(m)||(Ft.add(m),e.warn(v))},onFingerprint:async(m,v)=>{await Ce.callHook("task:fingerprint",m,v)}},Ot=vr(Je.remoteCache);if(Ot){const m=nc(t.cacheMode),v=ic(t.cacheBackend);if(Le.remoteCache={...Ot,...m?{mode:m}:{},...v?{backend:v}:{}},Le.remoteCache.attestation){const{expectedIdentity:y,requireOnDownload:R}=Le.remoteCache.attestation;if(!(y!==void 0&&("github"in y&&typeof y.github?.ref=="string"&&typeof y.github.repo=="string"&&typeof y.github.workflow=="string"||"oidcIssuer"in y&&typeof y.oidcIssuer=="string"&&(typeof y.san=="string"||typeof y.sanRegex=="string"))))throw new Error("[vis run] remoteCache.attestation requires a pinned keyless signer via `expectedIdentity`. Use one of:\n • { github: { repo, workflow, ref } } (GitHub Actions — recommended)\n • { oidcIssuer, san } (literal identity; vis regex-escapes + anchors it)\n • { oidcIssuer, sanRegex } (advanced: raw regex, you own anchoring)\nWithout it, verification is integrity-only — use `remoteCache.signing` (HMAC) for that instead.");"sanRegex"in y&&(!y.sanRegex.startsWith("^")||!y.sanRegex.endsWith("$"))&&e.warn("[vis run] remoteCache.attestation.expectedIdentity.sanRegex is not anchored (^…$). sigstore matches it as a regex; an unanchored value is substring-matched and weakens the identity pin. Prefer the literal `san` form unless you need a pattern.");const{installCommandFor:ee,isSigstoreInstalled:D}=await import("./loader.js");D()||e.warn(`[vis run] remoteCache.attestation is configured but the optional \`sigstore\` package is not installed. Cache uploads will be unsigned and signed entries can't be verified until you install it:
184
+ ${ee(o)}`);const{buildCacheAttestationHooks:A}=await import("./cache-attestation.js");Le.remoteCache.attestation=A({expectedIdentity:y,onReject:(Y,V)=>{e.warn(`[vis run] remote cache entry ${Y.slice(0,12)} rejected: attestation ${V}. Treating as a cache miss.`)},onVerifyFailure:Y=>{e.warn(`[vis run] attestation verification failed: ${Y}`)},requireOnDownload:R,workspaceRoot:o})}}else(t.cacheMode||t.cacheBackend)&&e.warn("[vis run] --cache-mode and --cache-backend require a `remoteCache` block in vis.config.ts (or TURBO_API env); ignoring.");const Zs=process.stdout.isTTY&&!Ye,er=r?.run?.quietOnSuccess===!0,tr=u.tui?.autoExit??(er?3:!1),At={args:{parallel:Le.parallel,targets:[b]},autoExit:tr,projectNames:N,tasks:[...H,...G],totalTaskCount:Object.keys(P.tasks).length+G.length},Lt=typeof t.retryBudget=="number"?t.retryBudget:void 0,Dt=Lt===void 0?void 0:ec(Lt),Bt=new cn(Ce,Rt),_t=new Kr(o),Nt=Xi(t.outputStyle,r?.run?.quietOnSuccess);if(te.satisfiedServices.length>0)for(const m of te.satisfiedServices){const v=te.serviceDependentsByServiceId.get(m.id)??[];try{await Ce.callHook("service:attach",m,v)}catch(y){Rt("service:attach",y)}}await Ce.callHook("run:before",{tasks:H,workspaceRoot:o});const Ve=t.stopServices;let Gt=!1;const Wt=()=>{if(Gt)return;Gt=!0,E&&E.dispose().catch(()=>{});const m=Ve?[...xe.values()]:void 0;Yo({extraPids:m,pidFiles:Ae,runDir:ve})},Qe=()=>{Wt()},Ht=Ae.length>0||ve!==void 0||Ve&&ye.length>0;Ht&&(process.on("SIGINT",Qe),process.on("SIGTERM",Qe));try{if(Zs){const m=new Map,v=Yi({...At,onRetryService:E?O=>E.retry(O):void 0,outputStyle:Nt,serviceDockStore:x,stdinRegistry:m}),{lifeCycle:y,store:R}=v,W=new Kt([y,Bt,_t]),D=Ss({affectedFiles:F,currentOs:M,hooks:Ce,initCwd:i,lifeCycle:W,mutexPool:new Map,onOutput:(O,L)=>{E&&C.has(O)?E.onTaskOutput(O,L):R.addOutput(O,L)},onOutputReplace:(O,L)=>{R.setOutput(O,L)},retryBudget:Dt,serviceEnvByTaskId:Ie,serviceEventBridge:E??void 0,stdinRegistry:m,strictEnv:Mt,taskSlots:ut,workspaceRoot:o});let A="rerun",Y=null,V=new Map;for(;A!=="quit";){if(A==="rerun"){if(V=await Xt(H,Le,{lifeCycle:W,projectGraph:k,taskExecutor:D,taskGraph:P,workspaceRoot:o}),G.length>0&&!t.failFast){const O=new Promise(L=>{const U=R.subscribe(()=>{const oe=R.getSnapshot();(oe.rerunRequested||oe.retryTaskId)&&(U(),L())});v.renderIsDone.then(()=>{U(),L()}).catch(()=>{U(),L()})});await ks(G,o,F,i,{abortSignal:O,lifeCycle:W,stdinRegistry:m,store:R},Ie)}}else if(A==="retry"&&Y){const O=H.find(U=>U.id===Y),L=O?.overrides.command;if(O&&L){const U=at(o,O.projectRoot,!1);W.startTasks?.([O]);const oe=new yt(ct),fe=(await tt([{command:L,cwd:U,name:O.id,ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}],{onEvent:ne=>{ne.kind==="started"&&ne.write&&m.set(O.id,{kill:ne.kill,resize:ne.resize,write:ne.write}),(ne.kind==="stdout"||ne.kind==="stderr")&&ne.text&&(oe.write(ne.text),R.setOutput(O.id,oe.toString())),ne.kind==="close"&&m.delete(O.id)}})).closeEvents[0];W.endTasks?.([{code:fe?.exitCode??1,status:fe?.exitCode===0?"success":"failure",task:O,terminalOutput:R.getSnapshot().outputs.get(O.id)}])}else O&&W.endTasks?.([{code:1,status:"failure",task:O,terminalOutput:`No command configured for ${O.id}`}]);Y=null,R.markDone()}A=await new Promise(O=>{const L=R.subscribe(()=>{const U=R.getSnapshot();U.rerunRequested&&(R.acknowledgeRerun(),L(),O("rerun")),U.retryTaskId&&(Y=R.acknowledgeRetry(),L(),O("retry"))});v.renderIsDone.then(()=>{L(),O("quit")}).catch(()=>{L(),O("quit")})})}await v.renderIsDone,await Ce.callHook("run:after",V),await Pt(V),he>0&&(e.info(""),Ve?e.info(`${String(he)} service(s) stopped (--stop-services).`):e.info(`${String(he)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))}else{const m=new Map,v=typeof t.log=="string"?t.log.toLowerCase():"",y=v==="labeled"||v==="grouped"||v==="interleaved"?v:void 0,R=y?yr(y):void 0,W=new Kt([new Qi({...At,ciGrouping:r?.run?.ciGrouping??"auto",logReporter:R,outputStyle:Nt}),Bt,_t]),ee=Ss({affectedFiles:F,currentOs:M,hooks:Ce,initCwd:i,lifeCycle:W,mutexPool:m,retryBudget:Dt,serviceEnvByTaskId:Ie,serviceEventBridge:E??void 0,strictEnv:Mt,taskSlots:ut,workspaceRoot:o}),D=async()=>{const L=Date.now(),U=await Xt(H,Le,{lifeCycle:W,projectGraph:k,taskExecutor:ee,taskGraph:P,workspaceRoot:o}),oe=Date.now()-L;if(t.summarize){const je=Jt(U,P,Et);await xr(je,o,{dataDirectory:st(o)})}let be=!1;for(const[,je]of U)je.status==="failure"&&(be=!0);const fe=Pr(U,oe),ne=Mr(o),Re=Fr(o,oe,ne);return e.info(""),e.info(` ${fe}${Re?` ${Re}`:""}`),{hasFailure:be,results:U,runHistory:ne}},A=await D();await Ce.callHook("run:after",A.results),await Pt(A.results);const{hasFailure:Y}=A;if(t.watch){const L=N.map(ue=>{const Pe=a.projects[ue]?.root;if(Pe)return Pe.startsWith("/")?Pe:`${o}/${Pe}`}).filter(ue=>ue!==void 0),U=H;let oe;const be=ue=>{const Se=io(U,ue);return oe=Se.filter,H=Se.tasks,Se.tasks.length};let fe=!1,ne=A.results;const Re=()=>{const ue=rs(ne,o);if(ue.directories.length>0&&ue.files.size>0){const Se=Nn(ue.files,o,ue.directories);return{handle:ns({filter:Se,onChange:Ze,paths:ue.directories}),mode:"tracked"}}return{handle:ns({onChange:Ze,paths:L}),mode:"roots"}};let je;const Ze=async ue=>{if(!fe){fe=!0;try{e.info(`Change detected in ${ue.length} file(s), rerunning…`),ne=(await D()).results,je?.close(),je=Re().handle}finally{fe=!1}}},qt=Re();je=qt.handle;const sr=qt.mode==="tracked"?`Watching ${String(rs(ne,o).files.size)} tracked file(s)`:`Watching ${String(L.length)} project root(s)`;e.info(`${sr} — edit a file to rerun, press h for keybinds, q to quit.`);const ft=async()=>{if(!fe){fe=!0;try{if(H.length===0){e.info("No tasks match the active filter — press a to clear it.");return}ne=(await D()).results,je?.close(),je=Re().handle}finally{fe=!1}}};await new Promise(ue=>{let Se=!1,Pe;const Vt=()=>{Ut()},Ut=()=>{Se||(Se=!0,Pe?.close(),process.off("SIGINT",Vt),je?.close(),ue())};process.on("SIGINT",Vt),Pe=lo({handlers:{onClearFilter:async()=>{const Ue=be(void 0);e.info(`Filter cleared — running ${String(Ue)} task(s).`),await ft()},onFilter:async Ue=>{const rr=oe,zt=be(Ue);if(zt===0){e.info(`Filter "${Ue}" matched no projects — keeping previous filter.`),be(rr);return}e.info(`Filter "${Ue}" matched ${String(zt)} task(s).`),await ft()},onHelp:()=>{co(process.stdout)},onQuit:()=>{Ut()},onRerun:ft}})});return}if(t.flaky){const L=Or(o,{minRuns:2},A.runHistory);if(L.length>0){e.info(""),e.info("Flaky tasks (based on historical runs):"),e.info("");for(const U of Ar(L))e.info(` ${U}`);e.info("")}}const V=[];for(const[L,U]of A.results)U.retryAttempts&&U.retryAttempts>0&&V.push(L);const O=t.failOnRetry&&V.length>0;if(O){const U=V.slice(0,5),oe=V.length-U.length,be=oe>0?`${U.join(", ")}, and ${String(oe)} more`:U.join(", ");e.warn(""),e.warn(`--fail-on-retry: ${String(V.length)} task(s) succeeded only after retry: ${be}`)}if(Y||O){const L=O&&!Y?"Some tasks succeeded only after retry (--fail-on-retry).":"Some tasks failed.",U=2e3,oe=[];for(const[be,fe]of A.results){if(fe.status!=="failure")continue;const ne=fe.terminalOutput??"",Re=ne.length>U?`…${ne.slice(-U)}`:ne,je=fe.code??"?";oe.push(` ${be} (exit ${String(je)}):
185
185
  ${Re.split(`
186
186
  `).map(Ze=>` ${Ze}`).join(`
187
187
  `)}`)}throw new Ke(oe.length>0?`${L}
188
188
  ${oe.join(`
189
- `)}`:L)}G.length>0&&!t.failFast&&await ks(G,o,F,i,void 0,Ie),he>0&&(e.info(""),Ve?e.info(`${String(he)} service(s) stopped (--stop-services).`):e.info(`${String(he)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))}}finally{Wt(),Ht&&(process.off("SIGINT",Qe),process.off("SIGTERM",Qe)),Ve&&ye.length>0&&await Promise.all(ye.map(async m=>{try{await an(o,m)}catch{}}))}};export{ec as createRetryBudget,Oc as default};
189
+ `)}`:L)}G.length>0&&!t.failFast&&await ks(G,o,F,i,void 0,Ie),he>0&&(e.info(""),Ve?e.info(`${String(he)} service(s) stopped (--stop-services).`):e.info(`${String(he)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))}}finally{Wt(),Ht&&(process.off("SIGINT",Qe),process.off("SIGTERM",Qe)),Ve&&ye.length>0&&await Promise.all(ye.map(async m=>{try{await an(o,m)}catch{}}))}};export{ec as createRetryBudget,Fc as default};