@visulima/vis 1.0.0-alpha.8 → 1.0.0-alpha.9

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 (280) hide show
  1. package/CHANGELOG.md +90 -57
  2. package/LICENSE.md +44 -1
  3. package/README.md +56 -0
  4. package/dist/bin.js +1 -1003
  5. package/dist/config.d.ts +1073 -68
  6. package/dist/config.js +1 -1
  7. package/dist/generate/index.d.ts +155 -30
  8. package/dist/packem_chunks/handler.js +1 -0
  9. package/dist/packem_chunks/handler10.js +1 -0
  10. package/dist/packem_chunks/handler11.js +1 -0
  11. package/dist/packem_chunks/handler12.js +153 -0
  12. package/dist/packem_chunks/handler13.js +1 -0
  13. package/dist/packem_chunks/handler14.js +3 -0
  14. package/dist/packem_chunks/handler15.js +1 -0
  15. package/dist/packem_chunks/handler16.js +2 -0
  16. package/dist/packem_chunks/handler17.js +7 -0
  17. package/dist/packem_chunks/handler18.js +1 -0
  18. package/dist/packem_chunks/handler19.js +19 -0
  19. package/dist/packem_chunks/handler2.js +1 -0
  20. package/dist/packem_chunks/handler20.js +428 -0
  21. package/dist/packem_chunks/handler21.js +22 -0
  22. package/dist/packem_chunks/handler22.js +3 -0
  23. package/dist/packem_chunks/handler23.js +5 -0
  24. package/dist/packem_chunks/handler24.js +1 -0
  25. package/dist/packem_chunks/handler25.js +20 -0
  26. package/dist/packem_chunks/handler26.js +1 -0
  27. package/dist/packem_chunks/handler27.js +1 -0
  28. package/dist/packem_chunks/handler28.js +1 -0
  29. package/dist/packem_chunks/handler29.js +2 -0
  30. package/dist/packem_chunks/handler3.js +2 -0
  31. package/dist/packem_chunks/handler30.js +22 -0
  32. package/dist/packem_chunks/handler31.js +1 -0
  33. package/dist/packem_chunks/handler32.js +1 -0
  34. package/dist/packem_chunks/handler33.js +37 -0
  35. package/dist/packem_chunks/handler34.js +3 -0
  36. package/dist/packem_chunks/handler35.js +23 -0
  37. package/dist/packem_chunks/handler36.js +5 -0
  38. package/dist/packem_chunks/handler37.js +27 -0
  39. package/dist/packem_chunks/handler38.js +1 -0
  40. package/dist/packem_chunks/handler39.js +2 -0
  41. package/dist/packem_chunks/handler4.js +5 -0
  42. package/dist/packem_chunks/handler40.js +1 -0
  43. package/dist/packem_chunks/handler41.js +5 -0
  44. package/dist/packem_chunks/handler42.js +1 -0
  45. package/dist/packem_chunks/handler43.js +24 -0
  46. package/dist/packem_chunks/handler44.js +3 -0
  47. package/dist/packem_chunks/handler45.js +1 -0
  48. package/dist/packem_chunks/handler5.js +4 -0
  49. package/dist/packem_chunks/handler6.js +2 -0
  50. package/dist/packem_chunks/handler7.js +24 -0
  51. package/dist/packem_chunks/handler8.js +6 -0
  52. package/dist/packem_chunks/handler9.js +8 -0
  53. package/dist/packem_shared/VisUpdateApp-BBx3idMI.js +1 -0
  54. package/dist/packem_shared/ai-analysis-DDqXRFxY.js +67 -0
  55. package/dist/packem_shared/bin-BaZZ32BK.js +93 -0
  56. package/dist/packem_shared/cache-directory-DL8hfXeG.js +1 -0
  57. package/dist/packem_shared/catalog-CuSpuB_R.js +12 -0
  58. package/dist/packem_shared/dependency-scan-BoLG2Fez.js +1 -0
  59. package/dist/packem_shared/docker-BcfqH4Av.js +2 -0
  60. package/dist/packem_shared/flakiness-DSIHZGBT.js +1 -0
  61. package/dist/packem_shared/otelPlugin-DxyvBcXO.js +1 -0
  62. package/dist/packem_shared/runtime-check-CGHal8SO.js +1 -0
  63. package/dist/packem_shared/selectors-CfH9ZY08.js +3 -0
  64. package/dist/packem_shared/symbols-CIMw60-G.js +1 -0
  65. package/dist/packem_shared/toolchain-C3ZG0o_X.js +5 -0
  66. package/dist/packem_shared/typosquats-Bpq4zcWL.js +1 -0
  67. package/dist/packem_shared/utils-DrNg0XTR.js +1 -0
  68. package/index.js +555 -727
  69. package/package.json +27 -19
  70. package/schemas/project.schema.json +1 -1
  71. package/schemas/vis-config.schema.json +47 -1
  72. package/dist/ai-analysis.d.ts +0 -26
  73. package/dist/ai-cache.d.ts +0 -21
  74. package/dist/ai-types.d.ts +0 -16
  75. package/dist/audit-config.d.ts +0 -24
  76. package/dist/bin.d.ts +0 -1
  77. package/dist/cache-directory.d.ts +0 -73
  78. package/dist/catalog.d.ts +0 -136
  79. package/dist/codeowners.d.ts +0 -30
  80. package/dist/commands/action-graph.d.ts +0 -8
  81. package/dist/commands/add.d.ts +0 -3
  82. package/dist/commands/affected.d.ts +0 -3
  83. package/dist/commands/ai.d.ts +0 -3
  84. package/dist/commands/analyze.d.ts +0 -3
  85. package/dist/commands/approve-builds.d.ts +0 -3
  86. package/dist/commands/audit.d.ts +0 -23
  87. package/dist/commands/cache.d.ts +0 -86
  88. package/dist/commands/check.d.ts +0 -3
  89. package/dist/commands/ci.d.ts +0 -19
  90. package/dist/commands/clean.d.ts +0 -3
  91. package/dist/commands/create/discovery.d.ts +0 -42
  92. package/dist/commands/create/index.d.ts +0 -13
  93. package/dist/commands/create/prompts.d.ts +0 -31
  94. package/dist/commands/create/random-name.d.ts +0 -15
  95. package/dist/commands/create/templates/builtin.d.ts +0 -15
  96. package/dist/commands/create/templates/generator.d.ts +0 -14
  97. package/dist/commands/create/templates/index.d.ts +0 -13
  98. package/dist/commands/create/templates/monorepo.d.ts +0 -16
  99. package/dist/commands/create/templates/remote.d.ts +0 -41
  100. package/dist/commands/create/templates/types.d.ts +0 -46
  101. package/dist/commands/create/utils.d.ts +0 -42
  102. package/dist/commands/dedupe.d.ts +0 -3
  103. package/dist/commands/devcontainer.d.ts +0 -3
  104. package/dist/commands/dlx.d.ts +0 -3
  105. package/dist/commands/docker.d.ts +0 -22
  106. package/dist/commands/doctor.d.ts +0 -15
  107. package/dist/commands/exec.d.ts +0 -3
  108. package/dist/commands/generate.d.ts +0 -10
  109. package/dist/commands/graph.d.ts +0 -3
  110. package/dist/commands/hook/constants.d.ts +0 -13
  111. package/dist/commands/hook/index.d.ts +0 -3
  112. package/dist/commands/hook/install.d.ts +0 -7
  113. package/dist/commands/hook/list.d.ts +0 -28
  114. package/dist/commands/hook/migrate.d.ts +0 -30
  115. package/dist/commands/hook/prek-builtins.d.ts +0 -8
  116. package/dist/commands/hook/prek.d.ts +0 -129
  117. package/dist/commands/hook/run.d.ts +0 -21
  118. package/dist/commands/hook/uninstall.d.ts +0 -3
  119. package/dist/commands/hook/validate.d.ts +0 -17
  120. package/dist/commands/ignore-helpers.d.ts +0 -157
  121. package/dist/commands/ignore.d.ts +0 -17
  122. package/dist/commands/implode.d.ts +0 -3
  123. package/dist/commands/info.d.ts +0 -3
  124. package/dist/commands/init.d.ts +0 -14
  125. package/dist/commands/install.d.ts +0 -3
  126. package/dist/commands/link.d.ts +0 -3
  127. package/dist/commands/list.d.ts +0 -3
  128. package/dist/commands/migrate/backup.d.ts +0 -8
  129. package/dist/commands/migrate/constants.d.ts +0 -16
  130. package/dist/commands/migrate/deps.d.ts +0 -32
  131. package/dist/commands/migrate/gitleaks.d.ts +0 -29
  132. package/dist/commands/migrate/index.d.ts +0 -3
  133. package/dist/commands/migrate/json.d.ts +0 -22
  134. package/dist/commands/migrate/kingfisher.d.ts +0 -14
  135. package/dist/commands/migrate/lint-staged.d.ts +0 -62
  136. package/dist/commands/migrate/moon.d.ts +0 -5
  137. package/dist/commands/migrate/nano-staged.d.ts +0 -30
  138. package/dist/commands/migrate/nx.d.ts +0 -12
  139. package/dist/commands/migrate/prompt.d.ts +0 -2
  140. package/dist/commands/migrate/secretlint.d.ts +0 -14
  141. package/dist/commands/migrate/shared.d.ts +0 -29
  142. package/dist/commands/migrate/turborepo.d.ts +0 -11
  143. package/dist/commands/migrate/types.d.ts +0 -27
  144. package/dist/commands/migrate/verify.d.ts +0 -12
  145. package/dist/commands/optimize.d.ts +0 -38
  146. package/dist/commands/pm.d.ts +0 -3
  147. package/dist/commands/remove.d.ts +0 -3
  148. package/dist/commands/run.d.ts +0 -16
  149. package/dist/commands/sbom.d.ts +0 -10
  150. package/dist/commands/secrets.d.ts +0 -3
  151. package/dist/commands/sort-package-json.d.ts +0 -3
  152. package/dist/commands/staged.d.ts +0 -10
  153. package/dist/commands/status.d.ts +0 -3
  154. package/dist/commands/sync.d.ts +0 -16
  155. package/dist/commands/task-why.d.ts +0 -3
  156. package/dist/commands/unlink.d.ts +0 -3
  157. package/dist/commands/update.d.ts +0 -3
  158. package/dist/commands/upgrade.d.ts +0 -3
  159. package/dist/commands/why.d.ts +0 -3
  160. package/dist/docker.d.ts +0 -73
  161. package/dist/flakiness.d.ts +0 -40
  162. package/dist/generate/discover.d.ts +0 -29
  163. package/dist/generate/loader.d.ts +0 -15
  164. package/dist/generate/moon-adapter/filename-interp.d.ts +0 -42
  165. package/dist/generate/moon-adapter/filters.d.ts +0 -22
  166. package/dist/generate/moon-adapter/frontmatter.d.ts +0 -39
  167. package/dist/generate/moon-adapter/index.d.ts +0 -19
  168. package/dist/generate/moon-adapter/tera-subset.d.ts +0 -85
  169. package/dist/generate/moon-adapter/util.d.ts +0 -14
  170. package/dist/generate/prompts.d.ts +0 -25
  171. package/dist/generate/remote.d.ts +0 -43
  172. package/dist/generate/runner.d.ts +0 -37
  173. package/dist/generate/types.d.ts +0 -152
  174. package/dist/hooks.d.ts +0 -118
  175. package/dist/native-binding.d.ts +0 -158
  176. package/dist/output.d.ts +0 -40
  177. package/dist/overrides.d.ts +0 -82
  178. package/dist/package-manager.d.ts +0 -23
  179. package/dist/packem_shared/otelPlugin-CJLkguJ8.js +0 -1
  180. package/dist/plugins/config-loader.d.ts +0 -3
  181. package/dist/plugins/otel.d.ts +0 -63
  182. package/dist/plugins/post-command.d.ts +0 -3
  183. package/dist/plugins/security-enforcement.d.ts +0 -3
  184. package/dist/pm-runner.d.ts +0 -44
  185. package/dist/run-report.d.ts +0 -40
  186. package/dist/runtime-check.d.ts +0 -27
  187. package/dist/sbom/cyclonedx.d.ts +0 -39
  188. package/dist/sbom/installed-package.d.ts +0 -49
  189. package/dist/sbom/license.d.ts +0 -31
  190. package/dist/sbom/lockfile.d.ts +0 -34
  191. package/dist/sbom/purl.d.ts +0 -25
  192. package/dist/sbom/resolve-specifier.d.ts +0 -24
  193. package/dist/sbom/types.d.ts +0 -196
  194. package/dist/secrets/baseline.d.ts +0 -20
  195. package/dist/secrets/format.d.ts +0 -14
  196. package/dist/secrets/git.d.ts +0 -6
  197. package/dist/secrets/spinner.d.ts +0 -9
  198. package/dist/security.d.ts +0 -64
  199. package/dist/selectors.d.ts +0 -81
  200. package/dist/shell-history.d.ts +0 -16
  201. package/dist/socket-security.d.ts +0 -129
  202. package/dist/staged/cli-parse.d.ts +0 -18
  203. package/dist/staged/config.d.ts +0 -14
  204. package/dist/staged/errors/apply-empty-commit-error.d.ts +0 -4
  205. package/dist/staged/errors/config-error.d.ts +0 -4
  206. package/dist/staged/errors/get-backup-stash-error.d.ts +0 -4
  207. package/dist/staged/errors/git-error.d.ts +0 -6
  208. package/dist/staged/errors/index.d.ts +0 -12
  209. package/dist/staged/errors/restore-original-state-error.d.ts +0 -4
  210. package/dist/staged/errors/staged-error.d.ts +0 -8
  211. package/dist/staged/errors/task-error.d.ts +0 -6
  212. package/dist/staged/git/diff.d.ts +0 -76
  213. package/dist/staged/git/exec.d.ts +0 -43
  214. package/dist/staged/git/index.d.ts +0 -77
  215. package/dist/staged/git/stash.d.ts +0 -37
  216. package/dist/staged/index.d.ts +0 -13
  217. package/dist/staged/match.d.ts +0 -12
  218. package/dist/staged/renderer/index.d.ts +0 -9
  219. package/dist/staged/renderer/ink/index.d.ts +0 -4
  220. package/dist/staged/renderer/plain.d.ts +0 -12
  221. package/dist/staged/tasks/build.d.ts +0 -13
  222. package/dist/staged/tasks/exec.d.ts +0 -56
  223. package/dist/staged/tasks/run.d.ts +0 -26
  224. package/dist/staged/types.d.ts +0 -173
  225. package/dist/target-discovery.d.ts +0 -59
  226. package/dist/target-options.d.ts +0 -261
  227. package/dist/tips.d.ts +0 -41
  228. package/dist/tui/components/CheckProgressApp.d.ts +0 -6
  229. package/dist/tui/components/CommandSummary.d.ts +0 -17
  230. package/dist/tui/components/Header.d.ts +0 -13
  231. package/dist/tui/components/OutputPanel.d.ts +0 -17
  232. package/dist/tui/components/QuitDialog.d.ts +0 -15
  233. package/dist/tui/components/TaskListPanel.d.ts +0 -19
  234. package/dist/tui/components/TaskRow.d.ts +0 -12
  235. package/dist/tui/components/TaskStore.d.ts +0 -80
  236. package/dist/tui/components/VisTaskRunnerApp.d.ts +0 -17
  237. package/dist/tui/components/devcontainer/DevcontainerStore.d.ts +0 -66
  238. package/dist/tui/components/devcontainer/VisDevcontainerApp.d.ts +0 -9
  239. package/dist/tui/components/devcontainer/catalogs/extensions.d.ts +0 -8
  240. package/dist/tui/components/devcontainer/catalogs/features.d.ts +0 -8
  241. package/dist/tui/components/devcontainer/catalogs/filters.d.ts +0 -4
  242. package/dist/tui/components/devcontainer/catalogs/mount-suggestions.d.ts +0 -19
  243. package/dist/tui/components/devcontainer/catalogs/templates.d.ts +0 -8
  244. package/dist/tui/components/devcontainer/devcontainer-io.d.ts +0 -14
  245. package/dist/tui/components/devcontainer/sections/DockerComposeSection.d.ts +0 -11
  246. package/dist/tui/components/devcontainer/sections/EnvironmentSection.d.ts +0 -16
  247. package/dist/tui/components/devcontainer/sections/ExtensionsSection.d.ts +0 -11
  248. package/dist/tui/components/devcontainer/sections/FeaturesSection.d.ts +0 -11
  249. package/dist/tui/components/devcontainer/sections/GeneralSection.d.ts +0 -12
  250. package/dist/tui/components/devcontainer/sections/LifecycleSection.d.ts +0 -13
  251. package/dist/tui/components/devcontainer/sections/MountsSection.d.ts +0 -16
  252. package/dist/tui/components/devcontainer/sections/PortsSection.d.ts +0 -10
  253. package/dist/tui/components/devcontainer/sections/PreviewPanel.d.ts +0 -11
  254. package/dist/tui/components/devcontainer/types.d.ts +0 -53
  255. package/dist/tui/components/devcontainer/validate.d.ts +0 -16
  256. package/dist/tui/components/graph/GraphStore.d.ts +0 -42
  257. package/dist/tui/components/graph/ProjectDetailPanel.d.ts +0 -10
  258. package/dist/tui/components/graph/ProjectListPanel.d.ts +0 -20
  259. package/dist/tui/components/graph/VisGraphApp.d.ts +0 -8
  260. package/dist/tui/components/optimize/OptimizeDetailPanel.d.ts +0 -9
  261. package/dist/tui/components/optimize/OptimizeListPanel.d.ts +0 -16
  262. package/dist/tui/components/optimize/OptimizeStore.d.ts +0 -50
  263. package/dist/tui/components/optimize/VisOptimizeApp.d.ts +0 -8
  264. package/dist/tui/components/optimize/constants.d.ts +0 -7
  265. package/dist/tui/components/update/PackageDetailPanel.d.ts +0 -12
  266. package/dist/tui/components/update/PackageListPanel.d.ts +0 -21
  267. package/dist/tui/components/update/UpdateStore.d.ts +0 -62
  268. package/dist/tui/components/update/VisUpdateApp.d.ts +0 -18
  269. package/dist/tui/dynamic-life-cycle.d.ts +0 -22
  270. package/dist/tui/formatting-utils.d.ts +0 -17
  271. package/dist/tui/pretty-time.d.ts +0 -8
  272. package/dist/tui/static-life-cycle.d.ts +0 -28
  273. package/dist/tui/status-utils.d.ts +0 -20
  274. package/dist/tui/symbols.d.ts +0 -7
  275. package/dist/tui/types.d.ts +0 -11
  276. package/dist/typosquats.d.ts +0 -70
  277. package/dist/upgrade-check.d.ts +0 -30
  278. package/dist/utils.d.ts +0 -22
  279. package/dist/watch.d.ts +0 -65
  280. package/dist/workspace.d.ts +0 -675
