@visulima/vis 3.0.0 → 3.0.2

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 (306) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/LICENSE.md +5760 -4562
  3. package/dashboard/dist/index.html +12 -12
  4. package/dist/bin.js +1 -1
  5. package/dist/binx.js +2 -2
  6. package/dist/config/index.js +1 -1
  7. package/dist/packem_chunks/CONFIG_FILES.js +6 -6
  8. package/dist/packem_chunks/DEFAULT_CLEAN_KEEP.js +1 -1
  9. package/dist/packem_chunks/agent-instructions.js +7 -7
  10. package/dist/packem_chunks/bloom-status.js +2 -2
  11. package/dist/packem_chunks/bloom-sync.js +2 -2
  12. package/dist/packem_chunks/cache-attestation.js +1 -1
  13. package/dist/packem_chunks/catalog-detector.js +1 -1
  14. package/dist/packem_chunks/catalog.js +87 -111
  15. package/dist/packem_chunks/cli-exec.js +1 -1
  16. package/dist/packem_chunks/cli-main.js +192 -217
  17. package/dist/packem_chunks/defineReleasePlugin.js +3 -3
  18. package/dist/packem_chunks/detect.js +8 -3
  19. package/dist/packem_chunks/devtools.js +1 -1
  20. package/dist/packem_chunks/discord.js +4 -4
  21. package/dist/packem_chunks/dispatch.js +4 -4
  22. package/dist/packem_chunks/doctor-probe.js +2 -2
  23. package/dist/packem_chunks/extra-files.js +3 -3
  24. package/dist/packem_chunks/fix.js +11 -11
  25. package/dist/packem_chunks/git.js +3 -3
  26. package/dist/packem_chunks/group-tags.js +1 -1
  27. package/dist/packem_chunks/handler.js +1 -1
  28. package/dist/packem_chunks/handler10.js +5 -5
  29. package/dist/packem_chunks/handler11.js +1 -1
  30. package/dist/packem_chunks/handler12.js +16 -16
  31. package/dist/packem_chunks/handler13.js +5 -5
  32. package/dist/packem_chunks/handler14.js +1 -1
  33. package/dist/packem_chunks/handler15.js +1 -1
  34. package/dist/packem_chunks/handler16.js +1 -1
  35. package/dist/packem_chunks/handler17.js +1 -1
  36. package/dist/packem_chunks/handler18.js +1 -1
  37. package/dist/packem_chunks/handler19.js +5 -5
  38. package/dist/packem_chunks/handler2.js +1 -1
  39. package/dist/packem_chunks/handler20.js +2 -2
  40. package/dist/packem_chunks/handler21.js +2 -2
  41. package/dist/packem_chunks/handler22.js +8 -8
  42. package/dist/packem_chunks/handler23.js +1 -1
  43. package/dist/packem_chunks/handler24.js +1 -1
  44. package/dist/packem_chunks/handler25.js +1 -1
  45. package/dist/packem_chunks/handler26.js +5 -5
  46. package/dist/packem_chunks/handler27.js +1 -1
  47. package/dist/packem_chunks/handler28.js +3 -3
  48. package/dist/packem_chunks/handler29.js +1 -1
  49. package/dist/packem_chunks/handler3.js +2 -2
  50. package/dist/packem_chunks/handler30.js +1 -1
  51. package/dist/packem_chunks/handler31.js +2 -2
  52. package/dist/packem_chunks/handler32.js +2 -2
  53. package/dist/packem_chunks/handler33.js +2 -2
  54. package/dist/packem_chunks/handler34.js +3 -3
  55. package/dist/packem_chunks/handler35.js +5 -5
  56. package/dist/packem_chunks/handler36.js +1 -1
  57. package/dist/packem_chunks/handler37.js +2 -2
  58. package/dist/packem_chunks/handler38.js +6 -6
  59. package/dist/packem_chunks/handler39.js +8 -8
  60. package/dist/packem_chunks/handler4.js +4 -4
  61. package/dist/packem_chunks/handler40.js +34 -34
  62. package/dist/packem_chunks/handler41.js +5 -5
  63. package/dist/packem_chunks/handler42.js +4 -4
  64. package/dist/packem_chunks/handler43.js +3 -3
  65. package/dist/packem_chunks/handler44.js +2 -2
  66. package/dist/packem_chunks/handler45.js +1 -1
  67. package/dist/packem_chunks/handler46.js +1 -1
  68. package/dist/packem_chunks/handler47.js +1 -1
  69. package/dist/packem_chunks/handler48.js +3 -3
  70. package/dist/packem_chunks/handler49.js +1 -1
  71. package/dist/packem_chunks/handler5.js +6 -6
  72. package/dist/packem_chunks/handler50.js +6 -6
  73. package/dist/packem_chunks/handler51.js +13 -13
  74. package/dist/packem_chunks/handler52.js +3 -3
  75. package/dist/packem_chunks/handler53.js +5 -5
  76. package/dist/packem_chunks/handler54.js +2 -2
  77. package/dist/packem_chunks/handler55.js +1 -1
  78. package/dist/packem_chunks/handler56.js +4 -4
  79. package/dist/packem_chunks/handler57.js +5 -5
  80. package/dist/packem_chunks/handler58.js +5 -5
  81. package/dist/packem_chunks/handler59.js +8 -8
  82. package/dist/packem_chunks/handler6.js +7 -7
  83. package/dist/packem_chunks/handler60.js +3 -3
  84. package/dist/packem_chunks/handler61.js +21 -21
  85. package/dist/packem_chunks/handler62.js +12 -12
  86. package/dist/packem_chunks/handler63.js +3 -3
  87. package/dist/packem_chunks/handler64.js +5 -5
  88. package/dist/packem_chunks/handler65.js +8 -8
  89. package/dist/packem_chunks/handler66.js +2 -2
  90. package/dist/packem_chunks/handler67.js +25 -24
  91. package/dist/packem_chunks/handler68.js +153 -25
  92. package/dist/packem_chunks/handler69.js +10 -153
  93. package/dist/packem_chunks/handler7.js +1 -1
  94. package/dist/packem_chunks/handler70.js +22 -10
  95. package/dist/packem_chunks/handler71.js +17 -17
  96. package/dist/packem_chunks/handler72.js +104 -104
  97. package/dist/packem_chunks/handler73.js +20 -20
  98. package/dist/packem_chunks/handler74.js +45 -45
  99. package/dist/packem_chunks/handler75.js +27 -3
  100. package/dist/packem_chunks/handler76.js +3 -27
  101. package/dist/packem_chunks/handler77.js +68 -68
  102. package/dist/packem_chunks/handler78.js +30 -30
  103. package/dist/packem_chunks/handler8.js +1 -1
  104. package/dist/packem_chunks/handler9.js +1 -1
  105. package/dist/packem_chunks/heal-accept.js +9 -9
  106. package/dist/packem_chunks/heal.js +11 -11
  107. package/dist/packem_chunks/help-command.js +7 -63
  108. package/dist/packem_chunks/index.js +1 -1
  109. package/dist/packem_chunks/index2.js +48 -804
  110. package/dist/packem_chunks/index3.js +3 -7
  111. package/dist/packem_chunks/index4.js +801 -134
  112. package/dist/packem_chunks/index5.js +7 -73
  113. package/dist/packem_chunks/index6.js +73 -0
  114. package/dist/packem_chunks/index7.js +135 -0
  115. package/dist/packem_chunks/interface.js +2 -2
  116. package/dist/packem_chunks/keys-refresh.js +4 -4
  117. package/dist/packem_chunks/lean.js +3 -3
  118. package/dist/packem_chunks/list.js +3 -3
  119. package/dist/packem_chunks/loader.js +4 -4
  120. package/dist/packem_chunks/loader2.js +1 -1
  121. package/dist/packem_chunks/orchestrator.js +27 -27
  122. package/dist/packem_chunks/pre-mode.js +2 -2
  123. package/dist/packem_chunks/print-config.js +1 -1
  124. package/dist/packem_chunks/prompts.js +7 -7
  125. package/dist/packem_chunks/prune.js +3 -3
  126. package/dist/packem_chunks/publish-guards.js +1 -1
  127. package/dist/packem_chunks/resolveFormatter.js +5 -5
  128. package/dist/packem_chunks/run.js +1 -1
  129. package/dist/packem_chunks/security.js +1 -1
  130. package/dist/packem_chunks/shell-runner.js +1 -1
  131. package/dist/packem_chunks/slack.js +2 -2
  132. package/dist/packem_chunks/snapshot.js +2 -2
  133. package/dist/packem_chunks/stage-publisher.js +1 -1
  134. package/dist/packem_chunks/staged-registry.js +2 -2
  135. package/dist/packem_chunks/state.js +3 -3
  136. package/dist/packem_chunks/status.js +2 -2
  137. package/dist/packem_chunks/success-walk.js +4 -4
  138. package/dist/packem_chunks/sync.js +2 -2
  139. package/dist/packem_chunks/sync2.js +2 -2
  140. package/dist/packem_chunks/tar.js +3 -3
  141. package/dist/packem_chunks/tripwire.js +2 -2
  142. package/dist/packem_chunks/ts-loader.js +5 -9
  143. package/dist/packem_chunks/verify-lockfile.js +2 -2
  144. package/dist/packem_chunks/version-resolver.js +2 -2
  145. package/dist/packem_chunks/webhook.js +1 -1
  146. package/dist/packem_chunks/workflow-templates.js +5 -5
  147. package/dist/packem_chunks/workspace.js +2 -2
  148. package/dist/packem_shared/ReleaseClient-DAvbxCdo.js +1 -0
  149. package/dist/packem_shared/Table-DyORjLji-CC9cYgCG.js +11 -0
  150. package/dist/packem_shared/{VisReleaseError-DMGRBTNO.js → VisReleaseError-DZtgcKf8.js} +1 -1
  151. package/dist/packem_shared/_commonjsHelpers-DTfxOvZk.js +1 -0
  152. package/dist/packem_shared/advisories-DZd1uGqa.js +1 -0
  153. package/dist/packem_shared/affected-selection-CoRXp5H4.js +1 -0
  154. package/dist/packem_shared/affected-shas-Dd0P7fGD.js +1 -0
  155. package/dist/packem_shared/ai-analysis-DSQQDFU9.js +68 -0
  156. package/dist/packem_shared/ai-fix-6nXZbecQ.js +43 -0
  157. package/dist/packem_shared/augment-COAiXSIx.js +4 -0
  158. package/dist/packem_shared/bin-C2eYtJ_N.js +1 -0
  159. package/dist/packem_shared/build-scripts-pdVmqXRm.js +1 -0
  160. package/dist/packem_shared/clean-DRiLimTx.js +1 -0
  161. package/dist/packem_shared/command-runtime-CiLVo4ED.js +1 -0
  162. package/dist/packem_shared/{compile-cache-B_Vf_WxT.js → compile-cache-DoMHRsRZ.js} +1 -1
  163. package/dist/packem_shared/createAdapter-F7GidOzU.js +1 -0
  164. package/dist/packem_shared/createVersionActions-ByaJ1Nbv.js +1 -0
  165. package/dist/packem_shared/cyclonedx-B1vzerwP.js +4 -0
  166. package/dist/packem_shared/dependency-scan-DBH2Qo4I.js +1 -0
  167. package/dist/packem_shared/docker-Bex05Qcn.js +59 -0
  168. package/dist/packem_shared/failure-log-D92tM0ie.js +2 -0
  169. package/dist/packem_shared/formatBytes-BHAzNIrn-DFIppnY0.js +4 -0
  170. package/dist/packem_shared/getRandomSpinner-4ZEcbTYv-DCyIuj19.js +1 -0
  171. package/dist/packem_shared/giget-D8Kwb0kD.js +2 -0
  172. package/dist/packem_shared/glob-Cyk1H9ZL-ox19CSsT.js +1 -0
  173. package/dist/packem_shared/index-B4AjSxHU.js +1 -0
  174. package/dist/packem_shared/index-BisalDCf.js +39 -0
  175. package/dist/packem_shared/{index-BWl4DbMp.js → index-BjdW45xX.js} +1 -1
  176. package/dist/packem_shared/index-DHD8wb6Z.js +22 -0
  177. package/dist/packem_shared/index-DXPSWMbG.js +1 -0
  178. package/dist/packem_shared/index.server-BAjDJSEu.js +2 -0
  179. package/dist/packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js +1 -0
  180. package/dist/packem_shared/license-DvlYdo6T.js +1 -0
  181. package/dist/packem_shared/lifecycle-CfTZQHOG.js +2 -0
  182. package/dist/packem_shared/lockfile-35RFsJDs.js +1 -0
  183. package/dist/packem_shared/lockfile-DhHAaHN5.js +1 -0
  184. package/dist/packem_shared/main-BP-w-K-6.js +1 -0
  185. package/dist/packem_shared/manifests-BNSmpPF_.js +1 -0
  186. package/dist/packem_shared/min-release-age-ChzTC7_I.js +34 -0
  187. package/dist/packem_shared/missing-package-json-C0keIt78.js +1 -0
  188. package/dist/packem_shared/native-config-sync-BSzU4qUO.js +21 -0
  189. package/dist/packem_shared/osv-bloom-1JS__1or.js +2 -0
  190. package/dist/packem_shared/otelPlugin-D8LL2-4L.js +1 -0
  191. package/dist/packem_shared/package-version-Bb7KGF36.js +4 -0
  192. package/dist/packem_shared/packument-C55kVxcQ.js +1 -0
  193. package/dist/packem_shared/{peer-warnings-BXAzXqY3.js → peer-warnings-CmYSxvql.js} +1 -1
  194. package/dist/packem_shared/pm-runner-de-jCq8q.js +1 -0
  195. package/dist/packem_shared/project-name-filter-DYaIbrXa.js +7 -0
  196. package/dist/packem_shared/{prompt-BSAy8SMH.js → prompt-DMzaQEVa.js} +1 -1
  197. package/dist/packem_shared/provenance-CvfQEJPQ.js +1 -0
  198. package/dist/packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js +1 -0
  199. package/dist/packem_shared/registry-keys-DmBrAlhg.js +1 -0
  200. package/dist/packem_shared/resolve-explicit-DYaHAVDg.js +5 -0
  201. package/dist/packem_shared/resolve-runtime-C7NBCA1C.js +1 -0
  202. package/dist/packem_shared/run-file-jMngGQhs.js +1 -0
  203. package/dist/packem_shared/runtime-check-BklgEMkC.js +1 -0
  204. package/dist/packem_shared/s1ngularity-C8sva2SO.js +1 -0
  205. package/dist/packem_shared/scan-progress-aVHGZYWf.js +2 -0
  206. package/dist/packem_shared/selectors-B7lSFz7l.js +3 -0
  207. package/dist/packem_shared/signatures-oZ_2IneN.js +2 -0
  208. package/dist/packem_shared/{slug-DoueYuLo.js → slug-OBHcH7wV.js} +1 -1
  209. package/dist/packem_shared/spinner-CbJfWYwB.js +1 -0
  210. package/dist/packem_shared/sticky-comment-DjhyCIZt.js +1 -0
  211. package/dist/packem_shared/subtree-DtmcKAJK.js +2 -0
  212. package/dist/packem_shared/symbols-BXDZ_sKt.js +1 -0
  213. package/dist/packem_shared/tabs-BilwonkM.js +1 -0
  214. package/dist/packem_shared/target-merge-DCGow6Kw.js +4 -0
  215. package/dist/packem_shared/target-options-d_rIrLyq.js +1 -0
  216. package/dist/packem_shared/toolchain-DY11tPCw.js +5 -0
  217. package/dist/packem_shared/typosquats-Cdsnf6aN.js +1 -0
  218. package/dist/packem_shared/use-measured-height-BPQg2q_p.js +1 -0
  219. package/dist/packem_shared/utils-DQFHJn72.js +1 -0
  220. package/dist/packem_shared/verify-D8wYvB85.js +1 -0
  221. package/dist/packem_shared/vis-update-app-ngwL2mRv.js +1 -0
  222. package/dist/packem_shared/vis-user-error-CAu9wIbe.js +30 -0
  223. package/dist/packem_shared/watch-Dswvj6Zp.js +1 -0
  224. package/dist/packem_shared/watch-loop-COWvvSbR.js +11 -0
  225. package/dist/packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js +1 -0
  226. package/dist/release/core/changelog/index.d.ts +62 -2
  227. package/dist/release/core/package-managers/index.d.ts +25 -1
  228. package/dist/release/core/package-managers/index.js +1 -1
  229. package/dist/release/core/version-actions/index.d.ts +47 -2
  230. package/dist/release/core/version-actions/index.js +1 -1
  231. package/dist/release/index.d.ts +100 -1
  232. package/dist/release/index.js +1 -1
  233. package/dist/release/plugin-sdk.d.ts +16 -1
  234. package/dist/release/plugin-sdk.js +1 -1
  235. package/dist/release/presets.js +1 -1
  236. package/dist/release/types.js +1 -1
  237. package/dist/runtime/preload.js +1 -1
  238. package/index.js +26 -26
  239. package/package.json +14 -14
  240. package/dist/packem_chunks/detect2.js +0 -8
  241. package/dist/packem_chunks/registry.js +0 -48
  242. package/dist/packem_shared/ReleaseClient-BY4OZNCK.js +0 -1
  243. package/dist/packem_shared/_commonjsHelpers-B5Y90VFO.js +0 -1
  244. package/dist/packem_shared/advisories-DsXRmIA5.js +0 -1
  245. package/dist/packem_shared/affected-selection-BE6VFCDV.js +0 -1
  246. package/dist/packem_shared/affected-shas-BKEu4RZc.js +0 -1
  247. package/dist/packem_shared/ai-analysis-DikAj6rX.js +0 -68
  248. package/dist/packem_shared/ai-fix-bfWo0cZX.js +0 -43
  249. package/dist/packem_shared/augment-BkJxi_GW.js +0 -4
  250. package/dist/packem_shared/bin-B-TytgzW.js +0 -1
  251. package/dist/packem_shared/build-scripts-DWypBQ--.js +0 -1
  252. package/dist/packem_shared/clean-DWjQl14S.js +0 -1
  253. package/dist/packem_shared/command-runtime-DQ7ZpLYL.js +0 -1
  254. package/dist/packem_shared/createAdapter-bU4DIP3F.js +0 -1
  255. package/dist/packem_shared/createVersionActions-BK43SNDH.js +0 -1
  256. package/dist/packem_shared/cyclonedx-DLBi65MV.js +0 -4
  257. package/dist/packem_shared/dependency-scan-ZLOuLkGN.js +0 -1
  258. package/dist/packem_shared/docker-B4zAZCZG.js +0 -59
  259. package/dist/packem_shared/en-BDYMmM2_.js +0 -27
  260. package/dist/packem_shared/failure-log-DyhWPqno.js +0 -2
  261. package/dist/packem_shared/giget-CAxjpwew.js +0 -2
  262. package/dist/packem_shared/glob-BUjyjdE8-Dp_QcayW.js +0 -1
  263. package/dist/packem_shared/index-BAe6e0XE.js +0 -1
  264. package/dist/packem_shared/index-BLtnel38.js +0 -35
  265. package/dist/packem_shared/index-CuKDxOCI.js +0 -1
  266. package/dist/packem_shared/index-tNFGWxc0.js +0 -39
  267. package/dist/packem_shared/index.server-CusjRLCh.js +0 -2
  268. package/dist/packem_shared/license-t5KnNX6v.js +0 -1
  269. package/dist/packem_shared/lifecycle-KY9umOg6.js +0 -2
  270. package/dist/packem_shared/lockfile-YAuZf1gh.js +0 -1
  271. package/dist/packem_shared/main-D_cam4hv.js +0 -1
  272. package/dist/packem_shared/manifests-BwTn_1ad.js +0 -1
  273. package/dist/packem_shared/min-release-age-6avfn81h.js +0 -34
  274. package/dist/packem_shared/missing-package-json-Cl0vdz6K.js +0 -1
  275. package/dist/packem_shared/native-config-sync-CHMCJx7H.js +0 -21
  276. package/dist/packem_shared/osv-bloom-DdqDnLCt.js +0 -2
  277. package/dist/packem_shared/otelPlugin-DmKDBaPo.js +0 -1
  278. package/dist/packem_shared/package-version-BNRJ3o9C.js +0 -4
  279. package/dist/packem_shared/packument-B9-WqReu.js +0 -1
  280. package/dist/packem_shared/pm-runner-DRybtzOV.js +0 -1
  281. package/dist/packem_shared/project-name-filter-Dw0fC6IO.js +0 -7
  282. package/dist/packem_shared/provenance-CLxuqCfL.js +0 -1
  283. package/dist/packem_shared/readJsonSync-DweZd5ZA-CtrDlqpb.js +0 -1
  284. package/dist/packem_shared/registry-keys-cTN24144.js +0 -1
  285. package/dist/packem_shared/resolve-explicit-Uw6WQl9R.js +0 -5
  286. package/dist/packem_shared/resolve-runtime-DztanwkZ.js +0 -1
  287. package/dist/packem_shared/run-file-CaE5_xBY.js +0 -1
  288. package/dist/packem_shared/runtime-check-C32yE57I.js +0 -1
  289. package/dist/packem_shared/s1ngularity-BIYhg82u.js +0 -1
  290. package/dist/packem_shared/scan-progress-DWfY4zkp.js +0 -2
  291. package/dist/packem_shared/selectors-D2j4M9Ul.js +0 -3
  292. package/dist/packem_shared/signatures-C8iQ5fUq.js +0 -2
  293. package/dist/packem_shared/sticky-comment-D6_7-w8T.js +0 -1
  294. package/dist/packem_shared/subtree-DSm0QEoE.js +0 -2
  295. package/dist/packem_shared/symbols-DPTlrJ3B.js +0 -1
  296. package/dist/packem_shared/target-merge-DLxJTcxn.js +0 -11
  297. package/dist/packem_shared/target-options-3t4-2F-F.js +0 -1
  298. package/dist/packem_shared/toolchain-BPzbahcQ.js +0 -5
  299. package/dist/packem_shared/typosquats-BWrmhh36.js +0 -1
  300. package/dist/packem_shared/use-measured-height-BwAwGHjw.js +0 -1
  301. package/dist/packem_shared/utils-CRueU43T.js +0 -1
  302. package/dist/packem_shared/verify-CzUPT6Uk.js +0 -1
  303. package/dist/packem_shared/vis-update-app-D6Wq8ZHM.js +0 -1
  304. package/dist/packem_shared/vis-user-error-CfM4_ORo.js +0 -30
  305. package/dist/packem_shared/watch-D_oAxW_Z.js +0 -1
  306. package/dist/packem_shared/watch-loop-BrjblOz5.js +0 -11
