@visulima/vis 6.1.3 → 6.1.4

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 (193) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE.md +0 -29
  3. package/dashboard/dist/index.html +10 -10
  4. package/dist/bin.js +1 -1
  5. package/dist/binx.js +1 -1
  6. package/dist/config/index.d.ts +16 -10
  7. package/dist/generate/index.d.ts +25 -0
  8. package/dist/packem_chunks/CONFIG_FILES.js +6 -7
  9. package/dist/packem_chunks/bloom-status.js +1 -1
  10. package/dist/packem_chunks/bloom-sync.js +1 -1
  11. package/dist/packem_chunks/catalog2.js +7 -7
  12. package/dist/packem_chunks/cli-exec.js +1 -1
  13. package/dist/packem_chunks/cli-main.js +129 -129
  14. package/dist/packem_chunks/dispatch.js +1 -1
  15. package/dist/packem_chunks/fix.js +1 -1
  16. package/dist/packem_chunks/handler.js +1 -1
  17. package/dist/packem_chunks/handler10.js +5 -5
  18. package/dist/packem_chunks/handler11.js +1 -1
  19. package/dist/packem_chunks/handler12.js +1 -1
  20. package/dist/packem_chunks/handler13.js +1 -1
  21. package/dist/packem_chunks/handler14.js +1 -1
  22. package/dist/packem_chunks/handler15.js +1 -1
  23. package/dist/packem_chunks/handler16.js +1 -1
  24. package/dist/packem_chunks/handler17.js +1 -1
  25. package/dist/packem_chunks/handler18.js +1 -1
  26. package/dist/packem_chunks/handler19.js +1 -1
  27. package/dist/packem_chunks/handler2.js +1 -1
  28. package/dist/packem_chunks/handler20.js +1 -1
  29. package/dist/packem_chunks/handler21.js +1 -1
  30. package/dist/packem_chunks/handler22.js +1 -1
  31. package/dist/packem_chunks/handler23.js +1 -1
  32. package/dist/packem_chunks/handler24.js +1 -1
  33. package/dist/packem_chunks/handler25.js +1 -1
  34. package/dist/packem_chunks/handler26.js +1 -1
  35. package/dist/packem_chunks/handler27.js +1 -1
  36. package/dist/packem_chunks/handler28.js +1 -1
  37. package/dist/packem_chunks/handler29.js +1 -1
  38. package/dist/packem_chunks/handler3.js +2 -2
  39. package/dist/packem_chunks/handler30.js +1 -1
  40. package/dist/packem_chunks/handler4.js +1 -1
  41. package/dist/packem_chunks/handler40.js +1 -1
  42. package/dist/packem_chunks/handler5.js +1 -1
  43. package/dist/packem_chunks/handler50.js +2 -2
  44. package/dist/packem_chunks/handler51.js +1 -1
  45. package/dist/packem_chunks/handler52.js +1 -1
  46. package/dist/packem_chunks/handler53.js +1 -1
  47. package/dist/packem_chunks/handler54.js +2 -2
  48. package/dist/packem_chunks/handler55.js +1 -1
  49. package/dist/packem_chunks/handler56.js +1 -1
  50. package/dist/packem_chunks/handler58.js +1 -1
  51. package/dist/packem_chunks/handler59.js +1 -1
  52. package/dist/packem_chunks/handler6.js +1 -1
  53. package/dist/packem_chunks/handler60.js +4 -4
  54. package/dist/packem_chunks/handler61.js +2 -2
  55. package/dist/packem_chunks/handler62.js +1 -1
  56. package/dist/packem_chunks/handler63.js +2 -61
  57. package/dist/packem_chunks/handler64.js +61 -6
  58. package/dist/packem_chunks/handler65.js +6 -8
  59. package/dist/packem_chunks/handler66.js +8 -2
  60. package/dist/packem_chunks/handler67.js +2 -28
  61. package/dist/packem_chunks/handler68.js +28 -12
  62. package/dist/packem_chunks/handler69.js +12 -25
  63. package/dist/packem_chunks/handler7.js +1 -1
  64. package/dist/packem_chunks/handler70.js +25 -22
  65. package/dist/packem_chunks/handler71.js +22 -10
  66. package/dist/packem_chunks/handler72.js +10 -133
  67. package/dist/packem_chunks/handler73.js +133 -23
  68. package/dist/packem_chunks/handler74.js +23 -323
  69. package/dist/packem_chunks/handler75.js +274 -659
  70. package/dist/packem_chunks/handler76.js +13 -13
  71. package/dist/packem_chunks/handler77.js +12 -12
  72. package/dist/packem_chunks/handler78.js +1 -1
  73. package/dist/packem_chunks/handler79.js +69 -67
  74. package/dist/packem_chunks/handler8.js +1 -1
  75. package/dist/packem_chunks/handler9.js +1 -1
  76. package/dist/packem_chunks/heal-accept.js +1 -1
  77. package/dist/packem_chunks/heal.js +1 -1
  78. package/dist/packem_chunks/help-command.js +1 -1
  79. package/dist/packem_chunks/html.js +707 -0
  80. package/dist/packem_chunks/index4.js +1 -1
  81. package/dist/packem_chunks/index6.js +57 -51
  82. package/dist/packem_chunks/index7.js +2 -2
  83. package/dist/packem_chunks/keys-refresh.js +1 -1
  84. package/dist/packem_chunks/lean.js +1 -1
  85. package/dist/packem_chunks/list.js +1 -1
  86. package/dist/packem_chunks/loader.js +1 -1
  87. package/dist/packem_chunks/prune.js +1 -1
  88. package/dist/packem_chunks/run.js +1 -1
  89. package/dist/packem_chunks/status.js +1 -1
  90. package/dist/packem_chunks/sync.js +1 -1
  91. package/dist/packem_chunks/sync2.js +1 -1
  92. package/dist/packem_chunks/tripwire.js +1 -1
  93. package/dist/packem_chunks/ts-loader.js +1 -1
  94. package/dist/packem_chunks/verify-lockfile.js +1 -1
  95. package/dist/packem_shared/advisories-DHGJ6XhP.js +1 -0
  96. package/dist/packem_shared/affected-selection-DCT4CLex.js +1 -0
  97. package/dist/packem_shared/{affected-shas-B_kfSKss.js → affected-shas-CycHU3nr.js} +1 -1
  98. package/dist/packem_shared/{ai-analysis-qdksWsn1.js → ai-analysis-CO4rT3Nd.js} +1 -1
  99. package/dist/packem_shared/ai-cache-Dkb6me20.js +1 -0
  100. package/dist/packem_shared/{ai-fix-DEwd0QKC.js → ai-fix-C0OBhGDq.js} +1 -1
  101. package/dist/packem_shared/{augment-B9kSZuvW.js → augment-BSeqaai8.js} +1 -1
  102. package/dist/packem_shared/{bin-BND-N6AL.js → bin-DwACrJUJ.js} +1 -1
  103. package/dist/packem_shared/build-scripts-BeMIA-_q.js +1 -0
  104. package/dist/packem_shared/{command-runtime-HSsYGCQd.js → command-runtime-DG49t2MT.js} +1 -1
  105. package/dist/packem_shared/{dependency-scan-B1CU6P9M.js → dependency-scan-D8e370_h.js} +1 -1
  106. package/dist/packem_shared/detect-C-9o_BPB.js +1 -0
  107. package/dist/packem_shared/{docker-DXqV-07f.js → docker-vRDm2lHX.js} +1 -1
  108. package/dist/packem_shared/{ecosystem-gate-InIAzSPA.js → ecosystem-gate-DpO43yAS.js} +1 -1
  109. package/dist/packem_shared/env-BymuoTL8.js +4 -0
  110. package/dist/packem_shared/env-consistency-BDfAa56d.js +1 -0
  111. package/dist/packem_shared/{failure-log-DIsKBKaI.js → failure-log-BslhfaEO.js} +1 -1
  112. package/dist/packem_shared/glob-Cyk1H9ZL-6yDyaJwk.js +1 -0
  113. package/dist/packem_shared/{index-BzhrR_iC.js → index-0dnGN3GP.js} +1 -1
  114. package/dist/packem_shared/index-CIdjkZgt.js +1 -0
  115. package/dist/packem_shared/{index-BtVOr8mn.js → index-Cwxbl_pY.js} +1 -1
  116. package/dist/packem_shared/index-Doab17tq.js +1 -0
  117. package/dist/packem_shared/{isAccessibleSync-DYKTrrvc-C-_5cgwu.js → isAccessibleSync-DYKTrrvc-CBsMZhj-.js} +1 -1
  118. package/dist/packem_shared/{lifecycle-CQjeMPY0.js → lifecycle-Gy7mqMGg.js} +2 -2
  119. package/dist/packem_shared/{lockfile-CiUtEbnt.js → lockfile-DEWjBrlY.js} +1 -1
  120. package/dist/packem_shared/manifests-kE5OweNT.js +1 -0
  121. package/dist/packem_shared/{min-release-age-JViyQuBM.js → min-release-age-yvuPbJ8G.js} +1 -1
  122. package/dist/packem_shared/missing-package-json-CEEPXqYi.js +1 -0
  123. package/dist/packem_shared/{multi-eco-lockfiles-h_HBOpPX.js → multi-eco-lockfiles-D5tM7pkg.js} +1 -1
  124. package/dist/packem_shared/{native-config-sync-TdTWjVgI.js → native-config-sync-DDGt3vvd.js} +1 -1
  125. package/dist/packem_shared/{npmrc-CHsOyMvA.js → npmrc-CIvOb61L.js} +1 -1
  126. package/dist/packem_shared/{osv-BLj4LauP.js → osv-4kFhXIoW.js} +1 -1
  127. package/dist/packem_shared/osv-bloom-DU6avR2k.js +2 -0
  128. package/dist/packem_shared/package-version-x7sPg2TM.js +4 -0
  129. package/dist/packem_shared/packument-Dg8cIDYR.js +1 -0
  130. package/dist/packem_shared/{pm-runner-RM72mDZg.js → pm-runner-Dboj-wZG.js} +1 -1
  131. package/dist/packem_shared/{project-name-filter-C6ObyhZ4.js → project-name-filter-B3tKt-Pf.js} +1 -1
  132. package/dist/packem_shared/{provenance-SX1MxPUZ.js → provenance-BG5mu0H_.js} +1 -1
  133. package/dist/packem_shared/registry-CndByNx9.js +85 -0
  134. package/dist/packem_shared/registry-keys-CE-RZlp_.js +1 -0
  135. package/dist/packem_shared/{removeSync-g1D5kONg-LbjATA8v.js → removeSync-g1D5kONg-jOsRSIIv.js} +1 -1
  136. package/dist/packem_shared/{renderToString-DR0zDUjh-5WQEQBtg.js → renderToString-DR0zDUjh-DeiCwydO.js} +1 -1
  137. package/dist/packem_shared/{resolve-explicit-D9kdTNvl.js → resolve-explicit-Cge6eKPt.js} +1 -1
  138. package/dist/packem_shared/{resolve-runtime-DNukUjIr.js → resolve-runtime-D8rxuo3J.js} +1 -1
  139. package/dist/packem_shared/run-CKL4VGzQ.js +10 -0
  140. package/dist/packem_shared/{run-file-UBukWaha.js → run-file-D1mlOnd8.js} +1 -1
  141. package/dist/packem_shared/{run-summary-utils-CMeURYtS.js → run-summary-utils-DbyeUM6f.js} +1 -1
  142. package/dist/packem_shared/runtime-check-Dw0q3X67.js +1 -0
  143. package/dist/packem_shared/s1ngularity-BOl0c716.js +1 -0
  144. package/dist/packem_shared/{scaffold-files-02tUvEKC.js → scaffold-files-B8zMyMvq.js} +1 -1
  145. package/dist/packem_shared/{scan-progress-D_POj2sy.js → scan-progress-CY3XIDOY.js} +1 -1
  146. package/dist/packem_shared/selectors-BB0yaWyK.js +3 -0
  147. package/dist/packem_shared/{signatures-CeL0bOEo.js → signatures-r1SeDHLL.js} +1 -1
  148. package/dist/packem_shared/spinner-B_rRdoro.js +1 -0
  149. package/dist/packem_shared/{table-bf3rvDd-.js → table-bu4cV-it.js} +1 -1
  150. package/dist/packem_shared/{tabs-CvrVM8BU.js → tabs-A2EUpTHt.js} +1 -1
  151. package/dist/packem_shared/target-merge-ya19LiWB.js +1 -0
  152. package/dist/packem_shared/{target-options-DsHFmRZH.js → target-options-rIthWS4M.js} +1 -1
  153. package/dist/packem_shared/{task-env-C2lmxvzA.js → task-env-Cl4jNMCR.js} +1 -1
  154. package/dist/packem_shared/toolchain-Bt93i37e.js +5 -0
  155. package/dist/packem_shared/typosquats-BbebOgKM.js +1 -0
  156. package/dist/packem_shared/{use-measured-height-CQ-qYCmz.js → use-measured-height-CwhybDI9.js} +1 -1
  157. package/dist/packem_shared/{verify-B_MblU_Q.js → verify-3WE9U_Bv.js} +1 -1
  158. package/dist/packem_shared/{vis-update-app-a93HLRLX.js → vis-update-app-PjJWvxqF.js} +1 -1
  159. package/dist/packem_shared/{vis-user-error-Cpb0P6VA.js → vis-user-error-BivZDkQD.js} +2 -2
  160. package/dist/packem_shared/{watch-CcTketln.js → watch-C-9-PD2m.js} +1 -1
  161. package/dist/packem_shared/{watch-loop-CGPe21AK.js → watch-loop-dWYGUQwi.js} +1 -1
  162. package/dist/release/plugin-sdk.d.ts +32 -0
  163. package/dist/release/presets.d.ts +38 -0
  164. package/dist/runtime/preload.js +1 -1
  165. package/index.js +26 -26
  166. package/package.json +19 -15
  167. package/schemas/vis-config.schema.json +12 -0
  168. package/dist/packem_shared/advisories-BKsh48bi.js +0 -1
  169. package/dist/packem_shared/affected-selection-C7rvg_xC.js +0 -1
  170. package/dist/packem_shared/ai-cache-iSIyY3So.js +0 -1
  171. package/dist/packem_shared/build-scripts-CEDx_nJp.js +0 -1
  172. package/dist/packem_shared/detect-CbMRSXkM.js +0 -1
  173. package/dist/packem_shared/env-BSXG3QKH.js +0 -4
  174. package/dist/packem_shared/env-consistency-B4rU4MQb.js +0 -1
  175. package/dist/packem_shared/glob-Cyk1H9ZL-DlsGNNhY.js +0 -1
  176. package/dist/packem_shared/index-BS3mFsh-.js +0 -1
  177. package/dist/packem_shared/manifests-Du4yKlf_.js +0 -1
  178. package/dist/packem_shared/missing-package-json-DDVQ_scH.js +0 -1
  179. package/dist/packem_shared/osv-bloom-BCAX5ARR.js +0 -2
  180. package/dist/packem_shared/package-version-D0b8b41D.js +0 -4
  181. package/dist/packem_shared/packument-CbTmbHU4.js +0 -1
  182. package/dist/packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js +0 -1
  183. package/dist/packem_shared/registry-B6LWRK9T.js +0 -81
  184. package/dist/packem_shared/registry-keys-z038Ecb4.js +0 -1
  185. package/dist/packem_shared/run-DLvd3RIZ.js +0 -10
  186. package/dist/packem_shared/runtime-check-D3cRDuoi.js +0 -1
  187. package/dist/packem_shared/s1ngularity-BuU9Cxpy.js +0 -1
  188. package/dist/packem_shared/selectors-edwcgNl3.js +0 -3
  189. package/dist/packem_shared/spinner-8fJUI_wl.js +0 -1
  190. package/dist/packem_shared/target-merge-DVJl-7Qz.js +0 -4
  191. package/dist/packem_shared/toolchain-CP79HNVy.js +0 -5
  192. package/dist/packem_shared/typosquats-BFKus_aM.js +0 -1
  193. package/dist/packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js +0 -1