@@ -0,0 +1,5 @@
1
+ var g=Object.defineProperty;var a=(e,i)=>g(e,"name",{value:i,configurable:!0});import{createRequire as y}from"node:module";import{isAccessibleSync as u,readFileSync as p,writeFileSync as j}from"@visulima/fs";import{join as r}from"@visulima/path";const _=y(import.meta.url),c=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,d=a(e=>{if(typeof c<"u"&&c.versions&&c.versions.node){const[i,o]=c.versions.node.split(".").map(Number);if(i>22||i===22&&o>=3||i===20&&o>=16)return c.getBuiltinModule(e)}return _(e)},"__cjs_getBuiltinModule"),{rmSync:b}=d("node:fs"),{homedir:s}=d("node:os"),{createInterface:w}=d("node:readline");var S=Object.defineProperty,m=a((e,i)=>S(e,"name",{value:i,configurable:!0}),"l");const f=r(s(),".vis"),h=[r(s(),".zshrc"),r(s(),".zshenv"),r(s(),".bashrc"),r(s(),".bash_profile"),r(s(),".profile"),r(s(),".config","fish","config.fish")],T=m(e=>{const i=[];for(const o of h)if(u(o))try{const l=p(o).split(`
2
+ `),n=l.filter(t=>!t.includes(".vis/bin")&&!t.includes("VIS_HOME")&&!t.includes("# vis "));n.length!==l.length&&(j(o,n.join(`
3
+ `)),i.push(o))}catch{e.warn(`warning: could not clean ${o}`)}return i},"cleanShellProfiles"),F=m(async({logger:e,options:i})=>{if(!u(f)){e.info("vis is not installed (no ~/.vis directory found).");return}e.info("This will remove:"),e.info(` ${f}/`);const o=h.filter(n=>u(n)&&p(n).includes(".vis"));for(const n of o)e.info(` Lines in ${n}`);if(!i.yes){if(!process.stdin.isTTY)throw new Error("Non-interactive terminal. Use --yes to confirm.");const n=w({input:process.stdin,output:process.stdout}),t=await new Promise(v=>{n.question(`
4
+ Type "uninstall" to confirm: `,v)});if(n.close(),t.trim()!=="uninstall"){e.info("Aborted.");return}}const l=T(e);for(const n of l)e.info(`Cleaned ${n}`);try{b(f,{force:!0,recursive:!0}),e.info(`
5
+ ✓ Removed ${f}`)}catch(n){throw new Error(`Failed to remove ${f}: ${n instanceof Error?n.message:String(n)}`)}e.info("✓ vis has been uninstalled.")},"execute");export{F as default};
@@ -0,0 +1 @@
1
+ var g=Object.defineProperty;var n=(e,a)=>g(e,"name",{value:a,configurable:!0});import{a as l,w as d}from"../packem_shared/bin-BaZZ32BK.js";var k=Object.defineProperty,u=n((e,a)=>k(e,"name",{value:a,configurable:!0}),"c");const m=u(async({argument:e,logger:a,options:c,visConfig:r,workspaceRoot:i})=>{if(!e||e.length===0)throw new Error("No package specified. Usage: vis info <package> [field...]");const[t,...f]=e,s=i??process.cwd(),p=l(s,{configBackend:r?.install?.backend}),o=d(p,{fields:f,json:c.json||!1,package:t},s,a);o!==0&&o!==1&&(process.exitCode=o)},"execute");export{m as default};
@@ -0,0 +1,20 @@
1
+ var O=Object.defineProperty;var w=(t,e)=>O(t,"name",{value:e,configurable:!0});import{createRequire as T}from"node:module";import{isAccessibleSync as h,writeFileSync as S}from"@visulima/fs";import{join as v}from"@visulima/path";import{findVisConfigFile as M}from"../config.js";import{O as n,c as l,I as g,b as R,y as _,U as C,m as P}from"../packem_shared/bin-BaZZ32BK.js";const I=T(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,x=w(t=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[e,o]=m.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return m.getBuiltinModule(t)}return I(t)},"__cjs_getBuiltinModule"),{execSync:E}=x("node:child_process"),{createInterface:N}=x("node:readline");var q=Object.defineProperty,f=w((t,e)=>q(t,"name",{value:e,configurable:!0}),"l");const K=f(t=>{const e=[];return h(v(t,"turbo.json"))&&e.push("turborepo"),h(v(t,"nx.json"))&&e.push("nx"),h(v(t,".moon"))&&e.push("moon"),e},"detectExistingTools"),V=f((t,e)=>new Promise(o=>{t.question(e,s=>{o(s.trim())})}),"ask"),p=f(async(t,e,o=!0)=>{const s=await V(t,`${e} ${o?"[Y/n]":"[y/N]"} `);return s===""?o:s.toLowerCase()==="y"||s.toLowerCase()==="yes"},"confirm"),j=f((t,e)=>{const o=[],s=Object.entries(e.allowBuilds).filter(([,a])=>a).map(([a])=>` "${a}": true,`).join(`
2
+ `);let i=` allowBuilds: ${s?`{
3
+ ${s}
4
+ }`:"{}"},`;return e.enableSocket&&(i+=`
5
+ socket: { enabled: true },`),o.push(` security: {
6
+ ${i}
7
+ },`),e.staged&&o.push(` staged: {
8
+ "*.{ts,tsx}": "eslint --fix",
9
+ "*.{ts,tsx,js,jsx,json,md}": "prettier --write",
10
+ },`),`import { defineConfig } from "@visulima/vis/config";
11
+
12
+ export default defineConfig({
13
+ ${o.join(`
14
+
15
+ `)}
16
+ });
17
+ `},"generateConfigContent"),A=f(async(t,e,o)=>{const s=N({input:process.stdin,output:process.stdout});n(`
18
+ vis init — interactive setup
19
+ `);const i=await p(s," Enable Socket.dev security scanning?");i&&(l(" Socket.dev enabled — scores, alerts, and supply chain data active."),process.env.VIS_SOCKET_TOKEN||g(" Set VIS_SOCKET_TOKEN for a custom API token (optional).")),n("");const a=await p(s," Scan for packages with build scripts?"),u={};if(a){n(" Scanning node_modules...");const c=R(t,{});if(c.length>0){n(` Found ${String(c.length)} package${c.length===1?"":"s"} with build scripts:
20
+ `);for(const r of c){const d=await p(s,` Allow ${r}?`,!1),k=r.split(" (")[0]??r;u[k]=d,d&&l(` ✓ ${k} approved`)}}else n(" No packages with build scripts found.")}n("");const $=await p(s," Set up pre-commit hooks (lint-staged)?",!1);let b=!1;(e.name==="pnpm"||e.name==="yarn"||e.name==="npm"||e.name==="bun")&&(n(""),b=await p(s,` Sync security settings to ${e.name} config?`));const y=K(t);if(y.length>0&&(n(""),n(` Detected existing tools: ${y.join(", ")}`),await p(s,` Run \`vis migrate\` for ${y.join(", ")}?`,!1))){s.close();const c=e.name==="pnpm"?"pnpm exec":e.name==="yarn"?"yarn exec":e.name==="bun"?"bunx":"npx";for(const r of y){n(` Migrating from ${r}...`);try{E(`${c} vis migrate ${r}`,{cwd:t,stdio:"inherit"})}catch{_(` Migration from ${r} had issues — run \`vis migrate ${r}\` manually.`)}}if(h(o))l(`Migrated config written to ${o}`);else{const r=j(e.name,{allowBuilds:u,enableSocket:i,staged:$});S(o,r),l(`Created ${o}`)}g(" Run 'vis doctor' to see your project's full health status.");return}s.close(),n("");const B=j(e.name,{allowBuilds:u,enableSocket:i,staged:$});if(S(o,B),l(`Created ${o}`),b){const c=Object.fromEntries(Object.entries(u).filter(([,d])=>d)),r=C(e.name,t,c);for(const d of r)l(` ${d}`)}n(""),n(" Setup complete. Your config:"),n(` Security: ${i?"Socket.dev enabled":"defaults only"}`),n(` Build scripts: ${Object.values(u).filter(Boolean).length} approved`),n(` Git hooks: ${$?"lint-staged configured":"not configured"}`),n(` PM sync: ${b?"done":"skipped"}`),n(""),g(" Run 'vis doctor' to see your project's full health status."),n("")},"runInteractiveInit"),F=f((t,e,o,s)=>{const i=j(e.name,{allowBuilds:{},enableSocket:!1,staged:!1});if(S(s,i),l(`Created ${s}`),n(" Secure defaults applied automatically by defineConfig()."),o.syncNative){const a=C(e.name,t,{});for(const u of a)l(` ${u}`)}n(""),g("Run 'vis doctor' for a full health check, or 'vis init' in a terminal for guided setup.")},"runStaticInit"),H=f(async({options:t,workspaceRoot:e})=>{const o=e??process.cwd(),s=P(o),i=M(o);if(i&&!t.force){_(`Config already exists: ${i}`),g("Use --force to overwrite, or edit the existing file.");return}const a=i??v(o,"vis.config.ts");process.stdin.isTTY&&t.interactive!==!1&&!t.noInteractive?await A(o,s,a):F(o,s,t,a)},"execute");export{H as default};
@@ -0,0 +1 @@
1
+ var _=Object.defineProperty;var c=(o,e)=>_(o,"name",{value:e,configurable:!0});import{createRequire as k}from"node:module";import{join as j}from"@visulima/path";import{E as l,m as C,a as w,G as q,y as O,O as S,K as R}from"../packem_shared/bin-BaZZ32BK.js";import{s as T}from"../packem_shared/typosquats-Bpq4zcWL.js";import{o as $}from"../packem_shared/utils-DrNg0XTR.js";const b=k(import.meta.url),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,x=c(o=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[e,n]=t.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return t.getBuiltinModule(o)}return b(o)},"__cjs_getBuiltinModule"),{rmSync:h}=x("node:fs");var E=Object.defineProperty,B=c((o,e)=>E(o,"name",{value:e,configurable:!0}),"d");const d=new Set(["aube","auto","bun","npm","pnpm","yarn"]),D=B(async({logger:o,options:e,visConfig:n,workspaceRoot:m})=>{const r=m??process.cwd();if(!e.noTyposquatCheck&&!await T(r,n?.security?.typosquatAllowlist)){process.exitCode=1;return}const i=e.installer;if(i&&!d.has(i)){l(`Invalid --installer value: "${i}". Expected one of: ${[...d].join(", ")}.`),process.exitCode=1;return}const g=i,y=e.noAube||!1;let a;try{a=y?C(r):w(r,{backend:g,configBackend:n?.install?.backend})}catch(s){l(s instanceof Error?s.message:String(s)),process.exitCode=1;return}const f=q(r,a);f&&O(f);const v=$(e.filter),p=e.ci||!1;if(p){S("Clean install: removing node_modules...");try{h(j(r,"node_modules"),{force:!0,recursive:!0})}catch(s){l(`Failed to remove node_modules: ${s instanceof Error?s.message:String(s)}`),process.exitCode=1;return}}const u=R(a,{dev:e.dev||!1,filter:v,force:e.force||!1,frozenLockfile:p||e.frozenLockfile||!1,ignoreScripts:e.ignoreScripts||!1,lockfileOnly:e.lockfileOnly||!1,noOptional:e.noOptional||!1,offline:e.offline||!1,prod:e.prod||!1,recursive:e.recursive||!1,silent:e.silent||!1,workspaceRoot:e.workspaceRoot||!1},r,o);u!==0&&(process.exitCode=u)},"execute");export{D as default};
@@ -0,0 +1 @@
1
+ var l=Object.defineProperty;var c=(e,a)=>l(e,"name",{value:a,configurable:!0});import{a as u,z as d}from"../packem_shared/bin-BaZZ32BK.js";var f=Object.defineProperty,g=c((e,a)=>f(e,"name",{value:a,configurable:!0}),"s");const v=g(async({argument:e,logger:a,visConfig:n,workspaceRoot:s})=>{const t=e?.[0]??null,o=s??process.cwd(),i=u(o,{configBackend:n?.install?.backend}),r=d(i,t,o,a);r!==0&&(process.exitCode=r)},"execute");export{v as default};
@@ -0,0 +1 @@
1
+ var b=Object.defineProperty;var u=(r,n)=>b(r,"name",{value:n,configurable:!0});import{f as O}from"../packem_shared/selectors-CfH9ZY08.js";import{Z as T}from"../packem_shared/bin-BaZZ32BK.js";var w=Object.defineProperty,d=u((r,n)=>w(r,"name",{value:n,configurable:!0}),"f");const S=d(async({logger:r,options:n,visConfig:h,workspaceRoot:l})=>{if(!l)throw new Error("Could not determine workspace root.");const{projectOptions:k,workspace:s}=T(l,h);let a=Object.keys(s.projects).sort();if(n.query&&(a=O(a,s,n.query)),a.length===0){r.info("No projects found.");return}if(n.json){const o=a.map(e=>{const t=s.projects[e],p=k.get(e)??{},g=Object.entries(t.targets??{}).map(([y])=>{const i=p[y];return{aliases:i?.aliases??[],command:i?.command,description:i?.description,name:y,type:i?.type}});return{language:t.language,layer:t.layer,name:e,root:t.root,stack:t.stack,tags:t.tags??[],targets:g,type:t.projectType??"library"}});r.info(JSON.stringify(o,null,2));return}const f=["Project","Type","Layer","Tags","Targets"],j=a.map(o=>{const e=s.projects[o],t=Object.keys(e.targets??{});return[o,e.projectType??"library",e.layer??"—",(e.tags??[]).join(", ")||"—",t.length>4?`${t.slice(0,4).join(", ")}… (${String(t.length)})`:t.join(", ")||"—"]}),c=f.map((o,e)=>{const t=j.reduce((p,g)=>Math.max(p,(g[e]??"").length),0);return Math.max(o.length,t)}),m=d((o,e)=>o.padEnd(e),"pad");r.info(f.map((o,e)=>m(o,c[e])).join(" ")),r.info(c.map(o=>"─".repeat(o)).join("──"));for(const o of j)r.info(o.map((e,t)=>m(e,c[t])).join(" "));r.info(""),r.info(`${String(a.length)} project(s)`)},"execute");export{S as default};
@@ -0,0 +1,2 @@
1
+ var v=Object.defineProperty;var u=(e,o)=>v(e,"name",{value:o,configurable:!0});import{createRequire as R}from"node:module";import{F as h,L as x,P as C,X as s,_ as j,a0 as E,a1 as $,a2 as M,a3 as S,a4 as _,a5 as I,a6 as T}from"../packem_shared/bin-BaZZ32BK.js";import{isAccessibleSync as d,readFileSync as k}from"@visulima/fs";import{join as m}from"@visulima/path";const w=R(import.meta.url),p=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=u(e=>{if(typeof p<"u"&&p.versions&&p.versions.node){const[o,r]=p.versions.node.split(".").map(Number);if(o>22||o===22&&r>=3||o===20&&r>=16)return p.getBuiltinModule(e)}return w(e)},"__cjs_getBuiltinModule"),{stdin:y,stdout:D}=p,{createInterface:N}=b("node:readline/promises");var O=Object.defineProperty,P=u((e,o)=>O(e,"name",{value:o,configurable:!0}),"o");const F=P(async e=>{if(!y.isTTY)return!0;const o=N({input:y,output:D});try{const r=(await o.question(`${e} [Y/n] `)).trim().toLowerCase();return r===""||r==="y"||r==="yes"}finally{o.close()}},"confirm");var L=Object.defineProperty,f=u((e,o)=>L(e,"name",{value:o,configurable:!0}),"c$1");const q=[".husky/pre-commit",".vis-hooks/pre-commit",".git/hooks/pre-commit"],B=[".secretlintrc",".secretlintrc.json",".secretlintrc.js",".secretlintrc.mjs",".secretlintrc.cjs",".secretlintrc.yml",".secretlintrc.yaml"],K=f(e=>{const o=m(e,"package.json");if(!d(o))return[];let r;try{r=JSON.parse(k(o))}catch{return[]}const i=[];if(r.scripts)for(const[t,l]of Object.entries(r.scripts))typeof l=="string"&&(/\bgitleaks\b/.test(l)&&i.push({detail:`Script "${t}" still invokes gitleaks: ${l}`,kind:"script",location:"package.json"}),/\bsecretlint\b/.test(l)&&i.push({detail:`Script "${t}" still invokes secretlint: ${l}`,kind:"script",location:"package.json"}));if(r.devDependencies)for(const t of Object.keys(r.devDependencies))(t==="gitleaks"||t==="@gitleaks/cli")&&i.push({detail:`devDependency \`${t}\` is still installed`,kind:"devDep",location:"package.json"}),(t==="secretlint"||t.startsWith("@secretlint/"))&&i.push({detail:`devDependency \`${t}\` is still installed`,kind:"devDep",location:"package.json"});return i},"scanPackageJson"),A=f(e=>{const o=[];for(const r of q){const i=m(e,r);if(!d(i))continue;const t=k(i);/\bgitleaks\b/.test(t)&&o.push({detail:"gitleaks invocation still present in hook",kind:"hook",location:r}),/\bsecretlint\b/.test(t)&&o.push({detail:"secretlint invocation still present in hook",kind:"hook",location:r})}return o},"scanHooks"),G=f(e=>{const o=[];for(const r of B)d(m(e,r))&&o.push({detail:"secretlint config should be removed after migration",kind:"config",location:r});return o},"scanConfigs"),J=f((e,o)=>{const r=[...K(e),...A(e),...G(e)];if(r.length===0)return o.info("✓ No unmigrated gitleaks/secretlint references found."),[];o.warn(`Found ${String(r.length)} unmigrated reference(s):`);for(const i of r)o.warn(` [${i.kind}] ${i.location} — ${i.detail}`);return r},"verifyMigration");var Q=Object.defineProperty,n=u((e,o)=>Q(e,"name",{value:o,configurable:!0}),"r");const a=n(e=>{const o=e.workspaceRoot??process.cwd();return{config:e.visConfig??{},dryRun:!!e.options.dryRun,logger:e.logger,packageManager:x(o),report:h(),root:o}},"buildContext"),c=n(async(e,o,r)=>{if(o.yes||o.dryRun)return!0;const i=await F(`This will edit files, scripts, and hooks for "${e}". Backups (.bak) will be created. Continue?`);return i||r.info("Aborted."),i},"maybeConfirm"),g=n(e=>{e.dryRun&&e.logger.info(`Running in dry-run mode — no changes will be made.
2
+ `)},"announceDryRun"),V=n(async({logger:e,options:o,visConfig:r,workspaceRoot:i})=>{if(!await c("deps",o,e))return;const t=a({logger:e,options:o,visConfig:r,workspaceRoot:i});g(t),e.info("── Migrating dependencies and scripts ──"),C(t.root,t.packageManager,t.config,{dryRun:t.dryRun},e,t.report),e.info(""),s(t.report,e)},"migrateDepsExecuteImpl"),W=n(async({logger:e,options:o,visConfig:r,workspaceRoot:i})=>{if(!await c("lint-staged",o,e))return;const t=a({logger:e,options:o,visConfig:r,workspaceRoot:i});g(t),e.info("── Migrating lint-staged ──"),j(t.root,{dryRun:t.dryRun},e,t.report),e.info(""),s(t.report,e)},"migrateLintStagedExecuteImpl"),Y=n(async({logger:e,options:o,visConfig:r,workspaceRoot:i})=>{if(!await c("nano-staged",o,e))return;const t=a({logger:e,options:o,visConfig:r,workspaceRoot:i});g(t),e.info("── Migrating nano-staged ──"),E(t.root,{dryRun:t.dryRun},e,t.report),e.info(""),s(t.report,e)},"migrateNanoStagedExecuteImpl"),H=n(async({logger:e,options:o,visConfig:r,workspaceRoot:i})=>{if(!await c("turborepo",o,e))return;const t=a({logger:e,options:o,visConfig:r,workspaceRoot:i});g(t),e.info("── Migrating turborepo ──"),$(t.root,{dryRun:t.dryRun},e,t.report),e.info(""),s(t.report,e)},"migrateTurborepoExecuteImpl"),X=n(async({logger:e,options:o,visConfig:r,workspaceRoot:i})=>{if(!await c("nx",o,e))return;const t=a({logger:e,options:o,visConfig:r,workspaceRoot:i});g(t),e.info("── Migrating nx ──"),M(t.root,{dryRun:t.dryRun},e,t.report),e.info(""),s(t.report,e)},"migrateNxExecuteImpl"),z=n(async({logger:e,options:o,visConfig:r,workspaceRoot:i})=>{if(!await c("moon",o,e))return;const t=a({logger:e,options:o,visConfig:r,workspaceRoot:i});g(t),e.info("── Migrating moon ──"),S(t.root,{copyTemplates:!!o.copyTemplates,dryRun:t.dryRun},e,t.report),e.info(""),s(t.report,e)},"migrateMoonExecuteImpl"),U=n(async({logger:e,options:o,visConfig:r,workspaceRoot:i})=>{if(!await c("gitleaks",o,e))return;const t=a({logger:e,options:o,visConfig:r,workspaceRoot:i});g(t),e.info("── Migrating gitleaks ──"),_(t.root,{dryRun:t.dryRun},e,t.report),e.info(""),s(t.report,e)},"migrateGitleaksExecuteImpl"),Z=n(async({logger:e,options:o,visConfig:r,workspaceRoot:i})=>{if(!await c("kingfisher",o,e))return;const t=a({logger:e,options:o,visConfig:r,workspaceRoot:i});g(t),e.info("── Migrating Kingfisher ──"),I(t.root,{dryRun:t.dryRun},e,t.report),e.info(""),s(t.report,e)},"migrateKingfisherExecuteImpl"),ee=n(async({logger:e,options:o,visConfig:r,workspaceRoot:i})=>{if(!await c("secretlint",o,e))return;const t=a({logger:e,options:o,visConfig:r,workspaceRoot:i});g(t),e.info("── Migrating secretlint ──"),T(t.root,{dryRun:t.dryRun},e,t.report),e.info(""),s(t.report,e)},"migrateSecretlintExecuteImpl"),te=n(({logger:e,workspaceRoot:o})=>{const r=o??process.cwd();J(r,e).length>0&&(process.exitCode=1)},"migrateVerifyExecuteImpl"),ae=V,ce=W,ge=Y,pe=H,le=X,ue=z,fe=U,de=Z,me=ee,ye=te;export{ae as migrateDepsExecute,fe as migrateGitleaksExecute,de as migrateKingfisherExecute,ce as migrateLintStagedExecute,ue as migrateMoonExecute,ge as migrateNanoStagedExecute,le as migrateNxExecute,me as migrateSecretlintExecute,pe as migrateTurborepoExecute,ye as migrateVerifyExecute};
@@ -0,0 +1,2 @@
1
+ var y=Object.defineProperty;var l=(t,r)=>y(t,"name",{value:r,configurable:!0});import{getAffectedProjects as v}from"@visulima/task-runner";import{f as E}from"../packem_shared/selectors-CfH9ZY08.js";import{Z as F,e as b}from"../packem_shared/bin-BaZZ32BK.js";var S=Object.defineProperty,$=l((t,r)=>S(t,"name",{value:r,configurable:!0}),"m");const A=$(async({argument:t,logger:r,options:e,runtime:h,visConfig:g,workspaceRoot:f})=>{const d=t[0];if(!d)throw new Error("Missing target. Usage: vis affected <target>");if(!f)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const s=f,{packageJsons:m,workspace:i}=F(s,g),w=b(s,i,m),u=new Set(["deep","direct","none"]),c=e.downstream??"deep",p=e.upstream??"none";if(!u.has(c))throw new Error(`Invalid --downstream value: "${c}". Must be "none", "direct", or "deep".`);if(!u.has(p))throw new Error(`Invalid --upstream value: "${p}". Must be "none", "direct", or "deep".`);const j={base:e.base,downstream:c,head:e.head,projectGraph:w,projects:i.projects,upstream:p,workspaceRoot:s},o=await v(j);if(o.changedFiles.length===0){r.info("No files changed. Nothing to run.");return}if(o.affectedProjects.length===0){r.info("No projects affected by the changes.");return}let{affectedProjects:n}=o;if(e.query&&(n=E(n,i,e.query),n.length===0)){r.info(`Query "${String(e.query)}" matched no affected projects.`);return}r.info(`Affected projects: ${n.join(", ")}`),o.changedFiles.length>0&&(process.env.VIS_AFFECTED_FILES=o.changedFiles.join(`
2
+ `));const a=[d,`--projects=${n.join(",")}`];e.parallel!==void 0&&a.push(`--parallel=${String(e.parallel)}`),e.cache||a.push("--no-cache"),e.dryRun&&a.push("--dry-run"),e.partition&&a.push(`--partition=${String(e.partition)}`);try{await h.runCommand("run",{argv:a})}finally{delete process.env.VIS_AFFECTED_FILES}},"execute");export{A as default};
@@ -0,0 +1,22 @@
1
+ var pe=Object.defineProperty;var T=(r,e)=>pe(r,"name",{value:e,configurable:!0});import{createRequire as fe}from"node:module";import{getManifestData as ge}from"@socketsecurity/registry";import{isAccessibleSync as X,readFileSync as M,writeFileSync as F,readJsonSync as re,glob as ye}from"@visulima/fs";import{join as A,resolve as ke}from"@visulima/path";import{Box as d,Text as c,ScrollView as ve,ScrollBar as we,useApp as be,useWindowSize as $e,useInput as Se,render as xe}from"@visulima/tui";import{C as Ce,D as Oe,B as W,m as je,O as v,c as q,y as Y,I as H,K as Ne,s as Ee}from"../packem_shared/bin-BaZZ32BK.js";import Te from"module-replacements/manifests/micro-utilities.json"with{type:"json"};import Pe from"module-replacements/manifests/native.json"with{type:"json"};import Ae from"module-replacements/manifests/preferred.json"with{type:"json"};import De,{useSyncExternalStore as Ie,useRef as Re,useState as U,useCallback as Fe}from"react";import{coerce as te}from"semver";import{readYamlSync as _e}from"@visulima/fs/yaml";import{jsx as i,jsxs as f,Fragment as K}from"react/jsx-runtime";const he=fe(import.meta.url),R=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,me=T(r=>{if(typeof R<"u"&&R.versions&&R.versions.node){const[e,t]=R.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return R.getBuiltinModule(r)}return he(r)},"__cjs_getBuiltinModule"),{writeFileSync:ue}=me("node:fs");var Me=Object.defineProperty,N=T((r,e)=>Me(r,"name",{value:e,configurable:!0}),"c$1");const ze=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],Le=["overrides","pnpm","resolutions"],Je=["engines","files"],qe=N(r=>{const e=te(r)?.major;return e!==void 0&&e>=10},"isPnpmV10Plus"),Ge=N(r=>{const e=A(r,"pnpm-workspace.yaml");if(!X(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:_e(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},"readPnpmWorkspaceOverrides"),Be=N((r,e)=>{let t={};return e==="pnpm"?t=r.pnpm?.overrides??{}:e==="yarn"||e==="bun"?t=r.resolutions??{}:t=r.overrides??{},{overrides:t,source:"package.json"}},"readPkgJsonOverrides"),Ve=N((r,e,t)=>t.name==="pnpm"&&qe(t.version)?Ge(r):Be(e,t.name),"readOverrides"),Z=N((r,e)=>{const t=e;for(const a of Le){const o=r.indexOf(a);if(o!==-1&&a!==t)return t==="overrides"?o:o+1}let n=-1;for(const a of ze){const o=r.indexOf(a);o>n&&(n=o)}if(n!==-1)return n+1;for(const a of Je){const o=r.indexOf(a);if(o!==-1)return o}return r.length},"findInsertIndex"),Xe=N(r=>/\n(\s+)/.exec(r)?.[1]??" ","detectIndent"),We=N((r,e)=>{const t=A(r,"pnpm-workspace.yaml");if(!X(t))throw new Error(`pnpm-workspace.yaml not found at ${t}. Cannot write overrides for pnpm v10+.`);let n=M(t);const a=`overrides:
2
+ ${Object.entries(e).map(([o,s])=>` '${o}': '${s}'`).join(`
3
+ `)}
4
+ `;n=/^overrides:\s*$/m.test(n)||/^overrides:\s*\n/m.test(n)?n.replace(/^overrides:\s*\n(?:(?:[ \t].*)?\n)*/m,a):`${n.trimEnd()}
5
+
6
+ ${a}`,F(t,n)},"writePnpmWorkspaceOverrides"),Ye=N((r,e,t,n)=>{const a=M(r),o=Xe(a);if(n==="pnpm"){const s=e.pnpm??{};if(s.overrides=t,e.pnpm)e.pnpm=s,F(r,`${JSON.stringify(e,null,o)}
7
+ `);else{const m=Object.keys(e),p=Z(m,"pnpm"),u=Object.entries(e);u.splice(p,0,["pnpm",s]),F(r,`${JSON.stringify(Object.fromEntries(u),null,o)}
8
+ `)}}else{const s=n==="yarn"||n==="bun"?"resolutions":"overrides";if(e[s])e[s]=t,F(r,`${JSON.stringify(e,null,o)}
9
+ `);else{const m=Object.keys(e),p=Z(m,s),u=Object.entries(e);u.splice(p,0,[s,t]),F(r,`${JSON.stringify(Object.fromEntries(u),null,o)}
10
+ `)}}},"writePkgJsonOverrides"),He=N((r,e,t,n)=>{const a=M(e),o=JSON.parse(a),{overrides:s,source:m}=Ve(r,o,n),p=[],u=[],x=new Set;if(n.name==="npm")for(const g of["dependencies","devDependencies"]){const w=o[g];if(w)for(const y of Object.keys(w))x.add(y)}for(const g of t){const w=s[g.original];if(typeof w=="object")continue;let y=g.spec;n.name==="npm"&&x.has(g.original)&&(y=`$${g.original}`),w!==y&&(w?u.push(g.original):p.push(g.original),s[g.original]=y)}if(p.length===0&&u.length===0)return{added:p,updated:u};const S=Object.fromEntries(Object.entries(s).sort(([g],[w])=>g.localeCompare(w)));return m==="pnpm-workspace.yaml"?We(r,S):Ye(e,o,S,n.name),{added:p,updated:u}},"applyOverrides"),Ue=N((r,e)=>{const t={bun:["bun.lock"],npm:["npm-shrinkwrap.json","package-lock.json"],pnpm:["pnpm-lock.yaml"],yarn:["yarn.lock"]};for(const n of t[e]??[]){const a=A(r,n);try{return M(a)}catch{continue}}return""},"readLockfileText"),Ke=N((r,e,t)=>{if(!r)return!1;const n=e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`);switch(t){case"bun":return r.includes(`"${e}":`)||new RegExp(String.raw`(^|\s|[",])${n}@`,"m").test(r);case"npm":return r.includes(`"${e}":`)||r.includes(`"node_modules/${e}":`);case"pnpm":return new RegExp(String.raw`(^|\s|['"/])${n}(@|['"]?:)`,"m").test(r);case"yarn":return new RegExp(String.raw`(^|\s|[",])${n}@`,"m").test(r);default:return!1}},"lockfileContainsPackage");var Ze=Object.defineProperty,_=T((r,e)=>Ze(r,"name",{value:e,configurable:!0}),"s");const Qe=_((r,e,t)=>{let n=r;if(e!=="all"&&(n=n.filter(a=>a.category===e)),t){const a=t.toLowerCase();n=n.filter(o=>o.packageName.toLowerCase().includes(a))}return n},"filterEntries");class er{static{T(this,"c")}static{_(this,"OptimizeStore")}#e;#t=new Set;constructor(e){this.#e={applyProgress:null,checkedEntries:new Set,entries:e,error:null,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",phase:"browsing",selectedIndex:0}}getSnapshot=_(()=>this.#e,"getSnapshot");subscribe=_(e=>(this.#t.add(e),()=>{this.#t.delete(e)}),"subscribe");getFilteredEntries=_(()=>Qe(this.#e.entries,this.#e.filterType,this.#e.filterText),"getFilteredEntries");#r(){this.#e={...this.#e};for(const e of this.#t)e()}select(e){const t=this.getFilteredEntries();this.#e.selectedIndex=t.length===0?-1:Math.max(0,Math.min(e,t.length-1)),this.#r()}toggleCheck(e){const t=new Set(this.#e.checkedEntries);t.has(e)?t.delete(e):t.add(e),this.#e.checkedEntries=t,this.#r()}toggleAll(){const e=this.getFilteredEntries(),t=new Set(this.#e.checkedEntries);if(e.every(n=>t.has(n.packageName)))for(const n of e)t.delete(n.packageName);else for(const n of e)t.add(n.packageName);this.#e.checkedEntries=t,this.#r()}setFilter(e){this.#e.filterType=e,this.#e.selectedIndex=0,this.#r()}setFilterText(e){this.#e.filterText=e,this.#e.selectedIndex=0,this.#r()}setFilterActive(e){this.#e.filterActive=e,this.#r()}setFocusedPanel(e){this.#e.focusedPanel=e,this.#r()}setPhase(e){this.#e.phase=e,this.#r()}setProgress(e,t){this.#e.applyProgress={current:e,total:t},this.#r()}setError(e){this.#e.error=e,this.#e.phase="error",this.#r()}getCheckedEntries(){return this.#e.entries.filter(e=>this.#e.checkedEntries.has(e.packageName))}}const ne={"micro-utility":"gray",native:"green",preferred:"yellow",socket:"cyan"},rr={"micro-utility":"MICRO",native:"NATIVE",preferred:"PREF",socket:"SOCKET"},tr={"micro-utility":"Trivial utility package that can be replaced with inline code.",native:"Polyfill for a native JS/Node.js API. Use the built-in instead.",preferred:"A lighter or faster alternative package exists.",socket:"Security-hardened replacement from Socket.dev's @socketregistry."};var nr=Object.defineProperty,or=T((r,e)=>nr(r,"name",{value:e,configurable:!0}),"a");const ir=or(({entry:r,focused:e,scrollRef:t})=>{const n=e?"white":"gray";if(!r)return i(d,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:i(c,{dimColor:!0,children:"No entry selected"})});const a=ne[r.category]??"gray";return f(d,{borderColor:n,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[i(d,{flexShrink:0,paddingTop:1,paddingX:2,children:i(c,{bold:!0,color:"white",children:r.packageName})}),f(ve,{flexGrow:1,flexShrink:1,paddingX:2,ref:t,scrollbar:!0,scrollbarColor:"gray",children:[i(c,{}),f(d,{children:[i(d,{width:14,children:i(c,{dimColor:!0,children:"Category:"})}),i(c,{bold:!0,color:a,children:r.category})]}),f(d,{children:[i(d,{width:14,children:i(c,{dimColor:!0,children:"Replace with:"})}),i(c,{children:r.replacement})]}),r.overrideSpec&&f(d,{children:[i(d,{width:14,children:i(c,{dimColor:!0,children:"Override:"})}),i(c,{color:"cyan",children:r.overrideSpec})]}),f(d,{children:[i(d,{width:14,children:i(c,{dimColor:!0,children:"Codemod:"})}),i(c,{color:r.hasCodemod?"green":"gray",children:r.hasCodemod?"available ⚙":"not available"})]}),f(d,{flexDirection:"column",marginTop:1,children:[i(c,{dimColor:!0,children:"── "}),i(c,{bold:!0,color:"white",children:"DESCRIPTION"}),i(d,{marginTop:1,paddingLeft:2,children:i(c,{children:tr[r.category]??""})})]}),r.category==="native"&&f(d,{flexDirection:"column",marginTop:1,children:[i(c,{dimColor:!0,children:"── "}),i(c,{bold:!0,color:"green",children:"ACTION"}),i(d,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.hasCodemod?f(K,{children:[f(c,{color:"green",children:["✓"," ","Codemod will rewrite imports to use native API."]}),i(c,{dimColor:!0,children:" The package can then be removed from dependencies."})]}):f(K,{children:[f(c,{color:"yellow",children:["ℹ"," ","No automated codemod available."]}),i(c,{dimColor:!0,children:" Manual migration required — replace usage with native equivalent."})]})})]}),r.category==="socket"&&f(d,{flexDirection:"column",marginTop:1,children:[i(c,{dimColor:!0,children:"── "}),i(c,{bold:!0,color:"cyan",children:"ACTION"}),f(d,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[f(c,{color:"cyan",children:["✓"," ","Override will redirect resolution to the hardened package."]}),i(c,{dimColor:!0,children:" No source code changes needed — drop-in replacement."})]})]}),f(d,{flexDirection:"column",marginTop:1,children:[i(c,{dimColor:!0,children:"── "}),i(c,{bold:!0,color:"white",children:"LINKS"}),i(d,{flexDirection:"column",marginTop:1,paddingLeft:2,children:f(c,{color:"cyan",underline:!0,children:["https://npmx.dev/",r.packageName]})})]})]})]})},"OptimizeDetailPanel");var cr=Object.defineProperty,oe=T((r,e)=>cr(r,"name",{value:e,configurable:!0}),"b$1");const sr=[{key:"all",label:"All",shortcut:"1"},{key:"native",label:"Native",shortcut:"2"},{key:"preferred",label:"Preferred",shortcut:"3"},{key:"micro-utility",label:"Micro",shortcut:"4"},{key:"socket",label:"Socket",shortcut:"5"}],ar=oe(({checked:r,entry:e,isSelected:t})=>{const n=ne[e.category]??"white",a=rr[e.category]??e.category,o=r?"☑":"☐",s=e.hasCodemod?"⚙":" ";return f(d,{flexShrink:0,height:1,children:[i(c,{children:t?">":" "}),f(c,{color:r?"white":"gray",children:[" ",o," "]}),i(c,{bold:!0,color:n,children:`[${a}]`.padEnd(9)}),f(c,{children:[" ",s," "]}),i(d,{flexGrow:1,children:i(c,{bold:t,inverse:t,wrap:"truncate",children:e.packageName})}),i(c,{dimColor:!0,children:" → "}),i(c,{wrap:"truncate",children:e.replacement})]})},"EntryRow"),lr=oe(({checkedEntries:r,entries:e,filterActive:t,filterText:n,filterType:a,focused:o,isDryRun:s,scrollOffset:m,selectedIndex:p,totalEntries:u,viewportHeight:x})=>{const S=o?"white":"gray";let g=0,w=0,y=0,O=0;for(const j of e)switch(j.category){case"micro-utility":{y++;break}case"native":{g++;break}case"preferred":{w++;break}case"socket":{O++;break}}const h=[];g>0&&h.push(`${g} native`),w>0&&h.push(`${w} preferred`),y>0&&h.push(`${y} micro`),O>0&&h.push(`${O} socket`);const b=h.length>0?` (${h.join(", ")})`:"",C=r.size,D=[];for(const[j,$]of e.entries())D.push(i(ar,{checked:r.has($.packageName),entry:$,isSelected:j===p},$.packageName));const I=e.length,l=I>x&&x>0;return f(d,{borderColor:S,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[f(d,{flexShrink:0,gap:1,paddingX:1,children:[i(c,{bold:!0,inverse:!0,children:" VIS OPTIMIZE "}),f(c,{wrap:"truncate",children:[u," ","optimizations",b]}),!s&&C>0&&f(c,{dimColor:!0,children:[" ","—",C," ","selected"]})]}),i(d,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:sr.map(j=>{const $=a===j.key;return f(d,{children:[i(c,{dimColor:!$,children:"["}),i(c,{bold:$,color:$?"cyan":"gray",children:j.shortcut}),i(c,{dimColor:!$,children:"]"}),f(c,{color:$?"white":"gray",children:[" ",j.label]})]},j.key)})}),t&&f(d,{flexShrink:0,paddingX:1,children:[i(c,{bold:!0,color:"white",children:"/ "}),i(c,{children:n}),i(c,{inverse:!0,children:" "})]}),f(d,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[i(d,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:i(d,{flexDirection:"column",marginTop:-m,children:D})}),l&&i(d,{flexShrink:0,marginLeft:1,marginRight:1,children:i(we,{contentHeight:I,placement:"inset",scrollOffset:m,style:"block",viewportHeight:x})})]})]})},"OptimizeListPanel");var dr=Object.defineProperty,pr=T((r,e)=>dr(r,"name",{value:e,configurable:!0}),"S");const fr=100,Q=10,ee={1:"all",2:"native",3:"preferred",4:"micro-utility",5:"socket"},hr=pr(({isDryRun:r,store:e})=>{const{exit:t}=be(),{columns:n,rows:a}=$e(),o=Ie(e.subscribe,e.getSnapshot),s=Re(null),[m,p]=U(0),[u,x]=U(!1),S=e.getFilteredEntries(),g=S[o.selectedIndex]??null,w=n>=fr,y=Math.max(0,a-5),O=Fe(h=>{t(h)},[t]);return Se((h,b)=>{if(u){h==="y"||h==="Y"?O():x(!1);return}if(o.filterActive){b.escape?(e.setFilterActive(!1),e.setFilterText("")):b.return?e.setFilterActive(!1):b.backspace||b.delete?e.setFilterText(o.filterText.slice(0,-1)):h&&!b.ctrl&&!b.meta&&e.setFilterText(o.filterText+h);return}if(h==="q"){!r&&o.checkedEntries.size>0?x(!0):O();return}if(h==="/"){e.setFilterActive(!0);return}if(ee[h]){e.setFilter(ee[h]);return}if(b.tab){e.setFocusedPanel(o.focusedPanel==="list"?"detail":"list");return}if(o.focusedPanel==="list")if(b.upArrow||h==="k"){const C=Math.max(0,o.selectedIndex-1);e.select(C),C<m&&p(C)}else if(b.downArrow||h==="j"){const C=Math.min(S.length-1,o.selectedIndex+1);e.select(C),C>=m+y&&p(C-y+1)}else h===" "?g&&e.toggleCheck(g.packageName):h==="a"?e.toggleAll():b.return&&!r&&o.checkedEntries.size>0&&O(e.getCheckedEntries());else o.focusedPanel==="detail"&&(b.upArrow||h==="k"?s.current?.scrollBy(-1):(b.downArrow||h==="j")&&s.current?.scrollBy(1))},{isActive:o.phase==="browsing"}),a<Q?i(d,{alignItems:"center",justifyContent:"center",children:f(c,{color:"yellow",children:["Terminal too small. Resize to at least",Q," ","rows."]})}):f(d,{flexDirection:"column",height:a,width:n,children:[f(d,{flexDirection:w?"row":"column",flexGrow:1,children:[i(d,{flexBasis:w?"50%":void 0,flexGrow:1,children:i(lr,{checkedEntries:o.checkedEntries,entries:S,filterActive:o.filterActive,filterText:o.filterText,filterType:o.filterType,focused:o.focusedPanel==="list",isDryRun:r,scrollOffset:m,selectedIndex:o.selectedIndex,totalEntries:o.entries.length,viewportHeight:y})}),i(d,{flexBasis:w?"50%":void 0,flexGrow:1,children:i(ir,{entry:g,focused:o.focusedPanel==="detail",scrollRef:s})})]}),i(d,{flexShrink:0,paddingX:1,children:f(c,{dimColor:!0,children:[r?"Preview mode":"space:toggle a:all enter:apply"," ","| tab:switch panel /: filter q:quit |","⚙","=codemod available"]})}),i(Ce,{autoExitSeconds:3,onCancel:T(()=>{x(!1)},"onCancel"),visible:u})]})},"VisOptimizeApp");var mr=Object.defineProperty,P=T((r,e)=>mr(r,"name",{value:e,configurable:!0}),"f");const V=P((r,e)=>{const t=new Set;try{const n=re(r),a=e?[n.dependencies,n.optionalDependencies]:[n.dependencies,n.devDependencies,n.peerDependencies,n.optionalDependencies];for(const o of a)if(o)for(const s of Object.keys(o))t.add(s)}catch{}return t},"collectDepsFromPkgJson"),ie=P(r=>{const e=Oe(r);if(e)return W(r,e);const t=A(r,"package.json");if(!X(t))return[];try{const n=re(t),a=Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages;return a?W(r,a):[]}catch{return[]}},"discoverWorkspacePackages"),ce=P(r=>{const e=[],t=P((n,a)=>{for(const[,o]of Object.entries(n.mappings)){if(!r.has(o.moduleName))continue;const s=[];for(const m of o.replacements){const p=n.replacements[m];p&&s.push(p.description??p.id)}e.push({category:a,hasCodemod:!1,overrideSpec:void 0,packageName:o.moduleName,replacement:s.join(", ")||o.replacements.join(", ")})}},"scanManifest");return t(Pe,"native"),t(Ae,"preferred"),t(Te,"micro-utility"),e},"buildE18eEntries"),se=P((r,e,t,n)=>{const a=ge("npm")??[],o=[];for(const[,s]of a){if(s.deprecated)continue;const m=r.has(s.package),p=e?Ke(e,s.package,t.name):!1;if(!m&&!p)continue;const u=te(s.version)?.major;if(u===void 0)continue;const x=n?`npm:${s.name}@${s.version}`:`npm:${s.name}@^${String(u)}`;o.push({category:"socket",hasCodemod:!1,overrideSpec:x,packageName:s.package,replacement:s.name})}return o},"buildSocketEntries");let G;const ae=P(async()=>{if(G)return G;try{return G=(await import("module-replacements-codemods")).codemods,G}catch{return{}}},"loadCodemods"),le=P(async r=>{try{const e=await ae();for(const t of r)t.category!=="socket"&&e[t.packageName]&&(t.hasCodemod=!0)}catch{}},"markCodemodAvailability"),de=P(async(r,e)=>{let t=0;try{const n=(await ae())[e];if(!n)return{filesChanged:0,packageName:e};const a=n({}),o=await ur(r);for(const s of o){const m=M(s);if(m.includes(e))try{const p=await a.transform({file:{filename:s,source:m}});p!==m&&(ue(s,p,"utf8"),t++)}catch(p){process.stderr.write(`warn: codemod transform failed for ${s}: ${p instanceof Error?p.message:String(p)}
11
+ `)}}}catch{}return{filesChanged:t,packageName:e}},"runCodemod"),ur=P(async r=>ye("**/*.{cjs,cts,js,jsx,mjs,mts,ts,tsx}",{absolute:!0,cwd:r,ignore:["**/.*/**","**/.*","**/node_modules/**","**/dist/**","**/coverage/**","**/.git/**","**/.next/**","**/.nuxt/**"]}),"collectSourceFiles"),gr=P(async({logger:r,options:e,workspaceRoot:t})=>{if(!t)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const n=je(t),a=!!e.dryRun,o=!!e.prod,s=!!e.pin;v(`Detected ${n.name} v${n.version}.`);const m=V(A(t,"package.json"),o),p=ie(t),u=new Set(m);for(const l of p){const j=V(A(ke(t,l),"package.json"),o);for(const $ of j)u.add($)}p.length>0&&v(`Scanned ${String(p.length)} workspace package${p.length===1?"":"s"}.`),v(`Scanning dependencies...
12
+ `);const x=Ue(t,n.name),S=ce(u),g=se(u,x,n,s),w=new Set(S.map(l=>l.packageName)),y=g.filter(l=>!w.has(l.packageName)),O=[...S,...y];if(await le(O),O.length===0){v("No optimizations found for your dependencies.");return}const h=!!process.stdout.isTTY&&!Ee,b=e.format==="json"||!!e.json;if(h&&!a&&!b){const l=new er(O),j=await xe(De.createElement(hr,{isDryRun:!1,store:l}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),$=Array.isArray(j)?j:[];if($.length===0){v("No optimizations selected.");return}const z=$.filter(k=>k.category!=="socket"&&k.hasCodemod),L=$.filter(k=>k.category!=="socket"&&!k.hasCodemod),B=$.filter(k=>k.category==="socket");if(z.length>0){v(`
13
+ Running ${String(z.length)} codemod${z.length===1?"":"s"}...
14
+ `);for(const k of z){const E=await de(t,k.packageName);E.filesChanged>0?q(` ${k.packageName}: ${String(E.filesChanged)} file${E.filesChanged===1?"":"s"} updated`):v(` ${k.packageName}: no files changed`)}}if(L.length>0){Y(`
15
+ ${String(L.length)} selected replacement${L.length===1?"":"s"} require manual migration (no codemod available):`);for(const k of L)v(` ${k.packageName} → ${k.replacement}`);H(" Replace usage in your source code, then remove from dependencies.")}if(B.length>0){const k=B.filter(J=>J.overrideSpec).map(J=>({original:J.packageName,spec:J.overrideSpec})),E=He(t,A(t,"package.json"),k,n);E.added.length>0&&q(`
16
+ Added ${String(E.added.length)} override${E.added.length===1?"":"s"}.`),E.updated.length>0&&q(`Updated ${String(E.updated.length)} override${E.updated.length===1?"":"s"}.`)}if(B.length>0&&!e.noInstall){v(`
17
+ Running ${n.name} install to update lockfile...`);const k=Ne(n,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},t,r);k!==0&&Y(`${n.name} install exited with code ${String(k)}. Run it manually.`)}v(""),q("Optimization complete.");return}if(b){process.stdout.write(`${JSON.stringify({e18e:S.map(l=>({category:l.category,hasCodemod:l.hasCodemod,packageName:l.packageName,replacement:l.replacement})),packageManager:n.name,socket:y.map(l=>({overrideSpec:l.overrideSpec,packageName:l.packageName,replacement:l.replacement})),total:O.length,workspaces:p.length},void 0,2)}
18
+ `);return}const C=S.filter(l=>l.category==="native"),D=S.filter(l=>l.category==="preferred"),I=S.filter(l=>l.category==="micro-utility");if(C.length>0){v(`Native replacements (${String(C.length)}):`);for(const l of C)v(` ${l.hasCodemod?"⚙":" "} ${l.packageName} → ${l.replacement}`)}if(D.length>0){v(`
19
+ Preferred alternatives (${String(D.length)}):`);for(const l of D)v(` ${l.hasCodemod?"⚙":" "} ${l.packageName} → ${l.replacement}`)}if(I.length>0){v(`
20
+ Micro-utilities (${String(I.length)}):`);for(const l of I)v(` ${l.hasCodemod?"⚙":" "} ${l.packageName} → ${l.replacement}`)}if(y.length>0){v(`
21
+ Socket.dev overrides (${String(y.length)}):`);for(const l of y)v(` ${l.packageName} → ${l.overrideSpec}`)}v(`
22
+ Total: ${String(O.length)} optimizations available (⚙ = codemod available).`),a&&H("Run without --dry-run for interactive selection.")},"execute"),Pr=Object.defineProperty({__proto__:null,buildE18eEntries:ce,buildSocketEntries:se,collectDepsFromPkgJson:V,default:gr,discoverWorkspacePackages:ie,markCodemodAvailability:le,runCodemod:de},Symbol.toStringTag,{value:"Module"});export{Ue as A,ie as B,He as F,ce as I,se as J,de as L,le as _,Pr as h,V as x};
@@ -0,0 +1 @@
1
+ var u=Object.defineProperty;var c=(e,a)=>u(e,"name",{value:a,configurable:!0});import{a as g,a7 as p}from"../packem_shared/bin-BaZZ32BK.js";var f=Object.defineProperty,b=c((e,a)=>f(e,"name",{value:a,configurable:!0}),"n");const h=b(async({argument:e,logger:a,visConfig:r,workspaceRoot:i})=>{const o=e;if(!o||o.length===0)throw new Error("No subcommand specified. Available: cache, publish, audit, list, view, config, whoami, login, logout, pack, owner, dist-tag, search, fund, ping, token, deprecate, rebuild, prune");const[s,...l]=o,n=i??process.cwd(),d=g(n,{configBackend:r?.install?.backend}),t=p(d,s,l,n,a);t!==0&&(process.exitCode=t)},"execute");export{h as default};
@@ -0,0 +1 @@
1
+ var f=Object.defineProperty;var t=(e,a)=>f(e,"name",{value:a,configurable:!0});import{a as p,a8 as g}from"../packem_shared/bin-BaZZ32BK.js";import{o as v}from"../packem_shared/utils-DrNg0XTR.js";var d=Object.defineProperty,k=t((e,a)=>d(e,"name",{value:a,configurable:!0}),"t");const b=k(async({argument:e,logger:a,options:o,visConfig:i,workspaceRoot:l})=>{const s=e;if(!s||s.length===0)throw new Error("No packages specified. Usage: vis remove <packages...>");const r=process.cwd(),n=p(l??r,{configBackend:i?.install?.backend}),c=g(n,{filter:v(o.filter),global:o.global||!1,packages:s,recursive:o.recursive||!1,saveDev:o.saveDev||!1,workspaceRoot:o.workspaceRoot||!1},r,a);c!==0&&(process.exitCode=c)},"execute");export{b as default};
@@ -0,0 +1,37 @@
1
+ var At=Object.defineProperty;var O=(o,e)=>At(o,"name",{value:e,configurable:!0});import{createRequire as Lt}from"node:module";import{runConcurrently as Le,TerminalBuffer as mt,readLastRunSummary as Bt,enforceProjectConstraints as Nt,parsePartition as Ht,TaskScheduler as Gt,createTaskGraph as qt,generateRunSummary as Qe,writeChromeTrace as Ut,CompositeLifeCycle as Xe,defaultTaskRunner as Ke,createLogReporter as _t,writeRunSummary as Wt}from"@visulima/task-runner";import{C as Vt,a9 as gt,aa as zt,Z as Yt,e as Qt,ab as Xt,ac as Kt,ad as Jt,s as Je,ae as Zt}from"../packem_shared/bin-BaZZ32BK.js";import{d as er,a as tr}from"../packem_shared/cache-directory-DL8hfXeG.js";import{f as rr,l as or,c as ir,a as nr,b as sr}from"../packem_shared/flakiness-DSIHZGBT.js";import{createHooks as lr}from"hookable";import{r as cr,f as ar}from"../packem_shared/selectors-CfH9ZY08.js";import{basename as ur,join as Ne,dirname as hr,resolve as wt,relative as fr}from"@visulima/path";import{r as mr}from"../packem_shared/toolchain-C3ZG0o_X.js";import{Box as u,Text as r,StaticRender as Ze,renderToString as K,ScrollView as kt,Spinner as gr,useApp as wr,useWindowSize as kr,useInput as et,Dialog as vr,render as br}from"@visulima/tui";import F,{useSyncExternalStore as yr,useState as tt,useRef as ye,useCallback as je,useEffect as Oe,useMemo as rt}from"react";import{jsxs as l,jsx as i}from"react/jsx-runtime";import{T as vt,C as He,D as Ie,E as bt}from"../packem_shared/symbols-CIMw60-G.js";import{duration as yt}from"@visulima/humanizer";const Dt=Lt(import.meta.url),be=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,xe=O(o=>{if(typeof be<"u"&&be.versions&&be.versions.node){const[e,t]=be.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return be.getBuiltinModule(o)}return Dt(o)},"__cjs_getBuiltinModule"),{appendFile:De}=xe("node:fs/promises"),{platform:dr,homedir:Be}=xe("node:os"),{createInterface:pr}=xe("node:readline"),{watch:Tr}=xe("node:fs");var Cr=Object.defineProperty,Re=O((o,e)=>Cr(o,"name",{value:e,configurable:!0}),"t$1");const Sr=Re(()=>lr(),"createVisHooks"),$r=Re(async(o,e)=>{if(!(!e||e.length===0))for(const t of e){if(t.hooks)for(const[s,n]of Object.entries(t.hooks)){const d=Array.isArray(n)?n:[n];for(const a of d)o.hook(s,a)}t.setup&&await t.setup(o)}},"registerPlugins");class xr{static{O(this,"HookableLifeCycle")}static{Re(this,"HookableLifeCycle")}#e;#r;#o=new Map;constructor(e,t){this.#e=e,this.#r=t}startTasks(e){for(const t of e)this.#o.set(t.id,t),this.#i("task:before",t)}endTasks(e){for(const t of e)this.#o.delete(t.task.id),this.#i("task:after",t.task,t),t.status==="failure"?this.#i("task:failure",t.task,t):Ir(t.status)&&this.#i("task:cacheHit",t.task,t)}printCacheMiss(e,t){this.#i("task:cacheMiss",e,t)}onTaskStdout(e,t){this.#i("task:stdout",e,t)}onTaskStderr(e,t){this.#i("task:stderr",e,t)}#i(e,...t){Promise.resolve(this.#e.callHook(e,...t)).catch(s=>{if(this.#r)try{this.#r(e,s)}catch{}})}}const Ir=Re(o=>o==="local-cache"||o==="local-cache-kept-existing"||o==="remote-cache","isCacheStatus");var Rr=Object.defineProperty,Ee=O((o,e)=>Rr(o,"name",{value:e,configurable:!0}),"o");const Er=Ee(async o=>{if(process.env.VIS_NO_SHELL_HISTORY||dr()==="win32")return;const e=process.env.SHELL;if(!e)return;const t=ur(e);try{if(t==="zsh"){await Mr(o);return}if(t==="bash"){await jr(o);return}t==="fish"&&await Or(o)}catch{}},"appendToShellHistory"),Mr=Ee(async o=>{const e=process.env.HISTFILE??Ne(process.env.ZDOTDIR??Be(),".zsh_history"),t=`: ${Math.floor(Date.now()/1e3)}:0;${o}
2
+ `;await De(e,t)},"writeZshHistory"),jr=Ee(async o=>{const e=process.env.HISTFILE??Ne(Be(),".bash_history");await De(e,`${o}
3
+ `)},"writeBashHistory"),Or=Ee(async o=>{const e=Ne(Be(),".local","share","fish","fish_history"),t=`- cmd: ${o.replaceAll("\\","\\\\").replaceAll(`
4
+ `,String.raw`\n`)}
5
+ when: ${Math.floor(Date.now()/1e3)}
6
+ `;await De(e,t)},"writeFishHistory");var Fr=Object.defineProperty,ue=O((o,e)=>Fr(o,"name",{value:e,configurable:!0}),"i$1");const ot=ue(o=>{const e=new Set;for(const t of Object.values(o.projects))for(const s of Object.keys(t.targets??{}))e.add(s);return[...e].sort()},"collectAvailableTargets"),Pr=ue(o=>{const e=new Map;for(const t of o.values())for(const[s,n]of Object.entries(t))for(const d of n.aliases??[])e.has(d)||e.set(d,s);return e},"buildAliasMap"),Ar=ue((o,e)=>e.get(o)??o,"resolveTargetAlias"),Lr=ue((o,e)=>{if(o.length===0)return e.length;if(e.length===0)return o.length;const t=[];for(let s=0;s<=e.length;s++)t[s]=[s];for(let s=0;s<=o.length;s++)t[0][s]=s;for(let s=1;s<=e.length;s++)for(let n=1;n<=o.length;n++){const d=e[s-1]===o[n-1]?0:1;t[s][n]=Math.min(t[s-1][n]+1,t[s][n-1]+1,t[s-1][n-1]+d)}return t[e.length][o.length]},"levenshtein"),Dr=ue((o,e,t=3)=>Tt(o,e,1,t)[0],"suggestTarget"),Tt=ue((o,e,t=3,s=3)=>{const n=[];for(const d of e){const a=Lr(o.toLowerCase(),d.toLowerCase());a<=s&&n.push({distance:a,name:d})}return n.sort((d,a)=>d.distance-a.distance||d.name.localeCompare(a.name)),n.slice(0,t).map(d=>d.name)},"suggestTargets"),Br=ue(o=>o.length===0?" (no targets found)":o.map(e=>` - ${e}`).join(`
7
+ `),"formatTargetList"),Nr=ue(async o=>{if(o.length===0||!process.stdin.isTTY||!process.stdout.isTTY)return;const e=pr({input:process.stdin,output:process.stdout});try{process.stdout.write(`Available targets:
8
+ `);for(const[n,d]of o.entries())process.stdout.write(` ${String(n+1).padStart(2," ")}. ${d}
9
+ `);process.stdout.write(`
10
+ `);const t=(await new Promise(n=>{e.question("Select a target (number or name, blank to cancel): ",n)})).trim();if(t.length===0)return;const s=Number.parseInt(t,10);return Number.isFinite(s)&&s>=1&&s<=o.length?o[s-1]:o.includes(t)?t:Dr(t,o)}finally{e.close()}},"promptTargetInteractively");var Hr=Object.defineProperty,Ge=O((o,e)=>Hr(o,"name",{value:e,configurable:!0}),"i");const Gr=Ge(o=>Array.isArray(o)?`[${o.join(",")}]`:typeof o=="object"&&o!==null?JSON.stringify(o):String(o),"formatValue"),qr=Ge((o,e,t)=>e==="_"?`${o}${Array.isArray(t)?t.join(" "):String(t)}`:`${o}--${e}=${Gr(t)}`,"formatFlags"),qe=Ge((o,e,t)=>{const s=new Set(new Set(t.map(k=>k.target.target))),n=new Set(new Set(t.map(k=>k.target.project))),d=e.filter(k=>s.has(k)),a=o.filter(k=>n.has(k)),f=t.length-a.length*d.length,p=d.length===1?"target":"targets",g=d.join(", ");let c;c=a.length===1?`project ${a[0]}`:`${a.length} projects`;let M=`${p} ${g} for ${c}`;return f>0&&(M+=` and ${f} ${f===1?"task":"tasks"} ${f===1?"it depends":"they depend"} on`),M},"formatTargetsAndProjects");var Ur=Object.defineProperty,_r=O((o,e)=>Ur(o,"name",{value:e,configurable:!0}),"c$2");const Wr={error:"red",info:"white",success:"green"},Pe=_r(({children:o,title:e,variant:t})=>{const s=Wr[t];return l(u,{flexDirection:"column",children:[l(u,{gap:1,children:[i(r,{bold:!0,inverse:!0,children:" VIS "}),i(r,{bold:!0,color:s,children:"•"}),i(r,{children:e})]}),o]})},"Header");var Vr=Object.defineProperty,zr=O((o,e)=>Vr(o,"name",{value:e,configurable:!0}),"s$1");const Ct=zr(({cached:o,failed:e,failedIds:t,projectNames:s,skippedIds:n,succeeded:d,targets:a,tasks:f,took:p})=>{const g=qe(s,a,f);if(e===0&&(!n||n.length===0)){const c=o>0?` (${o} read from cache)`:"";return i(Ze,{children:O(()=>i(Pe,{title:`Successfully ran ${g}`,variant:"success",children:l(u,{flexDirection:"column",paddingLeft:2,children:[l(r,{children:[i(r,{color:"green",children:vt})," ",d+o," ","tasks completed",c?i(r,{dimColor:!0,children:c}):null]}),l(r,{dimColor:!0,children:[" ","Took",p]})]})}),"children")})}return i(Ze,{children:O(()=>i(Pe,{title:`Ran ${g}`,variant:"error",children:l(u,{flexDirection:"column",paddingLeft:2,children:[n&&n.length>0&&l(u,{flexDirection:"column",children:[l(r,{dimColor:!0,children:[n.length," ","task",n.length===1?"":"s"," ","skipped (dependency failed or --bail)"]}),n.map(c=>l(r,{dimColor:!0,children:[" - ",c]},c)),i(r,{})]}),e>0&&l(u,{flexDirection:"column",children:[l(r,{children:[i(r,{color:"red",children:String(e)})," ","task",e===1?"":"s"," ","failed:"]}),t.map(c=>l(r,{children:[" ",i(r,{color:"red",children:He})," ",c]},c)),i(r,{})]}),l(r,{dimColor:!0,children:[" ","Took",p]})]})}),"children")})},"CommandSummary");var Yr=Object.defineProperty,Fe=O((o,e)=>Yr(o,"name",{value:e,configurable:!0}),"u$1");class $e{static{O(this,"TaskStore")}static{Fe(this,"TaskStore")}#e;#r=new Set;#o=new Map;constructor(e){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,retryTaskId:null,rows:e.map(t=>({status:"pending",taskId:t.id})),selectedIndex:0,startTime:Date.now(),statusFilter:"all",succeeded:0,viewMode:"list"}}getSnapshot=Fe(()=>this.#e,"getSnapshot");subscribe=Fe(e=>(this.#r.add(e),()=>{this.#r.delete(e)}),"subscribe");startTasks(e){const t=[...this.#e.rows];for(const s of e){const n=t.findIndex(d=>d.taskId===s.id);n!==-1&&(t[n]={...t[n],elapsed:0,status:"running"},this.#o.set(s.id,process.hrtime()))}this.#t({...this.#e,rows:t})}endTasks(e){const t=[...this.#e.rows];let{cached:s,completed:n,failed:d,succeeded:a}=this.#e;const f=new Map(this.#e.outputs);for(const g of e){const c=t.findIndex(M=>M.taskId===g.task.id);switch(c!==-1&&(t[c]={...t[c],duration:g.startTime&&g.endTime?g.endTime-g.startTime:void 0,status:g.status}),n++,g.status){case"failure":{d++;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{s++;break}case"success":{a++;break}}g.terminalOutput&&!f.has(g.task.id)&&f.set(g.task.id,g.terminalOutput),this.#o.delete(g.task.id)}let{selectedIndex:p}=this.#e;if(d>this.#e.failed){const g=t.findIndex(c=>c.status==="failure");g!==-1&&(p=g)}this.#t({...this.#e,cached:s,completed:n,failed:d,outputs:f,rows:t,selectedIndex:p,succeeded:a})}static#i=256*1024;addOutput(e,t){if(!t.trim())return;let s=(this.#e.outputs.get(e)??"")+t;s.length>$e.#i&&(s=s.slice(-$e.#i)),this.#e.outputs.set(e,s),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()})}tick(){if(this.#o.size===0)return;let e=!1;const t=[...this.#e.rows];for(let s=0;s<t.length;s++){const n=t[s];if(n.status==="running"){const d=this.#o.get(n.taskId);if(d){const a=process.hrtime(d),f=a[0]*1e3+a[1]/1e6;t[s]={...n,elapsed:f},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 s=[...this.#e.pinnedTaskIds];s[e]=t,this.#t({...this.#e,pinnedTaskIds:s})}clearPins(){this.#t({...this.#e,pinnedTaskIds:[null,null]})}requestRetry(e){const t=[...this.#e.rows],s=t.findIndex(f=>f.taskId===e);let{completed:n,failed:d,succeeded:a}=this.#e;if(s!==-1){const f=t[s].status;f==="failure"?(d=Math.max(0,d-1),n=Math.max(0,n-1)):f==="success"&&(a=Math.max(0,a-1),n=Math.max(0,n-1)),t[s]={...t[s],elapsed:0,status:"running"},this.#o.set(e,process.hrtime())}this.#t({...this.#e,completed:n,done:!1,endTime:null,failed:d,interactiveMode:!1,retryTaskId:e,rows:t,succeeded:a})}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.#o.clear(),this.#t({...this.#e,autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,interactiveMode:!1,outputs:new Map,rerunRequested:!0,rows:this.#e.rows.map(e=>({status:"pending",taskId:e.taskId})),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{}}}var Qr=Object.defineProperty,oe=O((o,e)=>Qr(o,"name",{value:e,configurable:!0}),"t");const Xr={d:oe(()=>" d","d"),future:"in %s",h:oe(()=>" h","h"),m:oe(()=>" m","m"),mo:oe(()=>" mo","mo"),ms:oe(()=>" ms","ms"),past:"%s ago",s:oe(()=>" s","s"),w:oe(()=>" w","w"),y:oe(()=>" y","y")},St={delimiter:" ",language:Xr,largest:2,round:!0,spacer:"",units:["h","m","s","ms"]};oe(o=>{const e=o[0]*1e3+o[1]/1e6;return yt(e,St)},"formatHrtime");const me=oe(o=>yt(o,St),"formatMs");var Kr=Object.defineProperty,Ce=O((o,e)=>Kr(o,"name",{value:e,configurable:!0}),"n$1");const Te=Ce(o=>o==="local-cache"||o==="local-cache-kept-existing"||o==="remote-cache","isCacheStatus"),Se=Ce(o=>{switch(o){case"failure":return{color:"red",icon:He};case"local-cache":case"local-cache-kept-existing":case"remote-cache":case"success":return{color:"green",icon:vt};case"skipped":return{color:"gray",icon:Ie};default:return{color:"gray",icon:"?"}}},"getStatusInfo"),$t=Ce(o=>{const{color:e,icon:t}=Se(o);return K(F.createElement(r,{color:e},t),{columns:10}).trim()},"getStatusIcon"),Jr=Ce(o=>{const{color:e,icon:t}=Se(o);switch(o){case"local-cache":case"local-cache-kept-existing":case"remote-cache":return K(F.createElement(r,null,F.createElement(r,{color:e},t)," ",F.createElement(r,{color:"cyan"},"[cache]")),{columns:30}).trim();case"skipped":return K(F.createElement(r,null,F.createElement(r,{dimColor:!0},t)," ",F.createElement(r,{dimColor:!0},"[skipped]")),{columns:30}).trim();default:return K(F.createElement(r,{color:e},t),{columns:10}).trim()}},"getStatusPrefix"),Zr=Ce((o,e,t)=>{const s=t.trim();if(!s)return;const n=`
11
+ `;if(process.env.GITHUB_ACTIONS==="true")process.stdout.write(`::group::${$t(e)} ${o}${n}`),process.stdout.write(s+n),process.stdout.write(`::endgroup::${n}`);else{const d=process.stdout.columns||80,a=K(F.createElement(r,{dimColor:!0},Ie.repeat(d)),{columns:d}).trim(),f=Jr(e),p=K(F.createElement(r,{bold:!0},o),{columns:d}).trim();process.stdout.write(`${a}${n}`),process.stdout.write(`${f} ${p}${n}`),process.stdout.write(s+n),process.stdout.write(`${a}${n}`)}},"logCommandOutputCI");var eo=Object.defineProperty,xt=O((o,e)=>eo(o,"name",{value:e,configurable:!0}),"c$1");const to=xt(o=>o==="running"?{color:"white",icon:"•"}:o==="pending"?{color:"gray",icon:"·"}:Se(o),"getDisplayInfo"),it=xt(({duration:o,focused:e,interactiveMode:t,output:s,scrollRef:n,showFullscreenHint:d,status:a,taskId:f})=>{const p=a??"pending",{icon:g}=to(p),c=e?"bold":"single",M=p==="failure"?"red":p==="success"||Te(p)?e?"green":"gray":p==="running"?e?"white":"cyan":e?"white":"gray",k=f?`${g} ${f}`:void 0,P=o===void 0?void 0:me(o),y=f?t?"Esc cancel | Enter send":e&&p==="running"&&d?"⏎ FULLSCREEN i INPUT":e&&p==="running"?"i INPUT":e&&d?"<enter> full screen":e?void 0:"<tab> or <enter> to focus":void 0;if(!f)return l(u,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",paddingX:2,paddingY:1,children:[i(r,{dimColor:!0,children:"Select a task to view output"}),i(r,{dimColor:!0,children:"Press Enter or 1/2 to pin"})]});const S=s?s.split(`
12
+ `).map(v=>v.replace(/\r$/,"")):[];return!s&&(p==="running"||p==="pending")?i(u,{borderBottomTitle:y,borderColor:M,borderStyle:c,borderTopRightTitle:P,borderTopTitle:k,flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:i(u,{alignItems:"center",flexGrow:1,justifyContent:"center",children:i(r,{dimColor:!0,children:"Waiting for task output..."})})}):l(u,{borderBottomTitle:y,borderColor:t?"yellow":M,borderStyle:c,borderTopRightTitle:P,borderTopTitle:k,flexDirection:"column",flexGrow:1,children:[i(u,{flexGrow:1,flexShrink:1,paddingY:1,children:i(kt,{flexGrow:1,followOutput:!0,paddingX:2,ref:n,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:S.map((v,x)=>i(r,{children:v},String(x)))})}),t&&i(u,{flexShrink:0,justifyContent:"center",paddingX:1,children:i(r,{bold:!0,color:"yellow",children:"INTERACTIVE — keystrokes forwarded to task — Esc to exit"})})]})},"OutputPanel");var ro=Object.defineProperty,Me=O((o,e)=>ro(o,"name",{value:e,configurable:!0}),"u");const It=6,Rt=8,Et=10,oo=Me(o=>o==="running"||o==="pending"?bt:o==="local-cache"||o==="local-cache-kept-existing"?"Local":o==="remote-cache"?"Remote":Ie,"getCacheLabel"),nt=Me((o,e)=>e[0]===o?"[1]":e[1]===o?"[2]":"","getPinLabel"),st=Me(({compact:o,isSelected:e,pinLabel:t,row:s})=>{const{status:n,taskId:d}=s,a=e?">":" ";let f;if(n==="running")f=l(r,{bold:!0,color:"white",children:[" ",i(gr,{type:"dots"})," "]});else if(n==="pending")f=i(r,{bold:!0,color:"gray",children:" · "});else{const{color:g,icon:c}=Se(n);f=l(r,{bold:!0,color:g,children:[" ",c," "]})}let p=bt;return n!=="running"&&n!=="pending"?p=s.duration===void 0?Ie:me(s.duration):n==="running"&&s.elapsed!==void 0&&(p=me(s.elapsed)),l(u,{children:[i(r,{children:a}),i(u,{width:It,children:f}),l(u,{flexGrow:1,children:[i(r,{bold:e,inverse:e,children:d}),t?i(r,{dimColor:!0,children:` ${t}`}):null]}),!o&&i(u,{justifyContent:"flex-end",width:Rt,children:i(r,{dimColor:!Te(n),children:oo(n)})}),!o&&i(u,{justifyContent:"flex-end",width:Et,children:i(r,{dimColor:n==="pending",children:p})})]})},"TaskListRow"),lt=Me(({compact:o,filterActive:e,filterText:t,focused:s,headerStatus:n,parallelSlots:d=3,pinnedTaskIds:a,rows:f,scrollRef:p,selectedIndex:g,title:c})=>{const M=n==="error"?"red":n==="success"?"green":s?"white":"gray",k=f[g]?.taskId,P=f.filter(v=>v.status==="running"),y=P.length>0||f.some(v=>v.status==="pending"),S=[];if(y)for(let v=0;v<d;v++){const x=P[v];x?S.push(i(st,{compact:o,isSelected:x.taskId===k,pinLabel:nt(x.taskId,a),row:x},`par-${x.taskId}`)):S.push(l(u,{children:[i(r,{children:" "}),i(u,{width:It,children:i(r,{bold:!0,color:"gray",children:" · "})}),i(r,{dimColor:!0,children:"Waiting for task..."})]},`par-empty-${String(v)}`))}return l(u,{borderColor:M,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[l(u,{flexShrink:0,gap:1,paddingX:1,children:[i(r,{bold:!0,inverse:!0,children:" VIS "}),i(r,{children:c}),!o&&l(u,{flexGrow:1,gap:0,justifyContent:"flex-end",children:[i(u,{justifyContent:"flex-end",width:Rt,children:i(r,{dimColor:!0,children:"Cache"})}),i(u,{justifyContent:"flex-end",width:Et,children:i(r,{dimColor:!0,children:"Duration"})})]})]}),i(kt,{flexGrow:1,flexShrink:1,paddingLeft:1,paddingY:1,ref:p,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:f.map(v=>i(st,{compact:o,isSelected:v.taskId===k,pinLabel:nt(v.taskId,a),row:v},v.taskId))}),y&&i(u,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexDirection:"column",flexShrink:0,paddingLeft:1,paddingY:1,children:S}),e&&l(u,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexShrink:0,paddingX:1,children:[i(r,{bold:!0,color:"white",children:"/ "}),i(r,{children:t}),i(r,{inverse:!0,children:" "})]})]})},"TaskListPanel");var io=Object.defineProperty,no=O((o,e)=>io(o,"name",{value:e,configurable:!0}),"y");const ct=40,at=10,dt=100,so=no(({autoExitSeconds:o,parallelSlots:e,projectNames:t,stdinRegistry:s,store:n,targets:d,tasks:a})=>{const{exit:f}=wr(),{columns:p,rows:g}=kr(),c=yr(n.subscribe,n.getSnapshot),[M,k]=tt(!1),P=ye(null),y=ye(null),S=ye(null),[v,x]=tt(!1),N=ye({list:0,splitList:0,splitOutput:0}),R=je(()=>{c.viewMode==="list"?N.current.list=y.current?.getScrollOffset()??0:c.viewMode==="split"&&(N.current.splitList=y.current?.getScrollOffset()??0,N.current.splitOutput=S.current?.getScrollOffset()??0)},[c.viewMode]),Z=je(m=>{setTimeout(()=>{if(m==="list"){const h=N.current.list;y.current?.scrollTo(h)}else if(m==="split"){const h=N.current.splitList;h>0?y.current?.scrollTo(h):y.current?.scrollTo(Math.max(0,n.getSnapshot().selectedIndex-2)),S.current?.scrollTo(N.current.splitOutput)}},0)},[n]),U=ye(!1);Oe(()=>{c.done&&!U.current&&(U.current=!0,o>0&&x(!0)),!c.done&&U.current&&(U.current=!1,x(!1))},[c.done,o]);const B=rt(()=>{let m=c.rows;if(c.statusFilter!=="all"&&(m=m.filter(h=>c.statusFilter==="failed"?h.status==="failure":c.statusFilter==="running"?h.status==="running"||h.status==="pending":c.statusFilter==="passed"?h.status==="success"||Te(h.status):!0)),c.filterText){const h=c.filterText.toLowerCase();m=m.filter(b=>b.taskId.toLowerCase().includes(h))}return m},[c.rows,c.filterText,c.statusFilter]),ie=rt(()=>c.rows.filter(m=>m.status==="running").length,[c.rows]),H=(B[c.selectedIndex]??null)?.taskId??null,$=c.pinnedTaskIds[0]??H,j=$?c.rows.find(m=>m.taskId===$):null,Y=$?c.outputs.get($)??"":"",D=qe(t,d,a),_=c.done?`Completed ${D} (${me((c.endTime??Date.now())-c.startTime)})`:`Running ${D}...`,he=c.done?c.failed>0?"error":"success":"running",ee=je(m=>{y.current?.scrollTo(Math.max(0,m-2))},[]);if(Oe(()=>{c.interactiveMode&&j?.status!=="running"&&n.setInteractiveMode(!1)},[c.interactiveMode,j?.status,n]),Oe(()=>{if(!$)return;let m=p;c.viewMode==="split"&&p>=dt?m=p-Math.floor(p*.4)-2:(c.viewMode==="split"||c.viewMode==="fullscreen")&&(m=p-2);const h=Math.max(1,g-4);s.get($)?.resize?.(m,h)},[p,g,c.viewMode,$]),et((m,h)=>{if(h.escape){n.setInteractiveMode(!1);return}if(!$)return;const b=s.get($);if(!b){n.setInteractiveMode(!1);return}if(h.return)b.write("\r");else if(h.upArrow)b.write("\x1B[A");else if(h.downArrow)b.write("\x1B[B");else if(h.rightArrow)b.write("\x1B[C");else if(h.leftArrow)b.write("\x1B[D");else if(h.backspace)b.write("");else if(h.delete)b.write("\x1B[3~");else if(h.tab)b.write(" ");else if(h.home)b.write("\x1B[H");else if(h.end)b.write("\x1B[F");else if(h.pageUp)b.write("\x1B[5~");else if(h.pageDown)b.write("\x1B[6~");else if(h.ctrl&&m){const Q=m.toUpperCase().codePointAt(0);Q!==void 0&&Q>=65&&Q<=90&&b.write(String.fromCodePoint(Q-64))}else m&&b.write(m)},{isActive:c.interactiveMode}),et((m,h)=>{if(m==="c"&&h.ctrl){f();return}if(!v){if(M){h.escape||m==="?"?k(!1):m==="q"?(k(!1),x(!0)):h.downArrow||m==="j"?P.current?.scrollBy(1):h.upArrow||m==="k"?P.current?.scrollBy(-1):h.pageDown?P.current?.scrollBy(5):h.pageUp?P.current?.scrollBy(-5):h.home?P.current?.scrollToTop():h.end&&P.current?.scrollToBottom();return}if(m==="?"){k(!0);return}if(m==="q"){x(!0);return}if(m==="r"&&c.done){n.requestRerun();return}if(m==="R"&&c.done){const b=B[c.selectedIndex];b?.status==="failure"&&n.requestRetry(b.taskId);return}if(m==="F"&&!c.filterActive){const b=["all","failed","running","passed"],Q=b.indexOf(c.statusFilter);n.setStatusFilter(b[(Q+1)%b.length]);return}if(c.filterActive){if(h.escape){n.setFilterActive(!1);return}if(h.return){n.setFilterActive(!1);return}if(h.backspace){n.setFilter(c.filterText.slice(0,-1));return}if(m&&!h.ctrl&&!h.meta){n.setFilter(c.filterText+m);return}return}if(m==="i"&&j?.status==="running"&&(c.viewMode==="fullscreen"||c.viewMode==="split"&&c.focusedPanel==="output")){n.setInteractiveMode(!0);return}if(c.viewMode==="fullscreen"){if(h.escape){n.setViewMode("split"),Z("split");return}if(h.downArrow||m==="j"){S.current?.scrollBy(1);return}if(h.upArrow||m==="k"){S.current?.scrollBy(-1);return}if(h.pageDown||h.ctrl&&m==="d"){S.current?.scrollBy(12);return}if(h.pageUp||h.ctrl&&m==="u"){S.current?.scrollBy(-12);return}if(h.home){S.current?.scrollToTop();return}if(h.end){S.current?.scrollToBottom();return}return}if(c.viewMode==="split"){if(h.tab){const b=c.focusedPanel==="tasks"?"output":"tasks";n.setFocusedPanel(b);return}if(c.focusedPanel==="output"){if(h.escape){n.setFocusedPanel("tasks");return}if(h.return){R(),n.setViewMode("fullscreen");return}if(h.downArrow||m==="j"){S.current?.scrollBy(1);return}if(h.upArrow||m==="k"){S.current?.scrollBy(-1);return}if(h.pageDown||h.ctrl&&m==="d"){S.current?.scrollBy(12);return}if(h.pageUp||h.ctrl&&m==="u"){S.current?.scrollBy(-12);return}if(h.home){S.current?.scrollToTop();return}if(h.end){S.current?.scrollToBottom();return}return}if(h.escape){n.setViewMode("list"),Z("list");return}if(h.return){n.setFocusedPanel("output");return}}if(c.viewMode==="list"||c.viewMode==="split"&&c.focusedPanel==="tasks"){if(h.downArrow||m==="j"){const b=Math.min(c.selectedIndex+1,Math.max(0,B.length-1));n.setSelectedIndex(b),ee(b);return}if(h.upArrow||m==="k"){const b=Math.max(c.selectedIndex-1,0);n.setSelectedIndex(b),ee(b);return}if(h.return&&c.viewMode==="list"){R(),N.current.splitList=0,N.current.splitOutput=0,n.setViewMode("split"),n.setFocusedPanel("output"),Z("split");return}if(m==="/"){n.setFilterActive(!0);return}if(m==="1"&&H){n.pinTask(0,H);return}if(m==="2"&&H){n.pinTask(1,H);return}if(m==="0"){n.clearPins();return}h.escape&&c.filterText&&n.setFilter("")}}},{isActive:!c.interactiveMode}),p<ct||g<at)return i(u,{alignItems:"center",height:g,justifyContent:"center",width:p,children:l(r,{color:"yellow",children:["Terminal too small (",p,"x",g,"). Minimum:"," ",ct,"x",at]})});const A=l(u,{gap:1,children:[c.succeeded>0&&l(r,{bold:!0,color:"green",children:["✓"," ",c.succeeded]}),c.failed>0&&l(r,{bold:!0,color:"red",children:["✗"," ",c.failed]}),ie>0&&l(r,{color:"cyan",children:["◷"," ",ie]}),l(r,{dimColor:!0,children:[c.rows.length," ","total"]}),c.statusFilter!=="all"&&l(r,{color:"yellow",children:["[",c.statusFilter,"]"]})]});let W;if(c.viewMode==="fullscreen")W=[l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"Esc"}),i(r,{dimColor:!0,children:"BACK"})]},"esc"),l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"↑↓"}),i(r,{dimColor:!0,children:"SCROLL"})]},"scroll"),l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"^u ^d"}),i(r,{dimColor:!0,children:"PAGE"})]},"page"),...j?.status==="running"?[l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"i"}),i(r,{dimColor:!0,children:"INPUT"})]},"i")]:[],l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"q"}),i(r,{dimColor:!0,children:"QUIT"})]},"q")];else if(c.done){const m=B[c.selectedIndex]?.status==="failure";W=[l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"q"}),i(r,{dimColor:!0,children:"QUIT"})]},"q"),l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"r"}),i(r,{dimColor:!0,children:"RERUN"})]},"r"),...m?[l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"R"}),i(r,{dimColor:!0,children:"RETRY"})]},"R")]:[],l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"?"}),i(r,{dimColor:!0,children:"HELP"})]},"?"),l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"↑↓"}),i(r,{dimColor:!0,children:"NAV"})]},"nav"),l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"F"}),i(r,{dimColor:!0,children:"FILTER"})]},"F"),l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"⏎"}),i(r,{dimColor:!0,children:c.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else c.viewMode==="split"&&c.focusedPanel==="output"?W=[l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"q"}),i(r,{dimColor:!0,children:"QUIT"})]},"q"),l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"Esc"}),i(r,{dimColor:!0,children:"BACK"})]},"esc"),l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"↑↓"}),i(r,{dimColor:!0,children:"SCROLL"})]},"scroll"),...j?.status==="running"?[l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"i"}),i(r,{dimColor:!0,children:"INPUT"})]},"i")]:[],l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"⏎"}),i(r,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"Tab"}),i(r,{dimColor:!0,children:"PANEL"})]},"tab"),l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"?"}),i(r,{dimColor:!0,children:"HELP"})]},"?")]:W=[l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"q"}),i(r,{dimColor:!0,children:"QUIT"})]},"q"),l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"?"}),i(r,{dimColor:!0,children:"HELP"})]},"?"),l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"↑↓"}),i(r,{dimColor:!0,children:"NAV"})]},"nav"),l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"/"}),i(r,{dimColor:!0,children:"FILTER"})]},"/"),l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"F"}),i(r,{dimColor:!0,children:"STATUS"})]},"F"),l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"⏎"}),i(r,{dimColor:!0,children:c.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...c.viewMode==="split"?[l(u,{gap:1,children:[i(r,{bold:!0,color:"white",children:"Tab"}),i(r,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const re=l(u,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,justifyContent:"space-between",children:[i(u,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:W}),i(u,{flexShrink:0,paddingX:1,children:A})]}),te=l(vr,{backgroundColor:"#1e1e1e",footer:l(r,{dimColor:!0,children:[i(r,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",i(r,{bold:!0,color:"white",children:"?"}),"/",i(r,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:P,title:"KEYBOARD SHORTCUTS",visible:M,width:52,children:[l(u,{flexDirection:"column",marginBottom:1,children:[l(u,{marginBottom:1,children:[i(r,{dimColor:!0,children:"── "}),i(r,{bold:!0,color:"white",children:"NAVIGATION"})]}),l(u,{children:[i(u,{width:24,children:l(r,{children:[l(r,{bold:!0,color:"white",children:[" ","↑","/k"]}),i(r,{dimColor:!0,children:" Move up"})]})}),l(r,{children:[l(r,{bold:!0,color:"white",children:[" ","↓","/j"]}),i(r,{dimColor:!0,children:" Move down"})]})]}),l(r,{children:[l(r,{bold:!0,color:"white",children:[" ","Tab"]}),i(r,{dimColor:!0,children:" Switch panel (split)"})]}),l(r,{children:[l(r,{bold:!0,color:"white",children:[" ","Esc"]}),i(r,{dimColor:!0,children:" Back / close"})]}),l(r,{children:[l(r,{bold:!0,color:"white",children:[" ","Enter"]}),i(r,{dimColor:!0,children:" Show output / fullscreen"})]})]}),l(u,{flexDirection:"column",marginBottom:1,children:[l(u,{marginBottom:1,children:[i(r,{dimColor:!0,children:"── "}),i(r,{bold:!0,color:"white",children:"VIEWS"})]}),l(r,{children:[l(r,{bold:!0,color:"white",children:[" ","Enter"]}),l(r,{dimColor:!0,children:[" ","List"," ","→"," ","Split"," ","→"," ","Fullscreen"]})]}),l(r,{children:[l(r,{bold:!0,color:"white",children:[" ","Esc"]}),l(r,{dimColor:!0,children:[" ","Fullscreen"," ","→"," ","Split"," ","→"," ","List"]})]})]}),l(u,{flexDirection:"column",marginBottom:1,children:[l(u,{marginBottom:1,children:[i(r,{dimColor:!0,children:"── "}),i(r,{bold:!0,color:"white",children:"ACTIONS"})]}),l(u,{children:[i(u,{width:24,children:l(r,{children:[l(r,{bold:!0,color:"white",children:[" ","/"]}),i(r,{dimColor:!0,children:" Filter by text"})]})}),l(r,{children:[l(r,{bold:!0,color:"white",children:[" ","F"]}),i(r,{dimColor:!0,children:" Filter by status"})]})]}),l(u,{children:[i(u,{width:24,children:l(r,{children:[l(r,{bold:!0,color:"white",children:[" ","1"]}),i(r,{dimColor:!0,children:"/"}),i(r,{bold:!0,color:"white",children:"2"}),i(r,{dimColor:!0,children:" Pin to output pane"})]})}),l(r,{children:[l(r,{bold:!0,color:"white",children:[" ","0"]}),i(r,{dimColor:!0,children:" Clear pins"})]})]}),l(u,{children:[i(u,{width:24,children:l(r,{children:[l(r,{bold:!0,color:"white",children:[" ","r"]}),i(r,{dimColor:!0,children:" Rerun all (done)"})]})}),l(r,{children:[l(r,{bold:!0,color:"white",children:[" ","R"]}),i(r,{dimColor:!0,children:" Retry failed task"})]})]}),l(r,{children:[l(r,{bold:!0,color:"white",children:[" ","i"]}),i(r,{dimColor:!0,children:" Interactive input (running task)"})]})]}),l(u,{flexDirection:"column",marginBottom:1,children:[l(u,{marginBottom:1,children:[i(r,{dimColor:!0,children:"── "}),i(r,{bold:!0,color:"white",children:"SCROLLING"}),i(r,{dimColor:!0,children:" (output panel)"})]}),l(u,{children:[i(u,{width:24,children:l(r,{children:[l(r,{bold:!0,color:"white",children:[" ","↑","/k"]}),i(r,{dimColor:!0,children:" Scroll up"})]})}),l(r,{children:[l(r,{bold:!0,color:"white",children:[" ","↓","/j"]}),i(r,{dimColor:!0,children:" Scroll down"})]})]}),l(u,{children:[i(u,{width:24,children:l(r,{children:[l(r,{bold:!0,color:"white",children:[" ","^u"]}),i(r,{dimColor:!0,children:" Page up"})]})}),l(r,{children:[l(r,{bold:!0,color:"white",children:[" ","^d"]}),i(r,{dimColor:!0,children:" Page down"})]})]}),l(u,{children:[i(u,{width:24,children:l(r,{children:[l(r,{bold:!0,color:"white",children:[" ","Home"]}),i(r,{dimColor:!0,children:" Top"})]})}),l(r,{children:[l(r,{bold:!0,color:"white",children:[" ","End"]}),i(r,{dimColor:!0,children:" Bottom"})]})]})]}),l(u,{flexDirection:"column",children:[l(u,{marginBottom:1,children:[i(r,{dimColor:!0,children:"── "}),i(r,{bold:!0,color:"white",children:"GENERAL"})]}),l(u,{children:[i(u,{width:24,children:l(r,{children:[l(r,{bold:!0,color:"white",children:[" ","q"]}),i(r,{dimColor:!0,children:" Quit"})]})}),l(r,{children:[l(r,{bold:!0,color:"white",children:[" ","?"]}),i(r,{dimColor:!0,children:" Toggle help"})]})]})]})]}),ne=i(Vt,{autoExitSeconds:o>0?o:3,onCancel:O(()=>{x(!1)},"onCancel"),visible:v});if(c.viewMode==="fullscreen")return l(u,{flexDirection:"column",height:g,width:p,children:[i(u,{flexGrow:1,children:i(it,{duration:j?.duration??j?.elapsed,focused:!0,interactiveMode:c.interactiveMode,output:Y,scrollRef:S,status:j?.status,taskId:$})}),re,ne,te]});if(c.viewMode==="split"){const m=p>=dt,h=i(lt,{compact:!0,filterActive:c.filterActive,filterText:c.filterText,focused:c.focusedPanel==="tasks",headerStatus:he,parallelSlots:e,pinnedTaskIds:c.pinnedTaskIds,rows:B,scrollRef:y,selectedIndex:c.selectedIndex,title:_}),b=i(it,{duration:j?.duration??j?.elapsed,focused:c.focusedPanel==="output",interactiveMode:c.interactiveMode,output:Y,scrollRef:S,showFullscreenHint:!0,status:j?.status,taskId:$});if(m){const ke=Math.floor(p*.4);return l(u,{flexDirection:"column",height:g,width:p,children:[l(u,{flexDirection:"row",flexGrow:1,children:[i(u,{width:ke,children:h}),i(u,{flexGrow:1,children:b})]}),re,ne,te]})}const Q=Math.floor(g*.45);return l(u,{flexDirection:"column",height:g,width:p,children:[i(u,{height:Q,children:h}),i(u,{flexGrow:1,children:b}),re,ne,te]})}return l(u,{flexDirection:"column",height:g,width:p,children:[i(u,{flexGrow:1,children:i(lt,{filterActive:c.filterActive,filterText:c.filterText,focused:!0,headerStatus:he,parallelSlots:e,pinnedTaskIds:c.pinnedTaskIds,rows:B,scrollRef:y,selectedIndex:c.selectedIndex,title:_})}),re,ne,te]})},"VisTaskRunnerApp");var lo=Object.defineProperty,ge=O((o,e)=>lo(o,"name",{value:e,configurable:!0}),"n");const co=ge(o=>{const{args:e,autoExit:t=!1,projectNames:s,stdinRegistry:n,tasks:d}=o,a=new $e(d),f=typeof e.parallel=="number"?e.parallel:3,p=t===!0?3:typeof t=="number"?t:0;let g,c;const M=new Promise(R=>{c=R});let k;const P=ge(()=>{k&&(clearInterval(k),k=void 0)},"cleanup"),y=ge(()=>{if(n){for(const R of n.values())R.kill?.();n.clear()}},"killAllPtyProcesses"),S=ge(()=>{P(),N(),y(),process.stdout.write("\x1B[?1049l\x1B[?25h"),g?.cleanup(),process.exit(1)},"onSignal"),v=ge(()=>{const R=a.getSnapshot(),Z=me(Date.now()-R.startTime),U=R.rows.filter(H=>H.status==="failure").map(H=>H.taskId),B=process.stdout.columns||80;process.stdout.write(`
13
+ `);for(const H of R.rows){const{status:$,taskId:j}=H,Y=Se($);let D="";switch($){case"local-cache":case"local-cache-kept-existing":{D=" [local cache]";break}case"remote-cache":{D=" [remote cache]";break}case"skipped":{D=" [skipped]";break}}const _=K(F.createElement(r,null," ",F.createElement(r,{color:Y.color},Y.icon),` vis run ${j}`,D?F.createElement(r,{dimColor:!0},` ${D}`):null),{columns:B});process.stdout.write(`${_}
14
+ `)}process.stdout.write(`
15
+ `);const ie=K(F.createElement(Ct,{cached:R.cached,failed:R.failed,failedIds:U,projectNames:s,succeeded:R.succeeded,targets:e.targets,tasks:d,took:Z}),{columns:B});if(process.stdout.write(`${ie}
16
+ `),U.length>0)for(const H of U){const $=R.outputs.get(H);if($?.trim()){const j=K(F.createElement(r,null,`
17
+ `,F.createElement(r,{bold:!0,color:"red"},` ${He} vis run ${H}`)),{columns:B});process.stdout.write(`${j}
18
+
19
+ `);const Y=$.trim().split(`
20
+ `).map(D=>` ${D}`).join(`
21
+ `);process.stdout.write(`${Y}
22
+ `)}}},"printExitSummary");let x;const N=ge(()=>{x&&(clearInterval(x),x=void 0)},"clearKeepAlive");return{lifeCycle:{endCommand(){P(),a.markDone(),x||(x=setInterval(()=>{},1e3)),process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume())},endTasks(R){a.endTasks(R)},printTaskTerminalOutput(R,Z,U){a.getSnapshot().outputs.has(R.id)||a.addOutput(R.id,U)},startCommand(){process.on("SIGINT",S),process.on("SIGTERM",S),x||(x=setInterval(()=>{},1e3)),process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume()),g=br(F.createElement(so,{autoExitSeconds:p,parallelSlots:f,projectNames:s,stdinRegistry:n??new Map,store:a,targets:e.targets,tasks:d}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}),g.waitUntilExit().then(()=>{N(),y(),process.removeListener("SIGINT",S),process.removeListener("SIGTERM",S),v(),c()},()=>{N(),y(),process.removeListener("SIGINT",S),process.removeListener("SIGTERM",S),c()})},startTasks(R){a.startTasks(R),k||(k=setInterval(()=>{a.tick()},100))}},renderIsDone:M,store:a}},"createDynamicOutputRenderer");var ao=Object.defineProperty,uo=O((o,e)=>ao(o,"name",{value:e,configurable:!0}),"m");class ho{static{O(this,"StaticOutputLifeCycle")}static{uo(this,"StaticOutputLifeCycle")}#e;#r;#o;#i=[];#t=[];#n=new Map;#s;#l=0;constructor(e){this.#e=e.projectNames,this.#r=e.args.targets,this.#o=e.tasks,this.#s=e.logReporter}startCommand(){this.#l=Date.now();const e=process.stdout.columns||80,t=`Running ${qe(this.#e,this.#r,this.#o)}`,s=K(F.createElement(Pe,{title:t,variant:"info"}),{columns:e});process.stdout.write(s);const n=this.#o[0],d=n?.overrides?Object.entries(n.overrides).filter(([a])=>a!=="command"):[];if(d.length>0){process.stdout.write(`
23
+ With additional flags:
24
+ `);for(const[a,f]of d)process.stdout.write(`${qr(" ",a,f)}
25
+ `)}process.stdout.write(`
26
+ `)}startTasks(e){const t=process.stdout.columns||80;for(const s of e){const n=K(F.createElement(r,null,F.createElement(r,{dimColor:!0},">"),` ${s.id}`),{columns:t});process.stdout.write(`${n}
27
+ `)}}endTasks(e){const t=process.stdout.columns||80;for(const s of e){this.#n.set(s.task.id,s),s.status==="failure"?this.#i.push(s):Te(s.status)&&this.#t.push(s);const n=$t(s.status),d=s.startTime&&s.endTime?` (${me(s.endTime-s.startTime)})`:"",a=Te(s.status)?" [cache]":"",f=K(F.createElement(r,null,n,` ${s.task.id}`,a?F.createElement(r,{color:"cyan"},a):null,d?F.createElement(r,{dimColor:!0},d):null),{columns:t});process.stdout.write(`${f}
28
+ `)}}printTaskTerminalOutput(e,t,s){if(this.#s){this.#s.printTaskTerminalOutput(e,t,s);return}Zr(e.id,t,s)}endCommand(){const e=me(Date.now()-this.#l),t=this.#o.filter(d=>!this.#n.has(d.id)).map(d=>d.id);process.stdout.write(`
29
+ `);const s=process.stdout.columns||80,n=K(F.createElement(Ct,{cached:this.#t.length,failed:this.#i.length,failedIds:this.#i.map(d=>d.task.id),projectNames:this.#e,skippedIds:t.length>0?t:void 0,succeeded:this.#n.size-this.#i.length-this.#t.length,targets:this.#r,tasks:this.#o,took:e}),{columns:s});process.stdout.write(`${n}
30
+ `)}}var fo=Object.defineProperty,we=O((o,e)=>fo(o,"name",{value:e,configurable:!0}),"l");const po=[/node_modules(?:\/|$)/,/\.git(?:\/|$)/,/\.vis(?:\/|$)/,/\.task-runner(?:\/|$)/],ut=we((o,e)=>{const t=new Set,s=new Set;for(const[,a]of o){const f=a.task.hashDetails?.nodes;if(f)for(const p of Object.keys(f))t.add(p),s.add(hr(wt(e,p)))}const n=[...s].sort(),d=[];for(const a of n)d.some(f=>a===f||a.startsWith(`${f}/`))||d.push(a);return{directories:d,files:t}},"collectTrackedWatchTargets"),mo=we((o,e,t)=>{const s=new Set;for(const n of o){const d=wt(e,n);for(const a of t)if(d===a||d.startsWith(`${a}/`)){const f=fr(a,d);f.length>0&&s.add(f)}}return n=>{const d=n.replaceAll("\\","/");return s.has(d)}},"createTrackedFileFilter"),go=we(o=>{const e=o.replaceAll("\\","/");return po.some(t=>t.test(e))},"shouldIgnore"),ht=we(o=>{const{debounceMs:e=150,filter:t,onChange:s,paths:n}=o,d=[];let a=new Set,f;const p=we(()=>{f=void 0;const g=[...a];a=new Set,g.length!==0&&Promise.resolve(s(g)).catch(c=>{console.error("[vis watch] onChange handler failed:",c)})},"flush");for(const g of n)try{const c=Tr(g,{recursive:!0},(M,k)=>{k&&(go(k)||t&&!t(k)||(a.add(k),f&&clearTimeout(f),f=setTimeout(p,e)))});d.push(c)}catch(c){console.warn(`[vis watch] unable to watch ${g}: ${c.message}`)}return{close:we(()=>{f&&clearTimeout(f);for(const g of d)try{g.close()}catch{}},"close")}},"startWatcher");var wo=Object.defineProperty,E=O((o,e)=>wo(o,"name",{value:e,configurable:!0}),"c");const Ue="VIS_AFFECTED_FILES",Mt=E((o,e,t)=>t||!e?o:e.startsWith("/")?e:`${o}/${e}`,"resolveCwd"),ft=E(async(o,e,t,s)=>{const n=o.map(d=>{const a=d.overrides.command;if(!a)return;const f=d.overrides.visOptions,p=Mt(e,d.projectRoot,!!f?.runFromWorkspaceRoot),g=f?.envFile?gt(p,f.envFile):{},c=t&&(f?.affectedFiles==="env"||f?.affectedFiles==="both")?{[Ue]:t.join(`
31
+ `)}:{};return{command:a,cwd:p,env:{INIT_CWD:s,...g,...c},name:d.id}}).filter(d=>d!==void 0);n.length!==0&&await Le(n,{killOthers:["failure"]})},"runPersistentTasks"),Ae=256*1024;class ko{static{O(this,"ye")}static{E(this,"OutputRingBuffer")}#e;#r="";#o=!1;constructor(e){this.#e=e}append(e){this.#r+=e,this.#r.length>this.#e&&(this.#r=this.#r.slice(-this.#e),this.#o=!0)}toString(){return this.#o?`[...output truncated, showing last ${Math.round(this.#e/1024)}KB...]
32
+ ${this.#r}`:this.#r}}const jt=E(o=>{const e=o.overrides.visOptions;if(e&&typeof e=="object")return e},"getTaskOptions"),_e=E(o=>`'${o.replaceAll("'",String.raw`'\''`)}'`,"singleQuoteEscape"),vo=E((o,e,t)=>{if(!e||e.length===0||t===!1||t===void 0)return o;if(t==="args"||t==="both"){const s=e.map(_e).join(" ");return`${o} ${s}`}return o},"buildAffectedFilesArgs"),Ot="visForwardedArgs",bo=E((o,e)=>{const t=e.overrides[Ot];if(!Array.isArray(t)||t.length===0)return o;const s=t.map(_e).join(" ");return`${o} ${s}`},"appendForwardedArgs"),yo=E(async(o,e,t)=>{if(!e)return t();const s=o.get(e)??Promise.resolve();let n;const d=new Promise(f=>{n=f}),a=s.then(()=>d);o.set(e,a),await s;try{return await t()}finally{n(),o.get(e)===a&&o.delete(e)}},"withMutex"),To=E(o=>{let e=Math.max(0,Math.floor(o));return{claim(t){const s=Math.max(0,Math.min(t,e));return e-=s,s},get remaining(){return e}}},"createRetryBudget"),Co=E((o,e,t)=>{const s=`${e}\0${typeof t=="string"?t:String(t)}`,n=o.get(s);if(n)return n;const d=gt(e,t);return o.set(s,d),d},"loadEnvFileCached"),pt=E(o=>{const e=new Map;return async(t,s)=>{const{affectedFiles:n,currentOs:d,initCwd:a,lifeCycle:f,mutexPool:p,onOutput:g,onOutputReplace:c,retryBudget:M,stdinRegistry:k,workspaceRoot:P}=o,y=jt(t),S=Mt(P,s.cwd??t.projectRoot,y?.runFromWorkspaceRoot===!0),v=t.overrides.command;if(!v)return{code:0,terminalOutput:`No command configured for ${t.target.project}:${t.target.target}`};const x=bo(v,t),N=vo(x,n,y?.affectedFiles),R=zt(y,d),Z=R?`${R} -c ${_e(N)}`:N,U=y?.envFile?Co(e,S,y.envFile):void 0,B={};n&&n.length>0&&(y?.affectedFiles==="env"||y?.affectedFiles==="both")&&(B[Ue]=n.join(`
33
+ `));const ie={INIT_CWD:a,...U,...s.env,...B},H=y?.pty===!0,$=!!k,j=$||H;j&&(t.cache=!1);const Y=j?void 0:new ko(Ae),D=j?new mt(Ae):void 0;let _;const he=E(A=>{if(A.kind==="started"&&(_=A.kill,A.write&&k&&k.set(t.id,{kill:A.kill,resize:A.resize,write:A.write})),(A.kind==="stdout"||A.kind==="stderr")&&A.text!==void 0)if(A.kind==="stdout"?f?.onTaskStdout?.(t,A.text):f?.onTaskStderr?.(t,A.text),D)D.write(A.text),$&&c?.(t.id,D.toString());else{const W=`${A.text}
34
+ `;Y.append(W),g?.(t.id,W)}A.kind==="close"&&k&&k.delete(t.id)},"onEvent"),ee=E(async()=>{const A=y?.retryCount??0,W=y?.retryDelay,re=M?M.claim(A):A,te=typeof y?.timeout=="number"&&y.timeout>0?y.timeout:0;let ne=!1,m;te>0&&(m=setTimeout(()=>{ne=!0,_?.("SIGTERM")},te));let h;try{h=await Le([{command:Z,cwd:S,env:ie,name:t.id,...j?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}],{killOthers:["failure"],onEvent:he,...re>0?{restart:{delay:W??"exponential",tries:re}}:{}})}finally{m&&clearTimeout(m)}const b=h.closeEvents[0],Q=D?D.toString():Y.toString();return ne?{code:124,terminalOutput:`${Q}
35
+ [timeout] Task "${t.id}" exceeded ${te}ms budget.
36
+ `}:{code:b?.exitCode??1,terminalOutput:Q}},"runOnce");return p?yo(p,y?.mutex,ee):ee()}},"createConcurrentExecutor"),So=E(o=>{if(!o||o.trim().length===0)return;const e=Number.parseFloat(o);return!Number.isFinite(e)||e<=0?{invalid:o}:{value:Math.floor(e)}},"parseEnvConcurrency"),$o=E(async(o,e)=>{const t=await Bt(o);if(!t){e.warn("No previous run recorded yet. Run a task at least once to populate .task-runner/last-summary.json.");return}const s=(t.duration/1e3).toFixed(2);if(e.info(""),e.info(`Last run — ${t.startTime} (${s}s)`),e.info(""),e.info(` Total: ${String(t.stats.total)}`),e.info(` Succeeded: ${String(t.stats.succeeded)}`),e.info(` Cached: ${String(t.stats.cached)}`),e.info(` Failed: ${String(t.stats.failed)}`),e.info(` Skipped: ${String(t.stats.skipped)}`),e.info(""),t.stats.failed>0){const d=t.tasks.filter(a=>a.exitCode!==void 0&&a.exitCode!==0);e.info("Failed tasks:");for(const a of d){const f=a.duration??0;e.info(` × ${a.taskId} (exit ${String(a.exitCode??-1)}, ${f}ms)`)}e.info("")}const n=[...t.tasks].filter(d=>typeof d.duration=="number").sort((d,a)=>(a.duration??0)-(d.duration??0)).slice(0,5);if(n.length>0){e.info("Slowest tasks:");for(const d of n)e.info(` ${d.taskId.padEnd(40)} ${String(d.duration??0).padStart(6)}ms [${d.cacheStatus}]`);e.info("")}},"renderLastRunSummary"),Go=E(async({argument:o,logger:e,options:t,runtime:s,visConfig:n,workspaceRoot:d})=>{if(!d)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const a=d;if(t.lastDetails===!0){await $o(a,e);return}const f=process.cwd(),{config:p,packageJsons:g,projectOptions:c,workspace:M}=Yt(a,n),k=Qt(a,M,g);let P=o[0];if(!P){const w=ot(M);if(process.stdout.isTTY&&process.stdin.isTTY){const T=await Nr(w);if(!T){e.info("No target selected.");return}P=T,await Er(`vis run ${T}`)}else{e.info("Available targets:"),e.info(""),e.info(Br(w)),e.info(""),e.info("Usage: vis run <target>");return}}if(p.constraints&&!t.skipConstraints){const w=Nt(k,p.constraints);if(w.length>0){for(const T of w)e.error(`[${T.rule}] ${T.message}`);throw new Error(`${w.length} project constraint violation(s) found. Use --skip-constraints to bypass.`)}}if(t.affected){const w=[P];t.parallel!==void 0&&w.push(`--parallel=${String(t.parallel)}`),t.cache||w.push("--no-cache"),t.query&&w.push(`--query=${String(t.query)}`),await s.runCommand("affected",{argv:w});return}const y=await cr(P,M,process.cwd(),a),S=Pr(c),v=Ar(y.target,S);v!==y.target&&e.debug?.(`Resolved alias "${y.target}" → "${v}"`);let x=y.projects;const N=o.slice(1).map(String);if(t.projects){const w=new Set(t.projects.split(",").map(T=>T.trim()));if(x=x.filter(T=>w.has(T)),x.length===0)throw new Error(`No matching projects found for: ${String(t.projects)}`)}if(t.query&&(x=ar(x,M,t.query),x.length===0)){e.info(`Query "${String(t.query)}" matched no projects.`);return}const R=Xt(),Z=process.env[Ue],U=Z?Z.split(`
37
+ `).filter(Boolean):void 0,B=[],ie=new Map;for(const w of x){const T=c.get(w)?.[v];if(!T)continue;const C=T.options;if(!C?.internal){if(!Kt(C,R)){e.debug?.(`Skipping ${w}:${v} — osType does not match ${R}`);continue}if(!Jt(C,!!Je)){e.debug?.(`Skipping ${w}:${v} — runInCI filter`);continue}if(!Zt(C?.when)){e.debug?.(`Skipping ${w}:${v} — \`when\` condition not satisfied`);continue}B.push(w),ie.set(w,T)}}if(B.length===0){const w=ot(M),T=Object.entries(M.projects).filter(([,C])=>C.targets?.[v]!==void 0).map(([C])=>C);if(e.error(`No projects have the "${v}" target.`),T.length>0){e.info(""),e.info(`Target "${v}" exists in these projects but was filtered out:`);for(const C of T.slice(0,5))e.info(` - ${C}`);T.length>5&&e.info(` …and ${T.length-5} more`)}else{const C=Tt(v,w,3);C.length>0&&(e.info(""),e.info(C.length===1?`Did you mean "${C[0]}"?`:`Did you mean one of: ${C.map(G=>`"${G}"`).join(", ")}?`)),e.info(""),e.info("Run `vis run` without arguments to see all available targets.")}return}const H=t.pty===!0;let $=B.map(w=>{const T=M.projects[w],C=ie.get(w),G={project:w,target:v},q=`${w}:${v}`,se=H?{...C.options,pty:C.options?.pty??!0}:C.options;return{cache:C.cache,id:q,outputs:C.outputs??[],overrides:{command:C.command,...N.length>0?{[Ot]:N}:{},...se?{visOptions:se}:{}},parallelism:C.parallelism,projectRoot:T?.root,target:G}});const j=[],Y=[];for(const w of $)jt(w)?.persistent?(w.cache=!1,j.push(w)):Y.push(w);$=Y;const D=Ht(t.partition);if(D&&($=Gt.partitionTasks($,D),e.info(`Partition ${D.index}/${D.total}: running ${$.length} task(s)`),$.length===0)){e.info("No tasks assigned to this partition.");return}const _=qt($,{projectGraph:k,targetDefaults:p.targetDefaults,workspace:M});if(t.dryRun){const w=Object.keys(_.tasks).length,T=_.roots.length;e.info(`Execution plan (${String(w)} task(s), ${String(T)} root(s)):`),e.info("");const C=new Set,G=E((q,se)=>{if(C.has(q))return;C.add(q);for(const fe of _.dependencies[q]??[])G(fe,se+1);const le=_.tasks[q],J=" ".repeat(se+1);e.info(`${J}${q}${le?.cache===!1?" (no-cache)":""}`)},"walkPlan");for(const q of _.roots)G(q,0);j.length>0&&(e.info(""),e.info(` + ${String(j.length)} persistent task(s) (run after graph completes)`)),e.info("");return}await mr(a,p.toolchain,{error:E(w=>e.error(w),"error"),info:E(w=>e.info(w),"info"),warn:E(w=>e.warn(w),"warn")},!!t.skipToolchain);const he=Date.now(),ee=Sr(),A=E((w,T)=>{const C=T instanceof Error?T.message:String(T);e.warn(`Plugin error in ${w}: ${C}`)},"onHookError");await $r(ee,p.plugins);const W=typeof t.profile=="string"?t.profile:void 0,re=E(async w=>{if(!W)return;const T=Qe(w,_,he),C=W.startsWith("/")?W:`${a}/${W}`;await Ut(T,C),e.info(`Profile written to ${W}`)},"maybeWriteProfile"),te=p.taskRunnerOptions??{},ne=er(a,t.cacheDir,te.cacheDirectory),m=tr(ne,a,p.branchScopedCache),h=So(process.env.VIS_RUN_CONCURRENCY_LIMIT);h&&"invalid"in h&&e.warn(`VIS_RUN_CONCURRENCY_LIMIT=${h.invalid} is not a positive number; falling back to default concurrency.`);const b=h&&"value"in h?h.value:void 0,Q=t.parallel??b??3,ke={dryRun:t.dryRun??!1,parallel:Q,skipNxCache:!t.cache,summarize:t.summarize??!1,...te,cacheDirectory:m},Ft=process.stdout.isTTY&&!Je,Pt=p.tui?.autoExit??!1,We={args:{parallel:ke.parallel,targets:[v]},autoExit:Pt,projectNames:B,tasks:$},Ve=typeof t.retryBudget=="number"?t.retryBudget:void 0,ze=Ve===void 0?void 0:To(Ve),Ye=new xr(ee,A);if(await ee.callHook("run:before",{tasks:$,workspaceRoot:a}),Ft){const w=new Map,T=co({...We,stdinRegistry:w}),{lifeCycle:C,store:G}=T,q=new Xe([C,Ye]),se=pt({affectedFiles:U,currentOs:R,initCwd:f,lifeCycle:q,mutexPool:new Map,onOutput:E((I,L)=>{G.addOutput(I,L)},"onOutput"),onOutputReplace:E((I,L)=>{G.setOutput(I,L)},"onOutputReplace"),retryBudget:ze,stdinRegistry:w,workspaceRoot:a});let le="rerun",J=null,fe=new Map;for(;le!=="quit";){if(le==="rerun")fe=await Ke($,ke,{lifeCycle:q,projectGraph:k,taskExecutor:se,taskGraph:_,workspaceRoot:a});else if(le==="retry"&&J){const I=$.find(z=>z.id===J),L=I?.overrides.command;if(I&&L){const z=I.projectRoot??a,pe=z.startsWith("/")?z:`${a}/${z}`;q.startTasks?.([I]);const ce=new mt(Ae),de=(await Le([{command:L,cwd:pe,name:I.id,ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}],{onEvent:E(V=>{V.kind==="started"&&V.write&&w.set(I.id,{kill:V.kill,resize:V.resize,write:V.write}),(V.kind==="stdout"||V.kind==="stderr")&&V.text&&(ce.write(V.text),G.setOutput(I.id,ce.toString())),V.kind==="close"&&w.delete(I.id)},"onEvent")})).closeEvents[0];q.endTasks?.([{code:de?.exitCode??1,status:de?.exitCode===0?"success":"failure",task:I,terminalOutput:G.getSnapshot().outputs.get(I.id)}])}else I&&q.endTasks?.([{code:1,status:"failure",task:I,terminalOutput:`No command configured for ${I.id}`}]);J=null,G.markDone()}le=await new Promise(I=>{const L=G.subscribe(()=>{const z=G.getSnapshot();z.rerunRequested&&(G.acknowledgeRerun(),L(),I("rerun")),z.retryTaskId&&(J=G.acknowledgeRetry(),L(),I("retry"))});T.renderIsDone.then(()=>{L(),I("quit")},()=>{L(),I("quit")})})}await T.renderIsDone,await ee.callHook("run:after",fe),await re(fe),j.length>0&&!t.failFast&&await ft(j,a,U,f)}else{const w=new Map,T=typeof t.log=="string"?t.log.toLowerCase():"",C=T==="labeled"||T==="grouped"||T==="interleaved"?T:void 0,G=C?_t(C):void 0,q=new Xe([new ho({...We,logReporter:G}),Ye]),se=pt({affectedFiles:U,currentOs:R,initCwd:f,lifeCycle:q,mutexPool:w,retryBudget:ze,workspaceRoot:a}),le=E(async()=>{const I=Date.now(),L=await Ke($,ke,{lifeCycle:q,projectGraph:k,taskExecutor:se,taskGraph:_,workspaceRoot:a}),z=Date.now()-I;if(t.summarize){const ve=Qe(L,_,he);await Wt(ve,a)}let pe=!1;for(const[,ve]of L)ve.status==="failure"&&(pe=!0);const ce=rr(L,z),de=or(a),V=ir(a,z,de);return e.info(""),e.info(` ${ce}${V?` ${V}`:""}`),{hasFailure:pe,results:L,runHistory:de}},"runOnce"),J=await le();await ee.callHook("run:after",J.results),await re(J.results);const{hasFailure:fe}=J;if(t.watch){const I=B.map(X=>{const ae=M.projects[X]?.root;if(ae)return ae.startsWith("/")?ae:`${a}/${ae}`}).filter(X=>X!==void 0);let L=!1,z=J.results;const pe=E(()=>{const X=ut(z,a);if(X.directories.length>0&&X.files.size>0){const ae=mo(X.files,a,X.directories);return{handle:ht({filter:ae,onChange:de,paths:X.directories}),mode:"tracked"}}return{handle:ht({onChange:de,paths:I}),mode:"roots"}},"buildHandle");let ce;const de=E(async X=>{if(!L){L=!0;try{e.info(`Change detected in ${X.length} file(s), rerunning…`),z=(await le()).results,ce?.close(),ce=pe().handle}finally{L=!1}}},"onChangeHandler"),V=pe();ce=V.handle;const ve=V.mode==="tracked"?`Watching ${String(ut(z,a).files.size)} tracked file(s)`:`Watching ${String(I.length)} project root(s)`;e.info(`${ve} — edit a file to rerun, Ctrl+C to exit.`),await new Promise(X=>{const ae=E(()=>{process.off("SIGINT",ae),ce?.close(),X()},"onSigint");process.on("SIGINT",ae)});return}if(fe){if(t.flaky!==!1){const I=nr(a,{minRuns:2},J.runHistory);if(I.length>0){e.info(""),e.info("Flaky tasks (based on historical runs):"),e.info("");for(const L of sr(I))e.info(` ${L}`);e.info("")}}throw new Error("Some tasks failed.")}j.length>0&&!t.failFast&&await ft(j,a,U,f)}},"execute");export{To as createRetryBudget,Go as default};
@@ -0,0 +1,3 @@
1
+ var le=Object.defineProperty;var g=(e,n)=>le(e,"name",{value:n,configurable:!0});import{createRequire as ue}from"node:module";import{readJsonSync as ne,readFileSync as he,ensureDirSync as ge}from"@visulima/fs";import{join as w,resolve as ye,dirname as ve}from"@visulima/path";import{Z as be,e as _e,c as Pe,I as $e}from"../packem_shared/bin-BaZZ32BK.js";import{toXML as we}from"jstoxml";import{r as Se}from"../packem_shared/docker-BcfqH4Av.js";import{parseLockFileContent as je}from"@visulima/package";import xe from"semver";const me=ue(import.meta.url),M=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ee=g(e=>{if(typeof M<"u"&&M.versions&&M.versions.node){const[n,t]=M.versions.node.split(".").map(Number);if(n>22||n===22&&t>=3||n===20&&t>=16)return M.getBuiltinModule(e)}return me(e)},"__cjs_getBuiltinModule"),{readdirSync:fe,writeFileSync:de}=ee("node:fs"),{randomUUID:ke}=ee("node:crypto");var Le=Object.defineProperty,L=g((e,n)=>Le(e,"name",{value:n,configurable:!0}),"r$1");const q=L(e=>{try{return ne(e)}catch{return}},"readJsonSafe"),Ce=L(e=>{if(e.length===0||e.includes("..")||e.startsWith(".")||e.includes("\0")||e.includes("\\"))return!1;if(e.startsWith("@")){const n=e.indexOf("/");return n>1&&!e.includes("/",n+1)}return!e.includes("/")},"isSafePackageName"),De=L(e=>e.length>0&&!e.includes("/")&&!e.includes("\\")&&!e.includes("..")&&!e.includes("\0"),"isSafeVersion"),Oe=L((e,n,t)=>{const o=`${n.replaceAll("/","+")}@${t}`,c=w(e,"node_modules",".pnpm"),l=q(w(c,o,"node_modules",n,"package.json"));if(l)return l;let y;try{y=fe(c)}catch{return}const _=`${o}_`;for(const f of y){if(!f.startsWith(_))continue;const d=q(w(c,f,"node_modules",n,"package.json"));if(d)return d}},"readPnpmVirtualStore"),Me=L((e,n,t)=>{const o=q(w(e,"node_modules",n,"package.json"));return o?.version===t?o:void 0},"readHoistedCopy"),Be=L((e,n,t)=>{if(!(!Ce(n)||!De(t)))return Oe(e,n,t)??Me(e,n,t)},"readInstalledPackageMetadata");var Ae=Object.defineProperty,te=g((e,n)=>Ae(e,"name",{value:n,configurable:!0}),"i");const oe=new Set(["0BSD","AGPL-3.0","AGPL-3.0-only","AGPL-3.0-or-later","Apache-1.1","Apache-2.0","Artistic-2.0","BlueOak-1.0.0","BSD-2-Clause","BSD-3-Clause","BSL-1.0","CC0-1.0","CC-BY-3.0","CC-BY-4.0","CDDL-1.0","CDDL-1.1","EPL-1.0","EPL-2.0","GPL-2.0","GPL-2.0-only","GPL-2.0-or-later","GPL-3.0","GPL-3.0-only","GPL-3.0-or-later","ISC","LGPL-2.0","LGPL-2.1","LGPL-3.0","MIT","MIT-0","MPL-1.1","MPL-2.0","Python-2.0","Unlicense","WTFPL","Zlib"]),Re={apache2:"Apache-2.0","apache 2.0":"Apache-2.0",bsd:"BSD-3-Clause","bsd-2":"BSD-2-Clause","bsd-3":"BSD-3-Clause",mit:"MIT",public:"Unlicense","public domain":"Unlicense"},Te=(()=>{const e=new Map;for(const n of oe)e.set(n.toLowerCase(),n);for(const[n,t]of Object.entries(Re))e.set(n,t);return e})(),Ge=te(e=>{const n=e.trim();if(n.length!==0)return oe.has(n)?n:Te.get(n.toLowerCase())},"normalizeSpdxId"),Ie=te(e=>{let n;if(typeof e.license=="string")n=e.license;else if(e.license&&typeof e.license=="object"&&typeof e.license.type=="string")n=e.license.type;else if(Array.isArray(e.licenses)&&e.licenses.length>0){const c=e.licenses[0];c&&typeof c.type=="string"&&(n=c.type)}if(!n)return;const t=n.trim();if(t.length===0)return;if(/[()]|\b(and|or|with)\b/i.test(t))return[{expression:t}];const o=Ge(t);return o?[{license:{id:o}}]:[{license:{name:t}}]},"extractLicenseChoice");var Ee=Object.defineProperty,se=g((e,n)=>Ee(e,"name",{value:n,configurable:!0}),"t");const Ne={sha256:"SHA-256",sha384:"SHA-384",sha512:"SHA-512"},Ue={sha256:64,sha384:96,sha512:128},Fe=se(e=>{const n={name:e.name,version:e.version},{integrity:t}=e;return t&&t.hex.length===Ue[t.algorithm]&&(n.hash={alg:Ne[t.algorithm],content:t.hex}),e.dependencies&&(n.dependencies=e.dependencies),e.peerDependencies&&(n.peerDependencies=e.peerDependencies),e.optionalDependencies&&(n.optionalDependencies=e.optionalDependencies),n},"toResolvedPackage"),Xe=[{file:"pnpm-lock.yaml",type:"pnpm"},{file:"package-lock.json",type:"npm"},{file:"yarn.lock",type:"yarn"},{file:"bun.lock",type:"bun"}],qe=se(e=>{for(const{file:n,type:t}of Xe){let o;try{o=he(w(e,n))}catch{continue}const c=new Map;for(const l of je(o,t))c.set(`${l.name}@${l.version}`,Fe(l));return{packages:c,type:t}}},"readLockfilePackages");var ze=Object.defineProperty,re=g((e,n)=>ze(e,"name",{value:n,configurable:!0}),"r");const B=re(e=>e.replaceAll(/[^\w.~-]/g,n=>`%${(n.codePointAt(0)??0).toString(16).toUpperCase().padStart(2,"0")}`),"encodeSegment"),k=re((e,n)=>{const t=e.toLowerCase();if(t.startsWith("@")){const o=t.indexOf("/");if(o>0){const c=t.slice(0,o),l=t.slice(o+1);return`pkg:npm/${B(c)}/${B(l)}@${B(n)}`}}return`pkg:npm/${B(t)}@${B(n)}`},"toNpmPurl");var Je=Object.defineProperty,ce=g((e,n)=>Je(e,"name",{value:n,configurable:!0}),"s");const Ve=ce(e=>{const n=e.indexOf(":");return n<=0?e:e.slice(0,n)==="npm"?e.slice(n+1):e},"stripProtocolPrefix"),F=ce((e,n,t)=>{const o=t.get(e);if(!o||o.size===0)return;if(o.has(n))return n;const c=Ve(n);if(c!==n&&o.has(c))return c;const l=[...o];return xe.maxSatisfying(l,c,{includePrerelease:!0})||l[0]},"resolveSpecifier");var We=Object.defineProperty,m=g((e,n)=>We(e,"name",{value:n,configurable:!0}),"p$1");const He="1.6",Ye="CycloneDX",Ze="http://cyclonedx.org/schema/bom-1.6.schema.json",Ke="@visulima/vis",Q=m(e=>{try{return ne(e)}catch{return}},"readPackageJson"),Qe=m(e=>{if(e){if(typeof e=="string")return e;if(typeof e=="object"&&e.name)return e.email?`${e.name} <${e.email}>`:e.name}},"toAuthorString"),en=m(e=>{if(e)return typeof e=="string"?e:e.url},"toRepositoryUrl"),nn=m(e=>{if(e)return typeof e=="string"?e:e.url},"toBugsUrl"),tn=m(e=>{const n=[];e.homepage&&n.push({type:"website",url:e.homepage});const t=en(e.repository);t&&n.push({type:"vcs",url:t});const o=nn(e.bugs);return o&&n.push({type:"issue-tracker",url:o}),n.length>0?n:void 0},"buildExternalReferences"),X=m((e,n)=>{if(!n)return;n.description&&(e.description=n.description);const t=Qe(n.author);t&&(e.author=t);const o=Ie(n);o&&(e.licenses=o);const c=tn(n);c&&(e.externalReferences=c)},"decoratePackageComponent"),on=m(e=>{const{focus:n,generatorVersion:t,includeDev:o=!1,now:c=new Date,projectGraph:l,serialNumber:y,workspace:_,workspaceRoot:f}=e,d=n&&n.length>0?[...Se(n,l)].sort():Object.keys(_.projects).sort(),A=new Set(d),S=new Map;for(const r of d){const s=_.projects[r];s&&S.set(r,Q(w(f,s.root,"package.json")))}const v=[],C=new Map;for(const r of d){const s=_.projects[r];if(!s)continue;const a=S.get(r),i=a?.version??"0.0.0",p=k(r,i);C.set(r,p);const u={"bom-ref":p,name:r,purl:p,type:s.projectType==="application"?"application":"library",version:i};X(u,a),v.push(u)}const R=qe(f),j=new Map,D=new Map;if(R)for(const r of R.packages.values()){j.set(`${r.name}@${r.version}`,r);let s=D.get(r.name);s||(s=new Set,D.set(r.name,s)),s.add(r.version)}const J=[],I=[],V=new Map;for(const r of d){const s=S.get(r);if(!s)continue;const a=[s.dependencies,s.peerDependencies];o&&a.push(s.devDependencies);const i=new Set,p=m((u,P)=>{if(P)for(const[$,b]of Object.entries(P)){if(A.has($)){const x=C.get($);x&&i.add(x);continue}const h=F($,b,D);h&&(i.add(k($,h)),u.push(`${$}@${h}`))}},"seedRef");for(const u of a)p(J,u);p(I,s.optionalDependencies),V.set(r,i)}const T=new Map,E=new Map,W=m((r,s)=>{const a=[...r];for(;a.length>0;){const i=a.pop(),p=T.get(i);if(p==="required"||p==="optional"&&s==="optional")continue;T.set(i,s);const u=j.get(i);if(!u)continue;const P=E.get(i)??new Set,$=[u.dependencies,u.peerDependencies];for(const b of $)if(b)for(const[h,x]of Object.entries(b))for(const O of x){const U=F(h,O,D);U&&(P.add(k(h,U)),a.push(`${h}@${U}`))}if(u.optionalDependencies)for(const[b,h]of Object.entries(u.optionalDependencies))for(const x of h){const O=F(b,x,D);O&&(P.add(k(b,O)),I.push(`${b}@${O}`))}P.size>0&&E.set(i,P)}},"walk");W(J,"required"),W(I,"optional");const H=[],Y=[...T.keys()].sort();for(const r of Y){const s=j.get(r);if(!s)continue;const a=k(s.name,s.version),i={"bom-ref":a,name:s.name,purl:a,scope:T.get(r)??"required",type:"library",version:s.version};s.hash&&(i.hashes=[s.hash]),X(i,Be(f,s.name,s.version)),H.push(i)}const G=[];for(const[r,s]of V){const a=C.get(r);if(!a)continue;const i=[...s].sort();G.push(i.length>0?{dependsOn:i,ref:a}:{ref:a})}for(const r of Y){const s=j.get(r);if(!s)continue;const a=k(s.name,s.version),i=E.get(r),p=i?[...i].sort():[];G.push(p.length>0?{dependsOn:p,ref:a}:{ref:a})}G.sort((r,s)=>r.ref.localeCompare(s.ref));const N=Q(w(f,"package.json")),Z=(()=>{if(n?.length===1){const p=v.find(u=>u.name===n[0]);if(p)return{"bom-ref":p["bom-ref"],name:p.name,purl:p.purl,type:p.type,version:p.version}}const r=N?.name??"workspace",s=N?.version??"0.0.0",a=k(r,s),i={"bom-ref":a,name:r,purl:a,type:"application",version:s};return X(i,N),i})(),K=Z["bom-ref"],pe=K?v.filter(r=>r["bom-ref"]!==K):v;return{$schema:Ze,bomFormat:Ye,components:[...pe,...H],dependencies:G,metadata:{component:Z,lifecycles:[{phase:"build"}],timestamp:c.toISOString(),tools:{components:[{name:Ke,type:"application",...t?{version:t}:{}}]}},serialNumber:y??`urn:uuid:${ke()}`,specVersion:He,version:1}},"buildCycloneDxBom"),sn=m(e=>{const n={version:e.version??1,xmlns:"http://cyclonedx.org/schema/bom/1.6"};e.serialNumber&&(n.serialNumber=e.serialNumber);const t=[];return e.metadata&&t.push(rn(e.metadata)),e.components&&e.components.length>0&&t.push({_content:e.components.map(z),_name:"components"}),e.dependencies&&e.dependencies.length>0&&t.push({_content:e.dependencies.map(an),_name:"dependencies"}),`${we({_attrs:n,_content:t,_name:"bom"},{header:!0,indent:" ",selfCloseTags:!0})}
2
+ `},"serializeBomToXml"),rn=m(e=>{const n=[];return e.timestamp&&n.push({timestamp:e.timestamp}),e.lifecycles&&e.lifecycles.length>0&&n.push({_content:e.lifecycles.map(t=>{const o=[];return t.phase&&o.push({phase:t.phase}),t.name&&o.push({name:t.name}),t.description&&o.push({description:t.description}),{_content:o,_name:"lifecycle"}}),_name:"lifecycles"}),e.tools?.components&&n.push({_content:[{_content:e.tools.components.map(z),_name:"components"}],_name:"tools"}),e.component&&n.push(z(e.component)),{_content:n,_name:"metadata"}},"metadataToXmlElement"),z=m(e=>{const n={type:e.type};e["bom-ref"]&&(n["bom-ref"]=e["bom-ref"]);const t=[];e.group&&t.push({group:e.group}),t.push({name:e.name}),e.version&&t.push({version:e.version}),e.description&&t.push({description:e.description}),e.author&&t.push({author:e.author}),e.hashes&&e.hashes.length>0&&t.push({_content:e.hashes.map(c=>({_attrs:{alg:c.alg},_content:c.content,_name:"hash"})),_name:"hashes"});const o=cn(e.licenses);return o&&t.push(o),e.purl&&t.push({purl:e.purl}),e.scope&&t.push({scope:e.scope}),e.externalReferences&&e.externalReferences.length>0&&t.push({_content:e.externalReferences.map(c=>({_attrs:{type:c.type},_content:[{url:c.url}],_name:"reference"})),_name:"externalReferences"}),{_attrs:n,_content:t,_name:"component"}},"componentToXmlElement"),cn=m(e=>{if(!e||e.length===0)return;const n=[];for(const t of e){if("expression"in t){n.push({expression:t.expression});continue}const o=[];"id"in t.license&&t.license.id?o.push({id:t.license.id}):"name"in t.license&&t.license.name&&o.push({name:t.license.name}),n.push({_content:o,_name:"license"})}return{_content:n,_name:"licenses"}},"licensesToXmlElement"),an=m(e=>e.dependsOn&&e.dependsOn.length>0?{_attrs:{ref:e.ref},_content:e.dependsOn.map(n=>({_attrs:{ref:n},_name:"dependency"})),_name:"dependency"}:{_attrs:{ref:e.ref},_name:"dependency"},"dependencyToXmlElement");var pn=Object.defineProperty,ie=g((e,n)=>pn(e,"name",{value:n,configurable:!0}),"m");const ae=["json","xml"],ln=ie(e=>ae.includes(e),"isSbomFormat"),_n=ie(async({options:e,visConfig:n,workspaceRoot:t})=>{if(!t)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{packageJsons:o,workspace:c}=be(t,n),l=_e(t,c,o),y=e.focus,_=y?y.split(",").map(j=>j.trim()).filter(Boolean):void 0,f=(e.format??"json").toLowerCase();if(!ln(f))throw new Error(`Unknown --format: "${f}". Expected one of: ${ae.join(", ")}.`);const d=on({focus:_,includeDev:!!e.includeDev,projectGraph:l,workspace:c,workspaceRoot:t}),A=f==="xml"?sn(d):`${JSON.stringify(d,void 0,2)}
3
+ `,S=e.output??(f==="xml"?"sbom.cdx.xml":"sbom.cdx.json");if(S==="-"){process.stdout.write(A);return}const v=ye(t,S);ge(ve(v)),de(v,A,"utf8");const C=d.components?.length??0,R=d.dependencies?.length??0;Pe(`SBOM written to ${v}`),$e(`${C} components, ${R} dependency edges`)},"execute");export{_n as default};
@@ -0,0 +1,23 @@
1
+ var ae=Object.defineProperty;var y=(e,t)=>ae(e,"name",{value:t,configurable:!0});import{createRequire as le}from"node:module";import K from"@visulima/colorize";import{isAccessibleSync as D,readJsonSync as de,writeFileSync as ue,readFileSync as fe}from"@visulima/fs";import{isAbsolute as C,relative as H,resolve as j,join as B}from"@visulima/path";import{fingerprint as k,listRules as Q,listRequiredValidators as pe,scan as X,scanFiles as ge,inspectRuleset as me}from"@visulima/secret-scanner";import{d as M,y as L,O as V,c as q,I as Z}from"../packem_shared/bin-BaZZ32BK.js";const ce=le(import.meta.url),F=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Y=y(e=>{if(typeof F<"u"&&F.versions&&F.versions.node){const[t,n]=F.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return F.getBuiltinModule(e)}return ce(e)},"__cjs_getBuiltinModule"),{pathToFileURL:ee}=Y("node:url"),{execFileSync:he}=Y("node:child_process");var $e=Object.defineProperty,A=y((e,t)=>$e(e,"name",{value:t,configurable:!0}),"s");const we=A((e,t)=>{if(!C(e))return e;const n=H(t,e);return n===""||n.startsWith("..")?e:n},"toRelative"),O=A((e,t)=>{const n=we(e.file,t);return n===e.file?e:{...e,file:n}},"toRelativeFinding"),te=A(e=>{if(!D(e))return[];try{const t=de(e);return Array.isArray(t)?t:[]}catch{return[]}},"readBaseline"),ve=A((e,t,n)=>{const r=te(t).map(c=>O(c,n)),s=new Set(r.map(c=>k(c))),a=e.map(c=>O(c,n)),o=new Set(a.map(c=>k(c)));return{fresh:a.filter(c=>!s.has(k(c))),resolved:r.filter(c=>!o.has(k(c))),surviving:a.filter(c=>s.has(k(c)))}},"diffBaseline"),re=A((e,t,n,r={})=>{const s=e.map(o=>O(o,n));let a;if(r.replace)a=s;else{const o=te(t).map(i=>O(i,n)),c=new Set;a=[];for(const i of[...o,...s]){const l=k(i);c.has(l)||(c.add(l),a.push(i))}}return ue(t,`${JSON.stringify(a,null,4)}
2
+ `),a.length},"writeBaseline");var ye=Object.defineProperty,m=y((e,t)=>ye(e,"name",{value:t,configurable:!0}),"a$3");const{cyan:be,dim:z,green:Se,red:xe,yellow:ke}=K,U=1,je=m(e=>{const t=new Map;for(const n of e){const r=t.get(n.file);r?r.push(n):t.set(n.file,[n])}return t},"groupByFile"),Ce=m(e=>{try{return fe(e).split(/\r?\n/)}catch{return}},"loadLines"),Re=m((e,t,n)=>{const r=Math.max(1,t);return`${e.slice(0,r-1).replaceAll(/[^\t]/g," ")}${"^".repeat(Math.max(1,n))}`},"caretFor"),Fe=m((e,t,n)=>{if(e.length===0)return n?z("No secrets detected."):"No secrets detected.";const r=n?{cyan:be,dim:z,green:Se,red:xe,yellow:ke}:{cyan:m(o=>o,"cyan"),dim:m(o=>o,"dim"),green:m(o=>o,"green"),red:m(o=>o,"red"),yellow:m(o=>o,"yellow")},s=[],a=je(e);for(const[o,c]of a){const i=H(t,o)||o;s.push(r.cyan(i));const l=Ce(o);for(const d of c){const u=[d.source,d.confidence].filter(Boolean).join(", "),S=u?` ${r.dim(`(${u})`)}`:"",w=d.alternateMatches&&d.alternateMatches.length>0?` ${r.dim(`also: ${d.alternateMatches.join(", ")}`)}`:"";let p="";switch(d.validation){case"error":{p=` ${r.yellow("! error")}`;break}case"rejected":{p=` ${r.red("✗ rejected")}`;break}case"skipped":{p=` ${r.dim("— unverifiable")}`;break}case"verified":{p=` ${r.green("✓ verified")}`;break}}if(s.push(` ${r.red("✖")} ${r.yellow(`[${d.ruleId}]`)}${S}${p} ${r.dim(`line ${String(d.startLine)}:${String(d.startColumn)}`)}${w}`),l){const g=Math.max(0,d.startLine-1-U),v=Math.min(l.length,d.startLine+U);for(let h=g;h<v;h+=1){const $=String(h+1).padStart(4," "),R=h+1===d.startLine,se=R?r.red("▶"):" ";if(s.push(` ${se} ${r.dim($)} │ ${l[h]??""}`),R){const ie=Math.max(1,(d.endColumn??d.startColumn+1)-d.startColumn),oe=Re(l[h]??"",d.startColumn,ie);s.push(` ${r.dim(" │ ")}${r.red(oe)}`)}}}s.push("")}}return s.join(`
3
+ `).trimEnd()},"formatText"),Te=m((e,t)=>{if(!C(e))return e.replaceAll("\\","/");try{return ee(e).toString()}catch{return`file://${j(t,e).replaceAll("\\","/")}`}},"toSarifUri"),Be=m((e,t=100)=>e.length<=t?e:`${e.slice(0,t-1).trimEnd()}…`,"shortText"),Me=m((e,t,n=process.cwd(),r=[])=>{const s=new Map(r.map(i=>[i.id,i])),a=new Set;for(const i of e)a.add(i.ruleId);const o=[...new Set([...s.keys(),...a])].sort((i,l)=>i.localeCompare(l)),c=new Map(o.map((i,l)=>[i,l]));return JSON.stringify({$schema:"https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0.json",runs:[{originalUriBaseIds:{SRCROOT:{uri:ee(n).toString()}},results:e.map(i=>{const l={};return i.source&&(l.source=i.source),i.confidence&&(l.confidence=i.confidence),i.alternateMatches&&i.alternateMatches.length>0&&(l.alternateRules=i.alternateMatches),i.validation&&(l.validation=i.validation),{level:"error",locations:[{physicalLocation:{artifactLocation:{uri:Te(i.file,n),uriBaseId:C(i.file)?void 0:"SRCROOT"},region:{endColumn:i.endColumn,endLine:i.endLine,snippet:{text:i.match},startColumn:i.startColumn,startLine:i.startLine}}}],message:{text:i.description||i.ruleId},properties:Object.keys(l).length>0?l:void 0,ruleId:i.ruleId,ruleIndex:c.get(i.ruleId)??-1}}),tool:{driver:{informationUri:"https://visulima.com/packages/secret-scanner",name:"visulima-secret-scanner",rules:o.map(i=>{const l=s.get(i),d=l?.description??`Detected by rule \`${i}\``,u={};return l?.tags&&l.tags.length>0&&(u.tags=l.tags),l?.source&&(u.source=l.source),l?.confidence&&(u.confidence=l.confidence),{defaultConfiguration:{level:"error"},fullDescription:{text:d},helpUri:"https://visulima.com/packages/secret-scanner",id:i,name:i,properties:Object.keys(u).length>0?u:void 0,shortDescription:{text:Be(d)}}}),version:t}}}],version:"2.1.0"},void 0,2)},"formatSarif");var Oe=Object.defineProperty,I=y((e,t)=>Oe(e,"name",{value:t,configurable:!0}),"n");const N=I((e,t)=>{try{return he("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim()}catch{return""}},"runGit"),_=I(e=>e.split(/\r?\n/).map(t=>t.trim()).filter(Boolean),"splitFiles"),Ae=I(e=>_(N(e,["diff","--cached","--name-only","--diff-filter=ACMR"])).map(t=>C(t)?t:B(e,t)),"stagedFiles"),J=I((e,t)=>{const n=N(e,["diff","--name-only","--diff-filter=ACMR",`${t}...HEAD`]),r=_(n);if(r.length===0){const s=N(e,["diff","--name-only","--diff-filter=ACMR",t]);return _(s).map(a=>C(a)?a:B(e,a))}return r.map(s=>C(s)?s:B(e,s))},"filesSince"),P=I(e=>N(e,["rev-parse","--show-toplevel"]).length>0,"hasGit");var Ie=Object.defineProperty,x=y((e,t)=>Ie(e,"name",{value:t,configurable:!0}),"r");const G=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],ne=x(e=>{if(!(typeof process.stderr.isTTY=="boolean"&&process.stderr.isTTY))return{stop:x(()=>{},"stop"),update:x(()=>{},"update")};let t=e,n=0;const r=x(()=>{process.stderr.write(`\r${G[n%G.length]} ${t}`),n+=1},"render");r();const s=setInterval(r,80);return s.unref?.(),{stop:x(a=>{clearInterval(s),process.stderr.write("\r\x1B[2K"),a&&process.stderr.write(`${a}
4
+ `)},"stop"),update:x(a=>{t=a},"update")}},"startSpinner");var qe=Object.defineProperty,f=y((e,t)=>qe(e,"name",{value:t,configurable:!0}),"a");const{dim:b,green:Le,yellow:E}=K,T=".secrets-baseline.json",W=f(e=>e?Array.isArray(e)?e:[e]:[],"toArray"),Ne=f(e=>{const t=new Set(["json","sarif","text"]);return e&&!t.has(e)&&(M(`--format must be one of: ${[...t].join(", ")} (got "${e}")`),process.exit(2)),e??"text"},"validateFormat"),Pe=f(e=>{if(e===void 0)return;const t=new Set(["high","low","medium"]);return t.has(e)||(M(`--min-confidence must be one of: ${[...t].join(", ")} (got "${e}")`),process.exit(2)),e},"validateConfidence"),_e=f(async(e,t)=>{const n=await Q(e);process.stdout.write(`${String(n.length)} rules loaded
5
+
6
+ `);for(const r of n){const s=t?E(r.id):r.id,a=r.tags.length>0?` ${t?b(`[${r.tags.join(", ")}]`):`[${r.tags.join(", ")}]`}`:"";if(process.stdout.write(`${s}${a}
7
+ ${r.description}
8
+ `),r.keywords.length>0){const o=`keywords: ${r.keywords.slice(0,6).join(", ")}${r.keywords.length>6?", ...":""}`;process.stdout.write(` ${t?b(o):o}
9
+ `)}process.stdout.write(`
10
+ `)}},"printListRules"),De=f(async(e,t)=>{const n=await pe(e);if(n.length===0){process.stdout.write(t?`${b("No non-HTTP validators required by the current ruleset.")}
11
+ `:`No non-HTTP validators required by the current ruleset.
12
+ `);return}process.stdout.write(`${String(n.length)} non-HTTP validator type(s) referenced by the current ruleset:
13
+
14
+ `);for(const r of n){const s=t?E(r.displayName):r.displayName,a=`(${r.type}, ${String(r.ruleCount)} rule${r.ruleCount===1?"":"s"})`;process.stdout.write(`${s} ${t?b(a):a}
15
+ `),process.stdout.write(` ${r.summary}
16
+ `);const o=r.packageName?`install: npm add ${r.packageName}`:"no driver — bespoke implementation required";process.stdout.write(` ${t?b(o):o}
17
+
18
+ `)}},"printListValidators"),He=f(async(e,t,n)=>{const r=B(e,T);!n&&D(r)&&(L(`Detected existing ${T} — refusing to overwrite. Delete it first to re-init.`),process.exit(1)),V(n?"[dry-run] Previewing init — no files will be written.":"Scanning workspace to seed baseline…");const s=ne("scanning");let a;try{a=await X([e],t)}finally{s.stop()}if(n){V(`[dry-run] Would create ${T} with ${String(a.length)} finding(s).`);return}const o=re(a,r,e,{replace:!0});q(`Wrote ${T} (${String(o)} findings).`),Z("Commit it. Use `vis secrets --baseline .secrets-baseline.json` in CI. Add path patterns to .gitignore to exclude directories from scanning.")},"runInit"),Ee=f((e,t,n)=>{const r=t??{},s=f(g=>g?j(n,g):void 0,"resolvePath"),a=f((g,v)=>{const h=W(g);return h.length>0?h:v},"pickList"),o=a(e.enableRule,r.rules?.enable),c=a(e.excludeRule,r.rules?.exclude),i=a(e.includeRule,r.rules?.include),l=a(e.exclude,r.walk?.excludePatterns),d=W(e.excludeFrom).map(g=>j(n,g)),u=d.length>0?d:r.walk?.excludeFromFiles?.map(g=>j(n,g)),S=s(e.baseline)??s(r.baseline),w=s(e.config)??s(r.config?.path),p=Pe(e.minConfidence??r.config?.minConfidence);return{baseline:S,concurrency:e.concurrency,config:{extendBundled:e.noExtendBundled?!1:r.config?.extendBundled,inline:r.config?.inline,minConfidence:p,onlyVerified:e.onlyVerified??r.config?.onlyVerified??!1,path:w,validate:e.validate??r.config?.validate??!1},redact:e.redact??r.redact,rules:{enable:o,exclude:c,include:i},verbose:e.verbose??!1,walk:{excludeFromFiles:u,excludePatterns:l,gitignore:e.noGitignore?!1:r.walk?.gitignore??!0,includeHidden:e.includeHidden??r.walk?.includeHidden,maxFileSize:e.maxSize??r.walk?.maxFileSize}}},"resolveScanOptions"),Ve=f(e=>{process.stderr.write(`${b("baseline diff: ")}${Le(`+${String(e.fresh.length)} new`)} · ${E(`${String(e.surviving.length)} unchanged`)} · ${b(`-${String(e.resolved.length)} resolved`)}
19
+ `)},"printDiff"),ze=f(async(e,t,n)=>{if(e.staged)return P(n)||(M("--staged requires a git working tree, and none was detected."),process.exit(2)),{files:Ae(n)};if(e.since)return P(n)||(M("--since requires a git working tree, and none was detected."),process.exit(2)),{files:J(n,e.since)};if(e.affected){if(!P(n))return L("--affected requires git; falling back to full scan"),{paths:t&&t.length>0?t.map(s=>j(n,s)):[n]};const r=process.env.VIS_BASE??"HEAD~1";return{files:J(n,r)}}return{paths:t&&t.length>0?t.map(r=>j(n,r)):[n]}},"chooseScanPaths"),Ue=f((e,t,n,r,s,a)=>{switch(t){case"json":{const o=e.map(c=>O(c,n));process.stdout.write(`${JSON.stringify(o,null,2)}
20
+ `);break}case"sarif":{process.stdout.write(`${Me(e,s,n,a)}
21
+ `);break}default:process.stdout.write(`${Fe(e,n,r)}
22
+ `)}},"emitFindings"),Ze=f(async({argument:e,options:t,visConfig:n,workspaceRoot:r})=>{const s=t,a=e,o=r??process.cwd(),c=!s.quiet&&process.stdout.isTTY,i=n?.secrets,l=Ee(s,i,o),d="0.0.0-alpha";if(s.listRules){await _e(l,c);return}if(s.listValidators){await De(l,c);return}if(s.init){await He(o,l,s.dryRun??!1);return}const u=await ze(s,a??[],o);if(u.files?.length===0){s.quiet||q("No files to scan.");return}const S=!s.quiet&&!["json","sarif"].includes(s.format??"text")?ne("scanning for secrets"):{stop:f(()=>{},"stop"),update:f(()=>{},"update")};let w;try{w=u.files===void 0?await X(u.paths??[o],l):await ge(u.files,l)}catch($){S.stop(),M(`secret scan failed: ${$ instanceof Error?$.message:String($)}`),process.exit(2)}finally{S.stop()}if(s.verbose){const $=await me(l);if($.length>0){L(`${String($.length)} rule(s) skipped due to invalid regex. First few:`);for(const R of $.slice(0,5))process.stderr.write(` - ${R.ruleId}: ${R.reason}
23
+ `)}}const p=l.baseline??B(o,T),g=!s.quiet&&D(p);if(s.updateBaseline){const $=re(w,p,o,{replace:s.replaceBaseline});q(`Baseline updated: ${H(o,p)||p} now contains ${String($)} entries.`);return}const v=Ne(s.format),h=v==="sarif"?await Q(l).catch(()=>[]):[];Ue(w,v,o,c,d,h),v==="text"&&g&&Ve(ve(w,p,o)),w.length>0&&(s.quiet||(L(`${String(w.length)} potential secret(s) found`),Z("Suppress individual lines with `gitleaks:allow` / `secret-scanner:allow`, or run `vis secrets --update-baseline`.")),process.exit(1)),s.quiet||q("No secrets detected.")},"execute");export{Ze as default};
@@ -0,0 +1,5 @@
1
+ var N=Object.defineProperty;var $=(e,t)=>N(e,"name",{value:t,configurable:!0});import{createRequire as A}from"node:module";import{isAccessibleSync as k,readFileSync as v}from"@visulima/fs";import{resolve as I,join as h,relative as P,basename as B}from"@visulima/path";import F from"zeptomatch";import{sortPackageJsonStringWithOptions as C}from"#native";import{D as M,B as w,d as O,O as y,y as T,c as q}from"../packem_shared/bin-BaZZ32BK.js";import{f as b}from"../packem_shared/utils-DrNg0XTR.js";const E=A(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,x=$(e=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[t,o]=u.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return u.getBuiltinModule(e)}return E(e)},"__cjs_getBuiltinModule"),{writeFileSync:J}=x("node:fs");var L=Object.defineProperty,a=$((e,t)=>L(e,"name",{value:t,configurable:!0}),"c");const R=a(e=>{const t=new Set,o=[],i=a(n=>{const s=I(n);!t.has(s)&&k(s)&&(t.add(s),o.push(s))},"addFile");i(h(e,"package.json"));const r=M(e);if(r){const n=w(e,r);for(const s of n)i(h(e,s,"package.json"))}else{const n=h(e,"package.json");if(k(n)){const s=JSON.parse(v(n)),l=Array.isArray(s.workspaces)?s.workspaces:s.workspaces?.packages;if(l){const g=w(e,l);for(const f of g)i(h(e,f,"package.json"))}}}return o},"findPackageJsonFiles"),D=a(e=>/\n([ \t]+)/.exec(e)?.[1]??" ","detectIndent"),U=a(e=>{if(!(e===void 0||e===""))return e==="tab"||e===String.raw`\t`?" ":/^\d+$/.test(e)?" ".repeat(Number.parseInt(e,10)):e},"resolveIndentOverride"),j=a(e=>e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(t=>t.split(",")).map(t=>t.trim()).filter(t=>t.length>0),"splitList"),W=a(e=>e.includes(`\r
2
+ `)?"crlf":"lf","detectLineEnding"),z=new Set(["auto","crlf","lf"]),G=a(e=>{if(e===void 0||e==="")return"auto";if(z.has(e))return e;O(`--line-ending must be one of: auto, lf, crlf (got "${e}")`),process.exit(2)},"validateLineEnding"),V=a((e,t,o)=>t.length===0?e:e.filter(i=>{const r=P(o,i),n=B(i);return!t.some(s=>{const l=s.includes("/")?r:n;return F(s,l)})}),"filterByIgnore"),H=a((e,t)=>{if(t.length===0)return e;const o={},i=new Set;for(const r of t)Object.hasOwn(e,r)&&(o[r]=e[r],i.add(r));for(const r of Object.keys(e))i.has(r)||(o[r]=e[r]);return o},"applySortOrder"),K=a((e,t,o)=>{if(o.length===0)return e;const i={...e};for(const r of o)Object.hasOwn(t,r)&&(i[r]=t[r]);return i},"restoreUnsortedSections"),Q=a((e,t)=>{const o=t.indent??D(e),i=t.lineEnding==="auto"?W(e):t.lineEnding,r=C(e,{pretty:!1,sortScripts:t.sortScripts});let n=JSON.parse(r);if(t.unsorted.length>0){const l=JSON.parse(e);n=K(n,l,t.unsorted)}n=H(n,t.sortOrder);let s=JSON.stringify(n,null,o);return t.finalNewline&&(s+=`
3
+ `),i==="crlf"&&(s=s.replaceAll(`
4
+ `,`\r
5
+ `)),s},"sortContents"),ie=a(async({options:e,visConfig:t,workspaceRoot:o})=>{const i=o??process.cwd(),r=t?.sortPackageJson,n=e.check||!1,s={finalNewline:e.finalNewline??r?.finalNewline??!0,ignore:[...j(e.ignore),...r?.ignore??[]],indent:U(e.indent??r?.indent),lineEnding:G(e.lineEnding??r?.lineEnding),sortOrder:[...j(e.sortOrder),...r?.sortOrder??[]],sortScripts:e.sortScripts||r?.sortScripts||!1,unsorted:[...j(e.unsorted),...r?.unsorted??[]]},l=R(i),g=V(l,s.ignore,i);if(g.length===0){y(l.length===0?"No package.json files found.":"All package.json files were excluded by --ignore.");return}let f=0,d=0,p=0;for(const c of g)try{const m=v(c);let S;try{S=Q(m,s)}catch(_){O(`${c}: ${b(_)}`),p++;continue}if(m===S){d++;continue}f++,n?T(`${c} is not sorted`):(J(c,S,"utf8"),q(`Sorted ${c}`))}catch(m){O(`${c}: ${b(m)}`),p++}if(n)f>0?(y(`${f} file${f===1?"":"s"} not sorted, ${d} already sorted`),process.exitCode=1):y(`All ${d} package.json file${d===1?" is":"s are"} sorted`);else{const c=[];f>0&&c.push(`sorted ${f} file${f===1?"":"s"}`),d>0&&c.push(`${d} already sorted`),p>0&&c.push(`${p} error${p===1?"":"s"}`),y(c.join(", "))}p>0&&(process.exitCode=1)},"execute");export{ie as default};
@@ -0,0 +1,27 @@
1
+ var Ee=Object.defineProperty;var f=(e,t)=>Ee(e,"name",{value:t,configurable:!0});import{createRequire as Ae}from"node:module";import{isAccessibleSync as re,isFsCaseSensitive as je}from"@visulima/fs";import{isAbsolute as Fe,join as X,relative as D,basename as ve}from"@visulima/path";import{execa as ye}from"execa";import ke from"zeptomatch";import{jsx as k,jsxs as x}from"react/jsx-runtime";import{Spinner as Ne,Text as S,Box as A,render as Ge}from"@visulima/tui";import{C as be,D as B,T as Te}from"../packem_shared/symbols-CIMw60-G.js";import _e from"@visulima/colorize";const Me=Ae(import.meta.url),F=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,we=f(e=>{if(typeof F<"u"&&F.versions&&F.versions.node){const[t,r]=F.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return F.getBuiltinModule(e)}return Me(e)},"__cjs_getBuiltinModule"),{readFileSync:Oe,writeFileSync:Pe,unlinkSync:Re}=we("node:fs"),{availableParallelism:se}=we("node:os");var De=Object.defineProperty,He=f((e,t)=>De(e,"name",{value:t,configurable:!0}),"s$5");class O extends Error{static{f(this,"StagedError")}static{He(this,"StagedError")}constructor(t,r){super(t,r),this.name=this.constructor.name}}var Le=Object.defineProperty,Be=f((e,t)=>Le(e,"name",{value:t,configurable:!0}),"o$6");class Ue extends O{static{f(this,"ApplyEmptyCommitError")}static{Be(this,"ApplyEmptyCommitError")}}var qe=Object.defineProperty,Ve=f((e,t)=>qe(e,"name",{value:t,configurable:!0}),"o$5");class b extends O{static{f(this,"ConfigError")}static{Ve(this,"ConfigError")}}var ze=Object.defineProperty,We=f((e,t)=>ze(e,"name",{value:t,configurable:!0}),"t$1");class ne extends O{static{f(this,"GetBackupStashError")}static{We(this,"GetBackupStashError")}}var Ke=Object.defineProperty,Ye=f((e,t)=>Ke(e,"name",{value:t,configurable:!0}),"s$4");class _ extends O{static{f(this,"GitError")}static{Ye(this,"GitError")}stderr;constructor(t,r,n){super(t,n),this.stderr=r}}var Je=Object.defineProperty,Qe=f((e,t)=>Je(e,"name",{value:t,configurable:!0}),"e");class ae extends O{static{f(this,"RestoreOriginalStateError")}static{Qe(this,"RestoreOriginalStateError")}}var Xe=Object.defineProperty,Ze=f((e,t)=>Xe(e,"name",{value:t,configurable:!0}),"o$2");class M extends O{static{f(this,"TaskError")}static{Ze(this,"TaskError")}commandTitle;constructor(t,r,n){super(r,n),this.commandTitle=t}}var et=Object.defineProperty,q=f((e,t)=>et(e,"name",{value:t,configurable:!0}),"i");const tt=q(async e=>{if(e.config!==void 0)return e.config;throw new b(`No staged config provided. Add \`staged\` to your vis.config.ts:
2
+
3
+ import { defineConfig } from "@visulima/vis/config";
4
+
5
+ export default defineConfig({
6
+ staged: { "*.ts": "eslint --fix" },
7
+ });
8
+
9
+ Coming from lint-staged or nano-staged? Run \`vis migrate lint-staged\` (or \`vis migrate nano-staged\`) to move the config in and remove the legacy files.`)},"resolveConfig"),ie=q(e=>{if(typeof e!="object"||e===null)throw new b("Staged config must be an object mapping glob patterns to tasks.");const t=Object.entries(e);if(t.length===0)throw new b("Staged config is empty — at least one glob pattern is required.");for(const[r,n]of t){if(!r||r.trim()==="")throw new b("Staged config keys must be non-empty glob patterns.");Se(r,n)}return e},"validateConfig"),Se=q((e,t)=>{if(typeof t=="string"){if(t.trim()==="")throw new b(`Task for "${e}" is an empty string.`);return}if(Array.isArray(t)){if(t.length===0)throw new b(`Task array for "${e}" is empty.`);for(const r of t)Se(e,r);return}if(typeof t!="function"&&!rt(t))throw new b(`Invalid task for "${e}" — expected string, string[], function, or { title, task } object.`)},"validateTask"),rt=q(e=>typeof e=="object"&&e!==null&&typeof e.title=="string"&&typeof e.task=="function","isCustomTask");var st=Object.defineProperty,$=f((e,t)=>st(e,"name",{value:t,configurable:!0}),"n$1");const oe=2048,g=$(async(e,t)=>{const r=await ye("git",[...e],{cwd:t.cwd,env:t.env?{...process.env,...t.env}:void 0,input:t.input,reject:!1,stderr:"pipe",stdin:t.input===void 0?"ignore":"pipe",stdout:"pipe"}),n=typeof r.exitCode=="number"?r.exitCode:1;if(n!==0&&!t.lenient){const s=typeof r.stderr=="string"?r.stderr:"",i=s.length>oe?`${s.slice(0,oe)}…`:s;throw new _(`git ${e.join(" ")} failed with exit code ${n}: ${i.trim()}`,s)}return{exitCode:n,stderr:typeof r.stderr=="string"?r.stderr:"",stdout:typeof r.stdout=="string"?r.stdout:""}},"git"),R=$(async(e,t)=>{const{stdout:r}=await g(e,t);return r.trim()},"gitOut"),nt=$(async e=>{const t=await g(["rev-parse","--is-inside-work-tree"],{cwd:e,lenient:!0});return t.exitCode===0&&t.stdout.trim()==="true"},"isGitRepo"),at=$(async e=>R(["rev-parse","--absolute-git-dir"],{cwd:e}),"getGitDirectory"),$e=$(async e=>R(["rev-parse","--show-toplevel"],{cwd:e}),"getWorkTree"),ce=$(async e=>R(["write-tree"],{cwd:e}),"writeIndexTree"),it=$(async e=>{const t=await g(["rev-parse","HEAD^{tree}"],{cwd:e,lenient:!0});return t.exitCode===0?t.stdout.trim():""},"headTreeSha"),N={major:2,minor:32},ot=$(e=>{const t=/git version (\d+)\.(\d+)/.exec(e);if(!t)return null;const r=Number.parseInt(t[1]??"",10),n=Number.parseInt(t[2]??"",10);return Number.isNaN(r)||Number.isNaN(n)?null:{major:r,minor:n}},"parseGitVersion"),ct=$(async e=>{const t=ot(await R(["--version"],{cwd:e}));if(t!==null&&(t.major<N.major||t.major===N.major&&t.minor<N.minor))throw new _(`Git ${N.major}.${N.minor} or newer is required; found ${t.major}.${t.minor}.`)},"assertGitVersion");var dt=Object.defineProperty,I=f((e,t)=>dt(e,"name",{value:t,configurable:!0}),"a$2");const lt="ACMR",de=500,ut=I(async e=>{const{stdout:t}=await g(["diff-files","--raw","-z"],{cwd:e}),r=t.split("\0").filter(s=>s.length>0),n=[];for(let s=0;s<r.length;s+=1){const i=r[s];if(!i?.startsWith(":"))continue;const o=i.slice(1).split(" "),a=o[3],c=o[4],l=r[s+1];s+=1,c==="A"&&a!==void 0&&/^0+$/.test(a)&&l!==void 0&&n.push(l)}return n},"getIntentToAddPaths"),le=I(async e=>{const{stdout:t}=await g(["ls-files","--others","--exclude-standard","-z"],{cwd:e});return t.split("\0").filter(r=>r.length>0)},"getUntrackedFiles"),ft=I(async(e,t)=>{if(e.length===0)return;const r=`${e.join("\0")}\0`;await g(["rm","--cached","--quiet","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:t.cwd,input:r})},"removeFromIndex"),ht=I(async e=>{const t=e.diffFilter??lt,r=e.diff===void 0?["diff","--name-only","-z",`--diff-filter=${t}`,"--staged"]:["diff","--name-only","-z",`--diff-filter=${t}`,...e.diff.split(/\s+/).filter(Boolean)],{stdout:n}=await g(r,{cwd:e.cwd}),s=n.split("\0").filter(o=>o.length>0);if(s.length===0)return[];const i=e.workTree??await $e(e.cwd);return s.map(o=>Fe(o)?o:X(i,o))},"getFiles"),pt=I(async(e,t)=>{if(e.length===0)return null;const r=[];for(let i=0;i<e.length;i+=de){const o=e.slice(i,i+de),{stdout:a}=await g(["diff","--binary","--unified=0","--no-color","--no-ext-diff","--src-prefix=a/","--dst-prefix=b/","--patch","--submodule=short","--",...o],{cwd:t.cwd});a.length>0&&r.push(a)}if(r.length===0)return null;const n=r.join(""),s=n.endsWith(`
10
+ `)?n:`${n}
11
+ `;return Buffer.from(s,"utf8")},"capturePatch"),gt=I(async e=>{const{stdout:t}=await g(["status","--porcelain=v1","-z"],{cwd:e}),r=t.split("\0"),n=[];for(let s=0;s<r.length;s+=1){const i=r[s];if(i===void 0||i.length<4)continue;const o=i.charAt(0),a=i.charAt(1),c=i.slice(3),l=o==="R"||o==="C"||a==="R"||a==="C";o!==" "&&o!=="?"&&a!==" "&&a!=="?"&&n.push(c),l&&(s+=1)}return n},"getPartiallyStagedFiles"),mt=I(async(e,t)=>{if(e.length===0)return;const r=`${e.join("\0")}\0`;await g(["checkout","--force","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:t.cwd,input:r})},"checkoutPaths"),wt=I(async(e,t)=>{if(await g(["update-index","--again"],{cwd:t.cwd,lenient:!0}),e.length===0)return;const r=`${e.join("\0")}\0`;await g(["add","-u","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:t.cwd,input:r})},"updateIndexAgain");var vt=Object.defineProperty,P=f((e,t)=>vt(e,"name",{value:t,configurable:!0}),"r$1");const yt="vis_staged_automatic_backup",xe=P(()=>`${yt}-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,"buildMessage"),kt=P(async e=>{const t=await R(["stash","create"],{cwd:e});return t.length===0?null:(await g(["stash","store","-m",xe(),t],{cwd:e}),t)},"createBackupStash"),bt=P(async e=>{const t=xe(),{exitCode:r,stdout:n}=await g(["stash","push","--keep-index","--include-untracked","--quiet","-m",t],{cwd:e,lenient:!0});if(r!==0)return null;const s=n.trim();return s.length>0&&/no local changes/i.test(s)?null:R(["rev-parse","stash@{0}"],{cwd:e})},"createHideAllStash"),ee=P(async(e,t)=>{const{exitCode:r,stdout:n}=await g(["reflog","--format=%H %gd","refs/stash"],{cwd:e,lenient:!0});if(r!==0)return null;for(const s of n.split(/\r?\n/)){const[i,o]=s.split(/\s+/,2);if(i===t&&o!==void 0)return o}return null},"findStashRefBySha"),ue=P(async(e,t)=>{if(t===null)return;const r=await ee(e,t);r!==null&&await g(["stash","drop","--quiet",r],{cwd:e})},"dropBackupStash"),Tt=P(async(e,t)=>{if(t===null)throw new ne("Backup stash was not found — can't revert working tree.");const r=await ee(e,t);if(r===null)throw new ne(`Backup stash ${t} is no longer reachable — can't revert working tree.`);await g(["reset","--hard","HEAD"],{cwd:e}),await g(["stash","apply","--index","--quiet",r],{cwd:e})},"applyBackupStash"),St=P(async(e,t)=>{if(t===null)return;const r=await ee(e,t);r!==null&&await g(["stash","pop","--quiet",r],{cwd:e})},"popHideAllStash");var $t=Object.defineProperty,xt=f((e,t)=>$t(e,"name",{value:t,configurable:!0}),"l");class Ct{static{f(this,"GitWorkflow")}static{xt(this,"GitWorkflow")}stagedFiles=[];partiallyStaged=[];workTree="";gitDir="";preTaskIndexTree="";postTaskIndexTree="";headTree="";revertApplied=!1;warnings=[];cwd;options;patch=null;backupStashSha=null;merge=[];shouldStash;shouldHidePartial;shouldHideUnstaged;shouldHideAll;hideAllStashSha=null;intentToAddPaths=[];preTaskUntracked=new Set;constructor(t){this.cwd=t.cwd??process.cwd(),this.options=t,this.shouldStash=t.stash!==!1&&t.diff===void 0,this.shouldHidePartial=t.hidePartiallyStaged!==!1,this.shouldHideUnstaged=t.hideUnstaged===!0,this.shouldHideAll=t.hideAll===!0}async prepare(){if(!await nt(this.cwd))throw new _(`Not a git repository: ${this.cwd}`);await ct(this.cwd),this.workTree=await $e(this.cwd),this.gitDir=await at(this.cwd),this.stagedFiles=await ht({cwd:this.cwd,diff:this.options.diff,diffFilter:this.options.diffFilter,workTree:this.workTree}),this.partiallyStaged=this.stagedFiles.length===0?[]:await gt(this.cwd),this.snapshotMergeState(),this.intentToAddPaths=await ut(this.workTree),this.intentToAddPaths.length>0&&await ft(this.intentToAddPaths,{cwd:this.workTree}),this.shouldStash?this.backupStashSha=await kt(this.workTree):this.partiallyStaged.length>0&&this.warnings.push("Running with --no-stash on partially-staged files — unstaged deltas will be captured to a patch, but if re-applying the patch fails after tasks run the changes cannot be recovered."),this.shouldHideAll?this.hideAllStashSha=await bt(this.workTree):await this.hideUnstagedChanges(),this.preTaskIndexTree=this.stagedFiles.length===0?"":await ce(this.workTree),this.postTaskIndexTree=this.preTaskIndexTree,this.headTree=await it(this.workTree),this.preTaskUntracked=new Set(await le(this.workTree))}async applyModifications({autoStage:t=!1}={}){if(this.stagedFiles.length===0)return;const r=this.stagedFiles.map(n=>D(this.workTree,n));if(await wt(r,{cwd:this.workTree}),t){const n=(await le(this.workTree)).filter(s=>!this.preTaskUntracked.has(s));if(n.length>0){const s=`${n.join("\0")}\0`;await g(["add","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:this.workTree,input:s})}}if(this.intentToAddPaths.length>0)try{await g(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.postTaskIndexTree=await ce(this.workTree)}indexTreeChanged(){return this.preTaskIndexTree.length>0&&this.postTaskIndexTree.length>0&&this.preTaskIndexTree!==this.postTaskIndexTree}postTaskIndexMatchesHead(){return this.postTaskIndexTree.length>0&&this.headTree.length>0&&this.postTaskIndexTree===this.headTree}async restoreUnstagedChanges(){if(this.revertApplied||this.patch===null||this.shouldHideAll)return;const t=["apply","--whitespace=nowarn","--recount","--unidiff-zero"];let r;try{await g(t,{cwd:this.workTree,input:this.patch});return}catch(n){r=n instanceof _?n.stderr:String(n)}try{await g([...t,"--3way"],{cwd:this.workTree,input:this.patch})}catch(n){const s=n instanceof _&&n.stderr?n.stderr:String(n);throw new ae(`Failed to re-apply unstaged changes after running tasks. Original changes remain in the backup stash — recover with \`git stash list\` and \`git stash apply\`.
12
+ First attempt: ${r??"(no stderr)"}
13
+ Second attempt: ${s}`,{cause:n})}}async revert(){if(this.backupStashSha!==null){try{await Tt(this.workTree,this.backupStashSha)}catch(t){throw new ae("Revert failed while restoring the backup stash. Use `git stash list` to recover manually.",{cause:t})}if(await ue(this.workTree,this.backupStashSha),this.intentToAddPaths.length>0)try{await g(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.revertApplied=!0}}async cleanup(t){if(this.restoreMergeState(),this.hideAllStashSha!==null)try{await St(this.workTree,this.hideAllStashSha)}catch{}t&&this.backupStashSha!==null&&!this.revertApplied&&await ue(this.workTree,this.backupStashSha)}recoveryHint(){return this.backupStashSha===null?null:`Backup stash is preserved (sha ${this.backupStashSha.slice(0,7)}) — restore with: git stash apply --index ${this.backupStashSha}`}async hideUnstagedChanges(){const t=new Set(this.stagedFiles.map(n=>D(this.workTree,n))),r=this.shouldHideUnstaged?[...t]:this.shouldHidePartial?this.partiallyStaged.filter(n=>t.has(n)):[];r.length!==0&&(this.patch=await pt(r,{cwd:this.workTree}),this.patch!==null&&await mt(r,{cwd:this.workTree}))}snapshotMergeState(){this.gitDir.length!==0&&(this.merge=["MERGE_HEAD","MERGE_MODE","MERGE_MSG"].map(t=>{const r=X(this.gitDir,t);return re(r)?{body:Oe(r),existed:!0,name:t}:{body:null,existed:!1,name:t}}))}restoreMergeState(){if(!(this.gitDir.length===0||this.merge.length===0))for(const t of this.merge){const r=X(this.gitDir,t.name);try{t.existed&&t.body!==null?Pe(r,t.body):re(r)&&Re(r)}catch{}}}}var It=Object.defineProperty,V=f((e,t)=>It(e,"name",{value:t,configurable:!0}),"r");const Ce=V(e=>e.includes("/"),"isPathStyle"),U=V((e,t)=>t?e.toLowerCase():e,"normalizeForMatch"),Et=V((e,t,r,n={})=>{const s=Ce(e),i=n.caseInsensitive===!0,o=U(e,i),a=[];for(const c of t){const l=s?D(r,c):ve(c);ke(o,U(l,i))&&a.push(c)}return a},"matchFiles"),At=V((e,t,r,n={})=>{if(!t||t.length===0)return[...e];const s=n.caseInsensitive===!0;return e.filter(i=>{for(const o of t){const a=Ce(o)?D(r,i):ve(i),c=U(o,s);if(ke(c,U(a,s)))return!1}return!0})},"applyIgnore");var Mt=Object.defineProperty,H=f((e,t)=>Mt(e,"name",{value:t,configurable:!0}),"g");const jt=H(e=>{switch(e){case"failed":return"red";case"running":return"cyan";case"skipped":return"yellow";case"success":return"green";default:return"gray"}},"colorForStatus"),fe=H(e=>{if(e==="running")return k(Ne,{type:"dots"});const t=e==="failed"?be:e==="skipped"?B:e==="success"?Te:B;return k(S,{color:jt(e),children:t})},"iconForStatus"),he=H(({state:e,tick:t,verbose:r})=>x(A,{flexDirection:"column",children:[[...e.patterns.values()].map(n=>x(A,{flexDirection:"column",children:[x(A,{children:[fe(n.status),x(S,{children:[" ",n.title]})]}),[...n.commands.values()].map(s=>x(A,{flexDirection:"column",marginLeft:2,children:[x(A,{children:[fe(s.status),x(S,{children:[" ",s.title," "]}),s.status!=="pending"&&s.status!=="running"?x(S,{color:"gray",children:["(",s.durationMs,"ms)"]}):null]}),r&&s.output?k(A,{flexDirection:"column",marginLeft:2,children:s.output.split(/\r?\n/).slice(0,20).map((i,o)=>k(S,{color:"gray",children:i},`${s.id}-line-${o}`))}):null,s.status==="failed"&&s.error?k(A,{marginLeft:2,children:k(S,{color:"red",children:s.error.message})}):null]},s.id))]},n.id)),e.infoMessages.map((n,s)=>k(S,{color:"gray",children:n},`info-${s}`)),e.warnMessages.map((n,s)=>k(S,{color:"yellow",children:n},`warn-${s}`)),e.errorMessages.map(({message:n},s)=>k(S,{color:"red",children:n},`err-${s}`))]}),"App"),Ot=H((e={})=>{const t=e.verbose===!0,r={errorMessages:[],infoMessages:[],patterns:new Map,started:!1,warnMessages:[]};let n=0;const s=Ge(k(he,{state:r,tick:n,verbose:t}),{exitOnCtrlC:!1,stdout:process.stderr}),i=H(()=>{n+=1,s.rerender(k(he,{state:r,tick:n,verbose:t}))},"refresh");return{commandEnd({commandId:o,durationMs:a,error:c,output:l,patternId:u,status:d}){const p=r.patterns.get(u)?.commands.get(o);p&&(p.status=d,p.durationMs=a,p.output=l,p.error=c,i())},commandStart({commandId:o,patternId:a}){const c=r.patterns.get(a)?.commands.get(o);c&&(c.status="running",i())},error({error:o,message:a}){r.errorMessages.push({error:o,message:a}),i()},info({message:o}){r.infoMessages.push(o),i()},patternEnd({patternId:o,status:a}){const c=r.patterns.get(o);c&&(c.status=a,i())},patternStart({patternId:o}){const a=r.patterns.get(o);a&&(a.status="running",i())},start({patterns:o}){r.started=!0;for(const a of o){const c=new Map;for(const l of a.commands)c.set(l.id,{durationMs:0,id:l.id,status:"pending",title:l.title});r.patterns.set(a.id,{commands:c,id:a.id,status:"pending",title:a.title})}i()},async stop(){s.unmount(),await s.waitUntilExit()},warn({message:o}){r.warnMessages.push(o),i()}}},"createInkRenderer");var Pt=Object.defineProperty,K=f((e,t)=>Pt(e,"name",{value:t,configurable:!0}),"a$1");const{cyan:Y,dim:C,green:Rt,red:J,yellow:pe}=_e,ge=K((e={})=>{const{quiet:t=!1,verbose:r=!1}=e,n=new Map,s=new Map,i=K(a=>{t||process.stderr.write(`${a}
14
+ `)},"print"),o=K(a=>{switch(a){case"failed":return J(be);case"running":return Y(">");case"skipped":return pe(B);case"success":return Rt(Te);default:return C(B)}},"iconFor");return{commandEnd({commandId:a,durationMs:c,error:l,output:u,status:d}){const p=s.get(a)??a,w=C(`(${c}ms)`);if(i(` ${o(d)} ${p} ${w}`),d==="failed"&&l&&i(C(l.message)),(d==="failed"||r)&&u&&u.trim().length>0)for(const h of u.split(/\r?\n/))i(` ${C(h)}`)},commandStart({commandId:a}){if(!r)return;const c=s.get(a)??a;i(` ${C("…")} ${c}`)},error({error:a,message:c}){t?process.stderr.write(`${J(c)}
15
+ `):i(J(c)),a?.stack&&(r||!t)&&process.stderr.write(`${C(a.stack)}
16
+ `)},info({message:a}){i(C(a))},patternEnd({patternId:a,status:c}){const l=n.get(a)??a;i(`${o(c)} ${l}`)},patternStart({patternId:a}){const c=n.get(a)??a;i(`${Y(">")} ${c}`)},start({patterns:a}){if(a.length===0){i(C("No staged files matched any pattern."));return}const c=new Set(a.flatMap(l=>l.files)).size;i(`${Y(">")} Running staged tasks on ${c} file${c===1?"":"s"} across ${a.length} pattern${a.length===1?"":"s"}`);for(const l of a){n.set(l.id,l.title);for(const u of l.commands)s.set(u.id,u.title)}},stop(){},warn({message:a}){i(pe(a))}}},"createPlainRenderer");var Ft=Object.defineProperty,Nt=f((e,t)=>Ft(e,"name",{value:t,configurable:!0}),"t");const Gt=Nt(async e=>{const{env:t}=process;if(e.debug===!0||e.quiet===!0||t.NODE_ENV==="test"||t.TERM==="dumb"||t.CI!==void 0||!process.stderr.isTTY)return ge({quiet:e.quiet,verbose:e.verbose});try{return Ot({verbose:e.verbose})}catch{return ge({quiet:e.quiet,verbose:e.verbose})}},"pickRenderer");var _t=Object.defineProperty,G=f((e,t)=>_t(e,"name",{value:t,configurable:!0}),"a");const Q=G(e=>typeof e=="object"&&e!==null&&typeof e.title=="string"&&typeof e.task=="function","isCustomTask"),Dt=G(async e=>{let t=0,r=0;const n=G(()=>(t+=1,`pattern-${t}`),"nextPatternId"),s=G(()=>(r+=1,`cmd-${r}`),"nextCommandId"),i=G(async(a,c,l)=>{if(typeof a=="string"){l.push({command:a,files:c,id:s(),source:"string",title:a});return}if(Array.isArray(a)){for(const u of a)await i(u,c,l);return}if(typeof a=="function"){const u=await a([...c]);if(typeof u=="string"){l.push({command:u,files:c,id:s(),source:"function",title:u});return}if(Array.isArray(u)){for(const d of u)if(typeof d=="string")l.push({command:d,files:c,id:s(),source:"function",title:d});else if(Q(d))l.push({files:c,id:s(),run:d.task,source:"custom",title:d.title});else throw new b("Task function returned an array with an unsupported entry — expected strings or { title, task }.");return}if(Q(u)){l.push({files:c,id:s(),run:u.task,source:"custom",title:u.title});return}throw new b("Task function returned an unsupported value — expected string, string[], or { title, task }.")}if(Q(a)){l.push({files:c,id:s(),run:a.task,source:"custom",title:a.title});return}throw new b("Unsupported task value — expected string, string[], function, or { title, task }.")},"expandTask"),o=[];for(const[a,c]of Object.entries(e.config)){const l=Et(a,e.files,e.cwd,{caseInsensitive:e.caseInsensitive===!0});if(l.length===0)continue;const u=e.relative?l.map(p=>D(e.cwd,p)):l,d=[];await i(c,u,d),d.length!==0&&o.push({commands:d,files:u,id:n(),pattern:a,title:`${a} — ${l.length} file${l.length===1?"":"s"}`})}return o},"buildTaskGraph");var Ht=Object.defineProperty,z=f((e,t)=>Ht(e,"name",{value:t,configurable:!0}),"d$1");const Lt=z(e=>{const t=[];let r="",n=!1,s=!1;for(let i=0;i<e.length;i+=1){const o=e[i];if(o===void 0)break;if(o==="\\"&&!n&&i+1<e.length){const a=e[i+1];if(a!==void 0){s&&a!=='"'&&a!=="\\"&&(r+=o),r+=a,i+=1;continue}}if(o==='"'&&!n){s=!s;continue}if(o==="'"&&!s){n=!n;continue}if(!n&&!s&&/\s/.test(o)){r.length>0&&(t.push(r),r="");continue}r+=o}if(n||s)throw new b(`Unterminated ${n?"single":"double"} quote in command: ${e}`);return r.length>0&&t.push(r),t},"parseCommandString"),Ie=process.platform==="win32"?28e3:131072,Bt=z((e,t,r)=>{const n=[];let s=[],i=t;const o=r<=0?Ie:r;for(const a of e){const c=Buffer.byteLength(a)+1;s.length>0&&i+c>o&&(n.push(s),s=[],i=t),s.push(a),i+=c}return s.length>0&&n.push(s),n},"chunkFiles"),Ut=z(async(e,t,r)=>{const n=Lt(e);if(n.length===0)throw new M(e,"Empty command for staged task.");const[s,...i]=n;if(s===void 0)throw new M(e,"Empty command for staged task.");const o=Buffer.byteLength(s)+i.reduce((u,d)=>u+Buffer.byteLength(d)+1,0),a=Bt(t,o,r.maxArgLength??Ie),c=Date.now(),l=[];for(const u of a){if(r.signal?.aborted===!0)throw new M(e,"Task aborted by earlier failure.");const d=await ye(s,[...i,...u],{cancelSignal:r.signal,cwd:r.cwd,env:qt(r.env),killSignal:r.killSignal??"SIGTERM",reject:!1,stderr:"pipe",stdout:"pipe"}),p=typeof d.stdout=="string"?d.stdout:"",w=typeof d.stderr=="string"?d.stderr:"",h=[p,w].filter(m=>m.length>0).join(`
17
+ `);if(h.length>0&&l.push(h),d.isCanceled||d.isTerminated||typeof d.exitCode!="number"){const m=d.isCanceled?"Task aborted by earlier failure.":d.isTerminated?`Task killed by signal ${d.signal??"(unknown)"}.`:h.trim()||"Task exited without a numeric status code.";throw new M(e,m)}if(d.exitCode!==0)throw new M(e,h.trim()||`Exit code ${d.exitCode} from ${s}`)}return{durationMs:Date.now()-c,output:l.join(`
18
+ `)}},"execCommand"),qt=z(e=>{const t={...process.env};return process.stderr.isTTY&&t.FORCE_COLOR===void 0&&t.NO_COLOR===void 0&&(t.FORCE_COLOR="1"),e?{...t,...e}:t},"buildTaskEnv");var Vt=Object.defineProperty,j=f((e,t)=>Vt(e,"name",{value:t,configurable:!0}),"o");const zt=j(async(e,t,r)=>{const n=Kt(r.concurrent,e.length),s=[],i=new AbortController;let o=!1,a=0;const c=j(()=>{o||(o=!0,r.continueOnError||i.abort())},"cancel");r.externalSignal&&(r.externalSignal.aborted?c():r.externalSignal.addEventListener("abort",()=>{c()},{once:!0}));const l=j(h=>{for(const m of h.commands)t.commandEnd({commandId:m.id,durationMs:0,patternId:h.id,status:"skipped"})},"emitSkippedCommands"),u=j(async h=>{if(o){l(h),t.patternEnd({patternId:h.id,status:"skipped"});return}t.patternStart({patternId:h.id});let m="success";for(const v of h.commands){if(o){t.commandEnd({commandId:v.id,durationMs:0,patternId:h.id,status:"skipped"}),m=m==="success"?"skipped":m;continue}t.commandStart({commandId:v.id,patternId:h.id});const y=await Wt(v,r,i.signal),T=y.status==="failed"&&i.signal.aborted?{...y,status:"skipped"}:y;if(t.commandEnd({commandId:v.id,durationMs:T.durationMs,error:T.error,output:T.output,patternId:h.id,status:T.status}),T.status==="failed"){s.push(v.title),m="failed",c();break}if(T.status==="skipped"){m=m==="success"?"skipped":m;break}}t.patternEnd({patternId:h.id,status:m})},"runOne"),d=j(async()=>{for(;a<e.length;){const h=e[a];a+=1,h&&await u(h)}},"pickNext"),p=[];for(let h=0;h<Math.min(n,e.length);h+=1)p.push(d());await Promise.all(p);const w=r.externalSignal?.aborted===!0;return{failedCommands:s,success:s.length===0&&!w}},"runTasks"),Wt=j(async(e,t,r)=>{const n=Date.now();try{if(e.source==="custom"&&e.run)return await e.run([...e.files]),{durationMs:Date.now()-n,status:"success"};if(e.command){const s=await Ut(e.command,e.files,{cwd:t.cwd,killSignal:t.killSignal,maxArgLength:t.maxArgLength,signal:r});return{durationMs:s.durationMs,output:t.verbose?s.output:void 0,status:"success"}}return{durationMs:Date.now()-n,error:new M(e.title,"Command has no invocation target."),status:"failed"}}catch(s){const i=s instanceof Error?s:new Error(String(s));return{durationMs:Date.now()-n,error:i,output:i instanceof M?i.message:void 0,status:"failed"}}},"runCommand"),Kt=j((e,t)=>{if(e===!1)return 1;if(e===!0){const n=Math.max(1,typeof se=="function"?se():4);return Math.min(Math.max(1,t),n)}const r=Math.floor(e);return r>0?r:1},"concurrencyLimit");var Yt=Object.defineProperty,Z=f((e,t)=>Yt(e,"name",{value:t,configurable:!0}),"u");const Jt=!0,Qt=Z(e=>{try{return!je(e)}catch{return!1}},"detectCaseInsensitive"),Xt=Z(async(e={})=>{const t=e.cwd??process.cwd(),r=await Gt(e),n=await tt(e);typeof n!="function"&&ie(n);const s=new Ct({...e,cwd:t}),i=new AbortController;let o=!1;const a=Z(d=>{if(o){process.removeListener("SIGINT",a),process.removeListener("SIGTERM",a),process.kill(process.pid,d);return}o=!0,r.warn({message:`Received ${d} — cancelling staged tasks and restoring state. Press Ctrl+C again to abort.`}),i.abort()},"onInterrupt");process.on("SIGINT",a),process.on("SIGTERM",a);let c={failedCommands:[],ranTasks:!1,success:!0},l=!1,u=!1;try{await s.prepare(),l=!0;for(const y of s.warnings)r.warn({message:y});if(s.stagedFiles.length===0)return e.allowEmpty!==!0&&r.info({message:"No staged files found."}),u=!0,{failedCommands:[],ranTasks:!1,success:!0};const d=Qt(t),p=At(s.stagedFiles,e.ignore,t,{caseInsensitive:d});if(p.length===0&&s.stagedFiles.length>0)return r.info({message:"Every staged file was excluded by the `ignore` list."}),u=!0,{failedCommands:[],ranTasks:!1,success:!0};const w=typeof n=="function"?ie(await n([...p])):n,h=await Dt({caseInsensitive:d,config:w,cwd:t,files:p,relative:e.relative});if(r.start({patterns:h}),h.length===0)return r.info({message:"No staged files matched any pattern."}),u=!0,{failedCommands:[],ranTasks:!1,success:!0};const{failedCommands:m,success:v}=await zt(h,r,{concurrent:e.concurrent??Jt,continueOnError:e.continueOnError===!0,cwd:t,externalSignal:i.signal,killSignal:e.killSignal,maxArgLength:e.maxArgLength,verbose:e.verbose});if(c={failedCommands:m,ranTasks:!0,success:v},v){if(e.diff===void 0&&(await s.applyModifications({autoStage:e.autoStage===!0}),e.failOnChanges===!0&&s.indexTreeChanged()&&(r.warn({message:"Tasks modified staged content — failing because --fail-on-changes is set."}),c={failedCommands:[...m],ranTasks:!0,success:!1}),e.allowEmpty!==!0&&s.postTaskIndexMatchesHead()))throw new Ue("All staged changes were reverted by tasks. Re-stage changes or rerun with --allow-empty.")}else if(e.revert===!0)r.info({message:"Reverting working tree from backup stash."}),await s.revert();else{const y=s.recoveryHint();y&&r.warn({message:y})}return await s.restoreUnstagedChanges(),u=c.success,c}catch(d){const p=d instanceof Error?d.message:String(d),w=d instanceof Error?d:new Error(p);if(r.error({error:w,message:p}),d instanceof O)return{failedCommands:c.failedCommands,ranTasks:c.ranTasks,success:!1};throw d}finally{if(process.removeListener("SIGINT",a),process.removeListener("SIGTERM",a),l)try{await s.cleanup(u)}catch(d){r.error({error:d,message:"Cleanup failed."})}await r.stop()}},"runStaged");var Zt=Object.defineProperty,er=f((e,t)=>Zt(e,"name",{value:t,configurable:!0}),"n");const tr="VIS_STAGED_CONCURRENT",me=er(e=>{const t=e.trim();if(t==="true"||t==="")return!0;if(t==="false")return!1;const r=Number(t);return Number.isNaN(r)?!0:r},"parseConcurrent");var rr=Object.defineProperty,L=f((e,t)=>rr(e,"name",{value:t,configurable:!0}),"d");const sr=L((e,t)=>{const r={};t!==void 0&&(r.config=t);const n=L(E=>e[E]===void 0?void 0:!!e[E],"readBool"),s=L(E=>{const W=e[E];return typeof W=="string"&&W.length>0?W:void 0},"readString"),i=n("allow-empty");i!==void 0&&(r.allowEmpty=i);const o=n("auto-stage");o!==void 0&&(r.autoStage=o);const a=n("continue-on-error");a!==void 0&&(r.continueOnError=a);const c=n("debug");c!==void 0&&(r.debug=c);const l=n("fail-on-changes");l!==void 0&&(r.failOnChanges=l);const u=n("hide-partially-staged");u!==void 0&&(r.hidePartiallyStaged=u);const d=n("hide-unstaged");d!==void 0&&(r.hideUnstaged=d);const p=n("quiet");p!==void 0&&(r.quiet=p);const w=n("relative");w!==void 0&&(r.relative=w);const h=n("revert");h!==void 0&&(r.revert=h);const m=n("stash");m!==void 0&&(r.stash=m);const v=n("verbose");v!==void 0&&(r.verbose=v);const y=s("cwd");y!==void 0&&(r.cwd=y);const T=s("diff");T!==void 0&&(r.diff=T);const te=s("diff-filter");if(te!==void 0&&(r.diffFilter=te),n("force-kill")===!0&&(r.killSignal="SIGKILL"),e.concurrent===void 0){const E=process.env[tr];E!==void 0&&(r.concurrent=me(E.trim()))}else r.concurrent=me(String(e.concurrent));return r},"buildRunOptions"),pr=L(async({options:e,visConfig:t})=>{const r=(t??{}).staged;if(!r)throw new Error(`No "staged" config found in vis.config.ts. Add one:
19
+
20
+ // vis.config.ts
21
+ import { defineConfig } from "@visulima/vis/config";
22
+
23
+ export default defineConfig({
24
+ staged: { '*': 'vis check --fix' },
25
+ });
26
+
27
+ Migrating from lint-staged or nano-staged? Run \`vis migrate lint-staged\` (or \`vis migrate nano-staged\`) to move the config in and remove the legacy files.`);(await Xt(sr(e,r))).success||(process.exitCode=1)},"execute");export{sr as buildRunOptions,pr as default};
@@ -0,0 +1 @@
1
+ var T=Object.defineProperty;var j=(e,t)=>T(e,"name",{value:t,configurable:!0});import{createRequire as C}from"node:module";import J from"@visulima/colorize";import{isAccessibleSync as M,readJsonSync as P}from"@visulima/fs";import{join as _}from"@visulima/path";import{enforceProjectConstraints as V}from"@visulima/task-runner";import{a as z}from"../packem_shared/flakiness-DSIHZGBT.js";import{c as A}from"../packem_shared/runtime-check-CGHal8SO.js";import{Z as B,e as H}from"../packem_shared/bin-BaZZ32BK.js";const q=C(import.meta.url),n=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,x=j(e=>{if(typeof n<"u"&&n.versions&&n.versions.node){const[t,i]=n.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return n.getBuiltinModule(e)}return q(e)},"__cjs_getBuiltinModule"),{readdirSync:F}=x("node:fs");var I=Object.defineProperty,v=j((e,t)=>I(e,"name",{value:t,configurable:!0}),"h");const{dim:K,green:f,red:O,yellow:b}=J,r=v(e=>e?f("✓"):O("✗"),"icon"),X=v(async({logger:e,options:t,visConfig:i,workspaceRoot:o})=>{if(!o)throw new Error("Could not determine workspace root.");const{config:y,packageJsons:w,workspace:u}=B(o,i),R=H(o,u,w),$=Object.keys(u.projects).length,k=new Set(Object.values(u.projects).flatMap(p=>Object.keys(p.targets??{}))).size,a=A(o);let s=0;y.constraints&&(s=V(R,y.constraints).length);const c=z(o,{minRuns:2});let l;const g=_(o,".task-runner","runs");if(M(g)){const p=F(g).filter(d=>d.endsWith(".json")).sort();let m=0,S=0;for(const d of p.slice(-20))try{const h=P(_(g,d));h.stats&&(m+=h.stats.total??0,S+=h.stats.cached??0)}catch{continue}m>0&&(l=`${(S/m*100).toFixed(0)}%`)}if(t.json){e.info(JSON.stringify({cacheHitRate:l??null,constraintViolations:s,flakyTasks:c.length,projects:$,runtimeIssues:a.length,targets:k},null,2));return}e.info(""),e.info(` ${K("VIS STATUS")}`),e.info(""),e.info(` ${r(!0)} ${String($)} projects · ${String(k)} unique targets`),e.info(` ${r(a.length===0)} Runtime: ${a.length===0?f("OK"):b(`${String(a.length)} issue(s)`)}`),e.info(` ${r(s===0)} Constraints: ${s===0?f("OK"):O(`${String(s)} violation(s)`)}`),e.info(` ${r(c.length===0)} Flaky tasks: ${c.length===0?f("none"):b(String(c.length))}`),l&&e.info(` ${r(!0)} Cache hit rate: ${l} (last 20 runs)`),e.info("")},"execute");export{X as default};