@@ -1,57 +1,57 @@
1
- import{createRequire as sr}from"node:module";import{w as oe,J as $s,K as nr,b as or,j as bs,z as ar,r as cr}from"../packem_shared/index-BLtnel38.js";import{expandAffected as lr,getChangedFiles as dr,buildEnhancedPath as ur,enforceProjectConstraints as hr,expandTokensInString as Ht,parsePartition as fr,TaskScheduler as pr,createTaskGraph as gr,reverseTaskGraph as mr,resolveTurboEnvCompat as wr,CompositeLifeCycle as Yt,defaultTaskRunner as Jt,createLogReporter as vr,readLastRunSummary as yr,getLastRunSummaryPath as kr,runConcurrently as Ze,generateRunSummary as Kt,writeChromeTrace as xr,writeRunSummary as jr,TerminalBuffer as wt}from"@visulima/task-runner";import{I as Ve}from"../packem_shared/index-BWl4DbMp.js";import{J as $r,I as br,K as Xt,M as Sr,P as Tr,ah as Ir,b as Cr,ai as Rr,aj as Er,ak as Mr,al as Fr}from"./cli-main.js";import{r as H,l as i,m,i as c,h as he,R as X,X as Pr,C as Or,v as Ar,S as Dr}from"./catalog.js";import{a as Xe}from"../packem_shared/vis-user-error-CfM4_ORo.js";import{d as Br,r as Lr}from"../packem_shared/lockfile-YAuZf1gh.js";import{I as Ss}from"../packem_shared/index-tNFGWxc0.js";import{F as Vr}from"../packem_shared/failure-log-DyhWPqno.js";import{r as Hr}from"../packem_shared/command-runtime-DQ7ZpLYL.js";import{r as Yr}from"../packem_shared/toolchain-BPzbahcQ.js";import{i as Jr,r as Kr,s as Xr,a as Qr,c as Zr,d as ei,e as ti,H as si,f as ri,b as ii}from"../packem_shared/lifecycle-KY9umOg6.js";import{s as ni}from"../packem_shared/affected-selection-BE6VFCDV.js";import{c as Zt,p as oi,a as ai,b as ci,r as li,f as di,s as ui}from"../packem_shared/project-name-filter-Dw0fC6IO.js";import{p as hi,r as fi,f as pi,a as gi}from"../packem_shared/selectors-D2j4M9Ul.js";import{r as ot,l as yt,d as mi,s as wi,m as vi,a as yi}from"../packem_shared/target-options-3t4-2F-F.js";import{o as ki,l as xi,c as et}from"../packem_shared/en-BDYMmM2_.js";import{T as Ts,C as Is,D as at,E as Cs}from"../packem_shared/symbols-DPTlrJ3B.js";import{Dialog as ji}from"@visulima/tui-kit/dialog";import{V as ut,E as ts,q as Ii,j as Ci}from"../packem_shared/index.server-CusjRLCh.js";import{parseStacktrace as Ri,codeFrame as Ei}from"@visulima/error";import{originalPositionFor as Mi,sourceContentFor as Fi,loadSourceMap as Pi}from"@visulima/source-map";import{ScrollView as Rs}from"@visulima/tui-kit/scroll-view";import{Spinner as Es}from"@visulima/tui-kit/spinner";import{c as ss,a as Li,s as rs}from"../packem_shared/watch-D_oAxW_Z.js";import pt from"./index.js";let rr;const ir=s=>(rr??=sr(import.meta.url))(s),ze=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ee=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 ir(s)},{existsSync:Ae,mkdirSync:Nr,writeFileSync:vt,readFileSync:Ge,openSync:Gr,statSync:Qt,readSync:_r,closeSync:qr,mkdtempSync:Wr}=Ee("node:fs"),{createInterface:Ur,emitKeypressEvents:zr}=Ee("node:readline"),{isAbsolute:$i,resolve:es,dirname:bi,relative:Si}=Ee("node:path"),{fileURLToPath:Ti}=Ee("node:url"),{createHash:Oi}=Ee("node:crypto"),{mkdir:Ai,appendFile:ct}=Ee("node:fs/promises"),{platform:Di,homedir:kt,tmpdir:Bi}=Ee("node:os"),{spawn:Ni}=Ee("node:child_process"),Ms=s=>s===155||s===157||s===144||s===152||s===158||s===159,Fs=(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},tt=(s,e,t)=>{for(let r=e;r<s.length;r+=1){const a=s.codePointAt(r);if(a===156||t&&a===7)return r;if(a===27&&s.codePointAt(r+1)===92)return r+1}return-1},Gi=(s,e)=>{const t=s.codePointAt(e+1);return t===91?Fs(s,e+2):t===93?tt(s,e+2,!0):t===80||t===88||t===94||t===95?tt(s,e+2,!1):t!==void 0?e+1:-1},_i=(s,e)=>{const t=s.codePointAt(e);return t===155?Fs(s,e+1):t===157?tt(s,e+1,!0):t===144||t===152||t===158||t===159?tt(s,e+1,!1):-1},qi=s=>{if(s.includes(String.fromCodePoint(27)))return!0;for(let e=0;e<s.length;e+=1)if(Ms(s.codePointAt(e)))return!0;return!1},Wi=s=>{if(!qi(s))return s;let e="",t=0,r=0;const{length:a}=s;for(;r<a;){const o=s.codePointAt(r);let n;if(o===27)n=Gi(s,r);else if(Ms(o))n=_i(s,r);else{r+=1;continue}n===-1&&(n=a-1),e+=s.slice(t,r),t=n+1,r=n+1}return e+=s.slice(t),e},is=new WeakSet,Ui=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)},Ps=(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},ns=({unitCount:s,unitName:e},t,r)=>{let{spacer:a}=r;const{maxDecimalPoints:o}=r;let n=".";r.decimal!==void 0?n=r.decimal:t.decimal!==void 0&&(n=t.decimal);let d;"digitReplacements"in r?d=r.digitReplacements:"_digitReplacements"in t&&(d=t._digitReplacements);let u,g=s;o!==void 0&&(g=Ps(s,o));const h=g.toString();if(!t._hideCountIf2||s!==2)if(d){u="";for(const j of h)u+=j==="."?n:d[j]}else u=h.replace(".",n);else u="";const f=t[e];let l=f;return typeof f=="function"&&(l=f(s)),t._hideCountIf2&&s===2&&(a=""),t._numberFirst?l+a+u:u+a+l},zi=(s,e)=>{const{units:t}=e;if(t.length===0)return[];const{unitMeasures:r}=e,a=e.largest??Number.POSITIVE_INFINITY,o={};let n,d,u,g=s;for(d=0;d<t.length;d++){n=t[d];const f=r[n];u=d===t.length-1?g/f:Math.floor(g/f),o[n]=u,g-=u*f}if(e.round){let f=a;for(d=0;d<t.length;d++)if(n=t[d],u=o[n],u!==0&&(f--,f===0)){for(let l=d+1;l<t.length;l++){const j=t[l],C=o[j];o[n]=(o[n]??0)+C*r[j]/r[n],o[j]=0}break}for(d=t.length-1;d>=0;d--){if(n=t[d],u=o[n],u===0)continue;const l=Math.round(u);if(o[n]=l,d===0)break;const j=t[d-1],C=r[j],U=Math.floor(l*r[n]/C);if(U)o[j]=(o[j]??0)+U,o[n]=0;else break}}const h=[];for(d=0;d<t.length&&h.length<a;d++){if(n=t[d],u=o[n],u&&!e.round&&h.length===a-1){let f,l=0;for(f=d+1,t.length;f<t.length;f++){const j=t[f];l+=o[j]*(e.unitMeasures[j]/e.unitMeasures[n])}u+=l,e.maxDecimalPoints!==void 0&&(u=Ps(u,e.maxDecimalPoints))}u&&h.push({unitCount:u,unitName:n})}return h},Vi=(s,e,t)=>{const{language:r,units:a}=e;if(s.length===0){const f=a.at(-1);return ns({unitCount:0,unitName:f},r,e)}const{conjunction:o,serialComma:n}=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 g=s.map(f=>ns(f,r,e));let h;return!o||s.length===1?h=g.join(d):s.length===2?h=g.join(o):h=g.slice(0,-1).join(d)+(n?",":"")+o+(g.at(-1)??""),u&&(h=u.replace("%s",h)),h},Hi=(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:ki,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};Ui(t.language);const r=Math.abs(s),a=zi(r,t);return Vi(a,t,s)},be="@voidzero-dev/vite-task-client",xt="@visulima/task-runner-client",st=`npm:${xt}@^1`,Os=oe(".vis",".vite-client-override-declined"),rt="pnpm-workspace.yaml",Yi=["dependencies","devDependencies","optionalDependencies","peerDependencies"],As=s=>{try{return JSON.parse(Ge(s,"utf8"))}catch{return}},Ji=s=>{const e=oe(s,rt);if(Ae(e))try{return Ss(Ge(e,"utf8")).toJS()?.overrides}catch{return}},Ki=s=>s==="pnpm"||s==="aube"?"pnpm.overrides":s==="yarn"?"resolutions":"overrides",Xi=s=>{const e=oe(s,rt);try{const t=Ss(Ge(e,"utf8"));return t.setIn(["overrides",be],st),vt(e,t.toString()),!0}catch{return!1}},os=s=>s!==void 0&&Yi.some(e=>s[e]?.[be]!==void 0),Qi=(s,e)=>s!==void 0&&(s.pnpm?.overrides?.[be]!==void 0||s.overrides?.[be]!==void 0||s.resolutions?.[be]!==void 0)||e?.[be]!==void 0,Zi=(s,e=[])=>{const t=As(oe(s,"package.json")),r=Ae(oe(s,"node_modules","@voidzero-dev","vite-task-client"));return{alreadyOverridden:Qi(t,Ji(s)),declined:Ae(oe(s,Os)),manager:Br(s)?.manager,present:os(t)||r||e.some(a=>os(a))}},en=s=>{try{const e=oe(s,Os);Nr($s(e),{recursive:!0}),vt(e,`Declined adding the ${be} → ${xt} override.
1
+ import{createRequire as rr}from"node:module";import{e as ue,m as Ss,$ as or,a as cr,z as ar}from"../packem_shared/index-DHD8wb6Z.js";import{expandAffected as lr,getChangedFiles as dr,buildEnhancedPath as ur,enforceProjectConstraints as fr,expandTokensInString as zt,parsePartition as hr,TaskScheduler as pr,createTaskGraph as mr,reverseTaskGraph as gr,resolveTurboEnvCompat as wr,CompositeLifeCycle as Yt,defaultTaskRunner as Kt,TerminalBuffer as vt,runConcurrently as tt,createLogReporter as yr,generateRunSummary as Xt,writeRunSummary as vr,readLastRunSummary as xr,getLastRunSummaryPath as jr,writeChromeTrace as kr}from"@visulima/task-runner";import{i as Ye}from"../packem_shared/index-BjdW45xX.js";import{U as Ts,W as br,T as Sr,u as Jt,X as Tr,Y as $r,C as Ir,Z as Cr,ao as Er,ap as Rr,aq as Pr,ar as Mr,j as Fr,as as Or}from"./cli-main.js";import{u as U,y as n,X as g,m as a,E as me,R as J,w as Ar,d as Lr,b as Dr,Q as Br}from"./catalog.js";import{V as Ze}from"../packem_shared/vis-user-error-CAu9wIbe.js";import{d as _r,r as Nr}from"../packem_shared/lockfile-35RFsJDs.js";import{y as $s}from"../packem_shared/index-BisalDCf.js";import{F as Yr}from"../packem_shared/failure-log-D92tM0ie.js";import{r as Kr}from"../packem_shared/command-runtime-CiLVo4ED.js";import{r as Xr}from"../packem_shared/toolchain-DY11tPCw.js";import{i as Jr,r as Qr,s as Zr,a as en,b as tn,c as sn,d as rn,e as nn,H as on,f as cn}from"../packem_shared/lifecycle-CfTZQHOG.js";import{s as an}from"../packem_shared/affected-selection-CoRXp5H4.js";import{c as Zt,p as ln,a as dn,b as un,r as fn,f as hn,s as pn}from"../packem_shared/project-name-filter-DYaIbrXa.js";import{p as mn,r as gn,f as wn,a as yn}from"../packem_shared/selectors-B7lSFz7l.js";import{r as at,l as jt,d as vn,s as xn,m as jn,a as kn}from"../packem_shared/target-options-d_rIrLyq.js";import{T as Is,C as Cs,D as lt,E as Es}from"../packem_shared/symbols-BXDZ_sKt.js";import{q as In,j as Cn,X as ht,F as ts}from"../packem_shared/index.server-BAjDJSEu.js";import{parseStacktrace as En,codeFrame as Rn}from"@visulima/error";import{originalPositionFor as Pn,sourceContentFor as Mn,loadSourceMap as Fn}from"@visulima/source-map";import{l as Rs}from"../packem_shared/spinner-CbJfWYwB.js";import{R as Bn,c as st}from"../packem_shared/formatBytes-BHAzNIrn-DFIppnY0.js";import{c as ss,a as _n,s as rs}from"../packem_shared/watch-Dswvj6Zp.js";import gt from"./index.js";import{U as Ps}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";let nr;const ir=s=>(nr??=rr(import.meta.url))(s),ze=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Pe=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 ir(s)},{existsSync:De,mkdirSync:Gr,writeFileSync:xt,readFileSync:We,openSync:Wr,statSync:Qt,readSync:Hr,closeSync:qr,mkdtempSync:Vr}=Pe("node:fs"),{createInterface:Ur,emitKeypressEvents:zr}=Pe("node:readline"),{isAbsolute:bn,resolve:es,dirname:Sn,relative:Tn}=Pe("node:path"),{fileURLToPath:$n}=Pe("node:url"),{createHash:On}=Pe("node:crypto"),{mkdir:An,appendFile:dt}=Pe("node:fs/promises"),{platform:Ln,homedir:kt,tmpdir:Dn}=Pe("node:os"),{spawn:Nn}=Pe("node:child_process"),Ms=s=>s===155||s===157||s===144||s===152||s===158||s===159,Fs=(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},Gn=(s,e)=>{const t=s.codePointAt(e+1);return t===91?Fs(s,e+2):t===93?rt(s,e+2,!0):t===80||t===88||t===94||t===95?rt(s,e+2,!1):t!==void 0?e+1:-1},Wn=(s,e)=>{const t=s.codePointAt(e);return t===155?Fs(s,e+1):t===157?rt(s,e+1,!0):t===144||t===152||t===158||t===159?rt(s,e+1,!1):-1},Hn=s=>{if(s.includes(String.fromCodePoint(27)))return!0;for(let e=0;e<s.length;e+=1)if(Ms(s.codePointAt(e)))return!0;return!1},qn=s=>{if(!Hn(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===27)i=Gn(s,r);else if(Ms(o))i=Wn(s,r);else{r+=1;continue}i===-1&&(i=c-1),e+=s.slice(t,r),t=i+1,r=i+1}return e+=s.slice(t),e},Vn=(s,e,t,r,c,o,i,d,u,p,f,h,l,b)=>{const T={d:r,h:c,m:o,mo:e,ms:d,s:i,w:t,y:s};return T.future=u,T.past=p,T.decimal=f,h!==void 0&&(T.unitMap=h),T.groupSeparator=l,T.placeholderSeparator=b,T},Un={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"},zn=Vn(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",".",Un,",","_"),ns=new WeakSet,Yn=s=>{if(ns.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");ns.add(s)},Os=(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},is=({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,p=s;o!==void 0&&(p=Os(s,o));const f=p.toString();if(!t._hideCountIf2||s!==2)if(d){u="";for(const b of f)u+=b==="."?i:d[b]}else u=f.replace(".",i);else u="";const h=t[e];let l=h;return typeof h=="function"&&(l=h(s)),t._hideCountIf2&&s===2&&(c=""),t._numberFirst?l+c+u:u+c+l},Kn=(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,p=s;for(d=0;d<t.length;d++){i=t[d];const h=r[i];u=d===t.length-1?p/h:Math.floor(p/h),o[i]=u,p-=u*h}if(e.round){let h=c;for(d=0;d<t.length;d++)if(i=t[d],u=o[i],u!==0&&(h--,h===0)){for(let l=d+1;l<t.length;l++){const b=t[l],T=o[b];o[i]=(o[i]??0)+T*r[b]/r[i],o[b]=0}break}for(d=t.length-1;d>=0;d--){if(i=t[d],u=o[i],u===0)continue;const l=Math.round(u);if(o[i]=l,d===0)break;const b=t[d-1],T=r[b],N=Math.floor(l*r[i]/T);if(N)o[b]=(o[b]??0)+N,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 h,l=0;for(h=d+1,t.length;h<t.length;h++){const b=t[h];l+=o[b]*(e.unitMeasures[b]/e.unitMeasures[i])}u+=l,e.maxDecimalPoints!==void 0&&(u=Os(u,e.maxDecimalPoints))}u&&f.push({unitCount:u,unitName:i})}return f},Xn=(s,e,t)=>{const{language:r,units:c}=e;if(s.length===0){const h=c.at(-1);return is({unitCount:0,unitName:h},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 p=s.map(h=>is(h,r,e));let f;return!o||s.length===1?f=p.join(d):s.length===2?f=p.join(o):f=p.slice(0,-1).join(d)+(i?",":"")+o+(p.at(-1)??""),u&&(f=u.replace("%s",f)),f},Jn=(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:zn,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};Yn(t.language);const r=Math.abs(s),c=Kn(r,t);return Xn(c,t,s)},be="@voidzero-dev/vite-task-client",bt="@visulima/task-runner-client",nt=`npm:${bt}@^1`,As=ue(".vis",".vite-client-override-declined"),it="pnpm-workspace.yaml",Qn=["dependencies","devDependencies","optionalDependencies","peerDependencies"],Ls=s=>{try{return JSON.parse(We(s,"utf8"))}catch{return}},Zn=s=>{const e=ue(s,it);if(De(e))try{return $s(We(e,"utf8")).toJS()?.overrides}catch{return}},ei=s=>s==="pnpm"||s==="aube"?"pnpm.overrides":s==="yarn"?"resolutions":"overrides",ti=s=>{const e=ue(s,it);try{const t=$s(We(e,"utf8"));return t.setIn(["overrides",be],nt),xt(e,t.toString()),!0}catch{return!1}},os=s=>s!==void 0&&Qn.some(e=>s[e]?.[be]!==void 0),si=(s,e)=>s!==void 0&&(s.pnpm?.overrides?.[be]!==void 0||s.overrides?.[be]!==void 0||s.resolutions?.[be]!==void 0)||e?.[be]!==void 0,ri=(s,e=[])=>{const t=Ls(ue(s,"package.json")),r=De(ue(s,"node_modules","@voidzero-dev","vite-task-client"));return{alreadyOverridden:si(t,Zn(s)),declined:De(ue(s,As)),manager:_r(s)?.manager,present:os(t)||r||e.some(c=>os(c))}},ni=s=>{try{const e=ue(s,As);Gr(Ss(e),{recursive:!0}),xt(e,`Declined adding the ${be} → ${bt} override.
2
2
  Delete this file to be asked again.
3
- `)}catch{}},tn=(s,e="npm")=>{const t=`${e} install`;if((e==="pnpm"||e==="aube")&&Ae(oe(s,rt))&&Xi(s))return{file:rt,installCommand:t};const r=oe(s,"package.json"),a=As(r);if(!a)return;const o=Ki(e);o==="pnpm.overrides"?(a.pnpm??={},a.pnpm.overrides??={},a.pnpm.overrides[be]=st):(a[o]??={},a[o][be]=st);try{vt(r,`${JSON.stringify(a,void 0,4)}
4
- `)}catch{return}return{file:"package.json",installCommand:t}},sn=async(s,e)=>{const t=Zi(s,e.projectManifests);if(!t.present||t.alreadyOverridden||t.declined)return!1;const r=Ur({input:process.stdin,output:process.stdout});try{e.logger.info(`Detected ${be}. Its cache hints no-op under @visulima/task-runner unless aliased to ${xt} (a drop-in replacement).`);const a=await new Promise(n=>{r.question("Add the override now? [y/N] ",n)});if(!/^y(?:es)?$/i.test(a.trim()))return en(s),e.logger.info("Skipped. Delete .vis/.vite-client-override-declined to be asked again."),!1;const o=tn(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 "${be}": "${st}" to ${o.file}. Run \`${o.installCommand}\` to apply it.`),!0)}finally{r.close()}},rn=({interactive:s,taskPty:e,workspacePty:t})=>e===!0?!0:e===!1?!1:s&&t!==!1,nn=s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),on=(s,e,t)=>{const r=new Set,a=[];if(s===void 0||s.trim()==="")return{skipTaskIds:r,unmatchedPatterns:a};const o=[...t],n=new Set(o),d=new Map;for(const u of o){const g=u.lastIndexOf(":");if(g===-1)continue;const h=u.slice(g+1),f=d.get(h);f===void 0?d.set(h,[u]):f.push(u)}for(const u of nn(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(n.has(u)){r.add(u);continue}const g=hi(u);if(!g){a.push(u);continue}let h=!1;switch(g.kind){case"all":{const f=d.get(g.target)??[];for(const l of f)r.add(l),h=!0;break}case"project":{const f=g.projects?.[0];if(f!==void 0){const l=`${f}:${g.target}`;n.has(l)&&(r.add(l),h=!0)}break}case"tag":{const{tag:f}=g;if(f!==void 0){const l=d.get(g.target)??[];for(const j of l){const C=j.slice(0,j.lastIndexOf(":"));e.projects[C]?.tags?.includes(f)===!0&&(r.add(j),h=!0)}}break}}h||a.push(u)}return{skipTaskIds:r,unmatchedPatterns:a}},an=/\$(?:\{([A-Z_]\w*)(:-[^}]*)?\}|([A-Z_]\w*))/gi,cn=new Set(["0","!","#","$","*","-","?","@","_"]),ln=s=>{const e=new Map;for(const t of s.matchAll(an)){const r=t[1],a=t[3],o=t[2],n=r??a;if(n===void 0||cn.has(n))continue;const d=o!==void 0,u=e.get(n);u===void 0?e.set(n,d):u&&!d&&e.set(n,!1)}return[...e.entries()].map(([t,r])=>({hasDefault:r,name:t}))},dn=s=>{const{command:e,processEnv:t,taskEnv:r,taskId:a}=s,o=ln(e);if(o.length===0)return;const n=[];for(const{hasDefault:d,name:u}of o){if(d)continue;const g=r[u],h=t[u];g===void 0&&h===void 0&&n.push(u)}if(n.length!==0)return{missing:n.toSorted(),taskId:a}},un=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.`},hn=new RegExp("[\x1B›]\\[[0-?]*[ -/]*[@-~]","g"),ht=s=>s.replaceAll(hn,"").replaceAll("\r","");class as{#e=[];#r=new Set;#s=new Map;#i=new Map;constructor(e=[]){for(const t of e)this.#i.set(t,{id:t,status:"pending",tailLines:[]});this.#e=[...e],this.#n()}getSnapshot=()=>this.#s;subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});getIds(){return this.#e}getState(e){return this.#i.get(e)}getDockState(){let e=!1,t=!1;for(const r of this.#i.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.#i.has(e)||(this.#i.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 a=r?.message;this.#t(e,o=>({...o,errorMessage:ht(a??t),status:"failed"}))}markCrashed(e,t){const r=t.slice(-256).map(a=>ht(a));this.#t(e,a=>({...a,errorMessage:r.length>0?r[r.length-1]:"process exited",status:"crashed",tailLines:r}))}appendLog(e,t){const r=t.split(`
5
- `).map(a=>ht(a)).filter(a=>a.length>0);r.length!==0&&this.#t(e,a=>{const o=[...a.tailLines,...r];for(;o.length>256;)o.shift();let n=0;for(let d=o.length-1;d>=0;d--)if(n+=o[d].length+1,n>65536){o.splice(0,d+1);break}return{...a,lastLine:r[r.length-1],tailLines:o}})}abortBoot(e){let t=!1;const r=new Map(this.#i);for(const[a,o]of r)(o.status==="pending"||o.status==="starting")&&(r.set(a,{...o,errorMessage:e,status:"failed"}),t=!0);t&&(this.#i=r,this.#n(),this.#o())}#t(e,t){const r=this.#i.get(e);r&&(this.#i.set(e,t(r)),this.#n(),this.#o())}#n(){this.#s=new Map(this.#i)}#o(){for(const e of this.#r)try{e()}catch{}}}const fn=(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},cs=({children:s,deps:e,onRender:t,style:r,width:a})=>{const o=H.useRef(null),n=H.useRef(!1),d=H.useRef(e),u=H.useRef(s),g=H.useRef(t);g.current=t;let h=!1;e!==void 0?fn(d.current,e)||(h=!0,d.current=e):s!==u.current&&(h=!0,u.current=s),h&&(n.current=!1,o.current&&(o.current.cachedRender=void 0)),H.useLayoutEffect(()=>{const l=o.current;l&&(l.internal_onRendered=()=>{n.current=!0,g.current?.(l)})}),H.useEffect(()=>()=>{const l=o.current;l&&(l.cachedRender=void 0,l.internal_onRendered=void 0)},[]);const f=H.useMemo(()=>({...r,width:a}),[r,a]);return i.jsx("ink-static-render",{ref:o,style:f,children:n.current?null:s()})},pn=s=>Array.isArray(s)?`[${s.join(",")}]`:typeof s=="object"&&s!==null?JSON.stringify(s):String(s),gn=(s,e,t)=>e==="_"?`${s}${Array.isArray(t)?t.join(" "):String(t)}`:`${s}--${e}=${pn(t)}`,jt=(s,e,t)=>{const r=new Set(new Set(t.map(l=>l.target.target))),a=new Set(new Set(t.map(l=>l.target.project))),o=e.filter(l=>r.has(l)),n=s.filter(l=>a.has(l)),d=t.length-n.length*o.length,u=o.length===1?"target":"targets",g=o.join(", "),h=n.length===1?`project ${n[0]}`:`${n.length} projects`;let f=`${u} ${g} for ${h}`;return d>0&&(f+=` and ${d} ${d===1?"task":"tasks"} ${d===1?"it depends":"they depend"} on`),f},mn={error:"red",info:"white",success:"green"},gt=({children:s,title:e,variant:t})=>{const r=mn[t];return i.jsxs(m,{flexDirection:"column",children:[i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,inverse:!0,children:" VIS "}),i.jsx(c,{bold:!0,color:r,children:"•"}),i.jsx(c,{children:e})]}),s]})},Ds=({cached:s,failed:e,failedIds:t,projectNames:r,retriedIds:a,skippedIds:o,succeeded:n,targets:d,tasks:u,took:g})=>{const h=jt(r,d,u),f=a??[];if(e===0&&(!o||o.length===0)){const l=s>0?` (${s} read from cache)`:"";return i.jsx(cs,{children:()=>i.jsx(gt,{title:`Successfully ran ${h}`,variant:"success",children:i.jsxs(m,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[i.jsxs(c,{children:[i.jsx(c,{color:"green",children:Ts})," ",n+s," tasks completed",l?i.jsx(c,{dimColor:!0,children:l}):null,i.jsx(c,{dimColor:!0,children:` · Took ${g}`})]}),f.length>0&&i.jsxs(m,{flexDirection:"column",marginTop:1,children:[i.jsxs(c,{children:[i.jsx(c,{color:"yellow",children:"↻"})," ",i.jsx(c,{color:"yellow",children:String(f.length)})," task",f.length===1?"":"s"," succeeded after retry:"]}),f.map(j=>i.jsxs(c,{children:[" ",i.jsx(c,{color:"yellow",children:"↻"})," ",j]},j))]})]})})})}return i.jsx(cs,{children:()=>i.jsx(gt,{title:`Ran ${h}`,variant:"error",children:i.jsxs(m,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[o&&o.length>0&&i.jsxs(m,{flexDirection:"column",children:[i.jsxs(c,{dimColor:!0,children:[o.length," ","task",o.length===1?"":"s"," ","skipped (dependency failed or --bail)"]}),o.map(l=>i.jsxs(c,{dimColor:!0,children:[" - ",l]},l)),i.jsx(c,{})]}),e>0&&i.jsxs(m,{flexDirection:"column",children:[i.jsxs(c,{children:[i.jsx(c,{color:"red",children:String(e)})," ","task",e===1?"":"s"," ","failed:"]}),t.map(l=>i.jsxs(c,{children:[" ",i.jsx(c,{color:"red",children:Is})," ",l]},l)),i.jsx(c,{})]}),f.length>0&&i.jsxs(m,{flexDirection:"column",children:[i.jsxs(c,{children:[i.jsx(c,{color:"yellow",children:String(f.length)})," ","task",f.length===1?"":"s"," ","finished after retry:"]}),f.map(l=>i.jsxs(c,{children:[" ",i.jsx(c,{color:"yellow",children:"↻"})," ",l]},l)),i.jsx(c,{})]}),i.jsx(c,{dimColor:!0,children:` Took ${g}`})]})})})};class it{#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 a=t.findIndex(o=>o.taskId===r.id);a!==-1&&(t[a]={...t[a],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:a,failed:o,succeeded:n}=this.#e;const d=new Map(this.#e.outputs),u=[...this.#e.retriedIds];for(const f of e){const l=t.findIndex(j=>j.taskId===f.task.id);switch(l!==-1&&(t[l]={...t[l],duration:f.startTime&&f.endTime?f.endTime-f.startTime:void 0,retryAttempts:f.retryAttempts,status:f.status}),f.retryAttempts&&f.retryAttempts>0&&u.push(f.task.id),a++,f.status){case"failure":{o++;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{r++;break}case"success":{n++;break}}f.terminalOutput&&!d.has(f.task.id)&&d.set(f.task.id,f.terminalOutput),this.#s.delete(f.task.id)}let{selectedIndex:g}=this.#e;if(o>this.#e.failed){const f=t.findIndex(l=>l.status==="failure");f!==-1&&(g=f)}const h=Math.max(0,this.#e.running-e.length);this.#t({...this.#e,cached:r,completed:a,failed:o,outputs:d,retriedIds:u,rows:t,running:h,selectedIndex:g,succeeded:n})}static#i=256*1024;addOutput(e,t){if(!t.trim())return;let r=(this.#e.outputs.get(e)??"")+t;r.length>it.#i&&(r=r.slice(-it.#i)),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 a=t[r];if(a.status==="running"){const o=this.#s.get(a.taskId);if(o){const n=process.hrtime(o),d=n[0]*1e3+n[1]/1e6;t[r]={...a,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:a,failed:o,succeeded:n}=this.#e;if(r!==-1){const d=t[r].status;d==="failure"?(o=Math.max(0,o-1),a=Math.max(0,a-1)):d==="success"&&(n=Math.max(0,n-1),a=Math.max(0,a-1)),t[r]={...t[r],elapsed:0,retryAttempts:void 0,status:"running"},this.#s.set(e,process.hrtime())}this.#t({...this.#e,completed:a,done:!1,endTime:null,failed:o,interactiveMode:!1,retriedIds:this.#e.retriedIds.filter(d=>d!==e),retryTaskId:e,rows:t,succeeded:n})}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 wn=s=>Wi(s),vn=/^(?<name>(?:[A-Z][\w$]*)?(?:Error|Exception))(?::[ \t](?<message>.*))?$/,yn=/^\s*at\s+/,kn=s=>{const e=s.split(`
6
- `);let t;for(let r=0;r<e.length;r++){const a=vn.exec(e[r].trim());if(!a)continue;const o=[];for(let n=r+1;n<e.length&&n<=r+200;n++){const d=e[n];if(yn.test(d))o.push(d.trim());else if(o.length>0||d.trim()!=="")break}if(o.length>0){const n=a.groups?.name??"Error",d=a.groups?.message??"";t={message:d,name:n,stack:`${n}: ${d}
3
+ `)}catch{}},ii=(s,e="npm")=>{const t=`${e} install`;if((e==="pnpm"||e==="aube")&&De(ue(s,it))&&ti(s))return{file:it,installCommand:t};const r=ue(s,"package.json"),c=Ls(r);if(!c)return;const o=ei(e);o==="pnpm.overrides"?(c.pnpm??={},c.pnpm.overrides??={},c.pnpm.overrides[be]=nt):(c[o]??={},c[o][be]=nt);try{xt(r,`${JSON.stringify(c,void 0,4)}
4
+ `)}catch{return}return{file:"package.json",installCommand:t}},oi=async(s,e)=>{const t=ri(s,e.projectManifests);if(!t.present||t.alreadyOverridden||t.declined)return!1;const r=Ur({input:process.stdin,output:process.stdout});try{e.logger.info(`Detected ${be}. 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 ni(s),e.logger.info("Skipped. Delete .vis/.vite-client-override-declined to be asked again."),!1;const o=ii(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 "${be}": "${nt}" to ${o.file}. Run \`${o.installCommand}\` to apply it.`),!0)}finally{r.close()}},ci=({interactive:s,taskPty:e,workspacePty:t})=>e===!0?!0:e===!1?!1:s&&t!==!1,ai=s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),li=(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 p=u.lastIndexOf(":");if(p===-1)continue;const f=u.slice(p+1),h=d.get(f);h===void 0?d.set(f,[u]):h.push(u)}for(const u of ai(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 p=mn(u);if(!p){c.push(u);continue}let f=!1;switch(p.kind){case"all":{const h=d.get(p.target)??[];for(const l of h)r.add(l),f=!0;break}case"project":{const h=p.projects?.[0];if(h!==void 0){const l=`${h}:${p.target}`;i.has(l)&&(r.add(l),f=!0)}break}case"tag":{const{tag:h}=p;if(h!==void 0){const l=d.get(p.target)??[];for(const b of l){const T=b.slice(0,b.lastIndexOf(":"));e.projects[T]?.tags?.includes(h)===!0&&(r.add(b),f=!0)}}break}}f||c.push(u)}return{skipTaskIds:r,unmatchedPatterns:c}},di=/\$(?:\{([A-Z_]\w*)(:-[^}]*)?\}|([A-Z_]\w*))/gi,ui=new Set(["0","!","#","$","*","-","?","@","_"]),fi=s=>{const e=new Map;for(const t of s.matchAll(di)){const r=t[1],c=t[3],o=t[2],i=r??c;if(i===void 0||ui.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}))},hi=s=>{const{command:e,processEnv:t,taskEnv:r,taskId:c}=s,o=fi(e);if(o.length===0)return;const i=[];for(const{hasDefault:d,name:u}of o){if(d)continue;const p=r[u],f=t[u];p===void 0&&f===void 0&&i.push(u)}if(i.length!==0)return{missing:i.toSorted(),taskId:c}},pi=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.`},mi=64*1024,cs=256,gi=new RegExp("[\x1B›]\\[[0-?]*[ -/]*[@-~]","g"),pt=s=>s.replaceAll(gi,"").replaceAll("\r","");class as{#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(-cs).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
+ `).map(c=>pt(c)).filter(c=>c.length>0);r.length!==0&&this.#t(e,c=>{const o=[...c.tailLines,...r];for(;o.length>cs;)o.shift();let i=0;for(let d=o.length-1;d>=0;d--)if(i+=o[d].length+1,i>mi){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 wi=(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},ls=({children:s,deps:e,onRender:t,style:r,width:c})=>{const o=U.useRef(null),i=U.useRef(!1),d=U.useRef(e),u=U.useRef(s),p=U.useRef(t);p.current=t;let f=!1;e!==void 0?wi(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)),U.useLayoutEffect(()=>{const l=o.current;l&&(l.internal_onRendered=()=>{i.current=!0,p.current?.(l)})}),U.useEffect(()=>()=>{const l=o.current;l&&(l.cachedRender=void 0,l.internal_onRendered=void 0)},[]);const h=U.useMemo(()=>({...r,width:c}),[r,c]);return n.jsx("ink-static-render",{ref:o,style:h,children:i.current?null:s()})},yi=s=>Array.isArray(s)?`[${s.join(",")}]`:typeof s=="object"&&s!==null?JSON.stringify(s):String(s),vi=(s,e,t)=>e==="_"?`${s}${Array.isArray(t)?t.join(" "):String(t)}`:`${s}--${e}=${yi(t)}`,St=(s,e,t)=>{const r=new Set(new Set(t.map(l=>l.target.target))),c=new Set(new Set(t.map(l=>l.target.project))),o=e.filter(l=>r.has(l)),i=s.filter(l=>c.has(l)),d=t.length-i.length*o.length,u=o.length===1?"target":"targets",p=o.join(", "),f=i.length===1?`project ${i[0]}`:`${i.length} projects`;let h=`${u} ${p} for ${f}`;return d>0&&(h+=` and ${d} ${d===1?"task":"tasks"} ${d===1?"it depends":"they depend"} on`),h},xi={error:"red",info:"white",success:"green"},wt=({children:s,title:e,variant:t})=>{const r=xi[t];return n.jsxs(g,{flexDirection:"column",children:[n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,inverse:!0,children:" VIS "}),n.jsx(a,{bold:!0,color:r,children:"•"}),n.jsx(a,{children:e})]}),s]})},Ds=({cached:s,failed:e,failedIds:t,projectNames:r,retriedIds:c,skippedIds:o,succeeded:i,targets:d,tasks:u,took:p})=>{const f=St(r,d,u),h=c??[];if(e===0&&(!o||o.length===0)){const l=s>0?` (${s} read from cache)`:"";return n.jsx(ls,{children:()=>n.jsx(wt,{title:`Successfully ran ${f}`,variant:"success",children:n.jsxs(g,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[n.jsxs(a,{children:[n.jsx(a,{color:"green",children:Is})," ",i+s," tasks completed",l?n.jsx(a,{dimColor:!0,children:l}):null,n.jsx(a,{dimColor:!0,children:` · Took ${p}`})]}),h.length>0&&n.jsxs(g,{flexDirection:"column",marginTop:1,children:[n.jsxs(a,{children:[n.jsx(a,{color:"yellow",children:"↻"})," ",n.jsx(a,{color:"yellow",children:String(h.length)})," task",h.length===1?"":"s"," succeeded after retry:"]}),h.map(b=>n.jsxs(a,{children:[" ",n.jsx(a,{color:"yellow",children:"↻"})," ",b]},b))]})]})})})}return n.jsx(ls,{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(a,{dimColor:!0,children:[o.length," ","task",o.length===1?"":"s"," ","skipped (dependency failed or --bail)"]}),o.map(l=>n.jsxs(a,{dimColor:!0,children:[" - ",l]},l)),n.jsx(a,{})]}),e>0&&n.jsxs(g,{flexDirection:"column",children:[n.jsxs(a,{children:[n.jsx(a,{color:"red",children:String(e)})," ","task",e===1?"":"s"," ","failed:"]}),t.map(l=>n.jsxs(a,{children:[" ",n.jsx(a,{color:"red",children:Cs})," ",l]},l)),n.jsx(a,{})]}),h.length>0&&n.jsxs(g,{flexDirection:"column",children:[n.jsxs(a,{children:[n.jsx(a,{color:"yellow",children:String(h.length)})," ","task",h.length===1?"":"s"," ","finished after retry:"]}),h.map(l=>n.jsxs(a,{children:[" ",n.jsx(a,{color:"yellow",children:"↻"})," ",l]},l)),n.jsx(a,{})]}),n.jsx(a,{dimColor:!0,children:` Took ${p}`})]})})})};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 h of e){const l=t.findIndex(b=>b.taskId===h.task.id);switch(l!==-1&&(t[l]={...t[l],duration:h.startTime&&h.endTime?h.endTime-h.startTime:void 0,retryAttempts:h.retryAttempts,status:h.status}),h.retryAttempts&&h.retryAttempts>0&&u.push(h.task.id),c++,h.status){case"failure":{o++;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{r++;break}case"success":{i++;break}}h.terminalOutput&&!d.has(h.task.id)&&d.set(h.task.id,h.terminalOutput),this.#s.delete(h.task.id)}let{selectedIndex:p}=this.#e;if(o>this.#e.failed){const h=t.findIndex(l=>l.status==="failure");h!==-1&&(p=h)}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:p,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 ji=s=>qn(s),ki=/^(?<name>(?:[A-Z][\w$]*)?(?:Error|Exception))(?::[ \t](?<message>.*))?$/,bi=/^\s*at\s+/,Si=s=>{const e=s.split(`
6
+ `);let t;for(let r=0;r<e.length;r++){const c=ki.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(bi.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(`
8
- `)}`}}}return t},Bs=s=>{if(s.startsWith("file://"))try{return Ti(s)}catch{return s}return s},xn=s=>!s.includes("node_modules")&&!s.startsWith("node:")&&!s.startsWith("internal/"),jn=s=>{try{return Pi(s)}catch{return}},$n=(s,e)=>{if(!s.file||s.line===void 0)return;const t=Bs(s.file),r=$i(t)?t:es(e,t);if(!xn(r)||!Ae(r))return;const a=jn(r);if(a){const o=Mi(a,{column:s.column===void 0?0:Math.max(0,s.column-1),line:s.line});if(o.source&&o.line!=null){const n=es(bi(r),o.source),d=Fi(a,o.source)??(Ae(n)?Ge(n,"utf8"):void 0);if(d!==void 0)return{column:o.column==null?void 0:o.column+1,file:n,line:o.line,source:d}}}return{column:s.column,file:r,line:s.line,source:Ge(r,"utf8")}},ls=(s,e)=>{const t=Si(e,s);return t&&!t.startsWith("..")?t:s},Ls=(s,e)=>{if(!s?.trim())return s;try{const t=kn(wn(s));if(!t)return s;const r=new Error(t.message);r.name=t.name,r.stack=t.stack;const a=Ri(r);if(a.length===0)return s;const o=e.color,n={dim:l=>o?ts(l):l,head:l=>o?Ci(ut(l)):l,loc:l=>o?Ii(l):l};let d,u;for(const l of a){const j=$n(l,e.cwd);if(j){d=j,u=l;break}}const g=[n.head(`✖ ${t.name}${t.message?`: ${t.message}`:""}`)];if(d){const l=`${ls(d.file,e.cwd)}:${d.line}${d.column?`:${d.column}`:""}`;g.push(` ${n.loc(l)}`,""),g.push(Ei(d.source,{start:{column:d.column,line:d.line}},{color:o?{gutter:ts,marker:ut,message:ut}:void 0,linesAbove:2,linesBelow:3}))}const h=a.filter(l=>l!==u).slice(0,8).map(l=>{const j=l.methodName??"<anonymous>",C=l.file?`${ls(Bs(l.file),e.cwd)}${l.line?`:${l.line}`:""}`:"";return n.dim(` at ${j}${C?` (${C})`:""}`)});h.length>0&&g.push("",...h);const f=n.dim("─".repeat(40));return`${g.join(`
8
+ `)}`}}}return t},Bs=s=>{if(s.startsWith("file://"))try{return $n(s)}catch{return s}return s},Ti=s=>!s.includes("node_modules")&&!s.startsWith("node:")&&!s.startsWith("internal/"),$i=s=>{try{return Fn(s)}catch{return}},Ii=(s,e)=>{if(!s.file||s.line===void 0)return;const t=Bs(s.file),r=bn(t)?t:es(e,t);if(!Ti(r)||!De(r))return;const c=$i(r);if(c){const o=Pn(c,{column:s.column===void 0?0:Math.max(0,s.column-1),line:s.line});if(o.source&&o.line!=null){const i=es(Sn(r),o.source),u=Mn(c,o.source)??(De(i)?We(i,"utf8"):void 0);if(u!==void 0)return{column:o.column==null?void 0:o.column+1,file:i,line:o.line,source:u}}}return{column:s.column,file:r,line:s.line,source:We(r,"utf8")}},ds=(s,e)=>{const t=Tn(e,s);return t&&!t.startsWith("..")?t:s},_s=(s,e)=>{if(!s?.trim())return s;try{const t=Si(ji(s));if(!t)return s;const r=new Error(t.message);r.name=t.name,r.stack=t.stack;const c=En(r);if(c.length===0)return s;const o=e.color,i={dim:l=>o?ts(l):l,head:l=>o?Cn(ht(l)):l,loc:l=>o?In(l):l};let d,u;for(const l of c){const b=Ii(l,e.cwd);if(b){d=b,u=l;break}}const p=[i.head(`✖ ${t.name}${t.message?`: ${t.message}`:""}`)];if(d){const l=`${ds(d.file,e.cwd)}:${d.line}${d.column?`:${d.column}`:""}`;p.push(` ${i.loc(l)}`,""),p.push(Rn(d.source,{start:{column:d.column,line:d.line}},{color:o?{gutter:ts,marker:ht,message:ht}:void 0,linesAbove:2,linesBelow:3}))}const f=c.filter(l=>l!==u).slice(0,8).map(l=>{const b=l.methodName??"<anonymous>",T=l.file?`${ds(Bs(l.file),e.cwd)}${l.line?`:${l.line}`:""}`:"";return i.dim(` at ${b}${T?` (${T})`:""}`)});f.length>0&&p.push("",...f);const h=i.dim("─".repeat(40));return`${p.join(`
9
9
  `)}
10
- ${f}
11
- ${s}`}catch{return s}},bn={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"]},De=s=>Hi(s,bn),Ne=s=>s==="local-cache"||s==="local-cache-kept-existing"||s==="remote-cache",_e=s=>{switch(s){case"failure":return{color:"red",icon:Is};case"local-cache":case"local-cache-kept-existing":case"remote-cache":case"success":return{color:"green",icon:Ts};case"skipped":return{color:"gray",icon:at};default:return{color:"gray",icon:"?"}}},He=s=>{const{color:e,icon:t}=_e(s);return he(X.createElement(c,{color:e},t),{columns:10}).trim()},Sn=s=>{const{color:e,icon:t}=_e(s);switch(s){case"local-cache":case"local-cache-kept-existing":case"remote-cache":return he(X.createElement(c,null,X.createElement(c,{color:e},t)," ",X.createElement(c,{color:"cyan"},"[cache]")),{columns:30}).trim();case"skipped":return he(X.createElement(c,null,X.createElement(c,{dimColor:!0},t)," ",X.createElement(c,{dimColor:!0},"[skipped]")),{columns:30}).trim();default:return he(X.createElement(c,{color:e},t),{columns:10}).trim()}},Tn=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",In=s=>{const e=s.replaceAll(/\W+/g,"_"),t=Oi("sha256").update(s).digest("hex").slice(0,6);return`${e}_${t}`},Cn=(s,e,t,r="auto")=>{const a=t.trim();if(!a)return;const o=`
12
- `,n=Tn(r);if(n==="github"){process.stdout.write(`::group::${He(e)} ${s}${o}`),process.stdout.write(a+o),process.stdout.write(`::endgroup::${o}`);return}if(n==="gitlab"){const f=Math.floor(Date.now()/1e3),l=In(s),j=e==="failure"?"":"[collapsed=true]",C="\x1B[0K";process.stdout.write(`${C}section_start:${String(f)}:${l}${j}\r${C}${He(e)} ${s}${o}`),process.stdout.write(a+o);const U=Math.floor(Date.now()/1e3);process.stdout.write(`${C}section_end:${String(U)}:${l}\r${C}${o}`);return}if(n==="buildkite"){const f=e==="failure"?"+++":"---";process.stdout.write(`${f} ${He(e)} ${s}${o}`),process.stdout.write(a+o);return}if(n==="azure"){process.stdout.write(`##[group]${He(e)} ${s}${o}`),process.stdout.write(a+o),process.stdout.write(`##[endgroup]${o}`);return}const d=process.stdout.columns||80,u=he(X.createElement(c,{dimColor:!0},at.repeat(d)),{columns:d}).trim(),g=Sn(e),h=he(X.createElement(c,{bold:!0},s),{columns:d}).trim();process.stdout.write(`${u}${o}`),process.stdout.write(`${g} ${h}${o}`),process.stdout.write(a+o),process.stdout.write(`${u}${o}`)},Rn=s=>s==="running"?{color:"white",icon:"•"}:s==="pending"?{color:"gray",icon:"·"}:_e(s),En=({autoScroll:s,focused:e,interactiveMode:t,showFullscreenHint:r,statusValue:a,supportsInteractive:o,taskId:n})=>{if(!n)return;if(t)return"Esc cancel | Enter send";const d=s?"":" PAUSED (f resume)",u=o?" i INPUT":"";return e&&a==="running"&&r?`⏎ FULLSCREEN${u} f FOLLOW${d}`:e&&a==="running"?`f FOLLOW${u}${d}`:e&&r?`<enter> full screen${d}`:e?d||void 0:"<tab> or <enter> to focus"},ds=({autoScroll:s=!0,duration:e,focused:t,interactiveMode:r,output:a,scrollRef:o,showFullscreenHint:n,status:d,supportsInteractive:u=!0,taskId:g})=>{const h=d??"pending",{icon:f}=Rn(h),l=t?"bold":"single",j=h==="failure"?"red":h==="success"||Ne(h)?t?"green":"gray":h==="running"?t?"white":"cyan":t?"white":"gray",C=g?`${f} ${g}`:void 0,U=e===void 0?void 0:De(e),O=En({autoScroll:s,focused:t,interactiveMode:r??!1,showFullscreenHint:n??!1,statusValue:h,supportsInteractive:u,taskId:g});if(!g)return i.jsxs(m,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",paddingX:2,paddingY:1,children:[i.jsx(c,{dimColor:!0,children:"Select a task to view output"}),i.jsx(c,{dimColor:!0,children:"Press Enter or 1/2 to pin"})]});const $=[];if(a)for(const E of a.split(`
13
- `))$.push(E.endsWith("\r")?E.slice(0,-1):E);return!a&&(h==="running"||h==="pending")?i.jsx(m,{borderBottomTitle:O,borderColor:j,borderStyle:l,borderTopRightTitle:U,borderTopTitle:C,flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:i.jsx(m,{alignItems:"center",flexGrow:1,justifyContent:"center",children:i.jsx(c,{dimColor:!0,children:"Waiting for task output…"})})}):i.jsxs(m,{borderBottomTitle:O,borderColor:r?"yellow":j,borderStyle:l,borderTopRightTitle:U,borderTopTitle:C,flexDirection:"column",flexGrow:1,children:[i.jsx(m,{flexGrow:1,flexShrink:1,paddingY:1,children:i.jsx(Rs,{flexGrow:1,followOutput:s,paddingX:2,ref:o,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:i.jsx(c,{children:$.join(`
14
- `)})})}),r&&i.jsx(m,{flexShrink:0,justifyContent:"center",paddingX:1,children:i.jsx(c,{bold:!0,color:"yellow",children:"INTERACTIVE | keystrokes forwarded to task | Esc to exit"})})]})},Mn={crashed:"✖",failed:"✖",pending:"·",ready:"●",starting:"•"},Ns=s=>s==="ready"?"green":s==="crashed"||s==="failed"?"red":s==="starting"?"cyan":"gray",Fn=({status:s})=>s==="starting"?i.jsx(c,{color:"cyan",children:i.jsx(Es,{type:"dots"})}):i.jsx(c,{bold:!0,color:Ns(s),children:Mn[s]}),Pn=({active:s,focused:e,state:t})=>{const r=e&&s,a=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 i.jsxs(m,{flexDirection:"row",flexShrink:0,overflow:"hidden",children:[i.jsx(c,{children:a}),i.jsx(c,{children:" "}),i.jsx(m,{flexShrink:0,width:3,children:i.jsx(Fn,{status:t.status})}),i.jsx(m,{flexGrow:0,flexShrink:0,width:28,children:i.jsx(c,{bold:r,inverse:r,children:t.id})}),i.jsx(m,{flexGrow:1,flexShrink:1,overflow:"hidden",children:i.jsxs(c,{color:Ns(t.status),dimColor:t.status!=="crashed"&&t.status!=="failed",wrap:"truncate-end",children:[" ",o]})})]})},On=({states:s})=>{const e=[];for(const r of s)r.status==="ready"&&e.push(r.id);const t=e.join(", ");return i.jsxs(m,{paddingX:1,children:[i.jsxs(c,{bold:!0,color:"green",children:["● ","Services"]}),i.jsxs(c,{children:[" ",String(e.length)," / ",String(s.length)," running"]}),t.length>0&&i.jsxs(c,{dimColor:!0,children:[" ",t]}),i.jsx(c,{dimColor:!0,children:" [Tab ↓]"})]})},An=({states:s})=>{const e=s.find(t=>t.status==="crashed"||t.status==="failed");return e?i.jsxs(m,{flexDirection:"column",paddingX:1,children:[i.jsxs(c,{bold:!0,color:"red",children:["✖ ","Service crashed:"," ",e.id]}),e.tailLines.slice(-3).map((t,r)=>i.jsxs(c,{color:"red",dimColor:!0,children:[" ",t]},`crash-${String(r)}`))]}):i.jsx(i.Fragment,{})},Dn=({activeIndex:s,focused:e,store:t})=>{const r=H.useSyncExternalStore(t.subscribe,t.getSnapshot),a=t.getIds();if(a.length===0)return i.jsx(i.Fragment,{});const o=a.map(h=>r.get(h)).filter(h=>h!==void 0),n=t.getDockState(),d=n==="crash"?"red":n==="ready"?"gray":e?"white":"cyan",u=n==="crash"?"Services (crashed)":n==="ready"?"Services":"Services (starting)",g=e?n==="crash"?"↑↓ select Enter logs R retry Esc back":"↑↓ select Enter logs Esc back":"Tab to focus services";return n==="ready"&&!e?i.jsx(m,{borderColor:d,borderStyle:"single",flexDirection:"row",flexShrink:0,children:i.jsx(On,{states:o})}):i.jsxs(m,{borderBottomTitle:g,borderColor:d,borderStyle:e?"bold":"single",borderTopTitle:u,flexDirection:"column",flexGrow:2,flexShrink:0,minHeight:6,paddingX:1,children:[n==="crash"&&i.jsx(An,{states:o}),o.map((h,f)=>i.jsx(Pn,{active:f===s,focused:e,state:h},h.id))]})},Gs=6,_s=8,qs=12,Bn=s=>s==="running"||s==="pending"?Cs:s==="local-cache"||s==="local-cache-kept-existing"?"Local":s==="remote-cache"?"Remote":at,us=(s,e)=>e[0]===s?"[1]":e[1]===s?"[2]":"",hs=({compact:s,focused:e,isSelected:t,pinLabel:r,row:a})=>{const{persistent:o,status:n,taskId:d}=a,u=e&&t,g=u?">":" ",h=n==="running"&&o===!0;let f;if(h)f=i.jsx(c,{bold:!0,color:"green",children:" ● "});else if(n==="running")f=i.jsxs(c,{bold:!0,color:"white",children:[" ",i.jsx(Es,{type:"dots"})," "]});else if(n==="pending")f=i.jsx(c,{bold:!0,color:"gray",children:" · "});else{const{color:j,icon:C}=_e(n);f=i.jsxs(c,{bold:!0,color:j,children:[" ",C," "]})}let l=Cs;return h?l="running":n!=="running"&&n!=="pending"?l=a.duration===void 0?at:De(a.duration):n==="running"&&a.elapsed!==void 0&&(l=De(a.elapsed)),i.jsxs(m,{children:[i.jsx(c,{children:g}),i.jsx(m,{width:Gs,children:f}),i.jsxs(m,{flexGrow:1,children:[i.jsx(c,{bold:u,inverse:u,children:d}),r?i.jsx(c,{dimColor:!0,children:` ${r}`}):null]}),!s&&i.jsx(m,{justifyContent:"flex-end",width:_s,children:i.jsx(c,{dimColor:!Ne(n),children:Bn(n)})}),!s&&i.jsx(m,{justifyContent:"flex-end",width:qs,children:i.jsx(c,{color:h?"green":void 0,dimColor:n==="pending"||h,children:l})})]})},fs=({compact:s,filterActive:e,filterText:t,focused:r,headerStatus:a,parallelSlots:o=3,pinnedTaskIds:n,rows:d,scrollRef:u,selectedIndex:g,title:h})=>{const f=a==="error"?"red":a==="success"?"green":r?"white":"gray",l=d[g]?.taskId,j=[];let C=0;for(const E of d)E.status==="running"?j.push(E):E.status==="pending"&&(C+=1);const U=Math.min(o,j.length+C),O=U>1,$=[];if(O)for(let E=0;E<U;E++){const S=j[E];S?$.push(i.jsx(hs,{compact:s,focused:r,isSelected:S.taskId===l,pinLabel:us(S.taskId,n),row:S},`par-${S.taskId}`)):$.push(i.jsxs(m,{children:[i.jsx(c,{children:" "}),i.jsx(m,{width:Gs,children:i.jsx(c,{bold:!0,color:"gray",children:" · "})}),i.jsx(c,{dimColor:!0,children:"Waiting for task..."})]},`par-empty-${String(E)}`))}return i.jsxs(m,{borderColor:f,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[i.jsxs(m,{flexShrink:0,paddingX:1,children:[i.jsx(c,{bold:!0,inverse:!0,children:" VIS "}),i.jsx(c,{children:` ${h}`}),!s&&i.jsxs(m,{flexGrow:1,gap:0,justifyContent:"flex-end",children:[i.jsx(m,{justifyContent:"flex-end",width:_s,children:i.jsx(c,{dimColor:!0,children:"Cache"})}),i.jsx(m,{justifyContent:"flex-end",width:qs,children:i.jsx(c,{dimColor:!0,children:"Duration"})})]})]}),i.jsx(Rs,{flexGrow:1,flexShrink:1,paddingX:1,paddingY:1,ref:u,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:d.map(E=>i.jsx(hs,{compact:s,focused:r,isSelected:E.taskId===l,pinLabel:us(E.taskId,n),row:E},E.taskId))}),O&&i.jsx(m,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexDirection:"column",flexShrink:0,paddingX:1,paddingY:1,children:$}),e&&i.jsxs(m,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexShrink:0,paddingX:1,children:[i.jsx(c,{bold:!0,color:"white",children:"/ "}),i.jsx(c,{children:t}),i.jsx(c,{inverse:!0,children:" "})]})]})},ps=40,gs=10,ms=100,Ln=Object.freeze([]),Nn=({autoExitSeconds:s,onRetryService:e,parallelSlots:t,projectNames:r,serviceDockStore:a,stdinRegistry:o,store:n,targets:d,tasks:u})=>{const{exit:g}=$r(),{columns:h,rows:f}=br(),l=H.useSyncExternalStore(n.subscribe,n.getSnapshot),j=H.useCallback(T=>a?a.subscribe(T):()=>{},[a]);H.useSyncExternalStore(j,()=>a?a.getDockState():"ready");const C=a?a.getIds():Ln,U=C.length>0,[O,$]=H.useState(0),[E,S]=H.useState(null),x=H.useSyncExternalStore(j,()=>E&&a?a.getState(E):void 0),[P,w]=H.useState(!1),B=H.useRef(null),b=H.useRef(null),F=H.useRef(null),[V,se]=H.useState(!1),[fe,W]=H.useState(!0),Y=H.useRef({list:0,splitList:0,splitOutput:0}),ce=H.useCallback(()=>{l.viewMode==="list"?Y.current.list=b.current?.getScrollOffset()??0:l.viewMode==="split"&&(Y.current.splitList=b.current?.getScrollOffset()??0,Y.current.splitOutput=F.current?.getScrollOffset()??0)},[l.viewMode]),re=H.useCallback(T=>{setTimeout(()=>{if(T==="list"){const k=Y.current.list;b.current?.scrollTo(k)}else if(T==="split"){const k=Y.current.splitList;k>0?b.current?.scrollTo(k):b.current?.scrollTo(Math.max(0,n.getSnapshot().selectedIndex-2)),F.current?.scrollTo(Y.current.splitOutput)}},0)},[n]),ae=H.useRef(!1);H.useEffect(()=>{l.done&&!ae.current&&(ae.current=!0,s>0&&l.failed===0&&se(!0)),!l.done&&ae.current&&(ae.current=!1,se(!1))},[l.done,l.failed,s]);const ne=H.useMemo(()=>{const T=C.length>0?new Set(C):null,k=l.filterText?l.filterText.toLowerCase():null,I=[];for(const te of l.rows)T?.has(te.taskId)||l.statusFilter==="failed"&&te.status!=="failure"||l.statusFilter==="running"&&te.status!=="running"&&te.status!=="pending"||l.statusFilter==="passed"&&te.status!=="success"&&!Ne(te.status)||k&&!te.taskId.toLowerCase().includes(k)||I.push(te);return I},[l.rows,l.filterText,l.statusFilter,C]),z=(ne[l.selectedIndex]??null)?.taskId??null,_=E?null:l.pinnedTaskIds[0]??z,Q=_?l.rows.find(T=>T.taskId===_):null,pe=x??null,je=E?(pe?.tailLines??[]).join(`
15
- `):_?l.outputs.get(_)??"":"",M=H.useMemo(()=>Q?.status==="failure"&&je?Ls(je,{color:!process.env.NO_COLOR,cwd:process.cwd()}):je,[Q?.status,je]),ge=E??_,Ce=E?pe?.status==="crashed"||pe?.status==="failed"?"failure":"running":Q?.status,Me=jt(r,d,u),Be=l.done?`Completed ${Me} (${De((l.endTime??Date.now())-l.startTime)})`:`Running ${Me}...`,Fe=l.done?l.failed>0?"error":"success":"running",ee=H.useCallback(T=>{b.current?.scrollTo(Math.max(0,T-2))},[]);if(H.useEffect(()=>{l.interactiveMode&&Q?.status!=="running"&&n.setInteractiveMode(!1)},[l.interactiveMode,Q?.status,n]),H.useEffect(()=>{if(!_)return;let T=h;l.viewMode==="split"&&h>=ms?T=h-Math.floor(h*.4)-2:(l.viewMode==="split"||l.viewMode==="fullscreen")&&(T=h-2);const k=Math.max(1,f-4);o.get(_)?.resize?.(T,k)},[h,f,l.viewMode,_]),Xt((T,k)=>{if(k.escape){n.setInteractiveMode(!1);return}if(!_)return;const I=o.get(_);if(!I){n.setInteractiveMode(!1);return}if(k.return)I.write("\r");else if(k.upArrow)I.write("\x1B[A");else if(k.downArrow)I.write("\x1B[B");else if(k.rightArrow)I.write("\x1B[C");else if(k.leftArrow)I.write("\x1B[D");else if(k.backspace)I.write("");else if(k.delete)I.write("\x1B[3~");else if(k.tab)I.write(" ");else if(k.home)I.write("\x1B[H");else if(k.end)I.write("\x1B[F");else if(k.pageUp)I.write("\x1B[5~");else if(k.pageDown)I.write("\x1B[6~");else if(k.ctrl&&T){const te=T.toUpperCase().codePointAt(0);te!==void 0&&te>=65&&te<=90&&I.write(String.fromCodePoint(te-64))}else T&&I.write(T)},{isActive:l.interactiveMode}),Xt((T,k)=>{if(T==="c"&&k.ctrl){g();return}if(!V){if(P){k.escape||T==="?"?w(!1):T==="q"?(w(!1),se(!0)):k.downArrow||T==="j"?B.current?.scrollBy(1):k.upArrow||T==="k"?B.current?.scrollBy(-1):k.pageDown?B.current?.scrollBy(5):k.pageUp?B.current?.scrollBy(-5):k.home?B.current?.scrollToTop():k.end&&B.current?.scrollToBottom();return}if(T==="?"){w(!0);return}if(T==="q"){se(!0);return}if(T==="r"&&l.done){n.requestRerun();return}if(T==="R"&&l.done){const I=ne[l.selectedIndex];I?.status==="failure"&&n.requestRetry(I.taskId);return}if(T==="F"&&!l.filterActive){const I=["all","failed","running","passed"],te=I.indexOf(l.statusFilter);n.setStatusFilter(I[(te+1)%I.length]);return}if(l.filterActive){if(k.escape){n.setFilterActive(!1);return}if(k.return){n.setFilterActive(!1);return}if(k.backspace){n.setFilter(l.filterText.slice(0,-1));return}if(T&&!k.ctrl&&!k.meta){n.setFilter(l.filterText+T);return}return}if(T==="i"&&Q?.status==="running"&&(l.viewMode==="fullscreen"||l.viewMode==="split"&&l.focusedPanel==="output")){n.setInteractiveMode(!0);return}if(l.viewMode==="fullscreen"){if(k.escape){n.setViewMode("split"),re("split");return}if(T==="f"){const I=!fe;W(I),I&&F.current?.scrollToBottom();return}if(k.downArrow||T==="j"){W(!1),F.current?.scrollBy(1);return}if(k.upArrow||T==="k"){W(!1),F.current?.scrollBy(-1);return}if(k.pageDown||k.ctrl&&T==="d"){W(!1),F.current?.scrollBy(12);return}if(k.pageUp||k.ctrl&&T==="u"){W(!1),F.current?.scrollBy(-12);return}if(k.home){W(!1),F.current?.scrollToTop();return}if(k.end){W(!0),F.current?.scrollToBottom();return}return}if(l.focusedPanel==="dock"&&U&&a){if(k.tab){S(null),n.setFocusedPanel("tasks");return}if(k.escape){n.setFocusedPanel("tasks"),S(null),l.viewMode==="split"&&(n.setViewMode("list"),re("list"));return}if(k.downArrow||T==="j"){$(I=>Math.min(I+1,C.length-1));return}if(k.upArrow||T==="k"){$(I=>Math.max(I-1,0));return}if(k.return){const I=C[O];I&&(S(I),W(!0),ce(),Y.current.splitList=0,Y.current.splitOutput=0,n.setViewMode("split"),n.setFocusedPanel("output"),re("split"));return}if((T==="r"||T==="R")&&e){const I=C[O],te=I?a.getState(I)?.status:void 0;if(I&&(te==="crashed"||te==="failed")){const Te=e(I);Te instanceof Promise&&Te.catch(()=>{})}return}return}if(l.viewMode==="split"){if(k.tab){l.focusedPanel==="tasks"?n.setFocusedPanel("output"):U?n.setFocusedPanel("dock"):(S(null),n.setFocusedPanel("tasks"));return}if(l.focusedPanel==="output"){if(k.escape){if(E&&U){S(null),n.setViewMode("list"),n.setFocusedPanel("dock"),re("list");return}S(null),n.setFocusedPanel("tasks");return}if(k.return){ce(),n.setViewMode("fullscreen");return}if(T==="f"){const I=!fe;W(I),I&&F.current?.scrollToBottom();return}if(k.downArrow||T==="j"){W(!1),F.current?.scrollBy(1);return}if(k.upArrow||T==="k"){W(!1),F.current?.scrollBy(-1);return}if(k.pageDown||k.ctrl&&T==="d"){W(!1),F.current?.scrollBy(12);return}if(k.pageUp||k.ctrl&&T==="u"){W(!1),F.current?.scrollBy(-12);return}if(k.home){W(!1),F.current?.scrollToTop();return}if(k.end){W(!0),F.current?.scrollToBottom();return}return}if(k.escape){n.setViewMode("list"),re("list");return}if(k.return){n.setFocusedPanel("output");return}}if(l.viewMode==="list"||l.viewMode==="split"&&l.focusedPanel==="tasks"){if(k.tab&&l.viewMode==="list"&&U){n.setFocusedPanel("dock");return}if(k.downArrow||T==="j"){const I=Math.min(l.selectedIndex+1,Math.max(0,ne.length-1));n.setSelectedIndex(I),ee(I);return}if(k.upArrow||T==="k"){const I=Math.max(l.selectedIndex-1,0);n.setSelectedIndex(I),ee(I);return}if(k.return&&l.viewMode==="list"){W(!0),ce(),Y.current.splitList=0,Y.current.splitOutput=0,n.setViewMode("split"),n.setFocusedPanel("output"),re("split");return}if(T==="/"){n.setFilterActive(!0);return}if(T==="1"&&z){n.pinTask(0,z);return}if(T==="2"&&z){n.pinTask(1,z);return}if(T==="0"){n.clearPins();return}k.escape&&l.filterText&&n.setFilter("")}}},{isActive:!l.interactiveMode}),h<ps||f<gs)return i.jsx(m,{alignItems:"center",height:f,justifyContent:"center",width:h,children:i.jsxs(c,{color:"yellow",children:["Terminal too small (",h,"x",f,"). Minimum:"," ",ps,"x",gs]})});const Pe=i.jsxs(m,{gap:1,children:[l.succeeded>0&&i.jsxs(c,{bold:!0,color:"green",children:["✓"," ",l.succeeded]}),l.cached>0&&i.jsxs(c,{dimColor:!0,children:["✓"," ",l.cached]}),l.failed>0&&i.jsxs(c,{bold:!0,color:"red",children:["✗"," ",l.failed]}),l.running>0&&i.jsxs(c,{color:"cyan",children:["◷"," ",l.running]}),i.jsxs(c,{dimColor:!0,children:[l.totalTasks," ","total"]}),l.statusFilter!=="all"&&i.jsxs(c,{color:"yellow",children:["[",l.statusFilter,"]"]})]});let we;if(l.viewMode==="fullscreen")we=[i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"Esc"}),i.jsx(c,{dimColor:!0,children:"BACK"})]},"esc"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"↑↓"}),i.jsx(c,{dimColor:!0,children:"SCROLL"})]},"scroll"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"^u ^d"}),i.jsx(c,{dimColor:!0,children:"PAGE"})]},"page"),...Q?.status==="running"?[i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"i"}),i.jsx(c,{dimColor:!0,children:"INPUT"})]},"i")]:[],i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"q"}),i.jsx(c,{dimColor:!0,children:"QUIT"})]},"q")];else if(l.done){const T=ne[l.selectedIndex]?.status==="failure";we=[i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"q"}),i.jsx(c,{dimColor:!0,children:"QUIT"})]},"q"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"r"}),i.jsx(c,{dimColor:!0,children:"RERUN"})]},"r"),...T?[i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"R"}),i.jsx(c,{dimColor:!0,children:"RETRY"})]},"R")]:[],i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"?"}),i.jsx(c,{dimColor:!0,children:"HELP"})]},"?"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"↑↓"}),i.jsx(c,{dimColor:!0,children:"NAV"})]},"nav"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"F"}),i.jsx(c,{dimColor:!0,children:"FILTER"})]},"F"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"⏎"}),i.jsx(c,{dimColor:!0,children:l.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else l.viewMode==="split"&&l.focusedPanel==="output"?we=[i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"q"}),i.jsx(c,{dimColor:!0,children:"QUIT"})]},"q"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"Esc"}),i.jsx(c,{dimColor:!0,children:"BACK"})]},"esc"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"↑↓"}),i.jsx(c,{dimColor:!0,children:"SCROLL"})]},"scroll"),...Q?.status==="running"?[i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"i"}),i.jsx(c,{dimColor:!0,children:"INPUT"})]},"i")]:[],i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"⏎"}),i.jsx(c,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"Tab"}),i.jsx(c,{dimColor:!0,children:"PANEL"})]},"tab"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"?"}),i.jsx(c,{dimColor:!0,children:"HELP"})]},"?")]:we=[i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"q"}),i.jsx(c,{dimColor:!0,children:"QUIT"})]},"q"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"?"}),i.jsx(c,{dimColor:!0,children:"HELP"})]},"?"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"↑↓"}),i.jsx(c,{dimColor:!0,children:"NAV"})]},"nav"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"/"}),i.jsx(c,{dimColor:!0,children:"FILTER"})]},"/"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"F"}),i.jsx(c,{dimColor:!0,children:"STATUS"})]},"F"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"⏎"}),i.jsx(c,{dimColor:!0,children:l.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...l.viewMode==="split"?[i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"Tab"}),i.jsx(c,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const de=i.jsxs(m,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,justifyContent:"space-between",children:[i.jsx(m,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:we}),i.jsx(m,{flexShrink:0,paddingX:1,children:Pe})]}),ve=i.jsxs(ji,{backgroundColor:"#1e1e1e",footer:i.jsxs(c,{dimColor:!0,children:[i.jsx(c,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",i.jsx(c,{bold:!0,color:"white",children:"?"}),"/",i.jsx(c,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:B,title:"KEYBOARD SHORTCUTS",visible:P,width:52,children:[i.jsxs(m,{flexDirection:"column",marginBottom:1,children:[i.jsxs(m,{marginBottom:1,children:[i.jsx(c,{dimColor:!0,children:"── "}),i.jsx(c,{bold:!0,color:"white",children:"NAVIGATION"})]}),i.jsxs(m,{children:[i.jsx(m,{width:24,children:i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","↑","/k"]}),i.jsx(c,{dimColor:!0,children:" Move up"})]})}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","↓","/j"]}),i.jsx(c,{dimColor:!0,children:" Move down"})]})]}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","Tab"]}),i.jsx(c,{dimColor:!0,children:" Switch panel (split)"})]}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","Esc"]}),i.jsx(c,{dimColor:!0,children:" Back / close"})]}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","Enter"]}),i.jsx(c,{dimColor:!0,children:" Show output / fullscreen"})]})]}),i.jsxs(m,{flexDirection:"column",marginBottom:1,children:[i.jsxs(m,{marginBottom:1,children:[i.jsx(c,{dimColor:!0,children:"── "}),i.jsx(c,{bold:!0,color:"white",children:"VIEWS"})]}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","Enter"]}),i.jsxs(c,{dimColor:!0,children:[" ","List"," ","→"," ","Split"," ","→"," ","Fullscreen"]})]}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","Esc"]}),i.jsxs(c,{dimColor:!0,children:[" ","Fullscreen"," ","→"," ","Split"," ","→"," ","List"]})]})]}),i.jsxs(m,{flexDirection:"column",marginBottom:1,children:[i.jsxs(m,{marginBottom:1,children:[i.jsx(c,{dimColor:!0,children:"── "}),i.jsx(c,{bold:!0,color:"white",children:"ACTIONS"})]}),i.jsxs(m,{children:[i.jsx(m,{width:24,children:i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","/"]}),i.jsx(c,{dimColor:!0,children:" Filter by text"})]})}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","F"]}),i.jsx(c,{dimColor:!0,children:" Filter by status"})]})]}),i.jsxs(m,{children:[i.jsx(m,{width:24,children:i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","1"]}),i.jsx(c,{dimColor:!0,children:"/"}),i.jsx(c,{bold:!0,color:"white",children:"2"}),i.jsx(c,{dimColor:!0,children:" Pin to output pane"})]})}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","0"]}),i.jsx(c,{dimColor:!0,children:" Clear pins"})]})]}),i.jsxs(m,{children:[i.jsx(m,{width:24,children:i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","r"]}),i.jsx(c,{dimColor:!0,children:" Rerun all (done)"})]})}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","R"]}),i.jsx(c,{dimColor:!0,children:" Retry failed task"})]})]}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","i"]}),i.jsx(c,{dimColor:!0,children:" Interactive input (running task)"})]})]}),i.jsxs(m,{flexDirection:"column",marginBottom:1,children:[i.jsxs(m,{marginBottom:1,children:[i.jsx(c,{dimColor:!0,children:"── "}),i.jsx(c,{bold:!0,color:"white",children:"SCROLLING"}),i.jsx(c,{dimColor:!0,children:" (output panel)"})]}),i.jsxs(m,{children:[i.jsx(m,{width:24,children:i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","↑","/k"]}),i.jsx(c,{dimColor:!0,children:" Scroll up"})]})}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","↓","/j"]}),i.jsx(c,{dimColor:!0,children:" Scroll down"})]})]}),i.jsxs(m,{children:[i.jsx(m,{width:24,children:i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","^u"]}),i.jsx(c,{dimColor:!0,children:" Page up"})]})}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","^d"]}),i.jsx(c,{dimColor:!0,children:" Page down"})]})]}),i.jsxs(m,{children:[i.jsx(m,{width:24,children:i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","Home"]}),i.jsx(c,{dimColor:!0,children:" Top"})]})}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","End"]}),i.jsx(c,{dimColor:!0,children:" Bottom (resume follow)"})]})]}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","f"]}),i.jsx(c,{dimColor:!0,children:" Toggle auto-scroll (tail mode)"})]})]}),i.jsxs(m,{flexDirection:"column",children:[i.jsxs(m,{marginBottom:1,children:[i.jsx(c,{dimColor:!0,children:"── "}),i.jsx(c,{bold:!0,color:"white",children:"GENERAL"})]}),i.jsxs(m,{children:[i.jsx(m,{width:24,children:i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","q"]}),i.jsx(c,{dimColor:!0,children:" Quit"})]})}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","?"]}),i.jsx(c,{dimColor:!0,children:" Toggle help"})]})]})]})]}),ye=i.jsx(Sr,{autoExitSeconds:s>0?s:3,onCancel:()=>{se(!1)},visible:V}),Se=U&&a?i.jsx(Dn,{activeIndex:O,focused:l.focusedPanel==="dock",store:a}):null;if(l.viewMode==="fullscreen")return i.jsxs(m,{flexDirection:"column",height:f,width:h,children:[i.jsx(m,{flexGrow:1,children:i.jsx(ds,{autoScroll:fe,duration:Q?.duration??Q?.elapsed,focused:!0,interactiveMode:l.interactiveMode,output:M,scrollRef:F,status:Ce,supportsInteractive:!E,taskId:ge})}),Se,de,ye,ve]});if(l.viewMode==="split"){const T=h>=ms,k=i.jsx(fs,{compact:!0,filterActive:l.filterActive,filterText:l.filterText,focused:l.focusedPanel==="tasks",headerStatus:Fe,parallelSlots:t,pinnedTaskIds:l.pinnedTaskIds,rows:ne,scrollRef:b,selectedIndex:l.selectedIndex,title:Be}),I=i.jsx(ds,{autoScroll:fe,duration:Q?.duration??Q?.elapsed,focused:l.focusedPanel==="output",interactiveMode:l.interactiveMode,output:M,scrollRef:F,showFullscreenHint:!0,status:Ce,supportsInteractive:!E,taskId:ge});if(T){const Te=Math.floor(h*.4);return i.jsxs(m,{flexDirection:"column",height:f,width:h,children:[i.jsxs(m,{flexDirection:"row",flexGrow:1,children:[i.jsx(m,{width:Te,children:k}),i.jsx(m,{flexGrow:1,children:I})]}),Se,de,ye,ve]})}const te=Math.floor(f*.45);return i.jsxs(m,{flexDirection:"column",height:f,width:h,children:[i.jsx(m,{height:te,children:k}),i.jsx(m,{flexGrow:1,children:I}),Se,de,ye,ve]})}return i.jsxs(m,{flexDirection:"column",height:f,width:h,children:[i.jsx(m,{flexGrow:1,children:i.jsx(fs,{filterActive:l.filterActive,filterText:l.filterText,focused:l.focusedPanel!=="dock",headerStatus:Fe,parallelSlots:t,pinnedTaskIds:l.pinnedTaskIds,rows:ne,scrollRef:b,selectedIndex:l.selectedIndex,title:Be})}),Se,de,ye,ve]})},Gn=s=>{const{args:e,autoExit:t=!1,onRetryService:r,outputStyle:a="normal",projectNames:o,serviceDockStore:n,stdinRegistry:d,tasks:u,totalTaskCount:g}=s,h=new it(u,g),f=typeof e.parallel=="number"?e.parallel:3,l=t===!0?3:typeof t=="number"?t:0;let j,C;const U=new Promise(b=>{C=b});let O;const $=()=>{O&&(clearInterval(O),O=void 0)},E=()=>{if(process.stdin.isTTY&&typeof process.stdin.setRawMode=="function")try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause(),process.stdin.unref()},S=()=>{if(d){for(const b of d.values())b.kill?.();d.clear()}},x=()=>{$(),B(),S(),E(),process.stdout.write("\x1B[?1049l\x1B[?25h"),j?.cleanup(),process.exit(1)},P=()=>{const b=h.getSnapshot(),F=De(Date.now()-b.startTime),V=b.rows.filter(W=>W.status==="failure").map(W=>W.taskId),se=process.stdout.columns||80;process.stdout.write(`
16
- `);for(const W of b.rows){const{persistent:Y,status:ce,taskId:re}=W,ae=ce==="running"||ce==="pending",ne=_e(ce),z=ae&&Y?"■":ne.icon,_=ae&&Y?"gray":ne.color;let Q="";switch(ce){case"local-cache":case"local-cache-kept-existing":{Q=" [local cache]";break}case"remote-cache":{Q=" [remote cache]";break}case"skipped":{Q=" [skipped]";break}default:{ae&&Y?Q=" [stopped]":ae&&(Q=" [skipped]");break}}const pe=W.retryAttempts&&W.retryAttempts>0?` [retried ${W.retryAttempts}x]`:"",je=he(X.createElement(c,null," ",X.createElement(c,{color:_},z),` vis run ${re}`,Q?X.createElement(c,{dimColor:!0},` ${Q}`):null,pe?X.createElement(c,{color:"yellow"},pe):null),{columns:se});process.stdout.write(`${je}
10
+ ${h}
11
+ ${s}`}catch{return s}},Ci={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=>Jn(s,Ci),Ge=s=>s==="local-cache"||s==="local-cache-kept-existing"||s==="remote-cache",He=s=>{switch(s){case"failure":return{color:"red",icon:Cs};case"local-cache":case"local-cache-kept-existing":case"remote-cache":case"success":return{color:"green",icon:Is};case"skipped":return{color:"gray",icon:lt};default:return{color:"gray",icon:"?"}}},Ke=s=>{const{color:e,icon:t}=He(s);return me(J.createElement(a,{color:e},t),{columns:10}).trim()},Ei=s=>{const{color:e,icon:t}=He(s);switch(s){case"local-cache":case"local-cache-kept-existing":case"remote-cache":return me(J.createElement(a,null,J.createElement(a,{color:e},t)," ",J.createElement(a,{color:"cyan"},"[cache]")),{columns:30}).trim();case"skipped":return me(J.createElement(a,null,J.createElement(a,{dimColor:!0},t)," ",J.createElement(a,{dimColor:!0},"[skipped]")),{columns:30}).trim();default:return me(J.createElement(a,{color:e},t),{columns:10}).trim()}},Ri=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",Pi=s=>{const e=s.replaceAll(/\W+/g,"_"),t=On("sha256").update(s).digest("hex").slice(0,6);return`${e}_${t}`},Mi=(s,e,t,r="auto")=>{const c=t.trim();if(!c)return;const o=`
12
+ `,i=Ri(r);if(i==="github"){process.stdout.write(`::group::${Ke(e)} ${s}${o}`),process.stdout.write(c+o),process.stdout.write(`::endgroup::${o}`);return}if(i==="gitlab"){const h=Math.floor(Date.now()/1e3),l=Pi(s),b=e==="failure"?"":"[collapsed=true]",T="\x1B[0K";process.stdout.write(`${T}section_start:${String(h)}:${l}${b}\r${T}${Ke(e)} ${s}${o}`),process.stdout.write(c+o);const N=Math.floor(Date.now()/1e3);process.stdout.write(`${T}section_end:${String(N)}:${l}\r${T}${o}`);return}if(i==="buildkite"){const h=e==="failure"?"+++":"---";process.stdout.write(`${h} ${Ke(e)} ${s}${o}`),process.stdout.write(c+o);return}if(i==="azure"){process.stdout.write(`##[group]${Ke(e)} ${s}${o}`),process.stdout.write(c+o),process.stdout.write(`##[endgroup]${o}`);return}const d=process.stdout.columns||80,u=me(J.createElement(a,{dimColor:!0},lt.repeat(d)),{columns:d}).trim(),p=Ei(e),f=me(J.createElement(a,{bold:!0},s),{columns:d}).trim();process.stdout.write(`${u}${o}`),process.stdout.write(`${p} ${f}${o}`),process.stdout.write(c+o),process.stdout.write(`${u}${o}`)},Fi=s=>s==="running"?{color:"white",icon:"•"}:s==="pending"?{color:"gray",icon:"·"}:He(s),Oi=({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"},us=({autoScroll:s=!0,duration:e,focused:t,interactiveMode:r,output:c,scrollRef:o,showFullscreenHint:i,status:d,supportsInteractive:u=!0,taskId:p})=>{const f=d??"pending",{icon:h}=Fi(f),l=t?"bold":"single",b=f==="failure"?"red":f==="success"||Ge(f)?t?"green":"gray":f==="running"?t?"white":"cyan":t?"white":"gray",T=p?`${h} ${p}`:void 0,N=e===void 0?void 0:Be(e),F=Oi({autoScroll:s,focused:t,interactiveMode:r??!1,showFullscreenHint:i??!1,statusValue:f,supportsInteractive:u,taskId:p});if(!p)return n.jsxs(g,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",paddingX:2,paddingY:1,children:[n.jsx(a,{dimColor:!0,children:"Select a task to view output"}),n.jsx(a,{dimColor:!0,children:"Press Enter or 1/2 to pin"})]});const S=[];if(c)for(const E of c.split(`
13
+ `))S.push(E.endsWith("\r")?E.slice(0,-1):E);return!c&&(f==="running"||f==="pending")?n.jsx(g,{borderBottomTitle:F,borderColor:b,borderStyle:l,borderTopRightTitle:N,borderTopTitle:T,flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:n.jsx(g,{alignItems:"center",flexGrow:1,justifyContent:"center",children:n.jsx(a,{dimColor:!0,children:"Waiting for task output…"})})}):n.jsxs(g,{borderBottomTitle:F,borderColor:r?"yellow":b,borderStyle:l,borderTopRightTitle:N,borderTopTitle:T,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(a,{children:S.join(`
14
+ `)})})}),r&&n.jsx(g,{flexShrink:0,justifyContent:"center",paddingX:1,children:n.jsx(a,{bold:!0,color:"yellow",children:"INTERACTIVE | keystrokes forwarded to task | Esc to exit"})})]})},Ai={crashed:"✖",failed:"✖",pending:"·",ready:"●",starting:"•"},Ns=s=>s==="ready"?"green":s==="crashed"||s==="failed"?"red":s==="starting"?"cyan":"gray",Li=({status:s})=>s==="starting"?n.jsx(a,{color:"cyan",children:n.jsx(Rs,{type:"dots"})}):n.jsx(a,{bold:!0,color:Ns(s),children:Ai[s]}),Di=({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(a,{children:c}),n.jsx(a,{children:" "}),n.jsx(g,{flexShrink:0,width:3,children:n.jsx(Li,{status:t.status})}),n.jsx(g,{flexGrow:0,flexShrink:0,width:28,children:n.jsx(a,{bold:r,inverse:r,children:t.id})}),n.jsx(g,{flexGrow:1,flexShrink:1,overflow:"hidden",children:n.jsxs(a,{color:Ns(t.status),dimColor:t.status!=="crashed"&&t.status!=="failed",wrap:"truncate-end",children:[" ",o]})})]})},Bi=({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(a,{bold:!0,color:"green",children:["● ","Services"]}),n.jsxs(a,{children:[" ",String(e.length)," / ",String(s.length)," running"]}),t.length>0&&n.jsxs(a,{dimColor:!0,children:[" ",t]}),n.jsx(a,{dimColor:!0,children:" [Tab ↓]"})]})},_i=({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(a,{bold:!0,color:"red",children:["✖ ","Service crashed:"," ",e.id]}),e.tailLines.slice(-3).map((t,r)=>n.jsxs(a,{color:"red",dimColor:!0,children:[" ",t]},`crash-${String(r)}`))]}):n.jsx(n.Fragment,{})},Ni=({activeIndex:s,focused:e,store:t})=>{const r=U.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)",p=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(Bi,{states:o})}):n.jsxs(g,{borderBottomTitle:p,borderColor:d,borderStyle:e?"bold":"single",borderTopTitle:u,flexDirection:"column",flexGrow:2,flexShrink:0,minHeight:6,paddingX:1,children:[i==="crash"&&n.jsx(_i,{states:o}),o.map((f,h)=>n.jsx(Di,{active:h===s,focused:e,state:f},f.id))]})},Gs=6,Ws=8,Hs=12,Gi=s=>s==="running"||s==="pending"?Es:s==="local-cache"||s==="local-cache-kept-existing"?"Local":s==="remote-cache"?"Remote":lt,fs=(s,e)=>e[0]===s?"[1]":e[1]===s?"[2]":"",hs=({compact:s,focused:e,isSelected:t,pinLabel:r,row:c})=>{const{persistent:o,status:i,taskId:d}=c,u=e&&t,p=u?">":" ",f=i==="running"&&o===!0;let h;if(f)h=n.jsx(a,{bold:!0,color:"green",children:" ● "});else if(i==="running")h=n.jsxs(a,{bold:!0,color:"white",children:[" ",n.jsx(Rs,{type:"dots"})," "]});else if(i==="pending")h=n.jsx(a,{bold:!0,color:"gray",children:" · "});else{const{color:b,icon:T}=He(i);h=n.jsxs(a,{bold:!0,color:b,children:[" ",T," "]})}let l=Es;return f?l="running":i!=="running"&&i!=="pending"?l=c.duration===void 0?lt:Be(c.duration):i==="running"&&c.elapsed!==void 0&&(l=Be(c.elapsed)),n.jsxs(g,{children:[n.jsx(a,{children:p}),n.jsx(g,{width:Gs,children:h}),n.jsxs(g,{flexGrow:1,children:[n.jsx(a,{bold:u,inverse:u,children:d}),r?n.jsx(a,{dimColor:!0,children:` ${r}`}):null]}),!s&&n.jsx(g,{justifyContent:"flex-end",width:Ws,children:n.jsx(a,{dimColor:!Ge(i),children:Gi(i)})}),!s&&n.jsx(g,{justifyContent:"flex-end",width:Hs,children:n.jsx(a,{color:f?"green":void 0,dimColor:i==="pending"||f,children:l})})]})},ps=({compact:s,filterActive:e,filterText:t,focused:r,headerStatus:c,parallelSlots:o=3,pinnedTaskIds:i,rows:d,scrollRef:u,selectedIndex:p,title:f})=>{const h=c==="error"?"red":c==="success"?"green":r?"white":"gray",l=d[p]?.taskId,b=[];let T=0;for(const E of d)E.status==="running"?b.push(E):E.status==="pending"&&(T+=1);const N=Math.min(o,b.length+T),F=N>1,S=[];if(F)for(let E=0;E<N;E++){const I=b[E];I?S.push(n.jsx(hs,{compact:s,focused:r,isSelected:I.taskId===l,pinLabel:fs(I.taskId,i),row:I},`par-${I.taskId}`)):S.push(n.jsxs(g,{children:[n.jsx(a,{children:" "}),n.jsx(g,{width:Gs,children:n.jsx(a,{bold:!0,color:"gray",children:" · "})}),n.jsx(a,{dimColor:!0,children:"Waiting for task..."})]},`par-empty-${String(E)}`))}return n.jsxs(g,{borderColor:h,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[n.jsxs(g,{flexShrink:0,paddingX:1,children:[n.jsx(a,{bold:!0,inverse:!0,children:" VIS "}),n.jsx(a,{children:` ${f}`}),!s&&n.jsxs(g,{flexGrow:1,gap:0,justifyContent:"flex-end",children:[n.jsx(g,{justifyContent:"flex-end",width:Ws,children:n.jsx(a,{dimColor:!0,children:"Cache"})}),n.jsx(g,{justifyContent:"flex-end",width:Hs,children:n.jsx(a,{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(E=>n.jsx(hs,{compact:s,focused:r,isSelected:E.taskId===l,pinLabel:fs(E.taskId,i),row:E},E.taskId))}),F&&n.jsx(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexDirection:"column",flexShrink:0,paddingX:1,paddingY:1,children:S}),e&&n.jsxs(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexShrink:0,paddingX:1,children:[n.jsx(a,{bold:!0,color:"white",children:"/ "}),n.jsx(a,{children:t}),n.jsx(a,{inverse:!0,children:" "})]})]})},ms=40,gs=10,ws=100,Wi=Object.freeze([]),Hi=({autoExitSeconds:s,onRetryService:e,parallelSlots:t,projectNames:r,serviceDockStore:c,stdinRegistry:o,store:i,targets:d,tasks:u})=>{const{exit:p}=br(),{columns:f,rows:h}=Sr(),l=U.useSyncExternalStore(i.subscribe,i.getSnapshot),b=U.useCallback($=>c?c.subscribe($):()=>{},[c]);U.useSyncExternalStore(b,()=>c?c.getDockState():"ready");const T=c?c.getIds():Wi,N=T.length>0,[F,S]=U.useState(0),[E,I]=U.useState(null),j=U.useSyncExternalStore(b,()=>E&&c?c.getState(E):void 0),[R,w]=U.useState(!1),O=U.useRef(null),B=U.useRef(null),k=U.useRef(null),[W,se]=U.useState(!1),[ae,Q]=U.useState(!0),ee=U.useRef({list:0,splitList:0,splitOutput:0}),ie=U.useCallback(()=>{l.viewMode==="list"?ee.current.list=B.current?.getScrollOffset()??0:l.viewMode==="split"&&(ee.current.splitList=B.current?.getScrollOffset()??0,ee.current.splitOutput=k.current?.getScrollOffset()??0)},[l.viewMode]),oe=U.useCallback($=>{setTimeout(()=>{if($==="list"){const x=ee.current.list;B.current?.scrollTo(x)}else if($==="split"){const x=ee.current.splitList;x>0?B.current?.scrollTo(x):B.current?.scrollTo(Math.max(0,i.getSnapshot().selectedIndex-2)),k.current?.scrollTo(ee.current.splitOutput)}},0)},[i]),ge=U.useRef(!1);U.useEffect(()=>{l.done&&!ge.current&&(ge.current=!0,s>0&&l.failed===0&&se(!0)),!l.done&&ge.current&&(ge.current=!1,se(!1))},[l.done,l.failed,s]);const le=U.useMemo(()=>{const $=T.length>0?new Set(T):null,x=l.filterText?l.filterText.toLowerCase():null,C=[];for(const te of l.rows)$?.has(te.taskId)||l.statusFilter==="failed"&&te.status!=="failure"||l.statusFilter==="running"&&te.status!=="running"&&te.status!=="pending"||l.statusFilter==="passed"&&te.status!=="success"&&!Ge(te.status)||x&&!te.taskId.toLowerCase().includes(x)||C.push(te);return C},[l.rows,l.filterText,l.statusFilter,T]),K=(le[l.selectedIndex]??null)?.taskId??null,re=E?null:l.pinnedTaskIds[0]??K,X=re?l.rows.find($=>$.taskId===re):null,Se=j??null,_=E?(Se?.tailLines??[]).join(`
15
+ `):re?l.outputs.get(re)??"":"",z=U.useMemo(()=>X?.status==="failure"&&_?_s(_,{color:!process.env.NO_COLOR,cwd:process.cwd()}):_,[X?.status,_]),we=E??re,Me=E?Se?.status==="crashed"||Se?.status==="failed"?"failure":"running":X?.status,Fe=St(r,d,u),_e=l.done?`Completed ${Fe} (${Be((l.endTime??Date.now())-l.startTime)})`:`Running ${Fe}...`,ne=l.done?l.failed>0?"error":"success":"running",Te=U.useCallback($=>{B.current?.scrollTo(Math.max(0,$-2))},[]);if(U.useEffect(()=>{l.interactiveMode&&X?.status!=="running"&&i.setInteractiveMode(!1)},[l.interactiveMode,X?.status,i]),U.useEffect(()=>{if(!re)return;let $=f;l.viewMode==="split"&&f>=ws?$=f-Math.floor(f*.4)-2:(l.viewMode==="split"||l.viewMode==="fullscreen")&&($=f-2);const x=Math.max(1,h-4);o.get(re)?.resize?.($,x)},[f,h,l.viewMode,re]),Jt(($,x)=>{if(x.escape){i.setInteractiveMode(!1);return}if(!re)return;const C=o.get(re);if(!C){i.setInteractiveMode(!1);return}if(x.return)C.write("\r");else if(x.upArrow)C.write("\x1B[A");else if(x.downArrow)C.write("\x1B[B");else if(x.rightArrow)C.write("\x1B[C");else if(x.leftArrow)C.write("\x1B[D");else if(x.backspace)C.write("");else if(x.delete)C.write("\x1B[3~");else if(x.tab)C.write(" ");else if(x.home)C.write("\x1B[H");else if(x.end)C.write("\x1B[F");else if(x.pageUp)C.write("\x1B[5~");else if(x.pageDown)C.write("\x1B[6~");else if(x.ctrl&&$){const te=$.toUpperCase().codePointAt(0);te!==void 0&&te>=65&&te<=90&&C.write(String.fromCodePoint(te-64))}else $&&C.write($)},{isActive:l.interactiveMode}),Jt(($,x)=>{if($==="c"&&x.ctrl){p();return}if(!W){if(R){x.escape||$==="?"?w(!1):$==="q"?(w(!1),se(!0)):x.downArrow||$==="j"?O.current?.scrollBy(1):x.upArrow||$==="k"?O.current?.scrollBy(-1):x.pageDown?O.current?.scrollBy(5):x.pageUp?O.current?.scrollBy(-5):x.home?O.current?.scrollToTop():x.end&&O.current?.scrollToBottom();return}if($==="?"){w(!0);return}if($==="q"){se(!0);return}if($==="r"&&l.done){i.requestRerun();return}if($==="R"&&l.done){const C=le[l.selectedIndex];C?.status==="failure"&&i.requestRetry(C.taskId);return}if($==="F"&&!l.filterActive){const C=["all","failed","running","passed"],te=C.indexOf(l.statusFilter);i.setStatusFilter(C[(te+1)%C.length]);return}if(l.filterActive){if(x.escape){i.setFilterActive(!1);return}if(x.return){i.setFilterActive(!1);return}if(x.backspace){i.setFilter(l.filterText.slice(0,-1));return}if($&&!x.ctrl&&!x.meta){i.setFilter(l.filterText+$);return}return}if($==="i"&&X?.status==="running"&&(l.viewMode==="fullscreen"||l.viewMode==="split"&&l.focusedPanel==="output")){i.setInteractiveMode(!0);return}if(l.viewMode==="fullscreen"){if(x.escape){i.setViewMode("split"),oe("split");return}if($==="f"){const C=!ae;Q(C),C&&k.current?.scrollToBottom();return}if(x.downArrow||$==="j"){Q(!1),k.current?.scrollBy(1);return}if(x.upArrow||$==="k"){Q(!1),k.current?.scrollBy(-1);return}if(x.pageDown||x.ctrl&&$==="d"){Q(!1),k.current?.scrollBy(12);return}if(x.pageUp||x.ctrl&&$==="u"){Q(!1),k.current?.scrollBy(-12);return}if(x.home){Q(!1),k.current?.scrollToTop();return}if(x.end){Q(!0),k.current?.scrollToBottom();return}return}if(l.focusedPanel==="dock"&&N&&c){if(x.tab){I(null),i.setFocusedPanel("tasks");return}if(x.escape){i.setFocusedPanel("tasks"),I(null),l.viewMode==="split"&&(i.setViewMode("list"),oe("list"));return}if(x.downArrow||$==="j"){S(C=>Math.min(C+1,T.length-1));return}if(x.upArrow||$==="k"){S(C=>Math.max(C-1,0));return}if(x.return){const C=T[F];C&&(I(C),Q(!0),ie(),ee.current.splitList=0,ee.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),oe("split"));return}if(($==="r"||$==="R")&&e){const C=T[F],te=C?c.getState(C)?.status:void 0;if(C&&(te==="crashed"||te==="failed")){const Ae=e(C);Ae instanceof Promise&&Ae.catch(()=>{})}return}return}if(l.viewMode==="split"){if(x.tab){l.focusedPanel==="tasks"?i.setFocusedPanel("output"):N?i.setFocusedPanel("dock"):(I(null),i.setFocusedPanel("tasks"));return}if(l.focusedPanel==="output"){if(x.escape){if(E&&N){I(null),i.setViewMode("list"),i.setFocusedPanel("dock"),oe("list");return}I(null),i.setFocusedPanel("tasks");return}if(x.return){ie(),i.setViewMode("fullscreen");return}if($==="f"){const C=!ae;Q(C),C&&k.current?.scrollToBottom();return}if(x.downArrow||$==="j"){Q(!1),k.current?.scrollBy(1);return}if(x.upArrow||$==="k"){Q(!1),k.current?.scrollBy(-1);return}if(x.pageDown||x.ctrl&&$==="d"){Q(!1),k.current?.scrollBy(12);return}if(x.pageUp||x.ctrl&&$==="u"){Q(!1),k.current?.scrollBy(-12);return}if(x.home){Q(!1),k.current?.scrollToTop();return}if(x.end){Q(!0),k.current?.scrollToBottom();return}return}if(x.escape){i.setViewMode("list"),oe("list");return}if(x.return){i.setFocusedPanel("output");return}}if(l.viewMode==="list"||l.viewMode==="split"&&l.focusedPanel==="tasks"){if(x.tab&&l.viewMode==="list"&&N){i.setFocusedPanel("dock");return}if(x.downArrow||$==="j"){const C=Math.min(l.selectedIndex+1,Math.max(0,le.length-1));i.setSelectedIndex(C),Te(C);return}if(x.upArrow||$==="k"){const C=Math.max(l.selectedIndex-1,0);i.setSelectedIndex(C),Te(C);return}if(x.return&&l.viewMode==="list"){Q(!0),ie(),ee.current.splitList=0,ee.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),oe("split");return}if($==="/"){i.setFilterActive(!0);return}if($==="1"&&K){i.pinTask(0,K);return}if($==="2"&&K){i.pinTask(1,K);return}if($==="0"){i.clearPins();return}x.escape&&l.filterText&&i.setFilter("")}}},{isActive:!l.interactiveMode}),f<ms||h<gs)return n.jsx(g,{alignItems:"center",height:h,justifyContent:"center",width:f,children:n.jsxs(a,{color:"yellow",children:["Terminal too small (",f,"x",h,"). Minimum:"," ",ms,"x",gs]})});const Oe=n.jsxs(g,{gap:1,children:[l.succeeded>0&&n.jsxs(a,{bold:!0,color:"green",children:["✓"," ",l.succeeded]}),l.cached>0&&n.jsxs(a,{dimColor:!0,children:["✓"," ",l.cached]}),l.failed>0&&n.jsxs(a,{bold:!0,color:"red",children:["✗"," ",l.failed]}),l.running>0&&n.jsxs(a,{color:"cyan",children:["◷"," ",l.running]}),n.jsxs(a,{dimColor:!0,children:[l.totalTasks," ","total"]}),l.statusFilter!=="all"&&n.jsxs(a,{color:"yellow",children:["[",l.statusFilter,"]"]})]});let fe;if(l.viewMode==="fullscreen")fe=[n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"Esc"}),n.jsx(a,{dimColor:!0,children:"BACK"})]},"esc"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"↑↓"}),n.jsx(a,{dimColor:!0,children:"SCROLL"})]},"scroll"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"^u ^d"}),n.jsx(a,{dimColor:!0,children:"PAGE"})]},"page"),...X?.status==="running"?[n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"i"}),n.jsx(a,{dimColor:!0,children:"INPUT"})]},"i")]:[],n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"q"}),n.jsx(a,{dimColor:!0,children:"QUIT"})]},"q")];else if(l.done){const $=le[l.selectedIndex]?.status==="failure";fe=[n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"q"}),n.jsx(a,{dimColor:!0,children:"QUIT"})]},"q"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"r"}),n.jsx(a,{dimColor:!0,children:"RERUN"})]},"r"),...$?[n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"R"}),n.jsx(a,{dimColor:!0,children:"RETRY"})]},"R")]:[],n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"?"}),n.jsx(a,{dimColor:!0,children:"HELP"})]},"?"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"↑↓"}),n.jsx(a,{dimColor:!0,children:"NAV"})]},"nav"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"F"}),n.jsx(a,{dimColor:!0,children:"FILTER"})]},"F"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"⏎"}),n.jsx(a,{dimColor:!0,children:l.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else l.viewMode==="split"&&l.focusedPanel==="output"?fe=[n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"q"}),n.jsx(a,{dimColor:!0,children:"QUIT"})]},"q"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"Esc"}),n.jsx(a,{dimColor:!0,children:"BACK"})]},"esc"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"↑↓"}),n.jsx(a,{dimColor:!0,children:"SCROLL"})]},"scroll"),...X?.status==="running"?[n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"i"}),n.jsx(a,{dimColor:!0,children:"INPUT"})]},"i")]:[],n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"⏎"}),n.jsx(a,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"Tab"}),n.jsx(a,{dimColor:!0,children:"PANEL"})]},"tab"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"?"}),n.jsx(a,{dimColor:!0,children:"HELP"})]},"?")]:fe=[n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"q"}),n.jsx(a,{dimColor:!0,children:"QUIT"})]},"q"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"?"}),n.jsx(a,{dimColor:!0,children:"HELP"})]},"?"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"↑↓"}),n.jsx(a,{dimColor:!0,children:"NAV"})]},"nav"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"/"}),n.jsx(a,{dimColor:!0,children:"FILTER"})]},"/"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"F"}),n.jsx(a,{dimColor:!0,children:"STATUS"})]},"F"),n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"⏎"}),n.jsx(a,{dimColor:!0,children:l.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...l.viewMode==="split"?[n.jsxs(g,{gap:1,children:[n.jsx(a,{bold:!0,color:"white",children:"Tab"}),n.jsx(a,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const xe=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:fe}),n.jsx(g,{flexShrink:0,paddingX:1,children:Oe})]}),$e=n.jsxs(Tr,{backgroundColor:"#1e1e1e",footer:n.jsxs(a,{dimColor:!0,children:[n.jsx(a,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",n.jsx(a,{bold:!0,color:"white",children:"?"}),"/",n.jsx(a,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:O,title:"KEYBOARD SHORTCUTS",visible:R,width:52,children:[n.jsxs(g,{flexDirection:"column",marginBottom:1,children:[n.jsxs(g,{marginBottom:1,children:[n.jsx(a,{dimColor:!0,children:"── "}),n.jsx(a,{bold:!0,color:"white",children:"NAVIGATION"})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","↑","/k"]}),n.jsx(a,{dimColor:!0,children:" Move up"})]})}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","↓","/j"]}),n.jsx(a,{dimColor:!0,children:" Move down"})]})]}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","Tab"]}),n.jsx(a,{dimColor:!0,children:" Switch panel (split)"})]}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","Esc"]}),n.jsx(a,{dimColor:!0,children:" Back / close"})]}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","Enter"]}),n.jsx(a,{dimColor:!0,children:" Show output / fullscreen"})]})]}),n.jsxs(g,{flexDirection:"column",marginBottom:1,children:[n.jsxs(g,{marginBottom:1,children:[n.jsx(a,{dimColor:!0,children:"── "}),n.jsx(a,{bold:!0,color:"white",children:"VIEWS"})]}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","Enter"]}),n.jsxs(a,{dimColor:!0,children:[" ","List"," ","→"," ","Split"," ","→"," ","Fullscreen"]})]}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","Esc"]}),n.jsxs(a,{dimColor:!0,children:[" ","Fullscreen"," ","→"," ","Split"," ","→"," ","List"]})]})]}),n.jsxs(g,{flexDirection:"column",marginBottom:1,children:[n.jsxs(g,{marginBottom:1,children:[n.jsx(a,{dimColor:!0,children:"── "}),n.jsx(a,{bold:!0,color:"white",children:"ACTIONS"})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","/"]}),n.jsx(a,{dimColor:!0,children:" Filter by text"})]})}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","F"]}),n.jsx(a,{dimColor:!0,children:" Filter by status"})]})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","1"]}),n.jsx(a,{dimColor:!0,children:"/"}),n.jsx(a,{bold:!0,color:"white",children:"2"}),n.jsx(a,{dimColor:!0,children:" Pin to output pane"})]})}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","0"]}),n.jsx(a,{dimColor:!0,children:" Clear pins"})]})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","r"]}),n.jsx(a,{dimColor:!0,children:" Rerun all (done)"})]})}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","R"]}),n.jsx(a,{dimColor:!0,children:" Retry failed task"})]})]}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","i"]}),n.jsx(a,{dimColor:!0,children:" Interactive input (running task)"})]})]}),n.jsxs(g,{flexDirection:"column",marginBottom:1,children:[n.jsxs(g,{marginBottom:1,children:[n.jsx(a,{dimColor:!0,children:"── "}),n.jsx(a,{bold:!0,color:"white",children:"SCROLLING"}),n.jsx(a,{dimColor:!0,children:" (output panel)"})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","↑","/k"]}),n.jsx(a,{dimColor:!0,children:" Scroll up"})]})}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","↓","/j"]}),n.jsx(a,{dimColor:!0,children:" Scroll down"})]})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","^u"]}),n.jsx(a,{dimColor:!0,children:" Page up"})]})}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","^d"]}),n.jsx(a,{dimColor:!0,children:" Page down"})]})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","Home"]}),n.jsx(a,{dimColor:!0,children:" Top"})]})}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","End"]}),n.jsx(a,{dimColor:!0,children:" Bottom (resume follow)"})]})]}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","f"]}),n.jsx(a,{dimColor:!0,children:" Toggle auto-scroll (tail mode)"})]})]}),n.jsxs(g,{flexDirection:"column",children:[n.jsxs(g,{marginBottom:1,children:[n.jsx(a,{dimColor:!0,children:"── "}),n.jsx(a,{bold:!0,color:"white",children:"GENERAL"})]}),n.jsxs(g,{children:[n.jsx(g,{width:24,children:n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","q"]}),n.jsx(a,{dimColor:!0,children:" Quit"})]})}),n.jsxs(a,{children:[n.jsxs(a,{bold:!0,color:"white",children:[" ","?"]}),n.jsx(a,{dimColor:!0,children:" Toggle help"})]})]})]})]}),ye=n.jsx($r,{autoExitSeconds:s>0?s:3,onCancel:()=>{se(!1)},visible:W}),Ce=N&&c?n.jsx(Ni,{activeIndex:F,focused:l.focusedPanel==="dock",store:c}):null;if(l.viewMode==="fullscreen")return n.jsxs(g,{flexDirection:"column",height:h,width:f,children:[n.jsx(g,{flexGrow:1,children:n.jsx(us,{autoScroll:ae,duration:X?.duration??X?.elapsed,focused:!0,interactiveMode:l.interactiveMode,output:z,scrollRef:k,status:Me,supportsInteractive:!E,taskId:we})}),Ce,xe,ye,$e]});if(l.viewMode==="split"){const $=f>=ws,x=n.jsx(ps,{compact:!0,filterActive:l.filterActive,filterText:l.filterText,focused:l.focusedPanel==="tasks",headerStatus:ne,parallelSlots:t,pinnedTaskIds:l.pinnedTaskIds,rows:le,scrollRef:B,selectedIndex:l.selectedIndex,title:_e}),C=n.jsx(us,{autoScroll:ae,duration:X?.duration??X?.elapsed,focused:l.focusedPanel==="output",interactiveMode:l.interactiveMode,output:z,scrollRef:k,showFullscreenHint:!0,status:Me,supportsInteractive:!E,taskId:we});if($){const Ae=Math.floor(f*.4);return n.jsxs(g,{flexDirection:"column",height:h,width:f,children:[n.jsxs(g,{flexDirection:"row",flexGrow:1,children:[n.jsx(g,{width:Ae,children:x}),n.jsx(g,{flexGrow:1,children:C})]}),Ce,xe,ye,$e]})}const te=Math.floor(h*.45);return n.jsxs(g,{flexDirection:"column",height:h,width:f,children:[n.jsx(g,{height:te,children:x}),n.jsx(g,{flexGrow:1,children:C}),Ce,xe,ye,$e]})}return n.jsxs(g,{flexDirection:"column",height:h,width:f,children:[n.jsx(g,{flexGrow:1,children:n.jsx(ps,{filterActive:l.filterActive,filterText:l.filterText,focused:l.focusedPanel!=="dock",headerStatus:ne,parallelSlots:t,pinnedTaskIds:l.pinnedTaskIds,rows:le,scrollRef:B,selectedIndex:l.selectedIndex,title:_e})}),Ce,xe,ye,$e]})},qi=s=>{const{args:e,autoExit:t=!1,onRetryService:r,outputStyle:c="normal",projectNames:o,serviceDockStore:i,stdinRegistry:d,tasks:u,totalTaskCount:p}=s,f=new ot(u,p),h=typeof e.parallel=="number"?e.parallel:3,l=t===!0?3:typeof t=="number"?t:0;let b,T;const N=new Promise(k=>{T=k});let F;const S=()=>{F&&(clearInterval(F),F=void 0)},E=()=>{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 k of d.values())k.kill?.();d.clear()}},j=()=>{S(),O(),I(),E(),process.stdout.write("\x1B[?1049l\x1B[?25h"),b?.cleanup(),process.exit(1)},R=()=>{const k=f.getSnapshot(),W=Be(Date.now()-k.startTime),se=k.rows.filter(ee=>ee.status==="failure").map(ee=>ee.taskId),ae=process.stdout.columns||80;process.stdout.write(`
16
+ `);for(const ee of k.rows){const{persistent:ie,status:oe,taskId:ge}=ee,le=oe==="running"||oe==="pending",q=He(oe),K=le&&ie?"■":q.icon,re=le&&ie?"gray":q.color;let X="";switch(oe){case"local-cache":case"local-cache-kept-existing":{X=" [local cache]";break}case"remote-cache":{X=" [remote cache]";break}case"skipped":{X=" [skipped]";break}default:{le&&ie?X=" [stopped]":le&&(X=" [skipped]");break}}const Se=ee.retryAttempts&&ee.retryAttempts>0?` [retried ${ee.retryAttempts}x]`:"",_=me(J.createElement(a,null," ",J.createElement(a,{color:re},K),` vis run ${ge}`,X?J.createElement(a,{dimColor:!0},` ${X}`):null,Se?J.createElement(a,{color:"yellow"},Se):null),{columns:ae});process.stdout.write(`${_}
17
17
  `)}process.stdout.write(`
18
- `);const fe=he(X.createElement(Ds,{cached:b.cached,failed:b.failed,failedIds:V,projectNames:o,retriedIds:b.retriedIds.length>0?b.retriedIds:void 0,succeeded:b.succeeded,targets:e.targets,tasks:u,took:F}),{columns:se});if(process.stdout.write(`${fe}
19
- `),a!=="quiet"){const W=[...b.rows.filter(Y=>Y.status!=="failure"),...b.rows.filter(Y=>Y.status==="failure")];for(const Y of W){if(Y.status==="running"||Y.status==="pending")continue;const ce=b.outputs.get(Y.taskId);if(!ce?.trim())continue;const{color:re,icon:ae}=_e(Y.status),ne=he(X.createElement(c,null,`
20
- `,X.createElement(c,{bold:!0,color:re},` ${ae} vis run ${Y.taskId}`)),{columns:se});process.stdout.write(`${ne}
21
-
22
- `);const z=ce.trim().split(`
23
- `).map(_=>` ${_}`).join(`
24
- `);process.stdout.write(`${z}
25
- `)}}};let w;const B=()=>{w&&(clearInterval(w),w=void 0)};return{lifeCycle:{endCommand(){$(),h.markDone(),w||(w=setInterval(()=>{},1e3))},endTasks(b){h.endTasks(b)},printCacheDisabledByTask(b){h.addOutput(b.id,`ⓘ caching disabled by task via disableCache()
26
- `)},printEmptyFingerprintWarning(b,F){h.addOutput(b.id,`ⓘ caching skipped — ${F}
27
- `)},printSelfModifyingSkip(b,F){h.addOutput(b.id,`ⓘ caching skipped — task modified its own input${F.length===1?"":"s"} (${F.join(", ")})
28
- `)},printTaskTerminalOutput(b,F,V){h.getSnapshot().outputs.has(b.id)||h.addOutput(b.id,V)},startCommand(){process.on("SIGINT",x),process.on("SIGTERM",x),w||(w=setInterval(()=>{},1e3)),j=Pr(X.createElement(Nn,{autoExitSeconds:l,onRetryService:r,parallelSlots:f,projectNames:o,serviceDockStore:n,stdinRegistry:d??new Map,store:h,targets:e.targets,tasks:u}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}),j.waitUntilExit().then(()=>{B(),S(),E(),process.removeListener("SIGINT",x),process.removeListener("SIGTERM",x),P(),C()}).catch(()=>{B(),S(),E(),process.removeListener("SIGINT",x),process.removeListener("SIGTERM",x),C()})},startTasks(b){h.startTasks(b),O||(O=setInterval(()=>{h.tick()},100))}},renderIsDone:U,store:h}},_n=s=>s==="quiet"?"quiet":"normal",qn=(s,e)=>typeof s=="string"?_n(s.toLowerCase()):e===!0?"quiet":"normal",Wn=(s,e)=>{const t=s.overrides.visOptions;return t?.outputStyle==="normal"||t?.outputStyle==="quiet"?t.outputStyle:e};class Un{#e;#r;#s;#i=[];#t=[];#n=[];#o=new Map;#a;#c;#l;#u=0;constructor(e){this.#e=e.projectNames,this.#r=e.args.targets,this.#s=e.tasks,this.#a=e.logReporter,this.#c=e.outputStyle??"normal",this.#l=e.ciGrouping??"auto"}startCommand(){this.#u=Date.now();const e=process.stdout.columns||80,t=`Running ${jt(this.#e,this.#r,this.#s)}`,r=he(X.createElement(gt,{title:t,variant:"info"}),{columns:e});process.stdout.write(r);const a=this.#s[0],o=a?.overrides?Object.entries(a.overrides).filter(([n])=>n!=="command"):[];if(o.length>0){process.stdout.write(`
18
+ `);const Q=me(J.createElement(Ds,{cached:k.cached,failed:k.failed,failedIds:se,projectNames:o,retriedIds:k.retriedIds.length>0?k.retriedIds:void 0,succeeded:k.succeeded,targets:e.targets,tasks:u,took:W}),{columns:ae});if(process.stdout.write(`${Q}
19
+ `),c!=="quiet"){const ee=[...k.rows.filter(ie=>ie.status!=="failure"),...k.rows.filter(ie=>ie.status==="failure")];for(const ie of ee){if(ie.status==="running"||ie.status==="pending")continue;const oe=k.outputs.get(ie.taskId);if(!oe?.trim())continue;const{color:ge,icon:le}=He(ie.status),q=me(J.createElement(a,null,`
20
+ `,J.createElement(a,{bold:!0,color:ge},` ${le} vis run ${ie.taskId}`)),{columns:ae});process.stdout.write(`${q}
21
+
22
+ `);const K=oe.trim().split(`
23
+ `).map(re=>` ${re}`).join(`
24
+ `);process.stdout.write(`${K}
25
+ `)}}};let w;const O=()=>{w&&(clearInterval(w),w=void 0)};return{lifeCycle:{endCommand(){S(),f.markDone(),w||(w=setInterval(()=>{},1e3))},endTasks(k){f.endTasks(k)},printCacheDisabledByTask(k){f.addOutput(k.id,`ⓘ caching disabled by task via disableCache()
26
+ `)},printEmptyFingerprintWarning(k,W){f.addOutput(k.id,`ⓘ caching skipped — ${W}
27
+ `)},printSelfModifyingSkip(k,W){f.addOutput(k.id,`ⓘ caching skipped — task modified its own input${W.length===1?"":"s"} (${W.join(", ")})
28
+ `)},printTaskTerminalOutput(k,W,se){f.getSnapshot().outputs.has(k.id)||f.addOutput(k.id,se)},startCommand(){process.on("SIGINT",j),process.on("SIGTERM",j),w||(w=setInterval(()=>{},1e3)),b=Ir(J.createElement(Hi,{autoExitSeconds:l,onRetryService:r,parallelSlots:h,projectNames:o,serviceDockStore:i,stdinRegistry:d??new Map,store:f,targets:e.targets,tasks:u}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}),b.waitUntilExit().then(()=>{O(),I(),E(),process.removeListener("SIGINT",j),process.removeListener("SIGTERM",j),R(),T()}).catch(()=>{O(),I(),E(),process.removeListener("SIGINT",j),process.removeListener("SIGTERM",j),T()})},startTasks(k){f.startTasks(k),F||(F=setInterval(()=>{f.tick()},100))}},renderIsDone:N,store:f}},Vi=s=>s==="quiet"?"quiet":"normal",Ui=(s,e)=>typeof s=="string"?Vi(s.toLowerCase()):e===!0?"quiet":"normal",zi=(s,e)=>{const t=s.overrides.visOptions;return t?.outputStyle==="normal"||t?.outputStyle==="quiet"?t.outputStyle:e};class Yi{#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=me(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
- `);for(const[n,d]of o)process.stdout.write(`${gn(" ",n,d)}
30
+ `);for(const[i,d]of o)process.stdout.write(`${vi(" ",i,d)}
31
31
  `)}process.stdout.write(`
32
- `)}startTasks(e){const t=process.stdout.columns||80;for(const r of e){const a=he(X.createElement(c,null,X.createElement(c,{dimColor:!0},">"),` ${r.id}`),{columns:t});process.stdout.write(`${a}
33
- `)}}endTasks(e){const t=process.stdout.columns||80;for(const r of e){this.#o.set(r.task.id,r),r.status==="failure"?this.#i.push(r):Ne(r.status)&&this.#t.push(r),r.retryAttempts&&r.retryAttempts>0&&this.#n.push(r);const a=He(r.status),o=r.startTime&&r.endTime?` (${De(r.endTime-r.startTime)})`:"",n=Ne(r.status)?" [cache]":"",d=r.retryAttempts&&r.retryAttempts>0?` [retried ${r.retryAttempts}x]`:"",u=he(X.createElement(c,null,a,` ${r.task.id}`,n?X.createElement(c,{color:"cyan"},n):null,d?X.createElement(c,{color:"yellow"},d):null,o?X.createElement(c,{dimColor:!0},o):null),{columns:t});process.stdout.write(`${u}
34
- `)}}#d(e){const t=process.stdout.columns||80,r=he(X.createElement(c,{dimColor:!0},` ⓘ ${e}`),{columns:t});process.stdout.write(`${r}
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(Wn(e,this.#c)==="quiet"&&(t==="success"||Ne(t)))return;const a=t==="failure"?Ls(r,{color:!process.env.NO_COLOR,cwd:process.cwd()}):r;if(this.#a){this.#a.printTaskTerminalOutput(e,t,a);return}Cn(e.id,t,a,this.#l)}endCommand(){const e=De(Date.now()-this.#u),t=this.#s.filter(o=>!this.#o.has(o.id)).map(o=>o.id);process.stdout.write(`
36
- `);const r=process.stdout.columns||80,a=he(X.createElement(Ds,{cached:this.#t.length,failed:this.#i.length,failedIds:this.#i.map(o=>o.task.id),projectNames:this.#e,retriedIds:this.#n.length>0?this.#n.map(o=>o.task.id):void 0,skippedIds:t.length>0?t:void 0,succeeded:this.#o.size-this.#i.length-this.#t.length,targets:this.#r,tasks:this.#s,took:e}),{columns:r});process.stdout.write(`${a}
37
- `)}}const zn=async s=>{if(process.env.VIS_NO_SHELL_HISTORY)return;if(Di()==="win32"){try{await Yn(s)}catch{}return}const e=process.env.SHELL;if(!e)return;const t=nr(e);try{if(t==="zsh"){await Vn(s);return}if(t==="bash"){await Hn(s);return}t==="fish"&&await Jn(s)}catch{}},$t=s=>s.replaceAll(/[\u0000-\u001F\u007F]/gu," ").trimEnd(),Vn=async s=>{const e=process.env.HISTFILE??oe(process.env.ZDOTDIR??kt(),".zsh_history"),t=`: ${Math.floor(Date.now()/1e3)}:0;${$t(s)}
38
- `;await ct(e,t)},Hn=async s=>{const e=process.env.HISTFILE??oe(kt(),".bash_history");await ct(e,`${$t(s)}
39
- `)},Yn=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??oe(t,"Microsoft","Windows","PowerShell","PSReadLine","ConsoleHost_history.txt");await Ai($s(r),{recursive:!0}),await ct(r,`${$t(s)}\r
40
- `)},Jn=async s=>{const e=oe(kt(),".local","share","fish","fish_history"),t=`- cmd: ${s.replaceAll("\\","\\\\").replaceAll(`
32
+ `)}startTasks(e){const t=process.stdout.columns||80;for(const r of e){const c=me(J.createElement(a,null,J.createElement(a,{dimColor:!0},">"),` ${r.id}`),{columns:t});process.stdout.write(`${c}
33
+ `)}}endTasks(e){const t=process.stdout.columns||80;for(const r of e){this.#o.set(r.task.id,r),r.status==="failure"?this.#n.push(r):Ge(r.status)&&this.#t.push(r),r.retryAttempts&&r.retryAttempts>0&&this.#i.push(r);const c=Ke(r.status),o=r.startTime&&r.endTime?` (${Be(r.endTime-r.startTime)})`:"",i=Ge(r.status)?" [cache]":"",d=r.retryAttempts&&r.retryAttempts>0?` [retried ${r.retryAttempts}x]`:"",u=me(J.createElement(a,null,c,` ${r.task.id}`,i?J.createElement(a,{color:"cyan"},i):null,d?J.createElement(a,{color:"yellow"},d):null,o?J.createElement(a,{dimColor:!0},o):null),{columns:t});process.stdout.write(`${u}
34
+ `)}}#d(e){const t=process.stdout.columns||80,r=me(J.createElement(a,{dimColor:!0},` ⓘ ${e}`),{columns:t});process.stdout.write(`${r}
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(zi(e,this.#a)==="quiet"&&(t==="success"||Ge(t)))return;const c=t==="failure"?_s(r,{color:!process.env.NO_COLOR,cwd:process.cwd()}):r;if(this.#c){this.#c.printTaskTerminalOutput(e,t,c);return}Mi(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
+ `);const r=process.stdout.columns||80,c=me(J.createElement(Ds,{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 Ki=async s=>{if(process.env.VIS_NO_SHELL_HISTORY)return;if(Ln()==="win32"){try{await Qi(s)}catch{}return}const e=process.env.SHELL;if(!e)return;const t=or(e);try{if(t==="zsh"){await Xi(s);return}if(t==="bash"){await Ji(s);return}t==="fish"&&await Zi(s)}catch{}},Tt=s=>s.replaceAll(/[\u0000-\u001F\u007F]/gu," ").trimEnd(),Xi=async s=>{const e=process.env.HISTFILE??ue(process.env.ZDOTDIR??kt(),".zsh_history"),t=`: ${Math.floor(Date.now()/1e3)}:0;${Tt(s)}
38
+ `;await dt(e,t)},Ji=async s=>{const e=process.env.HISTFILE??ue(kt(),".bash_history");await dt(e,`${Tt(s)}
39
+ `)},Qi=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??ue(t,"Microsoft","Windows","PowerShell","PSReadLine","ConsoleHost_history.txt");await An(Ss(r),{recursive:!0}),await dt(r,`${Tt(s)}\r
40
+ `)},Zi=async s=>{const e=ue(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
- `;await ct(e,t)},Kn=s=>{const{killGracePeriodMs:e=5e3,onTimeout:t,sendSignal:r,timeoutMs:a}=s;if(a<=0)return{cancel:()=>{}};const o=Math.max(e,0);let n;const d=setTimeout(()=>{t?.(),r("SIGTERM"),o>0&&(n=setTimeout(()=>{r("SIGKILL")},o))},a);return{cancel:()=>{clearTimeout(d),n&&clearTimeout(n)}}},Xn=(s,e)=>{const t=e?.trim();if(!t)return{filter:void 0,tasks:[...s]};const r=t.toLowerCase();return{filter:t,tasks:s.filter(a=>a.target.project.toLowerCase().includes(r))}},Qn=[""," 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
- `),Zn=s=>{s.write(`${Qn}
45
- `)},eo=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(a=>{let o="";const n=d=>{o+=typeof d=="string"?d:d.toString("utf8");const u=o.indexOf(`
46
- `);if(u===-1)return;const g=o.slice(0,u).replace(/\r$/,"").trim();if(s.off("data",n),r)try{t.setRawMode?.(!0)}catch{}a(g.length>0?g:void 0)};s.on("data",n)})},to=s=>{const{handlers:e}=s,t=s.input??process.stdin,r=s.output??process.stdout,a=s.promptFilter??eo;if(!t||t.isTTY===!1)return{close:()=>{}};zr(t);const o=t.isRaw===!0;try{t.setRawMode?.(!0)}catch{return{close:()=>{}}}typeof t.resume=="function"&&t.resume();let n=!1;const d=async h=>{if(h.ctrl===!0&&h.name==="c"){await e.onQuit();return}if(!n)switch(h.name){case"?":case"h":{await e.onHelp();break}case"a":{await e.onClearFilter();break}case"p":{n=!0;try{const f=await a(t,r);f===void 0?r.write(`filter cancelled.
47
- `):await e.onFilter(f)}finally{n=!1}break}case"q":{await e.onQuit();break}case"r":{await e.onRerun();break}case"return":{await e.onRerun();break}}},u=(h,f)=>{d(f).catch(l=>{r.write(`[vis watch] keybind handler failed: ${l.message}
48
- `)})},g=t;return g.on("keypress",u),{close:()=>{if(g.off("keypress",u),!o)try{t.setRawMode?.(!1)}catch{}const h=t;if(typeof h.pause=="function")try{h.pause()}catch{}}}},so=s=>{const e=s.overrides.visOptions;return e&&typeof e=="object"?e:void 0},ro=async s=>{const{initialTasks:e,probe:t,registeredEntries:r,taskGraph:a,visVersion:o}=s,n=new Map,d=new Map,u=new Map;for(const w of r)if(Jr(w.pid)){if(w.visVersion!==o){d.set(w.id,w);continue}n.set(w.id,w)}if(t){const w=[...n.values()],B=await Promise.all(w.map(async b=>{try{return[b.id,await t(b)]}catch{return[b.id,!1]}}));for(const[b,F]of B)if(!F){const V=n.get(b);n.delete(b),V&&u.set(b,V)}}const g=new Set(e.map(w=>w.id)),h=new Set,f=[],l=[],j=new Set;for(const w of Object.values(a.dependencies))for(const B of w)j.add(B);for(const[w,B]of Object.entries(a.tasks)){if(!so(B)?.service)continue;if(n.has(w)){h.add(w),l.push(n.get(w));continue}if(g.has(w)||!j.has(w))continue;const b=d.get(w),F=u.get(w);let V;b?V=`Service ${w} is registered with vis ${b.visVersion}, but this invocation is vis ${o}. Restart with \`vis service restart ${w}\` to pick up the new version.`:F?V=`Service ${w} is registered (PID ${String(F.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.`:V=`Target depends on the service ${w}, which is not running. Run \`vis service start ${w}\` first, or invoke \`${w}\` directly.`,f.push({message:V,targetId:w})}if(h.size===0)return{diagnostics:f,initialTasks:e,satisfiedServices:l,serviceDependentsByServiceId:new Map,serviceEnvByTaskId:new Map,taskGraph:a};const C=new Map,U=w=>{const B=new Set,b=[...a.dependencies[w]??[]],F=new Set;for(;b.length>0;){const V=b.pop();if(!F.has(V)){F.add(V),h.has(V)&&B.add(V);for(const se of a.dependencies[V]??[])F.has(se)||b.push(se)}}return[...B].sort()},O=new Map;for(const w of Object.keys(a.dependencies)){if(h.has(w))continue;const B=U(w);if(B.length===0)continue;const b={};for(const F of B){const V=n.get(F);if(!V)continue;Object.assign(b,V.env);const se=O.get(F);se?se.push(w):O.set(F,[w])}Object.keys(b).length>0&&C.set(w,b)}for(const w of O.values())w.sort();const $={};for(const[w,B]of Object.entries(a.tasks))h.has(w)||($[w]=B);const E={};for(const[w,B]of Object.entries(a.dependencies))h.has(w)||(E[w]=B.filter(b=>!h.has(b)));const S=new Map;for(const w of Object.keys($))S.set(w,0);for(const w of Object.values(E))for(const B of w)S.has(B)&&S.set(B,(S.get(B)??0)+1);const x=[];for(const w of a.roots)!h.has(w)&&$[w]&&x.push(w);for(const[w,B]of S)B===0&&!x.includes(w)&&$[w]&&x.push(w);const P=e.filter(w=>!h.has(w.id));return{diagnostics:f,initialTasks:P,satisfiedServices:l,serviceDependentsByServiceId:O,serviceEnvByTaskId:C,taskGraph:{dependencies:E,roots:x,tasks:$}}},io=s=>s.startsWith("./")||s.startsWith("../")||s.startsWith("/")||s.startsWith("**"),no=s=>{let e=s.trim();if(e==="")return;let t=!1,r=!1,a=!1;e.startsWith("...")&&(t=!0,e=e.slice(3),e.startsWith("^")&&(a=!0,e=e.slice(1))),e.endsWith("...")&&(r=!0,e=e.slice(0,-3),e.endsWith("^")&&(a=!0,e=e.slice(0,-1)));let o;const n=/\[([^\]]*)\]$/.exec(e);n&&(o=n[1]??"",e=e.slice(0,n.index));let d=e.trim(),u=!1;return d.startsWith("{")&&d.endsWith("}")&&d.length>=2?(d=d.slice(1,-1),u=!0):io(d)&&(u=!0),{changedSince:o,excludeSelf:a,includeDependencies:r,includeDependents:t,isPath:u,pattern:d}},mt=s=>{let e=s.replaceAll("\\","/");return e.startsWith("./")&&(e=e.slice(2)),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e},oo=(s,e,t)=>s===""?!1:pt(s,e)?!0:t!==void 0&&pt(s,t),ao=(s,e)=>{if(e===void 0||e==="")return!1;const t=mt(s),r=mt(e);return pt(t,r)},co=(s,e,t)=>{const{affected:r,downstream:a,upstream:o}=lr(s,t,{downstream:e.includeDependents?"deep":"none",upstream:e.includeDependencies?"deep":"none"});if(!e.excludeSelf)return r;const n=new Set([...a,...o]);for(const d of s)n.delete(d);return n},lo=async(s,e)=>{const{packageNameByProject:t,projectGraph:r}=e,a=Object.keys(r.nodes);let o=new Set;if(s.pattern!=="")for(const n of a)s.isPath?ao(s.pattern,r.nodes[n]?.data.root)&&o.add(n):oo(s.pattern,n,t?.get(n))&&o.add(n);if(s.changedSince!==void 0){const n=s.changedSince===""?e.defaultBase??"main":s.changedSince,d=e.changedProjectsForRef??uo(e),u=new Set(await d(n));o=s.pattern===""?u:new Set([...o].filter(g=>u.has(g)))}return!s.includeDependents&&!s.includeDependencies?o:co(o,s,r)},uo=s=>async e=>{const{projectGraph:t,workspaceRoot:r}=s;if(!r)return[];let a;try{a=await dr(r,e,"HEAD")}catch(n){const d=n instanceof Error?n.message:String(n);throw new Error(`vis run --filter: invalid changed-since ref "${e}" (${d})`,{cause:n})}const o=new Set;for(const[n,d]of Object.entries(t.nodes)){const u=mt(d.data.root??n);if(!(u===""||u==="."))for(const g of a){const h=or(r,g).replaceAll("\\","/");if(h===u||h.startsWith(`${u}/`)){o.add(n);break}}}return[...o]},ho=async(s,e)=>{const t=new Set;for(const r of s)for(const a of await lo(r,e))t.add(a);return[...t]},fo=async(s,e)=>{const t=[];for(const r of s){const a=no(r);a&&t.push(a)}return ho(t,e)},Qe="[[VIS_BOOT]]",po=250,go=1e3,ws=3,mo=s=>{try{return process.kill(s,0),!0}catch{return!1}},vs=s=>{try{const e=Ge(s,"utf8").trim(),t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:null}catch{return null}};class wo{#e;#r;#s;#i;#t=new Map;#n=new Map;#o=new Map;#a=new Map;#c=new Set;constructor(e){this.#e=e.indexToId,this.#r=new Map(e.services),this.#s=e.sink,this.#i=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 r=((this.#t.get(e)??"")+t).split(`
49
- `),a=r.pop()??"";this.#t.set(e,a);for(const o of r)this.#l(e,o)}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 a=await Kr(this.#i,e);if(!a){this.notifyRegistryFailed(e,"missing-registry-entry");return}const{config:o}=a,n=o.readiness?.tcp?.port??o.port??0,d=o.readiness?.tcp?.host??"127.0.0.1";this.notifyRegistryReady(e,{host:d,logFile:a.logFile,pid:a.pid,port:n})}notifyRegistryReady(e,t){this.#s.ready(e,{host:t.host,port:t.port}),this.#f(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.#h(e),this.#t.delete(e),this.#n.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.#a.keys()])this.#h(e);this.#c.size>0&&(await Promise.race([Promise.all(this.#c),new Promise(e=>{setTimeout(e,2e3)})]),this.#c.clear()),this.#t.clear(),this.#n.clear()}#l(e,t){if(t.startsWith(Qe)){this.#u(e,t.slice(Qe.length));return}const r=this.#n.get(e)??[];r.push(t),r.length>ws&&r.shift(),this.#n.set(e,r),this.#s.log(e,`${t}
50
- `)}#u(e,t){let r;try{r=JSON.parse(t)}catch{this.#s.log(e,`${Qe+t}
51
- `);return}switch(r.event){case"failed":{const a=typeof r.reason=="string"?r.reason:"unknown",o={};for(const[n,d]of Object.entries(r))n!=="event"&&n!=="id"&&n!=="reason"&&(o[n]=d);this.#s.failed(e,a,o);break}case"ready":{const a=typeof r.host=="string"?r.host:"127.0.0.1",o=typeof r.port=="number"?r.port:0;this.#s.ready(e,{host:a,port:o}),this.#d(e);break}case"started":{const a=typeof r.pid=="number"?r.pid:null;this.#s.started(e,a);break}default:this.#s.log(e,`${Qe+t}
52
- `)}}#d(e){const t=this.#r.get(e);if(t?.ephemeral===void 0)return;this.#f(e,t.ephemeral.logFile);const r=vs(t.ephemeral.pidFile);r!==null&&this.#p(e,r)}#f(e,t){if(this.#o.has(e)||!Ae(t))return;const r=Gr(t,"r"),a=(()=>{try{return Qt(t).size}catch{return 0}})(),o={fd:r,logFile:t,pollTimer:setInterval(()=>{this.#m(e)},po),position:a};this.#o.set(e,o)}#m(e){const t=this.#o.get(e);if(t)try{const r=Qt(t.logFile);if(r.size<=t.position)return;const a=Buffer.alloc(r.size-t.position),o=_r(t.fd,a,0,a.length,t.position);if(o>0){t.position+=o;const n=a.subarray(0,o).toString("utf8");for(const d of n.split(`
53
- `))d.length!==0&&this.#w(e,d);this.#s.log(e,n)}}catch{}}#w(e,t){const r=this.#n.get(e)??[];for(r.push(t);r.length>ws;)r.shift();this.#n.set(e,r)}#p(e,t){if(this.#a.has(e))return;const r={pid:t,timer:setInterval(()=>{if(!mo(t)){const a=[...this.#n.get(e)??[]];this.#h(e),this.#s.crashed(e,a)}},go)};this.#a.set(e,r)}#h(e){const t=this.#o.get(e);if(t){clearInterval(t.pollTimer);try{qr(t.fd)}catch{}this.#o.delete(e)}const r=this.#a.get(e);r&&(clearInterval(r.timer),this.#a.delete(e))}#v(e,t){if(t===void 0)return;const r=vs(t.pidFile);if(r!==null)try{process.kill(-r,"SIGTERM")}catch{}const a=Ni("node",[t.scriptPath,t.configFile],{cwd:t.cwd,stdio:["ignore","pipe","pipe"]});a.stdout.on("data",n=>{this.#g(e,n)}),a.stderr.on("data",n=>{this.#g(e,n)}),a.on("error",n=>{this.#s.failed(e,"respawn-error",{message:n.message})});const o=new Promise(n=>{const d=()=>{this.#c.delete(o),n()};a.once("exit",d),a.once("error",d)});this.#c.add(o)}#g(e,t){const r=((this.#t.get(e)??"")+t.toString("utf8")).split(`
54
- `),a=r.pop()??"";this.#t.set(e,a);for(const o of r)this.#l(e,o)}async#y(e,t){if(t!==void 0){try{await Xr({id:e,workspaceRoot:this.#i})}catch{}try{const r=await Qr({command:t.command,config:t.config,cwd:t.cwd,env:t.env,id:e,workspaceRoot:this.#i}),a=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:a})}catch(r){const a=r instanceof Error?r.message:String(r);this.#s.failed(e,"retry-failed",{message:a})}}}}const vo=s=>{const e=s.overrides.visOptions;return e&&typeof e=="object"?e:void 0},Ws=(s,e,t)=>{const r=[],a=[];for(const o of e){const n=t.tasks[o];if(!n){a.push({id:o,reason:"task not in graph"});continue}const d=n.overrides.command;if(!d){a.push({id:o,reason:"no command resolved"});continue}const u=vo(n);if(!u?.service){a.push({id:o,reason:"no service config"});continue}const g=ot(s,n.projectRoot,!!u.runFromWorkspaceRoot),{envFile:h}=u,f=h===void 0||h===!1?{}:yt(g,h),l=u.service.env??{};r.push({command:d,config:u.service,cwd:g,env:{...f,...l},id:o})}return{services:r,skipped:a}},yo=(s,e)=>{const t=new Set(s),r=new Map;for(const n of s){const d=(e.dependencies[n]??[]).filter(u=>t.has(u));r.set(n,new Set(d))}const a=[],o=new Set;for(;r.size>0;){const n=[];for(const[d,u]of r){for(const g of u)o.has(g)&&u.delete(g);u.size===0&&n.push(d)}n.length===0&&n.push(...r.keys());for(const d of n)o.add(d),r.delete(d);n.sort(),a.push({ids:n})}return a},ko=(s,e)=>{const t=[];for(const r of yo(s,e))t.push(...r.ids);return t},xo=String.raw`import { spawn } from "node:child_process";
43
+ `;await dt(e,r)},eo=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)}}},to=(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))}},so=[""," 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
+ `),ro=s=>{s.write(`${so}
45
+ `)},no=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 p=o.slice(0,u).replace(/\r$/,"").trim();if(s.off("data",i),r)try{t.setRawMode?.(!0)}catch{}c(p.length>0?p:void 0)};s.on("data",i)})},io=s=>{const{handlers:e}=s,t=s.input??process.stdin,r=s.output??process.stdout,c=s.promptFilter??no;if(!t||t.isTTY===!1)return{close:()=>{}};zr(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 h=await c(t,r);h===void 0?r.write(`filter cancelled.
47
+ `):await e.onFilter(h)}finally{i=!1}break}case"q":{await e.onQuit();break}case"r":{await e.onRerun();break}case"return":{await e.onRerun();break}}},u=(f,h)=>{d(h).catch(l=>{r.write(`[vis watch] keybind handler failed: ${l.message}
48
+ `)})},p=t;return p.on("keypress",u),{close:()=>{if(p.off("keypress",u),!o)try{t.setRawMode?.(!1)}catch{}const f=t;if(typeof f.pause=="function")try{f.pause()}catch{}}}},oo=s=>{const e=s.overrides.visOptions;return e&&typeof e=="object"?e:void 0},co=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(Jr(w.pid)){if(w.visVersion!==o){d.set(w.id,w);continue}i.set(w.id,w)}if(t){const w=[...i.values()],O=await Promise.all(w.map(async B=>{try{return[B.id,await t(B)]}catch{return[B.id,!1]}}));for(const[B,k]of O)if(!k){const W=i.get(B);i.delete(B),W&&u.set(B,W)}}const p=new Set(e.map(w=>w.id)),f=new Set,h=[],l=[],b=new Set;for(const w of Object.values(c.dependencies))for(const O of w)b.add(O);for(const[w,O]of Object.entries(c.tasks)){if(!oo(O)?.service)continue;if(i.has(w)){f.add(w),l.push(i.get(w));continue}if(p.has(w)||!b.has(w))continue;const W=d.get(w),se=u.get(w);let ae;W?ae=`Service ${w} is registered with vis ${W.visVersion}, but this invocation is vis ${o}. Restart with \`vis service restart ${w}\` to pick up the new version.`:se?ae=`Service ${w} is registered (PID ${String(se.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.`,h.push({message:ae,targetId:w})}if(f.size===0)return{diagnostics:h,initialTasks:e,satisfiedServices:l,serviceDependentsByServiceId:new Map,serviceEnvByTaskId:new Map,taskGraph:c};const T=new Map,N=w=>{const O=new Set,B=[...c.dependencies[w]??[]],k=new Set;for(;B.length>0;){const W=B.pop();if(!k.has(W)){k.add(W),f.has(W)&&O.add(W);for(const se of c.dependencies[W]??[])k.has(se)||B.push(se)}}return[...O].sort()},F=new Map;for(const w of Object.keys(c.dependencies)){if(f.has(w))continue;const O=N(w);if(O.length===0)continue;const B={};for(const k of O){const W=i.get(k);if(!W)continue;Object.assign(B,W.env);const se=F.get(k);se?se.push(w):F.set(k,[w])}Object.keys(B).length>0&&T.set(w,B)}for(const w of F.values())w.sort();const S={};for(const[w,O]of Object.entries(c.tasks))f.has(w)||(S[w]=O);const E={};for(const[w,O]of Object.entries(c.dependencies))f.has(w)||(E[w]=O.filter(B=>!f.has(B)));const I=new Map;for(const w of Object.keys(S))I.set(w,0);for(const w of Object.values(E))for(const O of w)I.has(O)&&I.set(O,(I.get(O)??0)+1);const j=[];for(const w of c.roots)!f.has(w)&&S[w]&&j.push(w);for(const[w,O]of I)O===0&&!j.includes(w)&&S[w]&&j.push(w);const R=e.filter(w=>!f.has(w.id));return{diagnostics:h,initialTasks:R,satisfiedServices:l,serviceDependentsByServiceId:F,serviceEnvByTaskId:T,taskGraph:{dependencies:E,roots:j,tasks:S}}},ao=s=>s.startsWith("./")||s.startsWith("../")||s.startsWith("/")||s.startsWith("**"),lo=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):ao(d)&&(u=!0),{changedSince:o,excludeSelf:c,includeDependencies:r,includeDependents:t,isPath:u,pattern:d}},yt=s=>{let e=s.replaceAll("\\","/");return e.startsWith("./")&&(e=e.slice(2)),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e},uo=(s,e,t)=>s===""?!1:gt(s,e)?!0:t!==void 0&&gt(s,t),fo=(s,e)=>{if(e===void 0||e==="")return!1;const t=yt(s),r=yt(e);return gt(t,r)},ho=(s,e,t)=>{const{affected:r,downstream:c,upstream:o}=lr(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},po=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?fo(s.pattern,r.nodes[i]?.data.root)&&o.add(i):uo(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??mo(e),u=new Set(await d(i));o=s.pattern===""?u:new Set([...o].filter(p=>u.has(p)))}return!s.includeDependents&&!s.includeDependencies?o:ho(o,s,r)},mo=s=>async e=>{const{projectGraph:t,workspaceRoot:r}=s;if(!r)return[];let c;try{c=await dr(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=yt(d.data.root??i);if(!(u===""||u==="."))for(const p of c){const f=cr(r,p).replaceAll("\\","/");if(f===u||f.startsWith(`${u}/`)){o.add(i);break}}}return[...o]},go=async(s,e)=>{const t=new Set;for(const r of s)for(const c of await po(r,e))t.add(c);return[...t]},wo=async(s,e)=>{const t=[];for(const r of s){const c=lo(r);c&&t.push(c)}return go(t,e)},et="[[VIS_BOOT]]",yo=250,vo=1e3,ys=3,xo=s=>{try{return process.kill(s,0),!0}catch{return!1}},vs=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 jo{#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
+ `),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 Qr(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.#v(e,t.registry);return}t.mode==="ephemeral"&&this.#y(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
+ `)}#u(e,t){let r;try{r=JSON.parse(t)}catch{this.#s.log(e,`${et+t}
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=vs(t.ephemeral.pidFile);r!==null&&this.#p(e,r)}#h(e,t){if(this.#o.has(e)||!De(t))return;const r=Wr(t,"r"),c=(()=>{try{return Qt(t).size}catch{return 0}})(),o={fd:r,logFile:t,pollTimer:setInterval(()=>{this.#g(e)},yo),position:c};this.#o.set(e,o)}#g(e){const t=this.#o.get(e);if(t)try{const r=Qt(t.logFile);if(r.size<=t.position)return;const c=Buffer.alloc(r.size-t.position),o=Hr(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(!xo(t)){const c=[...this.#i.get(e)??[]];this.#f(e),this.#s.crashed(e,c)}},vo)};this.#c.set(e,r)}#f(e){const t=this.#o.get(e);if(t){clearInterval(t.pollTimer);try{qr(t.fd)}catch{}this.#o.delete(e)}const r=this.#c.get(e);r&&(clearInterval(r.timer),this.#c.delete(e))}#y(e,t){if(t===void 0)return;const r=vs(t.pidFile);if(r!==null)try{process.kill(-r,"SIGTERM")}catch{}const c=Nn("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
+ `),i=o.pop()??"";this.#t.set(e,i);for(const d of o)this.#l(e,d)}async#v(e,t){if(t!==void 0){try{await Zr({id:e,workspaceRoot:this.#n})}catch{}try{const r=await en({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 ko=s=>{const e=s.overrides.visOptions;return e&&typeof e=="object"?e:void 0},qs=(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=ko(i);if(!u?.service){c.push({id:o,reason:"no service config"});continue}const p=at(s,i.projectRoot,!!u.runFromWorkspaceRoot),{envFile:f}=u,h=f===void 0||f===!1?{}:jt(p,f),l=u.service.env??{};r.push({command:d,config:u.service,cwd:p,env:{...h,...l},id:o})}return{services:r,skipped:c}},bo=(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 p of u)o.has(p)&&u.delete(p);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},So=(s,e)=>{const t=[];for(const r of bo(s,e))t.push(...r.ids);return t},To=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";
57
57
 
@@ -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
- `,jo=()=>{const s=Wr(oe(Bi(),"vis-services-")),e=oe(s,"bootstrap.mjs");return bs(e,xo),{runDir:s,scriptPath:e}},Us=(s,e,t)=>{const r=t.replaceAll(/[^\w-]/g,"_");return{configFile:oe(s,`${r}.json`),logFile:oe(s,`${r}.log`),pidFile:oe(s,`${r}.pid`),scriptPath:e}},$o=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 a={...t.env,PATH:ur(t.cwd,t.env)};return{command:t.command,cwd:t.cwd,env:a,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}},bo=s=>`node ${JSON.stringify(s.scriptPath)} ${JSON.stringify(s.configFile)}`,So=s=>{const{id:e,visBin:t,workspaceRoot:r}=s;return`node ${JSON.stringify(t)} service start ${JSON.stringify(e)} --cwd ${JSON.stringify(r)}`},To=s=>{const{missingServiceIds:e,mode:t,taskGraph:r,visBin:a,workspaceRoot:o}=s,{services:n,skipped:d}=Ws(o,e,r);if(n.length===0)return{chain:[],ephemeralPidFiles:[],runDir:void 0,serviceEnvByTaskId:new Map,skipped:d};const u=ko(n.map($=>$.id),r),g=new Map(n.map($=>[$.id,$])),h=[],f=[];if(t==="ephemeral")for(const $ of u){const E=g.get($);E&&f.push({id:$,payload:$o({paths:{logFile:"",pidFile:""},service:E})})}let l;t==="ephemeral"&&(l=jo());let j;for(const $ of u){const E=g.get($),S=r.tasks[$];if(!E||!S)continue;let x;if(t==="ephemeral"){const P=Us(l.runDir,l.scriptPath,$),w={...f.find(B=>B.id===$).payload,logFile:P.logFile,pidFile:P.pidFile};bs(P.configFile,JSON.stringify(w)),x=bo(P),h.push(P.pidFile)}else x=So({id:$,visBin:a,workspaceRoot:o});if(S.overrides={...S.overrides,command:x},S.cache=!1,r.tasks[$]=S,j!==void 0){const P=r.dependencies[$]??[];P.includes(j)||(r.dependencies[$]=[...P,j])}j=$}const C=new Set(u),U=new Map,O=$=>{const E=new Set,S=[...r.dependencies[$]??[]],x=new Set;for(;S.length>0;){const P=S.pop();if(!x.has(P)){x.add(P),C.has(P)&&E.add(P);for(const w of r.dependencies[P]??[])x.has(w)||S.push(w)}}return[...E].sort()};for(const $ of Object.keys(r.dependencies)){if(C.has($))continue;const E=O($);if(E.length===0)continue;const S={};for(const x of E){const P=g.get(x);P?.config.env&&Object.assign(S,P.config.env)}Object.keys(S).length>0&&U.set($,S)}return{chain:u,ephemeralPidFiles:h,runDir:l?.runDir,serviceEnvByTaskId:U,skipped:d}},Io=new Set(["auto","ephemeral","off","persistent"]),Co=s=>s.cli!==void 0?"cli":s.config===void 0?"default":"config",Ro=s=>{const{cli:e,config:t,isCi:r,isPersistentTarget:a,isTty:o,target:n}=s;if(e!==void 0&&!Io.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":a||n==="dev"?"ephemeral":"registry"},zs=s=>s.replace(/^--?/u,""),Eo=new Set(["0","1","false","no","true","yes"]),Mo=s=>!s.startsWith("-")||/^-(?:\d|\.\d)/u.test(s),ys=(s,e,t,r,a,o)=>{if(r!==void 0)return s.set(e,r),0;const n=a[o+1];return(t?.type??"string")==="boolean"?n!==void 0&&Eo.has(n.toLowerCase())?(s.set(e,n.toLowerCase()),1):(s.set(e,"true"),0):n!==void 0&&Mo(n)?(s.set(e,n),1):(s.set(e,"true"),0)},Fo=(s,e)=>{const t=s.type??"string";if(t==="number"){const r=e.trim(),a=Number(r);return r===""||!Number.isFinite(a)?{error:`--${s.name} expects a number, got "${e}"`}:{value:a}}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}},Po=s=>{const e=[],t=new Set;for(const r of s){const a=r.name||"<unnamed>";(!r.name||!/^[a-zA-Z][\w-]*$/u.test(r.name))&&e.push(`argument name "${a}" is empty or invalid (start with a letter; use letters, digits, '-', '_')`),t.has(r.name)&&e.push(`duplicate argument name "${a}"`),t.add(r.name),r.alias!==void 0&&r.alias.length!==1&&e.push(`argument "${a}" 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 "${a}" has type "enum" but declares no choices`),r.default!==void 0){const n=typeof r.default;o==="number"&&n==="number"||o==="boolean"&&n==="boolean"||(o==="string"||o==="enum")&&n==="string"?o==="enum"&&r.choices&&!r.choices.includes(r.default)&&e.push(`argument "${a}" default "${String(r.default)}" is not one of its choices`):e.push(`argument "${a}" default ${JSON.stringify(r.default)} does not match type "${o}"`)}}return e},Oo=(s,e)=>{const t=new Map,r=new Map;for(const g of s)t.set(g.name,g),g.alias&&r.set(g.alias,g);const a=new Map,o=[];for(let g=0;g<e.length;g+=1){const h=e[g];if(h==="--"){o.push(...e.slice(g+1));break}if(h.startsWith("--no-")){a.set(zs(h.slice(5)),"false");continue}const f=/^--([^=]+)(?:=(.*))?$/su.exec(h);if(f){const C=f[1];g+=ys(a,C,t.get(C),f[2],e,g);continue}const l=/^-([^=-])(?:=(.*))?$/su.exec(h),j=l?.[1];if(l&&j!==void 0){const C=r.get(j);g+=ys(a,C?.name??j,C,l[2],e,g);continue}o.push(h)}const n={},d=[];let u=0;for(const g of s){let h=a.get(g.name);if(h===void 0&&g.positional&&u<o.length&&(h=o[u],u+=1),h===void 0){g.default!==void 0?n[g.name]=g.default:g.required&&d.push(`missing required argument --${g.name}`);continue}const{error:f,value:l}=Fo(g,h);f?d.push(f):l!==void 0&&(n[g.name]=l)}return{errors:d,values:n}},Ao=s=>`VIS_ARG_${zs(s).replaceAll(/[^a-zA-Z0-9]+/gu,"_").toUpperCase()}`,Do=s=>{const e={};for(const[t,r]of Object.entries(s))e[Ao(t)]=String(r);return e},ft=(s,e,t)=>{const r=[`Usage: vis run ${s} [-- <args>]`];if(e&&r.push("",e),t.length===0)return r.join(`
169
- `);r.push("","Arguments:");const a=t.map(n=>{const d=n.positional?`<${n.name}>`:`--${n.name}`,u=n.alias?`, -${n.alias}`:"";return{left:`${d}${u}`,right:n}}),o=Math.max(...a.map(n=>n.left.length));for(const{left:n,right:d}of a){const u=[],g=d.type??"string";u.push(g==="enum"?`enum(${(d.choices??[]).join("|")})`:g),d.required&&u.push("required"),d.default!==void 0&&u.push(`default: ${String(d.default)}`);const h=`${d.description??""}${d.description?" ":""}[${u.join(", ")}]`;r.push(` ${n.padEnd(o)} ${h}`)}return r.join(`
170
- `)},Bo=(s,e,t,r)=>{if(!t||t.length===0)return{env:{},kind:"ok"};const a=Po(t);if(a.length>0)return{errors:a.map(n=>`invalid \`arguments\` schema for "${s}": ${n}`),help:ft(s,e,t),kind:"invalid"};if(r.includes("--help")||r.includes("-h"))return{kind:"help",text:ft(s,e,t)};const o=Oo(t,r);return o.errors.length>0?{errors:o.errors,help:ft(s,e,t),kind:"invalid"}:{env:Do(o.values),kind:"ok"}},bt="VIS_AFFECTED_FILES",Lo=2e3,ks=async(s,e,t,r,a,o)=>{const n=s.map(x=>{const P=x.overrides.command;if(!P)return;const w=x.overrides.visOptions,B=ot(e,x.projectRoot,!!w?.runFromWorkspaceRoot),b=w?.envFile?yt(B,w.envFile):{},F=t&&(w?.affectedFiles==="env"||w?.affectedFiles==="both")?{[bt]:t.join(`
171
- `)}:{},V=o?.get(x.id)??{},se=rn({interactive:!!a,taskPty:x.pty,workspacePty:w?.pty});return{command:P,cwd:B,env:{INIT_CWD:r,...b,...V,...F,...x.overrides[Tt]},name:x.id,...se?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}}).filter(x=>x!==void 0);if(n.length===0)return;if(!a){await Ze(n,{killOthers:["failure"],onEvent:()=>{}});return}const{abortSignal:d,lifeCycle:u,stdinRegistry:g,store:h}=a,f=n.map(x=>s.find(P=>P.id===x.name)).filter(Boolean),l=x=>n[x]?.stdin==="pty",j=new Map,C=x=>{if(!l(x))return;let P=j.get(x);return P||(P=new wt(nt),j.set(x,P)),P};h.unmarkDone(),u.startTasks?.(f);const U=new Map,O=new Map;let $;const E=()=>{for(const x of O.values())try{x("SIGTERM")}catch{}$||($=setTimeout(()=>{for(const x of O.values())try{x("SIGKILL")}catch{}O.clear()},2e3),$.unref?.())};let S;d&&(S=()=>{E()},d.then(()=>{S?.()}).catch(()=>{S?.()}));try{await Ze(n,{killOthers:["failure"],onEvent:x=>{const P=f[x.index];if(P)switch(x.kind){case"close":{const w=U.get(P.id)??Date.now(),B=x.killed||x.exitCode===0?"success":"failure";u.endTasks?.([{code:x.exitCode??0,endTime:Date.now(),startTime:w,status:B,task:P,terminalOutput:h.getSnapshot().outputs.get(P.id)??""}]),O.delete(x.index),g?.delete(P.id);break}case"error":{if(x.message){const w=C(x.index);w?(w.write(`${x.message}
172
- `),h.setOutput(P.id,w.toString())):h.addOutput(P.id,`${x.message}
173
- `)}break}case"started":{U.set(P.id,Date.now()),x.kill&&O.set(x.index,x.kill),x.write&&g&&g.set(P.id,{kill:x.kill,resize:x.resize,write:x.write});break}case"stderr":case"stdout":{if(x.text){const w=C(x.index);w?(w.write(x.text),h.setOutput(P.id,w.toString())):h.addOutput(P.id,`${x.text}
174
- `)}break}}}})}finally{$&&(clearTimeout($),$=void 0),h.markDone()}},xs=s=>{try{return process.kill(-s,0),!0}catch{try{return process.kill(s,0),!0}catch{return!1}}},No=s=>{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,s)},Go=s=>{const{extraPids:e=[],pidFiles:t,runDir:r}=s,a=[],o=n=>{try{process.kill(-n,"SIGTERM")}catch{try{process.kill(n,"SIGTERM")}catch{}}};for(const n of t){let d;try{const u=ar(n),g=Number.parseInt(u.trim(),10);d=Number.isFinite(g)&&g>0?g:void 0}catch{continue}d!==void 0&&(a.push(d),o(d))}for(const n of e)!Number.isFinite(n)||n<=0||(a.push(n),o(n));if(a.length>0){const n=Date.now()+1500;for(;Date.now()<n;){let d=!0;for(const u of a)if(xs(u)){d=!1;break}if(d)break;No(100)}for(const d of a)if(xs(d))try{process.kill(-d,"SIGKILL")}catch{try{process.kill(d,"SIGKILL")}catch{}}}r&&cr(r)},nt=256*1024;class _o{#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
- ${this.#r}`:this.#r}}const Vs=s=>{const e=s.overrides.visOptions;if(e&&typeof e=="object")return e},qo=s=>`'${s.replaceAll("'",String.raw`'\''`)}'`,St=s=>process.platform==="win32"?s.length>0&&!/[\s"&|<>^()%!]/.test(s)?s:`"${s.replaceAll('"','""')}"`:qo(s),Wo=(s,e,t)=>{if(!e||e.length===0||t===!1||t===void 0)return s;if(t==="args"||t==="both"){const r=e.map(a=>St(a)).join(" ");return`${s} ${r}`}return s},Hs="visForwardedArgs",Tt="visTaskArgEnv",Uo=(s,e)=>{const t=e.overrides[Hs];if(!Array.isArray(t)||t.length===0)return s;const r=t.map(a=>St(a)).join(" ");return`${s} ${r}`},zo=async(s,e,t)=>{if(!e)return t();const r=s.get(e)??Promise.resolve();let a;const o=new Promise(d=>{a=d}),n=r.then(()=>o);s.set(e,n),await r;try{return await t()}finally{a(),s.get(e)===n&&s.delete(e)}},Vo=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}}},Ho=(s,e,t)=>{const r=`${e}\0${typeof t=="string"?t:String(t)}`,a=s.get(r);if(a)return a;const o=yt(e,t);return s.set(r,o),o},js=s=>{const e=new Map;return async(t,r)=>{const{affectedFiles:a,currentOs:o,hooks:n,initCwd:d,lifeCycle:u,mutexPool:g,onOutput:h,onOutputReplace:f,retryBudget:l,serviceEnvByTaskId:j,serviceEventBridge:C,stdinRegistry:U,strictEnv:O,taskSlots:$,workspaceRoot:E}=s,S=Vs(t),x=ot(E,r.cwd??t.projectRoot,S?.runFromWorkspaceRoot===!0),P=t.overrides.command;if(!P)return{code:0,terminalOutput:`No command configured for ${t.target.project}:${t.target.target}`};const w=Uo(P,t),B=Wo(w,a,S?.affectedFiles),b=yi(S,o),F=S?.shellArgs,V=F&&F.length>0?F.join(" "):"-c",se=b?`${b} ${V} ${St(B)}`:B,fe=S?.envFile?Ho(e,x,S.envFile):void 0,W={};a&&a.length>0&&(S?.affectedFiles==="env"||S?.affectedFiles==="both")&&(W[bt]=a.join(`
176
- `));const Y=j?.get(t.id),ce={INIT_CWD:d,VIS_TASK_SLOTS:String($),...fe,...Y,...r.env,...W,...t.overrides[Tt]};if(S?.strictEnv??O??!1){const M=dn({command:B,processEnv:process.env,taskEnv:ce,taskId:t.id});if(M){const ge=un(M);return u?.onTaskStderr?.(t,ge),{code:1,terminalOutput:ge}}}const re=S?.pty===!0,ae=!!U,ne=t.pty===!0?!0:t.pty===!1?!1:ae||re;ne&&(t.cache=!1);const z=ne?void 0:new _o(nt),_=ne?new wt(nt):void 0;let Q;const pe=M=>{if(M.kind==="started"&&(Q=M.kill,M.write&&U&&U.set(t.id,{kill:M.kill,resize:M.resize,write:M.write}),C?.onRegistryTaskStarted(t.id)),(M.kind==="stdout"||M.kind==="stderr")&&M.text!==void 0)if(M.kind==="stdout"?u?.onTaskStdout?.(t,M.text):u?.onTaskStderr?.(t,M.text),_)_.write(M.text),ae&&f?.(t.id,_.toString()),C&&C.onTaskOutput(t.id,M.text);else{const ge=`${M.text}
177
- `;z.append(ge),h?.(t.id,ge)}M.kind==="close"&&(U&&U.delete(t.id),C&&C.onRegistryTaskClosed(t.id,M.exitCode??0,!!M.killed).catch(()=>{}))},je=async()=>{const M=S?.retryCount??0,ge=S?.retryDelay,Ce=l?l.claim(M):M,Me=typeof S?.timeout=="number"&&S.timeout>0?S.timeout:0,Be=typeof S?.killGracePeriodMs=="number"&&S.killGracePeriodMs>=0?S.killGracePeriodMs:5e3;let Fe=!1,ee=0;const Pe=Kn({killGracePeriodMs:Be,onTimeout:()=>{Fe=!0},sendSignal:ye=>{Q?.(ye)},timeoutMs:Me});let we;try{we=await Ze([{command:se,cwd:x,env:ce,name:t.id,...ne?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}],{killOthers:["failure"],onEvent:pe,...Ce>0?{restart:{delay:ge??"exponential",onRetry:async(ye,Se,T)=>{ee=ye,n&&await n.callHook("task:retry",t,ye,T)},tries:Ce}}:{}})}finally{Pe.cancel()}const de=we.closeEvents[0],ve=_?_.toString():z.toString();return Fe?{code:124,retryAttempts:ee,terminalOutput:`${ve}
178
- [timeout] Task "${t.id}" exceeded ${Me}ms budget.
179
- `}:{code:de?.exitCode??1,retryAttempts:ee,terminalOutput:ve}};return g?zo(g,S?.mutex,je):je()}},Yo=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)}},Jo=async(s,e)=>{const t=await yr(s,{dataDirectory:et(s)});if(!t){e.warn(`No previous run recorded yet. Run a task at least once to populate ${kr(s,{dataDirectory:et(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(n=>n.exitCode!==void 0&&n.exitCode!==0);e.info("Failed tasks:");for(const n of o){const d=n.duration??0;e.info(` × ${n.taskId} (exit ${String(n.exitCode??-1)}, ${d}ms)`)}e.info("")}const a=[...t.tasks].filter(o=>typeof o.duration=="number").sort((o,n)=>(n.duration??0)-(o.duration??0)).slice(0,5);if(a.length>0){e.info("Slowest tasks:");for(const o of a)e.info(` ${o.taskId.padEnd(40)} ${String(o.duration??0).padStart(6)}ms [${o.cacheStatus}]`);e.info("")}},Ko=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}},Xo=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}},Qo=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}},Ta=async({argument:s,logger:e,options:t,visConfig:r,workspaceRoot:a})=>{if(!a)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const o=a;if(Hr({logger:e,options:t,visConfig:r},o),xi(o),t.lastDetails===!0){await Jo(o,e);return}const n=process.cwd(),d=await Or(o),{config:u,packageJsons:g,projectOptions:h,workspace:f}=Ar(o,r,d),l=Dr(o,f,g);let j=s[0];if(!j){const p=Zt(f);if(process.stdout.isTTY&&process.stdin.isTTY){const v=await oi(p);if(!v){e.info("No target selected.");return}j=v,await zn(`vis run ${v}`)}else{e.info("Available targets:"),e.info(""),e.info(ai(p)),e.info(""),e.info("Usage: vis run <target>");return}}if(u.constraints&&!t.skipConstraints){const p=hr(l,u.constraints);if(p.length>0){for(const v of p)e.error(`[${v.rule}] ${v.message}`);throw new Error(`${p.length} project constraint violation(s) found. Use --skip-constraints to bypass.`)}}if(!t.affected){const p=t.uncommitted===!1?"--no-uncommitted":"--uncommitted",v=[["--base",t.base],["--head",t.head],["--downstream",t.downstream],["--upstream",t.upstream],[p,t.uncommitted]].filter(([,y])=>y!==void 0).map(([y])=>y);if(v.length>0)throw new Xe(`${v.join(", ")} ${v.length===1?"requires":"require"} --affected.
180
- Did you mean: vis run ${j} --affected ${v.map(y=>y.includes("uncommitted")?y:`${y}=…`).join(" ")}
181
- Or use the dedicated command: vis affected ${j} …`)}const C=await fi(j,f,process.cwd(),o),U=ci(h),O=li(C.target,U);O!==C.target&&e.debug?.(`Resolved alias "${C.target}" → "${O}"`);let $=C.projects;const E=s.slice(1).map(String);if(t.projects!==void 0&&($=di($,String(t.projects),Object.keys(f.projects))),t.filter&&t.filter.length>0){const p=new Map;for(const[A,q]of g)p.set(A,q.name);const v=await fo(t.filter,{defaultBase:r?.defaultBase,packageNameByProject:p,projectGraph:l,workspaceRoot:o}),y=new Set(v);if($=$.filter(A=>y.has(A)),$.length===0){e.info(`Filter ${t.filter.map(A=>`"${A}"`).join(", ")} matched no projects.`);return}}if(t.query&&($=pi($,f,t.query),$.length===0)){e.info(`Query "${String(t.query)}" matched no projects.`);return}if(t.tag&&t.tag.length>0&&($=gi($,f,t.tag),$.length===0)){e.info(`Tag filter ${t.tag.map(p=>`"${p}"`).join(", ")} matched no projects.`);return}let S;if(t.affected){const p=await ni({base:t.base,downstream:t.downstream,head:t.head,uncommitted:t.uncommitted,upstream:t.upstream},{projectGraph:l,projects:f.projects,workspaceRoot:o},{defaultBase:r?.defaultBase});for(const y of p.notes)e.info(`▸ ${y}`);if(p.changedFiles.length===0){e.info("No files changed. Nothing to run.");return}const v=new Set(p.affectedProjects);if($=$.filter(y=>v.has(y)),$.length===0){e.info("No projects affected by the changes.");return}S=p.changedFiles,e.info(`Affected projects: ${$.join(", ")}`)}const x=mi(),P=process.env[bt],w=S??(P?P.split(`
182
- `).filter(Boolean):void 0),B=(typeof t.runnerTags=="string"?t.runnerTags:process.env.VIS_RUNNER_TAGS)??void 0,b=B?new Set(B.split(",").map(p=>p.trim()).filter(Boolean)):void 0,F=[],V=new Map;for(const p of $){const v=h.get(p)?.[O];if(!v)continue;const y=v.options;if(!y?.internal){if(!wi(y,!!Ve)){e.debug?.(`Skipping ${p}:${O} — runInCI filter`);continue}if(!vi(y,b)){e.debug?.(`Skipping ${p}:${O} — runner-tags filter`);continue}F.push(p),V.set(p,v)}}if(F.length===0){const p=Zt(f),v=Object.entries(f.projects).filter(([,y])=>y.targets?.[O]!==void 0).map(([y])=>y);if(e.error(`No projects have the "${O}" target.`),v.length>0){e.info(""),e.info(`Target "${O}" 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=ui(O,p,3);y.length>0&&(e.info(""),e.info(y.length===1?`Did you mean "${y[0]}"?`:`Did you mean one of: ${y.map(A=>`"${A}"`).join(", ")}?`)),e.info(""),e.info("Run `vis run` without arguments to see all available targets.")}return}const se=t.pty===!0,fe=F.map(p=>({project:p,schema:V.get(p)?.arguments})).filter(p=>Array.isArray(p.schema)&&p.schema.length>0),W=new Map;for(const{project:p,schema:v}of fe){const y=JSON.stringify(v),A=W.get(y)??[];A.push(p),W.set(y,A)}if(W.size>1){const p=[...W.values()].map(v=>v.join(", ")).join(" | ");throw new Error(`Target "${O}" declares conflicting \`arguments\` schemas across projects (${p}). Run a single project (e.g. \`vis run ${fe[0]?.project}:${O}\` or --projects=<name>) so the argument contract is unambiguous.`)}const Y=fe[0]?.schema,ce=V.get(fe[0]?.project??F[0])?.description,re=Bo(O,ce,Y,E);if(re.kind==="help"){e.info(re.text);return}if(re.kind==="invalid"){e.info(`Invalid arguments for "${O}":`);for(const p of re.errors)e.info(` ✖ ${p}`);throw e.info(""),e.info(re.help),new Error(`Invalid arguments for target "${O}"`)}const ae=re.env,ne=Qo(t.hashMode);let z=F.map(p=>{const v=f.projects[p],y=V.get(p),A={project:p,target:O},q=`${p}:${O}`,J=se?{...y.options,pty:y.options?.pty??!0}:y.options,L=y.command?Ht(y.command,{affectedFiles:w,projectRoot:v?.root}):y.command,D=v?.root&&v.root.length>0?v.root:".",K=(y.outputs??[]).map(R=>typeof R!="string"?R:R.replaceAll("{projectRoot}",D).replaceAll("{projectName}",p));return{cache:y.cache,hashMode:ne??y.hashMode,id:q,outputs:K,overrides:{command:L,...E.length>0?{[Hs]:E}:{},...Object.keys(ae).length>0?{[Tt]:ae}:{},...J?{visOptions:J}:{}},parallelism:y.parallelism,projectRoot:v?.root,target:A}});const _=[],Q=[];for(const p of z)Vs(p)?.persistent?(p.cache=!1,_.push(p)):Q.push(p);z=Q;const pe=fr(t.partition);if(pe&&(z=pr.partitionTasks(z,pe),e.info(`Partition ${pe.index}/${pe.total}: running ${z.length} task(s)`),z.length===0)){e.info("No tasks assigned to this partition.");return}const je=new Set([...z,..._].map(p=>p.id));let M=gr([...z,..._],{onCycleBroken:p=>{e.warn(`Ignoring dev-only dependency cycle (build order is ambiguous): ${p.join(" → ")}`)},projectGraph:l,targetDefaults:u.tasks,workspace:f});for(const[p,v]of Object.entries(M.tasks)){const y=v.target.project,A=v.target.target,q=h.get(y)?.[A];if(!q){je.has(p)||e.warn(`${A} required via dependsOn but no command is configured for ${y} — skipping (no-op).`);continue}const J=f.projects[y];let L=!1;const D={...v.overrides};D.visOptions===void 0&&q.options&&(D.visOptions=q.options,L=!0),D.command===void 0&&q.command&&(D.command=Ht(q.command,{affectedFiles:w,projectRoot:J?.root}),L=!0),L&&(v.overrides=D,M.tasks[p]=v)}if(typeof t.skipCache=="string"&&t.skipCache.trim()!=="")if(t.cache){const p=on(t.skipCache,f,Object.keys(M.tasks));for(const v of p.skipTaskIds){const y=M.tasks[v];y!==void 0&&(y.cache=!1)}p.unmatchedPatterns.length>0&&e.warn(`--skip-cache: no tasks matched ${p.unmatchedPatterns.map(v=>`"${v}"`).join(", ")}`),p.skipTaskIds.size>0&&e.debug?.(`--skip-cache: bypassing cache for ${String(p.skipTaskIds.size)} task(s)`)}else e.debug?.("--skip-cache ignored: --no-cache already disables caching for the whole run");await Yr(o,u.toolchain,{error:p=>{e.error(p)},info:p=>{e.info(p)},warn:p=>{e.warn(p)}},!!t.skipToolchain);const ge=t.preflight!==!1&&u.preflight?.lockfile!==!1,Ce=Lr(o,Ve,{warn:p=>{e.warn(p)}},{skip:!ge});if(!Ce.shouldContinue)throw new Error(`${Ce.formattedMessage??"preflight: lockfile drift detected"} (pass --no-preflight to bypass)`);ge&&!Ve&&process.stdin.isTTY&&process.stdout.isTTY&&await sn(o,{logger:{info:p=>{e.info(p)},warn:p=>{e.warn(p)}},projectManifests:[...g.values()]});const Me=process.env.VIS_VERSION??"0.0.0",Be=t.dryRun?void 0:async p=>{try{return await ii(p.config,{timeoutMs:Lo}),!0}catch{return!1}},Fe=await Zr(o),ee=await ro({initialTasks:[...z,..._],probe:Be,registeredEntries:Fe,taskGraph:M,visVersion:Me}),Pe=[];let we,de=0;const ve=[],ye=new Map;let Se=[];const T=new Set;let k=null,I=null;if(ee.diagnostics.length>0){const p=!!(process.stdout.isTTY&&process.stdin.isTTY),v=t.dryRun?"off":Ro({cli:t.services,config:u.run?.services,isCi:!!Ve,isPersistentTarget:_.length>0,isTty:p,target:O});if(v==="off"){for(const R of ee.diagnostics)e.error(R.message);const D=Co({cli:t.services,config:u.run?.services}),K=[];throw t.dryRun?K.push("`--dry-run` never starts services; drop it to let vis boot them."):D==="default"?K.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."):D==="cli"?K.push("`--services=off` was passed; use `--services=ephemeral` to boot them for this run."):K.push('`run.services: "off"` is set in vis.config.ts; override it with `--services=ephemeral`.'),new Xe([`${ee.diagnostics.length} service dependency error(s) — start the missing services or invoke them directly.`,...K].join(`
183
- `))}const y=ee.diagnostics.map(D=>D.targetId),A=v,q=A==="registry"?Ws(o,y,M):void 0,J=process.argv[1]??"vis",L=To({missingServiceIds:y,mode:A,taskGraph:M,visBin:J,workspaceRoot:o});if(L.skipped.length>0){for(const{id:D,reason:K}of L.skipped)e.error(`Cannot auto-start ${D}: ${K}`);throw new Xe(`${L.skipped.length} service(s) cannot be auto-started — invoke them directly or add a service config.`)}Pe.push(...L.ephemeralPidFiles),we=L.runDir,Se=L.chain;for(const D of L.chain)T.add(D);if(A==="registry"&&(de=L.chain.length,ve.push(...L.chain)),L.chain.length>0){const D=new as(L.chain),K=new Map;if(A==="ephemeral"&&L.runDir)for(const R of L.chain){const G=Us(L.runDir,`${L.runDir}/bootstrap.mjs`,R);K.set(R,{ephemeral:{configFile:G.configFile,cwd:o,logFile:G.logFile,pidFile:G.pidFile,scriptPath:G.scriptPath},mode:"ephemeral"})}else if(A==="registry"&&q)for(const R of q.services)K.set(R.id,{mode:"registry",registry:{command:R.command,config:R.config,cwd:R.cwd,env:R.env}});if(K.size>0){const R=new wo({indexToId:new Map,services:K,sink:{crashed:(G,N)=>{D.markCrashed(G,N)},failed:(G,N,Z)=>{D.markFailed(G,N,Z)},log:(G,N)=>{D.appendLog(G,N)},ready:(G,N)=>{D.markReady(G,N)},started:(G,N)=>{D.markStarted(G,N),A==="registry"&&N!==null&&ye.set(G,N)},starting:G=>{D.markStarting(G)}},workspaceRoot:o});k=D,I=R}}for(const[D,K]of L.serviceEnvByTaskId){const R=ee.serviceEnvByTaskId.get(D)??{};ee.serviceEnvByTaskId.set(D,{...R,...K})}}const te=new Set(_.map(p=>p.id));if(z=ee.initialTasks.filter(p=>!te.has(p.id)),M=ee.taskGraph,Se.length>0&&(z=[...Se.map(p=>M.tasks[p]).filter(p=>p!==void 0),...z]),_.length>0){const p=new Set(_.map(J=>J.id)),v={};for(const[J,L]of Object.entries(M.tasks))p.has(J)||(v[J]=L);const y={};for(const[J,L]of Object.entries(M.dependencies))p.has(J)||(y[J]=L.filter(D=>!p.has(D)));const A=new Set;for(const J of Object.values(y))for(const L of J)A.add(L);const q=Object.keys(v).filter(J=>!A.has(J));M={dependencies:y,roots:q,tasks:v}}const{serviceEnvByTaskId:Te}=ee;if(ee.satisfiedServices.length>0){const p=ee.satisfiedServices.map(v=>v.id).join(", ");if(e.debug?.(`Auto-attached to running services: ${p}`),k)for(const v of ee.satisfiedServices)k.registerService(v.id);else k=new as(ee.satisfiedServices.map(v=>v.id));for(const v of ee.satisfiedServices){const y=v.config.readiness?.tcp?.port??v.config.port??0,A=v.config.readiness?.tcp?.host??"127.0.0.1";k.markReady(v.id,{host:A,port:y})}}if(t.reverse&&(M=mr(M),e.debug?.(`Reversed task graph: ${String(M.roots.length)} new root(s) (originally leaves)`)),t.dryRun){const p=Object.keys(M.tasks).length,v=M.roots.length;e.info(`Execution plan (${String(p)} task(s), ${String(v)} root(s)):`),e.info("");const y=new Set,A=(q,J)=>{if(y.has(q))return;y.add(q);for(const R of M.dependencies[q]??[])A(R,J+1);const L=M.tasks[q],D=" ".repeat(J+1),K=`${L?.cache===!1?" (no-cache)":""}${L?.hashMode==="trace"?" (trace)":""}`;e.info(`${D}${q}${K}`)};for(const q of M.roots)A(q,0);for(const q of Object.keys(M.tasks))A(q,0);_.length>0&&(e.info(""),e.info(` + ${String(_.length)} persistent task(s) (run after graph completes)`)),e.info("");return}const It=Date.now(),Ie=ei(),Ct=(p,v)=>{const y=v instanceof Error?v.message:String(v);e.warn(`Plugin error in ${p}: ${y}`)};await ti(Ie,u.plugins);const qe=typeof t.profile=="string"?t.profile:void 0,Rt=async p=>{if(!qe)return;const v=Kt(p,M,It),y=qe.startsWith("/")?qe:`${o}/${qe}`;await xr(v,y),e.info(`Profile written to ${qe}`)},Ye=u.taskRunner??{},Ys=Tr(o,t.cacheDir,Ye.cacheDirectory,u.sharedWorktreeCache),Js=Ir(Ys,o,u.branchScopedCache),Le=Yo(process.env.VIS_RUN_CONCURRENCY_LIMIT);Le&&"invalid"in Le&&e.warn(`VIS_RUN_CONCURRENCY_LIMIT=${Le.invalid} is not a positive number; falling back to default concurrency.`);const Ks=Le&&"value"in Le?Le.value:void 0,lt=t.parallel??Ks??3,Et=t.strictEnv??u.strictEnv??!1,Mt=new Set,Oe={dryRun:t.dryRun??!1,parallel:lt,skipNxCache:!t.cache,summarize:t.summarize??!1,...Ye,cacheDirectory:Js,dataDirectory:Ye.dataDirectory??et(o),namedInputs:u.namedInputs,onDiagnostic:(p,v)=>{Mt.has(p)||(Mt.add(p),e.warn(v))},onFingerprint:async(p,v)=>{await Ie.callHook("task:fingerprint",p,v)}},Ft=wr(Ye.remoteCache);if(Ft){const p=Ko(t.cacheMode),v=Xo(t.cacheBackend);if(Oe.remoteCache={...Ft,...p?{mode:p}:{},...v?{backend:v}:{}},Oe.remoteCache.attestation){const{expectedIdentity:y,requireOnDownload:A}=Oe.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:q,isSigstoreInstalled:J}=await import("./loader.js");J()||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
- ${q(o)}`);const{buildCacheAttestationHooks:L}=await import("./cache-attestation.js");Oe.remoteCache.attestation=L({expectedIdentity:y,onReject:(D,K)=>{e.warn(`[vis run] remote cache entry ${D.slice(0,12)} rejected: attestation ${K}. Treating as a cache miss.`)},onVerifyFailure:D=>{e.warn(`[vis run] attestation verification failed: ${D}`)},requireOnDownload:A,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 Xs=process.stdout.isTTY&&!Ve,Qs=r?.run?.quietOnSuccess===!0,Zs=u.tui?.autoExit??(Qs?3:!1),Pt={args:{parallel:Oe.parallel,targets:[O]},autoExit:Zs,projectNames:F,tasks:[...z,..._],totalTaskCount:Object.keys(M.tasks).length+_.length},Ot=typeof t.retryBudget=="number"?t.retryBudget:void 0,At=Ot===void 0?void 0:Vo(Ot),Dt=new si(Ie,Ct),Bt=new Vr(o),Lt=qn(t.outputStyle,r?.run?.quietOnSuccess);if(ee.satisfiedServices.length>0)for(const p of ee.satisfiedServices){const v=ee.serviceDependentsByServiceId.get(p.id)??[];try{await Ie.callHook("service:attach",p,v)}catch(y){Ct("service:attach",y)}}await Ie.callHook("run:before",{tasks:z,workspaceRoot:o});const We=t.stopServices===!0;let Nt=!1;const Gt=()=>{if(Nt)return;Nt=!0,I&&I.dispose().catch(()=>{});const p=We?[...ye.values()]:void 0;Go({extraPids:p,pidFiles:Pe,runDir:we})},Je=()=>{Gt()},_t=Pe.length>0||we!==void 0||We&&ve.length>0;_t&&(process.on("SIGINT",Je),process.on("SIGTERM",Je));try{if(Xs){const p=new Map,v=Gn({...Pt,onRetryService:I?R=>I.retry(R):void 0,outputStyle:Lt,serviceDockStore:k,stdinRegistry:p}),{lifeCycle:y,store:A}=v,q=new Yt([y,Dt,Bt]),J=js({affectedFiles:w,currentOs:x,hooks:Ie,initCwd:n,lifeCycle:q,mutexPool:new Map,onOutput:(R,G)=>{I&&T.has(R)?I.onTaskOutput(R,G):A.addOutput(R,G)},onOutputReplace:(R,G)=>{A.setOutput(R,G)},retryBudget:At,serviceEnvByTaskId:Te,serviceEventBridge:I??void 0,stdinRegistry:p,strictEnv:Et,taskSlots:lt,workspaceRoot:o});let L="rerun",D=null,K=new Map;for(;L!=="quit";){if(L==="rerun"){if(K=await Jt(z,Oe,{lifeCycle:q,projectGraph:l,taskExecutor:J,taskGraph:M,workspaceRoot:o}),_.length>0&&!t.failFast){const R=new Promise(G=>{const N=A.subscribe(()=>{const Z=A.getSnapshot();(Z.rerunRequested||Z.retryTaskId)&&(N(),G())});v.renderIsDone.then(()=>{N(),G()}).catch(()=>{N(),G()})});await ks(_,o,w,n,{abortSignal:R,lifeCycle:q,stdinRegistry:p,store:A},Te)}}else if(L==="retry"&&D){const R=z.find(N=>N.id===D),G=R?.overrides.command;if(R&&G){const N=ot(o,R.projectRoot,!1);q.startTasks?.([R]);const Z=new wt(nt),ue=(await Ze([{command:G,cwd:N,name:R.id,ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}],{onEvent:ie=>{ie.kind==="started"&&ie.write&&p.set(R.id,{kill:ie.kill,resize:ie.resize,write:ie.write}),(ie.kind==="stdout"||ie.kind==="stderr")&&ie.text&&(Z.write(ie.text),A.setOutput(R.id,Z.toString())),ie.kind==="close"&&p.delete(R.id)}})).closeEvents[0];q.endTasks?.([{code:ue?.exitCode??1,status:ue?.exitCode===0?"success":"failure",task:R,terminalOutput:A.getSnapshot().outputs.get(R.id)}])}else R&&q.endTasks?.([{code:1,status:"failure",task:R,terminalOutput:`No command configured for ${R.id}`}]);D=null,A.markDone()}L=await new Promise(R=>{const G=A.subscribe(()=>{const N=A.getSnapshot();N.rerunRequested&&(A.acknowledgeRerun(),G(),R("rerun")),N.retryTaskId&&(D=A.acknowledgeRetry(),G(),R("retry"))});v.renderIsDone.then(()=>{G(),R("quit")}).catch(()=>{G(),R("quit")})})}await v.renderIsDone,await Ie.callHook("run:after",K),await Rt(K),de>0&&(e.info(""),We?e.info(`${String(de)} service(s) stopped (--stop-services).`):e.info(`${String(de)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))}else{const p=new Map,v=typeof t.log=="string"?t.log.toLowerCase():"",y=v==="labeled"||v==="grouped"||v==="interleaved"?v:void 0,A=y?vr(y):void 0,q=new Yt([new Un({...Pt,ciGrouping:r?.run?.ciGrouping??"auto",logReporter:A,outputStyle:Lt}),Dt,Bt]),J=js({affectedFiles:w,currentOs:x,hooks:Ie,initCwd:n,lifeCycle:q,mutexPool:p,retryBudget:At,serviceEnvByTaskId:Te,serviceEventBridge:I??void 0,strictEnv:Et,taskSlots:lt,workspaceRoot:o}),L=async()=>{const N=Date.now(),Z=await Jt(z,Oe,{lifeCycle:q,projectGraph:l,taskExecutor:J,taskGraph:M,workspaceRoot:o}),ue=Date.now()-N;if(t.summarize){const xe=Kt(Z,M,It);await jr(xe,o,{dataDirectory:et(o)})}let ie=!1;for(const[,xe]of Z)xe.status==="failure"&&(ie=!0);const ke=Er(Z,ue),$e=Mr(o),Re=Fr(o,ue,$e);return e.info(""),e.info(` ${ke}${Re?` ${Re}`:""}`),{hasFailure:ie,results:Z,runHistory:$e}},D=await L();await Ie.callHook("run:after",D.results),await Rt(D.results);const{hasFailure:K}=D;if(t.watch){const N=F.map(le=>{const me=f.projects[le]?.root;if(me)return me.startsWith("/")?me:`${o}/${me}`}).filter(le=>le!==void 0),Z=z;let ue;const ie=le=>{const me=Xn(Z,le);return ue=me.filter,z=me.tasks,me.tasks.length};let ke=!1,$e=D.results;const Re=()=>{const le=ss($e,o);if(le.directories.length>0&&le.files.size>0){const me=Li(le.files,o,le.directories);return{handle:rs({filter:me,onChange:Ke,paths:le.directories}),mode:"tracked"}}return{handle:rs({onChange:Ke,paths:N}),mode:"roots"}};let xe;const Ke=async le=>{if(!ke){ke=!0;try{e.info(`Change detected in ${le.length} file(s), rerunning…`),$e=(await L()).results,xe?.close(),xe=Re().handle}finally{ke=!1}}},qt=Re();xe=qt.handle;const er=qt.mode==="tracked"?`Watching ${String(ss($e,o).files.size)} tracked file(s)`:`Watching ${String(N.length)} project root(s)`;e.info(`${er} — edit a file to rerun, press h for keybinds, q to quit.`);const dt=async()=>{if(!ke){ke=!0;try{if(z.length===0){e.info("No tasks match the active filter — press a to clear it.");return}$e=(await L()).results,xe?.close(),xe=Re().handle}finally{ke=!1}}};await new Promise(le=>{let me=!1,Wt;const Ut=()=>{zt()},zt=()=>{me||(me=!0,Wt?.close(),process.off("SIGINT",Ut),xe?.close(),le())};process.on("SIGINT",Ut),Wt=to({handlers:{onClearFilter:async()=>{const Ue=ie(void 0);e.info(`Filter cleared — running ${String(Ue)} task(s).`),await dt()},onFilter:async Ue=>{const tr=ue,Vt=ie(Ue);if(Vt===0){e.info(`Filter "${Ue}" matched no projects — keeping previous filter.`),ie(tr);return}e.info(`Filter "${Ue}" matched ${String(Vt)} task(s).`),await dt()},onHelp:()=>{Zn(process.stdout)},onQuit:()=>{zt()},onRerun:dt}})});return}if(t.flaky!==!1){const N=Cr(o,{minRuns:2},D.runHistory);if(N.length>0){e.info(""),e.info("Flaky tasks (based on historical runs):"),e.info("");for(const Z of Rr(N))e.info(` ${Z}`);e.info("")}}const R=[];for(const[N,Z]of D.results)Z.retryAttempts&&Z.retryAttempts>0&&R.push(N);const G=t.failOnRetry===!0&&R.length>0;if(G){const N=R.slice(0,5),Z=R.length-N.length,ue=Z>0?`${N.join(", ")}, and ${String(Z)} more`:N.join(", ");e.warn(""),e.warn(`--fail-on-retry: ${String(R.length)} task(s) succeeded only after retry: ${ue}`)}if(K||G){const N=G&&!K?"Some tasks succeeded only after retry (--fail-on-retry).":"Some tasks failed.",Z=2e3,ue=[];for(const[ie,ke]of D.results){if(ke.status!=="failure")continue;const $e=ke.terminalOutput??"",Re=$e.length>Z?`…${$e.slice(-Z)}`:$e,xe=ke.code??"?";ue.push(` ${ie} (exit ${String(xe)}):
185
- ${Re.split(`
186
- `).map(Ke=>` ${Ke}`).join(`
187
- `)}`)}throw new Xe(ue.length>0?`${N}
188
- ${ue.join(`
189
- `)}`:N)}_.length>0&&!t.failFast&&await ks(_,o,w,n,void 0,Te),de>0&&(e.info(""),We?e.info(`${String(de)} service(s) stopped (--stop-services).`):e.info(`${String(de)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))}}finally{Gt(),_t&&(process.off("SIGINT",Je),process.off("SIGTERM",Je)),We&&ve.length>0&&await Promise.all(ve.map(async p=>{try{await ri(o,p)}catch{}}))}};export{Vo as createRetryBudget,Ta as default};
168
+ `,$o=()=>{const s=Vr(ue(Dn(),"vis-services-")),e=ue(s,"bootstrap.mjs");return Ps(e,To),{runDir:s,scriptPath:e}},Vs=(s,e,t)=>{const r=t.replaceAll(/[^\w-]/g,"_");return{configFile:ue(s,`${r}.json`),logFile:ue(s,`${r}.log`),pidFile:ue(s,`${r}.pid`),scriptPath:e}},Io=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:ur(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}},Co=s=>`node ${JSON.stringify(s.scriptPath)} ${JSON.stringify(s.configFile)}`,Eo=s=>{const{id:e,visBin:t,workspaceRoot:r}=s;return`node ${JSON.stringify(t)} service start ${JSON.stringify(e)} --cwd ${JSON.stringify(r)}`},Ro=s=>{const{missingServiceIds:e,mode:t,taskGraph:r,visBin:c,workspaceRoot:o}=s,{services:i,skipped:d}=qs(o,e,r);if(i.length===0)return{chain:[],ephemeralPidFiles:[],runDir:void 0,serviceEnvByTaskId:new Map,skipped:d};const u=So(i.map(S=>S.id),r),p=new Map(i.map(S=>[S.id,S])),f=[],h=[];if(t==="ephemeral")for(const S of u){const E=p.get(S);E&&h.push({id:S,payload:Io({paths:{logFile:"",pidFile:""},service:E})})}let l;t==="ephemeral"&&(l=$o());let b;for(const S of u){const E=p.get(S),I=r.tasks[S];if(!E||!I)continue;let j;if(t==="ephemeral"){const R=Vs(l.runDir,l.scriptPath,S),O={...h.find(B=>B.id===S).payload,logFile:R.logFile,pidFile:R.pidFile};Ps(R.configFile,JSON.stringify(O)),j=Co(R),f.push(R.pidFile)}else j=Eo({id:S,visBin:c,workspaceRoot:o});if(I.overrides={...I.overrides,command:j},I.cache=!1,r.tasks[S]=I,b!==void 0){const R=r.dependencies[S]??[];R.includes(b)||(r.dependencies[S]=[...R,b])}b=S}const T=new Set(u),N=new Map,F=S=>{const E=new Set,I=[...r.dependencies[S]??[]],j=new Set;for(;I.length>0;){const R=I.pop();if(!j.has(R)){j.add(R),T.has(R)&&E.add(R);for(const w of r.dependencies[R]??[])j.has(w)||I.push(w)}}return[...E].sort()};for(const S of Object.keys(r.dependencies)){if(T.has(S))continue;const E=F(S);if(E.length===0)continue;const I={};for(const j of E){const R=p.get(j);R?.config.env&&Object.assign(I,R.config.env)}Object.keys(I).length>0&&N.set(S,I)}return{chain:u,ephemeralPidFiles:f,runDir:l?.runDir,serviceEnvByTaskId:N,skipped:d}},Po=new Set(["auto","ephemeral","off","persistent"]),Mo=s=>s.cli!==void 0?"cli":s.config===void 0?"default":"config",Fo=s=>{const{cli:e,config:t,isCi:r,isPersistentTarget:c,isTty:o,target:i}=s;if(e!==void 0&&!Po.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"},Us=s=>s.replace(/^--?/u,""),Oo=new Set(["0","1","false","no","true","yes"]),Ao=s=>!s.startsWith("-")||/^-(?:\d|\.\d)/u.test(s),xs=(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&&Oo.has(i.toLowerCase())?(s.set(e,i.toLowerCase()),1):(s.set(e,"true"),0):i!==void 0&&Ao(i)?(s.set(e,i),1):(s.set(e,"true"),0)},Lo=(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}},Do=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},Bo=(s,e)=>{const t=new Map,r=new Map;for(const p of s)t.set(p.name,p),p.alias&&r.set(p.alias,p);const c=new Map,o=[];for(let p=0;p<e.length;p+=1){const f=e[p];if(f==="--"){o.push(...e.slice(p+1));break}if(f.startsWith("--no-")){c.set(Us(f.slice(5)),"false");continue}const h=/^--([^=]+)(?:=(.*))?$/su.exec(f);if(h){const T=h[1];p+=xs(c,T,t.get(T),h[2],e,p);continue}const l=/^-([^=-])(?:=(.*))?$/su.exec(f),b=l?.[1];if(l&&b!==void 0){const T=r.get(b);p+=xs(c,T?.name??b,T,l[2],e,p);continue}o.push(f)}const i={},d=[];let u=0;for(const p of s){let f=c.get(p.name);if(f===void 0&&p.positional&&u<o.length&&(f=o[u],u+=1),f===void 0){p.default!==void 0?i[p.name]=p.default:p.required&&d.push(`missing required argument --${p.name}`);continue}const{error:h,value:l}=Lo(p,f);h?d.push(h):l!==void 0&&(i[p.name]=l)}return{errors:d,values:i}},_o=s=>`VIS_ARG_${Us(s).replaceAll(/[^a-zA-Z0-9]+/gu,"_").toUpperCase()}`,No=s=>{const e={};for(const[t,r]of Object.entries(s))e[_o(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
+ `);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=[],p=d.type??"string";u.push(p==="enum"?`enum(${(d.choices??[]).join("|")})`:p),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
+ `)},Go=(s,e,t,r)=>{if(!t||t.length===0)return{env:{},kind:"ok"};const c=Do(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=Bo(t,r);return o.errors.length>0?{errors:o.errors,help:mt(s,e,t),kind:"invalid"}:{env:No(o.values),kind:"ok"}},$t="VIS_AFFECTED_FILES",Wo=2e3,js=async(s,e,t,r,c,o)=>{const i=s.map(j=>{const R=j.overrides.command;if(!R)return;const w=j.overrides.visOptions,O=at(e,j.projectRoot,!!w?.runFromWorkspaceRoot),B=w?.envFile?jt(O,w.envFile):{},k=t&&(w?.affectedFiles==="env"||w?.affectedFiles==="both")?{[$t]:t.join(`
171
+ `)}:{},W=o?.get(j.id)??{},se=ci({interactive:!!c,taskPty:j.pty,workspacePty:w?.pty});return{command:R,cwd:O,env:{INIT_CWD:r,...B,...W,...k,...j.overrides[Ct]},name:j.id,...se?{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:p,store:f}=c,h=i.map(j=>s.find(R=>R.id===j.name)).filter(Boolean),l=j=>i[j]?.stdin==="pty",b=new Map,T=j=>{if(!l(j))return;let R=b.get(j);return R||(R=new vt(ct),b.set(j,R)),R};f.unmarkDone(),u.startTasks?.(h);const N=new Map,F=new Map;let S;const E=()=>{for(const j of F.values())try{j("SIGTERM")}catch{}S||(S=setTimeout(()=>{for(const j of F.values())try{j("SIGKILL")}catch{}F.clear()},2e3),S.unref?.())};let I;d&&(I=()=>{E()},d.then(()=>{I?.()}).catch(()=>{I?.()}));try{await tt(i,{killOthers:["failure"],onEvent:j=>{const R=h[j.index];if(R)switch(j.kind){case"close":{const w=N.get(R.id)??Date.now(),O=j.killed||j.exitCode===0?"success":"failure";u.endTasks?.([{code:j.exitCode??0,endTime:Date.now(),startTime:w,status:O,task:R,terminalOutput:f.getSnapshot().outputs.get(R.id)??""}]),F.delete(j.index),p?.delete(R.id);break}case"error":{if(j.message){const w=T(j.index);w?(w.write(`${j.message}
172
+ `),f.setOutput(R.id,w.toString())):f.addOutput(R.id,`${j.message}
173
+ `)}break}case"started":{N.set(R.id,Date.now()),j.kill&&F.set(j.index,j.kill),j.write&&p&&p.set(R.id,{kill:j.kill,resize:j.resize,write:j.write});break}case"stderr":case"stdout":{if(j.text){const w=T(j.index);w?(w.write(j.text),f.setOutput(R.id,w.toString())):f.addOutput(R.id,`${j.text}
174
+ `)}break}default:}}})}finally{S&&(clearTimeout(S),S=void 0),f.markDone()}},ks=s=>{try{return process.kill(-s,0),!0}catch{try{return process.kill(s,0),!0}catch{return!1}}},Ho=s=>{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,s)},qo=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=ar(i),p=Number.parseInt(u.trim(),10);d=Number.isFinite(p)&&p>0?p: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 p=!0;for(const f of c)if(ks(f)){p=!1;break}if(p)break;Ho(100)}for(const p of c)if(ks(p))try{process.kill(-p,"SIGKILL")}catch{try{process.kill(p,"SIGKILL")}catch{}}}r&&Br(r)},ct=256*1024;class Vo{#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
+ ${this.#r}`:this.#r}}const zs=s=>{const e=s.overrides.visOptions;if(e&&typeof e=="object")return e},Uo=s=>`'${s.replaceAll("'",String.raw`'\''`)}'`,It=s=>process.platform==="win32"?s.length>0&&!/[\s"&|<>^()%!]/.test(s)?s:`"${s.replaceAll('"','""')}"`:Uo(s),zo=(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},Ys="visForwardedArgs",Ct="visTaskArgEnv",Yo=(s,e)=>{const t=e.overrides[Ys];if(!Array.isArray(t)||t.length===0)return s;const r=t.map(c=>It(c)).join(" ");return`${s} ${r}`},Ko=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)}},Xo=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}}},Jo=(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},bs=s=>{const e=new Map;return async(t,r)=>{const{affectedFiles:c,currentOs:o,hooks:i,initCwd:d,lifeCycle:u,mutexPool:p,onOutput:f,onOutputReplace:h,retryBudget:l,serviceEnvByTaskId:b,serviceEventBridge:T,stdinRegistry:N,strictEnv:F,taskSlots:S,workspaceRoot:E}=s,I=zs(t),j=at(E,r.cwd??t.projectRoot,I?.runFromWorkspaceRoot===!0),R=t.overrides.command;if(!R)return{code:0,terminalOutput:`No command configured for ${t.target.project}:${t.target.target}`};const w=Yo(R,t),O=zo(w,c,I?.affectedFiles),B=kn(I,o),k=I?.shellArgs,W=k&&k.length>0?k.join(" "):"-c",se=B?`${B} ${W} ${It(O)}`:O,ae=I?.envFile?Jo(e,j,I.envFile):void 0,Q={};c&&c.length>0&&(I?.affectedFiles==="env"||I?.affectedFiles==="both")&&(Q[$t]=c.join(`
176
+ `));const ee=b?.get(t.id),ie={INIT_CWD:d,VIS_TASK_SLOTS:String(S),...ae,...ee,...r.env,...Q,...t.overrides[Ct]};if(I?.strictEnv??F??!1){const z=hi({command:O,processEnv:process.env,taskEnv:ie,taskId:t.id});if(z){const we=pi(z);return u?.onTaskStderr?.(t,we),{code:1,terminalOutput:we}}}const ge=I?.pty===!0,le=!!N,q=t.pty===!0?!0:t.pty===!1?!1:le||ge;q&&(t.cache=!1);const K=q?void 0:new Vo(ct),re=q?new vt(ct):void 0;let X;const Se=z=>{if(z.kind==="started"&&(X=z.kill,z.write&&N&&N.set(t.id,{kill:z.kill,resize:z.resize,write:z.write}),T?.onRegistryTaskStarted(t.id)),(z.kind==="stdout"||z.kind==="stderr")&&z.text!==void 0)if(z.kind==="stdout"?u?.onTaskStdout?.(t,z.text):u?.onTaskStderr?.(t,z.text),re)re.write(z.text),le&&h?.(t.id,re.toString()),T&&T.onTaskOutput(t.id,z.text);else{const we=`${z.text}
177
+ `;K.append(we),f?.(t.id,we)}z.kind==="close"&&(N&&N.delete(t.id),T&&T.onRegistryTaskClosed(t.id,z.exitCode??0,!!z.killed).catch(()=>{}))},_=async()=>{const z=I?.retryCount??0,we=I?.retryDelay,Me=l?l.claim(z):z,Fe=typeof I?.timeout=="number"&&I.timeout>0?I.timeout:0,_e=typeof I?.killGracePeriodMs=="number"&&I.killGracePeriodMs>=0?I.killGracePeriodMs:5e3;let ne=!1,Te=0;const Oe=eo({killGracePeriodMs:_e,onTimeout:()=>{ne=!0},sendSignal:ye=>{X?.(ye)},timeoutMs:Fe});let fe;try{fe=await tt([{command:se,cwd:j,env:ie,name:t.id,...q?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}],{killOthers:["failure"],onEvent:Se,...Me>0?{restart:{delay:we??"exponential",onRetry:async(ye,Ce,$)=>{Te=ye,i&&await i.callHook("task:retry",t,ye,$)},tries:Me}}:{}})}finally{Oe.cancel()}const xe=fe.closeEvents[0],$e=re?re.toString():K.toString();return ne?{code:124,retryAttempts:Te,terminalOutput:`${$e}
178
+ [timeout] Task "${t.id}" exceeded ${Fe}ms budget.
179
+ `}:{code:xe?.exitCode??1,retryAttempts:Te,terminalOutput:$e}};return p?Ko(p,I?.mutex,_):_()}},Qo=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)}},Zo=async(s,e)=>{const t=await xr(s,{dataDirectory:st(s)});if(!t){e.warn(`No previous run recorded yet. Run a task at least once to populate ${jr(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("")}},ec=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}},tc=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}},sc=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}},Ec=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(Kr({logger:e,options:t,visConfig:r},o),Bn(o),t.lastDetails===!0){await Zo(o,e);return}const i=process.cwd(),d=await Ar(o),{config:u,packageJsons:p,projectOptions:f,workspace:h}=Lr(o,r,d),l=Dr(o,h,p);let b=s[0];if(!b){const m=Zt(h);if(process.stdout.isTTY&&process.stdin.isTTY){const y=await ln(m);if(!y){e.info("No target selected.");return}b=y,await Ki(`vis run ${y}`)}else{e.info("Available targets:"),e.info(""),e.info(dn(m)),e.info(""),e.info("Usage: vis run <target>");return}}if(u.constraints&&!t.skipConstraints){const m=fr(l,u.constraints);if(m.length>0){for(const y of m)e.error(`[${y.rule}] ${y.message}`);throw new Error(`${m.length} project constraint violation(s) found. Use --skip-constraints to bypass.`)}}if(!t.affected){const m=t.uncommitted===!1?"--no-uncommitted":"--uncommitted",y=[["--base",t.base],["--head",t.head],["--downstream",t.downstream],["--upstream",t.upstream],[m,t.uncommitted]].filter(([,v])=>v!==void 0).map(([v])=>v);if(y.length>0)throw new Ze(`${y.join(", ")} ${y.length===1?"requires":"require"} --affected.
180
+ Did you mean: vis run ${b} --affected ${y.map(v=>v.includes("uncommitted")?v:`${v}=…`).join(" ")}
181
+ Or use the dedicated command: vis affected ${b} …`)}const T=await gn(b,h,process.cwd(),o),N=un(f),F=fn(T.target,N);F!==T.target&&e.debug?.(`Resolved alias "${T.target}" → "${F}"`);let S=T.projects;const E=s.slice(1).map(String);if(t.projects!==void 0&&(S=hn(S,String(t.projects),Object.keys(h.projects))),t.filter&&t.filter.length>0){const m=new Map;for(const[P,G]of p)m.set(P,G.name);const y=await wo(t.filter,{defaultBase:r?.defaultBase,packageNameByProject:m,projectGraph:l,workspaceRoot:o}),v=new Set(y);if(S=S.filter(P=>v.has(P)),S.length===0){e.info(`Filter ${t.filter.map(P=>`"${P}"`).join(", ")} matched no projects.`);return}}if(t.query&&(S=wn(S,h,t.query),S.length===0)){e.info(`Query "${String(t.query)}" matched no projects.`);return}if(t.tag&&t.tag.length>0&&(S=yn(S,h,t.tag),S.length===0)){e.info(`Tag filter ${t.tag.map(m=>`"${m}"`).join(", ")} matched no projects.`);return}let I;if(t.affected){const m=await an({base:t.base,downstream:t.downstream,head:t.head,uncommitted:t.uncommitted,upstream:t.upstream},{projectGraph:l,projects:h.projects,workspaceRoot:o},{defaultBase:r?.defaultBase});for(const v of m.notes)e.info(`▸ ${v}`);if(m.changedFiles.length===0){e.info("No files changed. Nothing to run.");return}const y=new Set(m.affectedProjects);if(S=S.filter(v=>y.has(v)),S.length===0){e.info("No projects affected by the changes.");return}I=m.changedFiles,e.info(`Affected projects: ${S.join(", ")}`)}const j=vn(),R=process.env[$t],w=I??(R?R.split(`
182
+ `).filter(Boolean):void 0),O=(typeof t.runnerTags=="string"?t.runnerTags:process.env.VIS_RUNNER_TAGS)??void 0,B=O?new Set(O.split(",").map(m=>m.trim()).filter(Boolean)):void 0,k=[],W=new Map;for(const m of S){const v=f.get(m)?.[F];if(!v)continue;const P=v.options;if(!P?.internal){if(!xn(P,!!Ye)){e.debug?.(`Skipping ${m}:${F} — runInCI filter`);continue}if(!jn(P,B)){e.debug?.(`Skipping ${m}:${F} — runner-tags filter`);continue}k.push(m),W.set(m,v)}}if(k.length===0){const m=Zt(h),y=Object.entries(h.projects).filter(([,v])=>v.targets?.[F]!==void 0).map(([v])=>v);if(e.error(`No projects have the "${F}" target.`),y.length>0){e.info(""),e.info(`Target "${F}" exists in these projects but was filtered out:`);for(const v of y.slice(0,5))e.info(` - ${v}`);y.length>5&&e.info(` …and ${y.length-5} more`)}else{const v=pn(F,m,3);v.length>0&&(e.info(""),e.info(v.length===1?`Did you mean "${v[0]}"?`:`Did you mean one of: ${v.map(P=>`"${P}"`).join(", ")}?`)),e.info(""),e.info("Run `vis run` without arguments to see all available targets.")}return}const se=t.pty===!0,ae=k.map(m=>({project:m,schema:W.get(m)?.arguments})).filter(m=>Array.isArray(m.schema)&&m.schema.length>0),Q=new Map;for(const{project:m,schema:y}of ae){const v=JSON.stringify(y),P=Q.get(v)??[];P.push(m),Q.set(v,P)}if(Q.size>1){const m=[...Q.values()].map(y=>y.join(", ")).join(" | ");throw new Error(`Target "${F}" declares conflicting \`arguments\` schemas across projects (${m}). Run a single project (e.g. \`vis run ${ae[0]?.project}:${F}\` or --projects=<name>) so the argument contract is unambiguous.`)}const ee=ae[0]?.schema,ie=W.get(ae[0]?.project??k[0])?.description,oe=Go(F,ie,ee,E);if(oe.kind==="help"){e.info(oe.text);return}if(oe.kind==="invalid"){e.info(`Invalid arguments for "${F}":`);for(const m of oe.errors)e.info(` ✖ ${m}`);throw e.info(""),e.info(oe.help),new Error(`Invalid arguments for target "${F}"`)}const ge=oe.env,le=sc(t.hashMode);let q=k.map(m=>{const y=h.projects[m],v=W.get(m),P={project:m,target:F},G=`${m}:${F}`,Z=se?{...v.options,pty:v.options?.pty??!0}:v.options,D=v.command?zt(v.command,{affectedFiles:w,projectRoot:y?.root}):v.command,A=y?.root&&y.root.length>0?y.root:".",Y=(v.outputs??[]).map(H=>typeof H!="string"?H:H.replaceAll("{projectRoot}",A).replaceAll("{projectName}",m));return{cache:v.cache,hashMode:le??v.hashMode,id:G,outputs:Y,overrides:{command:D,...E.length>0?{[Ys]:E}:{},...Object.keys(ge).length>0?{[Ct]:ge}:{},...Z?{visOptions:Z}:{}},parallelism:v.parallelism,projectRoot:y?.root,target:P}});const K=[],re=[];for(const m of q)zs(m)?.persistent?(m.cache=!1,K.push(m)):re.push(m);q=re;const X=hr(t.partition);if(X&&(q=pr.partitionTasks(q,X),e.info(`Partition ${X.index}/${X.total}: running ${q.length} task(s)`),q.length===0)){e.info("No tasks assigned to this partition.");return}const Se=new Set([...q,...K].map(m=>m.id));let _=mr([...q,...K],{onCycleBroken:m=>{e.warn(`Ignoring dev-only dependency cycle (build order is ambiguous): ${m.join(" → ")}`)},projectGraph:l,targetDefaults:u.tasks,workspace:h});for(const[m,y]of Object.entries(_.tasks)){const v=y.target.project,P=y.target.target,G=f.get(v)?.[P];if(!G){Se.has(m)||e.warn(`${P} required via dependsOn but no command is configured for ${v} — skipping (no-op).`);continue}const Z=h.projects[v];let D=!1;const A={...y.overrides};A.visOptions===void 0&&G.options&&(A.visOptions=G.options,D=!0),A.command===void 0&&G.command&&(A.command=zt(G.command,{affectedFiles:w,projectRoot:Z?.root}),D=!0),D&&(y.overrides=A,_.tasks[m]=y)}if(typeof t.skipCache=="string"&&t.skipCache.trim()!=="")if(t.cache){const m=li(t.skipCache,h,Object.keys(_.tasks));for(const y of m.skipTaskIds){const v=_.tasks[y];v!==void 0&&(v.cache=!1)}m.unmatchedPatterns.length>0&&e.warn(`--skip-cache: no tasks matched ${m.unmatchedPatterns.map(y=>`"${y}"`).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 Xr(o,u.toolchain,{error:m=>{e.error(m)},info:m=>{e.info(m)},warn:m=>{e.warn(m)}},!!t.skipToolchain);const z=t.preflight!==!1&&u.preflight?.lockfile!==!1,we=Nr(o,Ye,{warn:m=>{e.warn(m)}},{skip:!z});if(!we.shouldContinue)throw new Error(`${we.formattedMessage??"preflight: lockfile drift detected"} (pass --no-preflight to bypass)`);z&&!Ye&&process.stdin.isTTY&&process.stdout.isTTY&&await oi(o,{interactive:!0,logger:{info:m=>{e.info(m)},warn:m=>{e.warn(m)}},projectManifests:[...p.values()]});const Me=process.env.VIS_VERSION??"0.0.0",Fe=t.dryRun?void 0:async m=>{try{return await tn(m.config,{timeoutMs:Wo}),!0}catch{return!1}},_e=await sn(o),ne=await co({initialTasks:[...q,...K],probe:Fe,registeredEntries:_e,taskGraph:_,visVersion:Me}),Te=[];let Oe,fe=0;const xe=[],$e=new Map;let ye=[];const Ce=new Set;let $=null,x=null;if(ne.diagnostics.length>0){const m=!!(process.stdout.isTTY&&process.stdin.isTTY),y=t.dryRun?"off":Fo({cli:t.services,config:u.run?.services,isCi:!!Ye,isPersistentTarget:K.length>0,isTty:m,target:F});if(y==="off"){for(const H of ne.diagnostics)e.error(H.message);const A=Mo({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 Ze([`${ne.diagnostics.length} service dependency error(s) — start the missing services or invoke them directly.`,...Y].join(`
183
+ `))}const v=ne.diagnostics.map(A=>A.targetId),P=y,G=P==="registry"?qs(o,v,_):void 0,Z=process.argv[1]??"vis",D=Ro({missingServiceIds:v,mode:P,taskGraph:_,visBin:Z,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 Ze(`${D.skipped.length} service(s) cannot be auto-started — invoke them directly or add a service config.`)}Te.push(...D.ephemeralPidFiles),Oe=D.runDir,ye=D.chain;for(const A of D.chain)Ce.add(A);if(P==="registry"&&(fe=D.chain.length,xe.push(...D.chain)),D.chain.length>0){const A=new as(D.chain),Y=new Map;if(P==="ephemeral"&&D.runDir)for(const H of D.chain){const M=Vs(D.runDir,`${D.runDir}/bootstrap.mjs`,H);Y.set(H,{ephemeral:{configFile:M.configFile,cwd:o,logFile:M.logFile,pidFile:M.pidFile,scriptPath:M.scriptPath},mode:"ephemeral"})}else if(P==="registry"&&G)for(const H of G.services)Y.set(H.id,{mode:"registry",registry:{command:H.command,config:H.config,cwd:H.cwd,env:H.env}});if(Y.size>0){const H=new jo({indexToId:new Map,services:Y,sink:{crashed:(M,L)=>{A.markCrashed(M,L)},failed:(M,L,V)=>{A.markFailed(M,L,V)},log:(M,L)=>{A.appendLog(M,L)},ready:(M,L)=>{A.markReady(M,L)},started:(M,L)=>{A.markStarted(M,L),P==="registry"&&L!==null&&$e.set(M,L)},starting:M=>{A.markStarting(M)}},workspaceRoot:o});$=A,x=H}}for(const[A,Y]of D.serviceEnvByTaskId){const H=ne.serviceEnvByTaskId.get(A)??{};ne.serviceEnvByTaskId.set(A,{...H,...Y})}}const C=new Set(K.map(m=>m.id));if(q=ne.initialTasks.filter(m=>!C.has(m.id)),_=ne.taskGraph,ye.length>0&&(q=[...ye.map(y=>_.tasks[y]).filter(y=>y!==void 0),...q]),K.length>0){const m=new Set(K.map(Z=>Z.id)),y={};for(const[Z,D]of Object.entries(_.tasks))m.has(Z)||(y[Z]=D);const v={};for(const[Z,D]of Object.entries(_.dependencies))m.has(Z)||(v[Z]=D.filter(A=>!m.has(A)));const P=new Set;for(const Z of Object.values(v))for(const D of Z)P.add(D);const G=Object.keys(y).filter(Z=>!P.has(Z));_={dependencies:v,roots:G,tasks:y}}const{serviceEnvByTaskId:te}=ne;if(ne.satisfiedServices.length>0){const m=ne.satisfiedServices.map(y=>y.id).join(", ");if(e.debug?.(`Auto-attached to running services: ${m}`),$)for(const y of ne.satisfiedServices)$.registerService(y.id);else $=new as(ne.satisfiedServices.map(y=>y.id));for(const y of ne.satisfiedServices){const v=y.config.readiness?.tcp?.port??y.config.port??0,P=y.config.readiness?.tcp?.host??"127.0.0.1";$.markReady(y.id,{host:P,port:v})}}if(t.reverse&&(_=gr(_),e.debug?.(`Reversed task graph: ${String(_.roots.length)} new root(s) (originally leaves)`)),t.dryRun){const m=Object.keys(_.tasks).length,y=_.roots.length;e.info(`Execution plan (${String(m)} task(s), ${String(y)} root(s)):`),e.info("");const v=new Set,P=(G,Z)=>{if(v.has(G))return;v.add(G);for(const H of _.dependencies[G]??[])P(H,Z+1);const D=_.tasks[G],A=" ".repeat(Z+1),Y=`${D?.cache===!1?" (no-cache)":""}${D?.hashMode==="trace"?" (trace)":""}`;e.info(`${A}${G}${Y}`)};for(const G of _.roots)P(G,0);for(const G of Object.keys(_.tasks))P(G,0);K.length>0&&(e.info(""),e.info(` + ${String(K.length)} persistent task(s) (run after graph completes)`)),e.info("");return}const Ae=Date.now(),Ie=rn(),Et=(m,y)=>{const v=y instanceof Error?y.message:String(y);e.warn(`Plugin error in ${m}: ${v}`)};await nn(Ie,u.plugins);const qe=typeof t.profile=="string"?t.profile:void 0,Rt=async m=>{if(!qe)return;const y=Xt(m,_,Ae),v=qe.startsWith("/")?qe:`${o}/${qe}`;await kr(y,v),e.info(`Profile written to ${qe}`)},Xe=u.taskRunner??{},Ks=Cr(o,t.cacheDir,Xe.cacheDirectory,u.sharedWorktreeCache),Xs=Er(Ks,o,u.branchScopedCache),Ne=Qo(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 Js=Ne&&"value"in Ne?Ne.value:void 0,ut=t.parallel??Js??3,Pt=t.strictEnv??u.strictEnv??!1,Mt=new Set,Le={dryRun:t.dryRun??!1,parallel:ut,skipNxCache:!t.cache,summarize:t.summarize??!1,...Xe,cacheDirectory:Xs,dataDirectory:Xe.dataDirectory??st(o),namedInputs:u.namedInputs,onDiagnostic:(m,y)=>{Mt.has(m)||(Mt.add(m),e.warn(y))},onFingerprint:async(m,y)=>{await Ie.callHook("task:fingerprint",m,y)}},Ft=wr(Xe.remoteCache);if(Ft){const m=ec(t.cacheMode),y=tc(t.cacheBackend);if(Le.remoteCache={...Ft,...m?{mode:m}:{},...y?{backend:y}:{}},Le.remoteCache.attestation){const{expectedIdentity:v,requireOnDownload:P}=Le.remoteCache.attestation;if(!(v!==void 0&&("github"in v&&typeof v.github?.ref=="string"&&typeof v.github.repo=="string"&&typeof v.github.workflow=="string"||"oidcIssuer"in v&&typeof v.oidcIssuer=="string"&&(typeof v.san=="string"||typeof v.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 v&&(!v.sanRegex.startsWith("^")||!v.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:Z,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
+ ${Z(o)}`);const{buildCacheAttestationHooks:A}=await import("./cache-attestation.js");Le.remoteCache.attestation=A({expectedIdentity:v,onReject:(Y,H)=>{e.warn(`[vis run] remote cache entry ${Y.slice(0,12)} rejected: attestation ${H}. Treating as a cache miss.`)},onVerifyFailure:Y=>{e.warn(`[vis run] attestation verification failed: ${Y}`)},requireOnDownload:P,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 Qs=process.stdout.isTTY&&!Ye,Zs=r?.run?.quietOnSuccess===!0,er=u.tui?.autoExit??(Zs?3:!1),Ot={args:{parallel:Le.parallel,targets:[F]},autoExit:er,projectNames:k,tasks:[...q,...K],totalTaskCount:Object.keys(_.tasks).length+K.length},At=typeof t.retryBudget=="number"?t.retryBudget:void 0,Lt=At===void 0?void 0:Xo(At),Dt=new on(Ie,Et),Bt=new Yr(o),_t=Ui(t.outputStyle,r?.run?.quietOnSuccess);if(ne.satisfiedServices.length>0)for(const m of ne.satisfiedServices){const y=ne.serviceDependentsByServiceId.get(m.id)??[];try{await Ie.callHook("service:attach",m,y)}catch(v){Et("service:attach",v)}}await Ie.callHook("run:before",{tasks:q,workspaceRoot:o});const Ve=t.stopServices===!0;let Nt=!1;const Gt=()=>{if(Nt)return;Nt=!0,x&&x.dispose().catch(()=>{});const m=Ve?[...$e.values()]:void 0;qo({extraPids:m,pidFiles:Te,runDir:Oe})},Je=()=>{Gt()},Wt=Te.length>0||Oe!==void 0||Ve&&xe.length>0;Wt&&(process.on("SIGINT",Je),process.on("SIGTERM",Je));try{if(Qs){const m=new Map,y=qi({...Ot,onRetryService:x?M=>x.retry(M):void 0,outputStyle:_t,serviceDockStore:$,stdinRegistry:m}),{lifeCycle:v,store:P}=y,G=new Yt([v,Dt,Bt]),D=bs({affectedFiles:w,currentOs:j,hooks:Ie,initCwd:i,lifeCycle:G,mutexPool:new Map,onOutput:(M,L)=>{x&&Ce.has(M)?x.onTaskOutput(M,L):P.addOutput(M,L)},onOutputReplace:(M,L)=>{P.setOutput(M,L)},retryBudget:Lt,serviceEnvByTaskId:te,serviceEventBridge:x??void 0,stdinRegistry:m,strictEnv:Pt,taskSlots:ut,workspaceRoot:o});let A="rerun",Y=null,H=new Map;for(;A!=="quit";){if(A==="rerun"){if(H=await Kt(q,Le,{lifeCycle:G,projectGraph:l,taskExecutor:D,taskGraph:_,workspaceRoot:o}),K.length>0&&!t.failFast){const M=new Promise(L=>{const V=P.subscribe(()=>{const de=P.getSnapshot();(de.rerunRequested||de.retryTaskId)&&(V(),L())});y.renderIsDone.then(()=>{V(),L()}).catch(()=>{V(),L()})});await js(K,o,w,i,{abortSignal:M,lifeCycle:G,stdinRegistry:m,store:P},te)}}else if(A==="retry"&&Y){const M=q.find(V=>V.id===Y),L=M?.overrides.command;if(M&&L){const V=at(o,M.projectRoot,!1);G.startTasks?.([M]);const de=new vt(ct),pe=(await tt([{command:L,cwd:V,name:M.id,ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}],{onEvent:ce=>{ce.kind==="started"&&ce.write&&m.set(M.id,{kill:ce.kill,resize:ce.resize,write:ce.write}),(ce.kind==="stdout"||ce.kind==="stderr")&&ce.text&&(de.write(ce.text),P.setOutput(M.id,de.toString())),ce.kind==="close"&&m.delete(M.id)}})).closeEvents[0];G.endTasks?.([{code:pe?.exitCode??1,status:pe?.exitCode===0?"success":"failure",task:M,terminalOutput:P.getSnapshot().outputs.get(M.id)}])}else M&&G.endTasks?.([{code:1,status:"failure",task:M,terminalOutput:`No command configured for ${M.id}`}]);Y=null,P.markDone()}A=await new Promise(M=>{const L=P.subscribe(()=>{const V=P.getSnapshot();V.rerunRequested&&(P.acknowledgeRerun(),L(),M("rerun")),V.retryTaskId&&(Y=P.acknowledgeRetry(),L(),M("retry"))});y.renderIsDone.then(()=>{L(),M("quit")}).catch(()=>{L(),M("quit")})})}await y.renderIsDone,await Ie.callHook("run:after",H),await Rt(H),fe>0&&(e.info(""),Ve?e.info(`${String(fe)} service(s) stopped (--stop-services).`):e.info(`${String(fe)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))}else{const m=new Map,y=typeof t.log=="string"?t.log.toLowerCase():"",v=y==="labeled"||y==="grouped"||y==="interleaved"?y:void 0,P=v?yr(v):void 0,G=new Yt([new Yi({...Ot,ciGrouping:r?.run?.ciGrouping??"auto",logReporter:P,outputStyle:_t}),Dt,Bt]),Z=bs({affectedFiles:w,currentOs:j,hooks:Ie,initCwd:i,lifeCycle:G,mutexPool:m,retryBudget:Lt,serviceEnvByTaskId:te,serviceEventBridge:x??void 0,strictEnv:Pt,taskSlots:ut,workspaceRoot:o}),D=async()=>{const L=Date.now(),V=await Kt(q,Le,{lifeCycle:G,projectGraph:l,taskExecutor:Z,taskGraph:_,workspaceRoot:o}),de=Date.now()-L;if(t.summarize){const ve=Xt(V,_,Ae);await vr(ve,o,{dataDirectory:st(o)})}let je=!1;for(const[,ve]of V)ve.status==="failure"&&(je=!0);const pe=Rr(V,de),ce=Pr(o),Ee=Mr(o,de,ce);return e.info(""),e.info(` ${pe}${Ee?` ${Ee}`:""}`),{hasFailure:je,results:V,runHistory:ce}},A=await D();await Ie.callHook("run:after",A.results),await Rt(A.results);const{hasFailure:Y}=A;if(t.watch){const L=k.map(he=>{const Re=h.projects[he]?.root;if(Re)return Re.startsWith("/")?Re:`${o}/${Re}`}).filter(he=>he!==void 0),V=q;let de;const je=he=>{const ke=to(V,he);return de=ke.filter,q=ke.tasks,ke.tasks.length};let pe=!1,ce=A.results;const Ee=()=>{const he=ss(ce,o);if(he.directories.length>0&&he.files.size>0){const ke=_n(he.files,o,he.directories);return{handle:rs({filter:ke,onChange:Qe,paths:he.directories}),mode:"tracked"}}return{handle:rs({onChange:Qe,paths:L}),mode:"roots"}};let ve;const Qe=async he=>{if(!pe){pe=!0;try{e.info(`Change detected in ${he.length} file(s), rerunning…`),ce=(await D()).results,ve?.close(),ve=Ee().handle}finally{pe=!1}}},Ht=Ee();ve=Ht.handle;const tr=Ht.mode==="tracked"?`Watching ${String(ss(ce,o).files.size)} tracked file(s)`:`Watching ${String(L.length)} project root(s)`;e.info(`${tr} — edit a file to rerun, press h for keybinds, q to quit.`);const ft=async()=>{if(!pe){pe=!0;try{if(q.length===0){e.info("No tasks match the active filter — press a to clear it.");return}ce=(await D()).results,ve?.close(),ve=Ee().handle}finally{pe=!1}}};await new Promise(he=>{let ke=!1,Re;const qt=()=>{Vt()},Vt=()=>{ke||(ke=!0,Re?.close(),process.off("SIGINT",qt),ve?.close(),he())};process.on("SIGINT",qt),Re=io({handlers:{onClearFilter:async()=>{const Ue=je(void 0);e.info(`Filter cleared — running ${String(Ue)} task(s).`),await ft()},onFilter:async Ue=>{const sr=de,Ut=je(Ue);if(Ut===0){e.info(`Filter "${Ue}" matched no projects — keeping previous filter.`),je(sr);return}e.info(`Filter "${Ue}" matched ${String(Ut)} task(s).`),await ft()},onHelp:()=>{ro(process.stdout)},onQuit:()=>{Vt()},onRerun:ft}})});return}if(t.flaky!==!1){const L=Fr(o,{minRuns:2},A.runHistory);if(L.length>0){e.info(""),e.info("Flaky tasks (based on historical runs):"),e.info("");for(const V of Or(L))e.info(` ${V}`);e.info("")}}const H=[];for(const[L,V]of A.results)V.retryAttempts&&V.retryAttempts>0&&H.push(L);const M=t.failOnRetry===!0&&H.length>0;if(M){const V=H.slice(0,5),de=H.length-V.length,je=de>0?`${V.join(", ")}, and ${String(de)} more`:V.join(", ");e.warn(""),e.warn(`--fail-on-retry: ${String(H.length)} task(s) succeeded only after retry: ${je}`)}if(Y||M){const L=M&&!Y?"Some tasks succeeded only after retry (--fail-on-retry).":"Some tasks failed.",V=2e3,de=[];for(const[je,pe]of A.results){if(pe.status!=="failure")continue;const ce=pe.terminalOutput??"",Ee=ce.length>V?`…${ce.slice(-V)}`:ce,ve=pe.code??"?";de.push(` ${je} (exit ${String(ve)}):
185
+ ${Ee.split(`
186
+ `).map(Qe=>` ${Qe}`).join(`
187
+ `)}`)}throw new Ze(de.length>0?`${L}
188
+ ${de.join(`
189
+ `)}`:L)}K.length>0&&!t.failFast&&await js(K,o,w,i,void 0,te),fe>0&&(e.info(""),Ve?e.info(`${String(fe)} service(s) stopped (--stop-services).`):e.info(`${String(fe)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))}}finally{Gt(),Wt&&(process.off("SIGINT",Je),process.off("SIGTERM",Je)),Ve&&xe.length>0&&await Promise.all(xe.map(async m=>{try{await cn(o,m)}catch{}}))}};export{Xo as createRetryBudget,Ec as default};