@@ -1,12 +1,28 @@
1
- import{createRequire as ee}from"node:module";import{e as A,a as re}from"../packem_shared/index-BzhrR_iC.js";import{f as ae,h as M}from"../packem_shared/ai-cache-iSIyY3So.js";import{p as c,V,X as k,Y as ne,P as O,Z as L,_ as oe,g as ie}from"./cli-main.js";import{z as ce,A as de,B as N,C as z}from"../packem_shared/registry-B6LWRK9T.js";import{p as he,d as x,a as U,q as I}from"../packem_shared/env-BSXG3QKH.js";import{z as b}from"../packem_shared/formatBytes-_HvjOy8a-iHCer6uX.js";import{Cache as E,readLastRunSummary as Y,getLastRunSummaryPath as P,parseCacheSize as me,digestFile as X,describeCacheMissReason as pe}from"@visulima/task-runner";import{y as R}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{r as G,f as F,a as ye,d as Se}from"../packem_shared/run-summary-utils-CMeURYtS.js";let te;const se=e=>(te??=ee(import.meta.url))(e),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[s,t]=g.versions.node.split(".").map(Number);if(s>22||s===22&&t>=3||s===20&&t>=16)return g.getBuiltinModule(e)}return se(e)},{realpath:_,rm:W,mkdtemp:fe,readdir:ue,stat:q}=j("node:fs/promises"),{createInterface:le}=j("node:readline"),{tmpdir:$e}=j("node:os"),we=e=>new Promise(s=>{const t=le({input:process.stdin,output:process.stderr});t.question(`${e} (y/N) `,r=>{t.close();const n=r.trim().toLowerCase();s(n==="y"||n==="yes")})}),ve=()=>{try{const e=ae();e>0&&c.info(`Cleared ${String(e)} cached AI response${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear AI response cache: ${e instanceof Error?e.message:String(e)}`)}},ke=()=>{try{const e=he();e>0&&c.info(`Cleared ${String(e)} cached Socket.dev report${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear Socket.dev cache: ${e instanceof Error?e.message:String(e)}`)}},Ce=()=>{try{const e=ce();e>0&&c.info(`Cleared ${String(e)} cached deps.dev record${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear deps.dev cache: ${e instanceof Error?e.message:String(e)}`)}},ge=()=>{try{const e=de();e>0&&c.info(`Cleared ${String(e)} cached Snyk record${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear Snyk cache: ${e instanceof Error?e.message:String(e)}`)}},De=async(e,s,t)=>{if(!R(e)){c.info(`No cache directory to clean at ${e}`);return}if(t.dryRun){const a=(await Promise.all(V(e,!0).map(async i=>k(i)))).flat(),o=a.reduce((i,d)=>i+d.sizeBytes,0);c.info(`Would remove ${String(a.length)} cache entr${a.length===1?"y":"ies"} (${b(o,{decimals:1,space:!1})}) from ${e}`);return}const r=ne(e,s);try{const n=await _(e),a=await _(s);if(n===a){c.error("Refusing to delete the workspace root. The cache directory resolved to the same path as the workspace."),process.exitCode=1;return}}catch{}if(!r&&!t.force){if(c.warn(`Cache directory is outside the workspace root: ${e}`),c.warn("This will recursively delete the entire directory, including anything stored there by other tools."),!process.stdin.isTTY){c.error("Refusing to clean an out-of-workspace cache without --force (stdin is not a TTY)."),process.exitCode=1;return}if(!await we(" Continue?")){c.info("Aborted.");return}}r?await new E({cacheDirectory:e,workspaceRoot:s}).clear():await W(e,{force:!0,recursive:!0}),c.success(`Cleared cache: ${e}`)},Z=e=>e==="task"||e==="ai"||e==="socket"||e==="deps-dev"||e==="snyk"||e==="all"?e:(e&&e.length>0&&c.warn(`Unknown --type value '${e}'; falling back to 'all'.`),"all"),m=(e,s)=>e==="all"||e===s,xe=e=>e==="worktree"||e==="shared"||e==="all"?e:(e&&e.length>0&&c.warn(`Unknown --scope value '${e}'; falling back to 'shared'.`),"shared"),w=(e,s,t)=>{const r=e??process.cwd(),n=t??{},a=n.taskRunner??{},o=xe(s.scope),i=s.cacheDir,d=O(r,i,a.cacheDirectory,!1),f=O(r,i,a.cacheDirectory,n.sharedWorktreeCache),h=L(d,r,n.branchScopedCache),u=L(f,r,n.branchScopedCache);let l;switch(o){case"all":{l=u===h?[{base:f,scoped:u}]:[{base:f,scoped:u},{base:d,scoped:h}];break}case"worktree":{l=[{base:d,scoped:h}];break}default:l=[{base:f,scoped:u}]}const S=n.branchScopedCache===!0;return{directoriesFor:T=>T==="read"?[...new Set(l.flatMap(p=>p.scoped!==p.base&&oe(p.base)?[p.scoped,p.base]:[p.scoped]))]:T==="wipe"?[...new Set(l.map(p=>p.base))]:[...new Set(l.flatMap(p=>V(p.base,S)))],scope:o,sharedWorktreeCache:n.sharedWorktreeCache,workspaceRoot:r}},H=16,K=e=>e.length>H?`${e.slice(0,H)}…`:e,v=(e,s,t)=>{const r=Object.entries(s??{});if(r.length!==0){t.info(` ${e}:`),r.sort(([n],[a])=>n.localeCompare(a));for(const[n,a]of r)t.info(` ${n.padEnd(40)} ${K(a)}`)}},be=async(e,s,t)=>{if(e!==void 0)for(const r of s){const n=await new E({cacheDirectory:r,workspaceRoot:t}).get(e);if(n?.fingerprint)return n.fingerprint}},Ee=(e,s)=>{v("tracked files",e.fileHashes,s),v("tracked env",e.envHashes,s),v("missing files",Object.fromEntries(e.missingFiles.map(t=>[t,"absent"])),s)},Re=async(e,s,t)=>{const{format:r,runId:n,workspaceRoot:a}=s,o=n===void 0?await Y(a,{dataDirectory:x(a)}):await G(a,n);if(!o){if(r==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:n??null,taskId:e},void 0,2)}
2
- `),process.exitCode=1;return}n===void 0?c.error(`No previous run summary found. Run a task first to populate \`${P(a,{dataDirectory:x(a)})}\`.`):c.error(`Run summary "${n}" not found in ${U(a)}/.`),process.exitCode=1;return}const i=F(o,e);if(!i){if(r==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:o.id,taskId:e},void 0,2)}
3
- `),process.exitCode=1;return}c.error(`Task "${e}" was not part of run ${o.id}.`),process.exitCode=1;return}const d=i.hashDetails===void 0?await be(i.hash,s.cacheDirectories??[],a):void 0;if(r==="json"){process.stdout.write(`${JSON.stringify({cacheStatus:i.cacheStatus,hash:i.hash??null,hashDetails:i.hashDetails??null,hashSource:i.hashSource??null,runId:o.id,taskId:i.taskId,trackedFingerprint:d??null},void 0,2)}
4
- `);return}c.info(`Hash for ${e} (run ${o.id})`),t.info(""),t.info(` status: ${i.cacheStatus}`),t.info(` hash: ${i.hash??"(none)"}`),i.hashSource==="declared-fallback"&&t.info(" key: declared-fallback (no files were tracked; the entry is keyed on the declared inputs below)"),i.hashDetails?(t.info(""),t.info(` command: ${K(i.hashDetails.command)}`),v("nodes",i.hashDetails.nodes,t),v("runtime",i.hashDetails.runtime,t),v("implicitDeps",i.hashDetails.implicitDeps,t)):d?(t.info(""),Ee(d,t)):(t.info(""),c.info("No hash details recorded for this task."))},$=e=>{process.stdout.write(`${e}
5
- `)},C=e=>{process.stdout.write(`${JSON.stringify(e,void 0,2)}
6
- `)},Be=async(e,s,t)=>{if(!R(e)){if(s==="json"){process.stdout.write(`${JSON.stringify({directory:e,entries:[],totalBytes:0,totalCount:0},void 0,2)}
7
- `);return}c.info(`No cache directory found at ${e}`);return}const r=await k(e);if(r.length===0){if(s==="json"){process.stdout.write(`${JSON.stringify({directory:e,entries:[],totalBytes:0,totalCount:0},void 0,2)}
8
- `);return}c.info(`Cache directory is empty: ${e}`);return}const n=r.reduce((h,u)=>h+u.sizeBytes,0);if(s==="json"){const h=Date.now();process.stdout.write(`${JSON.stringify({directory:e,entries:r.map(u=>({ageMs:h-u.mtimeMs,hash:u.hash,mtimeIso:new Date(u.mtimeMs).toISOString(),sizeBytes:u.sizeBytes})),totalBytes:n,totalCount:r.length},void 0,2)}
9
- `);return}$(`Cache directory: ${e}`),$(`Entries: ${String(r.length)} (${b(n,{decimals:1,space:!1})})`),t.info("");const a=Date.now(),o=r.map(h=>({age:ie(h.mtimeMs,a),hash:h.hash.slice(0,12),size:b(h.sizeBytes,{decimals:1,space:!1})})),i=Math.max(4,...o.map(h=>h.hash.length)),d=Math.max(4,...o.map(h=>h.size.length)),f=Math.max(3,...o.map(h=>h.age.length));t.info(` ${"hash".padEnd(i)} ${"size".padEnd(d)} ${"age".padEnd(f)}`),t.info(` ${"-".repeat(i)} ${"-".repeat(d)} ${"-".repeat(f)}`);for(const h of o)t.info(` ${h.hash.padEnd(i)} ${h.size.padEnd(d)} ${h.age.padEnd(f)}`)},Me=async(e,s,t)=>{if(!R(e)){c.info(`No cache directory to prune at ${e}`);return}if(t.maxCacheAgeDays!==void 0&&(!Number.isFinite(t.maxCacheAgeDays)||t.maxCacheAgeDays<0)){c.error(`Invalid --max-age-days value: expected a finite number >= 0, got ${String(t.maxCacheAgeDays)}`),process.exitCode=1;return}if(t.keepLast!==void 0&&(!Number.isFinite(t.keepLast)||t.keepLast<0||!Number.isInteger(t.keepLast))){c.error(`Invalid --keep-last value: expected a non-negative integer, got ${String(t.keepLast)}`),process.exitCode=1;return}if(t.maxCacheSize!==void 0){let u;try{u=me(t.maxCacheSize)}catch(l){c.error(`Invalid --max-size value: ${l instanceof Error?l.message:String(l)}`),process.exitCode=1;return}if(!Number.isFinite(u)||u<=0){c.error(`Invalid --max-size value: expected a positive size, got "${t.maxCacheSize}" (${String(u)} bytes)`),process.exitCode=1;return}}const r=t.maxCacheAgeDays===void 0?void 0:t.maxCacheAgeDays*24*60*60*1e3,n=await k(e),a=n.reduce((u,l)=>u+l.sizeBytes,0);if(t.keepLast!==void 0&&n.length>t.keepLast){const u=n.slice(t.keepLast);await Promise.all(u.map(l=>W(l.path,{force:!0,recursive:!0})))}await new E({cacheDirectory:e,maxCacheAge:r,maxCacheSize:t.maxCacheSize,workspaceRoot:s}).removeOldEntries();const i=await k(e),d=i.reduce((u,l)=>u+l.sizeBytes,0),f=n.length-i.length,h=a-d;if(f<=0){c.info("Nothing to prune — all entries are within the configured limits.");return}c.success(`Pruned ${String(f)} entr${f===1?"y":"ies"}, freed ${b(h,{decimals:1,space:!1})}.`)},y=e=>e===void 0?null:new Date(e).toISOString(),D=(e,s)=>{$(`${e}:`),s.directory!==void 0&&$(` Directory: ${s.directory}`),$(` Entries: ${String(s.entries)}`),$(` Total size: ${b(s.totalSizeBytes,{decimals:1,space:!1})}`),$(` Oldest: ${s.oldestEntry?new Date(s.oldestEntry).toISOString():"N/A"}`),$(` Newest: ${s.newestEntry?new Date(s.newestEntry).toISOString():"N/A"}`)},Ne=async(e,s)=>{if(!R(e)){if(s==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!1,totalBytes:0,totalCount:0})}
10
- `);return}c.info(`No cache directory at ${e}`);return}const t=await k(e),r=t.reduce((n,a)=>n+a.sizeBytes,0);if(s==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!0,totalBytes:r,totalCount:t.length})}
11
- `);return}D("Task cache",{directory:e,entries:t.length,newestEntry:t[0]?.mtimeMs,oldestEntry:t.at(-1)?.mtimeMs,totalSizeBytes:r})},ze=async e=>{const s=[],t=async r=>{const a=(await ue(r,{withFileTypes:!0})).toSorted((o,i)=>o.name.localeCompare(i.name));for(const o of a){const i=A(r,o.name);if(o.isDirectory()){await t(i);continue}if(!o.isFile())continue;const[d,f]=await Promise.all([q(i),X(i)]);s.push({hash:f?.hash??"",mode:d.mode&4095,mtimeMs:d.mtimeMs,relativePath:re(e,i).replaceAll("\\","/"),sizeBytes:d.size})}};return await t(e),s},Ie=(e,s)=>Math.floor(e/1e3)===Math.floor(s/1e3),J=16,Fe=async(e,s)=>{const t=A(s,e.relativePath),r=await q(t).catch(()=>{});if(!r)return{expected:{hash:e.hash,mode:e.mode,mtimeMs:e.mtimeMs},issues:["missing"],relativePath:e.relativePath};const n=await X(t),a=[];(n?.hash??"")!==e.hash&&a.push("content");const o=r.mode&4095;if(process.platform!=="win32"&&o!==e.mode&&a.push("mode"),Ie(r.mtimeMs,e.mtimeMs)||a.push("mtime"),a.length!==0)return{actual:{hash:n?.hash,mode:o,mtimeMs:r.mtimeMs},expected:{hash:e.hash,mode:e.mode,mtimeMs:e.mtimeMs},issues:a,relativePath:e.relativePath}},je=async(e,s,t)=>{for(const r of s){const n=await new E({cacheDirectory:r,workspaceRoot:t}).getByTaskId(e);if(n)return{cached:n,cacheDirectory:r}}},B=(e,s,t)=>{e==="json"?C(s):c.error(t),process.exitCode=1},Ae=async(e,s)=>{const t=Array.from({length:e.length});for(let r=0;r<e.length;r+=J){const n=e.slice(r,r+J),a=await Promise.all(n.map(async o=>Fe(o,s)));for(const[o,i]of a.entries())t[r+o]=i}return t.filter(r=>r!==void 0)},We=(e,s,t)=>{t.info(` expected hash: ${e.hash||"(none)"}`),t.info(` actual hash: ${s.hash??"(unreadable)"}`)},Pe=(e,s,t)=>{t.info(` expected mode: ${e.mode.toString(8)}`),t.info(` actual mode: ${(s.mode??0).toString(8)}`)},Te=(e,s,t)=>{t.info(` expected mtime: ${new Date(e.mtimeMs).toISOString()}`),t.info(` actual mtime: ${s.mtimeMs===void 0?"(unreadable)":new Date(s.mtimeMs).toISOString()}`)},Oe=(e,s)=>{const t=e.issues.includes("missing")?"MISSING":e.issues.join(",").toUpperCase();s.info(` [${t}] ${e.relativePath}`);const{expected:r}=e,{actual:n}=e;e.issues.includes("missing")||!r||!n||(e.issues.includes("content")&&We(r,n,s),e.issues.includes("mode")&&Pe(r,n,s),e.issues.includes("mtime")&&Te(r,n,s))},Le=(e,s,t,r,n,a)=>{if(c.info(`Verify ${e} (hash ${s})`),a.info(""),a.info(` cache: ${t}`),a.info(` files: ${String(r)}`),n.length===0){a.info(""),c.success("Cache restore is faithful — all files match content, mode, and mtime.");return}a.info(` drift: ${String(n.length)} file(s)`),a.info("");for(const o of n)Oe(o,a);process.exitCode=1},_e=async(e,s,t)=>{const{cacheDirectories:r,format:n,workspaceRoot:a}=s;if(r.length===0){B(n,{error:"no-cache-directory",taskId:e},"No cache directory resolved — pass --cache-dir or run inside a workspace.");return}const o=await je(e,r,a);if(!o){B(n,{error:"no-cached-entry",searchedCaches:r,taskId:e},`No cached entry found for task "${e}". Run it once before verifying.`);return}const{cached:i,cacheDirectory:d}=o,f=await fe(A($e(),"vis-cache-verify-"));try{if(!await new E({cacheDirectory:d,workspaceRoot:f}).restoreOutputs(i.hash)){B(n,{error:"restore-failed",hash:i.hash,taskId:e},`Cache restore failed for ${e} (hash ${i.hash}).`);return}const l=await ze(f);if(l.length===0){n==="json"?C({diffs:[],hash:i.hash,status:"no-outputs",taskId:e}):c.info(`Cached entry for ${e} has no recorded outputs — nothing to verify.`);return}const S=await Ae(l,a);if(n==="json"){C({cachedFileCount:l.length,cacheDirectory:d,diffs:S,hash:i.hash,status:S.length===0?"ok":"drift",taskId:e}),S.length>0&&(process.exitCode=1);return}Le(e,i.hash,d,l.length,S,t)}finally{await W(f,{force:!0,recursive:!0}).catch(()=>{})}},He=(e,s,t,r)=>{e==="json"?C({error:"no-summary",runId:t??null,taskId:s}):t===void 0?c.error(`No previous run summary found. Run a task first to populate \`${P(r,{dataDirectory:x(r)})}\`.`):c.error(`Run summary "${t}" not found in ${U(r)}/.`),process.exitCode=1},Je=(e,s,t)=>{e==="json"?C({error:"task-not-in-summary",runId:t.id,taskId:s}):(c.error(`Task "${s}" was not part of run ${t.id}.`),c.info(`Tasks in this run: ${t.tasks.map(r=>r.taskId).join(", ")||"(none)"}`)),process.exitCode=1},Ve=(e,s,t,r,n)=>({diff:n,previousRunId:t?.id??null,previousTask:r?{cacheStatus:r.cacheStatus,hash:r.hash??null,hashDetails:r.hashDetails??null}:null,runId:e.id,task:{cacheMissReasons:s.cacheMissReasons??null,cacheStatus:s.cacheStatus,hash:s.hash??null,hashDetails:s.hashDetails??null,hashSource:s.hashSource??null,taskId:s.taskId}}),Ue=(e,s,t,r,n,a)=>{c.info(`Why ${e}? (run ${s.id})`),a.info(""),a.info(` status: ${t.cacheStatus}`),a.info(` hash: ${t.hash??"(none)"}`),t.hashSource==="declared-fallback"&&a.info(" key: declared-fallback (tracker observed no workspace access; keyed on declared inputs)"),n?a.info(` prev: ${n.hash??"(none)"} [run ${r?.id??"?"}]`):a.info(" prev: (no prior run found)"),a.info("")},qe=(e,s,t,r)=>{if(t.cacheMissReasons&&t.cacheMissReasons.length>0){r.info("Cache miss reasons (trace-mode fingerprint):");for(const n of t.cacheMissReasons)r.info(` - ${pe(n)}`)}else c.info("No hash inputs recorded for this run (trace-mode tasks record a miss reason only when the cache misses).");r.info(""),c.info(`Tracked files and env of this run: vis cache hash ${e} --run ${s.id}`)},Ye=e=>!e.commandChanged&&[e.nodes,e.runtime,e.implicitDeps].every(s=>s.added.length===0&&s.changed.length===0&&s.removed.length===0),Xe=(e,s)=>{s.info("Hash inputs that changed since the previous run:"),s.info(""),e.commandChanged&&s.info(" command: changed");for(const t of["nodes","runtime","implicitDeps"]){const r=e[t];if(!(r.added.length===0&&r.changed.length===0&&r.removed.length===0)){s.info(` ${t}:`);for(const n of r.added)s.info(` + ${n}`);for(const n of r.changed)s.info(` ~ ${n}`);for(const n of r.removed)s.info(` - ${n}`)}}},Ge=async(e,s,t)=>{const{format:r,runId:n,workspaceRoot:a}=s,o=n===void 0?await Y(a,{dataDirectory:x(a)}):await G(a,n);if(!o){He(r,e,n,a);return}const i=F(o,e);if(!i){Je(r,e,o);return}const d=await ye(a,o.id),f=d?F(d,e):void 0,h=Se(i.hashDetails,f?.hashDetails);if(r==="json"){C(Ve(o,i,d,f,h));return}if(Ue(e,o,i,d,f,t),i.hashDetails===void 0){qe(e,o,i,t);return}if(!f){c.info("No previous run to diff against — first time this task was recorded.");return}if(Ye(h)){c.success("No hash inputs changed since the previous run.");return}Xe(h,t),t.info(""),c.info(`Last summary file: ${P(a,{dataDirectory:x(a)})}`)},it=async({logger:e,options:s,visConfig:t,workspaceRoot:r})=>{const{directoriesFor:n}=w(r,s,t),a=n("read"),o=s.format??"table";for(const i of a)a.length>1&&c.info(`# ${i}`),await Be(i,o,e)},ct=async({options:e,visConfig:s,workspaceRoot:t})=>{const r=Z(e.type),n=!!e.dryRun;if(m(r,"task")){const{directoriesFor:a,workspaceRoot:o}=w(t,e,s);for(const i of a("wipe"))await De(i,o,{dryRun:n,force:!!e.force})}if(m(r,"ai"))if(n){const a=M();c.info(`Would clear ${String(a.entries)} cached AI response${a.entries===1?"":"s"}.`)}else ve();if(m(r,"socket"))if(n){const a=I();c.info(`Would clear ${String(a.entries)} cached Socket.dev report${a.entries===1?"":"s"}.`)}else ke();if(m(r,"deps-dev"))if(n){const a=N();c.info(`Would clear ${String(a.entries)} cached deps.dev record${a.entries===1?"":"s"}.`)}else Ce();if(m(r,"snyk"))if(n){const a=z();c.info(`Would clear ${String(a.entries)} cached Snyk record${a.entries===1?"":"s"}.`)}else ge()},dt=async({options:e,visConfig:s,workspaceRoot:t})=>{const{directoriesFor:r,workspaceRoot:n}=w(t,e,s),a=r("evict");for(const o of a)a.length>1&&c.info(`# ${o}`),await Me(o,n,{keepLast:typeof e.keepLast=="number"?e.keepLast:void 0,maxCacheAgeDays:typeof e.maxAgeDays=="number"?e.maxAgeDays:void 0,maxCacheSize:e.maxSize})},Q=e=>e??process.cwd(),ht=async({argument:e,logger:s,options:t,workspaceRoot:r})=>{const n=e[0];if(!n){c.error("No task ID specified. Usage: vis cache why <project>:<target>"),process.exitCode=1;return}await Ge(n,{format:t.format??"table",runId:t.run,workspaceRoot:Q(r)},s)},ft=async({argument:e,logger:s,options:t,visConfig:r,workspaceRoot:n})=>{const a=e[0];if(!a){c.error("No task ID specified. Usage: vis cache hash <project>:<target>"),process.exitCode=1;return}const{directoriesFor:o}=w(n,t,r);await Re(a,{cacheDirectories:o("read"),format:t.format??"table",runId:t.run,workspaceRoot:Q(n)},s)},ut=async({options:e,visConfig:s,workspaceRoot:t})=>{const r=Z(e.type);if((e.format??"table")==="json"){const a={};if(m(r,"task")){const{directoriesFor:o}=w(t,e,s),i=o("read");a.task=await Promise.all(i.map(async d=>{const f=R(d),h=f?await k(d):[],u=h.reduce((l,S)=>l+S.sizeBytes,0);return{directory:d,entries:h.length,exists:f,newestEntry:y(h[0]?.mtimeMs),oldestEntry:y(h.at(-1)?.mtimeMs),totalBytes:u}}))}if(m(r,"ai")){const o=M();a.ai={entries:o.entries,newestEntry:y(o.newestEntry),oldestEntry:y(o.oldestEntry),totalBytes:o.totalSizeBytes}}if(m(r,"socket")){const o=I();a.socket={entries:o.entries,newestEntry:y(o.newestEntry),oldestEntry:y(o.oldestEntry),totalBytes:o.totalSizeBytes}}if(m(r,"deps-dev")){const o=N();a["deps-dev"]={entries:o.entries,newestEntry:y(o.newestEntry),oldestEntry:y(o.oldestEntry),totalBytes:o.totalSizeBytes}}if(m(r,"snyk")){const o=z();a.snyk={entries:o.entries,newestEntry:y(o.newestEntry),oldestEntry:y(o.oldestEntry),totalBytes:o.totalSizeBytes}}process.stdout.write(`${JSON.stringify(a,void 0,2)}
12
- `);return}if(m(r,"task")){const{directoriesFor:a}=w(t,e,s),o=a("read");for(const i of o)o.length>1&&c.info(`# ${i}`),await Ne(i,"table")}m(r,"ai")&&D("AI response cache",M()),m(r,"socket")&&D("Socket.dev report cache",I()),m(r,"deps-dev")&&D("deps.dev cache",N()),m(r,"snyk")&&D("Snyk issue cache",z())},lt=async({argument:e,logger:s,options:t,visConfig:r,workspaceRoot:n})=>{const a=e[0];if(!a){c.error("No task ID specified. Usage: vis cache verify <project>:<target>"),process.exitCode=1;return}const{directoriesFor:o,workspaceRoot:i}=w(n,t,r),d=o("read");await _e(a,{cacheDirectories:d,format:t.format??"table",workspaceRoot:i},s)};export{ct as cacheCleanExecute,ft as cacheHashExecute,it as cacheListExecute,dt as cachePruneExecute,ut as cacheSizeExecute,lt as cacheVerifyExecute,ht as cacheWhyExecute,ve as clearAiCacheSafe,Ce as clearDepsDevCacheSafe,ge as clearSnykCacheSafe,ke as clearSocketCacheSafe,k as collectCacheEntries,ie as formatAge,De as runClean,Re as runHash,Be as runList,Me as runPrune,Ne as runSize,_e as runVerify,Ge as runWhy};
1
+ import{createRequire as be}from"node:module";import{F as $,b as L,X as ce,J,q as ae}from"../packem_shared/index.server-Ca_EEVfw.js";import{v as R,a as G,U as I,z as Se,e as M}from"../packem_shared/index-0dnGN3GP.js";import{fingerprint as E,scan as le,scanFiles as Ee,inspectRuleset as Ie,listRules as K,listRequiredValidators as Re,scanGitHistory as Te}from"@visulima/secret-scanner";import{V as Ae,W as Q,p as y}from"./cli-main.js";import{E as je,A as Ne}from"../packem_shared/getRandomSpinner-DX11qCB2-CoIsn7ZU.js";import{U as Fe}from"../packem_shared/env-BymuoTL8.js";import{y as X}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{p as Me}from"../packem_shared/package-version-x7sPg2TM.js";let ve;const ke=e=>(ve??=be(import.meta.url))(e),j=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,W=e=>{if(typeof j<"u"&&j.versions&&j.versions.node){const[t,n]=j.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return j.getBuiltinModule(e)}return ke(e)},{createRequire:Ce}=W("node:module"),{pathToFileURL:ue}=W("node:url"),{execFileSync:Le}=W("node:child_process");let Oe;const _e=e=>(Oe??=Ce(import.meta.url))(e),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Be=e=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[t,n]=N.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return N.getBuiltinModule(e)}return _e(e)},{styleText:qe}=Be("node:util"),Ue={error:"✖",info:"ℹ",success:"✓",warning:"⚠"},De=()=>{const{env:e}=process;return!!e.CI||e.CONTINUOUS_INTEGRATION==="true"||"BUILD_NUMBER"in e||"RUN_ID"in e},Pe=/\u001B\[[\d;]*[a-z]/gi,He=e=>[...e.replaceAll(Pe,"")].length,Ve=e=>{const t=[];return e.bold&&t.push("bold"),e.dim&&t.push("dim"),e.italic&&t.push("italic"),e.underline&&t.push("underline"),e.strikethrough&&t.push("strikethrough"),e.color&&t.push(e.color),e.bgColor&&t.push(e.bgColor),t.length===0?n=>n:n=>qe(t,n)};let ze=class{#i=0;#l;#e=!1;#r="";#o="";#m=0;#u=0;#t;#n;#f="";#c;#p;#s;#x;#d=0;#a;#b;constructor(t={},n){if(t.frames)this.#c=t.frames;else{const s=t.name??"dots",r=Ne(s);if(!r)throw new Error(`Unknown spinner "${s}". Pass a custom \`frames\` set or use one of: ${je().join(", ")}.`);this.#c=r}this.#p=t.verbose!==!1,this.#r=t.prefixText??"",this.#t=n,this.#s=t.stream??process.stderr,this.#x=n?!0:this.#s.isTTY&&!De(),this.#b={...Ue,...t.icons},typeof t.style=="function"?this.#a=t.style:t.style&&(this.#a=Ve(t.style))}get elapsedTime(){return this.#m===0?0:(this.#u||Date.now())-this.#m}get text(){return this.#o}set text(t){this.#o=t,this.#e&&this.#w()}get prefixText(){return this.#r}set prefixText(t){this.#r=t,this.#e&&this.#w()}get isRunning(){return this.#e}setInteractiveManager(t){this.#t=t}setMultiSpinner(t){this.#n=t}tick(){this.#e&&(this.#i=(this.#i+1)%this.#c.frames.length)}start(t,n){return this.#e?this:this.#p?(this.#e=!0,this.#m=Date.now(),this.#u=0,this.#i=0,this.#f="",t&&(this.#o=t),n?.prefixText&&(this.#r=n.prefixText),this.#n?(this.#n.renderAll(),this):(this.#t?(this.#t.hook(),this.#v(),this.#y()):(this.#k(),this.#y()),this)):this}stop(){if(this.#e){if(this.#h(),this.#e=!1,this.#u=Date.now(),this.#f="",this.#n){this.#n.renderAll();return}this.#t?(this.#t.erase("stdout"),this.#t.unhook(!1)):this.#$()}}stopAndPersist(t){if(!this.#e||(this.#h(),this.#e=!1,this.#u=Date.now(),!this.#p))return;const n=t?.prefixText??this.#r,s=t?.text??this.#o;let r=t?.symbol??"";n&&(r=r?`${n} ${r}`:n),s&&(r=r?`${r} ${s}`:s),this.#S(r)}succeed(t){this.#g("success",t)}failed(t){this.#g("error",t)}warn(t){this.#g("warning",t)}info(t){this.#g("info",t)}pause(){this.#h()}resume(){this.#e&&(this.#h(),this.#n||this.#y())}getFrameOutput(){if(!this.#e&&this.#f)return this.#f;const t=this.#c.frames[this.#i];let n=this.#a?this.#a(t):t;return this.#r&&(n=`${this.#r} ${n}`),this.#o&&(n=`${n} ${this.#o}`),n}#y(){this.#x&&(this.#l=setInterval(()=>{this.#e&&(this.#i=(this.#i+1)%this.#c.frames.length,this.#w())},this.#c.interval),this.#l.unref())}#h(){this.#l&&(clearInterval(this.#l),this.#l=void 0)}#w(){this.#n?this.#n.renderAll():this.#t?this.#v():this.#k()}#v(){this.#t&&this.#t.update("stdout",[this.getFrameOutput()])}#k(){const t=this.getFrameOutput();if(this.#$(),this.#s.isTTY){this.#s.write(t);const n=this.#s.columns||80;this.#d=Math.max(1,Math.ceil(He(t)/n))}else this.#s.write(`${t}
2
+ `),this.#d=0}#$(){if(this.#d>0&&this.#s.isTTY){for(let t=1;t<this.#d;t+=1)this.#s.write("\x1B[1A\x1B[2K");this.#s.write("\r\x1B[K")}this.#d=0}#S(t){this.#f=t,this.#n?this.#n.renderAll():this.#t?(this.#t.update("stdout",[t]),this.#t.unhook(!1)):(this.#$(),this.#s.write(`${t}
3
+ `))}#g(t,n){if(!this.#e||(this.#h(),this.#e=!1,this.#u=Date.now(),!this.#p))return;let s="";const r=this.#b[t];r&&(s=this.#a?this.#a(r):r),this.#r&&(s=`${this.#r} ${s}`),n&&(s=`${s} ${n}`),this.#S(s)}};const We=(e,t,n)=>{const s=n.toLowerCase();e[s]??=new Map;const r=e[s].get(t);if(r!==void 0)return r;const{size:i}=e[s],c=`<${n.toUpperCase()}${i>0?String(i):""}>`;return e[s].set(t,c),c},Z=(e,t)=>{const{replacement:n,tag:s,text:r}=t;return typeof n=="function"?String(n(r,void 0)):typeof n=="string"?n:We(e,r,s)},Je=(e,t)=>{const n={};let s="",r=0;for(const i of e){const{start:c,text:o}=i;if(o==="")continue;if(Number.isInteger(c)&&c>=0&&t.slice(c,c+o.length)===o){if(c<r)continue;s+=t.slice(r,c)+Z(n,i),r=c+o.length;continue}let a=t.indexOf(o,r);if(a===-1)continue;const l=Z(n,i);for(;a!==-1;)s+=t.slice(r,a)+l,r=a+o.length,a=t.indexOf(o,r)}return s+t.slice(r)},Ge=e=>[...e.reduce((t,n)=>t.set(n.text+String(n.start)+n.tag,n),new Map).values()].toSorted((t,n)=>{const s=t.start-n.start;return s!==0?s:n.text.length-t.text.length}),Ke=(e,t)=>{const n=[];for(const s of e){const{key:r,pattern:i}=s,c=s.compiledPattern??new RegExp(i,"giu");c.lastIndex=0;let o;for(;(o=c.exec(t))!==null;){const a=s;n.push({replacement:a.userReplacement??a.replacement!==void 0?a.replacement:void 0,start:o.index,tag:r,text:o[0]}),o.index===c.lastIndex&&(c.lastIndex+=1)}}return n},Xe=(e,t,n,s)=>Ge([...Ke(n,e)]),fe=(e,t,n)=>{const s=[],r=[];for(const o of t)typeof o=="object"&&o.pattern&&s.push(o),r.push((typeof o=="object"?o.key:String(o)).toLowerCase());let i=e;const c=Xe(e,r,s);return i=Je(c,i),i},k=e=>{const t=typeof e;return e!==null&&(t==="object"||t==="function")},q=new Set(["__proto__","prototype","constructor"]),Ye=Math.max(...[...q].map(e=>e.length)),de=1e6,Qe=e=>e>="0"&&e<="9";function he(e){if(e==="0")return!0;if(/^[1-9]\d*$/.test(e)){const t=Number.parseInt(e,10);return t<=Number.MAX_SAFE_INTEGER&&t<=de}return!1}function D(e,t){return q.has(e)?!1:(e&&he(e)?t.push(Number.parseInt(e,10)):t.push(e),!0)}function Ze(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);const t=[];let n="",s="",r=!1,i="start",c=!1,o=0;for(const a of e){if(o++,c){n+=a,c=!1;continue}if(a==="\\"){if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);c=!0,i=i==="start"?"property":i;continue}switch(a){case".":{if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd"){i="property";break}if(!D(n,t))return[];n="",i="property";break}case"[":{if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd"){i="index";break}if(i==="property"&&n.length<=Ye&&q.has(n))return[];r=i==="property",i="index";break}case"]":{if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);if(i!=="index"){i==="start"&&(i="property"),n+=a;break}if(s===""){n+="[]",i="property";break}if((n!==""||r)&&!D(n,t))return[];n="",r=!1;const l=Number.parseInt(s,10),f=l<=de&&s===String(l);t.push(f?l:s),s="",i="indexEnd";break}default:{if(i==="index"){if(!Qe(a))throw new Error(`Invalid character '${a}' in an index at position ${o}`);s+=a;break}if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);i==="start"&&(i="property"),n+=a}}}switch(c&&(n+="\\"),i){case"property":{if(!D(n,t))return[];break}case"index":throw new Error("Index was not closed");case"start":{t.push("");break}}return t}function U(e){if(typeof e=="string")return Ze(e);if(Array.isArray(e)){const t=[];for(const[n,s]of e.entries()){if(typeof s!="string"&&typeof s!="number")throw new TypeError(`Expected a string or number for path segment at index ${n}, got ${typeof s}`);if(typeof s=="number"&&!Number.isFinite(s))throw new TypeError(`Path segment at index ${n} must be a finite number, got ${s}`);if(q.has(s))return[];typeof s=="string"&&he(s)?t.push(Number.parseInt(s,10)):t.push(s)}return t}return[]}function et(e,t,n){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return e;const s=U(t);if(s.length===0)return n;for(let r=0;r<s.length;r++){const i=s[r];if(e=e[i],e==null){if(r!==s.length-1)return n;break}}return e===void 0?n:e}function tt(e,t,n){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return e;const s=e,r=U(t);if(r.length===0)return e;for(let i=0;i<r.length;i++){const c=r[i];if(i===r.length-1){e[c]=n;continue}const o=e[c];if(k(o)){e=o;continue}const a=typeof r[i+1]=="number";e[c]=a?[]:{},e=e[c]}return s}function nt(e,t){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return!1;const n=U(t);if(n.length===0)return!1;for(let s=0;s<n.length;s++){const r=n[s];if(s===n.length-1)return Object.hasOwn(e,r)?(delete e[r],!0):!1;const i=e[r];if(!k(i))return!1;e=i}}function ee(e,t){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return!1;const n=U(t);if(n.length===0)return!1;for(const s of n){if(!k(e)||!(s in e))return!1;e=e[s]}return!0}const P="#;/?:@&",H=new RegExp(String.raw`([${P}][^${P}=\s]+=[^${P}=\s]*)`,"g"),st=e=>{const t=[];let n=0;H.lastIndex=0;let s=H.exec(e);for(;s!==null;){const{0:i,index:c}=s;t.push({key:void 0,value:e.slice(n,c+1)}),n=c+i.length,t.push({key:i.slice(1,i.indexOf("=")),value:i.slice(i.indexOf("=")+1)}),s=H.exec(e)}const r=e.slice(n);return r.length>0&&t.push({key:void 0,value:r}),t},te=(e,t)=>{for(let n=0;n<e.length;n+=1){let s=e[n].string,r=e[n].index;for(;r<t.length;){const i=t[r];if(!s.includes(i))break;const c=s.slice(1);for(e.push({index:r,string:c}),c.includes(i)||e.pop(),s=s.slice(s.indexOf(i)+i.length),r+=1;t[r]==="";)r+=1;if(r>=t.length){if(t.at(-1)!==""&&s.length>0)break;return!0}}}return!1},V=(e,t)=>{if(!t.includes("*"))return t===e;const n=t.split("*");let s=0,r=e;for(;n[s]==="";)if(s+=1,s===t.length)return!0;if(s===0&&!e.startsWith(n[0]))return!1;const i=[];for(;s<n.length;){const c=n[s];if(!r.includes(c))return te(i,n);const o=r.slice(1);for(i.push({index:s,string:o}),o.includes(c)||i.pop(),r=r.slice(r.indexOf(c)+c.length),s+=1;n[s]==="";)s+=1}return s>=n.length&&n.at(-1)!==""&&r.length>0?r===e?!1:te(i,n):!0},rt=/(?:http|https):\/\/?/,T=(e,t,n)=>typeof e.replacement=="function"?e.replacement(t,n):e.replacement,pe=(e,t,n)=>e.wildcard?V(t,e.key)||V(n,e.key):t===e.key||n===e.key,it=(e,t,n,s)=>{n.remove?delete e[t]:e[t]=T(n,e[t],s)},ne=(e,t,n,s,r,i)=>{const c=[],o=[];for(const l of s)!l.wildcard&&!l.deep&&ee(e,l.key)?o.push(l):c.push(l);const a=Object.keys(e);for(const l of a){if(!Object.hasOwn(e,l))continue;const f=l.toLowerCase(),u=i?`${i}.${f}`:f;let h;for(const g of c)pe(g,f,u)&&(h=g);h?it(e,l,h,u):e[l]=x(e[l],t,n,c,r,u)}for(const l of o)if(ee(e,l.key))if(l.remove)nt(e,l.key);else{const f=i?`${i}.${l.key}`:l.key;tt(e,l.key,T(l,et(e,l.key),f))}},se=(e,t)=>{const n=t.toLowerCase();return e.find(s=>s.key===n||!!s.wildcard&&V(n,s.key))},ot=(e,t,n)=>{const s=st(e),r=[];for(const i of s){const{key:c,value:o}=i;if(c===void 0){const a=se(t,o);r.push(a?String(T(a,o,void 0)):fe(o,t))}else{const a=se(t,c);a?r.push(`${c}=${String(T(a,o,void 0))}`):r.push(`${c}=${o}`)}}return r.join("")},x=(e,t,n,s,r,i)=>{if(e==null)return e;if(typeof e=="object"&&e.constructor===String)return x(String(e),t,n,s,r,i);if(typeof e=="object"&&t.has(e))return t.get(e);if(typeof e=="object"&&!Array.isArray(e)){if(e instanceof Error){const o=new Error(e.message);Object.defineProperties(o,{name:{configurable:!0,enumerable:!1,value:e.name,writable:!0},stack:{configurable:!0,enumerable:!1,value:e.stack,writable:!0}}),e.code!==void 0&&(o.code=e.code);const a=Object.keys(e);for(const l of a)o[l]=e[l];return n(e,o),ne(o,t,n,s,r,i),o}if(e instanceof Map){const o=new Map;n(e,o);const a=e.entries();let l=a.next();for(;!l.done;){const[f,u]=l.value;if(typeof f=="string"||typeof f=="object"&&f!==null&&f.constructor===String){const h=f.toLowerCase(),g=i?`${i}.${h}`:h;let p;for(const m of s)pe(m,h,g)&&(p=m);p?p.remove||o.set(f,T(p,u,g)):o.set(f,x(u,t,n,s,r,g))}else o.set(x(f,t,n,s,r),x(u,t,n,s,r));l=a.next()}return o}if(e instanceof Set){const o=new Set;n(e,o);const a=e.values();let l=a.next();for(;!l.done;)o.add(x(l.value,t,n,s,r,i)),l=a.next();return o}const c={...e};return n(e,c),ne(c,t,n,s,r,i),c}if(typeof e=="string"){const c=e;try{const o=JSON.parse(c);if(typeof o=="object"&&o!==null){const a=x(o,t,n,s,r,i);return JSON.stringify(a)}}catch{}return rt.test(c)?ot(c,s):fe(c,s)}if(Array.isArray(e)){const c=[];n(e,c);for(const[o,a]of e.entries()){const l=o.toString().toLowerCase(),f=i?`${i}.${l}`.toLowerCase():l,u=s.find(h=>h.key===l||h.key===f);u?c.push(T(u,a,f)):c.push(x(a,t,n,s,r,f))}return c}return e},ct=(e,t)=>{const n=[];for(const s of e)if(typeof s=="string"){const r=s.includes("*");n.push({deep:!1,key:s.toLowerCase(),replacement:`<${s.toUpperCase()}>`,userReplacement:!1,wildcard:r})}else if(typeof s=="number")n.push({deep:!1,key:s.toString(),replacement:"<REDACTED>"});else{const r=s.key.toLowerCase(),i={...s,key:r,replacement:s.replacement??`<${r.toUpperCase()}>`,userReplacement:s.replacement!==void 0,wildcard:r.includes("*")?!0:s.wildcard};if(i.pattern!==void 0){const c=i.pattern instanceof RegExp?i.pattern.source:i.pattern;i.compiledPattern=new RegExp(c,"giu")}n.push(i)}return n},at=(e,t,n)=>{if(e==null||typeof e=="number"||typeof e=="boolean")return e;const s=new WeakMap;return x(e,s,(r,i)=>{s.set(r,i)},t,n)},ge=(e,t,n)=>{const s=ct(t);return at(e,s,n)},Y=(e={})=>{const t=new Ae(new Q(process.stdout),new Q(process.stderr));return new ze(e,t)},lt=(e,t)=>{if(!R(e))return e;const n=G(t,e);return n===""||n.startsWith("..")?e:n},A=(e,t)=>{const n=lt(e.file,t);return n===e.file?e:{...e,file:n}},me=e=>{if(!X(e))return[];try{const t=Me(e);return Array.isArray(t)?t:[]}catch{return[]}},ut=(e,t,n)=>{const s=me(t).map(o=>A(o,n)),r=new Set(s.map(o=>E(o))),i=e.map(o=>A(o,n)),c=new Set(i.map(o=>E(o)));return{fresh:i.filter(o=>!r.has(E(o))),resolved:s.filter(o=>!c.has(E(o))),surviving:i.filter(o=>r.has(E(o)))}},ye=(e,t,n,s={})=>{const r=e.map(c=>A(c,n));let i;if(s.replace)i=r;else{const c=me(t).map(a=>A(a,n)),o=new Set;i=[];for(const a of[...c,...r]){const l=E(a);o.has(l)||(o.add(l),i.push(a))}}return Fe(t,`${JSON.stringify(i,null,4)}
4
+ `),i.length},re=1,ft=e=>{const t=new Map;for(const n of e){const s=t.get(n.file);s?s.push(n):t.set(n.file,[n])}return t},dt=e=>{try{return Se(e).split(/\r?\n/)}catch{return}},ht=(e,t,n)=>{const s=Math.max(1,t);return`${e.slice(0,s-1).replaceAll(/[^\t]/g," ")}${"^".repeat(Math.max(1,n))}`},pt=(e,t,n,s={})=>{if(e.length===0)return n?$("No secrets detected."):"No secrets detected.";const r=n?{cyan:ae,dim:$,green:J,red:ce,yellow:L}:{cyan:o=>o,dim:o=>o,green:o=>o,red:o=>o,yellow:o=>o},i=[],c=ft(e);for(const[o,a]of c){const l=G(t,o)||o;i.push(r.cyan(l));const f=s.redact?void 0:dt(o);for(const u of a){const h=[u.source,u.confidence].filter(Boolean).join(", "),g=h?` ${r.dim(`(${h})`)}`:"",p=u.alternateMatches&&u.alternateMatches.length>0?` ${r.dim(`also: ${u.alternateMatches.join(", ")}`)}`:"";let m="";switch(u.validation){case"error":{m=` ${r.yellow("! error")}`;break}case"rejected":{m=` ${r.red("✗ rejected")}`;break}case"skipped":{m=` ${r.dim("— unverifiable")}`;break}case"verified":{m=` ${r.green("✓ verified")}`;break}}if(i.push(` ${r.red("✖")} ${r.yellow(`[${u.ruleId}]`)}${g}${m} ${r.dim(`line ${String(u.startLine)}:${String(u.startColumn)}`)}${p}`),f){const C=Math.max(0,u.startLine-1-re),b=Math.min(f.length,u.startLine+re);for(let d=C;d<b;d+=1){const S=String(d+1).padStart(4," "),v=d+1===u.startLine,w=v?r.red("▶"):" ";if(i.push(` ${w} ${r.dim(S)} │ ${f[d]??""}`),v){const O=Math.max(1,(u.endColumn??u.startColumn+1)-u.startColumn),xe=ht(f[d]??"",u.startColumn,O);i.push(` ${r.dim(" │ ")}${r.red(xe)}`)}}}i.push("")}}return i.join(`
5
+ `).trimEnd()},gt=(e,t,n={})=>{if(e.length===0)return t?$("No secrets detected in git history."):"No secrets detected in git history.";const s=t?{cyan:ae,dim:$,green:J,red:ce,yellow:L}:{cyan:c=>c,dim:c=>c,green:c=>c,red:c=>c,yellow:c=>c},r=new Map;for(const c of e){const o=r.get(c.commit.sha);o?o.push(c):r.set(c.commit.sha,[c])}const i=[];for(const[c,o]of r){const{authorName:a,date:l,message:f}=o[0].commit;i.push(`${s.yellow(c.slice(0,10))} ${f}`),i.push(` ${s.dim(`${a} · ${l}`)}`);for(const u of o){const h=[u.source,u.confidence].filter(Boolean).join(", "),g=h?` ${s.dim(`(${h})`)}`:"",p=n.redact?"":` ${s.dim(u.match)}`;i.push(` ${s.red("✖")} ${s.yellow(`[${u.ruleId}]`)}${g} ${s.cyan(u.file)} ${s.dim(`line ${String(u.startLine)}:${String(u.startColumn)}`)}${p}`)}i.push("")}return i.join(`
6
+ `).trimEnd()},mt=(e,t)=>{if(!R(e))return e.replaceAll("\\","/");try{return ue(e).toString()}catch{return`file://${I(t,e).replaceAll("\\","/")}`}},yt=(e,t=100)=>e.length<=t?e:`${e.slice(0,t-1).trimEnd()}…`,we=(e,t,n=process.cwd(),s=[])=>{const r=new Map(s.map(a=>[a.id,a])),i=new Set;for(const a of e)i.add(a.ruleId);const c=[...new Set([...r.keys(),...i])].sort((a,l)=>a.localeCompare(l)),o=new Map(c.map((a,l)=>[a,l]));return JSON.stringify({$schema:"https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0.json",runs:[{originalUriBaseIds:{SRCROOT:{uri:ue(n).toString()}},results:e.map(a=>{const l={};return a.source&&(l.source=a.source),a.confidence&&(l.confidence=a.confidence),a.alternateMatches&&a.alternateMatches.length>0&&(l.alternateRules=a.alternateMatches),a.validation&&(l.validation=a.validation),{level:"error",locations:[{physicalLocation:{artifactLocation:{uri:mt(a.file,n),uriBaseId:R(a.file)?void 0:"SRCROOT"},region:{endColumn:a.endColumn,endLine:a.endLine,snippet:{text:a.match},startColumn:a.startColumn,startLine:a.startLine}}}],message:{text:a.description||a.ruleId},properties:Object.keys(l).length>0?l:void 0,ruleId:a.ruleId,ruleIndex:o.get(a.ruleId)??-1}}),tool:{driver:{informationUri:"https://visulima.com/packages/secret-scanner",name:"visulima-secret-scanner",rules:c.map(a=>{const l=r.get(a),f=l?.description??`Detected by rule \`${a}\``,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:f},helpUri:"https://visulima.com/packages/secret-scanner",id:a,name:a,properties:Object.keys(u).length>0?u:void 0,shortDescription:{text:yt(f)}}}),version:t}}}],version:"2.1.0"},void 0,2)},B=(e,t)=>{try{return Le("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim()}catch{return""}},z=e=>e.split(/\r?\n/).map(t=>t.trim()).filter(Boolean),wt=e=>z(B(e,["diff","--cached","--name-only","--diff-filter=ACMR"])).map(t=>R(t)?t:M(e,t)),ie=(e,t)=>{const n=B(e,["diff","--name-only","--diff-filter=ACMR",`${t}...HEAD`]),s=z(n);if(s.length===0){const r=B(e,["diff","--name-only","--diff-filter=ACMR",t]);return z(r).map(i=>R(i)?i:M(e,i))}return s.map(r=>R(r)?r:M(e,r))},_=e=>B(e,["rev-parse","--show-toplevel"]).length>0,F=".secrets-baseline.json",oe=e=>e?Array.isArray(e)?e:[e]:[],$e=e=>{const t=new Set(["json","sarif","text"]);if(e&&!t.has(e))throw new Error(`--format must be one of: ${[...t].join(", ")} (got "${e}")`);return e??"text"},$t=e=>{if(e===void 0)return;const t=new Set(["high","low","medium"]);if(!t.has(e))throw new Error(`--min-confidence must be one of: ${[...t].join(", ")} (got "${e}")`);return e},xt=async(e,t)=>{const n=await K(e);process.stdout.write(`${String(n.length)} rules loaded
7
+
8
+ `);for(const s of n){const r=t?L(s.id):s.id,i=s.tags.length>0?` ${t?$(`[${s.tags.join(", ")}]`):`[${s.tags.join(", ")}]`}`:"";if(process.stdout.write(`${r}${i}
9
+ ${s.description}
10
+ `),s.keywords.length>0){const c=`keywords: ${s.keywords.slice(0,6).join(", ")}${s.keywords.length>6?", ...":""}`;process.stdout.write(` ${t?$(c):c}
11
+ `)}process.stdout.write(`
12
+ `)}},bt=async(e,t)=>{const n=await Re(e);if(n.length===0){process.stdout.write(t?`${$("No non-HTTP validators required by the current ruleset.")}
13
+ `:`No non-HTTP validators required by the current ruleset.
14
+ `);return}process.stdout.write(`${String(n.length)} non-HTTP validator type(s) referenced by the current ruleset:
15
+
16
+ `);for(const s of n){const r=t?L(s.displayName):s.displayName,i=`(${s.type}, ${String(s.ruleCount)} rule${s.ruleCount===1?"":"s"})`;process.stdout.write(`${r} ${t?$(i):i}
17
+ `),process.stdout.write(` ${s.summary}
18
+ `);const c=s.packageName?`install: npm add ${s.packageName}`:"no driver — bespoke implementation required";process.stdout.write(` ${t?$(c):c}
19
+
20
+ `)}},vt=async(e,t,n)=>{const s=M(e,F);if(!n&&X(s)){y.warn(`Detected existing ${F} — refusing to overwrite. Delete it first to re-init.`),process.exitCode=1;return}y.info(n?"[dry-run] Previewing init — no files will be written.":"Scanning workspace to seed baseline…");const r=Y();r.start("scanning");let i;try{i=await le([e],t),r.succeed()}catch(o){throw r.failed(),o}if(n){y.info(`[dry-run] Would create ${F} with ${String(i.length)} finding(s).`);return}const c=ye(i,s,e,{replace:!0});y.success(`Wrote ${F} (${String(c)} findings).`),y.notice("Commit it. Use `vis secrets --baseline .secrets-baseline.json` in CI. Add path patterns to .gitignore to exclude directories from scanning.")},kt=(e,t,n)=>{const s=t??{},r=d=>d?I(n,d):void 0,i=(d,S)=>{const v=oe(d);return v.length>0?v:S},c=(s.config?.presets??[]).map(d=>`tag:preset:${d}`),o=i(e.enableRule,s.rules?.enable)??[],a=[...o,...c.filter(d=>!o.includes(d))],l=a.length>0?a:void 0,f=i(e.excludeRule,s.rules?.exclude),u=i(e.includeRule,s.rules?.include),h=i(e.exclude,s.walk?.excludePatterns),g=oe(e.excludeFrom).map(d=>I(n,d)),p=g.length>0?g:s.walk?.excludeFromFiles?.map(d=>I(n,d)),m=r(e.baseline)??r(s.baseline),C=r(e.config)??r(s.config?.path),b=$t(e.minConfidence??s.config?.minConfidence);return{baseline:m,concurrency:e.concurrency,config:{extendBundled:e.extendBundled===!1?!1:s.config?.extendBundled,inline:s.config?.inline,minConfidence:b,onlyVerified:e.onlyVerified??s.config?.onlyVerified??!1,path:C,validate:e.validate??s.config?.validate??!1},redact:e.redact??s.redact,rules:{enable:l,exclude:f,include:u},verbose:e.verbose??!1,walk:{excludeFromFiles:p,excludePatterns:h,gitignore:e.gitignore===!1?!1:s.walk?.gitignore??!0,includeHidden:e.includeHidden??s.walk?.includeHidden,maxFileSize:e.maxSize??s.walk?.maxFileSize}}},St=e=>{process.stderr.write(`${$("baseline diff: ")}${J(`+${String(e.fresh.length)} new`)} · ${L(`${String(e.surviving.length)} unchanged`)} · ${$(`-${String(e.resolved.length)} resolved`)}
21
+ `)},Et=async(e,t,n)=>{if(e.staged){if(!_(n))throw new Error("--staged requires a git working tree, and none was detected.");return{files:wt(n)}}if(e.since){if(!_(n))throw new Error("--since requires a git working tree, and none was detected.");return{files:ie(n,e.since)}}if(e.affected){if(!_(n))return y.warn("--affected requires git; falling back to full scan"),{paths:t&&t.length>0?t.map(r=>I(n,r)):[n]};const s=process.env.VIS_BASE??"HEAD~1";return{files:ie(n,s)}}return{paths:t&&t.length>0?t.map(s=>I(n,s)):[n]}},It=(e,t,n,s,r,i,c)=>{switch(t){case"json":{const o=e.map(a=>A(a,n));process.stdout.write(`${JSON.stringify(o,null,2)}
22
+ `);break}case"sarif":{process.stdout.write(`${we(e,r,n,i)}
23
+ `);break}default:process.stdout.write(`${pt(e,n,s,{redact:c})}
24
+ `)}},Rt=async(e,t,n,s,r)=>{if(e.staged||e.since||e.affected)throw new Error("--history scans commit history and can't be combined with --staged / --since / --affected (those scan the working tree).");if(!_(t))throw new Error("--history requires a git working tree, and none was detected.");const i=$e(e.format),c=!e.quiet&&i==="text",o=Y({verbose:c});o.start("scanning git history for secrets");let a;try{a=await Te({...n,cwd:t,maxCommits:e.maxCommits,range:e.historyRange}),o.succeed()}catch(u){throw o.failed(),new Error(`git-history secret scan failed: ${u instanceof Error?u.message:String(u)}`,{cause:u})}const l=n.redact===!0,f=l?ge(a,["match","secret"]):a;switch(i){case"json":{process.stdout.write(`${JSON.stringify(f.map(u=>A(u,t)),null,2)}
25
+ `);break}case"sarif":{const u=await K(n).catch(()=>[]);process.stdout.write(`${we(f,r,t,u)}
26
+ `);break}default:process.stdout.write(`${gt(f,s,{redact:l})}
27
+ `)}if(a.length>0){e.quiet||(y.warn(`${String(a.length)} potential secret(s) found across git history`),y.notice("Findings reference the commit that introduced them — rotate the credential and rewrite history (e.g. git filter-repo) if it is still reachable.")),process.exitCode=1;return}e.quiet||y.success("No secrets detected in git history.")},Bt=async({argument:e,options:t,visConfig:n,workspaceRoot:s})=>{const r=t,i=e,c=s??process.cwd(),o=!r.quiet&&process.stdout.isTTY,a=n?.secrets,l=kt(r,a,c),f="0.0.0-alpha";if(r.listRules){await xt(l,o);return}if(r.listValidators){await bt(l,o);return}if(r.init){await vt(c,l,r.dryRun??!1);return}if(r.history){await Rt(r,c,l,o,f);return}const u=await Et(r,i??[],c);if(u.files?.length===0){r.quiet||y.success("No files to scan.");return}const h=!r.quiet&&!["json","sarif"].includes(r.format??"text"),g=Y({verbose:h});g.start("scanning for secrets");let p;try{p=u.files===void 0?await le(u.paths??[c],l):await Ee(u.files,l),g.succeed()}catch(w){throw g.failed(),new Error(`secret scan failed: ${w instanceof Error?w.message:String(w)}`,{cause:w})}if(r.verbose){const w=await Ie(l);if(w.length>0){y.warn(`${String(w.length)} rule(s) skipped due to invalid regex. First few:`);for(const O of w.slice(0,5))process.stderr.write(` - ${O.ruleId}: ${O.reason}
28
+ `)}}const m=typeof l.baseline=="string"?l.baseline:M(c,F),C=!r.quiet&&X(m);if(r.updateBaseline){const w=ye(p,m,c,{replace:r.replaceBaseline});y.success(`Baseline updated: ${G(c,m)||m} now contains ${String(w)} entries.`);return}const b=$e(r.format),d=b==="sarif"?await K(l).catch(()=>[]):[],S=l.redact===!0,v=S?ge(p,["match","secret"]):p;if(It(v,b,c,o,f,d,S),b==="text"&&C&&St(ut(p,m,c)),p.length>0){r.quiet||(y.warn(`${String(p.length)} potential secret(s) found`),y.notice("Suppress individual lines with `gitleaks:allow` / `secret-scanner:allow`, or run `vis secrets --update-baseline`.")),process.exitCode=1;return}r.quiet||y.success("No secrets detected.")};export{Bt as default,kt as resolveScanOptions};
@@ -1,25 +1,12 @@
1
- import{createRequire as Q}from"node:module";import{J as v,j as w,F as g,q as x,b,X as D}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as I,z as se,a as $}from"../packem_shared/index-BzhrR_iC.js";import U from"./index.js";import{y as _}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{T as oe,R as F,k as ne,$ as ae,a0 as ie,a1 as re,a2 as ce}from"./cli-main.js";import{h as pe,i as z,q as W,p as L,F as K}from"../packem_shared/registry-B6LWRK9T.js";import{p as S}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";import{U as fe}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{T as j}from"../packem_shared/target-merge-DVJl-7Qz.js";import{l as le}from"../packem_shared/missing-package-json-DDVQ_scH.js";import{readCatalogs as ue}from"./catalog2.js";let Z;const ee=e=>(Z??=Q(import.meta.url))(e),V=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,te=e=>{if(typeof V<"u"&&V.versions&&V.versions.node){const[a,s]=V.versions.node.split(".").map(Number);if(a>22||a===22&&s>=3||a===20&&s>=16)return V.getBuiltinModule(e)}return ee(e)},{readFileSync:Y,writeFileSync:H}=te("node:fs"),de=e=>/[*?[\]{}!]/.test(e),ge=e=>typeof e=="string"?e:e.reason,me=e=>typeof e=="string"?void 0:e.replacement,q=(e,a)=>e.some(s=>U(s,a)),G=(e,a)=>{if(typeof e=="string")return!0;const s=Array.isArray(e.packages)&&e.packages.length>0,t=Array.isArray(e.paths)&&e.paths.length>0;return!!(!s&&!t||s&&a.packageName!==void 0&&q(e.packages,a.packageName)||t&&q(e.paths,a.packageDir))},he=(e,a)=>{const s=a[e.depName];if(s!==void 0&&G(s,e))return{pattern:e.depName,rule:s};for(const[t,r]of Object.entries(a))if(de(t)&&U(t,e.depName)&&G(r,e))return{pattern:t,rule:r}},ke=(e,a)=>{if(Object.keys(a).length===0)return[];const s=[];for(const t of e){if(t.isInternal)continue;const r=he(t,a);r&&s.push({depName:t.depName,depType:t.depType,matchedPattern:r.pattern,packageDir:t.packageDir,packageJsonPath:t.packageJsonPath,packageName:t.packageName,reason:ge(r.rule),replacement:me(r.rule),specifier:t.specifier})}return s},ye=new Set(["dependencies","devDependencies","peerDependencies"]),Pe=e=>e.startsWith("catalog:"),$e=e=>e.startsWith("workspace:"),we=(e,a)=>{if(!e)return!1;for(const s of e.values())if(s.has(a))return!0;return!1},ve=(e,a={})=>{const s=a.min??3,t=new Set(a.ignoreDeps),r=e.filter(i=>i.isInternal||!ye.has(i.depType)||$e(i.specifier)||a.dep!==void 0&&i.depName!==a.dep?!1:!t.has(i.depName)),n=new Map;for(const i of r){const c=n.get(i.depName);c?c.push(i):n.set(i.depName,[i])}const o=[];for(const[i,c]of n){if(we(a.catalogs,i)||c.some(h=>Pe(h.specifier)))continue;const p=new Map;for(const h of c){let d=p.get(h.specifier);d||(d=new Set,p.set(h.specifier,d)),d.add(h.packageJsonPath)}const m=[...p.entries()].sort((h,d)=>h[1].size!==d[1].size?d[1].size-h[1].size:h[0].localeCompare(d[0]))[0];!m||m[1].size<s||o.push({catalogName:"default",depName:i,instanceCount:m[1].size,specifier:m[0]})}return o.sort((i,c)=>i.depName.localeCompare(c.depName))},De=(e,a)=>{if(a.length===0)return;const s=I(e,"pnpm-workspace.yaml"),r=_(s)?Y(s,"utf8"):"",n=r.includes(`\r
2
- `)?`\r
3
- `:`
4
- `,o=a.filter(d=>d.catalogName==="default").sort((d,u)=>d.depName.localeCompare(u.depName));if(o.length===0)return;const i=r.length>0?r.split(n):[],c=i.findIndex(d=>/^catalog\s*:\s*$/.test(d));if(c===-1){const d=["catalog:"];for(const J of o)d.push(` ${J.depName}: "${J.specifier}"`);let u=0;for(;u<i.length&&(i[u]??"").trim().length===0;)u+=1;const k=[...i.slice(0,u),...d,"",...i.slice(u)].join(n);return H(s,k.endsWith(n)?k:`${k}${n}`),s}let p=i.length;const f=new Set;for(let d=c+1;d<i.length;d+=1){const u=i[d]??"",k=u.trimStart();if(u.length===0)continue;if(u.length-k.length===0&&k.length>0&&!k.startsWith("#")){p=d;break}const P=/^([\w./@-]+)\s*:/.exec(k);P?.[1]&&f.add(P[1])}const m=[];for(const d of o)f.has(d.depName)||m.push(` ${d.depName}: "${d.specifier}"`);if(m.length===0)return;const h=[...i.slice(0,p),...m,...i.slice(p)].join(n);return H(s,h.endsWith(n)?h:`${h}${n}`),s},be=(e,a)=>{if(a.length===0)return"";const s=I(e,"pnpm-workspace.yaml"),r=_(s)?Y(s,"utf8"):"",n=[...a].sort((f,m)=>f.depName.localeCompare(m.depName)),o=["--- pnpm-workspace.yaml","+++ pnpm-workspace.yaml"],i=r.includes(`\r
5
- `)?`\r
6
- `:`
7
- `;if((r.length>0?r.split(i):[]).findIndex(f=>/^catalog\s*:\s*$/.test(f))===-1){o.push("@@ +1 @@","+catalog:");for(const f of n)o.push(`+ ${f.depName}: "${f.specifier}"`)}else{o.push("@@ catalog: @@");for(const f of n)o.push(`+ ${f.depName}: "${f.specifier}"`)}return o.join(i)},Ne=e=>{const a=[],s=pe(e);if(s){const r=I(e,"pnpm-workspace.yaml");for(const n of s)n.startsWith("!")||z(e,[n]).length===0&&a.push({pattern:n,source:"pnpm-workspace.yaml",sourcePath:r})}const t=I(e,"package.json");if(_(t)){const n=S(t).workspaces,o=Array.isArray(n)?n:n?.packages;if(o)for(const i of o)typeof i!="string"||i.startsWith("!")||z(e,[i]).length===0&&a.push({pattern:i,source:"package.json",sourcePath:t})}return a},Te=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.sourcePath);o?o.push(n):t.set(n.sourcePath,[n])}const r=[];for(const[n,o]of t){const i=new Set(o.map(m=>m.pattern));if(n.endsWith(".yaml")||n.endsWith(".yml")){const h=se(n).split(`
8
- `).filter(d=>{const u=d.trim();if(!u.startsWith("- "))return!0;const k=u.slice(2).replaceAll(/^['"]|['"]$/g,"");return!i.has(k)}).join(`
9
- `);fe(n,h,{overwrite:!0}),r.push(n);continue}const p=S(n),f=p.workspaces;Array.isArray(f)?p.workspaces=f.filter(m=>typeof m!="string"||!i.has(m)):f&&Array.isArray(f.packages)&&(f.packages=f.packages.filter(m=>typeof m!="string"||!i.has(m))),j(n,p,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},xe=["dependencies","devDependencies","peerDependencies","optionalDependencies"],Je=(e,a={})=>{const s=new Set(a.ignoreBlocks),t=oe(e),r=[];for(const n of t){const o=I(e,n,"package.json"),i=F(o);if(!i)continue;const c=typeof i.name=="string"?i.name:void 0;for(const p of xe){if(s.has(p))continue;const f=i[p];typeof f=="object"&&f!==null&&!Array.isArray(f)&&Object.keys(f).length===0&&r.push({depType:p,packageDir:n,packageJsonPath:o,packageName:c})}}return r},Se=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n);for(const c of o){const p=i[c.depType];typeof p=="object"&&p!==null&&!Array.isArray(p)&&Object.keys(p).length===0&&Reflect.deleteProperty(i,c.depType)}j(n,i,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},Ie=["dependencies","devDependencies","optionalDependencies","peerDependencies"],Me=(e,a={})=>{const s=new Set(a.depTypes??Ie),t=new Set(a.ignoreDeps),r=new Map;for(const o of e)o.packageDir!=="."||!s.has(o.depType)||r.set(o.depName,{depType:o.depType,specifier:o.specifier});if(r.size===0)return[];const n=[];for(const o of e){if(o.packageDir==="."||!s.has(o.depType)||t.has(o.depName))continue;const i=r.get(o.depName);i&&n.push({childSpecifier:o.specifier,depName:o.depName,depType:o.depType,packageDir:o.packageDir,packageJsonPath:o.packageJsonPath,packageName:o.packageName,rootDepType:i.depType,rootSpecifier:i.specifier})}return n},We=(e,a)=>{if(!a)return[];const s=I(e,"package.json"),t=F(s);if(!t)return[];if(t.private!==!0)return[];const r=t.dependencies;if(typeof r!="object"||r===null||Array.isArray(r))return[];const n=Object.keys(r);return n.length===0?[]:[{depNames:n,packageJsonPath:s}]},je=(e,a={})=>{const{useEditorconfig:s}=a,t=[];for(const r of e){const n=S(r.packageJsonPath),o=n.dependencies;if(typeof o!="object"||o===null)continue;const i=o;n.devDependencies??={};const c=n.devDependencies;for(const p of r.depNames){const f=i[p];typeof f=="string"&&(p in c||(c[p]=f),Reflect.deleteProperty(i,p))}Object.keys(i).length===0&&Reflect.deleteProperty(n,"dependencies"),j(r.packageJsonPath,n,{indent:W(r.packageJsonPath,{useEditorconfig:s}),overwrite:!0}),t.push(r.packageJsonPath)}return t},Ae=/^[a-z][\w-]*@\S+$/i,Ee=(e,a,s={})=>{if(!a)return[];const t=I(e,"package.json"),r=F(t);if(!r)return[];const n=r.packageManager;return typeof n=="string"&&Ae.test(n)?[]:[{packageJsonPath:t,suggested:s.suggested}]},Re=(e,a={})=>{const{useEditorconfig:s}=a,t=[];for(const r of e){if(!r.suggested)continue;const n=S(r.packageJsonPath);n.packageManager=r.suggested,j(r.packageJsonPath,n,{indent:W(r.packageJsonPath,{useEditorconfig:s}),overwrite:!0}),t.push(r.packageJsonPath)}return t},Ce=(e,a)=>{if(!a)return[];const s=I(e,"package.json"),t=F(s);return t?t.private===!0?[]:[{packageJsonPath:s,rawValue:t.private}]:[]},Ve=(e,a={})=>{const{useEditorconfig:s}=a,t=[];for(const r of e){const n=S(r.packageJsonPath);let o=n;if("private"in n)n.private=!0;else{const{name:i,version:c,...p}=n,f={};i!==void 0&&(f.name=i),c!==void 0&&(f.version=c),f.private=!0;for(const[m,h]of Object.entries(p))f[m]=h;o=f}j(r.packageJsonPath,o,{indent:W(r.packageJsonPath,{useEditorconfig:s}),overwrite:!0}),t.push(r.packageJsonPath)}return t},_e=[{id:"react",label:"React",members:["react","react-dom","react-test-renderer"]},{id:"next",label:"Next.js",members:["next","@next/font","@next/bundle-analyzer","@next/mdx","@next/third-parties","@next/eslint-plugin-next","eslint-config-next"]},{id:"babel",label:"Babel",prefixes:["@babel/"]},{id:"storybook",label:"Storybook",members:["storybook","sb"],prefixes:["@storybook/"]},{id:"vitest",label:"Vitest",members:["vitest"],prefixes:["@vitest/"]},{id:"playwright",label:"Playwright",members:["playwright","@playwright/test"]},{id:"trpc",label:"tRPC",prefixes:["@trpc/"]},{id:"prisma",label:"Prisma",members:["prisma"],prefixes:["@prisma/"]},{id:"turborepo",label:"Turborepo",members:["turbo","turbo-ignore","@turbo/gen","eslint-config-turbo","eslint-plugin-turbo"]},{id:"typescript-eslint",label:"typescript-eslint",members:["typescript-eslint"],prefixes:["@typescript-eslint/"]},{id:"eslint-stylistic",label:"ESLint Stylistic",prefixes:["@stylistic/"]},{id:"lexical",label:"Lexical",members:["lexical"],prefixes:["@lexical/"]},{id:"nx",label:"Nx",prefixes:["@nx/","@nrwl/"]}],Fe=new Set(["dependencies","devDependencies","peerDependencies"]),Oe=(e,a)=>{for(const s of e)if(s.members?.includes(a)||s.prefixes?.some(t=>a.startsWith(t)))return s},Be=e=>e.startsWith("workspace:")||e.startsWith("catalog:"),He=(e,a={})=>{const s=new Set(a.ignoreFamilies),t=new Map;for(const i of _e)t.set(i.id,i);for(const i of a.extraFamilies??[])t.set(i.id,i);const r=[...t.values()],n=new Map;for(const i of e){if(i.isInternal||!Fe.has(i.depType)||Be(i.specifier))continue;const c=Oe(r,i.depName);if(!c||s.has(c.id))continue;const p=n.get(c.id),f={depName:i.depName,depType:i.depType,packageDir:i.packageDir,packageJsonPath:i.packageJsonPath,packageName:i.packageName,specifier:i.specifier};p?p.push(f):n.set(c.id,[f])}const o=[];for(const[i,c]of n){const p=[...new Set(c.map(m=>m.specifier))];if(p.length<2)continue;const f=t.get(i);f&&o.push({family:i,familyLabel:f.label??i,members:c,specifiers:p})}return o},ze=e=>e.startsWith("@types/"),Le=(e,a={})=>{const s=new Set(a.ignoreDeps),t=new Map,r=o=>{const i=t.get(o);if(i!==void 0)return i;try{const p=S(o).private===!0;return t.set(o,p),p}catch{return t.set(o,!1),!1}},n=[];for(const o of e)o.depType==="dependencies"&&ze(o.depName)&&(s.has(o.depName)||r(o.packageJsonPath)&&n.push({childSpecifier:o.specifier,depName:o.depName,packageDir:o.packageDir,packageJsonPath:o.packageJsonPath,packageName:o.packageName}));return n},Ke=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n),c=i.dependencies;if(typeof c!="object"||c===null)continue;const p=c;i.devDependencies??={};const f=i.devDependencies;for(const m of o){const h=p[m.depName];typeof h=="string"&&(m.depName in f||(f[m.depName]=h),Reflect.deleteProperty(p,m.depName))}Object.keys(p).length===0&&Reflect.deleteProperty(i,"dependencies"),j(n,i,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},qe=e=>e.startsWith("workspace:"),Ge=(e,a={})=>{const s=a.fixSpecifier??"workspace:*",t=[];for(const r of e)r.isInternal&&(qe(r.specifier)||t.push({depName:r.depName,depType:r.depType,fix:s,packageDir:r.packageDir,packageJsonPath:r.packageJsonPath,packageName:r.packageName,specifier:r.specifier}));return t},Ue=(e,a,s,t)=>{const r=a.split(".");let n=e;for(let c=0;c<r.length-1;c+=1){const p=r[c],f=n[p];(typeof f!="object"||f===null)&&(n[p]={}),n=n[p]}const o=r.at(-1);let i=n[o];(typeof i!="object"||i===null)&&(i={},n[o]=i),i[s]=t},Ye=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n);for(const c of o)if(c.depType.includes("."))Ue(i,c.depType,c.depName,c.fix);else{const p=i[c.depType];typeof p=="object"&&p!==null&&(p[c.depName]=c.fix)}j(n,i,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},Xe=new Set(["dependencies","devDependencies","peerDependencies"]),Qe=e=>e.startsWith("catalog:"),Ze=e=>e.startsWith("workspace:"),et=e=>{if(!e.startsWith("catalog:"))return;const a=e.slice(8);return a===""?"default":a},tt=(e,a)=>{if(e.get("default")?.has(a))return"default";const s=[...e.keys()].filter(t=>t!=="default").sort();for(const t of s)if(e.get(t)?.has(a))return t},st=e=>e==="default"?"catalog:":`catalog:${e}`,ot=(e,a)=>{const s=[...e].sort((r,n)=>(r.packageName??r.packageDir).localeCompare(n.packageName??n.packageDir));let t;for(const r of s){const n=L(r.specifier);if(!n)continue;if(!t){t=r;continue}const o=L(t.specifier);if(!o){t=r;continue}const i=K(o,n),c=K(n,o);(a==="highest"&&i||a==="lowest"&&c)&&(t=r)}if(t)return{canonical:t,canonicalSource:t.packageName??t.packageDir}},nt=(e,a={})=>{const s=a.resolve??"highest",t=new Set(a.ignoreDeps),r=[],n=e.filter(i=>i.isInternal||!Xe.has(i.depType)||Ze(i.specifier)||a.dep!==void 0&&i.depName!==a.dep?!1:!t.has(i.depName)),o=new Map;for(const i of n){const c=o.get(i.depName);c?c.push(i):o.set(i.depName,[i])}for(const[i,c]of o){const p=a.pinned?.get(i);if(p!==void 0){for(const u of c)u.specifier!==p&&r.push({canonicalSource:"cli:--pin",depName:i,depType:u.depType,fix:p,packageDir:u.packageDir,packageJsonPath:u.packageJsonPath,packageName:u.packageName,specifier:u.specifier});continue}if(s==="catalog"){const{catalogs:u}=a;if(!u)continue;const k=tt(u,i);if(!k)continue;const J=st(k);for(const P of c)et(P.specifier)!==k&&r.push({canonicalSource:`catalog:${k}`,depName:i,depType:P.depType,fix:J,packageDir:P.packageDir,packageJsonPath:P.packageJsonPath,packageName:P.packageName,specifier:P.specifier});continue}const f=c.filter(u=>!Qe(u.specifier));if(f.length<2||new Set(f.map(u=>u.specifier)).size<=1)continue;const h=ot(f,s);if(!h)continue;const d=h.canonical.specifier;for(const u of f)u.specifier!==d&&r.push({canonicalSource:h.canonicalSource,depName:i,depType:u.depType,fix:d,packageDir:u.packageDir,packageJsonPath:u.packageJsonPath,packageName:u.packageName,specifier:u.specifier})}return r},at=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n);for(const c of o){const p=i[c.depType];typeof p=="object"&&p!==null&&(p[c.depName]=c.fix)}j(n,i,{indent:W(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},it=e=>{if(_(I(e,"pnpm-workspace.yaml")))return!0;const a=I(e,"package.json");if(!_(a))return!1;try{return S(a).workspaces!==void 0}catch{return!1}},A=(e,a)=>{const s=new Map;for(const t of e){const r=a(t),n=s.get(r);n?n.push(t):s.set(r,[t])}return s},rt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ workspace-protocol: no violations"));return}const r=s?"Fixed":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} workspace-protocol violation${e.length===1?"":"s"}`)));for(const[o,i]of A(e,c=>c.packageName??c.packageJsonPath)){const c=$(a,i[0].packageJsonPath);t.info(` ${w(o)} ${g(`(${c})`)}`);for(const p of i){const f=s?x("→"):b("→");t.info(` ${g(p.depType)} ${p.depName}: ${D(p.specifier)} ${f} ${v(p.fix)}`)}}s||t.info(g(" Run with --fix to rewrite specifiers in place."))},ct=(e,a,s)=>{if(e.length===0){s.info(v("✓ redefine-root: no violations"));return}s.info(b(w(`Found ${String(e.length)} dep${e.length===1?"":"s"} re-declared from root`)));for(const[t,r]of A(e,n=>n.packageName??n.packageJsonPath)){const n=$(a,r[0].packageJsonPath);s.info(` ${w(t)} ${g(`(${n})`)}`);for(const o of r)s.info(` ${g(o.depType)} ${o.depName}: ${D(o.childSpecifier)} ${g(`(root ${o.rootDepType}: ${o.rootSpecifier})`)}`)}s.info(g(" Remove these from child package.json files — root pin will resolve."))},pt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ workspace-versions: no drift"));return}const r=s?"Fixed":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} workspace-version drift${e.length===1?"":"s"}`)));for(const[o,i]of A(e,c=>c.depName)){const c=i[0].fix,p=i[0].canonicalSource;t.info(` ${w(o)} ${g(`canonical: ${c} (from ${p})`)}`);for(const f of i){const m=$(a,f.packageJsonPath),h=f.packageName??m,d=s?x("→"):b("→");t.info(` ${h} ${g(`(${m})`)} ${g(f.depType)}: ${D(f.specifier)} ${d} ${v(f.fix)}`)}}s||t.info(g(" Run with --fix to align drifting specifiers."))},ft=(e,a,s)=>{if(e.length===0){s.info(v("✓ banned-deps: no violations"));return}s.info(D(w(`Found ${String(e.length)} banned dep${e.length===1?"":"s"}`)));for(const[t,r]of A(e,n=>n.packageName??n.packageJsonPath)){const n=$(a,r[0].packageJsonPath);s.info(` ${w(t)} ${g(`(${n})`)}`);for(const o of r){const i=o.replacement?` ${g("→")} ${v(o.replacement)}`:"";s.info(` ${g(o.depType)} ${D(o.depName)}${i}`),s.info(` ${g(o.reason)}`)}}},lt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ catalog-proposals: nothing worth promoting"));return}const r=s?"Added":"Would add",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} catalog entr${e.length===1?"y":"ies"}`)));for(const o of e)t.info(` ${w(o.depName)}: ${v(o.specifier)} ${g(`(${String(o.instanceCount)} packages agree)`)}`);if(!s){const o=be(a,e);if(o){t.info(""),t.info(g("Proposed pnpm-workspace.yaml changes:"));for(const i of o.split(`
10
- `))i.startsWith("+")?t.info(v(i)):i.startsWith("-")?t.info(D(i)):t.info(g(i))}t.info(g(" Run with --fix to write these entries to pnpm-workspace.yaml."))}},ut=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ custom-types: no engines / packageManager / volta drift"));return}const r=s?"Fixed":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} custom-type drift${e.length===1?"":"s"}`)));for(const[o,i]of A(e,c=>`${c.customType} ${c.depName}`)){const c=i[0].fix,p=i[0].canonicalSource;t.info(` ${w(o)} ${g(`canonical: ${c} (from ${p})`)}`);for(const f of i){const m=$(a,f.packageJsonPath),h=f.packageName??m,d=s?x("→"):b("→");t.info(` ${h} ${g(`(${m})`)}: ${D(f.specifier)} ${d} ${v(f.fix)}`)}}s||t.info(g(" Run with --fix to align engines/packageManager/volta versions."))},dt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ empty-deps: no empty dependency blocks"));return}const r=s?"Removed":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} empty dependency block${e.length===1?"":"s"}`)));for(const[o,i]of A(e,c=>c.packageName??c.packageJsonPath)){const c=$(a,i[0].packageJsonPath);t.info(` ${w(o)} ${g(`(${c})`)}`);for(const p of i)t.info(` ${g(p.depType)}: ${D("{}")}`)}s||t.info(g(" Run with --fix to drop empty blocks."))},gt=(e,a,s,t)=>{if(e.length===0){t.info(v('✓ root-private: root package.json is "private": true'));return}const r=s?"Set":"Missing",n=s?x:D;for(const o of e){const i=$(a,o.packageJsonPath);if(t.info(n(w(`${r} "private": true on root ${g(`(${i})`)}`))),!s){const c=o.rawValue===void 0?"absent":JSON.stringify(o.rawValue);t.info(` ${g("current:")} ${D(c)}`)}}s||t.info(g(' Run with --fix to set "private": true.'))},mt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ root-package-manager: packageManager field present"));return}const r=s?"Set":"Missing",n=s?x:D;for(const o of e){const i=$(a,o.packageJsonPath);t.info(n(w(`${r} packageManager on root ${g(`(${i})`)}`))),!s&&!o.suggested&&t.info(g(" no canonical specifier configured (set policy.rootPackageManager.suggested to enable --fix)"))}s||t.info(g(' e.g. "packageManager": "pnpm@10.32.1"'))},ht=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ root-deps: no runtime dependencies on private root"));return}const r=s?"Moved":"Found",n=s?x:b;for(const o of e){const i=$(a,o.packageJsonPath);t.info(n(w(`${r} ${String(o.depNames.length)} runtime dep${o.depNames.length===1?"":"s"} on private root ${g(`(${i})`)}`)));for(const c of o.depNames)t.info(` ${D(c)}`)}s||t.info(g(" Run with --fix to move them to devDependencies."))},kt=(e,a)=>{if(e.length===0){a.info(v("✓ missing-package-json: every workspace dir has a package.json"));return}a.info(b(w(`Found ${String(e.length)} workspace dir${e.length===1?"":"s"} without a package.json`)));for(const s of e)a.info(` ${D(s.packageDir)}`);a.info(g(" Either delete the directory or scaffold a package.json (vis create)."))},yt=(e,a,s)=>{if(e.length===0){s.info(v("✓ dead-workspace-pattern: every workspace pattern matches at least one package"));return}const t=a?"Removed":"Found",r=a?x:b;s.info(r(w(`${t} ${String(e.length)} unmatched workspace pattern${e.length===1?"":"s"}`)));for(const[n,o]of A(e,i=>i.source)){s.info(` ${w(n)}`);for(const i of o)s.info(` ${D(i.pattern)}`)}a||s.info(g(" Run with --fix to drop dead patterns."))},Pt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ types-in-deps: no @types/* in dependencies of private packages"));return}const r=s?"Moved":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} @types/* dep${e.length===1?"":"s"} in dependencies`)));for(const[o,i]of A(e,c=>c.packageName??c.packageJsonPath)){const c=$(a,i[0].packageJsonPath);t.info(` ${w(o)} ${g(`(${c})`)}`);for(const p of i)t.info(` ${D(p.depName)} ${g(p.childSpecifier)}`)}s||t.info(g(" Run with --fix to move them to devDependencies."))},$t=(e,a,s)=>{if(e.length===0){s.info(v("✓ similar-deps: every related dep family is in sync"));return}s.info(b(w(`Found ${String(e.length)} family${e.length===1?"":" families"} with version drift`)));for(const t of e){s.info(` ${w(t.familyLabel)} ${g(`(${t.specifiers.join(", ")})`)}`);for(const r of t.members){const n=$(a,r.packageJsonPath),o=r.packageName??n;s.info(` ${o} ${g(`(${n})`)} ${g(r.depType)}: ${D(r.depName)}@${b(r.specifier)}`)}}s.info(g(" Pick a single specifier per family and align by hand — auto-fix is unsafe across name boundaries."))},wt=(e,a,s,t,r)=>{let n=!0;const o=i=>{n||r.info(""),n=!1,i()};t.workspaceProtocol&&o(()=>{rt(e.workspaceProtocol??[],a,s.workspaceProtocol,r)}),t.redefineRoot&&o(()=>{ct(e.redefineRoot??[],a,r)}),t.workspaceVersions&&o(()=>{pt(e.workspaceVersions??[],a,s.workspaceVersions,r)}),t.customTypes&&o(()=>{ut(e.customTypes??[],a,s.customTypes,r)}),e.catalogProposals!==void 0&&o(()=>{lt(e.catalogProposals??[],a,s.catalogProposals,r)}),t.bannedDeps&&o(()=>{ft(e.bannedDeps??[],a,r)}),t.emptyDeps&&o(()=>{dt(e.emptyDeps??[],a,s.emptyDeps,r)}),t.rootPrivate&&o(()=>{gt(e.rootPrivate??[],a,s.rootPrivate,r)}),t.rootPackageManager&&o(()=>{mt(e.rootPackageManager??[],a,s.rootPackageManager,r)}),t.rootDeps&&o(()=>{ht(e.rootDeps??[],a,s.rootDeps,r)}),t.missingPackageJson&&o(()=>{kt(e.missingPackageJson??[],r)}),t.deadWorkspacePatterns&&o(()=>{yt(e.deadWorkspacePatterns??[],s.deadWorkspacePatterns,r)}),t.typesInDeps&&o(()=>{Pt(e.typesInDeps??[],a,s.typesInDeps,r)}),t.similarDeps&&o(()=>{$t(e.similarDeps??[],a,r)})},vt=(e,a)=>{for(const s of e.workspaceProtocol??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`workspace-protocol ${t} ${s.depType} ${s.depName} ${s.specifier} → ${s.fix}
11
- `)}for(const s of e.redefineRoot??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`redefine-root ${t} ${s.depType} ${s.depName} ${s.childSpecifier}
12
- `)}for(const s of e.workspaceVersions??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`workspace-versions ${t} ${s.depType} ${s.depName} ${s.specifier} → ${s.fix}
13
- `)}for(const s of e.customTypes??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`custom-types ${t} ${s.customType} ${s.depName} ${s.specifier} → ${s.fix}
14
- `)}for(const s of e.bannedDeps??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`banned-deps ${t} ${s.depType} ${s.depName} ${s.reason}
15
- `)}for(const s of e.catalogProposals??[])process.stdout.write(`catalog-proposal ${s.catalogName} ${s.depName} ${s.specifier} ${String(s.instanceCount)}
16
- `);for(const s of e.emptyDeps??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`empty-deps ${t} ${s.depType}
17
- `)}for(const s of e.rootPrivate??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`root-private ${t}
18
- `)}for(const s of e.rootPackageManager??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`root-package-manager ${t} ${s.suggested??""}
19
- `)}for(const s of e.rootDeps??[]){const t=$(a,s.packageJsonPath);for(const r of s.depNames)process.stdout.write(`root-deps ${t} ${r}
20
- `)}for(const s of e.missingPackageJson??[])process.stdout.write(`missing-package-json ${s.packageDir}
21
- `);for(const s of e.deadWorkspacePatterns??[])process.stdout.write(`dead-workspace-pattern ${s.source} ${s.pattern}
22
- `);for(const s of e.typesInDeps??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`types-in-deps ${t} ${s.depName} ${s.childSpecifier}
23
- `)}for(const s of e.similarDeps??[])for(const t of s.members){const r=$(a,t.packageJsonPath);process.stdout.write(`similar-deps ${s.family} ${r} ${t.depType} ${t.depName} ${t.specifier}
24
- `)}},Dt=(e,a,s,t)=>{const r=o=>({...o,packageJsonPath:$(a,o.packageJsonPath)}),n={fixed:s};if(t.workspaceProtocol){const o=(e.workspaceProtocol??[]).map(i=>r(i));n.workspaceProtocol={issues:o,total:o.length}}if(t.redefineRoot){const o=(e.redefineRoot??[]).map(i=>r(i));n.redefineRoot={issues:o,total:o.length}}if(t.workspaceVersions){const o=(e.workspaceVersions??[]).map(i=>r(i));n.workspaceVersions={issues:o,total:o.length}}if(t.customTypes){const o=(e.customTypes??[]).map(i=>r(i));n.customTypes={issues:o,total:o.length}}if(t.bannedDeps){const o=(e.bannedDeps??[]).map(i=>r(i));n.bannedDeps={issues:o,total:o.length}}if(e.catalogProposals!==void 0){const o=e.catalogProposals;n.catalogProposals={proposals:o,total:o.length}}if(t.emptyDeps){const o=(e.emptyDeps??[]).map(i=>r(i));n.emptyDeps={issues:o,total:o.length}}if(t.rootPrivate){const o=(e.rootPrivate??[]).map(i=>r(i));n.rootPrivate={issues:o,total:o.length}}if(t.rootPackageManager){const o=(e.rootPackageManager??[]).map(i=>r(i));n.rootPackageManager={issues:o,total:o.length}}if(t.rootDeps){const o=(e.rootDeps??[]).map(i=>r(i));n.rootDeps={issues:o,total:o.length}}if(t.missingPackageJson){const o=e.missingPackageJson??[];n.missingPackageJson={issues:o,total:o.length}}if(t.deadWorkspacePatterns){const o=e.deadWorkspacePatterns??[];n.deadWorkspacePatterns={issues:o,total:o.length}}if(t.typesInDeps){const o=(e.typesInDeps??[]).map(i=>r(i));n.typesInDeps={issues:o,total:o.length}}if(t.similarDeps){const o=(e.similarDeps??[]).map(i=>({...i,members:i.members.map(c=>({...c,packageJsonPath:$(a,c.packageJsonPath)}))}));n.similarDeps={issues:o,total:o.length}}process.stdout.write(`${JSON.stringify(n,void 0,2)}
25
- `)},T=(e,a,s)=>{const t=e[a];return typeof t=="boolean"?t:e[s]===!0},bt=e=>{const a=e,s=(e.ban?.length??0)>0,t=(e.pin?.length??0)>0,r=T(a,"workspaceProtocol","workspace-protocol"),n=T(a,"redefineRoot","redefine-root"),o=T(a,"bannedDeps","banned-deps"),i=T(a,"workspaceVersions","workspace-versions"),c=T(a,"customTypes","custom-types"),p=T(a,"emptyDeps","empty-deps"),f=T(a,"rootPrivate","root-private"),m=T(a,"rootPackageManager","root-package-manager"),h=T(a,"rootDeps","root-deps"),d=T(a,"missingPackageJson","missing-package-json"),u=T(a,"deadWorkspacePatterns","dead-workspace-patterns"),k=T(a,"typesInDeps","types-in-deps"),J=T(a,"similarDeps","similar-deps");return r||n||o||i||c||p||f||m||h||d||u||k||J||s||t?{bannedDeps:o||s,customTypes:c,deadWorkspacePatterns:u,emptyDeps:p,missingPackageJson:d,redefineRoot:n,rootDeps:h,rootPackageManager:m,rootPrivate:f,similarDeps:J,typesInDeps:k,workspaceProtocol:r,workspaceVersions:i||t}:{bannedDeps:!0,customTypes:!0,deadWorkspacePatterns:!0,emptyDeps:!0,missingPackageJson:!0,redefineRoot:!0,rootDeps:!0,rootPackageManager:!0,rootPrivate:!0,similarDeps:!0,typesInDeps:!0,workspaceProtocol:!0,workspaceVersions:!0}},Nt=e=>{const a=new Map;for(const s of e??[]){const t=s.lastIndexOf("@");if(t<=0||t===s.length-1)throw new Error(`Invalid --pin "${s}". Use: name@<specifier> (e.g. react@^18.2.0).`);const r=s.slice(0,t),n=s.slice(t+1);a.set(r,n)}return a},Tt=new Set(["catalog","highest","lowest"]),xt=e=>{if(e===void 0)return"highest";if(!Tt.has(e))throw new Error(`Invalid --resolve "${e}". Use: highest, lowest, or catalog.`);return e},M=(e,a)=>e?a===void 0||a===!0:!1,Jt={"custom-types":"policy.customTypes.autofix","workspace-protocol":"policy.workspaceProtocol.autofix","workspace-versions":"policy.workspaceVersions.autofix"},B=(e,a,s,t)=>{const r=Jt[a],n=s==="prompt"?`${r} = "prompt" (interactive mode not yet implemented; report-only)`:`${r} = false`,o=`Set "${r}": true (or remove it) to enable rewrites.`;e.warn(`${a}: ${String(t)} issue${t===1?"":"s"} not rewritten — ${n}. ${o}`)},Ot=async({logger:e,options:a,visConfig:s,workspaceRoot:t})=>{if(!t)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const r=t,n=a.fix??!1,o=a.format??"human",i=a.quiet??!1;if(!["human","json","minimal"].includes(o))throw new Error(`Invalid --format "${o}". Use: human, json, or minimal.`);const c=bt(a),p=s?.policy??{},f=s?.editorconfig??!0,m=Nt(a.pin),h=a.ban??[];(a.dep!==void 0||a.resolve!==void 0)&&!c.workspaceVersions&&!i&&e.warn("--dep / --resolve only apply to --workspace-versions; ignored.");const d=ne(r),u={},k={catalogProposals:!1,customTypes:!1,deadWorkspacePatterns:!1,emptyDeps:!1,rootDeps:!1,rootPackageManager:!1,rootPrivate:!1,typesInDeps:!1,workspaceProtocol:!1,workspaceVersions:!1},J=it(r);let P=0;if(c.workspaceProtocol){const l=Ge(d,{fixSpecifier:a.fixSpecifier}),y=M(n,p.workspaceProtocol?.autofix);y&&l.length>0&&(Ye(l,{useEditorconfig:f}),k.workspaceProtocol=!0),u.workspaceProtocol=l,y||(P+=l.length),n&&!y&&l.length>0&&!i&&B(e,"workspace-protocol",p.workspaceProtocol?.autofix,l.length)}if(c.redefineRoot){const l=Me(d,{ignoreDeps:p.redefineRoot?.ignore});u.redefineRoot=l,P+=l.length}if(c.workspaceVersions){const l=xt(a.resolve??p.workspaceVersions?.resolve),y=l==="catalog"?ue(r):void 0;l==="catalog"&&(!y||y.size===0)&&!i&&e.warn("--resolve catalog: no catalog found in pnpm-workspace.yaml or root package.json — nothing to align.");const N=nt(d,{catalogs:y,dep:a.dep,ignoreDeps:p.workspaceVersions?.ignore,pinned:m.size>0?m:void 0,resolve:l}),R=M(n,p.workspaceVersions?.autofix);if(R&&N.length>0&&(at(N,{useEditorconfig:f}),k.workspaceVersions=!0),u.workspaceVersions=N,R||(P+=N.length),n&&!R&&N.length>0&&!i&&B(e,"workspace-versions",p.workspaceVersions?.autofix,N.length),a.proposeMin!==void 0){if(l!=="catalog"&&!i)e.warn("--propose-min only runs under --resolve catalog; ignored.");else if(l==="catalog"){const C=ve(d,{catalogs:y,ignoreDeps:p.workspaceVersions?.ignore,min:a.proposeMin});R&&C.length>0&&(De(r,C),k.catalogProposals=!0),u.catalogProposals=C}}}if(c.customTypes){const l=p.customTypes?.extraTypes,y=ae(l);if(y.length>0){for(const X of y)e.error(`policy.customTypes.${X}`);process.exitCode=1;return}const N=ie(r,l),C=(a.resolve??p.customTypes?.resolve)==="lowest"?"lowest":"highest",E=re(N,{dep:a.dep,ignoreDeps:p.customTypes?.ignore,resolve:C}),O=M(n,p.customTypes?.autofix);O&&E.length>0&&(ce(E,{useEditorconfig:f}),k.customTypes=!0),u.customTypes=E,O||(P+=E.length),n&&!O&&E.length>0&&!i&&B(e,"custom-types",p.customTypes?.autofix,E.length)}if(c.bannedDeps){const l={...p.bannedDeps};for(const N of h)l[N]={reason:"banned via --ban CLI flag"};Object.keys(l).length===0&&a.bannedDeps&&!i&&e.warn("--banned-deps: no policy.bannedDeps in vis config, nothing to check.");const y=ke(d,l);u.bannedDeps=y,P+=y.length}if(c.emptyDeps){const l=Je(r,{ignoreBlocks:p.emptyDeps?.ignoreBlocks}),y=M(n,p.emptyDeps?.autofix);y&&l.length>0&&(Se(l,{useEditorconfig:f}),k.emptyDeps=!0),u.emptyDeps=l,y||(P+=l.length)}if(c.rootPrivate){const l=Ce(r,J),y=M(n,p.rootPrivate?.autofix);y&&l.length>0&&(Ve(l,{useEditorconfig:f}),k.rootPrivate=!0),u.rootPrivate=l,y||(P+=l.length)}if(c.rootPackageManager){const l=Ee(r,J,{suggested:p.rootPackageManager?.suggested}),y=M(n,p.rootPackageManager?.autofix);y&&l.some(N=>N.suggested!==void 0)&&(Re(l,{useEditorconfig:f}),k.rootPackageManager=!0),u.rootPackageManager=l,(!y||!k.rootPackageManager)&&(P+=l.filter(N=>N.suggested===void 0||!k.rootPackageManager).length)}if(c.rootDeps){const l=We(r,J),y=M(n,p.rootDeps?.autofix);y&&l.length>0&&(je(l,{useEditorconfig:f}),k.rootDeps=!0),u.rootDeps=l,y||(P+=l.length)}if(c.missingPackageJson){const l=le(r);u.missingPackageJson=l,P+=l.length}if(c.deadWorkspacePatterns){const l=Ne(r),y=M(n,p.deadWorkspacePatterns?.autofix);y&&l.length>0&&(Te(l,{useEditorconfig:f}),k.deadWorkspacePatterns=!0),u.deadWorkspacePatterns=l,y||(P+=l.length)}if(c.typesInDeps){const l=Le(d,{ignoreDeps:p.typesInDeps?.ignore}),y=M(n,p.typesInDeps?.autofix);y&&l.length>0&&(Ke(l,{useEditorconfig:f}),k.typesInDeps=!0),u.typesInDeps=l,y||(P+=l.length)}if(c.similarDeps){const l=He(d,{extraFamilies:p.similarDeps?.extraFamilies,ignoreFamilies:p.similarDeps?.ignoreFamilies});u.similarDeps=l,P+=l.length}i||(o==="json"?Dt(u,r,k,c):o==="minimal"?vt(u,r):wt(u,r,k,c,e)),P>0&&(process.exitCode=1)};export{Ot as default};
1
+ import{createRequire as ee}from"node:module";import{e as A,a as re}from"../packem_shared/index-0dnGN3GP.js";import{f as ae,h as M}from"../packem_shared/ai-cache-Dkb6me20.js";import{p as c,X as V,Y as k,Z as ne,R as P,_ as L,$ as oe,h as ie}from"./cli-main.js";import{B as ce,C as de,D as N,E as z}from"../packem_shared/registry-CndByNx9.js";import{r as he,d as x,a as U,t as I}from"../packem_shared/env-BymuoTL8.js";import{z as b}from"../packem_shared/formatBytes-_HvjOy8a-iHCer6uX.js";import{Cache as E,readLastRunSummary as q,getLastRunSummaryPath as T,parseCacheSize as me,digestFile as X,describeCacheMissReason as pe}from"@visulima/task-runner";import{y as R}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{r as G,f as F,a as ye,d as $e}from"../packem_shared/run-summary-utils-DbyeUM6f.js";let te;const se=e=>(te??=ee(import.meta.url))(e),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[s,t]=g.versions.node.split(".").map(Number);if(s>22||s===22&&t>=3||s===20&&t>=16)return g.getBuiltinModule(e)}return se(e)},{realpath:_,rm:W,mkdtemp:fe,readdir:ue,stat:Y}=j("node:fs/promises"),{createInterface:le}=j("node:readline"),{tmpdir:Se}=j("node:os"),we=e=>new Promise(s=>{const t=le({input:process.stdin,output:process.stderr});t.question(`${e} (y/N) `,r=>{t.close();const n=r.trim().toLowerCase();s(n==="y"||n==="yes")})}),ve=()=>{try{const e=ae();e>0&&c.info(`Cleared ${String(e)} cached AI response${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear AI response cache: ${e instanceof Error?e.message:String(e)}`)}},ke=()=>{try{const e=he();e>0&&c.info(`Cleared ${String(e)} cached Socket.dev report${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear Socket.dev cache: ${e instanceof Error?e.message:String(e)}`)}},Ce=()=>{try{const e=ce();e>0&&c.info(`Cleared ${String(e)} cached deps.dev record${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear deps.dev cache: ${e instanceof Error?e.message:String(e)}`)}},ge=()=>{try{const e=de();e>0&&c.info(`Cleared ${String(e)} cached Snyk record${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear Snyk cache: ${e instanceof Error?e.message:String(e)}`)}},De=async(e,s,t)=>{if(!R(e)){c.info(`No cache directory to clean at ${e}`);return}if(t.dryRun){const a=(await Promise.all(V(e,!0).map(async i=>k(i)))).flat(),o=a.reduce((i,d)=>i+d.sizeBytes,0);c.info(`Would remove ${String(a.length)} cache entr${a.length===1?"y":"ies"} (${b(o,{decimals:1,space:!1})}) from ${e}`);return}const r=ne(e,s);try{const n=await _(e),a=await _(s);if(n===a){c.error("Refusing to delete the workspace root. The cache directory resolved to the same path as the workspace."),process.exitCode=1;return}}catch{}if(!r&&!t.force){if(c.warn(`Cache directory is outside the workspace root: ${e}`),c.warn("This will recursively delete the entire directory, including anything stored there by other tools."),!process.stdin.isTTY){c.error("Refusing to clean an out-of-workspace cache without --force (stdin is not a TTY)."),process.exitCode=1;return}if(!await we(" Continue?")){c.info("Aborted.");return}}r?await new E({cacheDirectory:e,workspaceRoot:s}).clear():await W(e,{force:!0,recursive:!0}),c.success(`Cleared cache: ${e}`)},Z=e=>e==="task"||e==="ai"||e==="socket"||e==="deps-dev"||e==="snyk"||e==="all"?e:(e&&e.length>0&&c.warn(`Unknown --type value '${e}'; falling back to 'all'.`),"all"),m=(e,s)=>e==="all"||e===s,xe=e=>e==="worktree"||e==="shared"||e==="all"?e:(e&&e.length>0&&c.warn(`Unknown --scope value '${e}'; falling back to 'shared'.`),"shared"),w=(e,s,t)=>{const r=e??process.cwd(),n=t??{},a=n.taskRunner??{},o=xe(s.scope),i=s.cacheDir,d=P(r,i,a.cacheDirectory,!1),f=P(r,i,a.cacheDirectory,n.sharedWorktreeCache),h=L(d,r,n.branchScopedCache),u=L(f,r,n.branchScopedCache);let l;switch(o){case"all":{l=u===h?[{base:f,scoped:u}]:[{base:f,scoped:u},{base:d,scoped:h}];break}case"worktree":{l=[{base:d,scoped:h}];break}default:l=[{base:f,scoped:u}]}const $=n.branchScopedCache===!0;return{directoriesFor:O=>O==="read"?[...new Set(l.flatMap(p=>p.scoped!==p.base&&oe(p.base)?[p.scoped,p.base]:[p.scoped]))]:O==="wipe"?[...new Set(l.map(p=>p.base))]:[...new Set(l.flatMap(p=>V(p.base,$)))],scope:o,sharedWorktreeCache:n.sharedWorktreeCache,workspaceRoot:r}},H=16,K=e=>e.length>H?`${e.slice(0,H)}…`:e,v=(e,s,t)=>{const r=Object.entries(s??{});if(r.length!==0){t.info(` ${e}:`),r.sort(([n],[a])=>n.localeCompare(a));for(const[n,a]of r)t.info(` ${n.padEnd(40)} ${K(a)}`)}},be=async(e,s,t)=>{if(e!==void 0)for(const r of s){const n=await new E({cacheDirectory:r,workspaceRoot:t}).get(e);if(n?.fingerprint)return n.fingerprint}},Ee=(e,s)=>{v("tracked files",e.fileHashes,s),v("tracked env",e.envHashes,s),v("missing files",Object.fromEntries(e.missingFiles.map(t=>[t,"absent"])),s)},Re=async(e,s,t)=>{const{format:r,runId:n,workspaceRoot:a}=s,o=n===void 0?await q(a,{dataDirectory:x(a)}):await G(a,n);if(!o){if(r==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:n??null,taskId:e},void 0,2)}
2
+ `),process.exitCode=1;return}n===void 0?c.error(`No previous run summary found. Run a task first to populate \`${T(a,{dataDirectory:x(a)})}\`.`):c.error(`Run summary "${n}" not found in ${U(a)}/.`),process.exitCode=1;return}const i=F(o,e);if(!i){if(r==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:o.id,taskId:e},void 0,2)}
3
+ `),process.exitCode=1;return}c.error(`Task "${e}" was not part of run ${o.id}.`),process.exitCode=1;return}const d=i.hashDetails===void 0?await be(i.hash,s.cacheDirectories??[],a):void 0;if(r==="json"){process.stdout.write(`${JSON.stringify({cacheStatus:i.cacheStatus,hash:i.hash??null,hashDetails:i.hashDetails??null,hashSource:i.hashSource??null,runId:o.id,taskId:i.taskId,trackedFingerprint:d??null},void 0,2)}
4
+ `);return}c.info(`Hash for ${e} (run ${o.id})`),t.info(""),t.info(` status: ${i.cacheStatus}`),t.info(` hash: ${i.hash??"(none)"}`),i.hashSource==="declared-fallback"&&t.info(" key: declared-fallback (no files were tracked; the entry is keyed on the declared inputs below)"),i.hashDetails?(t.info(""),t.info(` command: ${K(i.hashDetails.command)}`),v("nodes",i.hashDetails.nodes,t),v("runtime",i.hashDetails.runtime,t),v("implicitDeps",i.hashDetails.implicitDeps,t)):d?(t.info(""),Ee(d,t)):(t.info(""),c.info("No hash details recorded for this task."))},S=e=>{process.stdout.write(`${e}
5
+ `)},C=e=>{process.stdout.write(`${JSON.stringify(e,void 0,2)}
6
+ `)},Be=async(e,s,t)=>{if(!R(e)){if(s==="json"){process.stdout.write(`${JSON.stringify({directory:e,entries:[],totalBytes:0,totalCount:0},void 0,2)}
7
+ `);return}c.info(`No cache directory found at ${e}`);return}const r=await k(e);if(r.length===0){if(s==="json"){process.stdout.write(`${JSON.stringify({directory:e,entries:[],totalBytes:0,totalCount:0},void 0,2)}
8
+ `);return}c.info(`Cache directory is empty: ${e}`);return}const n=r.reduce((h,u)=>h+u.sizeBytes,0);if(s==="json"){const h=Date.now();process.stdout.write(`${JSON.stringify({directory:e,entries:r.map(u=>({ageMs:h-u.mtimeMs,hash:u.hash,mtimeIso:new Date(u.mtimeMs).toISOString(),sizeBytes:u.sizeBytes})),totalBytes:n,totalCount:r.length},void 0,2)}
9
+ `);return}S(`Cache directory: ${e}`),S(`Entries: ${String(r.length)} (${b(n,{decimals:1,space:!1})})`),t.info("");const a=Date.now(),o=r.map(h=>({age:ie(h.mtimeMs,a),hash:h.hash.slice(0,12),size:b(h.sizeBytes,{decimals:1,space:!1})})),i=Math.max(4,...o.map(h=>h.hash.length)),d=Math.max(4,...o.map(h=>h.size.length)),f=Math.max(3,...o.map(h=>h.age.length));t.info(` ${"hash".padEnd(i)} ${"size".padEnd(d)} ${"age".padEnd(f)}`),t.info(` ${"-".repeat(i)} ${"-".repeat(d)} ${"-".repeat(f)}`);for(const h of o)t.info(` ${h.hash.padEnd(i)} ${h.size.padEnd(d)} ${h.age.padEnd(f)}`)},Me=async(e,s,t)=>{if(!R(e)){c.info(`No cache directory to prune at ${e}`);return}if(t.maxCacheAgeDays!==void 0&&(!Number.isFinite(t.maxCacheAgeDays)||t.maxCacheAgeDays<0)){c.error(`Invalid --max-age-days value: expected a finite number >= 0, got ${String(t.maxCacheAgeDays)}`),process.exitCode=1;return}if(t.keepLast!==void 0&&(!Number.isFinite(t.keepLast)||t.keepLast<0||!Number.isInteger(t.keepLast))){c.error(`Invalid --keep-last value: expected a non-negative integer, got ${String(t.keepLast)}`),process.exitCode=1;return}if(t.maxCacheSize!==void 0){let u;try{u=me(t.maxCacheSize)}catch(l){c.error(`Invalid --max-size value: ${l instanceof Error?l.message:String(l)}`),process.exitCode=1;return}if(!Number.isFinite(u)||u<=0){c.error(`Invalid --max-size value: expected a positive size, got "${t.maxCacheSize}" (${String(u)} bytes)`),process.exitCode=1;return}}const r=t.maxCacheAgeDays===void 0?void 0:t.maxCacheAgeDays*24*60*60*1e3,n=await k(e),a=n.reduce((u,l)=>u+l.sizeBytes,0);if(t.keepLast!==void 0&&n.length>t.keepLast){const u=n.slice(t.keepLast);await Promise.all(u.map(l=>W(l.path,{force:!0,recursive:!0})))}await new E({cacheDirectory:e,maxCacheAge:r,maxCacheSize:t.maxCacheSize,workspaceRoot:s}).removeOldEntries();const i=await k(e),d=i.reduce((u,l)=>u+l.sizeBytes,0),f=n.length-i.length,h=a-d;if(f<=0){c.info("Nothing to prune — all entries are within the configured limits.");return}c.success(`Pruned ${String(f)} entr${f===1?"y":"ies"}, freed ${b(h,{decimals:1,space:!1})}.`)},y=e=>e===void 0?null:new Date(e).toISOString(),D=(e,s)=>{S(`${e}:`),s.directory!==void 0&&S(` Directory: ${s.directory}`),S(` Entries: ${String(s.entries)}`),S(` Total size: ${b(s.totalSizeBytes,{decimals:1,space:!1})}`),S(` Oldest: ${s.oldestEntry?new Date(s.oldestEntry).toISOString():"N/A"}`),S(` Newest: ${s.newestEntry?new Date(s.newestEntry).toISOString():"N/A"}`)},Ne=async(e,s)=>{if(!R(e)){if(s==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!1,totalBytes:0,totalCount:0})}
10
+ `);return}c.info(`No cache directory at ${e}`);return}const t=await k(e),r=t.reduce((n,a)=>n+a.sizeBytes,0);if(s==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!0,totalBytes:r,totalCount:t.length})}
11
+ `);return}D("Task cache",{directory:e,entries:t.length,newestEntry:t[0]?.mtimeMs,oldestEntry:t.at(-1)?.mtimeMs,totalSizeBytes:r})},ze=async e=>{const s=[],t=async r=>{const a=(await ue(r,{withFileTypes:!0})).toSorted((o,i)=>o.name.localeCompare(i.name));for(const o of a){const i=A(r,o.name);if(o.isDirectory()){await t(i);continue}if(!o.isFile())continue;const[d,f]=await Promise.all([Y(i),X(i)]);s.push({hash:f?.hash??"",mode:d.mode&4095,mtimeMs:d.mtimeMs,relativePath:re(e,i).replaceAll("\\","/"),sizeBytes:d.size})}};return await t(e),s},Ie=(e,s)=>Math.floor(e/1e3)===Math.floor(s/1e3),J=16,Fe=async(e,s)=>{const t=A(s,e.relativePath),r=await Y(t).catch(()=>{});if(!r)return{expected:{hash:e.hash,mode:e.mode,mtimeMs:e.mtimeMs},issues:["missing"],relativePath:e.relativePath};const n=await X(t),a=[];(n?.hash??"")!==e.hash&&a.push("content");const o=r.mode&4095;if(process.platform!=="win32"&&o!==e.mode&&a.push("mode"),Ie(r.mtimeMs,e.mtimeMs)||a.push("mtime"),a.length!==0)return{actual:{hash:n?.hash,mode:o,mtimeMs:r.mtimeMs},expected:{hash:e.hash,mode:e.mode,mtimeMs:e.mtimeMs},issues:a,relativePath:e.relativePath}},je=async(e,s,t)=>{for(const r of s){const n=await new E({cacheDirectory:r,workspaceRoot:t}).getByTaskId(e);if(n)return{cached:n,cacheDirectory:r}}},B=(e,s,t)=>{e==="json"?C(s):c.error(t),process.exitCode=1},Ae=async(e,s)=>{const t=Array.from({length:e.length});for(let r=0;r<e.length;r+=J){const n=e.slice(r,r+J),a=await Promise.all(n.map(async o=>Fe(o,s)));for(const[o,i]of a.entries())t[r+o]=i}return t.filter(r=>r!==void 0)},We=(e,s,t)=>{t.info(` expected hash: ${e.hash||"(none)"}`),t.info(` actual hash: ${s.hash??"(unreadable)"}`)},Te=(e,s,t)=>{t.info(` expected mode: ${e.mode.toString(8)}`),t.info(` actual mode: ${(s.mode??0).toString(8)}`)},Oe=(e,s,t)=>{t.info(` expected mtime: ${new Date(e.mtimeMs).toISOString()}`),t.info(` actual mtime: ${s.mtimeMs===void 0?"(unreadable)":new Date(s.mtimeMs).toISOString()}`)},Pe=(e,s)=>{const t=e.issues.includes("missing")?"MISSING":e.issues.join(",").toUpperCase();s.info(` [${t}] ${e.relativePath}`);const{expected:r}=e,{actual:n}=e;e.issues.includes("missing")||!r||!n||(e.issues.includes("content")&&We(r,n,s),e.issues.includes("mode")&&Te(r,n,s),e.issues.includes("mtime")&&Oe(r,n,s))},Le=(e,s,t,r,n,a)=>{if(c.info(`Verify ${e} (hash ${s})`),a.info(""),a.info(` cache: ${t}`),a.info(` files: ${String(r)}`),n.length===0){a.info(""),c.success("Cache restore is faithful — all files match content, mode, and mtime.");return}a.info(` drift: ${String(n.length)} file(s)`),a.info("");for(const o of n)Pe(o,a);process.exitCode=1},_e=async(e,s,t)=>{const{cacheDirectories:r,format:n,workspaceRoot:a}=s;if(r.length===0){B(n,{error:"no-cache-directory",taskId:e},"No cache directory resolved — pass --cache-dir or run inside a workspace.");return}const o=await je(e,r,a);if(!o){B(n,{error:"no-cached-entry",searchedCaches:r,taskId:e},`No cached entry found for task "${e}". Run it once before verifying.`);return}const{cached:i,cacheDirectory:d}=o,f=await fe(A(Se(),"vis-cache-verify-"));try{if(!await new E({cacheDirectory:d,workspaceRoot:f}).restoreOutputs(i.hash)){B(n,{error:"restore-failed",hash:i.hash,taskId:e},`Cache restore failed for ${e} (hash ${i.hash}).`);return}const l=await ze(f);if(l.length===0){n==="json"?C({diffs:[],hash:i.hash,status:"no-outputs",taskId:e}):c.info(`Cached entry for ${e} has no recorded outputs — nothing to verify.`);return}const $=await Ae(l,a);if(n==="json"){C({cachedFileCount:l.length,cacheDirectory:d,diffs:$,hash:i.hash,status:$.length===0?"ok":"drift",taskId:e}),$.length>0&&(process.exitCode=1);return}Le(e,i.hash,d,l.length,$,t)}finally{await W(f,{force:!0,recursive:!0}).catch(()=>{})}},He=(e,s,t,r)=>{e==="json"?C({error:"no-summary",runId:t??null,taskId:s}):t===void 0?c.error(`No previous run summary found. Run a task first to populate \`${T(r,{dataDirectory:x(r)})}\`.`):c.error(`Run summary "${t}" not found in ${U(r)}/.`),process.exitCode=1},Je=(e,s,t)=>{e==="json"?C({error:"task-not-in-summary",runId:t.id,taskId:s}):(c.error(`Task "${s}" was not part of run ${t.id}.`),c.info(`Tasks in this run: ${t.tasks.map(r=>r.taskId).join(", ")||"(none)"}`)),process.exitCode=1},Ve=(e,s,t,r,n)=>({diff:n,previousRunId:t?.id??null,previousTask:r?{cacheStatus:r.cacheStatus,hash:r.hash??null,hashDetails:r.hashDetails??null}:null,runId:e.id,task:{cacheMissReasons:s.cacheMissReasons??null,cacheStatus:s.cacheStatus,hash:s.hash??null,hashDetails:s.hashDetails??null,hashSource:s.hashSource??null,taskId:s.taskId}}),Ue=(e,s,t,r,n,a)=>{c.info(`Why ${e}? (run ${s.id})`),a.info(""),a.info(` status: ${t.cacheStatus}`),a.info(` hash: ${t.hash??"(none)"}`),t.hashSource==="declared-fallback"&&a.info(" key: declared-fallback (tracker observed no workspace access; keyed on declared inputs)"),n?a.info(` prev: ${n.hash??"(none)"} [run ${r?.id??"?"}]`):a.info(" prev: (no prior run found)"),a.info("")},Ye=(e,s,t,r)=>{if(t.cacheMissReasons&&t.cacheMissReasons.length>0){r.info("Cache miss reasons (trace-mode fingerprint):");for(const n of t.cacheMissReasons)r.info(` - ${pe(n)}`)}else c.info("No hash inputs recorded for this run (trace-mode tasks record a miss reason only when the cache misses).");r.info(""),c.info(`Tracked files and env of this run: vis cache hash ${e} --run ${s.id}`)},qe=e=>!e.commandChanged&&[e.nodes,e.runtime,e.implicitDeps].every(s=>s.added.length===0&&s.changed.length===0&&s.removed.length===0),Xe=(e,s)=>{s.info("Hash inputs that changed since the previous run:"),s.info(""),e.commandChanged&&s.info(" command: changed");for(const t of["nodes","runtime","implicitDeps"]){const r=e[t];if(!(r.added.length===0&&r.changed.length===0&&r.removed.length===0)){s.info(` ${t}:`);for(const n of r.added)s.info(` + ${n}`);for(const n of r.changed)s.info(` ~ ${n}`);for(const n of r.removed)s.info(` - ${n}`)}}},Ge=async(e,s,t)=>{const{format:r,runId:n,workspaceRoot:a}=s,o=n===void 0?await q(a,{dataDirectory:x(a)}):await G(a,n);if(!o){He(r,e,n,a);return}const i=F(o,e);if(!i){Je(r,e,o);return}const d=await ye(a,o.id),f=d?F(d,e):void 0,h=$e(i.hashDetails,f?.hashDetails);if(r==="json"){C(Ve(o,i,d,f,h));return}if(Ue(e,o,i,d,f,t),i.hashDetails===void 0){Ye(e,o,i,t);return}if(!f){c.info("No previous run to diff against — first time this task was recorded.");return}if(qe(h)){c.success("No hash inputs changed since the previous run.");return}Xe(h,t),t.info(""),c.info(`Last summary file: ${T(a,{dataDirectory:x(a)})}`)},it=async({logger:e,options:s,visConfig:t,workspaceRoot:r})=>{const{directoriesFor:n}=w(r,s,t),a=n("read"),o=s.format??"table";for(const i of a)a.length>1&&c.info(`# ${i}`),await Be(i,o,e)},ct=async({options:e,visConfig:s,workspaceRoot:t})=>{const r=Z(e.type),n=!!e.dryRun;if(m(r,"task")){const{directoriesFor:a,workspaceRoot:o}=w(t,e,s);for(const i of a("wipe"))await De(i,o,{dryRun:n,force:!!e.force})}if(m(r,"ai"))if(n){const a=M();c.info(`Would clear ${String(a.entries)} cached AI response${a.entries===1?"":"s"}.`)}else ve();if(m(r,"socket"))if(n){const a=I();c.info(`Would clear ${String(a.entries)} cached Socket.dev report${a.entries===1?"":"s"}.`)}else ke();if(m(r,"deps-dev"))if(n){const a=N();c.info(`Would clear ${String(a.entries)} cached deps.dev record${a.entries===1?"":"s"}.`)}else Ce();if(m(r,"snyk"))if(n){const a=z();c.info(`Would clear ${String(a.entries)} cached Snyk record${a.entries===1?"":"s"}.`)}else ge()},dt=async({options:e,visConfig:s,workspaceRoot:t})=>{const{directoriesFor:r,workspaceRoot:n}=w(t,e,s),a=r("evict");for(const o of a)a.length>1&&c.info(`# ${o}`),await Me(o,n,{keepLast:typeof e.keepLast=="number"?e.keepLast:void 0,maxCacheAgeDays:typeof e.maxAgeDays=="number"?e.maxAgeDays:void 0,maxCacheSize:e.maxSize})},Q=e=>e??process.cwd(),ht=async({argument:e,logger:s,options:t,workspaceRoot:r})=>{const n=e[0];if(!n){c.error("No task ID specified. Usage: vis cache why <project>:<target>"),process.exitCode=1;return}await Ge(n,{format:t.format??"table",runId:t.run,workspaceRoot:Q(r)},s)},ft=async({argument:e,logger:s,options:t,visConfig:r,workspaceRoot:n})=>{const a=e[0];if(!a){c.error("No task ID specified. Usage: vis cache hash <project>:<target>"),process.exitCode=1;return}const{directoriesFor:o}=w(n,t,r);await Re(a,{cacheDirectories:o("read"),format:t.format??"table",runId:t.run,workspaceRoot:Q(n)},s)},ut=async({options:e,visConfig:s,workspaceRoot:t})=>{const r=Z(e.type);if((e.format??"table")==="json"){const a={};if(m(r,"task")){const{directoriesFor:o}=w(t,e,s),i=o("read");a.task=await Promise.all(i.map(async d=>{const f=R(d),h=f?await k(d):[],u=h.reduce((l,$)=>l+$.sizeBytes,0);return{directory:d,entries:h.length,exists:f,newestEntry:y(h[0]?.mtimeMs),oldestEntry:y(h.at(-1)?.mtimeMs),totalBytes:u}}))}if(m(r,"ai")){const o=M();a.ai={entries:o.entries,newestEntry:y(o.newestEntry),oldestEntry:y(o.oldestEntry),totalBytes:o.totalSizeBytes}}if(m(r,"socket")){const o=I();a.socket={entries:o.entries,newestEntry:y(o.newestEntry),oldestEntry:y(o.oldestEntry),totalBytes:o.totalSizeBytes}}if(m(r,"deps-dev")){const o=N();a["deps-dev"]={entries:o.entries,newestEntry:y(o.newestEntry),oldestEntry:y(o.oldestEntry),totalBytes:o.totalSizeBytes}}if(m(r,"snyk")){const o=z();a.snyk={entries:o.entries,newestEntry:y(o.newestEntry),oldestEntry:y(o.oldestEntry),totalBytes:o.totalSizeBytes}}process.stdout.write(`${JSON.stringify(a,void 0,2)}
12
+ `);return}if(m(r,"task")){const{directoriesFor:a}=w(t,e,s),o=a("read");for(const i of o)o.length>1&&c.info(`# ${i}`),await Ne(i,"table")}m(r,"ai")&&D("AI response cache",M()),m(r,"socket")&&D("Socket.dev report cache",I()),m(r,"deps-dev")&&D("deps.dev cache",N()),m(r,"snyk")&&D("Snyk issue cache",z())},lt=async({argument:e,logger:s,options:t,visConfig:r,workspaceRoot:n})=>{const a=e[0];if(!a){c.error("No task ID specified. Usage: vis cache verify <project>:<target>"),process.exitCode=1;return}const{directoriesFor:o,workspaceRoot:i}=w(n,t,r),d=o("read");await _e(a,{cacheDirectories:d,format:t.format??"table",workspaceRoot:i},s)};export{ct as cacheCleanExecute,ft as cacheHashExecute,it as cacheListExecute,dt as cachePruneExecute,ut as cacheSizeExecute,lt as cacheVerifyExecute,ht as cacheWhyExecute,ve as clearAiCacheSafe,Ce as clearDepsDevCacheSafe,ge as clearSnykCacheSafe,ke as clearSocketCacheSafe,k as collectCacheEntries,ie as formatAge,De as runClean,Re as runHash,Be as runList,Me as runPrune,Ne as runSize,_e as runVerify,Ge as runWhy};
@@ -1 +1 @@
1
- import{r as m}from"../packem_shared/affected-shas-B_kfSKss.js";import{r as u}from"../packem_shared/toolchain-CP79HNVy.js";const $=async({argument:h,logger:r,options:e,runtime:s,visConfig:f,workspaceRoot:n})=>{const o=h[0];if(!o)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");const l=o.split(",").map(a=>a.trim()).filter(Boolean);if(l.length===0)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=m({defaultBase:f?.defaultBase,workspaceRoot:n}),c=e.base??i.base,d=e.head??i.head;!e.base&&!e.head&&r.info(`▸ Resolved affected refs from ${i.provider} (${i.notes.join("; ")})`),e.skipToolchain||r.info("▸ Toolchain pre-flight"),await u(n,f?.toolchain,{error:a=>{r.error(a)},info:a=>{r.info(a)},warn:a=>{r.warn(a)}},!!e.skipToolchain),e.install?(r.info("▸ Installing dependencies"),await s.runCommand("install",{argv:["--ci","--frozen-lockfile"]})):r.info("▸ Skipping install (--no-install)");for(const a of l){r.info(`▸ Running affected ${a} (base=${c}, head=${d})`);const t=[a,`--base=${c}`,`--head=${d}`,`--upstream=${String(e.upstream??"none")}`,`--downstream=${String(e.downstream??"deep")}`];Number.isFinite(e.parallel)&&t.push(`--parallel=${String(e.parallel)}`),e.partition&&t.push(`--partition=${String(e.partition)}`),e.query&&t.push(`--query=${String(e.query)}`),e.ifPresent&&t.push("--if-present"),await s.runCommand("affected",{argv:t})}r.info("▸ CI pipeline complete")};export{$ as default};
1
+ import{r as m}from"../packem_shared/affected-shas-CycHU3nr.js";import{r as u}from"../packem_shared/toolchain-Bt93i37e.js";const $=async({argument:h,logger:r,options:e,runtime:s,visConfig:f,workspaceRoot:n})=>{const o=h[0];if(!o)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");const l=o.split(",").map(a=>a.trim()).filter(Boolean);if(l.length===0)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=m({defaultBase:f?.defaultBase,workspaceRoot:n}),c=e.base??i.base,d=e.head??i.head;!e.base&&!e.head&&r.info(`▸ Resolved affected refs from ${i.provider} (${i.notes.join("; ")})`),e.skipToolchain||r.info("▸ Toolchain pre-flight"),await u(n,f?.toolchain,{error:a=>{r.error(a)},info:a=>{r.info(a)},warn:a=>{r.warn(a)}},!!e.skipToolchain),e.install?(r.info("▸ Installing dependencies"),await s.runCommand("install",{argv:["--ci","--frozen-lockfile"]})):r.info("▸ Skipping install (--no-install)");for(const a of l){r.info(`▸ Running affected ${a} (base=${c}, head=${d})`);const t=[a,`--base=${c}`,`--head=${d}`,`--upstream=${String(e.upstream??"none")}`,`--downstream=${String(e.downstream??"deep")}`];Number.isFinite(e.parallel)&&t.push(`--parallel=${String(e.parallel)}`),e.partition&&t.push(`--partition=${String(e.partition)}`),e.query&&t.push(`--query=${String(e.query)}`),e.ifPresent&&t.push("--if-present"),await s.runCommand("affected",{argv:t})}r.info("▸ CI pipeline complete")};export{$ as default};