@jerryan/just-bash 3.8.0 → 3.10.0

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 (189) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +5 -15
  3. package/dist/AGENTS.md +2 -2
  4. package/dist/Bash.d.ts +2 -4
  5. package/dist/bin/chunks/builtin-manifest-ORBIZM7I.js +3 -0
  6. package/dist/bin/chunks/{chmod-GX5SYTRL.js → chmod-S4ARARR4.js} +1 -1
  7. package/dist/bin/chunks/chunk-3ASHUC7C.js +44 -0
  8. package/dist/bin/{shell/chunks/chunk-7WBCA2BB.js → chunks/chunk-3DWQCLNP.js} +1 -1
  9. package/dist/bin/{shell/chunks/chunk-3ROYEBJI.js → chunks/chunk-4JPWP5WS.js} +1 -1
  10. package/dist/bin/chunks/{chunk-QFTZKD5O.js → chunk-6TUILMPB.js} +1 -1
  11. package/dist/bin/chunks/{chunk-DRPHNXG7.js → chunk-7LGT4LHQ.js} +1 -1
  12. package/dist/bin/chunks/{chunk-MBREBDZQ.js → chunk-AIWBN36Z.js} +1 -1
  13. package/dist/bin/chunks/chunk-AQKIHX3Q.js +3 -0
  14. package/dist/bin/chunks/chunk-E2O6S35K.js +10 -0
  15. package/dist/bin/chunks/chunk-E54Z6VIE.js +12 -0
  16. package/dist/bin/{shell/chunks/chunk-F2PYTUMR.js → chunks/chunk-F4ACJZIY.js} +7 -6
  17. package/dist/bin/{shell/chunks/chunk-MPFNZYEA.js → chunks/chunk-GKJD4ULC.js} +1 -1
  18. package/dist/bin/{shell/chunks/chunk-QJWFCA7P.js → chunks/chunk-HARVZWUX.js} +1 -1
  19. package/dist/bin/chunks/chunk-IRCAXXH6.js +14 -0
  20. package/dist/bin/chunks/{chunk-T6OIISUC.js → chunk-K65FCSAT.js} +1 -1
  21. package/dist/bin/{shell/chunks/chunk-MF3GVFLC.js → chunks/chunk-L345YZ6R.js} +1 -1
  22. package/dist/bin/{shell/chunks/chunk-6FGMEZZP.js → chunks/chunk-MWQMHODV.js} +1 -1
  23. package/dist/bin/chunks/{chunk-BB5VTPMQ.js → chunk-NSI6LMDS.js} +1 -1
  24. package/dist/bin/{shell/chunks/chunk-ABP4OLJV.js → chunks/chunk-OXEDIWNZ.js} +1 -1
  25. package/dist/bin/chunks/chunk-QKJAAJ7J.js +3 -0
  26. package/dist/bin/chunks/{chunk-KMYJMEON.js → chunk-R7THHH4J.js} +1 -1
  27. package/dist/bin/chunks/chunk-UBA7DOWE.js +3 -0
  28. package/dist/bin/chunks/{chunk-VPSBWWXM.js → chunk-UNCYBFWT.js} +7 -6
  29. package/dist/bin/chunks/chunk-VMVXACZ5.js +6 -0
  30. package/dist/bin/chunks/chunk-Z3TCELKN.js +12 -0
  31. package/dist/bin/chunks/{cp-YLP7ULVT.js → cp-WRBRHVVD.js} +1 -1
  32. package/dist/bin/chunks/{diff-JSJ56EOK.js → diff-YLVT27CZ.js} +1 -1
  33. package/dist/bin/{shell/chunks/du-DH76GZJ3.js → chunks/du-YNAJTGCR.js} +1 -1
  34. package/dist/bin/{shell/chunks/find-MHC4QV6H.js → chunks/find-T3JZPTUX.js} +1 -1
  35. package/dist/bin/chunks/{flag-coverage-2H5CPEM6.js → flag-coverage-LVKHEUTL.js} +1 -1
  36. package/dist/bin/chunks/{gzip-UQZL4R74.js → gzip-EXJSFNCU.js} +1 -1
  37. package/dist/bin/chunks/js-exec-PLUMFEX6.js +99 -0
  38. package/dist/bin/chunks/js-exec-worker.js +4995 -0
  39. package/dist/bin/chunks/{ls-5Z45FV4U.js → ls-LOCOWLZ3.js} +1 -1
  40. package/dist/bin/chunks/{mkdir-YJ3SOVRP.js → mkdir-VHLJ3E65.js} +1 -1
  41. package/dist/bin/chunks/{mv-EOOP2TO3.js → mv-NAMOL2HF.js} +1 -1
  42. package/dist/bin/chunks/python3-J5GXF27H.js +14 -0
  43. package/dist/bin/{shell/chunks/readlink-EJ3IKLWW.js → chunks/readlink-BF435HNQ.js} +1 -1
  44. package/dist/bin/chunks/{rg-WHVR3YDT.js → rg-XF5U7GS2.js} +1 -1
  45. package/dist/bin/{shell/chunks/rm-B4LVIG7A.js → chunks/rm-L4RHENMV.js} +1 -1
  46. package/dist/bin/{shell/chunks/rmdir-PRNISPBA.js → chunks/rmdir-W73C4GEA.js} +1 -1
  47. package/dist/bin/{shell/chunks/sleep-DVFE2GSF.js → chunks/sleep-MOJQBZMY.js} +1 -1
  48. package/dist/bin/{shell/chunks/split-HIFKSV2A.js → chunks/split-2VXPZJJ4.js} +1 -1
  49. package/dist/bin/chunks/{sqlite3-KNN6V2W6.js → sqlite3-3S5HIA5W.js} +1 -1
  50. package/dist/bin/chunks/{timeout-YGFHQJKX.js → timeout-RQOWSWYG.js} +1 -1
  51. package/dist/bin/chunks/{which-4TPGVSBZ.js → which-G7X54RZL.js} +1 -1
  52. package/dist/bin/just-bash.js +243 -242
  53. package/dist/bin/shell/chunks/builtin-manifest-ORBIZM7I.js +3 -0
  54. package/dist/bin/shell/chunks/{chmod-GX5SYTRL.js → chmod-S4ARARR4.js} +1 -1
  55. package/dist/bin/shell/chunks/chunk-3ASHUC7C.js +44 -0
  56. package/dist/bin/{chunks/chunk-7WBCA2BB.js → shell/chunks/chunk-3DWQCLNP.js} +1 -1
  57. package/dist/bin/{chunks/chunk-3ROYEBJI.js → shell/chunks/chunk-4JPWP5WS.js} +1 -1
  58. package/dist/bin/shell/chunks/{chunk-QFTZKD5O.js → chunk-6TUILMPB.js} +1 -1
  59. package/dist/bin/shell/chunks/{chunk-DRPHNXG7.js → chunk-7LGT4LHQ.js} +1 -1
  60. package/dist/bin/shell/chunks/{chunk-MBREBDZQ.js → chunk-AIWBN36Z.js} +1 -1
  61. package/dist/bin/shell/chunks/chunk-AQKIHX3Q.js +3 -0
  62. package/dist/bin/shell/chunks/chunk-E2O6S35K.js +10 -0
  63. package/dist/bin/shell/chunks/chunk-E54Z6VIE.js +12 -0
  64. package/dist/bin/{chunks/chunk-F2PYTUMR.js → shell/chunks/chunk-F4ACJZIY.js} +7 -6
  65. package/dist/bin/{chunks/chunk-MPFNZYEA.js → shell/chunks/chunk-GKJD4ULC.js} +1 -1
  66. package/dist/bin/{chunks/chunk-QJWFCA7P.js → shell/chunks/chunk-HARVZWUX.js} +1 -1
  67. package/dist/bin/shell/chunks/chunk-IRCAXXH6.js +14 -0
  68. package/dist/bin/shell/chunks/{chunk-T6OIISUC.js → chunk-K65FCSAT.js} +1 -1
  69. package/dist/bin/{chunks/chunk-MF3GVFLC.js → shell/chunks/chunk-L345YZ6R.js} +1 -1
  70. package/dist/bin/{chunks/chunk-6FGMEZZP.js → shell/chunks/chunk-MWQMHODV.js} +1 -1
  71. package/dist/bin/shell/chunks/{chunk-BB5VTPMQ.js → chunk-NSI6LMDS.js} +1 -1
  72. package/dist/bin/{chunks/chunk-ABP4OLJV.js → shell/chunks/chunk-OXEDIWNZ.js} +1 -1
  73. package/dist/bin/shell/chunks/chunk-QKJAAJ7J.js +3 -0
  74. package/dist/bin/shell/chunks/{chunk-KMYJMEON.js → chunk-R7THHH4J.js} +1 -1
  75. package/dist/bin/shell/chunks/chunk-UBA7DOWE.js +3 -0
  76. package/dist/bin/shell/chunks/{chunk-VPSBWWXM.js → chunk-UNCYBFWT.js} +7 -6
  77. package/dist/bin/shell/chunks/chunk-VMVXACZ5.js +6 -0
  78. package/dist/bin/shell/chunks/chunk-Z3TCELKN.js +12 -0
  79. package/dist/bin/shell/chunks/{cp-YLP7ULVT.js → cp-WRBRHVVD.js} +1 -1
  80. package/dist/bin/shell/chunks/{diff-JSJ56EOK.js → diff-YLVT27CZ.js} +1 -1
  81. package/dist/bin/{chunks/du-DH76GZJ3.js → shell/chunks/du-YNAJTGCR.js} +1 -1
  82. package/dist/bin/{chunks/find-MHC4QV6H.js → shell/chunks/find-T3JZPTUX.js} +1 -1
  83. package/dist/bin/shell/chunks/{flag-coverage-2H5CPEM6.js → flag-coverage-LVKHEUTL.js} +1 -1
  84. package/dist/bin/shell/chunks/{gzip-UQZL4R74.js → gzip-EXJSFNCU.js} +1 -1
  85. package/dist/bin/shell/chunks/js-exec-PLUMFEX6.js +99 -0
  86. package/dist/bin/shell/chunks/{ls-5Z45FV4U.js → ls-LOCOWLZ3.js} +1 -1
  87. package/dist/bin/shell/chunks/{mkdir-YJ3SOVRP.js → mkdir-VHLJ3E65.js} +1 -1
  88. package/dist/bin/shell/chunks/{mv-EOOP2TO3.js → mv-NAMOL2HF.js} +1 -1
  89. package/dist/bin/shell/chunks/python3-J5GXF27H.js +14 -0
  90. package/dist/bin/{chunks/readlink-EJ3IKLWW.js → shell/chunks/readlink-BF435HNQ.js} +1 -1
  91. package/dist/bin/shell/chunks/{rg-WHVR3YDT.js → rg-XF5U7GS2.js} +1 -1
  92. package/dist/bin/{chunks/rm-B4LVIG7A.js → shell/chunks/rm-L4RHENMV.js} +1 -1
  93. package/dist/bin/{chunks/rmdir-PRNISPBA.js → shell/chunks/rmdir-W73C4GEA.js} +1 -1
  94. package/dist/bin/{chunks/sleep-DVFE2GSF.js → shell/chunks/sleep-MOJQBZMY.js} +1 -1
  95. package/dist/bin/{chunks/split-HIFKSV2A.js → shell/chunks/split-2VXPZJJ4.js} +1 -1
  96. package/dist/bin/shell/chunks/{sqlite3-KNN6V2W6.js → sqlite3-3S5HIA5W.js} +1 -1
  97. package/dist/bin/shell/chunks/{timeout-YGFHQJKX.js → timeout-RQOWSWYG.js} +1 -1
  98. package/dist/bin/shell/chunks/{which-4TPGVSBZ.js → which-G7X54RZL.js} +1 -1
  99. package/dist/bin/shell/shell.js +305 -304
  100. package/dist/bundle/browser.js +637 -611
  101. package/dist/bundle/chunks/builtin-manifest-7MJJDZ2T.js +2 -0
  102. package/dist/bundle/chunks/{chmod-TEY5MD2W.js → chmod-KMFNCMRX.js} +1 -1
  103. package/dist/bundle/chunks/chunk-2A4OZBCS.js +43 -0
  104. package/dist/bundle/chunks/{chunk-SE23TEGG.js → chunk-4CDTAUYP.js} +1 -1
  105. package/dist/bundle/chunks/chunk-4OKRFRMS.js +13 -0
  106. package/dist/bundle/chunks/{chunk-ATGOUOX2.js → chunk-4WRO2G22.js} +1 -1
  107. package/dist/bundle/chunks/{chunk-45QZRGYF.js → chunk-5KOWUQOZ.js} +7 -6
  108. package/dist/bundle/chunks/{chunk-6HO6HX7V.js → chunk-5NUTFEEG.js} +1 -1
  109. package/dist/bundle/chunks/{chunk-N3A4JVFJ.js → chunk-6IA4DXG2.js} +1 -1
  110. package/dist/bundle/chunks/{chunk-WE7BJ7YU.js → chunk-6IFH67ZB.js} +1 -1
  111. package/dist/bundle/chunks/chunk-6L6OYVLY.js +2 -0
  112. package/dist/bundle/chunks/chunk-BMBITA6Y.js +2 -0
  113. package/dist/bundle/chunks/chunk-BS6EJR2R.js +11 -0
  114. package/dist/bundle/chunks/{chunk-S6DNKKUL.js → chunk-CM4T4GB4.js} +1 -1
  115. package/dist/bundle/chunks/{chunk-MWL2I5BV.js → chunk-FXAKF2QS.js} +1 -1
  116. package/dist/bundle/chunks/chunk-H4AFUSSQ.js +9 -0
  117. package/dist/bundle/chunks/{chunk-GNPLDVBD.js → chunk-MMXJJCAE.js} +1 -1
  118. package/dist/bundle/chunks/{chunk-6QAM55HM.js → chunk-NFODJFHN.js} +1 -1
  119. package/dist/bundle/chunks/{chunk-LRFR25IP.js → chunk-O5OYOY3C.js} +7 -6
  120. package/dist/bundle/chunks/{chunk-HCKTU6IR.js → chunk-PASYAXFP.js} +1 -1
  121. package/dist/bundle/chunks/chunk-PS2RJNZZ.js +2 -0
  122. package/dist/bundle/chunks/chunk-THDUQVY3.js +11 -0
  123. package/dist/bundle/chunks/{chunk-DMWNBCXJ.js → chunk-TLPMB3FO.js} +1 -1
  124. package/dist/bundle/chunks/{chunk-FSKXIFYT.js → chunk-Y6UHNLT5.js} +1 -1
  125. package/dist/bundle/chunks/{chunk-XV2V56NQ.js → chunk-YFFU74KY.js} +1 -1
  126. package/dist/bundle/chunks/chunk-ZIQS5QAW.js +5 -0
  127. package/dist/bundle/chunks/{cp-UR762VVT.js → cp-P2D2L6PC.js} +1 -1
  128. package/dist/bundle/chunks/{diff-VDB6RXHO.js → diff-Z3XOLW44.js} +1 -1
  129. package/dist/bundle/chunks/{du-EQKH3UNA.js → du-YBSJVBXP.js} +1 -1
  130. package/dist/bundle/chunks/{find-RLKBCGJR.js → find-IUWEB4XQ.js} +1 -1
  131. package/dist/bundle/chunks/{flag-coverage-UMQ3BWDP.js → flag-coverage-SZ4AUPRQ.js} +1 -1
  132. package/dist/bundle/chunks/{gzip-KC5ENBD2.js → gzip-VUJBDHZ5.js} +1 -1
  133. package/dist/bundle/chunks/js-exec-6RW7WZCG.js +98 -0
  134. package/dist/bundle/chunks/js-exec-worker.js +4995 -0
  135. package/dist/bundle/chunks/{ls-WH5S4PPL.js → ls-ECKG2XHZ.js} +1 -1
  136. package/dist/bundle/chunks/{mkdir-Z6MMWH3D.js → mkdir-YL7XGMD7.js} +1 -1
  137. package/dist/bundle/chunks/{mv-WE7DBLEK.js → mv-IF55A2UD.js} +1 -1
  138. package/dist/bundle/chunks/python3-XHTOW7VA.js +13 -0
  139. package/dist/bundle/chunks/{readlink-JSRKXLLQ.js → readlink-7XGQ3PL7.js} +1 -1
  140. package/dist/bundle/chunks/{rg-JKB7DR66.js → rg-E6H2HACA.js} +1 -1
  141. package/dist/bundle/chunks/{rm-IGPLE632.js → rm-CWLMERIO.js} +1 -1
  142. package/dist/bundle/chunks/{rmdir-3WTXMVKI.js → rmdir-WKKBLZ54.js} +1 -1
  143. package/dist/bundle/chunks/{sleep-PPRBTSVR.js → sleep-25QUPVDK.js} +1 -1
  144. package/dist/bundle/chunks/{split-HUKVGJTW.js → split-NEU2K2YN.js} +1 -1
  145. package/dist/bundle/chunks/{sqlite3-KB3MXTTM.js → sqlite3-KJ5NMKBM.js} +1 -1
  146. package/dist/bundle/chunks/{timeout-C6WDYPLV.js → timeout-37GM7IIL.js} +1 -1
  147. package/dist/bundle/chunks/{which-UWVKETYW.js → which-BP5YY5BR.js} +1 -1
  148. package/dist/bundle/index.cjs +1134 -2660
  149. package/dist/bundle/index.js +210 -209
  150. package/dist/commands/js-exec/js-exec-worker.d.ts +35 -0
  151. package/dist/commands/js-exec/js-exec.d.ts +14 -1
  152. package/dist/commands/which/which.d.ts +10 -0
  153. package/dist/custom-commands.d.ts +5 -0
  154. package/dist/fs/path-utils.d.ts +0 -4
  155. package/dist/fs/vfs-template.d.ts +6 -0
  156. package/dist/interpreter/interpreter.d.ts +1 -1
  157. package/dist/interpreter/types.d.ts +1 -1
  158. package/dist/limits.d.ts +2 -5
  159. package/dist/timers.d.ts +9 -0
  160. package/dist/types.d.ts +9 -4
  161. package/package.json +8 -8
  162. package/dist/bin/chunks/chunk-2NJJXU4K.js +0 -27
  163. package/dist/bin/chunks/chunk-6JUPBMCR.js +0 -13
  164. package/dist/bin/chunks/chunk-CN4JKMTR.js +0 -8
  165. package/dist/bin/chunks/chunk-HWK7KFGB.js +0 -3
  166. package/dist/bin/chunks/chunk-PPVF2N6C.js +0 -3
  167. package/dist/bin/chunks/chunk-RTN6X652.js +0 -11
  168. package/dist/bin/chunks/chunk-RVPTAYDS.js +0 -4
  169. package/dist/bin/chunks/js-exec-T3SAB2B6.js +0 -1651
  170. package/dist/bin/chunks/python3-3ERN3L6S.js +0 -23
  171. package/dist/bin/shell/chunks/chunk-2NJJXU4K.js +0 -27
  172. package/dist/bin/shell/chunks/chunk-6JUPBMCR.js +0 -13
  173. package/dist/bin/shell/chunks/chunk-CN4JKMTR.js +0 -8
  174. package/dist/bin/shell/chunks/chunk-HWK7KFGB.js +0 -3
  175. package/dist/bin/shell/chunks/chunk-PPVF2N6C.js +0 -3
  176. package/dist/bin/shell/chunks/chunk-RTN6X652.js +0 -11
  177. package/dist/bin/shell/chunks/chunk-RVPTAYDS.js +0 -4
  178. package/dist/bin/shell/chunks/js-exec-T3SAB2B6.js +0 -1651
  179. package/dist/bin/shell/chunks/python3-3ERN3L6S.js +0 -23
  180. package/dist/bundle/chunks/chunk-2SMD2AUA.js +0 -3
  181. package/dist/bundle/chunks/chunk-3OBCZP7T.js +0 -12
  182. package/dist/bundle/chunks/chunk-4CC3OZPU.js +0 -2
  183. package/dist/bundle/chunks/chunk-A257L6QO.js +0 -7
  184. package/dist/bundle/chunks/chunk-B6OSJB22.js +0 -26
  185. package/dist/bundle/chunks/chunk-RWQWFXMH.js +0 -10
  186. package/dist/bundle/chunks/chunk-WXPNKIIH.js +0 -2
  187. package/dist/bundle/chunks/js-exec-ZQMIYQTH.js +0 -1650
  188. package/dist/bundle/chunks/python3-QB7OE256.js +0 -22
  189. package/dist/commands/js-exec/run-runtime.d.ts +0 -10
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{b as E}from"./chunk-GR4ZHKXI.js";import{a as h}from"./chunk-MBREBDZQ.js";import{l as $}from"./chunk-FUT3X2GJ.js";import{a as k}from"./chunk-CPKBPQ2C.js";import{a as C,b as L,c as F}from"./chunk-MUFNRCMY.js";var A={name:"split",summary:"split a file into pieces",usage:"split [OPTION]... [FILE [PREFIX]]",description:"Output pieces of FILE to PREFIXaa, PREFIXab, ...; default size is 1000 lines, and default PREFIX is 'x'.",options:["-l N Put N lines per output file","-b SIZE Put SIZE bytes per output file (K, M, G suffixes)","-n CHUNKS Split into CHUNKS equal-sized files","-d Use numeric suffixes (00, 01, ...) instead of alphabetic","-a LENGTH Use suffixes of length LENGTH (default: 2)","--additional-suffix=SUFFIX Append SUFFIX to file names"],examples:["split -l 100 file.txt # Split into 100-line chunks","split -b 1M file.bin # Split into 1MB chunks","split -n 5 file.txt # Split into 5 equal parts","split -d file.txt part_ # part_00, part_01, ...","split -a 3 -d file.txt x # x000, x001, ..."]},S=1e5,_=0;function U(e){return Uint8Array.from(e,t=>t.charCodeAt(0))}function N(e){let t=e.match(/^(\d+)([KMGTPEZY]?)([B]?)$/i);if(!t)return null;let i=Number(t[1]);if(!Number.isSafeInteger(i)||i<1)return null;let u=(t[2]||"").toUpperCase(),a=new Map([["",1],["K",1024],["M",1024*1024],["G",1024*1024*1024],["T",1024*1024*1024*1024],["P",1024*1024*1024*1024*1024]]).get(u);return a===void 0||i>Math.floor(Number.MAX_SAFE_INTEGER/a)?null:i*a}function x(e){if(!/^[0-9]+$/.test(e))return null;let t=Number(e);return Number.isSafeInteger(t)&&t>=1?t:null}function H(e,t,i){if(t)return e.toString().padStart(i,"0");let u="abcdefghijklmnopqrstuvwxyz",n=new Array(i),a=e;for(let o=i-1;o>=0;o--)n[o]=u[a%26],a=Math.floor(a/26);return n.join("")}function B(e,t){let i=[],u=0,n=0;for(let a=0;a<e.length;a++)e[a]===10&&(n++,n===t&&(i.push(e.subarray(u,a+1)),u=a+1,n=0));return u<e.length&&i.push(e.subarray(u)),i}function T(e,t){let i=[];for(let u=0;u<e.length;u+=t)i.push(e.subarray(u,u+t));return i}function X(e,t){let i=[],u=Math.ceil(e.length/t);for(let n=0;n<t;n++){let a=n*u,o=Math.min(a+u,e.length);a<o&&i.push(e.subarray(a,o))}return i}function z(e,t){let i=e?10**t:26**t;return Number.isSafeInteger(i)?i:Number.MAX_SAFE_INTEGER}function G(e){if(e.existence!=="unknown")return e.existence==="existing"?e.stableIdentity:e.canonicalPath===void 0?void 0:`missing:${e.canonicalPath}`}function I(e,t){return e.existence!==t.existence||e.existence==="unknown"||t.existence==="unknown"?!1:e.existence==="missing"&&t.existence==="missing"?e.canonicalPath===t.canonicalPath:e.existence==="existing"&&t.existence==="existing"?e.stableIdentity!==void 0&&e.stableIdentity===t.stableIdentity:!1}async function M(e,t,i){let u=t.lastIndexOf("/"),n=u<=0?"/":t.slice(0,u),a=t.slice(u+1);for(let o=0;o<100;o++){let d=_++,c=e.fs.resolvePath(n,`.${a}.just-bash-split-${i}-${d}`),p=await h(e.fs,c);if(p.existence==="missing")return c;if(p.existence==="unknown")break}throw new Error("unable to allocate transaction path")}var Z={name:"split",execute:async(e,t)=>{if(L(e))return C(A);let i={mode:"lines",lines:1e3,bytes:0,chunks:0,useNumericSuffix:!1,suffixLength:2,additionalSuffix:""},u=[],n=0;for(;n<e.length;){let s=e[n];if(s==="-l"&&n+1<e.length){let l=x(e[n+1]);if(l===null)return{exitCode:1,stdout:"",stderr:`split: invalid number of lines: '${e[n+1]}'
3
+ import{b as E}from"./chunk-GR4ZHKXI.js";import{a as h}from"./chunk-AIWBN36Z.js";import{l as $}from"./chunk-FUT3X2GJ.js";import{a as k}from"./chunk-CPKBPQ2C.js";import{a as C,b as L,c as F}from"./chunk-MUFNRCMY.js";var A={name:"split",summary:"split a file into pieces",usage:"split [OPTION]... [FILE [PREFIX]]",description:"Output pieces of FILE to PREFIXaa, PREFIXab, ...; default size is 1000 lines, and default PREFIX is 'x'.",options:["-l N Put N lines per output file","-b SIZE Put SIZE bytes per output file (K, M, G suffixes)","-n CHUNKS Split into CHUNKS equal-sized files","-d Use numeric suffixes (00, 01, ...) instead of alphabetic","-a LENGTH Use suffixes of length LENGTH (default: 2)","--additional-suffix=SUFFIX Append SUFFIX to file names"],examples:["split -l 100 file.txt # Split into 100-line chunks","split -b 1M file.bin # Split into 1MB chunks","split -n 5 file.txt # Split into 5 equal parts","split -d file.txt part_ # part_00, part_01, ...","split -a 3 -d file.txt x # x000, x001, ..."]},S=1e5,_=0;function U(e){return Uint8Array.from(e,t=>t.charCodeAt(0))}function N(e){let t=e.match(/^(\d+)([KMGTPEZY]?)([B]?)$/i);if(!t)return null;let i=Number(t[1]);if(!Number.isSafeInteger(i)||i<1)return null;let u=(t[2]||"").toUpperCase(),a=new Map([["",1],["K",1024],["M",1024*1024],["G",1024*1024*1024],["T",1024*1024*1024*1024],["P",1024*1024*1024*1024*1024]]).get(u);return a===void 0||i>Math.floor(Number.MAX_SAFE_INTEGER/a)?null:i*a}function x(e){if(!/^[0-9]+$/.test(e))return null;let t=Number(e);return Number.isSafeInteger(t)&&t>=1?t:null}function H(e,t,i){if(t)return e.toString().padStart(i,"0");let u="abcdefghijklmnopqrstuvwxyz",n=new Array(i),a=e;for(let o=i-1;o>=0;o--)n[o]=u[a%26],a=Math.floor(a/26);return n.join("")}function B(e,t){let i=[],u=0,n=0;for(let a=0;a<e.length;a++)e[a]===10&&(n++,n===t&&(i.push(e.subarray(u,a+1)),u=a+1,n=0));return u<e.length&&i.push(e.subarray(u)),i}function T(e,t){let i=[];for(let u=0;u<e.length;u+=t)i.push(e.subarray(u,u+t));return i}function X(e,t){let i=[],u=Math.ceil(e.length/t);for(let n=0;n<t;n++){let a=n*u,o=Math.min(a+u,e.length);a<o&&i.push(e.subarray(a,o))}return i}function z(e,t){let i=e?10**t:26**t;return Number.isSafeInteger(i)?i:Number.MAX_SAFE_INTEGER}function G(e){if(e.existence!=="unknown")return e.existence==="existing"?e.stableIdentity:e.canonicalPath===void 0?void 0:`missing:${e.canonicalPath}`}function I(e,t){return e.existence!==t.existence||e.existence==="unknown"||t.existence==="unknown"?!1:e.existence==="missing"&&t.existence==="missing"?e.canonicalPath===t.canonicalPath:e.existence==="existing"&&t.existence==="existing"?e.stableIdentity!==void 0&&e.stableIdentity===t.stableIdentity:!1}async function M(e,t,i){let u=t.lastIndexOf("/"),n=u<=0?"/":t.slice(0,u),a=t.slice(u+1);for(let o=0;o<100;o++){let d=_++,c=e.fs.resolvePath(n,`.${a}.just-bash-split-${i}-${d}`),p=await h(e.fs,c);if(p.existence==="missing")return c;if(p.existence==="unknown")break}throw new Error("unable to allocate transaction path")}var Z={name:"split",execute:async(e,t)=>{if(L(e))return C(A);let i={mode:"lines",lines:1e3,bytes:0,chunks:0,useNumericSuffix:!1,suffixLength:2,additionalSuffix:""},u=[],n=0;for(;n<e.length;){let s=e[n];if(s==="-l"&&n+1<e.length){let l=x(e[n+1]);if(l===null)return{exitCode:1,stdout:"",stderr:`split: invalid number of lines: '${e[n+1]}'
4
4
  `};i.mode="lines",i.lines=l,n+=2}else if(s.match(/^-l\d+$/)){let l=x(s.slice(2));if(l===null)return{exitCode:1,stdout:"",stderr:`split: invalid number of lines: '${s.slice(2)}'
5
5
  `};i.mode="lines",i.lines=l,n++}else if(s==="-b"&&n+1<e.length){let l=N(e[n+1]);if(l===null)return{exitCode:1,stdout:"",stderr:`split: invalid number of bytes: '${e[n+1]}'
6
6
  `};i.mode="bytes",i.bytes=l,n+=2}else if(s.match(/^-b.+$/)){let l=N(s.slice(2));if(l===null)return{exitCode:1,stdout:"",stderr:`split: invalid number of bytes: '${s.slice(2)}'
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
+ import{a as i}from"./chunk-OHFB3M3X.js";var a=40,d=493,x=420,$=511;function e(t){if(!t||t==="/")return"/";let r=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;r.startsWith("/")||(r=`/${r}`);let n=r.split("/").filter(s=>s&&s!=="."),o=[];for(let s of n)s===".."?o.pop():o.push(s);return`/${o.join("/")}`||"/"}function m(t,r){let n=e(t),o=e(r);return o===n||n==="/"||o.startsWith(`${n}/`)}function E(t,r){if(t.includes("\0"))throw new i("ENOENT",`path contains null byte, ${r} '${t}'`)}function c(t){let r=e(t);if(r==="/")return"/";let n=r.lastIndexOf("/");return n===0?"/":r.slice(0,n)}function l(t){if(typeof process>"u"||process.platform!=="win32"||!/^[A-Za-z]:[\\/]/.test(t))return t;let r=t[0].toLowerCase(),n=t.slice(2).replace(/\\/g,"/");return`/${r}${n}`}function p(t,r){if(r=l(r),r.startsWith("/"))return e(r);let n=t==="/"?`/${r}`:`${t}/${r}`;return e(n)}function D(t){return t.replace(/\\/g,"/")}function u(t,r){return t==="/"?`/${r}`:`${t}/${r}`}function P(t,r){if(r.startsWith("/"))return e(r);let n=c(t);return e(u(n,r))}export{a,d as b,x as c,$ as d,e,m as f,E as g,c as h,p as i,D as j,u as k,P as l};
@@ -1,19 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{f as Y}from"./chunk-47IFMQYS.js";import{a as K}from"./chunk-3MRB66F4.js";import{a as P,b as J,c as D}from"./chunk-QFOXSCOD.js";import{a as W}from"./chunk-YXPSX3SI.js";import{b as N}from"./chunk-GR4ZHKXI.js";import{d as V}from"./chunk-I57EACSL.js";import{d as Z}from"./chunk-MBREBDZQ.js";import{l as M}from"./chunk-FUT3X2GJ.js";import{a as G,b as T,e as _}from"./chunk-CPKBPQ2C.js";import{a as q,b as H,c as O}from"./chunk-MUFNRCMY.js";var X=Y({js:{extensions:[".js",".mjs",".cjs",".jsx"],globs:[]},ts:{extensions:[".ts",".tsx",".mts",".cts"],globs:[]},html:{extensions:[".html",".htm",".xhtml"],globs:[]},css:{extensions:[".css",".scss",".sass",".less"],globs:[]},json:{extensions:[".json",".jsonc",".json5"],globs:[]},xml:{extensions:[".xml",".xsl",".xslt"],globs:[]},c:{extensions:[".c",".h"],globs:[]},cpp:{extensions:[".cpp",".cc",".cxx",".hpp",".hh",".hxx",".h"],globs:[]},rust:{extensions:[".rs"],globs:[]},go:{extensions:[".go"],globs:[]},zig:{extensions:[".zig"],globs:[]},java:{extensions:[".java"],globs:[]},kotlin:{extensions:[".kt",".kts"],globs:[]},scala:{extensions:[".scala",".sc"],globs:[]},clojure:{extensions:[".clj",".cljc",".cljs",".edn"],globs:[]},py:{extensions:[".py",".pyi",".pyw"],globs:[]},rb:{extensions:[".rb",".rake",".gemspec"],globs:["Rakefile","Gemfile"]},php:{extensions:[".php",".phtml",".php3",".php4",".php5"],globs:[]},perl:{extensions:[".pl",".pm",".pod",".t"],globs:[]},lua:{extensions:[".lua"],globs:[]},sh:{extensions:[".sh",".bash",".zsh",".fish"],globs:[".bashrc",".zshrc",".profile"]},bat:{extensions:[".bat",".cmd"],globs:[]},ps:{extensions:[".ps1",".psm1",".psd1"],globs:[]},yaml:{extensions:[".yaml",".yml"],globs:[]},toml:{extensions:[".toml"],globs:["Cargo.toml","pyproject.toml"]},ini:{extensions:[".ini",".cfg",".conf"],globs:[]},csv:{extensions:[".csv",".tsv"],globs:[]},md:{extensions:[".md",".mdx",".markdown",".mdown",".mkd"],globs:[]},markdown:{extensions:[".md",".mdx",".markdown",".mdown",".mkd"],globs:[]},rst:{extensions:[".rst"],globs:[]},txt:{extensions:[".txt",".text"],globs:[]},tex:{extensions:[".tex",".ltx",".sty",".cls"],globs:[]},sql:{extensions:[".sql"],globs:[]},graphql:{extensions:[".graphql",".gql"],globs:[]},proto:{extensions:[".proto"],globs:[]},make:{extensions:[".mk",".mak"],globs:["Makefile","GNUmakefile","makefile"]},docker:{extensions:[],globs:["Dockerfile","Dockerfile.*","*.dockerfile"]},tf:{extensions:[".tf",".tfvars"],globs:[]}}),A=class{types;constructor(){this.types=new Map(Object.entries(X).map(([t,s])=>[t,{extensions:[...s.extensions],globs:[...s.globs]}]))}addType(t){let s=t.indexOf(":");if(s===-1)return;let n=t.slice(0,s),r=t.slice(s+1);if(r.startsWith("include:")){let i=r.slice(8),l=this.types.get(i);if(l){let o=this.types.get(n)||{extensions:[],globs:[]};o.extensions.push(...l.extensions),o.globs.push(...l.globs),this.types.set(n,o)}}else{let i=this.types.get(n)||{extensions:[],globs:[]};if(r.startsWith("*.")&&!r.slice(2).includes("*")){let l=r.slice(1);i.extensions.includes(l)||i.extensions.push(l)}else i.globs.includes(r)||i.globs.push(r);this.types.set(n,i)}}clearType(t){let s=this.types.get(t);s&&(s.extensions=[],s.globs=[])}getType(t){return this.types.get(t)}getAllTypes(){return this.types}matchesType(t,s){let n=t.toLowerCase();for(let r of s){if(r==="all"){if(this.matchesAnyType(t))return!0;continue}let i=this.types.get(r);if(i){for(let l of i.extensions)if(n.endsWith(l))return!0;for(let l of i.globs)if(l.includes("*")){let o=l.replace(/\./g,"\\.").replace(/\*/g,".*");if(W(`^${o}$`,"i").test(t))return!0}else if(n===l.toLowerCase())return!0}}return!1}matchesAnyType(t){let s=t.toLowerCase();for(let n of this.types.values()){for(let r of n.extensions)if(s.endsWith(r))return!0;for(let r of n.globs)if(r.includes("*")){let i=r.replace(/\./g,"\\.").replace(/\*/g,".*");if(W(`^${i}$`,"i").test(t))return!0}else if(s===r.toLowerCase())return!0}return!1}};function Q(){let e=[];for(let[t,s]of Object.entries(X).sort()){let n=[];for(let r of s.extensions)n.push(`*${r}`);for(let r of s.globs)n.push(r);e.push(`${t}: ${n.join(", ")}`)}return`${e.join(`
3
+ import{f as Y}from"./chunk-47IFMQYS.js";import{a as K}from"./chunk-3MRB66F4.js";import{a as P,b as J,c as D}from"./chunk-QFOXSCOD.js";import{a as W}from"./chunk-YXPSX3SI.js";import{b as N}from"./chunk-GR4ZHKXI.js";import{d as H}from"./chunk-I57EACSL.js";import{d as Z}from"./chunk-AIWBN36Z.js";import{l as M}from"./chunk-FUT3X2GJ.js";import{a as G,b as T,e as _}from"./chunk-CPKBPQ2C.js";import{a as q,b as V,c as E}from"./chunk-MUFNRCMY.js";var X=Y({js:{extensions:[".js",".mjs",".cjs",".jsx"],globs:[]},ts:{extensions:[".ts",".tsx",".mts",".cts"],globs:[]},html:{extensions:[".html",".htm",".xhtml"],globs:[]},css:{extensions:[".css",".scss",".sass",".less"],globs:[]},json:{extensions:[".json",".jsonc",".json5"],globs:[]},xml:{extensions:[".xml",".xsl",".xslt"],globs:[]},c:{extensions:[".c",".h"],globs:[]},cpp:{extensions:[".cpp",".cc",".cxx",".hpp",".hh",".hxx",".h"],globs:[]},rust:{extensions:[".rs"],globs:[]},go:{extensions:[".go"],globs:[]},zig:{extensions:[".zig"],globs:[]},java:{extensions:[".java"],globs:[]},kotlin:{extensions:[".kt",".kts"],globs:[]},scala:{extensions:[".scala",".sc"],globs:[]},clojure:{extensions:[".clj",".cljc",".cljs",".edn"],globs:[]},py:{extensions:[".py",".pyi",".pyw"],globs:[]},rb:{extensions:[".rb",".rake",".gemspec"],globs:["Rakefile","Gemfile"]},php:{extensions:[".php",".phtml",".php3",".php4",".php5"],globs:[]},perl:{extensions:[".pl",".pm",".pod",".t"],globs:[]},lua:{extensions:[".lua"],globs:[]},sh:{extensions:[".sh",".bash",".zsh",".fish"],globs:[".bashrc",".zshrc",".profile"]},bat:{extensions:[".bat",".cmd"],globs:[]},ps:{extensions:[".ps1",".psm1",".psd1"],globs:[]},yaml:{extensions:[".yaml",".yml"],globs:[]},toml:{extensions:[".toml"],globs:["Cargo.toml","pyproject.toml"]},ini:{extensions:[".ini",".cfg",".conf"],globs:[]},csv:{extensions:[".csv",".tsv"],globs:[]},md:{extensions:[".md",".mdx",".markdown",".mdown",".mkd"],globs:[]},markdown:{extensions:[".md",".mdx",".markdown",".mdown",".mkd"],globs:[]},rst:{extensions:[".rst"],globs:[]},txt:{extensions:[".txt",".text"],globs:[]},tex:{extensions:[".tex",".ltx",".sty",".cls"],globs:[]},sql:{extensions:[".sql"],globs:[]},graphql:{extensions:[".graphql",".gql"],globs:[]},proto:{extensions:[".proto"],globs:[]},make:{extensions:[".mk",".mak"],globs:["Makefile","GNUmakefile","makefile"]},docker:{extensions:[],globs:["Dockerfile","Dockerfile.*","*.dockerfile"]},tf:{extensions:[".tf",".tfvars"],globs:[]}}),j=class{types;constructor(){this.types=new Map(Object.entries(X).map(([t,s])=>[t,{extensions:[...s.extensions],globs:[...s.globs]}]))}addType(t){let s=t.indexOf(":");if(s===-1)return;let n=t.slice(0,s),r=t.slice(s+1);if(r.startsWith("include:")){let i=r.slice(8),l=this.types.get(i);if(l){let o=this.types.get(n)||{extensions:[],globs:[]};o.extensions.push(...l.extensions),o.globs.push(...l.globs),this.types.set(n,o)}}else{let i=this.types.get(n)||{extensions:[],globs:[]};if(r.startsWith("*.")&&!r.slice(2).includes("*")){let l=r.slice(1);i.extensions.includes(l)||i.extensions.push(l)}else i.globs.includes(r)||i.globs.push(r);this.types.set(n,i)}}clearType(t){let s=this.types.get(t);s&&(s.extensions=[],s.globs=[])}getType(t){return this.types.get(t)}getAllTypes(){return this.types}matchesType(t,s){let n=t.toLowerCase();for(let r of s){if(r==="all"){if(this.matchesAnyType(t))return!0;continue}let i=this.types.get(r);if(i){for(let l of i.extensions)if(n.endsWith(l))return!0;for(let l of i.globs)if(l.includes("*")){let o=l.replace(/\./g,"\\.").replace(/\*/g,".*");if(W(`^${o}$`,"i").test(t))return!0}else if(n===l.toLowerCase())return!0}}return!1}matchesAnyType(t){let s=t.toLowerCase();for(let n of this.types.values()){for(let r of n.extensions)if(s.endsWith(r))return!0;for(let r of n.globs)if(r.includes("*")){let i=r.replace(/\./g,"\\.").replace(/\*/g,".*");if(W(`^${i}$`,"i").test(t))return!0}else if(s===r.toLowerCase())return!0}return!1}};function Q(){let e=[];for(let[t,s]of Object.entries(X).sort()){let n=[];for(let r of s.extensions)n.push(`*${r}`);for(let r of s.globs)n.push(r);e.push(`${t}: ${n.join(", ")}`)}return`${e.join(`
4
4
  `)}
5
5
  `}function ee(){return{ignoreCase:!1,caseSensitive:!1,smartCase:!0,fixedStrings:!1,wordRegexp:!1,lineRegexp:!1,invertMatch:!1,multiline:!1,multilineDotall:!1,patterns:[],patternFiles:[],count:!1,countMatches:!1,files:!1,filesWithMatches:!1,filesWithoutMatch:!1,stats:!1,onlyMatching:!1,maxCount:0,lineNumber:!0,noFilename:!1,withFilename:!1,nullSeparator:!1,byteOffset:!1,column:!1,vimgrep:!1,replace:null,afterContext:0,beforeContext:0,contextSeparator:"--",quiet:!1,heading:!1,passthru:!1,includeZero:!1,sort:"path",json:!1,globs:[],iglobs:[],globCaseInsensitive:!1,types:[],typesNot:[],typeAdd:[],typeClear:[],hidden:!1,noIgnore:!1,noIgnoreDot:!1,noIgnoreVcs:!1,ignoreFiles:[],maxDepth:256,maxFilesize:512*1024*1024,followSymlinks:!1,searchZip:!1,searchBinary:!1,preprocessor:null,preprocessorGlobs:[]}}function ue(e){let t=e.match(/^(\d+)([KMG])?$/i);if(!t)return 0;let s=parseInt(t[1],10);switch((t[2]||"").toUpperCase()){case"K":return s*1024;case"M":return s*1024*1024;case"G":return s*1024*1024*1024;default:return s}}function fe(e){return/^\d+[KMG]?$/i.test(e)?null:{stdout:"",stderr:`rg: invalid --max-filesize value: ${e}
6
6
  `,exitCode:1}}function he(e,t){return!/^\d+$/.test(t)||!Number.isSafeInteger(Number(t))?{stdout:"",stderr:`rg: invalid --${e} value: ${t}
7
7
  `,exitCode:1}:null}function te(e){return null}var se=[{short:"g",long:"glob",target:"globs",multi:!0},{long:"iglob",target:"iglobs",multi:!0},{short:"t",long:"type",target:"types",multi:!0,validate:te},{short:"T",long:"type-not",target:"typesNot",multi:!0,validate:te},{long:"type-add",target:"typeAdd",multi:!0},{long:"type-clear",target:"typeClear",multi:!0},{short:"m",long:"max-count",target:"maxCount",parse:parseInt},{short:"e",long:"regexp",target:"patterns",multi:!0},{short:"f",long:"file",target:"patternFiles",multi:!0},{short:"r",long:"replace",target:"replace"},{short:"d",long:"max-depth",target:"maxDepth",parse:e=>Number(e),validate:e=>he("max-depth",e)},{long:"max-filesize",target:"maxFilesize",parse:ue,validate:fe},{long:"context-separator",target:"contextSeparator"},{short:"j",long:"threads",ignored:!0},{long:"ignore-file",target:"ignoreFiles",multi:!0},{long:"pre",target:"preprocessor"},{long:"pre-glob",target:"preprocessorGlobs",multi:!0}],ge=new Map([["i",e=>{e.ignoreCase=!0,e.caseSensitive=!1,e.smartCase=!1}],["--ignore-case",e=>{e.ignoreCase=!0,e.caseSensitive=!1,e.smartCase=!1}],["s",e=>{e.caseSensitive=!0,e.ignoreCase=!1,e.smartCase=!1}],["--case-sensitive",e=>{e.caseSensitive=!0,e.ignoreCase=!1,e.smartCase=!1}],["S",e=>{e.smartCase=!0,e.ignoreCase=!1,e.caseSensitive=!1}],["--smart-case",e=>{e.smartCase=!0,e.ignoreCase=!1,e.caseSensitive=!1}],["F",e=>{e.fixedStrings=!0}],["--fixed-strings",e=>{e.fixedStrings=!0}],["w",e=>{e.wordRegexp=!0}],["--word-regexp",e=>{e.wordRegexp=!0}],["x",e=>{e.lineRegexp=!0}],["--line-regexp",e=>{e.lineRegexp=!0}],["v",e=>{e.invertMatch=!0}],["--invert-match",e=>{e.invertMatch=!0}],["U",e=>{e.multiline=!0}],["--multiline",e=>{e.multiline=!0}],["--multiline-dotall",e=>{e.multilineDotall=!0,e.multiline=!0}],["c",e=>{e.count=!0}],["--count",e=>{e.count=!0}],["--count-matches",e=>{e.countMatches=!0}],["l",e=>{e.filesWithMatches=!0}],["--files",e=>{e.files=!0}],["--files-with-matches",e=>{e.filesWithMatches=!0}],["--files-without-match",e=>{e.filesWithoutMatch=!0}],["--stats",e=>{e.stats=!0}],["o",e=>{e.onlyMatching=!0}],["--only-matching",e=>{e.onlyMatching=!0}],["q",e=>{e.quiet=!0}],["--quiet",e=>{e.quiet=!0}],["N",e=>{e.lineNumber=!1}],["--no-line-number",e=>{e.lineNumber=!1}],["H",e=>{e.withFilename=!0}],["--with-filename",e=>{e.withFilename=!0}],["I",e=>{e.noFilename=!0}],["--no-filename",e=>{e.noFilename=!0}],["0",e=>{e.nullSeparator=!0}],["--null",e=>{e.nullSeparator=!0}],["b",e=>{e.byteOffset=!0}],["--byte-offset",e=>{e.byteOffset=!0}],["--column",e=>{e.column=!0,e.lineNumber=!0}],["--no-column",e=>{e.column=!1}],["--vimgrep",e=>{e.vimgrep=!0,e.column=!0,e.lineNumber=!0}],["--json",e=>{e.json=!0}],["--hidden",e=>{e.hidden=!0}],["--no-ignore",e=>{e.noIgnore=!0}],["--no-ignore-dot",e=>{e.noIgnoreDot=!0}],["--no-ignore-vcs",e=>{e.noIgnoreVcs=!0}],["L",e=>{e.followSymlinks=!0}],["--follow",e=>{e.followSymlinks=!0}],["z",e=>{e.searchZip=!0}],["--search-zip",e=>{e.searchZip=!0}],["a",e=>{e.searchBinary=!0}],["--text",e=>{e.searchBinary=!0}],["--heading",e=>{e.heading=!0}],["--passthru",e=>{e.passthru=!0}],["--include-zero",e=>{e.includeZero=!0}],["--glob-case-insensitive",e=>{e.globCaseInsensitive=!0}]]),me=new Set(["n","--line-number"]);function pe(e){e.hidden?e.searchBinary=!0:e.noIgnore?e.hidden=!0:e.noIgnore=!0}function de(e,t,s){let n=e[t];for(let r of se){if(n.startsWith(`--${r.long}=`)){let i=n.slice(`--${r.long}=`.length),l=z(s,r,i);return l?{newIndex:t,error:l}:{newIndex:t}}if(r.short&&n.startsWith(`-${r.short}`)&&n.length>2){let i=n.slice(2),l=z(s,r,i);return l?{newIndex:t,error:l}:{newIndex:t}}if(r.short&&n===`-${r.short}`||n===`--${r.long}`){if(t+1>=e.length)return null;let i=e[t+1],l=z(s,r,i);return l?{newIndex:t+1,error:l}:{newIndex:t+1}}}return null}function ye(e){return se.find(t=>t.short===e)}function z(e,t,s){if(t.validate){let r=t.validate(s);if(r)return r}if(t.ignored||!t.target)return;let n=t.parse?t.parse(s):s;t.multi?e[t.target].push(n):e[t.target]=n}function xe(e,t){let s=e[t];if(s==="--sort"&&t+1<e.length){let n=e[t+1];if(n==="path"||n==="none")return{value:n,newIndex:t+1}}if(s.startsWith("--sort=")){let n=s.slice(7);if(n==="path"||n==="none")return{value:n,newIndex:t}}return null}function be(e,t){let s=e[t],n=s.match(/^-([ABC])(\d+)$/);return n?{flag:n[1],value:parseInt(n[2],10),newIndex:t}:(s==="-A"||s==="-B"||s==="-C")&&t+1<e.length?{flag:s[1],value:parseInt(e[t+1],10),newIndex:t+1}:null}function we(e){let t=e.match(/^-m(\d+)$/);return t?parseInt(t[1],10):null}function ne(e){let t=ee(),s=null,n=[],r=-1,i=-1,l=-1,o=!1;for(let a=0;a<e.length;a++){let c=e[a];if(c.startsWith("-")&&c!=="-"){let f=be(e,a);if(f){let{flag:u,value:w,newIndex:v}=f;u==="A"?r=Math.max(r,w):u==="B"?i=Math.max(i,w):l=w,a=v;continue}let h=we(c);if(h!==null){t.maxCount=h;continue}let m=de(e,a,t);if(m){if(m.error)return{success:!1,error:m.error};a=m.newIndex;continue}let y=xe(e,a);if(y){t.sort=y.value,a=y.newIndex;continue}let S=c.startsWith("--")?[c]:c.slice(1).split(""),b=!1;for(let u of S){if(me.has(u)){t.lineNumber=!0,o=!0;continue}if(u==="u"||u==="--unrestricted"){pe(t);continue}if(u==="P"||u==="--pcre2")return{success:!1,error:{stdout:"",stderr:`rg: PCRE2 is not supported. Use standard regex syntax instead.
8
- `,exitCode:1}};if(u.length===1){let v=ye(u);if(v){if(a+1>=e.length)return{success:!1,error:O("rg",`-${u}`)};let g=z(t,v,e[a+1]);if(g)return{success:!1,error:g};a++,b=!0;continue}}let w=ge.get(u);if(w){w(t);continue}if(u.startsWith("--"))return{success:!1,error:O("rg",u)};if(u.length===1)return{success:!1,error:O("rg",`-${u}`)}}}else s===null&&t.patterns.length===0&&t.patternFiles.length===0?s=c:n.push(c)}return(r>=0||l>=0)&&(t.afterContext=Math.max(r>=0?r:0,l>=0?l:0)),(i>=0||l>=0)&&(t.beforeContext=Math.max(i>=0?i:0,l>=0?l:0)),s!==null&&t.patterns.push(s),(t.column||t.vimgrep)&&(o=!0),{success:!0,options:t,paths:n,explicitLineNumbers:o}}import{gunzipSync as ve}from"node:zlib";var j=class{patterns=[];basePath;constructor(t="/"){this.basePath=t}parse(t){let s=t.split(`
9
- `);for(let n of s){let r=n.replace(/\s+$/,"");if(!r||r.startsWith("#"))continue;let i=!1;r.startsWith("!")&&(i=!0,r=r.slice(1));let l=!1;r.endsWith("/")&&(l=!0,r=r.slice(0,-1));let o=!1;r.startsWith("/")?(o=!0,r=r.slice(1)):r.includes("/")&&!r.startsWith("**/")&&(o=!0);let a=this.patternToRegex(r,o);this.patterns.push({pattern:n,regex:a,negated:i,directoryOnly:l,rooted:o})}}patternToRegex(t,s){let n="";s?n="^":n="(?:^|/)";let r=0;for(;r<t.length;){let i=t[r];if(i==="*")t[r+1]==="*"?t[r+2]==="/"?(n+="(?:.*/)?",r+=3):(r+2>=t.length,n+=".*",r+=2):(n+="[^/]*",r++);else if(i==="?")n+="[^/]",r++;else if(i==="["){let l=r+1;for(l<t.length&&t[l]==="!"&&l++,l<t.length&&t[l]==="]"&&l++;l<t.length&&t[l]!=="]";)l++;if(l<t.length){let o=t.slice(r,l+1);o.startsWith("[!")&&(o=`[^${o.slice(2)}`),n+=o,r=l+1}else n+="\\[",r++}else i==="/"?(n+="/",r++):(n+=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r++)}return n+="(?:/.*)?$",W(n)}matches(t,s){let n=t.replace(/^\.\//,"");n=n.replace(/^\//,"");let r=!1;for(let i of this.patterns)i.directoryOnly&&!s||i.regex.test(n)&&(r=!i.negated);return r}isWhitelisted(t,s){let n=t.replace(/^\.\//,"");n=n.replace(/^\//,"");for(let r of this.patterns)if(!(r.directoryOnly&&!s)&&r.negated&&r.regex.test(n))return!0;return!1}getBasePath(){return this.basePath}},E=class{parsers=[];fs;skipDotIgnore;skipVcsIgnore;loadedDirs=new Set;constructor(t,s,n=!1,r=!1){this.fs=t,this.skipDotIgnore=n,this.skipVcsIgnore=r}async load(t){let s=[],n=t;for(;;){s.unshift(n);let i=this.fs.resolvePath(n,"..");if(i===n)break;n=i}let r=[];this.skipVcsIgnore||r.push(".gitignore"),this.skipDotIgnore||r.push(".rgignore",".ignore");for(let i of s){this.loadedDirs.add(i);for(let l of r){let o=this.fs.resolvePath(i,l);try{let a=await this.fs.readFile(o),c=new j(i);c.parse(a),this.parsers.push(c)}catch{}}}}async loadForDirectory(t){if(this.loadedDirs.has(t))return;this.loadedDirs.add(t);let s=[];this.skipVcsIgnore||s.push(".gitignore"),this.skipDotIgnore||s.push(".rgignore",".ignore");for(let n of s){let r=this.fs.resolvePath(t,n);try{let i=await this.fs.readFile(r),l=new j(t);l.parse(i),this.parsers.push(l)}catch{}}}addPatternsFromContent(t,s){let n=new j(s);n.parse(t),this.parsers.push(n)}matches(t,s){for(let n of this.parsers){let r=n.getBasePath();if(!t.startsWith(r))continue;let i=t.slice(r.length).replace(/^\//,"");if(n.matches(i,s))return!0}return!1}isWhitelisted(t,s){for(let n of this.parsers){let r=n.getBasePath();if(!t.startsWith(r))continue;let i=t.slice(r.length).replace(/^\//,"");if(n.isWhitelisted(i,s))return!0}return!1}static isCommonIgnored(t){return new Set(["node_modules",".git",".svn",".hg","__pycache__",".pytest_cache",".mypy_cache","venv",".venv",".next",".nuxt",".cargo"]).has(t)}};async function R(e,t,s=!1,n=!1,r=[]){let i=new E(e,t,s,n);await i.load(t);for(let l of r)try{let o=e.resolvePath(t,l),a=await e.readFile(o);i.addPatternsFromContent(a,t)}catch{}return i}function Se(e){return e.length>=2&&e[0]===31&&e[1]===139}function Ce(e){let t=!1;for(let s=0;s<e.length;s++){let n=e[s];n==="["&&!t?t=!0:n==="]"&&t&&(t=!1)}return t?`rg: glob '${e}' has an unclosed character class`:null}function re(e,t){if(!Number.isSafeInteger(t)||t<0||t>e.limits.maxStringLength||t>Math.floor(e.limits.maxLiveBytes/3))throw new M(t>e.limits.maxStringLength?`rg: pattern file exceeds string limit (${e.limits.maxStringLength} bytes)`:`rg: live byte limit exceeded (${e.limits.maxLiveBytes} bytes)`,"string_length");return e.executionScope?.reserveBytes("rg pattern files",t*3,"rg")??{release:()=>{}}}function Ie(e,t,s){let n=0;for(let r=0;r<=t.length;r++)if(!(r<t.length&&t.charCodeAt(r)!==10)){if(r>n){if(e.length>=s.limits.maxArrayElements)throw new M(`rg: pattern limit exceeded (${s.limits.maxArrayElements})`,"iterations");s.executionScope?.consumeWork(1,"rg pattern insertion"),e.push(t.slice(n,r))}n=r+1}}function ie(e,t,s){if(t>e.limits.maxInputBytes-s)throw new M(`rg: aggregate input size limit exceeded (${e.limits.maxInputBytes} bytes)`,"string_length");return e.executionScope?.consumeInput(t,"rg pattern files"),s+t}async function le(e){let{ctx:t,options:s,paths:n,explicitLineNumbers:r}=e;for(let g of s.globs){let d=g.startsWith("!")?g.slice(1):g,x=Ce(d);if(x)return{stdout:"",stderr:`${x}
8
+ `,exitCode:1}};if(u.length===1){let v=ye(u);if(v){if(a+1>=e.length)return{success:!1,error:E("rg",`-${u}`)};let g=z(t,v,e[a+1]);if(g)return{success:!1,error:g};a++,b=!0;continue}}let w=ge.get(u);if(w){w(t);continue}if(u.startsWith("--"))return{success:!1,error:E("rg",u)};if(u.length===1)return{success:!1,error:E("rg",`-${u}`)}}}else s===null&&t.patterns.length===0&&t.patternFiles.length===0?s=c:n.push(c)}return(r>=0||l>=0)&&(t.afterContext=Math.max(r>=0?r:0,l>=0?l:0)),(i>=0||l>=0)&&(t.beforeContext=Math.max(i>=0?i:0,l>=0?l:0)),s!==null&&t.patterns.push(s),(t.column||t.vimgrep)&&(o=!0),{success:!0,options:t,paths:n,explicitLineNumbers:o}}import{gunzipSync as ve}from"node:zlib";var A=class{patterns=[];basePath;constructor(t="/"){this.basePath=t}parse(t){let s=t.split(`
9
+ `);for(let n of s){let r=n.replace(/\s+$/,"");if(!r||r.startsWith("#"))continue;let i=!1;r.startsWith("!")&&(i=!0,r=r.slice(1));let l=!1;r.endsWith("/")&&(l=!0,r=r.slice(0,-1));let o=!1;r.startsWith("/")?(o=!0,r=r.slice(1)):r.includes("/")&&!r.startsWith("**/")&&(o=!0);let a=this.patternToRegex(r,o);this.patterns.push({pattern:n,regex:a,negated:i,directoryOnly:l,rooted:o})}}patternToRegex(t,s){let n="";s?n="^":n="(?:^|/)";let r=0;for(;r<t.length;){let i=t[r];if(i==="*")t[r+1]==="*"?t[r+2]==="/"?(n+="(?:.*/)?",r+=3):(r+2>=t.length,n+=".*",r+=2):(n+="[^/]*",r++);else if(i==="?")n+="[^/]",r++;else if(i==="["){let l=r+1;for(l<t.length&&t[l]==="!"&&l++,l<t.length&&t[l]==="]"&&l++;l<t.length&&t[l]!=="]";)l++;if(l<t.length){let o=t.slice(r,l+1);o.startsWith("[!")&&(o=`[^${o.slice(2)}`),n+=o,r=l+1}else n+="\\[",r++}else i==="/"?(n+="/",r++):(n+=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r++)}return n+="(?:/.*)?$",W(n)}matches(t,s){let n=t.replace(/^\.\//,"");n=n.replace(/^\//,"");let r=!1;for(let i of this.patterns)i.directoryOnly&&!s||i.regex.test(n)&&(r=!i.negated);return r}isWhitelisted(t,s){let n=t.replace(/^\.\//,"");n=n.replace(/^\//,"");for(let r of this.patterns)if(!(r.directoryOnly&&!s)&&r.negated&&r.regex.test(n))return!0;return!1}getBasePath(){return this.basePath}},O=class{parsers=[];fs;skipDotIgnore;skipVcsIgnore;loadedDirs=new Set;constructor(t,s,n=!1,r=!1){this.fs=t,this.skipDotIgnore=n,this.skipVcsIgnore=r}async load(t){let s=[],n=t;for(;;){s.unshift(n);let i=this.fs.resolvePath(n,"..");if(i===n)break;n=i}let r=[];this.skipVcsIgnore||r.push(".gitignore"),this.skipDotIgnore||r.push(".rgignore",".ignore");for(let i of s){this.loadedDirs.add(i);for(let l of r){let o=this.fs.resolvePath(i,l);try{let a=await this.fs.readFile(o),c=new A(i);c.parse(a),this.parsers.push(c)}catch{}}}}async loadForDirectory(t){if(this.loadedDirs.has(t))return;this.loadedDirs.add(t);let s=[];this.skipVcsIgnore||s.push(".gitignore"),this.skipDotIgnore||s.push(".rgignore",".ignore");for(let n of s){let r=this.fs.resolvePath(t,n);try{let i=await this.fs.readFile(r),l=new A(t);l.parse(i),this.parsers.push(l)}catch{}}}addPatternsFromContent(t,s){let n=new A(s);n.parse(t),this.parsers.push(n)}matches(t,s){for(let n of this.parsers){let r=n.getBasePath();if(!t.startsWith(r))continue;let i=t.slice(r.length).replace(/^\//,"");if(n.matches(i,s))return!0}return!1}isWhitelisted(t,s){for(let n of this.parsers){let r=n.getBasePath();if(!t.startsWith(r))continue;let i=t.slice(r.length).replace(/^\//,"");if(n.isWhitelisted(i,s))return!0}return!1}static isCommonIgnored(t){return new Set(["node_modules",".git",".svn",".hg","__pycache__",".pytest_cache",".mypy_cache","venv",".venv",".next",".nuxt",".cargo"]).has(t)}};async function R(e,t,s=!1,n=!1,r=[]){let i=new O(e,t,s,n);await i.load(t);for(let l of r)try{let o=e.resolvePath(t,l),a=await e.readFile(o);i.addPatternsFromContent(a,t)}catch{}return i}function Se(e){return e.length>=2&&e[0]===31&&e[1]===139}function Ce(e){let t=!1;for(let s=0;s<e.length;s++){let n=e[s];n==="["&&!t?t=!0:n==="]"&&t&&(t=!1)}return t?`rg: glob '${e}' has an unclosed character class`:null}function re(e,t){if(!Number.isSafeInteger(t)||t<0||t>e.limits.maxStringLength||t>Math.floor(e.limits.maxLiveBytes/3))throw new M(t>e.limits.maxStringLength?`rg: pattern file exceeds string limit (${e.limits.maxStringLength} bytes)`:`rg: live byte limit exceeded (${e.limits.maxLiveBytes} bytes)`,"string_length");return e.executionScope?.reserveBytes("rg pattern files",t*3,"rg")??{release:()=>{}}}function Ie(e,t,s){let n=0;for(let r=0;r<=t.length;r++)if(!(r<t.length&&t.charCodeAt(r)!==10)){if(r>n){if(e.length>=s.limits.maxArrayElements)throw new M(`rg: pattern limit exceeded (${s.limits.maxArrayElements})`,"iterations");s.executionScope?.consumeWork(1,"rg pattern insertion"),e.push(t.slice(n,r))}n=r+1}}function ie(e,t,s){if(t>e.limits.maxInputBytes-s)throw new M(`rg: aggregate input size limit exceeded (${e.limits.maxInputBytes} bytes)`,"string_length");return e.executionScope?.consumeInput(t,"rg pattern files"),s+t}async function le(e){let{ctx:t,options:s,paths:n,explicitLineNumbers:r}=e;for(let g of s.globs){let d=g.startsWith("!")?g.slice(1):g,x=Ce(d);if(x)return{stdout:"",stderr:`${x}
10
10
  `,exitCode:1}}if(s.files){let g=[...s.patterns,...n];return Me(t,g,s)}if(s.patterns.length>t.limits.maxArrayElements)throw new M(`rg: pattern limit exceeded (${t.limits.maxArrayElements})`,"iterations");let i=s.patterns.slice(),l=[],o=0,a,c;try{for(let d of s.patternFiles)try{let x,p;if(d==="-")x=t.stdin,p=t.stdin.length,o=ie(t,p,o);else{let $=t.fs.resolvePath(t.cwd,d);p=(await t.fs.stat($)).size,o=ie(t,p,o);let I=re(t,p);l.push(I),x=await _(t.fs,$);let B=x.length;if(B>p)throw new M("rg: pattern file grew while being read","string_length");p=B}d==="-"&&l.push(re(t,p));let C=T(x,t.limits.maxStringLength);t.executionScope?.consumeWork(C.length,"rg pattern file parsing"),Ie(i,C,t)}catch(x){return N(x),{stdout:"",stderr:`rg: ${d}: No such file or directory
11
11
  `,exitCode:2}}if(i.length===0)return s.patternFiles.length>0?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`rg: no pattern given
12
12
  `,exitCode:2};let g=Fe(s,i);try{let d=$e(i,s,g);a=d.regex,c=d.kResetGroup}catch{return{stdout:"",stderr:`rg: invalid regex: ${i.join(", ")}
13
13
  `,exitCode:2}}}finally{for(let g of l)g.release()}let f=s.patternFiles.includes("-"),h=T(t.stdin);if(n.length===0&&h.length>0&&!f){let d=P(h,a,{invertMatch:s.invertMatch,showLineNumbers:s.lineNumber,countOnly:s.count,countMatches:s.countMatches,filename:"",onlyMatching:s.onlyMatching,beforeContext:s.beforeContext,afterContext:s.afterContext,maxCount:s.maxCount,contextSeparator:s.contextSeparator,showColumn:s.column,vimgrep:s.vimgrep,showByteOffset:s.byteOffset,replace:s.replace!==null?D(s.replace):null,passthru:s.passthru,multiline:s.multiline,kResetGroup:c,maxWork:t.limits.maxLoopIterations,maxMatches:t.limits.maxArrayElements,signal:t.signal});return s.quiet?{stdout:"",stderr:"",exitCode:d.matched?0:1}:s.filesWithMatches?{stdout:d.matched?`(standard input)
14
14
  `:"",stderr:"",exitCode:d.matched?0:1}:s.filesWithoutMatch?{stdout:d.matched?"":`(standard input)
15
- `,stderr:"",exitCode:d.matched?1:0}:{stdout:d.output,stderr:"",exitCode:d.matched?0:1}}let m=n.length===0?["."]:n,y=null;s.noIgnore||(y=await R(t.fs,t.cwd,s.noIgnoreDot,s.noIgnoreVcs,s.ignoreFiles));let S=new A;for(let g of s.typeClear)S.clearType(g);for(let g of s.typeAdd)S.addType(g);let{files:b,singleExplicitFile:u}=await oe(t,m,s,y,S);if(b.length===0)return{stdout:"",stderr:"",exitCode:1};let w=!s.noFilename&&(s.withFilename||!u||b.length>1),v=s.lineNumber;return r||(u&&b.length===1&&(v=!1),s.onlyMatching&&(v=!1)),We(t,b,a,s,w,v,c)}function Fe(e,t){return e.caseSensitive?!1:e.ignoreCase?!0:e.smartCase?!t.some(s=>/[A-Z]/.test(s)):!1}function $e(e,t,s){let n;return e.length===1?n=e[0]:n=e.map(r=>t.fixedStrings?r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):`(?:${r})`).join("|"),J(n,{mode:t.fixedStrings&&e.length===1?"fixed":"perl",ignoreCase:s,wholeWord:t.wordRegexp,lineRegexp:t.lineRegexp,multiline:t.multiline,multilineDotall:t.multilineDotall})}async function oe(e,t,s,n,r){let i=[],l=new Z({limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:"rg"}),o=0,a=0;for(let f of t){l.checkpoint();let h=e.fs.resolvePath(e.cwd,f);try{let m=await e.fs.stat(h);if(m.isFile){if(o++,s.maxFilesize>0&&m.size>s.maxFilesize)continue;if(ce(f,s,n,h,r)){if(i.length>=e.limits.maxArrayElements)throw new M(`rg: file collection limit exceeded (${e.limits.maxArrayElements})`,"array_elements");i.push(f)}}else m.isDirectory&&(a++,await ae(e,f,h,0,s,n,r,i,l,new Set))}catch(m){N(m)}}return{files:s.sort==="path"?i.sort():i,singleExplicitFile:o===1&&a===0}}async function ae(e,t,s,n,r,i,l,o,a,c){if(n>=r.maxDepth)return;a.visit(n);let f;if(r.followSymlinks)try{let h=await e.fs.stat(s);if(f=h.identity!==void 0?`identity:${h.identity}`:h.dev!==void 0&&h.ino!==void 0?`inode:${String(h.dev)}:${String(h.ino)}`:`path:${await e.fs.realpath(s)}`,c.has(f))return;c.add(f)}catch(h){N(h);return}i&&await i.loadForDirectory(s);try{let h=e.fs.readdirWithFileTypes?await e.fs.readdirWithFileTypes(s):(await e.fs.readdir(s)).map(m=>({name:m,isFile:void 0}));for(let m of h){a.checkpoint();let y=m.name;if(!r.noIgnore&&E.isCommonIgnored(y))continue;let S=y.startsWith("."),b=t==="."?y:t==="./"?`./${y}`:t.endsWith("/")?`${t}${y}`:`${t}/${y}`,u=e.fs.resolvePath(s,y),w,v,g=!1;if(m.isFile!==void 0&&"isDirectory"in m){let p=m;if(g=p.isSymbolicLink===!0,g&&!r.followSymlinks)continue;if(g&&r.followSymlinks)try{let C=await e.fs.stat(u);w=C.isFile,v=C.isDirectory}catch{continue}else w=p.isFile,v=p.isDirectory}else try{let p=e.fs.lstat?await e.fs.lstat(u):await e.fs.stat(u);if(g=p.isSymbolicLink===!0,g&&!r.followSymlinks)continue;let C=g&&r.followSymlinks?await e.fs.stat(u):p;w=C.isFile,v=C.isDirectory}catch{continue}if(!i?.matches(u,v)&&!(S&&!r.hidden&&!i?.isWhitelisted(u,v))){if(v)await ae(e,b,u,n+1,r,i,l,o,a,c);else if(w){if(a.visit(n+1),r.maxFilesize>0)try{if((await e.fs.stat(u)).size>r.maxFilesize)continue}catch{continue}if(ce(b,r,i,u,l)){if(o.length>=e.limits.maxArrayElements)throw new M(`rg: file collection limit exceeded (${e.limits.maxArrayElements})`,"array_elements");o.push(b)}}}}}catch(h){N(h)}finally{f!==void 0&&c.delete(f)}}function ce(e,t,s,n,r){let i=e.split("/").pop()||e;if(s?.matches(n,!1)||t.types.length>0&&!r.matchesType(i,t.types)||t.typesNot.length>0&&r.matchesType(i,t.typesNot))return!1;if(t.globs.length>0){let l=t.globCaseInsensitive,o=t.globs.filter(c=>!c.startsWith("!")),a=t.globs.filter(c=>c.startsWith("!")).map(c=>c.slice(1));if(o.length>0){let c=!1;for(let f of o)if(F(i,f,l)||F(e,f,l)){c=!0;break}if(!c)return!1}for(let c of a)if(c.startsWith("/")){let f=c.slice(1);if(F(e,f,l))return!1}else if(F(i,c,l)||F(e,c,l))return!1}if(t.iglobs.length>0){let l=t.iglobs.filter(a=>!a.startsWith("!")),o=t.iglobs.filter(a=>a.startsWith("!")).map(a=>a.slice(1));if(l.length>0){let a=!1;for(let c of l)if(F(i,c,!0)||F(e,c,!0)){a=!0;break}if(!a)return!1}for(let a of o)if(a.startsWith("/")){let c=a.slice(1);if(F(e,c,!0))return!1}else if(F(i,a,!0)||F(e,a,!0))return!1}return!0}function F(e,t,s=!1){let n="^";for(let r=0;r<t.length;r++){let i=t[r];if(i==="*")t[r+1]==="*"?(n+=".*",r++):n+="[^/]*";else if(i==="?")n+="[^/]";else if(i==="["){let l=r+1;for(l<t.length&&t[l]==="!"&&l++,l<t.length&&t[l]==="]"&&l++;l<t.length&&t[l]!=="]";)l++;if(l<t.length){let o=t.slice(r,l+1);o.startsWith("[!")&&(o=`[^${o.slice(2)}`),n+=o,r=l}else n+="\\["}else n+=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}return n+="$",W(n,s?"i":"").test(e)}async function Me(e,t,s){let n=null;s.noIgnore||(n=await R(e.fs,e.cwd,s.noIgnoreDot,s.noIgnoreVcs,s.ignoreFiles));let r=new A;for(let f of s.typeClear)r.clearType(f);for(let f of s.typeAdd)r.addType(f);let i=t.length===0?["."]:t,{files:l}=await oe(e,i,s,n,r);if(l.length===0)return{stdout:"",stderr:"",exitCode:1};if(s.quiet)return{stdout:"",stderr:"",exitCode:0};let o=s.nullSeparator?"\0":`
16
- `,a=new V(Math.min(e.limits.maxOutputSize,e.limits.maxStringLength),"rg");for(let f of l)a.append(f).append(o);return{stdout:a.build(),stderr:"",exitCode:0}}function ke(e,t){if(t.length===0)return!0;for(let s of t)if(F(e,s,!1))return!0;return!1}async function Le(e,t,s,n){let r;try{if(n.preprocessor&&e.exec){let f=s.split("/").pop()||s;if(ke(f,n.preprocessorGlobs)){let h=await e.exec(K([n.preprocessor]),{cwd:e.cwd,signal:e.signal,args:[t]});if(h.exitCode===0&&h.stdout){r=e.executionScope?.reserveBytes("rg preprocessor text",h.stdout.length,"rg preprocessor");let m=T(h.stdout);e.executionScope?.consumeInput(G(m),"rg preprocessor");let y=m.slice(0,8192);return{content:m,isBinary:y.includes("\0"),lease:r}}}}if(n.searchZip&&s.endsWith(".gz")){let f=await e.fs.stat(t),h=e.executionScope?.reserveBytes("rg compressed input",f.size,"rg"),m=await e.fs.readFileBuffer(t);if(m.byteLength>f.size)throw h?.release(),new M("rg: file grew while being read","string_length");if(e.executionScope?.consumeInput(m.byteLength,"rg"),Se(m)){let y;try{let S=Math.min(e.limits.maxStringLength,e.limits.maxOutputSize,Math.floor((e.executionScope?.remainingLiveBytes??e.limits.maxLiveBytes)/2));y=e.executionScope?.reserveBytes("rg decompressed text",S*2,"rg");let b=ve(m,{maxOutputLength:S}),u=new TextDecoder().decode(b),w=u.slice(0,8192);return{content:u,isBinary:w.includes("\0"),lease:Ne(h,y)}}catch(S){return y?.release(),h?.release(),N(S),null}}h?.release()}let i=await e.fs.stat(t);r=e.executionScope?.reserveBytes("rg file text",i.size*2,"rg");let l=await _(e.fs,t),o=l.length;if(o>i.size)throw new M("rg: file grew while being read","string_length");e.executionScope?.consumeInput(o,"rg");let a=T(l,e.limits.maxStringLength),c=a.slice(0,8192);return{content:a,isBinary:c.includes("\0"),lease:r}}catch(i){return r?.release(),N(i),null}}function Ne(...e){let t=e.filter(s=>s!==void 0);if(t.length!==0)return{release:()=>{for(let s of t)s.release()}}}async function We(e,t,s,n,r,i,l){let o="",a=!1,c=[],f=0,h=0,m=0,y=n.searchZip?2:50;e:for(let u=0;u<t.length;u+=y){let w=t.slice(u,u+y),v=await Promise.all(w.map(async g=>{let d=e.fs.resolvePath(e.cwd,g),x=await Le(e,d,g,n);if(!x)return null;let{content:p,isBinary:C,lease:$}=x;if(m+=p.length,C&&!n.searchBinary)return $?.release(),null;let L=r&&!n.heading?g:"";try{let I=P(p,s,{invertMatch:n.invertMatch,showLineNumbers:i,countOnly:n.count,countMatches:n.countMatches,filename:L,onlyMatching:n.onlyMatching,beforeContext:n.beforeContext,afterContext:n.afterContext,maxCount:n.maxCount,contextSeparator:n.contextSeparator,showColumn:n.column,vimgrep:n.vimgrep,showByteOffset:n.byteOffset,replace:n.replace!==null?D(n.replace):null,passthru:n.passthru,multiline:n.multiline,kResetGroup:l,maxWork:e.limits.maxLoopIterations,maxMatches:e.limits.maxArrayElements,signal:e.signal});return n.json&&I.matched?{file:g,result:I,content:p,isBinary:!1,lease:$}:($?.release(),{file:g,result:I})}catch(I){throw $?.release(),I}}));for(let g of v){if(!g)continue;let{file:d,result:x}=g;if(x.matched){if(a=!0,h++,f+=x.matchCount,n.quiet&&!n.json)break e;if(n.json&&!n.quiet){let p=g.content||"";c.push(JSON.stringify({type:"begin",data:{path:{text:d}}}));let C=p.split(`
15
+ `,stderr:"",exitCode:d.matched?1:0}:{stdout:d.output,stderr:"",exitCode:d.matched?0:1}}let m=n.length===0?["."]:n,y=null;s.noIgnore||(y=await R(t.fs,t.cwd,s.noIgnoreDot,s.noIgnoreVcs,s.ignoreFiles));let S=new j;for(let g of s.typeClear)S.clearType(g);for(let g of s.typeAdd)S.addType(g);let{files:b,singleExplicitFile:u}=await oe(t,m,s,y,S);if(b.length===0)return{stdout:"",stderr:"",exitCode:1};let w=!s.noFilename&&(s.withFilename||!u||b.length>1),v=s.lineNumber;return r||(u&&b.length===1&&(v=!1),s.onlyMatching&&(v=!1)),We(t,b,a,s,w,v,c)}function Fe(e,t){return e.caseSensitive?!1:e.ignoreCase?!0:e.smartCase?!t.some(s=>/[A-Z]/.test(s)):!1}function $e(e,t,s){let n;return e.length===1?n=e[0]:n=e.map(r=>t.fixedStrings?r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):`(?:${r})`).join("|"),J(n,{mode:t.fixedStrings&&e.length===1?"fixed":"perl",ignoreCase:s,wholeWord:t.wordRegexp,lineRegexp:t.lineRegexp,multiline:t.multiline,multilineDotall:t.multilineDotall})}async function oe(e,t,s,n,r){let i=[],l=new Z({limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:"rg"}),o=0,a=0;for(let f of t){l.checkpoint();let h=e.fs.resolvePath(e.cwd,f);try{let m=await e.fs.stat(h);if(m.isFile){if(o++,s.maxFilesize>0&&m.size>s.maxFilesize)continue;if(ce(f,s,n,h,r)){if(i.length>=e.limits.maxArrayElements)throw new M(`rg: file collection limit exceeded (${e.limits.maxArrayElements})`,"array_elements");i.push(f)}}else m.isDirectory&&(a++,await ae(e,f,h,0,s,n,r,i,l,new Set))}catch(m){N(m)}}return{files:s.sort==="path"?i.sort():i,singleExplicitFile:o===1&&a===0}}async function ae(e,t,s,n,r,i,l,o,a,c){if(n>=r.maxDepth)return;a.visit(n);let f;if(r.followSymlinks)try{let h=await e.fs.stat(s);if(f=h.identity!==void 0?`identity:${h.identity}`:h.dev!==void 0&&h.ino!==void 0?`inode:${String(h.dev)}:${String(h.ino)}`:`path:${await e.fs.realpath(s)}`,c.has(f))return;c.add(f)}catch(h){N(h);return}i&&await i.loadForDirectory(s);try{let h=e.fs.readdirWithFileTypes?await e.fs.readdirWithFileTypes(s):(await e.fs.readdir(s)).map(m=>({name:m,isFile:void 0}));for(let m of h){a.checkpoint();let y=m.name;if(!r.noIgnore&&O.isCommonIgnored(y))continue;let S=y.startsWith("."),b=t==="."?y:t==="./"?`./${y}`:t.endsWith("/")?`${t}${y}`:`${t}/${y}`,u=e.fs.resolvePath(s,y),w,v,g=!1;if(m.isFile!==void 0&&"isDirectory"in m){let p=m;if(g=p.isSymbolicLink===!0,g&&!r.followSymlinks)continue;if(g&&r.followSymlinks)try{let C=await e.fs.stat(u);w=C.isFile,v=C.isDirectory}catch{continue}else w=p.isFile,v=p.isDirectory}else try{let p=e.fs.lstat?await e.fs.lstat(u):await e.fs.stat(u);if(g=p.isSymbolicLink===!0,g&&!r.followSymlinks)continue;let C=g&&r.followSymlinks?await e.fs.stat(u):p;w=C.isFile,v=C.isDirectory}catch{continue}if(!i?.matches(u,v)&&!(S&&!r.hidden&&!i?.isWhitelisted(u,v))){if(v)await ae(e,b,u,n+1,r,i,l,o,a,c);else if(w){if(a.visit(n+1),r.maxFilesize>0)try{if((await e.fs.stat(u)).size>r.maxFilesize)continue}catch{continue}if(ce(b,r,i,u,l)){if(o.length>=e.limits.maxArrayElements)throw new M(`rg: file collection limit exceeded (${e.limits.maxArrayElements})`,"array_elements");o.push(b)}}}}}catch(h){N(h)}finally{f!==void 0&&c.delete(f)}}function ce(e,t,s,n,r){let i=e.split("/").pop()||e;if(s?.matches(n,!1)||t.types.length>0&&!r.matchesType(i,t.types)||t.typesNot.length>0&&r.matchesType(i,t.typesNot))return!1;if(t.globs.length>0){let l=t.globCaseInsensitive,o=t.globs.filter(c=>!c.startsWith("!")),a=t.globs.filter(c=>c.startsWith("!")).map(c=>c.slice(1));if(o.length>0){let c=!1;for(let f of o)if(F(i,f,l)||F(e,f,l)){c=!0;break}if(!c)return!1}for(let c of a)if(c.startsWith("/")){let f=c.slice(1);if(F(e,f,l))return!1}else if(F(i,c,l)||F(e,c,l))return!1}if(t.iglobs.length>0){let l=t.iglobs.filter(a=>!a.startsWith("!")),o=t.iglobs.filter(a=>a.startsWith("!")).map(a=>a.slice(1));if(l.length>0){let a=!1;for(let c of l)if(F(i,c,!0)||F(e,c,!0)){a=!0;break}if(!a)return!1}for(let a of o)if(a.startsWith("/")){let c=a.slice(1);if(F(e,c,!0))return!1}else if(F(i,a,!0)||F(e,a,!0))return!1}return!0}function F(e,t,s=!1){let n="^";for(let r=0;r<t.length;r++){let i=t[r];if(i==="*")t[r+1]==="*"?(n+=".*",r++):n+="[^/]*";else if(i==="?")n+="[^/]";else if(i==="["){let l=r+1;for(l<t.length&&t[l]==="!"&&l++,l<t.length&&t[l]==="]"&&l++;l<t.length&&t[l]!=="]";)l++;if(l<t.length){let o=t.slice(r,l+1);o.startsWith("[!")&&(o=`[^${o.slice(2)}`),n+=o,r=l}else n+="\\["}else n+=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}return n+="$",W(n,s?"i":"").test(e)}async function Me(e,t,s){let n=null;s.noIgnore||(n=await R(e.fs,e.cwd,s.noIgnoreDot,s.noIgnoreVcs,s.ignoreFiles));let r=new j;for(let f of s.typeClear)r.clearType(f);for(let f of s.typeAdd)r.addType(f);let i=t.length===0?["."]:t,{files:l}=await oe(e,i,s,n,r);if(l.length===0)return{stdout:"",stderr:"",exitCode:1};if(s.quiet)return{stdout:"",stderr:"",exitCode:0};let o=s.nullSeparator?"\0":`
16
+ `,a=new H(Math.min(e.limits.maxOutputSize,e.limits.maxStringLength),"rg");for(let f of l)a.append(f).append(o);return{stdout:a.build(),stderr:"",exitCode:0}}function ke(e,t){if(t.length===0)return!0;for(let s of t)if(F(e,s,!1))return!0;return!1}async function Le(e,t,s,n){let r;try{if(n.preprocessor&&e.exec){let f=s.split("/").pop()||s;if(ke(f,n.preprocessorGlobs)){let h=await e.exec(K([n.preprocessor]),{cwd:e.cwd,signal:e.signal,args:[t]});if(h.exitCode===0&&h.stdout){r=e.executionScope?.reserveBytes("rg preprocessor text",h.stdout.length,"rg preprocessor");let m=T(h.stdout);e.executionScope?.consumeInput(G(m),"rg preprocessor");let y=m.slice(0,8192);return{content:m,isBinary:y.includes("\0"),lease:r}}}}if(n.searchZip&&s.endsWith(".gz")){let f=await e.fs.stat(t),h=e.executionScope?.reserveBytes("rg compressed input",f.size,"rg"),m=await e.fs.readFileBuffer(t);if(m.byteLength>f.size)throw h?.release(),new M("rg: file grew while being read","string_length");if(e.executionScope?.consumeInput(m.byteLength,"rg"),Se(m)){let y;try{let S=Math.min(e.limits.maxStringLength,e.limits.maxOutputSize,Math.floor((e.executionScope?.remainingLiveBytes??e.limits.maxLiveBytes)/2));y=e.executionScope?.reserveBytes("rg decompressed text",S*2,"rg");let b=ve(m,{maxOutputLength:S}),u=new TextDecoder().decode(b),w=u.slice(0,8192);return{content:u,isBinary:w.includes("\0"),lease:Ne(h,y)}}catch(S){return y?.release(),h?.release(),N(S),null}}h?.release()}let i=await e.fs.stat(t);r=e.executionScope?.reserveBytes("rg file text",i.size*2,"rg");let l=await _(e.fs,t),o=l.length;if(o>i.size)throw new M("rg: file grew while being read","string_length");e.executionScope?.consumeInput(o,"rg");let a=T(l,e.limits.maxStringLength),c=a.slice(0,8192);return{content:a,isBinary:c.includes("\0"),lease:r}}catch(i){return r?.release(),N(i),null}}function Ne(...e){let t=e.filter(s=>s!==void 0);if(t.length!==0)return{release:()=>{for(let s of t)s.release()}}}async function We(e,t,s,n,r,i,l){let o="",a=!1,c=[],f=0,h=0,m=0,y=n.searchZip?2:50;e:for(let u=0;u<t.length;u+=y){let w=t.slice(u,u+y),v=await Promise.all(w.map(async g=>{let d=e.fs.resolvePath(e.cwd,g),x=await Le(e,d,g,n);if(!x)return null;let{content:p,isBinary:C,lease:$}=x;if(m+=p.length,C&&!n.searchBinary)return $?.release(),null;let L=r&&!n.heading?g:"";try{let I=P(p,s,{invertMatch:n.invertMatch,showLineNumbers:i,countOnly:n.count,countMatches:n.countMatches,filename:L,onlyMatching:n.onlyMatching,beforeContext:n.beforeContext,afterContext:n.afterContext,maxCount:n.maxCount,contextSeparator:n.contextSeparator,showColumn:n.column,vimgrep:n.vimgrep,showByteOffset:n.byteOffset,replace:n.replace!==null?D(n.replace):null,passthru:n.passthru,multiline:n.multiline,kResetGroup:l,maxWork:e.limits.maxLoopIterations,maxMatches:e.limits.maxArrayElements,signal:e.signal});return n.json&&I.matched?{file:g,result:I,content:p,isBinary:!1,lease:$}:($?.release(),{file:g,result:I})}catch(I){throw $?.release(),I}}));for(let g of v){if(!g)continue;let{file:d,result:x}=g;if(x.matched){if(a=!0,h++,f+=x.matchCount,n.quiet&&!n.json)break e;if(n.json&&!n.quiet){let p=g.content||"";c.push(JSON.stringify({type:"begin",data:{path:{text:d}}}));let C=p.split(`
17
17
  `);s.lastIndex=0;let $=0;for(let L=0;L<C.length;L++){let I=C[L];s.lastIndex=0;let B=[];for(let k=s.exec(I);k!==null;k=s.exec(I)){let U={match:{text:k[0]},start:k.index,end:k.index+k[0].length};n.replace!==null&&(U.replacement={text:n.replace}),B.push(U),k[0].length===0&&s.lastIndex++}if(B.length>0){let k={type:"match",data:{path:{text:d},lines:{text:`${I}
18
18
  `},line_number:L+1,absolute_offset:$,submatches:B}};c.push(JSON.stringify(k))}$+=I.length+1}c.push(JSON.stringify({type:"end",data:{path:{text:d},binary_offset:null,stats:{elapsed:{secs:0,nanos:0,human:"0s"},searches:1,searches_with_match:1,bytes_searched:p.length,bytes_printed:0,matched_lines:x.matchCount,matches:x.matchCount}}}))}else if(n.filesWithMatches){let p=n.nullSeparator?"\0":`
19
19
  `;o+=`${d}${p}`}else n.filesWithoutMatch||(n.heading&&!n.noFilename&&(o+=`${d}
@@ -33,4 +33,5 @@ EXAMPLES:
33
33
  rg -t js foo Search only JavaScript files
34
34
  rg -g '*.ts' foo Search files matching glob
35
35
  rg --hidden foo Include hidden files
36
- rg -l foo List files with matches only`,options:["-e, --regexp PATTERN search for PATTERN (can be used multiple times)","-f, --file FILE read patterns from FILE, one per line","-i, --ignore-case case-insensitive search","-s, --case-sensitive case-sensitive search (overrides smart-case)","-S, --smart-case smart case (default: case-insensitive unless pattern has uppercase)","-F, --fixed-strings treat pattern as literal string","-w, --word-regexp match whole words only","-x, --line-regexp match whole lines only","-v, --invert-match select non-matching lines","-r, --replace TEXT replace matches with TEXT","-c, --count print count of matching lines per file"," --count-matches print count of individual matches per file","-l, --files-with-matches print only file names with matches"," --files-without-match print file names without matches"," --files list files that would be searched","-o, --only-matching print only matching parts","-m, --max-count NUM stop after NUM matches per file","-q, --quiet suppress output, exit 0 on match"," --stats print search statistics","-n, --line-number print line numbers (default: on)","-N, --no-line-number do not print line numbers","-I, --no-filename suppress the prefixing of file names","-0, --null use NUL as filename separator","-b, --byte-offset show byte offset of each match"," --column show column number of first match"," --vimgrep show results in vimgrep format"," --json show results in JSON Lines format","-A NUM print NUM lines after each match","-B NUM print NUM lines before each match","-C NUM print NUM lines before and after each match"," --context-separator SEP separator for context groups (default: --)","-U, --multiline match patterns across lines","-z, --search-zip search in compressed files (gzip only)","-g, --glob GLOB include files matching GLOB","-t, --type TYPE only search files of TYPE (e.g., js, py, ts)","-T, --type-not TYPE exclude files of TYPE","-L, --follow follow symbolic links","-u, --unrestricted reduce filtering (-u: no ignore, -uu: +hidden, -uuu: +binary)","-a, --text search binary files as text"," --hidden search hidden files and directories"," --no-ignore don't respect .gitignore/.ignore files","-d, --max-depth NUM maximum search depth"," --sort TYPE sort files (path, none)"," --heading show file path above matches"," --passthru print all lines (non-matches use - separator)"," --include-zero include files with 0 matches in count output"," --type-list list all available file types"," --help display this help and exit"]},lt={name:"rg",async execute(e,t){if(H(e))return q(Be);if(e.includes("--type-list"))return{stdout:Q(),stderr:"",exitCode:0};let s=ne(e);return s.success?le({ctx:t,options:s.options,paths:s.paths,explicitLineNumbers:s.explicitLineNumbers}):s.error}},ot={name:"rg",flags:[{flag:"-i",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-S",type:"boolean"},{flag:"-F",type:"boolean"},{flag:"-w",type:"boolean"},{flag:"-x",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-l",type:"boolean"},{flag:"-o",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-N",type:"boolean"},{flag:"--hidden",type:"boolean"},{flag:"--no-ignore",type:"boolean"},{flag:"-m",type:"value",valueHint:"number"},{flag:"-A",type:"value",valueHint:"number"},{flag:"-B",type:"value",valueHint:"number"},{flag:"-C",type:"value",valueHint:"number"},{flag:"-g",type:"value",valueHint:"pattern"},{flag:"-t",type:"value",valueHint:"string"},{flag:"-T",type:"value",valueHint:"string"}],needsArgs:!0};export{lt as a,ot as b};
36
+ rg -l foo List files with matches only`,options:["-e, --regexp PATTERN search for PATTERN (can be used multiple times)","-f, --file FILE read patterns from FILE, one per line","-i, --ignore-case case-insensitive search","-s, --case-sensitive case-sensitive search (overrides smart-case)","-S, --smart-case smart case (default: case-insensitive unless pattern has uppercase)","-F, --fixed-strings treat pattern as literal string","-w, --word-regexp match whole words only","-x, --line-regexp match whole lines only","-v, --invert-match select non-matching lines","-r, --replace TEXT replace matches with TEXT","-c, --count print count of matching lines per file"," --count-matches print count of individual matches per file","-l, --files-with-matches print only file names with matches"," --files-without-match print file names without matches"," --files list files that would be searched","-o, --only-matching print only matching parts","-m, --max-count NUM stop after NUM matches per file","-q, --quiet suppress output, exit 0 on match"," --stats print search statistics","-n, --line-number print line numbers (default: on)","-N, --no-line-number do not print line numbers","-I, --no-filename suppress the prefixing of file names","-0, --null use NUL as filename separator","-b, --byte-offset show byte offset of each match"," --column show column number of first match"," --vimgrep show results in vimgrep format"," --json show results in JSON Lines format","-A NUM print NUM lines after each match","-B NUM print NUM lines before each match","-C NUM print NUM lines before and after each match"," --context-separator SEP separator for context groups (default: --)","-U, --multiline match patterns across lines","-z, --search-zip search in compressed files (gzip only)","-g, --glob GLOB include files matching GLOB","-t, --type TYPE only search files of TYPE (e.g., js, py, ts)","-T, --type-not TYPE exclude files of TYPE","-L, --follow follow symbolic links","-u, --unrestricted reduce filtering (-u: no ignore, -uu: +hidden, -uuu: +binary)","-a, --text search binary files as text"," --hidden search hidden files and directories"," --no-ignore don't respect .gitignore/.ignore files","-d, --max-depth NUM maximum search depth"," --sort TYPE sort files (path, none)"," --heading show file path above matches"," --passthru print all lines (non-matches use - separator)"," --include-zero include files with 0 matches in count output"," --type-list list all available file types"," --help display this help and exit"]},lt={handlesOwnVersion:!0,name:"rg",async execute(e,t){if(V(e))return q(Be);if(e.includes("--version")||e.includes("-V"))return{stdout:`rg (just-bash)
37
+ `,stderr:"",exitCode:0};if(e.includes("--type-list"))return{stdout:Q(),stderr:"",exitCode:0};let s=ne(e);return s.success?le({ctx:t,options:s.options,paths:s.paths,explicitLineNumbers:s.explicitLineNumbers}):s.error}},ot={name:"rg",flags:[{flag:"-i",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-S",type:"boolean"},{flag:"-F",type:"boolean"},{flag:"-w",type:"boolean"},{flag:"-x",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-l",type:"boolean"},{flag:"-o",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-N",type:"boolean"},{flag:"--hidden",type:"boolean"},{flag:"--no-ignore",type:"boolean"},{flag:"-m",type:"value",valueHint:"number"},{flag:"-A",type:"value",valueHint:"number"},{flag:"-B",type:"value",valueHint:"number"},{flag:"-C",type:"value",valueHint:"number"},{flag:"-g",type:"value",valueHint:"pattern"},{flag:"-t",type:"value",valueHint:"string"},{flag:"-T",type:"value",valueHint:"string"}],needsArgs:!0};export{lt as a,ot as b};
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
+ import{a as m}from"./chunk-NE4R2FVV.js";import{a as p,b as d}from"./chunk-MUFNRCMY.js";var y={name:"which",summary:"locate a command",usage:"which [-as] program ...",options:["-a List all instances of executables found","-s No output, just return 0 if found, 1 if not","--help display this help and exit"]},x={showAll:{short:"a",type:"boolean"},silent:{short:"s",type:"boolean"}},a=null;async function A(){return a||(a=(await import("./builtin-manifest-ORBIZM7I.js")).SHELL_BUILTINS),a}var L={name:"which",async execute(n,o){if(d(n))return p(y);let t=m("which",n,x);if(!t.ok)return t.error;let g=t.result.flags.showAll,i=t.result.flags.silent,r=t.result.positional;if(r.length===0)return{stdout:"",stderr:"",exitCode:1};let w=await A(),b=(o.env.get("PATH")||"/usr/bin:/bin").split(":"),l="",h="",f=!0;for(let e of r){let s=!1;for(let u of b){if(!u)continue;let c=o.fs.resolvePath(u,e);if(await o.fs.exists(c)&&(s=!0,i||(l+=`${c}
4
+ `),!g))break}!s&&w.has(e)&&(s=!0,i||(l+=`${e}: shell builtin
5
+ `)),s||(i||(h+=`which: no ${e} in this sandboxed bash environment
6
+ `),f=!1)}return{stdout:l,stderr:h,exitCode:f?0:1}}},B={name:"which",flags:[{flag:"-a",type:"boolean"},{flag:"-s",type:"boolean"}],needsArgs:!0};export{L as a,B as b};
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
+ import{b as O,c as N,d as T,e as k}from"./chunk-AIWBN36Z.js";import{f as P}from"./chunk-UBA7DOWE.js";import{l as $,m as C}from"./chunk-FUT3X2GJ.js";import{c as p}from"./chunk-OHFB3M3X.js";import{a as F}from"./chunk-NE4R2FVV.js";import{a as D}from"./chunk-I4IRHQDW.js";import{a as E,b as S}from"./chunk-MUFNRCMY.js";var H={name:"mv",summary:"move (rename) files",usage:"mv [OPTION]... SOURCE... DEST",options:["-f, --force do not prompt before overwriting","-n, --no-clobber do not overwrite an existing file","-v, --verbose explain what is being done"," --help display this help and exit"]},I={force:{short:"f",long:"force",type:"boolean"},noClobber:{short:"n",long:"no-clobber",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},j={name:"mv",async execute(v,e){if(S(v))return E(H);let i=F("mv",v,I);if(!i.ok)return i.error;let g=i.result.flags.force,u=i.result.flags.noClobber,A=i.result.flags.verbose,d=i.result.positional;if(u&&(g=!1),d.length<2)return{stdout:"",stderr:`mv: missing destination file operand
4
+ `,exitCode:1};let a=d.pop()??"",h=d,f=e.fs.resolvePath(e.cwd,a),b="",s="",l=0,y=new T({limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:"mv"}),m=!1;try{m=(await e.fs.stat(f)).isDirectory}catch{}if(h.length>1&&!m)return{stdout:"",stderr:`mv: target '${a}' is not a directory
5
+ `,exitCode:1};for(let t of h)try{let o=e.fs.resolvePath(e.cwd,t),c=await e.fs.stat(o),n=f;if(m){let r=t.split("/").pop()||t;n=f==="/"?`/${r}`:`${f}/${r}`}if(c.isDirectory){let r=await N(e.fs,o,n,y);if(P(o,n)||r==="inside"){s+=`mv: cannot move '${t}' into itself, '${n}'
6
+ `,l=1;continue}if(r==="unknown"){s+=`mv: cannot safely determine whether '${n}' is inside '${t}'
7
+ `,l=1;continue}}if(u)try{await e.fs.stat(n);continue}catch{}let w=await O(e.fs,o,n);if(w==="same")continue;if(w==="unknown"){s+=`mv: cannot safely determine whether '${t}' and '${n}' are the same file
8
+ `,l=1;continue}if(c.isDirectory&&await k({fs:e.fs,root:o,limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:"mv",symlinks:"never",budget:y},()=>{}),await e.fs.mv(o,n),A){let r=m?`${a}/${t.split("/").pop()||t}`:a;b+=`renamed '${t}' -> '${r}'
9
+ `}}catch(o){if(o instanceof $||o instanceof C)throw o;let c=D(o);p(o,"ENOENT")?s+=`mv: cannot stat '${t}': No such file or directory
10
+ `:p(o,"EROFS")?s+=`mv: cannot move '${t}' to '${a}': Read-only file system
11
+ `:s+=`mv: cannot move '${t}': ${c}
12
+ `,l=1}return{stdout:b,stderr:s,exitCode:l}}},G={name:"mv",flags:[{flag:"-f",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-v",type:"boolean"}],needsArgs:!0,minArgs:2};export{j as a,G as b};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a,b}from"./chunk-6JUPBMCR.js";import"./chunk-MBREBDZQ.js";import"./chunk-HWK7KFGB.js";import"./chunk-FUT3X2GJ.js";import"./chunk-CPKBPQ2C.js";import"./chunk-OHFB3M3X.js";import"./chunk-PBOVSFTJ.js";import"./chunk-NE4R2FVV.js";import"./chunk-I4IRHQDW.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";export{a as cpCommand,b as flagsForFuzzing};
3
+ import{a,b}from"./chunk-IRCAXXH6.js";import"./chunk-AIWBN36Z.js";import"./chunk-UBA7DOWE.js";import"./chunk-FUT3X2GJ.js";import"./chunk-CPKBPQ2C.js";import"./chunk-OHFB3M3X.js";import"./chunk-PBOVSFTJ.js";import"./chunk-NE4R2FVV.js";import"./chunk-I4IRHQDW.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";export{a as cpCommand,b as flagsForFuzzing};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a,b}from"./chunk-2NJJXU4K.js";import"./chunk-CPKBPQ2C.js";import"./chunk-NE4R2FVV.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";export{a as diffCommand,b as flagsForFuzzing};
3
+ import{a,b}from"./chunk-3ASHUC7C.js";import"./chunk-CPKBPQ2C.js";import"./chunk-NE4R2FVV.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";export{a as diffCommand,b as flagsForFuzzing};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a,b}from"./chunk-DRPHNXG7.js";import"./chunk-MBREBDZQ.js";import"./chunk-HWK7KFGB.js";import"./chunk-FUT3X2GJ.js";import"./chunk-CPKBPQ2C.js";import"./chunk-OHFB3M3X.js";import"./chunk-PBOVSFTJ.js";import"./chunk-NE4R2FVV.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";export{a as duCommand,b as flagsForFuzzing};
3
+ import{a,b}from"./chunk-7LGT4LHQ.js";import"./chunk-AIWBN36Z.js";import"./chunk-UBA7DOWE.js";import"./chunk-FUT3X2GJ.js";import"./chunk-CPKBPQ2C.js";import"./chunk-OHFB3M3X.js";import"./chunk-PBOVSFTJ.js";import"./chunk-NE4R2FVV.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";export{a as duCommand,b as flagsForFuzzing};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a,b}from"./chunk-BB5VTPMQ.js";import"./chunk-BIJXTWZ4.js";import"./chunk-IOKQFPM6.js";import"./chunk-3MRB66F4.js";import"./chunk-K27FY3ES.js";import"./chunk-YXPSX3SI.js";import"./chunk-YERKK5B3.js";import"./chunk-I57EACSL.js";import"./chunk-MBREBDZQ.js";import"./chunk-HWK7KFGB.js";import"./chunk-FUT3X2GJ.js";import"./chunk-CPKBPQ2C.js";import"./chunk-OHFB3M3X.js";import"./chunk-PBOVSFTJ.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";export{a as findCommand,b as flagsForFuzzing};
3
+ import{a,b}from"./chunk-NSI6LMDS.js";import"./chunk-BIJXTWZ4.js";import"./chunk-IOKQFPM6.js";import"./chunk-3MRB66F4.js";import"./chunk-K27FY3ES.js";import"./chunk-YXPSX3SI.js";import"./chunk-YERKK5B3.js";import"./chunk-I57EACSL.js";import"./chunk-AIWBN36Z.js";import"./chunk-UBA7DOWE.js";import"./chunk-FUT3X2GJ.js";import"./chunk-CPKBPQ2C.js";import"./chunk-OHFB3M3X.js";import"./chunk-PBOVSFTJ.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";export{a as findCommand,b as flagsForFuzzing};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{b as yr}from"./chunk-M3Z5NZXT.js";import{b as Ar}from"./chunk-PRVPFKTC.js";import{b as $r}from"./chunk-ANX7U57Q.js";import"./chunk-V4U26ZWL.js";import"./chunk-KP2UH5CJ.js";import{c as Sr}from"./chunk-MPFNZYEA.js";import"./chunk-7WBCA2BB.js";import{b as wr}from"./chunk-PQ2INDRF.js";import{b as xr}from"./chunk-DYIBFLS3.js";import{b as vr}from"./chunk-RVPTAYDS.js";import{b as kr}from"./chunk-TYBXHT6W.js";import{b as qr}from"./chunk-AJF3OBTR.js";import{b as Cr}from"./chunk-2ETT4ELS.js";import{b as br}from"./chunk-OUQKFRVR.js";import{d as Ir,e as Mr,f as jr}from"./chunk-QJWFCA7P.js";import"./chunk-QES5OSUC.js";import{b as tr}from"./chunk-QFTZKD5O.js";import{b as lr}from"./chunk-CC2AQ6B7.js";import{b as ur}from"./chunk-QMPZXXEK.js";import{b as pr}from"./chunk-CNVNOT67.js";import{b as er}from"./chunk-LXFMIXGA.js";import{b as dr}from"./chunk-WFVCEB5T.js";import{b as cr}from"./chunk-KG2KXL4Y.js";import"./chunk-2YLY6FJA.js";import{b as hr}from"./chunk-H7PD6FLC.js";import{c as or,d as ar}from"./chunk-KI54R2QB.js";import{b as sr}from"./chunk-KUMHQGUR.js";import{c as ir,d as gr}from"./chunk-MYTNZ7MA.js";import{b as mr}from"./chunk-V4S4A7M6.js";import"./chunk-ONF4KUYV.js";import{b as Fr}from"./chunk-FPWHWWXO.js";import{b as zr}from"./chunk-2NJJXU4K.js";import{b as fr}from"./chunk-LJQIAFWS.js";import{b as nr}from"./chunk-MF3GVFLC.js";import"./chunk-B2DRBHGQ.js";import{b as R}from"./chunk-YJ5OCPSK.js";import{b as U}from"./chunk-Q2GOPGDA.js";import{b as V}from"./chunk-PXP4YYZA.js";import{b as W}from"./chunk-DRPHNXG7.js";import{c as X,d as Y}from"./chunk-YUZRUF5F.js";import{c as Z,d as _}from"./chunk-DJAX3ZRG.js";import{b as N}from"./chunk-PZQVSQX6.js";import{b as rr}from"./chunk-SDGPS6XI.js";import{b as G}from"./chunk-SC5TEGMM.js";import{b as H}from"./chunk-5SKEZPTU.js";import{b as J}from"./chunk-OYXHOZZ4.js";import{b as K}from"./chunk-KMYJMEON.js";import{b as L}from"./chunk-N26Y42L6.js";import{b as O}from"./chunk-4JF56A3P.js";import{b as P}from"./chunk-AGKL4LDL.js";import{b as Q}from"./chunk-BB5VTPMQ.js";import{b as y}from"./chunk-FHMIEBRM.js";import{b as A}from"./chunk-7FGDUBSN.js";import{b as $}from"./chunk-GOWX7VPU.js";import{b as S}from"./chunk-B6WWC6K3.js";import{b as T}from"./chunk-MVBK66TR.js";import{b as B}from"./chunk-YIANER7Y.js";import{b as D}from"./chunk-HDWHYM2T.js";import{b as E}from"./chunk-Q3LE3Y66.js";import{b as w}from"./chunk-3FQBUEB6.js";import{b as x}from"./chunk-45DUHCXR.js";import{b as v}from"./chunk-HZGHQZSY.js";import"./chunk-BIJXTWZ4.js";import{d as k,e as q,f as C}from"./chunk-U5JLGI56.js";import"./chunk-IOKQFPM6.js";import{b}from"./chunk-VPSBWWXM.js";import"./chunk-47IFMQYS.js";import"./chunk-3MRB66F4.js";import"./chunk-QFOXSCOD.js";import{b as I}from"./chunk-PTUQEN6I.js";import{b as M}from"./chunk-ZVG47PYA.js";import{b as j}from"./chunk-FONAGXRJ.js";import{b as t}from"./chunk-F2PYTUMR.js";import{b as l}from"./chunk-6JUPBMCR.js";import{b as u}from"./chunk-RTN6X652.js";import{b as p}from"./chunk-KNTDFP7X.js";import{b as e}from"./chunk-T6OIISUC.js";import{b as d}from"./chunk-G4AUMZUY.js";import{b as c}from"./chunk-ABP4OLJV.js";import{b as h}from"./chunk-VTAMGD42.js";import"./chunk-6KHZX4HU.js";import"./chunk-3PCPQIUD.js";import"./chunk-TW2IJRUF.js";import"./chunk-PPVF2N6C.js";import"./chunk-K27FY3ES.js";import"./chunk-MROECM42.js";import"./chunk-42AMF6EE.js";import"./chunk-YXPSX3SI.js";import{b as i}from"./chunk-CMTQFWZK.js";import{b as g}from"./chunk-NXUXZWS5.js";import"./chunk-2UV6ZFHK.js";import"./chunk-GR4ZHKXI.js";import"./chunk-HWI42GQO.js";import{b as m}from"./chunk-WAJVRK5B.js";import"./chunk-HW2VJKFH.js";import"./chunk-YERKK5B3.js";import{b as F}from"./chunk-6FGMEZZP.js";import"./chunk-I57EACSL.js";import"./chunk-7JZKVC3F.js";import{b as z}from"./chunk-CN4JKMTR.js";import{b as f}from"./chunk-3ROYEBJI.js";import"./chunk-MBREBDZQ.js";import"./chunk-HWK7KFGB.js";import"./chunk-FUT3X2GJ.js";import"./chunk-CPKBPQ2C.js";import"./chunk-OHFB3M3X.js";import"./chunk-PBOVSFTJ.js";import"./chunk-NE4R2FVV.js";import{b as n}from"./chunk-QL33F2W6.js";import"./chunk-I4IRHQDW.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";var Er=[i,g,m,F,z,f,n,t,l,u,p,e,d,c,h,w,x,v,k,q,C,b,I,M,j,y,A,$,S,T,B,D,E,G,H,J,K,L,O,P,Q,R,U,V,W,X,Y,Z,_,N,rr,or,ar,sr,ir,gr,mr,Fr,zr,fr,nr,tr,lr,ur,pr,er,dr,cr,hr,wr,xr,vr,kr,qr,Cr,br,Ir,Mr,jr,yr,Ar,$r,Sr];function Tr(){return Er}var Br=new Map;for(let r of Tr())Br.set(r.name,new Set(r.flags.map(o=>o.flag)));function Fa(r,o,Dr){let a=Br.get(o);if(!(!a||a.size===0))for(let s of Dr)a.has(s)&&r.hit(`cmd:flag:${o}:${s}`)}export{Fa as emitFlagCoverage};
3
+ import{d as Ir,e as Mr,f as jr}from"./chunk-HARVZWUX.js";import{b as yr}from"./chunk-M3Z5NZXT.js";import"./chunk-QES5OSUC.js";import{b as Ar}from"./chunk-PRVPFKTC.js";import{b as $r}from"./chunk-ANX7U57Q.js";import"./chunk-V4U26ZWL.js";import"./chunk-KP2UH5CJ.js";import{c as Sr}from"./chunk-GKJD4ULC.js";import"./chunk-3DWQCLNP.js";import{b as wr}from"./chunk-PQ2INDRF.js";import{b as xr}from"./chunk-DYIBFLS3.js";import{b as vr}from"./chunk-VMVXACZ5.js";import{b as kr}from"./chunk-TYBXHT6W.js";import{b as qr}from"./chunk-AJF3OBTR.js";import{b as Cr}from"./chunk-2ETT4ELS.js";import{b as br}from"./chunk-OUQKFRVR.js";import{b as tr}from"./chunk-6TUILMPB.js";import{b as lr}from"./chunk-CC2AQ6B7.js";import{b as ur}from"./chunk-QMPZXXEK.js";import{b as pr}from"./chunk-CNVNOT67.js";import{b as er}from"./chunk-LXFMIXGA.js";import{b as dr}from"./chunk-WFVCEB5T.js";import{b as cr}from"./chunk-KG2KXL4Y.js";import"./chunk-2YLY6FJA.js";import{b as hr}from"./chunk-H7PD6FLC.js";import{c as or,d as ar}from"./chunk-KI54R2QB.js";import{b as sr}from"./chunk-KUMHQGUR.js";import{c as ir,d as gr}from"./chunk-MYTNZ7MA.js";import{b as mr}from"./chunk-V4S4A7M6.js";import"./chunk-ONF4KUYV.js";import{b as Fr}from"./chunk-FPWHWWXO.js";import{b as zr}from"./chunk-3ASHUC7C.js";import{b as fr}from"./chunk-LJQIAFWS.js";import{b as nr}from"./chunk-L345YZ6R.js";import"./chunk-B2DRBHGQ.js";import{b as R}from"./chunk-YJ5OCPSK.js";import{b as U}from"./chunk-Q2GOPGDA.js";import{b as V}from"./chunk-PXP4YYZA.js";import{b as W}from"./chunk-7LGT4LHQ.js";import{c as X,d as Y}from"./chunk-YUZRUF5F.js";import{c as Z,d as _}from"./chunk-DJAX3ZRG.js";import{b as N}from"./chunk-PZQVSQX6.js";import{b as rr}from"./chunk-SDGPS6XI.js";import{b as G}from"./chunk-SC5TEGMM.js";import{b as H}from"./chunk-5SKEZPTU.js";import{b as J}from"./chunk-OYXHOZZ4.js";import{b as K}from"./chunk-R7THHH4J.js";import{b as L}from"./chunk-N26Y42L6.js";import{b as O}from"./chunk-4JF56A3P.js";import{b as P}from"./chunk-AGKL4LDL.js";import{b as Q}from"./chunk-NSI6LMDS.js";import{b as y}from"./chunk-FHMIEBRM.js";import{b as A}from"./chunk-7FGDUBSN.js";import{b as $}from"./chunk-GOWX7VPU.js";import{b as S}from"./chunk-B6WWC6K3.js";import{b as T}from"./chunk-MVBK66TR.js";import{b as B}from"./chunk-YIANER7Y.js";import{b as D}from"./chunk-HDWHYM2T.js";import{b as E}from"./chunk-Q3LE3Y66.js";import{b as w}from"./chunk-3FQBUEB6.js";import{b as x}from"./chunk-45DUHCXR.js";import{b as v}from"./chunk-HZGHQZSY.js";import"./chunk-BIJXTWZ4.js";import{d as k,e as q,f as C}from"./chunk-U5JLGI56.js";import"./chunk-IOKQFPM6.js";import{b}from"./chunk-UNCYBFWT.js";import"./chunk-47IFMQYS.js";import"./chunk-3MRB66F4.js";import"./chunk-QFOXSCOD.js";import{b as I}from"./chunk-PTUQEN6I.js";import{b as M}from"./chunk-ZVG47PYA.js";import{b as j}from"./chunk-FONAGXRJ.js";import{b as t}from"./chunk-F4ACJZIY.js";import{b as l}from"./chunk-IRCAXXH6.js";import{b as u}from"./chunk-Z3TCELKN.js";import{b as p}from"./chunk-KNTDFP7X.js";import{b as e}from"./chunk-K65FCSAT.js";import{b as d}from"./chunk-G4AUMZUY.js";import{b as c}from"./chunk-OXEDIWNZ.js";import{b as h}from"./chunk-VTAMGD42.js";import"./chunk-6KHZX4HU.js";import"./chunk-3PCPQIUD.js";import"./chunk-TW2IJRUF.js";import"./chunk-QKJAAJ7J.js";import"./chunk-K27FY3ES.js";import"./chunk-MROECM42.js";import"./chunk-42AMF6EE.js";import"./chunk-YXPSX3SI.js";import{b as i}from"./chunk-CMTQFWZK.js";import{b as g}from"./chunk-NXUXZWS5.js";import"./chunk-2UV6ZFHK.js";import"./chunk-GR4ZHKXI.js";import"./chunk-HWI42GQO.js";import{b as m}from"./chunk-WAJVRK5B.js";import"./chunk-HW2VJKFH.js";import"./chunk-YERKK5B3.js";import{b as F}from"./chunk-MWQMHODV.js";import"./chunk-I57EACSL.js";import"./chunk-7JZKVC3F.js";import{b as z}from"./chunk-E2O6S35K.js";import{b as f}from"./chunk-4JPWP5WS.js";import"./chunk-AIWBN36Z.js";import"./chunk-UBA7DOWE.js";import"./chunk-FUT3X2GJ.js";import"./chunk-CPKBPQ2C.js";import"./chunk-OHFB3M3X.js";import"./chunk-PBOVSFTJ.js";import"./chunk-NE4R2FVV.js";import{b as n}from"./chunk-QL33F2W6.js";import"./chunk-I4IRHQDW.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";var Er=[i,g,m,F,z,f,n,t,l,u,p,e,d,c,h,w,x,v,k,q,C,b,I,M,j,y,A,$,S,T,B,D,E,G,H,J,K,L,O,P,Q,R,U,V,W,X,Y,Z,_,N,rr,or,ar,sr,ir,gr,mr,Fr,zr,fr,nr,tr,lr,ur,pr,er,dr,cr,hr,wr,xr,vr,kr,qr,Cr,br,Ir,Mr,jr,yr,Ar,$r,Sr];function Tr(){return Er}var Br=new Map;for(let r of Tr())Br.set(r.name,new Set(r.flags.map(o=>o.flag)));function Fa(r,o,Dr){let a=Br.get(o);if(!(!a||a.size===0))for(let s of Dr)a.has(s)&&r.hit(`cmd:flag:${o}:${s}`)}export{Fa as emitFlagCoverage};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a,b,c,d,e,f}from"./chunk-QJWFCA7P.js";import"./chunk-QES5OSUC.js";import"./chunk-GR4ZHKXI.js";import"./chunk-HWI42GQO.js";import"./chunk-I57EACSL.js";import"./chunk-MBREBDZQ.js";import"./chunk-HWK7KFGB.js";import"./chunk-FUT3X2GJ.js";import"./chunk-CPKBPQ2C.js";import"./chunk-OHFB3M3X.js";import"./chunk-PBOVSFTJ.js";import"./chunk-NE4R2FVV.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";export{d as flagsForFuzzing,b as gunzipCommand,e as gunzipFlagsForFuzzing,a as gzipCommand,c as zcatCommand,f as zcatFlagsForFuzzing};
3
+ import{a,b,c,d,e,f}from"./chunk-HARVZWUX.js";import"./chunk-QES5OSUC.js";import"./chunk-GR4ZHKXI.js";import"./chunk-HWI42GQO.js";import"./chunk-I57EACSL.js";import"./chunk-AIWBN36Z.js";import"./chunk-UBA7DOWE.js";import"./chunk-FUT3X2GJ.js";import"./chunk-CPKBPQ2C.js";import"./chunk-OHFB3M3X.js";import"./chunk-PBOVSFTJ.js";import"./chunk-NE4R2FVV.js";import"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";export{d as flagsForFuzzing,b as gunzipCommand,e as gunzipFlagsForFuzzing,a as gzipCommand,c as zcatCommand,f as zcatFlagsForFuzzing};
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env node
2
+ import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
+ import{a as B,b as A}from"./chunk-E54Z6VIE.js";import{a as q}from"./chunk-3DWQCLNP.js";import"./chunk-3MRB66F4.js";import"./chunk-O2BCKSMK.js";import"./chunk-TW2IJRUF.js";import{b as v,c as j}from"./chunk-QKJAAJ7J.js";import{a as F}from"./chunk-MROECM42.js";import{b as C}from"./chunk-HWI42GQO.js";import{b as E}from"./chunk-CPKBPQ2C.js";import"./chunk-OHFB3M3X.js";import{a as W,b as h}from"./chunk-PBOVSFTJ.js";import{a as S}from"./chunk-I4IRHQDW.js";import{b as M}from"./chunk-MUFNRCMY.js";import"./chunk-DN2YCFOR.js";import{AsyncLocalStorage as J}from"node:async_hooks";import{fileURLToPath as H}from"node:url";import{Worker as L}from"node:worker_threads";var O=new J,P=`js-exec - Sandboxed JavaScript/TypeScript runtime with Node.js-compatible APIs
4
+
5
+ Usage: js-exec [OPTIONS] [-c CODE | FILE] [ARGS...]
6
+
7
+ Options:
8
+ -c CODE Execute inline code
9
+ -m, --module Enable ES module mode (import/export)
10
+ --strip-types Strip TypeScript type annotations
11
+ --version, -V Show version
12
+ --help Show this help
13
+
14
+ Examples:
15
+ js-exec -c "console.log(1 + 2)"
16
+ js-exec script.js
17
+ js-exec app.ts
18
+ echo 'console.log("hello")' | js-exec
19
+
20
+ File Extension Auto-Detection:
21
+ .js script mode (module mode if top-level await detected)
22
+ .mjs ES module mode
23
+ .ts, .mts ES module mode + TypeScript stripping
24
+
25
+ Node.js Compatibility:
26
+ Code written for Node.js largely works here. Both require and import
27
+ are supported, the node: prefix works, and standard globals like process,
28
+ console, and fetch are available. All I/O is synchronous.
29
+
30
+ Available modules:
31
+ fs, path, child_process, process, console,
32
+ os, url, assert, util, events, buffer, stream,
33
+ string_decoder, querystring
34
+
35
+ fs (global, require('fs'), or import from 'node:fs'):
36
+ readFileSync, writeFileSync, appendFileSync, copyFileSync, renameSync
37
+ readdirSync, mkdirSync, rmSync, unlinkSync, rmdirSync
38
+ statSync, lstatSync, existsSync, realpathSync, chmodSync
39
+ symlinkSync, readlinkSync, readFileBuffer
40
+ fs.promises.readFile, fs.promises.writeFile, fs.promises.access, ...
41
+
42
+ path: join, resolve, dirname, basename, extname, normalize,
43
+ relative, isAbsolute, parse, format, sep, delimiter
44
+
45
+ child_process:
46
+ execSync(cmd) throws on non-zero exit, returns stdout
47
+ spawnSync(cmd, args) returns { stdout, stderr, status }
48
+
49
+ process (also global): argv, cwd(), exit(), env, platform, arch,
50
+ version, versions
51
+
52
+ os: platform(), arch(), homedir(), tmpdir(), type(), hostname(),
53
+ EOL, cpus(), endianness()
54
+
55
+ url: URL, URLSearchParams, parse(), format()
56
+
57
+ assert: ok(), equal(), strictEqual(), deepEqual(), throws(),
58
+ doesNotThrow(), fail()
59
+
60
+ util: format(), inspect(), promisify(), types, inherits()
61
+
62
+ events: EventEmitter (on, once, emit, off, removeListener, ...)
63
+
64
+ buffer: Buffer.from(), Buffer.alloc(), Buffer.concat(),
65
+ Buffer.isBuffer(), toString(), slice(), equals()
66
+
67
+ stream: Readable, Writable, Duplex, Transform, PassThrough, pipeline
68
+
69
+ string_decoder: StringDecoder (write, end)
70
+
71
+ querystring: parse(), stringify(), escape(), unescape()
72
+
73
+ Other Globals:
74
+ console log (stdout), error/warn (stderr)
75
+ fetch(url, opts) HTTP; returns Promise<Response> (Web Fetch API)
76
+ URL, URLSearchParams, Headers, Request, Response
77
+ Buffer Buffer.from(), Buffer.alloc(), etc.
78
+
79
+ Not Available:
80
+ http, https, net, tls, crypto, zlib, dns, cluster, worker_threads,
81
+ vm, v8, readline, and other Node.js built-in modules that require
82
+ native bindings. Use fetch() for HTTP requests.
83
+
84
+ Limits:
85
+ Memory: 64 MB per execution
86
+ Timeout: 10 s by default; configurable via maxJsTimeoutMs
87
+ Engine: QuickJS (compiled to WebAssembly)
88
+ `;function N(r){let e={code:null,scriptFile:null,showVersion:!1,scriptArgs:[],isModule:!1,stripTypes:!1};if(r.length===0)return e;for(let t=0;t<r.length;t++){let s=r[t];if(s==="-m"||s==="--module"){e.isModule=!0;continue}if(s==="--strip-types"){e.stripTypes=!0;continue}if(s==="-c")return t+1>=r.length?{stdout:"",stderr:`js-exec: option requires an argument -- 'c'
89
+ `,exitCode:2}:(e.code=r[t+1],e.scriptArgs=r.slice(t+2),e);if(s==="--version"||s==="-V")return e.showVersion=!0,e;if(s.startsWith("-")&&s!=="-"&&s!=="--")return{stdout:"",stderr:`js-exec: unrecognized option '${s}'
90
+ `,exitCode:2};if(s==="--")return t+1<r.length&&(e.scriptFile=r[t+1],e.scriptArgs=r.slice(t+2)),e;if(!s.startsWith("-"))return e.scriptFile=s,e.scriptArgs=r.slice(t+1),e}return e}var l=null,y=null,c=[],n=null,x=null,U=1e3,R=5e3;function fe(r){R=r}function pe(){return l!==null}function _(r,e,t){r.controller.close();let s=!1,o=()=>{if(!s&&(s=!0,v(i),n===r)){x="worker termination was not acknowledged";for(let a of c)a.bridgeHandler.stop(),a.resolve({success:!1,error:x});c.length=0,r.resolve(t)}},u=()=>{s||(s=!0,v(i),n===r&&(r.resolve(t),n=null,g()))},i=j(()=>{o()},U);r.controller.terminate(e).then(a=>a?u():o(),o)}function me(){y&&(v(y),y=null),n?.bridgeHandler.stop(),n=null;for(let e of c)e.bridgeHandler.stop();c.length=0;let r=l;l=null,r&&r.terminate(),x=null}var D=H(new URL("./js-exec-worker.js",import.meta.url));function g(){if(n||c.length===0)return;let r=c.shift();if(!r)return;n=r;let e=null;try{e=V(),e.postMessage(r.input)}catch(t){r.bridgeHandler.stop();let s={success:!1,error:h(S(t))},o=e??l;l===o&&(l=null),o?_(r,o,s):(r.resolve(s),n===r&&(n=null),g())}}function $(r,e){if(!r||typeof r!="object")return{success:!1,error:"Malformed worker response"};let t=r;return typeof t.protocolToken!="string"||t.protocolToken!==e?{success:!1,error:"Malformed worker response: invalid protocol token"}:typeof t.success!="boolean"?{success:!1,error:"Malformed worker response: missing success flag"}:t.success?{success:!0}:{success:!1,type:t.type==="initialization-failure"?"initialization-failure":void 0,error:typeof t.error=="string"&&t.error.length>0?t.error:"Worker execution failed"}}function V(){if(y&&(v(y),y=null),l)return l;let r=C.runTrusted(()=>new L(D));return l=r,r.on("message",e=>{if(l===r){if(n){let t;try{n.controller.assertMessageSize(e,"response"),t=$(e,n.input.protocolToken)}catch(s){t={success:!1,error:h(S(s))}}if(t.type==="initialization-failure"){x=t.error??"Worker initialization failed",n.bridgeHandler.stop(),n.resolve(t),n=null;for(let s of c)s.bridgeHandler.stop(),s.resolve({success:!1,type:"initialization-failure",error:x});c.length=0,l=null,r.terminate();return}n.resolve(t),n=null}c.length>0?g():Q()}}),r.on("error",e=>{if(l===r){if(n){let t=h(S(e));n.resolve({success:!1,error:t}),n=null}for(let t of c)t.resolve({success:!1,error:"Worker crashed"});c.length=0,l=null}}),r.on("exit",()=>{l===r&&(l=null,n&&(n.resolve({success:!1,error:"Worker exited unexpectedly"}),n=null),c.length>0&&g())}),r}function Q(){y=j(()=>{l&&!n&&c.length===0&&(l.terminate(),l=null)},R)}async function G(r,e,t,s=[],o,u,i){return O.getStore()?{stdout:"",stderr:`js-exec: recursive invocation is not supported
91
+ `,exitCode:1}:Y(r,e,t,s,o,u,i)}async function K(r,e,t,s){let o,u=new Promise(d=>{o=d}),i={input:r,bridgeHandler:e,resolve:()=>{},controller:s};s.assertMessageSize({...r,sharedBuffer:void 0},"request");let a=d=>{e.stop();let f={success:!1,error:d==="abort"?i.controller.abortMessage():i.controller.timeoutMessage()};if(n===i){let p=l;l=null,p?_(i,p,f):(i.resolve(f),n=null,g())}else{let p=c.indexOf(i);p!==-1&&c.splice(p,1),i.resolve(f),n||g()}};if(i.resolve=d=>{i.controller.close(),o(d)},i.controller.arm(a),!i.controller.isCanceled){c.push(i);try{g()}catch(d){let f=c.indexOf(i);throw f!==-1&&c.splice(f,1),i.controller.close(),d}}let[m,k]=await Promise.all([e.run(t),u.catch(d=>({success:!1,error:h(S(d))}))]);return{bridgeOutput:m,workerResult:k}}function X(r){return r.limits.maxJsTimeoutMs}async function Y(r,e,t,s=[],o,u,i){if(x!==null)return{stdout:"",stderr:`js-exec: ${h(x)}
92
+ `,exitCode:1};let a=B(),m=e.exec,k=m?(b,I)=>O.run(!0,()=>m(b,I)):void 0,d=new A(a,e.fs,e.cwd,"js-exec",e.fetch,e.limits.maxOutputSize,k,e.invokeTool),f=X(e),p=new q({commandName:"js-exec",timeoutMs:f,signal:e.signal,maxMessageBytes:e.limits.maxWorkerMessageBytes}),z={protocolToken:p.protocolToken,sharedBuffer:a,jsCode:r,cwd:e.cwd,env:F(e.env),args:s,scriptPath:t,bootstrapCode:o,isModule:u,stripTypes:i,timeoutMs:f,memoryBytes:e.limits.maxJsMemoryBytes,hasInvokeTool:e.invokeTool!==void 0},{bridgeOutput:T,workerResult:w}=await K(z,d,f,p);if(!w.success&&w.error){let b=w.error===p.timeoutMessage()||w.error===p.abortMessage();return{stdout:T.stdout,stderr:`${T.stderr}js-exec: ${h(w.error)}
93
+ `,exitCode:T.exitCode||(b?124:1)}}return{...T}}var he={handlesOwnVersion:!0,name:"js-exec",async execute(r,e){if(M(r))return{stdout:P,stderr:"",exitCode:0};let t=N(r);if("exitCode"in t)return t;if(t.showVersion)return{stdout:`QuickJS (quickjs-emscripten)
94
+ `,stderr:"",exitCode:0};let s,o;if(t.code!==null)s=t.code,o="-c";else if(t.scriptFile!==null){let m=e.fs.resolvePath(e.cwd,t.scriptFile);if(!await e.fs.exists(m))return{stdout:"",stderr:`js-exec: can't open file '${t.scriptFile}': No such file or directory
95
+ `,exitCode:2};try{s=await e.fs.readFile(m),o=m}catch(k){return{stdout:"",stderr:`js-exec: can't open file '${t.scriptFile}': ${W(k.message)}
96
+ `,exitCode:2}}}else if(E(e.stdin).trim())s=E(e.stdin),o="<stdin>";else return{stdout:"",stderr:`js-exec: no input provided (use -c CODE or provide a script file)
97
+ `,exitCode:2};let u=t.isModule,i=t.stripTypes;o&&o!=="-c"&&o!=="<stdin>"&&((o.endsWith(".mjs")||o.endsWith(".mts")||o.endsWith(".ts"))&&(u=!0),(o.endsWith(".ts")||o.endsWith(".mts"))&&(i=!0)),!u&&/\bawait\s+[\w([`]/.test(s)&&(u=!0);let a=e.jsBootstrapCode;return G(s,e,o,t.scriptArgs,a,u,i)}},ye={name:"node",async execute(){return{stdout:"",stderr:`node: this sandbox uses js-exec instead of node
98
+
99
+ ${P}`,exitCode:1}}};export{pe as _hasSharedJsExecWorkerForTests,me as _resetJsExecWorkerForTests,fe as _setJsExecWorkerIdleTimeoutMsForTests,he as jsExecCommand,ye as nodeStubCommand};