just-bash 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (291) hide show
  1. package/dist/ast/types.d.ts +2 -0
  2. package/dist/bin/just-bash.js +124 -116
  3. package/dist/bin/shell/shell.js +107 -99
  4. package/dist/bundle/ai/index.js +394 -386
  5. package/dist/bundle/index.js +120 -112
  6. package/dist/interpreter/types.d.ts +6 -0
  7. package/dist/shell-metadata.d.ts +28 -0
  8. package/package.json +1 -1
  9. package/dist/bin/chunks/alias-74DFXE2E.js +0 -7
  10. package/dist/bin/chunks/awk-S63F6IYK.js +0 -15
  11. package/dist/bin/chunks/awk2-4DKPX43H.js +0 -20
  12. package/dist/bin/chunks/awk2-6XCE67AX.js +0 -20
  13. package/dist/bin/chunks/awk2-DKAZ7LPG.js +0 -20
  14. package/dist/bin/chunks/awk2-GAJ72X3Z.js +0 -20
  15. package/dist/bin/chunks/awk2-HJAPWU2N.js +0 -18
  16. package/dist/bin/chunks/awk2-LVXC5OAC.js +0 -20
  17. package/dist/bin/chunks/awk2-T6HR4EYO.js +0 -20
  18. package/dist/bin/chunks/awk2-UYU2UYZ2.js +0 -20
  19. package/dist/bin/chunks/awk2-W64AZN7P.js +0 -20
  20. package/dist/bin/chunks/base64-KNBBHA5Y.js +0 -5
  21. package/dist/bin/chunks/base64-NC7HTKLZ.js +0 -5
  22. package/dist/bin/chunks/basename-Y7JDBYHN.js +0 -6
  23. package/dist/bin/chunks/bash-5IWSVGHN.js +0 -7
  24. package/dist/bin/chunks/bash-TQGTNXAE.js +0 -7
  25. package/dist/bin/chunks/cat-YZXBF5YF.js +0 -6
  26. package/dist/bin/chunks/chmod-3G4LK462.js +0 -9
  27. package/dist/bin/chunks/chunk-5KNEBKYN.js +0 -2
  28. package/dist/bin/chunks/chunk-6QUZ7QML.js +0 -3
  29. package/dist/bin/chunks/chunk-7Q4WQLOS.js +0 -9
  30. package/dist/bin/chunks/chunk-LV662IGP.js +0 -6
  31. package/dist/bin/chunks/clear-GTCFHSB2.js +0 -2
  32. package/dist/bin/chunks/cp-77UY7PGN.js +0 -8
  33. package/dist/bin/chunks/curl-NE7XEWMN.js +0 -26
  34. package/dist/bin/chunks/cut-UYV3FM7R.js +0 -6
  35. package/dist/bin/chunks/date-7NBRXV2Z.js +0 -5
  36. package/dist/bin/chunks/diff-TG2NXCX2.js +0 -19
  37. package/dist/bin/chunks/dirname-VLHP44TU.js +0 -5
  38. package/dist/bin/chunks/du-4FZ7WF2P.js +0 -8
  39. package/dist/bin/chunks/echo-DEUIS5JO.js +0 -4
  40. package/dist/bin/chunks/env-AKGX6HSG.js +0 -9
  41. package/dist/bin/chunks/env-FVITWNHG.js +0 -9
  42. package/dist/bin/chunks/expr-HA2ZNL6S.js +0 -5
  43. package/dist/bin/chunks/file-Q4UOC4J2.js +0 -23
  44. package/dist/bin/chunks/find-4B67H4RP.js +0 -11
  45. package/dist/bin/chunks/find-7BUNQZX4.js +0 -11
  46. package/dist/bin/chunks/find-AMA6ABN5.js +0 -11
  47. package/dist/bin/chunks/find-HW2TUO6B.js +0 -11
  48. package/dist/bin/chunks/find-JADNFF7V.js +0 -11
  49. package/dist/bin/chunks/find-NCI6KGUI.js +0 -11
  50. package/dist/bin/chunks/find-QEYP42JQ.js +0 -11
  51. package/dist/bin/chunks/find-WJV3FM6L.js +0 -11
  52. package/dist/bin/chunks/find-YATLECXJ.js +0 -11
  53. package/dist/bin/chunks/grep-OVWU4WCZ.js +0 -15
  54. package/dist/bin/chunks/grep-PHBFGJCV.js +0 -15
  55. package/dist/bin/chunks/head-VGXR3WWL.js +0 -2
  56. package/dist/bin/chunks/help-5V3MPCYQ.js +0 -16
  57. package/dist/bin/chunks/help-YQGNAT2T.js +0 -16
  58. package/dist/bin/chunks/history-PRQ4B6N2.js +0 -3
  59. package/dist/bin/chunks/html-to-markdown-L4UWMK4S.js +0 -84
  60. package/dist/bin/chunks/jq-EYSXBSCP.js +0 -14
  61. package/dist/bin/chunks/ln-DB7J2W5X.js +0 -10
  62. package/dist/bin/chunks/ls-C4MPAF3H.js +0 -26
  63. package/dist/bin/chunks/md5sum-KZ4MRIXM.js +0 -2
  64. package/dist/bin/chunks/mkdir-LWULWDHP.js +0 -7
  65. package/dist/bin/chunks/mv-TDYCNSIQ.js +0 -7
  66. package/dist/bin/chunks/paste-R36J3G4K.js +0 -8
  67. package/dist/bin/chunks/printf-ASOYDPIK.js +0 -14
  68. package/dist/bin/chunks/printf-BOFQVMMK.js +0 -15
  69. package/dist/bin/chunks/printf-WM4X6IZ6.js +0 -14
  70. package/dist/bin/chunks/pwd-X4MWD4JP.js +0 -3
  71. package/dist/bin/chunks/readlink-DPNOQY67.js +0 -7
  72. package/dist/bin/chunks/rm-W6CCBEMG.js +0 -8
  73. package/dist/bin/chunks/sed-7IS44XON.js +0 -48
  74. package/dist/bin/chunks/sed-B6FXUN7R.js +0 -80
  75. package/dist/bin/chunks/sed-LTCVBSRV.js +0 -80
  76. package/dist/bin/chunks/sed-RHLDIXPL.js +0 -76
  77. package/dist/bin/chunks/sed-SYSATJXR.js +0 -75
  78. package/dist/bin/chunks/seq-DGJILX2Q.js +0 -7
  79. package/dist/bin/chunks/sha1sum-XLRE72T4.js +0 -2
  80. package/dist/bin/chunks/sha256sum-BBKWFA43.js +0 -2
  81. package/dist/bin/chunks/sleep-E4DIYGTT.js +0 -10
  82. package/dist/bin/chunks/sort-NCQNGVCX.js +0 -16
  83. package/dist/bin/chunks/sort-UJP353TM.js +0 -15
  84. package/dist/bin/chunks/sort-WGKQ3WYR.js +0 -15
  85. package/dist/bin/chunks/stat-3PHITCPO.js +0 -9
  86. package/dist/bin/chunks/tail-YSVKBQ77.js +0 -2
  87. package/dist/bin/chunks/tee-UU2VS3OM.js +0 -3
  88. package/dist/bin/chunks/timeout-OZVAGW2H.js +0 -12
  89. package/dist/bin/chunks/timeout-RP2AJGMV.js +0 -12
  90. package/dist/bin/chunks/touch-XCIAYF5I.js +0 -4
  91. package/dist/bin/chunks/tr-2EEKHHO6.js +0 -20
  92. package/dist/bin/chunks/tree-4247W67O.js +0 -12
  93. package/dist/bin/chunks/true-JCX733LK.js +0 -2
  94. package/dist/bin/chunks/uniq-W4HF6YSB.js +0 -5
  95. package/dist/bin/chunks/wc-CNJ3QDRA.js +0 -6
  96. package/dist/bin/chunks/which-HX2NMOP3.js +0 -3
  97. package/dist/bin/chunks/xargs-DKUAYNEK.js +0 -4
  98. package/dist/bin/chunks/xargs-XAZFX5J3.js +0 -4
  99. package/dist/bin/chunks/xargs-YNLVLPOF.js +0 -4
  100. package/dist/bin/shell/chunks/alias-74DFXE2E.js +0 -7
  101. package/dist/bin/shell/chunks/awk-S63F6IYK.js +0 -15
  102. package/dist/bin/shell/chunks/awk2-4DKPX43H.js +0 -20
  103. package/dist/bin/shell/chunks/awk2-6XCE67AX.js +0 -20
  104. package/dist/bin/shell/chunks/awk2-DKAZ7LPG.js +0 -20
  105. package/dist/bin/shell/chunks/awk2-GAJ72X3Z.js +0 -20
  106. package/dist/bin/shell/chunks/awk2-HJAPWU2N.js +0 -18
  107. package/dist/bin/shell/chunks/awk2-LVXC5OAC.js +0 -20
  108. package/dist/bin/shell/chunks/awk2-T6HR4EYO.js +0 -20
  109. package/dist/bin/shell/chunks/awk2-UYU2UYZ2.js +0 -20
  110. package/dist/bin/shell/chunks/awk2-W64AZN7P.js +0 -20
  111. package/dist/bin/shell/chunks/base64-KNBBHA5Y.js +0 -5
  112. package/dist/bin/shell/chunks/base64-NC7HTKLZ.js +0 -5
  113. package/dist/bin/shell/chunks/basename-Y7JDBYHN.js +0 -6
  114. package/dist/bin/shell/chunks/bash-5IWSVGHN.js +0 -7
  115. package/dist/bin/shell/chunks/bash-TQGTNXAE.js +0 -7
  116. package/dist/bin/shell/chunks/cat-YZXBF5YF.js +0 -6
  117. package/dist/bin/shell/chunks/chmod-3G4LK462.js +0 -9
  118. package/dist/bin/shell/chunks/chunk-5KNEBKYN.js +0 -2
  119. package/dist/bin/shell/chunks/chunk-6QUZ7QML.js +0 -3
  120. package/dist/bin/shell/chunks/chunk-7Q4WQLOS.js +0 -9
  121. package/dist/bin/shell/chunks/chunk-LV662IGP.js +0 -6
  122. package/dist/bin/shell/chunks/clear-GTCFHSB2.js +0 -2
  123. package/dist/bin/shell/chunks/cp-77UY7PGN.js +0 -8
  124. package/dist/bin/shell/chunks/curl-NE7XEWMN.js +0 -26
  125. package/dist/bin/shell/chunks/cut-UYV3FM7R.js +0 -6
  126. package/dist/bin/shell/chunks/date-7NBRXV2Z.js +0 -5
  127. package/dist/bin/shell/chunks/diff-TG2NXCX2.js +0 -19
  128. package/dist/bin/shell/chunks/dirname-VLHP44TU.js +0 -5
  129. package/dist/bin/shell/chunks/du-4FZ7WF2P.js +0 -8
  130. package/dist/bin/shell/chunks/echo-DEUIS5JO.js +0 -4
  131. package/dist/bin/shell/chunks/env-AKGX6HSG.js +0 -9
  132. package/dist/bin/shell/chunks/env-FVITWNHG.js +0 -9
  133. package/dist/bin/shell/chunks/expr-HA2ZNL6S.js +0 -5
  134. package/dist/bin/shell/chunks/file-Q4UOC4J2.js +0 -23
  135. package/dist/bin/shell/chunks/find-4B67H4RP.js +0 -11
  136. package/dist/bin/shell/chunks/find-7BUNQZX4.js +0 -11
  137. package/dist/bin/shell/chunks/find-AMA6ABN5.js +0 -11
  138. package/dist/bin/shell/chunks/find-HW2TUO6B.js +0 -11
  139. package/dist/bin/shell/chunks/find-JADNFF7V.js +0 -11
  140. package/dist/bin/shell/chunks/find-NCI6KGUI.js +0 -11
  141. package/dist/bin/shell/chunks/find-QEYP42JQ.js +0 -11
  142. package/dist/bin/shell/chunks/find-WJV3FM6L.js +0 -11
  143. package/dist/bin/shell/chunks/find-YATLECXJ.js +0 -11
  144. package/dist/bin/shell/chunks/grep-OVWU4WCZ.js +0 -15
  145. package/dist/bin/shell/chunks/grep-PHBFGJCV.js +0 -15
  146. package/dist/bin/shell/chunks/head-VGXR3WWL.js +0 -2
  147. package/dist/bin/shell/chunks/help-5V3MPCYQ.js +0 -16
  148. package/dist/bin/shell/chunks/help-YQGNAT2T.js +0 -16
  149. package/dist/bin/shell/chunks/history-PRQ4B6N2.js +0 -3
  150. package/dist/bin/shell/chunks/html-to-markdown-L4UWMK4S.js +0 -84
  151. package/dist/bin/shell/chunks/jq-EYSXBSCP.js +0 -14
  152. package/dist/bin/shell/chunks/ln-DB7J2W5X.js +0 -10
  153. package/dist/bin/shell/chunks/ls-C4MPAF3H.js +0 -26
  154. package/dist/bin/shell/chunks/md5sum-KZ4MRIXM.js +0 -2
  155. package/dist/bin/shell/chunks/mkdir-LWULWDHP.js +0 -7
  156. package/dist/bin/shell/chunks/mv-TDYCNSIQ.js +0 -7
  157. package/dist/bin/shell/chunks/paste-R36J3G4K.js +0 -8
  158. package/dist/bin/shell/chunks/printf-ASOYDPIK.js +0 -14
  159. package/dist/bin/shell/chunks/printf-BOFQVMMK.js +0 -15
  160. package/dist/bin/shell/chunks/printf-WM4X6IZ6.js +0 -14
  161. package/dist/bin/shell/chunks/pwd-X4MWD4JP.js +0 -3
  162. package/dist/bin/shell/chunks/readlink-DPNOQY67.js +0 -7
  163. package/dist/bin/shell/chunks/rm-W6CCBEMG.js +0 -8
  164. package/dist/bin/shell/chunks/sed-7IS44XON.js +0 -48
  165. package/dist/bin/shell/chunks/sed-B6FXUN7R.js +0 -80
  166. package/dist/bin/shell/chunks/sed-LTCVBSRV.js +0 -80
  167. package/dist/bin/shell/chunks/sed-RHLDIXPL.js +0 -76
  168. package/dist/bin/shell/chunks/sed-SYSATJXR.js +0 -75
  169. package/dist/bin/shell/chunks/seq-DGJILX2Q.js +0 -7
  170. package/dist/bin/shell/chunks/sha1sum-XLRE72T4.js +0 -2
  171. package/dist/bin/shell/chunks/sha256sum-BBKWFA43.js +0 -2
  172. package/dist/bin/shell/chunks/sleep-E4DIYGTT.js +0 -10
  173. package/dist/bin/shell/chunks/sort-NCQNGVCX.js +0 -16
  174. package/dist/bin/shell/chunks/sort-UJP353TM.js +0 -15
  175. package/dist/bin/shell/chunks/sort-WGKQ3WYR.js +0 -15
  176. package/dist/bin/shell/chunks/stat-3PHITCPO.js +0 -9
  177. package/dist/bin/shell/chunks/tail-YSVKBQ77.js +0 -2
  178. package/dist/bin/shell/chunks/tee-UU2VS3OM.js +0 -3
  179. package/dist/bin/shell/chunks/timeout-OZVAGW2H.js +0 -12
  180. package/dist/bin/shell/chunks/timeout-RP2AJGMV.js +0 -12
  181. package/dist/bin/shell/chunks/touch-XCIAYF5I.js +0 -4
  182. package/dist/bin/shell/chunks/tr-2EEKHHO6.js +0 -20
  183. package/dist/bin/shell/chunks/tree-4247W67O.js +0 -12
  184. package/dist/bin/shell/chunks/true-JCX733LK.js +0 -2
  185. package/dist/bin/shell/chunks/uniq-W4HF6YSB.js +0 -5
  186. package/dist/bin/shell/chunks/wc-CNJ3QDRA.js +0 -6
  187. package/dist/bin/shell/chunks/which-HX2NMOP3.js +0 -3
  188. package/dist/bin/shell/chunks/xargs-DKUAYNEK.js +0 -4
  189. package/dist/bin/shell/chunks/xargs-XAZFX5J3.js +0 -4
  190. package/dist/bin/shell/chunks/xargs-YNLVLPOF.js +0 -4
  191. package/dist/bundle/chunks/alias-7ZSTROM7.js +0 -6
  192. package/dist/bundle/chunks/awk-V4C3GTJI.js +0 -14
  193. package/dist/bundle/chunks/awk2-365HINHI.js +0 -19
  194. package/dist/bundle/chunks/awk2-4YCQ6UCB.js +0 -19
  195. package/dist/bundle/chunks/awk2-7YCFY7D2.js +0 -19
  196. package/dist/bundle/chunks/awk2-7YL3P4KU.js +0 -19
  197. package/dist/bundle/chunks/awk2-ETXZHQQ4.js +0 -19
  198. package/dist/bundle/chunks/awk2-FMEL7ESV.js +0 -19
  199. package/dist/bundle/chunks/awk2-LE4QUFGK.js +0 -19
  200. package/dist/bundle/chunks/awk2-MGHA6JPJ.js +0 -17
  201. package/dist/bundle/chunks/awk2-XEAK5PBN.js +0 -19
  202. package/dist/bundle/chunks/base64-JN6XXTIG.js +0 -4
  203. package/dist/bundle/chunks/base64-WATI5PWI.js +0 -4
  204. package/dist/bundle/chunks/basename-SB5JXIY3.js +0 -5
  205. package/dist/bundle/chunks/bash-5WG5RD6L.js +0 -6
  206. package/dist/bundle/chunks/bash-T4PXVRYX.js +0 -6
  207. package/dist/bundle/chunks/cat-5KESXK2M.js +0 -5
  208. package/dist/bundle/chunks/chmod-VLKWIL3N.js +0 -8
  209. package/dist/bundle/chunks/chunk-4HEWHW5W.js +0 -8
  210. package/dist/bundle/chunks/chunk-JYYFSUWP.js +0 -5
  211. package/dist/bundle/chunks/chunk-TDJNT32M.js +0 -2
  212. package/dist/bundle/chunks/clear-ZBD2DMXN.js +0 -1
  213. package/dist/bundle/chunks/cp-BLHAPLQZ.js +0 -7
  214. package/dist/bundle/chunks/curl-PA2MWGKN.js +0 -25
  215. package/dist/bundle/chunks/cut-7RHEYJ7Y.js +0 -5
  216. package/dist/bundle/chunks/date-YOOSNZVA.js +0 -4
  217. package/dist/bundle/chunks/diff-IVJFQANX.js +0 -6
  218. package/dist/bundle/chunks/dirname-Q5HDZLH2.js +0 -4
  219. package/dist/bundle/chunks/du-I5HYAKTQ.js +0 -7
  220. package/dist/bundle/chunks/echo-W2TA2N7Y.js +0 -3
  221. package/dist/bundle/chunks/env-2F2VHNYS.js +0 -8
  222. package/dist/bundle/chunks/env-OORA5GFS.js +0 -8
  223. package/dist/bundle/chunks/expr-A4LJAGVP.js +0 -4
  224. package/dist/bundle/chunks/file-JMDIXLHY.js +0 -22
  225. package/dist/bundle/chunks/find-3O5V74IR.js +0 -10
  226. package/dist/bundle/chunks/find-4QUN2ATO.js +0 -10
  227. package/dist/bundle/chunks/find-522XP4ZY.js +0 -10
  228. package/dist/bundle/chunks/find-5UN24ZV7.js +0 -10
  229. package/dist/bundle/chunks/find-JXG2HF6L.js +0 -10
  230. package/dist/bundle/chunks/find-K3NO35MZ.js +0 -10
  231. package/dist/bundle/chunks/find-K7D4PKHS.js +0 -10
  232. package/dist/bundle/chunks/find-KP4M5DWC.js +0 -10
  233. package/dist/bundle/chunks/find-WM6ZETA7.js +0 -10
  234. package/dist/bundle/chunks/grep-3D2INI4S.js +0 -14
  235. package/dist/bundle/chunks/grep-CZTYKNEE.js +0 -14
  236. package/dist/bundle/chunks/head-7H5R4WKO.js +0 -1
  237. package/dist/bundle/chunks/help-SDCRRU2F.js +0 -15
  238. package/dist/bundle/chunks/help-XHGUXTV3.js +0 -15
  239. package/dist/bundle/chunks/history-7Z2STZ6Y.js +0 -2
  240. package/dist/bundle/chunks/html-to-markdown-XMBYO6FD.js +0 -4
  241. package/dist/bundle/chunks/jq-7R2XGLLH.js +0 -13
  242. package/dist/bundle/chunks/ln-UTUVIAFP.js +0 -9
  243. package/dist/bundle/chunks/ls-B7C35UDO.js +0 -23
  244. package/dist/bundle/chunks/md5sum-3BXZVFKC.js +0 -1
  245. package/dist/bundle/chunks/mkdir-WYI2LJ6H.js +0 -6
  246. package/dist/bundle/chunks/mv-GN23UIZU.js +0 -6
  247. package/dist/bundle/chunks/paste-L4TYPVSP.js +0 -7
  248. package/dist/bundle/chunks/printf-3ZT5XOIZ.js +0 -14
  249. package/dist/bundle/chunks/printf-G2SBUNW3.js +0 -13
  250. package/dist/bundle/chunks/printf-O2UW73XK.js +0 -13
  251. package/dist/bundle/chunks/pwd-ZVX5RTL4.js +0 -2
  252. package/dist/bundle/chunks/readlink-HHC33N5C.js +0 -6
  253. package/dist/bundle/chunks/rm-5X2XSQQ6.js +0 -7
  254. package/dist/bundle/chunks/sed-2WWCANZT.js +0 -79
  255. package/dist/bundle/chunks/sed-5LZHAGFR.js +0 -74
  256. package/dist/bundle/chunks/sed-IGVS3UIY.js +0 -79
  257. package/dist/bundle/chunks/sed-UZJSXYQZ.js +0 -47
  258. package/dist/bundle/chunks/sed-V7XSBPTD.js +0 -75
  259. package/dist/bundle/chunks/seq-TFPZQZPJ.js +0 -6
  260. package/dist/bundle/chunks/sha1sum-MSBXCB4N.js +0 -1
  261. package/dist/bundle/chunks/sha256sum-YMKJMSTW.js +0 -1
  262. package/dist/bundle/chunks/sleep-QJBQD6VS.js +0 -9
  263. package/dist/bundle/chunks/sort-LHMQWYH2.js +0 -14
  264. package/dist/bundle/chunks/sort-R3YWDMTV.js +0 -14
  265. package/dist/bundle/chunks/sort-TEXV7CUR.js +0 -15
  266. package/dist/bundle/chunks/stat-TM5F5YO4.js +0 -8
  267. package/dist/bundle/chunks/tail-BLGGG2VX.js +0 -1
  268. package/dist/bundle/chunks/tee-VCNOG5VI.js +0 -2
  269. package/dist/bundle/chunks/timeout-THAT7IOO.js +0 -11
  270. package/dist/bundle/chunks/timeout-VG2N46UR.js +0 -11
  271. package/dist/bundle/chunks/touch-Z5XRYFYY.js +0 -3
  272. package/dist/bundle/chunks/tr-UV4V27RJ.js +0 -19
  273. package/dist/bundle/chunks/tree-75UXQ4XJ.js +0 -11
  274. package/dist/bundle/chunks/true-OD7ZXH3O.js +0 -1
  275. package/dist/bundle/chunks/uniq-IIOQKNTS.js +0 -4
  276. package/dist/bundle/chunks/wc-OXLYBRUE.js +0 -5
  277. package/dist/bundle/chunks/which-ONWH3TNF.js +0 -2
  278. package/dist/bundle/chunks/xargs-752VENJT.js +0 -3
  279. package/dist/bundle/chunks/xargs-7KV5F66T.js +0 -3
  280. package/dist/bundle/chunks/xargs-E5JPQL24.js +0 -3
  281. package/dist/commands/awk/awk.d.ts +0 -2
  282. package/dist/commands/awk/executor.d.ts +0 -3
  283. package/dist/commands/awk/expressions.d.ts +0 -3
  284. package/dist/commands/awk/functions.d.ts +0 -12
  285. package/dist/commands/awk/interpreter2.d.ts +0 -90
  286. package/dist/commands/awk/parser.d.ts +0 -3
  287. package/dist/commands/awk/types.d.ts +0 -44
  288. package/dist/fs-interface.d.ts +0 -186
  289. package/dist/fs.d.ts +0 -39
  290. package/dist/overlay-fs/OverlayFs.d.ts +0 -87
  291. package/dist/overlay-fs/index.d.ts +0 -1
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as N}from"./chunk-26Q3PZQ6.js";import{a as L,b as B,c as H}from"./chunk-PM2DS2YW.js";import{a as I,b as O}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";function w(e,s){switch(e.type){case"name":return{matches:N(s.name,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"path":return{matches:N(s.relativePath,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"regex":try{let n=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,n).test(s.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:s.isEmpty,pruned:!1,printed:!1};case"mtime":{let r=(Date.now()-s.mtime)/(1e3*60*60*24),t;return e.comparison==="more"?t=r>e.days:e.comparison==="less"?t=r<e.days:t=Math.floor(r)===e.days,{matches:t,pruned:!1,printed:!1}}case"newer":{let n=s.newerRefTimes.get(e.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:s.mtime>n,pruned:!1,printed:!1}}case"size":{let n=e.value;switch(e.unit){case"c":n=e.value;break;case"k":n=e.value*1024;break;case"M":n=e.value*1024*1024;break;case"G":n=e.value*1024*1024*1024;break;case"b":n=e.value*512;break}let r;return e.comparison==="more"?r=s.size>n:e.comparison==="less"?r=s.size<n:e.unit==="b"?r=Math.ceil(s.size/512)===e.value:r=s.size===n,{matches:r,pruned:!1,printed:!1}}case"perm":{let n=s.mode&511,r=e.mode&511,t;return e.matchType==="exact"?t=n===r:e.matchType==="all"?t=(n&r)===r:t=(n&r)!==0,{matches:t,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let n=w(e.expr,s);return{matches:!n.matches,pruned:n.pruned,printed:!1}}case"and":{let n=w(e.left,s);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1};let r=w(e.right,s);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:n.printed||r.printed}}case"or":{let n=w(e.left,s);if(n.matches)return n;let r=w(e.right,s);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:r.printed}}}}function G(e){let s=[],n=r=>{r&&(r.type==="newer"?s.push(r.refPath):r.type==="not"?n(r.expr):(r.type==="and"||r.type==="or")&&(n(r.left),n(r.right)))};return n(e),s}function j(e,s){let n=[],r=[],t=s;for(;t<e.length;){let a=e[t];if(a==="("||a==="\\("){n.push({type:"lparen"}),t++;continue}if(a===")"||a==="\\)"){n.push({type:"rparen"}),t++;continue}if(a==="-name"&&t+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++t]}});else if(a==="-iname"&&t+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++t],ignoreCase:!0}});else if(a==="-path"&&t+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++t]}});else if(a==="-ipath"&&t+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++t],ignoreCase:!0}});else if(a==="-regex"&&t+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++t]}});else if(a==="-iregex"&&t+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++t],ignoreCase:!0}});else if(a==="-type"&&t+1<e.length){let i=e[++t];if(i==="f"||i==="d")n.push({type:"expr",expr:{type:"type",fileType:i}});else return{expr:null,pathIndex:t,error:`find: Unknown argument to -type: ${i}
3
- `,actions:[]}}else if(a==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(a==="-mtime"&&t+1<e.length){let i=e[++t],c="exact",o=i;i.startsWith("+")?(c="more",o=i.slice(1)):i.startsWith("-")&&(c="less",o=i.slice(1));let h=parseInt(o,10);Number.isNaN(h)||n.push({type:"expr",expr:{type:"mtime",days:h,comparison:c}})}else if(a==="-newer"&&t+1<e.length){let i=e[++t];n.push({type:"expr",expr:{type:"newer",refPath:i}})}else if(a==="-size"&&t+1<e.length){let i=e[++t],c="exact",o=i;i.startsWith("+")?(c="more",o=i.slice(1)):i.startsWith("-")&&(c="less",o=i.slice(1));let h=o.match(/^(\d+)([ckMGb])?$/);if(h){let b=parseInt(h[1],10),y=h[2]||"b";n.push({type:"expr",expr:{type:"size",value:b,unit:y,comparison:c}})}}else if(a==="-perm"&&t+1<e.length){let i=e[++t],c="exact",o=i;i.startsWith("-")?(c="all",o=i.slice(1)):i.startsWith("/")&&(c="any",o=i.slice(1));let h=parseInt(o,8);Number.isNaN(h)||n.push({type:"expr",expr:{type:"perm",mode:h,matchType:c}})}else if(a==="-prune")n.push({type:"expr",expr:{type:"prune"}});else if(a==="-not"||a==="!")n.push({type:"not"});else if(a==="-o"||a==="-or")n.push({type:"op",op:"or"});else if(a==="-a"||a==="-and")n.push({type:"op",op:"and"});else if(a==="-maxdepth"||a==="-mindepth")t++;else if(a!=="-depth")if(a==="-exec"){let i=[];for(t++;t<e.length&&e[t]!==";"&&e[t]!=="+";)i.push(e[t]),t++;if(t>=e.length)return{expr:null,pathIndex:t,error:"find: missing argument to `-exec'\n",actions:[]};let c=e[t]==="+";r.push({type:"exec",command:i,batchMode:c})}else if(a==="-print")n.push({type:"expr",expr:{type:"print"}}),r.push({type:"print"});else if(a==="-print0")r.push({type:"print0"});else if(a==="-printf"&&t+1<e.length){let i=e[++t];r.push({type:"printf",format:i})}else if(a==="-delete")r.push({type:"delete"});else{if(a.startsWith("-"))return{expr:null,pathIndex:t,error:`find: unknown predicate '${a}'
4
- `,actions:[]};if(n.length===0){t++;continue}break}t++}if(n.length===0)return{expr:null,pathIndex:t,actions:r};let m=_(n);return m.error?{expr:null,pathIndex:t,error:m.error,actions:r}:{expr:m.expr,pathIndex:t,actions:r}}function _(e){let s=0;function n(){let i=r();if(!i)return null;for(;s<e.length;){let c=e[s];if(c.type==="op"&&c.op==="or"){s++;let o=r();if(!o)return i;i={type:"or",left:i,right:o}}else break}return i}function r(){let i=t();if(!i)return null;for(;s<e.length;){let c=e[s];if(c.type==="op"&&c.op==="and"){s++;let o=t();if(!o)return i;i={type:"and",left:i,right:o}}else if(c.type==="expr"||c.type==="not"||c.type==="lparen"){let o=t();if(!o)return i;i={type:"and",left:i,right:o}}else break}return i}function t(){if(s<e.length&&e[s].type==="not"){s++;let i=t();return i?{type:"not",expr:i}:null}return m()}function m(){if(s>=e.length)return null;let i=e[s];if(i.type==="lparen"){s++;let c=n();return s<e.length&&e[s].type==="rparen"&&s++,c}return i.type==="expr"?(s++,i.expr):(i.type==="rparen",null)}return{expr:n()}}var K={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-regex PATTERN file path matches regular expression PATTERN","-iregex PATTERN like -regex but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-depth process directory contents before directory itself","-prune do not descend into this directory","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-printf FORMAT print FORMAT with directives: %f %h %p %P %s %d %m %M %t","-delete delete found files/directories"," --help display this help and exit"]},U=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),oe={name:"find",async execute(e,s){if(O(e))return I(K);let n=[],r=null,t=null,m=!1,a=!1;for(let p=0;p<e.length;p++){let l=e[p];if(l==="-maxdepth"&&p+1<e.length)a=!0,r=parseInt(e[++p],10);else if(l==="-mindepth"&&p+1<e.length)a=!0,t=parseInt(e[++p],10);else if(l==="-depth")a=!0,m=!0;else if(l==="-exec")for(a=!0,p++;p<e.length&&e[p]!==";"&&e[p]!=="+";)p++;else!l.startsWith("-")&&l!==";"&&l!=="+"&&l!=="("&&l!==")"&&l!=="\\("&&l!=="\\)"&&l!=="!"?a||n.push(l):U.has(l)?(a=!0,p++):(l.startsWith("-")||l==="("||l==="\\("||l==="!")&&(a=!0)}n.length===0&&n.push(".");let{expr:i,error:c,actions:o}=j(e,0);if(c)return{stdout:"",stderr:c,exitCode:1};let h=o.some(p=>p.type==="print"),b=o.length===0,y=[],Y=o.some(p=>p.type==="printf"),F=[],T="",D=0,V=G(i),k=new Map;for(let p of V){let l=s.fs.resolvePath(s.cwd,p);try{let g=await s.fs.stat(l);k.set(p,g.mtime?.getTime()??Date.now())}catch{}}for(let p of n){let l=s.fs.resolvePath(s.cwd,p);try{await s.fs.stat(l)}catch{T+=`find: ${p}: No such file or directory
5
- `,D=1;continue}async function g(u,d){if(r!==null&&d>r)return;let f;try{f=await s.fs.stat(u)}catch{return}if(!f)return;let E;u===l?E=p.split("/").pop()||p:E=u.split("/").pop()||"";let $=u===l?p:p==="."?`./${u.slice(l.length+1)}`:p+u.slice(l.length),M=null;f.isDirectory&&(M=await s.fs.readdir(u));let R=f.isFile?f.size===0:M!==null&&M.length===0,C=()=>{let x=t===null||d>=t,v=!1;if(x&&i!==null){let J={name:E,relativePath:$,isFile:f.isFile,isDirectory:f.isDirectory,isEmpty:R,mtime:f.mtime?.getTime()??Date.now(),size:f.size??0,mode:f.mode??420,newerRefTimes:k},W=w(i,J);x=W.matches,h?v=W.printed:v=x}else x&&(v=!0);v&&(y.push($),Y&&F.push({path:$,name:E,size:f.size??0,mtime:f.mtime?.getTime()??Date.now(),mode:f.mode??420,isDirectory:f.isDirectory,depth:d,startingPoint:p}))},A=async()=>{if(M!==null)for(let P of M){let x=u==="/"?`/${P}`:`${u}/${P}`;await g(x,d+1)}},z=!1;if(!m&&i!==null){let P={name:E,relativePath:$,isFile:f.isFile,isDirectory:f.isDirectory,isEmpty:R,mtime:f.mtime?.getTime()??Date.now(),size:f.size??0,mode:f.mode??420,newerRefTimes:k};z=w(i,P).pruned}m?(await A(),C()):(C(),z||await A())}await g(l,0)}let S="";if(o.length>0)for(let p of o)switch(p.type){case"print":S+=y.length>0?`${y.join(`
6
- `)}
7
- `:"";break;case"print0":S+=y.length>0?`${y.join("\0")}\0`:"";break;case"delete":{let l=[...y].sort((g,u)=>u.length-g.length);for(let g of l){let u=s.fs.resolvePath(s.cwd,g);try{await s.fs.rm(u,{recursive:!1})}catch(d){let f=d instanceof Error?d.message:String(d);T+=`find: cannot delete '${g}': ${f}
8
- `,D=1}}break}case"printf":for(let l of F)S+=q(p.format,l);break;case"exec":if(!s.exec)return{stdout:"",stderr:`find: -exec not supported in this context
9
- `,exitCode:1};if(p.batchMode){let l=[];for(let d of p.command)d==="{}"?l.push(...y):l.push(d);let g=l.map(d=>`"${d}"`).join(" "),u=await s.exec(g,{cwd:s.cwd});S+=u.stdout,T+=u.stderr,u.exitCode!==0&&(D=u.exitCode)}else for(let l of y){let u=p.command.map(f=>f==="{}"?l:f).map(f=>`"${f}"`).join(" "),d=await s.exec(u,{cwd:s.cwd});S+=d.stdout,T+=d.stderr,d.exitCode!==0&&(D=d.exitCode)}break}else b&&(S=y.length>0?`${y.join(`
10
- `)}
11
- `:"");return{stdout:S,stderr:T,exitCode:D}}};function q(e,s){let n=H(e),r="",t=0;for(;t<n.length;)if(n[t]==="%"&&t+1<n.length){if(t++,n[t]==="%"){r+="%",t++;continue}let[m,a,i]=B(n,t);if(t+=i,t>=n.length){r+="%";break}let c=n[t],o;switch(c){case"f":o=s.name,t++;break;case"h":{let h=s.path.lastIndexOf("/");o=h>0?s.path.slice(0,h):".",t++;break}case"p":o=s.path,t++;break;case"P":{let h=s.startingPoint;s.path===h?o="":s.path.startsWith(`${h}/`)?o=s.path.slice(h.length+1):h==="."&&s.path.startsWith("./")?o=s.path.slice(2):o=s.path,t++;break}case"s":o=String(s.size),t++;break;case"d":o=String(s.depth),t++;break;case"m":o=(s.mode&511).toString(8),t++;break;case"M":o=Q(s.mode,s.isDirectory),t++;break;case"t":{let h=new Date(s.mtime);o=X(h),t++;break}case"T":{if(t+1<n.length){let h=n[t+1],b=new Date(s.mtime);o=Z(b,h),t+=2}else o="%T",t++;break}default:r+=`%${m!==0||a!==-1?`${m}.${a}`:""}${c}`,t++;continue}r+=L(o,m,a)}else r+=n[t],t++;return r}function Q(e,s){let n=e&511,r=s?"d":"-";return r+=n&256?"r":"-",r+=n&128?"w":"-",r+=n&64?"x":"-",r+=n&32?"r":"-",r+=n&16?"w":"-",r+=n&8?"x":"-",r+=n&4?"r":"-",r+=n&2?"w":"-",r+=n&1?"x":"-",r}function X(e){let s=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=s[e.getDay()],t=n[e.getMonth()],m=String(e.getDate()).padStart(2," "),a=String(e.getHours()).padStart(2,"0"),i=String(e.getMinutes()).padStart(2,"0"),c=String(e.getSeconds()).padStart(2,"0"),o=e.getFullYear();return`${r} ${t} ${m} ${a}:${i}:${c} ${o}`}function Z(e,s){switch(s){case"@":return String(e.getTime()/1e3);case"Y":return String(e.getFullYear());case"m":return String(e.getMonth()+1).padStart(2,"0");case"d":return String(e.getDate()).padStart(2,"0");case"H":return String(e.getHours()).padStart(2,"0");case"M":return String(e.getMinutes()).padStart(2,"0");case"S":return String(e.getSeconds()).padStart(2,"0");case"T":return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}`;case"F":return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`;default:return`%T${s}`}}export{oe as findCommand};
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as N}from"./chunk-26Q3PZQ6.js";import{a as L,b as B,c as H}from"./chunk-6QUZ7QML.js";import{a as I,b as O}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";function w(e,s){switch(e.type){case"name":return{matches:N(s.name,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"path":return{matches:N(s.relativePath,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"regex":try{let n=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,n).test(s.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:s.isEmpty,pruned:!1,printed:!1};case"mtime":{let r=(Date.now()-s.mtime)/(1e3*60*60*24),t;return e.comparison==="more"?t=r>e.days:e.comparison==="less"?t=r<e.days:t=Math.floor(r)===e.days,{matches:t,pruned:!1,printed:!1}}case"newer":{let n=s.newerRefTimes.get(e.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:s.mtime>n,pruned:!1,printed:!1}}case"size":{let n=e.value;switch(e.unit){case"c":n=e.value;break;case"k":n=e.value*1024;break;case"M":n=e.value*1024*1024;break;case"G":n=e.value*1024*1024*1024;break;case"b":n=e.value*512;break}let r;return e.comparison==="more"?r=s.size>n:e.comparison==="less"?r=s.size<n:e.unit==="b"?r=Math.ceil(s.size/512)===e.value:r=s.size===n,{matches:r,pruned:!1,printed:!1}}case"perm":{let n=s.mode&511,r=e.mode&511,t;return e.matchType==="exact"?t=n===r:e.matchType==="all"?t=(n&r)===r:t=(n&r)!==0,{matches:t,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let n=w(e.expr,s);return{matches:!n.matches,pruned:n.pruned,printed:!1}}case"and":{let n=w(e.left,s);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1};let r=w(e.right,s);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:n.printed||r.printed}}case"or":{let n=w(e.left,s);if(n.matches)return n;let r=w(e.right,s);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:r.printed}}}}function G(e){let s=[],n=r=>{r&&(r.type==="newer"?s.push(r.refPath):r.type==="not"?n(r.expr):(r.type==="and"||r.type==="or")&&(n(r.left),n(r.right)))};return n(e),s}function j(e,s){let n=[],r=[],t=s;for(;t<e.length;){let a=e[t];if(a==="("||a==="\\("){n.push({type:"lparen"}),t++;continue}if(a===")"||a==="\\)"){n.push({type:"rparen"}),t++;continue}if(a==="-name"&&t+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++t]}});else if(a==="-iname"&&t+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++t],ignoreCase:!0}});else if(a==="-path"&&t+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++t]}});else if(a==="-ipath"&&t+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++t],ignoreCase:!0}});else if(a==="-regex"&&t+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++t]}});else if(a==="-iregex"&&t+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++t],ignoreCase:!0}});else if(a==="-type"&&t+1<e.length){let i=e[++t];if(i==="f"||i==="d")n.push({type:"expr",expr:{type:"type",fileType:i}});else return{expr:null,pathIndex:t,error:`find: Unknown argument to -type: ${i}
3
- `,actions:[]}}else if(a==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(a==="-mtime"&&t+1<e.length){let i=e[++t],c="exact",o=i;i.startsWith("+")?(c="more",o=i.slice(1)):i.startsWith("-")&&(c="less",o=i.slice(1));let h=parseInt(o,10);Number.isNaN(h)||n.push({type:"expr",expr:{type:"mtime",days:h,comparison:c}})}else if(a==="-newer"&&t+1<e.length){let i=e[++t];n.push({type:"expr",expr:{type:"newer",refPath:i}})}else if(a==="-size"&&t+1<e.length){let i=e[++t],c="exact",o=i;i.startsWith("+")?(c="more",o=i.slice(1)):i.startsWith("-")&&(c="less",o=i.slice(1));let h=o.match(/^(\d+)([ckMGb])?$/);if(h){let b=parseInt(h[1],10),y=h[2]||"b";n.push({type:"expr",expr:{type:"size",value:b,unit:y,comparison:c}})}}else if(a==="-perm"&&t+1<e.length){let i=e[++t],c="exact",o=i;i.startsWith("-")?(c="all",o=i.slice(1)):i.startsWith("/")&&(c="any",o=i.slice(1));let h=parseInt(o,8);Number.isNaN(h)||n.push({type:"expr",expr:{type:"perm",mode:h,matchType:c}})}else if(a==="-prune")n.push({type:"expr",expr:{type:"prune"}});else if(a==="-not"||a==="!")n.push({type:"not"});else if(a==="-o"||a==="-or")n.push({type:"op",op:"or"});else if(a==="-a"||a==="-and")n.push({type:"op",op:"and"});else if(a==="-maxdepth"||a==="-mindepth")t++;else if(a!=="-depth")if(a==="-exec"){let i=[];for(t++;t<e.length&&e[t]!==";"&&e[t]!=="+";)i.push(e[t]),t++;if(t>=e.length)return{expr:null,pathIndex:t,error:"find: missing argument to `-exec'\n",actions:[]};let c=e[t]==="+";r.push({type:"exec",command:i,batchMode:c})}else if(a==="-print")n.push({type:"expr",expr:{type:"print"}}),r.push({type:"print"});else if(a==="-print0")r.push({type:"print0"});else if(a==="-printf"&&t+1<e.length){let i=e[++t];r.push({type:"printf",format:i})}else if(a==="-delete")r.push({type:"delete"});else{if(a.startsWith("-"))return{expr:null,pathIndex:t,error:`find: unknown predicate '${a}'
4
- `,actions:[]};if(n.length===0){t++;continue}break}t++}if(n.length===0)return{expr:null,pathIndex:t,actions:r};let m=_(n);return m.error?{expr:null,pathIndex:t,error:m.error,actions:r}:{expr:m.expr,pathIndex:t,actions:r}}function _(e){let s=0;function n(){let i=r();if(!i)return null;for(;s<e.length;){let c=e[s];if(c.type==="op"&&c.op==="or"){s++;let o=r();if(!o)return i;i={type:"or",left:i,right:o}}else break}return i}function r(){let i=t();if(!i)return null;for(;s<e.length;){let c=e[s];if(c.type==="op"&&c.op==="and"){s++;let o=t();if(!o)return i;i={type:"and",left:i,right:o}}else if(c.type==="expr"||c.type==="not"||c.type==="lparen"){let o=t();if(!o)return i;i={type:"and",left:i,right:o}}else break}return i}function t(){if(s<e.length&&e[s].type==="not"){s++;let i=t();return i?{type:"not",expr:i}:null}return m()}function m(){if(s>=e.length)return null;let i=e[s];if(i.type==="lparen"){s++;let c=n();return s<e.length&&e[s].type==="rparen"&&s++,c}return i.type==="expr"?(s++,i.expr):(i.type==="rparen",null)}return{expr:n()}}var K={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-regex PATTERN file path matches regular expression PATTERN","-iregex PATTERN like -regex but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-depth process directory contents before directory itself","-prune do not descend into this directory","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-printf FORMAT print FORMAT with directives: %f %h %p %P %s %d %m %M %t","-delete delete found files/directories"," --help display this help and exit"]},U=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),oe={name:"find",async execute(e,s){if(O(e))return I(K);let n=[],r=null,t=null,m=!1,a=!1;for(let p=0;p<e.length;p++){let l=e[p];if(l==="-maxdepth"&&p+1<e.length)a=!0,r=parseInt(e[++p],10);else if(l==="-mindepth"&&p+1<e.length)a=!0,t=parseInt(e[++p],10);else if(l==="-depth")a=!0,m=!0;else if(l==="-exec")for(a=!0,p++;p<e.length&&e[p]!==";"&&e[p]!=="+";)p++;else!l.startsWith("-")&&l!==";"&&l!=="+"&&l!=="("&&l!==")"&&l!=="\\("&&l!=="\\)"&&l!=="!"?a||n.push(l):U.has(l)?(a=!0,p++):(l.startsWith("-")||l==="("||l==="\\("||l==="!")&&(a=!0)}n.length===0&&n.push(".");let{expr:i,error:c,actions:o}=j(e,0);if(c)return{stdout:"",stderr:c,exitCode:1};let h=o.some(p=>p.type==="print"),b=o.length===0,y=[],Y=o.some(p=>p.type==="printf"),F=[],T="",D=0,V=G(i),k=new Map;for(let p of V){let l=s.fs.resolvePath(s.cwd,p);try{let g=await s.fs.stat(l);k.set(p,g.mtime?.getTime()??Date.now())}catch{}}for(let p of n){let l=s.fs.resolvePath(s.cwd,p);try{await s.fs.stat(l)}catch{T+=`find: ${p}: No such file or directory
5
- `,D=1;continue}async function g(u,d){if(r!==null&&d>r)return;let f;try{f=await s.fs.stat(u)}catch{return}if(!f)return;let E;u===l?E=p.split("/").pop()||p:E=u.split("/").pop()||"";let $=u===l?p:p==="."?`./${u.slice(l.length+1)}`:p+u.slice(l.length),M=null;f.isDirectory&&(M=await s.fs.readdir(u));let R=f.isFile?f.size===0:M!==null&&M.length===0,C=()=>{let x=t===null||d>=t,v=!1;if(x&&i!==null){let J={name:E,relativePath:$,isFile:f.isFile,isDirectory:f.isDirectory,isEmpty:R,mtime:f.mtime?.getTime()??Date.now(),size:f.size??0,mode:f.mode??420,newerRefTimes:k},W=w(i,J);x=W.matches,h?v=W.printed:v=x}else x&&(v=!0);v&&(y.push($),Y&&F.push({path:$,name:E,size:f.size??0,mtime:f.mtime?.getTime()??Date.now(),mode:f.mode??420,isDirectory:f.isDirectory,depth:d,startingPoint:p}))},A=async()=>{if(M!==null)for(let P of M){let x=u==="/"?`/${P}`:`${u}/${P}`;await g(x,d+1)}},z=!1;if(!m&&i!==null){let P={name:E,relativePath:$,isFile:f.isFile,isDirectory:f.isDirectory,isEmpty:R,mtime:f.mtime?.getTime()??Date.now(),size:f.size??0,mode:f.mode??420,newerRefTimes:k};z=w(i,P).pruned}m?(await A(),C()):(C(),z||await A())}await g(l,0)}let S="";if(o.length>0)for(let p of o)switch(p.type){case"print":S+=y.length>0?`${y.join(`
6
- `)}
7
- `:"";break;case"print0":S+=y.length>0?`${y.join("\0")}\0`:"";break;case"delete":{let l=[...y].sort((g,u)=>u.length-g.length);for(let g of l){let u=s.fs.resolvePath(s.cwd,g);try{await s.fs.rm(u,{recursive:!1})}catch(d){let f=d instanceof Error?d.message:String(d);T+=`find: cannot delete '${g}': ${f}
8
- `,D=1}}break}case"printf":for(let l of F)S+=q(p.format,l);break;case"exec":if(!s.exec)return{stdout:"",stderr:`find: -exec not supported in this context
9
- `,exitCode:1};if(p.batchMode){let l=[];for(let d of p.command)d==="{}"?l.push(...y):l.push(d);let g=l.map(d=>`"${d}"`).join(" "),u=await s.exec(g,{cwd:s.cwd});S+=u.stdout,T+=u.stderr,u.exitCode!==0&&(D=u.exitCode)}else for(let l of y){let u=p.command.map(f=>f==="{}"?l:f).map(f=>`"${f}"`).join(" "),d=await s.exec(u,{cwd:s.cwd});S+=d.stdout,T+=d.stderr,d.exitCode!==0&&(D=d.exitCode)}break}else b&&(S=y.length>0?`${y.join(`
10
- `)}
11
- `:"");return{stdout:S,stderr:T,exitCode:D}}};function q(e,s){let n=H(e),r="",t=0;for(;t<n.length;)if(n[t]==="%"&&t+1<n.length){if(t++,n[t]==="%"){r+="%",t++;continue}let[m,a,i]=B(n,t);if(t+=i,t>=n.length){r+="%";break}let c=n[t],o;switch(c){case"f":o=s.name,t++;break;case"h":{let h=s.path.lastIndexOf("/");o=h>0?s.path.slice(0,h):".",t++;break}case"p":o=s.path,t++;break;case"P":{let h=s.startingPoint;s.path===h?o="":s.path.startsWith(`${h}/`)?o=s.path.slice(h.length+1):h==="."&&s.path.startsWith("./")?o=s.path.slice(2):o=s.path,t++;break}case"s":o=String(s.size),t++;break;case"d":o=String(s.depth),t++;break;case"m":o=(s.mode&511).toString(8),t++;break;case"M":o=Q(s.mode,s.isDirectory),t++;break;case"t":{let h=new Date(s.mtime);o=X(h),t++;break}case"T":{if(t+1<n.length){let h=n[t+1],b=new Date(s.mtime);o=Z(b,h),t+=2}else o="%T",t++;break}default:r+=`%${m!==0||a!==-1?`${m}.${a}`:""}${c}`,t++;continue}r+=L(o,m,a)}else r+=n[t],t++;return r}function Q(e,s){let n=e&511,r=s?"d":"-";return r+=n&256?"r":"-",r+=n&128?"w":"-",r+=n&64?"x":"-",r+=n&32?"r":"-",r+=n&16?"w":"-",r+=n&8?"x":"-",r+=n&4?"r":"-",r+=n&2?"w":"-",r+=n&1?"x":"-",r}function X(e){let s=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=s[e.getDay()],t=n[e.getMonth()],m=String(e.getDate()).padStart(2," "),a=String(e.getHours()).padStart(2,"0"),i=String(e.getMinutes()).padStart(2,"0"),c=String(e.getSeconds()).padStart(2,"0"),o=e.getFullYear();return`${r} ${t} ${m} ${a}:${i}:${c} ${o}`}function Z(e,s){switch(s){case"@":return String(e.getTime()/1e3);case"Y":return String(e.getFullYear());case"m":return String(e.getMonth()+1).padStart(2,"0");case"d":return String(e.getDate()).padStart(2,"0");case"H":return String(e.getHours()).padStart(2,"0");case"M":return String(e.getMinutes()).padStart(2,"0");case"S":return String(e.getSeconds()).padStart(2,"0");case"T":return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}`;case"F":return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`;default:return`%T${s}`}}export{oe as findCommand};
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as k}from"./chunk-26Q3PZQ6.js";import{a as $,b as S}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";function g(e,s){switch(e.type){case"name":return{matches:k(s.name,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"path":return{matches:k(s.relativePath,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"regex":try{let t=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,t).test(s.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:s.isEmpty,pruned:!1,printed:!1};case"mtime":{let r=(Date.now()-s.mtime)/(1e3*60*60*24),n;return e.comparison==="more"?n=r>e.days:e.comparison==="less"?n=r<e.days:n=Math.floor(r)===e.days,{matches:n,pruned:!1,printed:!1}}case"newer":{let t=s.newerRefTimes.get(e.refPath);return t===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:s.mtime>t,pruned:!1,printed:!1}}case"size":{let t=e.value;switch(e.unit){case"c":t=e.value;break;case"k":t=e.value*1024;break;case"M":t=e.value*1024*1024;break;case"G":t=e.value*1024*1024*1024;break;case"b":t=e.value*512;break}let r;return e.comparison==="more"?r=s.size>t:e.comparison==="less"?r=s.size<t:e.unit==="b"?r=Math.ceil(s.size/512)===e.value:r=s.size===t,{matches:r,pruned:!1,printed:!1}}case"perm":{let t=s.mode&511,r=e.mode&511,n;return e.matchType==="exact"?n=t===r:e.matchType==="all"?n=(t&r)===r:n=(t&r)!==0,{matches:n,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let t=g(e.expr,s);return{matches:!t.matches,pruned:t.pruned,printed:!1}}case"and":{let t=g(e.left,s);if(!t.matches)return{matches:!1,pruned:t.pruned,printed:!1};let r=g(e.right,s);return{matches:r.matches,pruned:t.pruned||r.pruned,printed:t.printed||r.printed}}case"or":{let t=g(e.left,s);if(t.matches)return t;let r=g(e.right,s);return{matches:r.matches,pruned:t.pruned||r.pruned,printed:r.printed}}}}function L(e){let s=[],t=r=>{r&&(r.type==="newer"?s.push(r.refPath):r.type==="not"?t(r.expr):(r.type==="and"||r.type==="or")&&(t(r.left),t(r.right)))};return t(e),s}function O(e,s){let t=[],r=[],n=s;for(;n<e.length;){let l=e[n];if(l==="("||l==="\\("){t.push({type:"lparen"}),n++;continue}if(l===")"||l==="\\)"){t.push({type:"rparen"}),n++;continue}if(l==="-name"&&n+1<e.length)t.push({type:"expr",expr:{type:"name",pattern:e[++n]}});else if(l==="-iname"&&n+1<e.length)t.push({type:"expr",expr:{type:"name",pattern:e[++n],ignoreCase:!0}});else if(l==="-path"&&n+1<e.length)t.push({type:"expr",expr:{type:"path",pattern:e[++n]}});else if(l==="-ipath"&&n+1<e.length)t.push({type:"expr",expr:{type:"path",pattern:e[++n],ignoreCase:!0}});else if(l==="-regex"&&n+1<e.length)t.push({type:"expr",expr:{type:"regex",pattern:e[++n]}});else if(l==="-iregex"&&n+1<e.length)t.push({type:"expr",expr:{type:"regex",pattern:e[++n],ignoreCase:!0}});else if(l==="-type"&&n+1<e.length){let i=e[++n];if(i==="f"||i==="d")t.push({type:"expr",expr:{type:"type",fileType:i}});else return{expr:null,pathIndex:n,error:`find: Unknown argument to -type: ${i}
3
- `,actions:[]}}else if(l==="-empty")t.push({type:"expr",expr:{type:"empty"}});else if(l==="-mtime"&&n+1<e.length){let i=e[++n],o="exact",f=i;i.startsWith("+")?(o="more",f=i.slice(1)):i.startsWith("-")&&(o="less",f=i.slice(1));let y=parseInt(f,10);Number.isNaN(y)||t.push({type:"expr",expr:{type:"mtime",days:y,comparison:o}})}else if(l==="-newer"&&n+1<e.length){let i=e[++n];t.push({type:"expr",expr:{type:"newer",refPath:i}})}else if(l==="-size"&&n+1<e.length){let i=e[++n],o="exact",f=i;i.startsWith("+")?(o="more",f=i.slice(1)):i.startsWith("-")&&(o="less",f=i.slice(1));let y=f.match(/^(\d+)([ckMGb])?$/);if(y){let N=parseInt(y[1],10),d=y[2]||"b";t.push({type:"expr",expr:{type:"size",value:N,unit:d,comparison:o}})}}else if(l==="-perm"&&n+1<e.length){let i=e[++n],o="exact",f=i;i.startsWith("-")?(o="all",f=i.slice(1)):i.startsWith("/")&&(o="any",f=i.slice(1));let y=parseInt(f,8);Number.isNaN(y)||t.push({type:"expr",expr:{type:"perm",mode:y,matchType:o}})}else if(l==="-prune")t.push({type:"expr",expr:{type:"prune"}});else if(l==="-not"||l==="!")t.push({type:"not"});else if(l==="-o"||l==="-or")t.push({type:"op",op:"or"});else if(l==="-a"||l==="-and")t.push({type:"op",op:"and"});else if(l==="-maxdepth"||l==="-mindepth")n++;else if(l!=="-depth")if(l==="-exec"){let i=[];for(n++;n<e.length&&e[n]!==";"&&e[n]!=="+";)i.push(e[n]),n++;if(n>=e.length)return{expr:null,pathIndex:n,error:"find: missing argument to `-exec'\n",actions:[]};let o=e[n]==="+";r.push({type:"exec",command:i,batchMode:o})}else if(l==="-print")t.push({type:"expr",expr:{type:"print"}}),r.push({type:"print"});else if(l==="-print0")r.push({type:"print0"});else if(l==="-delete")r.push({type:"delete"});else{if(l.startsWith("-"))return{expr:null,pathIndex:n,error:`find: unknown predicate '${l}'
4
- `,actions:[]};if(t.length===0){n++;continue}break}n++}if(t.length===0)return{expr:null,pathIndex:n,actions:r};let w=j(t);return w.error?{expr:null,pathIndex:n,error:w.error,actions:r}:{expr:w.expr,pathIndex:n,actions:r}}function j(e){let s=0;function t(){let i=r();if(!i)return null;for(;s<e.length;){let o=e[s];if(o.type==="op"&&o.op==="or"){s++;let f=r();if(!f)return i;i={type:"or",left:i,right:f}}else break}return i}function r(){let i=n();if(!i)return null;for(;s<e.length;){let o=e[s];if(o.type==="op"&&o.op==="and"){s++;let f=n();if(!f)return i;i={type:"and",left:i,right:f}}else if(o.type==="expr"||o.type==="not"||o.type==="lparen"){let f=n();if(!f)return i;i={type:"and",left:i,right:f}}else break}return i}function n(){if(s<e.length&&e[s].type==="not"){s++;let i=n();return i?{type:"not",expr:i}:null}return w()}function w(){if(s>=e.length)return null;let i=e[s];if(i.type==="lparen"){s++;let o=t();return s<e.length&&e[s].type==="rparen"&&s++,o}return i.type==="expr"?(s++,i.expr):(i.type==="rparen",null)}return{expr:t()}}var H={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-regex PATTERN file path matches regular expression PATTERN","-iregex PATTERN like -regex but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-depth process directory contents before directory itself","-prune do not descend into this directory","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-delete delete found files/directories"," --help display this help and exit"]},V=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),Q={name:"find",async execute(e,s){if(S(e))return $(H);let t=[],r=null,n=null,w=!1,l=!1;for(let p=0;p<e.length;p++){let a=e[p];if(a==="-maxdepth"&&p+1<e.length)l=!0,r=parseInt(e[++p],10);else if(a==="-mindepth"&&p+1<e.length)l=!0,n=parseInt(e[++p],10);else if(a==="-depth")l=!0,w=!0;else if(a==="-exec")for(l=!0,p++;p<e.length&&e[p]!==";"&&e[p]!=="+";)p++;else!a.startsWith("-")&&a!==";"&&a!=="+"&&a!=="("&&a!==")"&&a!=="\\("&&a!=="\\)"&&a!=="!"?l||t.push(a):V.has(a)?(l=!0,p++):(a.startsWith("-")||a==="("||a==="\\("||a==="!")&&(l=!0)}t.length===0&&t.push(".");let{expr:i,error:o,actions:f}=O(e,0);if(o)return{stdout:"",stderr:o,exitCode:1};let y=f.some(p=>p.type==="print"),N=f.length===0,d=[],b="",T=0,B=L(i),C=new Map;for(let p of B){let a=s.fs.resolvePath(s.cwd,p);try{let m=await s.fs.stat(a);C.set(p,m.mtime?.getTime()??Date.now())}catch{}}for(let p of t){let a=s.fs.resolvePath(s.cwd,p);try{await s.fs.stat(a)}catch{b+=`find: ${p}: No such file or directory
5
- `,T=1;continue}async function m(u,h){if(r!==null&&h>r)return;let c;try{c=await s.fs.stat(u)}catch{return}if(!c)return;let v;u===a?v=p.split("/").pop()||p:v=u.split("/").pop()||"";let R=u===a?p:p==="."?`./${u.slice(a.length+1)}`:p+u.slice(a.length),D=null;c.isDirectory&&(D=await s.fs.readdir(u));let z=c.isFile?c.size===0:D!==null&&D.length===0,A=()=>{let x=n===null||h>=n,M=!1;if(x&&i!==null){let G={name:v,relativePath:R,isFile:c.isFile,isDirectory:c.isDirectory,isEmpty:z,mtime:c.mtime?.getTime()??Date.now(),size:c.size??0,mode:c.mode??420,newerRefTimes:C},W=g(i,G);x=W.matches,y?M=W.printed:M=x}else x&&(M=!0);M&&d.push(R)},F=async()=>{if(D!==null)for(let P of D){let x=u==="/"?`/${P}`:`${u}/${P}`;await m(x,h+1)}},I=!1;if(!w&&i!==null){let P={name:v,relativePath:R,isFile:c.isFile,isDirectory:c.isDirectory,isEmpty:z,mtime:c.mtime?.getTime()??Date.now(),size:c.size??0,mode:c.mode??420,newerRefTimes:C};I=g(i,P).pruned}w?(await F(),A()):(A(),I||await F())}await m(a,0)}let E="";if(f.length>0)for(let p of f)switch(p.type){case"print":E+=d.length>0?`${d.join(`
6
- `)}
7
- `:"";break;case"print0":E+=d.length>0?`${d.join("\0")}\0`:"";break;case"delete":{let a=[...d].sort((m,u)=>u.length-m.length);for(let m of a){let u=s.fs.resolvePath(s.cwd,m);try{await s.fs.rm(u,{recursive:!1})}catch(h){let c=h instanceof Error?h.message:String(h);b+=`find: cannot delete '${m}': ${c}
8
- `,T=1}}break}case"exec":if(!s.exec)return{stdout:"",stderr:`find: -exec not supported in this context
9
- `,exitCode:1};if(p.batchMode){let a=[];for(let h of p.command)h==="{}"?a.push(...d):a.push(h);let m=a.map(h=>`"${h}"`).join(" "),u=await s.exec(m,{cwd:s.cwd});E+=u.stdout,b+=u.stderr,u.exitCode!==0&&(T=u.exitCode)}else for(let a of d){let u=p.command.map(c=>c==="{}"?a:c).map(c=>`"${c}"`).join(" "),h=await s.exec(u,{cwd:s.cwd});E+=h.stdout,b+=h.stderr,h.exitCode!==0&&(T=h.exitCode)}break}else N&&(E=d.length>0?`${d.join(`
10
- `)}
11
- `:"");return{stdout:E,stderr:b,exitCode:T}}};export{Q as findCommand};
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as N}from"./chunk-26Q3PZQ6.js";import{a as A,b as z}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";function g(e,s){switch(e.type){case"name":return{matches:N(s.name,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"path":return{matches:N(s.relativePath,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"regex":try{let t=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,t).test(s.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:s.isEmpty,pruned:!1,printed:!1};case"mtime":{let r=(Date.now()-s.mtime)/(1e3*60*60*24),n;return e.comparison==="more"?n=r>e.days:e.comparison==="less"?n=r<e.days:n=Math.floor(r)===e.days,{matches:n,pruned:!1,printed:!1}}case"newer":{let t=s.newerRefTimes.get(e.refPath);return t===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:s.mtime>t,pruned:!1,printed:!1}}case"size":{let t=e.value;switch(e.unit){case"c":t=e.value;break;case"k":t=e.value*1024;break;case"M":t=e.value*1024*1024;break;case"G":t=e.value*1024*1024*1024;break;case"b":t=e.value*512;break}let r;return e.comparison==="more"?r=s.size>t:e.comparison==="less"?r=s.size<t:e.unit==="b"?r=Math.ceil(s.size/512)===e.value:r=s.size===t,{matches:r,pruned:!1,printed:!1}}case"perm":{let t=s.mode&511,r=e.mode&511,n;return e.matchType==="exact"?n=t===r:e.matchType==="all"?n=(t&r)===r:n=(t&r)!==0,{matches:n,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let t=g(e.expr,s);return{matches:!t.matches,pruned:t.pruned,printed:!1}}case"and":{let t=g(e.left,s);if(!t.matches)return{matches:!1,pruned:t.pruned,printed:!1};let r=g(e.right,s);return{matches:r.matches,pruned:t.pruned||r.pruned,printed:t.printed||r.printed}}case"or":{let t=g(e.left,s);if(t.matches)return t;let r=g(e.right,s);return{matches:r.matches,pruned:t.pruned||r.pruned,printed:r.printed}}}}function I(e){let s=[],t=r=>{r&&(r.type==="newer"?s.push(r.refPath):r.type==="not"?t(r.expr):(r.type==="and"||r.type==="or")&&(t(r.left),t(r.right)))};return t(e),s}function $(e,s){let t=[],r=[],n=s;for(;n<e.length;){let l=e[n];if(l==="("||l==="\\("){t.push({type:"lparen"}),n++;continue}if(l===")"||l==="\\)"){t.push({type:"rparen"}),n++;continue}if(l==="-name"&&n+1<e.length)t.push({type:"expr",expr:{type:"name",pattern:e[++n]}});else if(l==="-iname"&&n+1<e.length)t.push({type:"expr",expr:{type:"name",pattern:e[++n],ignoreCase:!0}});else if(l==="-path"&&n+1<e.length)t.push({type:"expr",expr:{type:"path",pattern:e[++n]}});else if(l==="-ipath"&&n+1<e.length)t.push({type:"expr",expr:{type:"path",pattern:e[++n],ignoreCase:!0}});else if(l==="-regex"&&n+1<e.length)t.push({type:"expr",expr:{type:"regex",pattern:e[++n]}});else if(l==="-iregex"&&n+1<e.length)t.push({type:"expr",expr:{type:"regex",pattern:e[++n],ignoreCase:!0}});else if(l==="-type"&&n+1<e.length){let i=e[++n];if(i==="f"||i==="d")t.push({type:"expr",expr:{type:"type",fileType:i}});else return{expr:null,pathIndex:n,error:`find: Unknown argument to -type: ${i}
3
- `,actions:[]}}else if(l==="-empty")t.push({type:"expr",expr:{type:"empty"}});else if(l==="-mtime"&&n+1<e.length){let i=e[++n],p="exact",f=i;i.startsWith("+")?(p="more",f=i.slice(1)):i.startsWith("-")&&(p="less",f=i.slice(1));let u=parseInt(f,10);Number.isNaN(u)||t.push({type:"expr",expr:{type:"mtime",days:u,comparison:p}})}else if(l==="-newer"&&n+1<e.length){let i=e[++n];t.push({type:"expr",expr:{type:"newer",refPath:i}})}else if(l==="-size"&&n+1<e.length){let i=e[++n],p="exact",f=i;i.startsWith("+")?(p="more",f=i.slice(1)):i.startsWith("-")&&(p="less",f=i.slice(1));let u=f.match(/^(\d+)([ckMGb])?$/);if(u){let m=parseInt(u[1],10),v=u[2]||"b";t.push({type:"expr",expr:{type:"size",value:m,unit:v,comparison:p}})}}else if(l==="-perm"&&n+1<e.length){let i=e[++n],p="exact",f=i;i.startsWith("-")?(p="all",f=i.slice(1)):i.startsWith("/")&&(p="any",f=i.slice(1));let u=parseInt(f,8);Number.isNaN(u)||t.push({type:"expr",expr:{type:"perm",mode:u,matchType:p}})}else if(l==="-prune")t.push({type:"expr",expr:{type:"prune"}});else if(l==="-not"||l==="!")t.push({type:"not"});else if(l==="-o"||l==="-or")t.push({type:"op",op:"or"});else if(l==="-a"||l==="-and")t.push({type:"op",op:"and"});else if(l==="-maxdepth"||l==="-mindepth")n++;else if(l==="-exec"){let i=[];for(n++;n<e.length&&e[n]!==";"&&e[n]!=="+";)i.push(e[n]),n++;if(n>=e.length)return{expr:null,pathIndex:n,error:"find: missing argument to `-exec'\n",actions:[]};let p=e[n]==="+";r.push({type:"exec",command:i,batchMode:p})}else if(l==="-print")t.push({type:"expr",expr:{type:"print"}}),r.push({type:"print"});else if(l==="-print0")r.push({type:"print0"});else if(l==="-delete")r.push({type:"delete"});else{if(l.startsWith("-"))return{expr:null,pathIndex:n,error:`find: unknown predicate '${l}'
4
- `,actions:[]};if(t.length===0){n++;continue}break}n++}if(t.length===0)return{expr:null,pathIndex:n,actions:r};let w=S(t);return w.error?{expr:null,pathIndex:n,error:w.error,actions:r}:{expr:w.expr,pathIndex:n,actions:r}}function S(e){let s=0;function t(){let i=r();if(!i)return null;for(;s<e.length;){let p=e[s];if(p.type==="op"&&p.op==="or"){s++;let f=r();if(!f)return i;i={type:"or",left:i,right:f}}else break}return i}function r(){let i=n();if(!i)return null;for(;s<e.length;){let p=e[s];if(p.type==="op"&&p.op==="and"){s++;let f=n();if(!f)return i;i={type:"and",left:i,right:f}}else if(p.type==="expr"||p.type==="not"||p.type==="lparen"){let f=n();if(!f)return i;i={type:"and",left:i,right:f}}else break}return i}function n(){if(s<e.length&&e[s].type==="not"){s++;let i=n();return i?{type:"not",expr:i}:null}return w()}function w(){if(s>=e.length)return null;let i=e[s];if(i.type==="lparen"){s++;let p=t();return s<e.length&&e[s].type==="rparen"&&s++,p}return i.type==="expr"?(s++,i.expr):(i.type==="rparen",null)}return{expr:t()}}var F={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-regex PATTERN file path matches regular expression PATTERN","-iregex PATTERN like -regex but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-prune do not descend into this directory","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-delete delete found files/directories"," --help display this help and exit"]},L=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),K={name:"find",async execute(e,s){if(z(e))return A(F);let t=".",r=null,n=null;for(let a=0;a<e.length;a++){let o=e[a];if(o==="-maxdepth"&&a+1<e.length)r=parseInt(e[++a],10);else if(o==="-mindepth"&&a+1<e.length)n=parseInt(e[++a],10);else if(o==="-exec")for(a++;a<e.length&&e[a]!==";"&&e[a]!=="+";)a++;else!o.startsWith("-")&&o!==";"&&o!=="+"&&o!=="("&&o!==")"&&o!=="\\("&&o!=="\\)"?t=o:L.has(o)&&a++}let{expr:w,error:l,actions:i}=$(e,0);if(l)return{stdout:"",stderr:l,exitCode:1};let p=i.some(a=>a.type==="print"),f=i.length===0,u=s.fs.resolvePath(s.cwd,t);try{await s.fs.stat(u)}catch{return{stdout:"",stderr:`find: ${t}: No such file or directory
5
- `,exitCode:1}}let m=[],v=I(w),C=new Map;for(let a of v){let o=s.fs.resolvePath(s.cwd,a);try{let c=await s.fs.stat(o);C.set(a,c.mtime?.getTime()??Date.now())}catch{}}async function R(a,o){if(r!==null&&o>r)return;let c;try{c=await s.fs.stat(a)}catch{return}if(!c)return;let d;a===u?d=t.split("/").pop()||t:d=a.split("/").pop()||"";let h=a===u?t:t==="."?`./${a.slice(u.length+1)}`:t+a.slice(u.length),y=null;c.isDirectory&&(y=await s.fs.readdir(a));let W=c.isFile?c.size===0:y!==null&&y.length===0,P=n===null||o>=n,k=!1,D=!1;if(P&&w!==null){let M={name:d,relativePath:h,isFile:c.isFile,isDirectory:c.isDirectory,isEmpty:W,mtime:c.mtime?.getTime()??Date.now(),size:c.size??0,mode:c.mode??420,newerRefTimes:C},E=g(w,M);P=E.matches,k=E.pruned,p?D=E.printed:D=P}else P&&(D=!0);if(D&&m.push(h),y!==null&&!k)for(let M of y){let E=a==="/"?`/${M}`:`${a}/${M}`;await R(E,o+1)}}await R(u,0);let x="",b="",T=0;if(i.length>0)for(let a of i)switch(a.type){case"print":x+=m.length>0?`${m.join(`
6
- `)}
7
- `:"";break;case"print0":x+=m.length>0?`${m.join("\0")}\0`:"";break;case"delete":{let o=[...m].sort((c,d)=>d.length-c.length);for(let c of o){let d=s.fs.resolvePath(s.cwd,c);try{await s.fs.rm(d,{recursive:!1})}catch(h){let y=h instanceof Error?h.message:String(h);b+=`find: cannot delete '${c}': ${y}
8
- `,T=1}}break}case"exec":if(!s.exec)return{stdout:"",stderr:`find: -exec not supported in this context
9
- `,exitCode:1};if(a.batchMode){let o=[];for(let h of a.command)h==="{}"?o.push(...m):o.push(h);let c=o.map(h=>`"${h}"`).join(" "),d=await s.exec(c,{cwd:s.cwd});x+=d.stdout,b+=d.stderr,d.exitCode!==0&&(T=d.exitCode)}else for(let o of m){let d=a.command.map(y=>y==="{}"?o:y).map(y=>`"${y}"`).join(" "),h=await s.exec(d,{cwd:s.cwd});x+=h.stdout,b+=h.stderr,h.exitCode!==0&&(T=h.exitCode)}break}else f&&(x=m.length>0?`${m.join(`
10
- `)}
11
- `:"");return{stdout:x,stderr:b,exitCode:T}}};export{K as findCommand};
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as N}from"./chunk-26Q3PZQ6.js";import{a as A,b as z}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";function x(e,s){switch(e.type){case"name":return{matches:N(s.name,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"path":return{matches:N(s.relativePath,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"regex":try{let t=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,t).test(s.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:s.isEmpty,pruned:!1,printed:!1};case"mtime":{let r=(Date.now()-s.mtime)/(1e3*60*60*24),n;return e.comparison==="more"?n=r>e.days:e.comparison==="less"?n=r<e.days:n=Math.floor(r)===e.days,{matches:n,pruned:!1,printed:!1}}case"newer":{let t=s.newerRefTimes.get(e.refPath);return t===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:s.mtime>t,pruned:!1,printed:!1}}case"size":{let t=e.value;switch(e.unit){case"c":t=e.value;break;case"k":t=e.value*1024;break;case"M":t=e.value*1024*1024;break;case"G":t=e.value*1024*1024*1024;break;case"b":t=e.value*512;break}let r;return e.comparison==="more"?r=s.size>t:e.comparison==="less"?r=s.size<t:e.unit==="b"?r=Math.ceil(s.size/512)===e.value:r=s.size===t,{matches:r,pruned:!1,printed:!1}}case"perm":{let t=s.mode&511,r=e.mode&511,n;return e.matchType==="exact"?n=t===r:e.matchType==="all"?n=(t&r)===r:n=(t&r)!==0,{matches:n,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let t=x(e.expr,s);return{matches:!t.matches,pruned:t.pruned,printed:!1}}case"and":{let t=x(e.left,s);if(!t.matches)return{matches:!1,pruned:t.pruned,printed:!1};let r=x(e.right,s);return{matches:r.matches,pruned:t.pruned||r.pruned,printed:t.printed||r.printed}}case"or":{let t=x(e.left,s);if(t.matches)return t;let r=x(e.right,s);return{matches:r.matches,pruned:t.pruned||r.pruned,printed:r.printed}}}}function I(e){let s=[],t=r=>{r&&(r.type==="newer"?s.push(r.refPath):r.type==="not"?t(r.expr):(r.type==="and"||r.type==="or")&&(t(r.left),t(r.right)))};return t(e),s}function $(e,s){let t=[],r=[],n=s;for(;n<e.length;){let l=e[n];if(l==="("||l==="\\("){t.push({type:"lparen"}),n++;continue}if(l===")"||l==="\\)"){t.push({type:"rparen"}),n++;continue}if(l==="-name"&&n+1<e.length)t.push({type:"expr",expr:{type:"name",pattern:e[++n]}});else if(l==="-iname"&&n+1<e.length)t.push({type:"expr",expr:{type:"name",pattern:e[++n],ignoreCase:!0}});else if(l==="-path"&&n+1<e.length)t.push({type:"expr",expr:{type:"path",pattern:e[++n]}});else if(l==="-ipath"&&n+1<e.length)t.push({type:"expr",expr:{type:"path",pattern:e[++n],ignoreCase:!0}});else if(l==="-regex"&&n+1<e.length)t.push({type:"expr",expr:{type:"regex",pattern:e[++n]}});else if(l==="-iregex"&&n+1<e.length)t.push({type:"expr",expr:{type:"regex",pattern:e[++n],ignoreCase:!0}});else if(l==="-type"&&n+1<e.length){let i=e[++n];if(i==="f"||i==="d")t.push({type:"expr",expr:{type:"type",fileType:i}});else return{expr:null,pathIndex:n,error:`find: Unknown argument to -type: ${i}
3
- `,actions:[]}}else if(l==="-empty")t.push({type:"expr",expr:{type:"empty"}});else if(l==="-mtime"&&n+1<e.length){let i=e[++n],p="exact",f=i;i.startsWith("+")?(p="more",f=i.slice(1)):i.startsWith("-")&&(p="less",f=i.slice(1));let u=parseInt(f,10);Number.isNaN(u)||t.push({type:"expr",expr:{type:"mtime",days:u,comparison:p}})}else if(l==="-newer"&&n+1<e.length){let i=e[++n];t.push({type:"expr",expr:{type:"newer",refPath:i}})}else if(l==="-size"&&n+1<e.length){let i=e[++n],p="exact",f=i;i.startsWith("+")?(p="more",f=i.slice(1)):i.startsWith("-")&&(p="less",f=i.slice(1));let u=f.match(/^(\d+)([ckMGb])?$/);if(u){let m=parseInt(u[1],10),v=u[2]||"b";t.push({type:"expr",expr:{type:"size",value:m,unit:v,comparison:p}})}}else if(l==="-perm"&&n+1<e.length){let i=e[++n],p="exact",f=i;i.startsWith("-")?(p="all",f=i.slice(1)):i.startsWith("/")&&(p="any",f=i.slice(1));let u=parseInt(f,8);Number.isNaN(u)||t.push({type:"expr",expr:{type:"perm",mode:u,matchType:p}})}else if(l==="-prune")t.push({type:"expr",expr:{type:"prune"}});else if(l==="-not"||l==="!")t.push({type:"not"});else if(l==="-o"||l==="-or")t.push({type:"op",op:"or"});else if(l==="-a"||l==="-and")t.push({type:"op",op:"and"});else if(l==="-maxdepth"||l==="-mindepth")n++;else if(l==="-exec"){let i=[];for(n++;n<e.length&&e[n]!==";"&&e[n]!=="+";)i.push(e[n]),n++;if(n>=e.length)return{expr:null,pathIndex:n,error:"find: missing argument to `-exec'\n",actions:[]};let p=e[n]==="+";r.push({type:"exec",command:i,batchMode:p})}else if(l==="-print")t.push({type:"expr",expr:{type:"print"}}),r.push({type:"print"});else if(l==="-print0")r.push({type:"print0"});else if(l==="-delete")r.push({type:"delete"});else{if(l.startsWith("-"))return{expr:null,pathIndex:n,error:`find: unknown predicate '${l}'
4
- `,actions:[]};if(t.length===0){n++;continue}break}n++}if(t.length===0)return{expr:null,pathIndex:n,actions:r};let g=S(t);return g.error?{expr:null,pathIndex:n,error:g.error,actions:r}:{expr:g.expr,pathIndex:n,actions:r}}function S(e){let s=0;function t(){let i=r();if(!i)return null;for(;s<e.length;){let p=e[s];if(p.type==="op"&&p.op==="or"){s++;let f=r();if(!f)return i;i={type:"or",left:i,right:f}}else break}return i}function r(){let i=n();if(!i)return null;for(;s<e.length;){let p=e[s];if(p.type==="op"&&p.op==="and"){s++;let f=n();if(!f)return i;i={type:"and",left:i,right:f}}else if(p.type==="expr"||p.type==="not"||p.type==="lparen"){let f=n();if(!f)return i;i={type:"and",left:i,right:f}}else break}return i}function n(){if(s<e.length&&e[s].type==="not"){s++;let i=n();return i?{type:"not",expr:i}:null}return g()}function g(){if(s>=e.length)return null;let i=e[s];if(i.type==="lparen"){s++;let p=t();return s<e.length&&e[s].type==="rparen"&&s++,p}return i.type==="expr"?(s++,i.expr):(i.type==="rparen",null)}return{expr:t()}}var F={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-regex PATTERN file path matches regular expression PATTERN","-iregex PATTERN like -regex but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-prune do not descend into this directory","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-delete delete found files/directories"," --help display this help and exit"]},L=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),K={name:"find",async execute(e,s){if(z(e))return A(F);let t=".",r=null,n=null;for(let a=0;a<e.length;a++){let o=e[a];if(o==="-maxdepth"&&a+1<e.length)r=parseInt(e[++a],10);else if(o==="-mindepth"&&a+1<e.length)n=parseInt(e[++a],10);else if(o==="-exec")for(a++;a<e.length&&e[a]!==";"&&e[a]!=="+";)a++;else!o.startsWith("-")&&o!==";"&&o!=="+"&&o!=="("&&o!==")"&&o!=="\\("&&o!=="\\)"?t=o:L.has(o)&&a++}let{expr:g,error:l,actions:i}=$(e,0);if(l)return{stdout:"",stderr:l,exitCode:1};let p=i.some(a=>a.type==="print"),f=i.length===0,u=s.fs.resolvePath(s.cwd,t);try{await s.fs.stat(u)}catch{return{stdout:"",stderr:`find: ${t}: No such file or directory
5
- `,exitCode:1}}let m=[],v=I(g),C=new Map;for(let a of v){let o=s.fs.resolvePath(s.cwd,a);try{let c=await s.fs.stat(o);C.set(a,c.mtime?.getTime()??Date.now())}catch{}}async function R(a,o){if(r!==null&&o>r)return;let c;try{c=await s.fs.stat(a)}catch{return}if(!c)return;let d;a===u?d=t.split("/").pop()||t:d=a.split("/").pop()||"";let h=a===u?t:t==="."?`./${a.slice(u.length+1)}`:t+a.slice(u.length),y=null;c.isDirectory&&(y=await s.fs.readdir(a));let W=c.isFile?c.size===0:y!==null&&y.length===0,P=n===null||o>=n,k=!1,D=!1;if(P&&g!==null){let M={name:d,relativePath:h,isFile:c.isFile,isDirectory:c.isDirectory,isEmpty:W,mtime:c.mtime?.getTime()??Date.now(),size:c.size??0,mode:c.mode??420,newerRefTimes:C},E=x(g,M);P=E.matches,k=E.pruned,p?D=E.printed:D=P}else P&&(D=!0);if(D&&m.push(h),y!==null&&!k)for(let M of y){let E=a==="/"?`/${M}`:`${a}/${M}`;await R(E,o+1)}}await R(u,0);let w="",b="",T=0;if(i.length>0)for(let a of i)switch(a.type){case"print":w+=m.length>0?`${m.join(`
6
- `)}
7
- `:"";break;case"print0":w+=m.length>0?`${m.join("\0")}\0`:"";break;case"delete":{let o=[...m].sort((c,d)=>d.length-c.length);for(let c of o){let d=s.fs.resolvePath(s.cwd,c);try{await s.fs.rm(d,{recursive:!1})}catch(h){let y=h instanceof Error?h.message:String(h);b+=`find: cannot delete '${c}': ${y}
8
- `,T=1}}break}case"exec":if(!s.exec)return{stdout:"",stderr:`find: -exec not supported in this context
9
- `,exitCode:1};if(a.batchMode){let o=[];for(let h of a.command)h==="{}"?o.push(...m):o.push(h);let c=o.map(h=>`"${h}"`).join(" "),d=await s.exec(c);w+=d.stdout,b+=d.stderr,d.exitCode!==0&&(T=d.exitCode)}else for(let o of m){let d=a.command.map(y=>y==="{}"?o:y).map(y=>`"${y}"`).join(" "),h=await s.exec(d);w+=h.stdout,b+=h.stderr,h.exitCode!==0&&(T=h.exitCode)}break}else f&&(w=m.length>0?`${m.join(`
10
- `)}
11
- `:"");return{stdout:w,stderr:b,exitCode:T}}};export{K as findCommand};
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as N}from"./chunk-26Q3PZQ6.js";import{a as q,b as G,c as O}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";var j={name:"grep",summary:"print lines that match patterns",usage:"grep [OPTION]... PATTERN [FILE]...",options:["-E, --extended-regexp PATTERN is an extended regular expression","-F, --fixed-strings PATTERN is a set of newline-separated strings","-i, --ignore-case ignore case distinctions","-v, --invert-match select non-matching lines","-w, --word-regexp match only whole words","-c, --count print only a count of matching lines","-l, --files-with-matches print only names of files with matches","-L, --files-without-match print names of files with no matches","-n, --line-number print line number with output lines","-h, --no-filename suppress the file name prefix on output","-o, --only-matching show only nonempty parts of lines that match","-q, --quiet, --silent suppress all normal output","-r, -R, --recursive search directories recursively","-A NUM print NUM lines of trailing context","-B NUM print NUM lines of leading context","-C NUM print NUM lines of context","-e PATTERN use PATTERN for matching"," --include=GLOB search only files matching GLOB"," --exclude=GLOB skip files matching GLOB"," --exclude-dir=DIR skip directories matching DIR"," --help display this help and exit"]},k={name:"grep",async execute(s,e){if(G(s))return q(j);let o=!1,r=!1,f=!1,u=!1,w=!1,p=!1,h=!1,d=!1,g=!1,m=!1,y=!1,L=!1,x=!1,v=0,l=0,C=[],i=[],n=[],I=null,P=[];for(let a=0;a<s.length;a++){let c=s[a];if(c.startsWith("-")&&c!=="-"){if(c==="-e"&&a+1<s.length){I=s[++a];continue}if(c.startsWith("--include=")){C.push(c.slice(10));continue}if(c.startsWith("--exclude=")){i.push(c.slice(10));continue}if(c.startsWith("--exclude-dir=")){n.push(c.slice(14));continue}let $=c.match(/^-([ABC])(\d+)$/);if($){let t=parseInt($[2],10);$[1]==="A"?l=t:$[1]==="B"?v=t:$[1]==="C"&&(v=t,l=t);continue}if((c==="-A"||c==="-B"||c==="-C")&&a+1<s.length){let t=parseInt(s[++a],10);c==="-A"?l=t:c==="-B"?v=t:(v=t,l=t);continue}let A=c.startsWith("--")?[c]:c.slice(1).split("");for(let t of A)if(t==="i"||t==="--ignore-case")o=!0;else if(t==="n"||t==="--line-number")r=!0;else if(t==="v"||t==="--invert-match")f=!0;else if(t==="c"||t==="--count")u=!0;else if(t==="l"||t==="--files-with-matches")w=!0;else if(t==="L"||t==="--files-without-match")p=!0;else if(t==="r"||t==="R"||t==="--recursive")h=!0;else if(t==="w"||t==="--word-regexp")d=!0;else if(t==="E"||t==="--extended-regexp")g=!0;else if(t==="F"||t==="--fixed-strings")m=!0;else if(t==="o"||t==="--only-matching")y=!0;else if(t==="h"||t==="--no-filename")L=!0;else if(t==="q"||t==="--quiet"||t==="--silent")x=!0;else{if(t.startsWith("--"))return O("grep",t);if(t.length===1)return O("grep",`-${t}`)}}else I===null?I=c:P.push(c)}if(I===null)return{stdout:"",stderr:`grep: missing pattern
3
- `,exitCode:2};let R;m?R=I.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):g?R=I:R=z(I),d&&(R=`\\b${R}\\b`);let B;try{B=new RegExp(R,o?"gi":"g")}catch{return{stdout:"",stderr:`grep: invalid regular expression: ${I}
4
- `,exitCode:2}}if(P.length===0&&e.stdin){let a=b(e.stdin,B,f,r,u,"",y,v,l);return x?{stdout:"",stderr:"",exitCode:a.matched?0:1}:{stdout:a.output,stderr:"",exitCode:a.matched?0:1}}if(P.length===0)return{stdout:"",stderr:`grep: no input files
5
- `,exitCode:2};let E="",W="",Q=!1,U=!1,M=[];for(let a of P)if(a.includes("*")||a.includes("?")||a.includes("[")){let c=await J(a,e);if(h)for(let $ of c){let A=await S($,e,C,i,n);M.push(...A)}else M.push(...c)}else if(h){let c=await S(a,e,C,i,n);M.push(...c)}else M.push(a);let H=(M.length>1||h)&&!L;for(let a of M){let c=a.split("/").pop()||a;if(!(i.length>0&&!h&&i.some($=>N(c,$,{stripQuotes:!0})))&&!(C.length>0&&!h&&!C.some($=>N(c,$,{stripQuotes:!0}))))try{let $=e.fs.resolvePath(e.cwd,a);if((await e.fs.stat($)).isDirectory){h||(W+=`grep: ${a}: Is a directory
6
- `);continue}let t=await e.fs.readFile($),F=b(t,B,f,r,u,H?a:"",y,v,l);if(F.matched){if(Q=!0,x)return{stdout:"",stderr:"",exitCode:0};w?E+=`${a}
7
- `:p||(E+=F.output)}else p?E+=`${a}
8
- `:u&&!w&&(E+=F.output)}catch{W+=`grep: ${a}: No such file or directory
9
- `,U=!0}}let T;return U?T=2:p?T=E.length>0?0:1:T=Q?0:1,x?{stdout:"",stderr:"",exitCode:T}:{stdout:E,stderr:W,exitCode:T}}};function z(s){let e="",o=0;for(;o<s.length;){let r=s[o];if(r==="\\"&&o+1<s.length){let f=s[o+1];if(f==="|"||f==="("||f===")"){e+=f,o+=2;continue}else if(f==="{"||f==="}"){e+=`\\${f}`,o+=2;continue}}r==="+"||r==="?"||r==="|"||r==="("||r===")"||r==="{"||r==="}"?e+=`\\${r}`:e+=r,o++}return e}function b(s,e,o,r,f,u,w=!1,p=0,h=0){let d=s.split(`
10
- `),g=d.length,m=g>0&&d[g-1]===""?g-1:g;if(f){let l=0;for(let i=0;i<m;i++)e.lastIndex=0,e.test(d[i])!==o&&l++;return{output:`${u?`${u}:${l}`:String(l)}
11
- `,matched:l>0}}if(p===0&&h===0){let l=[],C=!1;for(let i=0;i<m;i++){let n=d[i];if(e.lastIndex=0,e.test(n)!==o)if(C=!0,w){e.lastIndex=0;for(let P=e.exec(n);P!==null;P=e.exec(n))l.push(u?`${u}:${P[0]}`:P[0]),P[0].length===0&&e.lastIndex++}else r?l.push(u?`${u}:${i+1}:${n}`:`${i+1}:${n}`):l.push(u?`${u}:${n}`:n)}return{output:l.length>0?`${l.join(`
12
- `)}
13
- `:"",matched:C}}let y=[],L=0,x=new Set,v=[];for(let l=0;l<m;l++)e.lastIndex=0,e.test(d[l])!==o&&(v.push(l),L++);for(let l of v){for(let i=Math.max(0,l-p);i<l;i++)if(!x.has(i)){x.add(i);let n=d[i];r&&(n=`${i+1}-${n}`),u&&(n=`${u}-${n}`),y.push(n)}if(!x.has(l)){x.add(l);let i=d[l];if(w){e.lastIndex=0;for(let n=e.exec(i);n!==null;n=e.exec(i))y.push(u?`${u}:${n[0]}`:n[0]),n[0].length===0&&e.lastIndex++}else{let n=i;r&&(n=`${l+1}:${n}`),u&&(n=`${u}:${n}`),y.push(n)}}let C=Math.min(m-1,l+h);for(let i=l+1;i<=C;i++)if(!x.has(i)){x.add(i);let n=d[i];r&&(n=`${i+1}-${n}`),u&&(n=`${u}-${n}`),y.push(n)}}return{output:y.length>0?`${y.join(`
14
- `)}
15
- `:"",matched:L>0}}async function S(s,e,o=[],r=[],f=[]){let u=e.fs.resolvePath(e.cwd,s),w=[];try{if(!(await e.fs.stat(u)).isDirectory){let g=s.split("/").pop()||s;return r.length>0&&r.some(m=>N(g,m,{stripQuotes:!0}))?[]:o.length>0&&!o.some(m=>N(g,m,{stripQuotes:!0}))?[]:[s]}let h=s.split("/").pop()||s;if(f.length>0&&f.some(g=>N(h,g,{stripQuotes:!0})))return[];let d=await e.fs.readdir(u);for(let g of d){if(g.startsWith("."))continue;let m=s==="."?g:`${s}/${g}`,y=await S(m,e,o,r,f);w.push(...y)}}catch{}return w}async function J(s,e){let o=[],r=s.lastIndexOf("/"),f,u;if(r===-1?(f=e.cwd,u=s):(f=s.slice(0,r)||"/",u=s.slice(r+1)),s.includes("**")){let p=s.split("**"),h=p[0].replace(/\/$/,"")||".",d=p[1]||"";return await D(h,d,e,o),o}let w=e.fs.resolvePath(e.cwd,f);try{let p=await e.fs.readdir(w);for(let h of p)if(N(h,u,{stripQuotes:!0})){let d=r===-1?h:`${f}/${h}`;o.push(d)}}catch{}return o.sort()}async function D(s,e,o,r){let f=o.fs.resolvePath(o.cwd,s);try{if(!(await o.fs.stat(f)).isDirectory){let p=s.split("/").pop()||"";if(e){let h=e.replace(/^\//,"");N(p,h,{stripQuotes:!0})&&r.push(s)}return}let w=await o.fs.readdir(f);for(let p of w){let h=s==="."?p:`${s}/${p}`,d=o.fs.resolvePath(o.cwd,h);if((await o.fs.stat(d)).isDirectory)await D(h,e,o,r);else if(e){let m=e.replace(/^\//,"");N(p,m,{stripQuotes:!0})&&r.push(h)}}}catch{}}var X={name:"fgrep",async execute(s,e){return k.execute(["-F",...s],e)}},Y={name:"egrep",async execute(s,e){return k.execute(["-E",...s],e)}};export{Y as egrepCommand,X as fgrepCommand,k as grepCommand};
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as v}from"./chunk-26Q3PZQ6.js";import{a as q,b as G,c as U}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";var J={name:"grep",summary:"print lines that match patterns",usage:"grep [OPTION]... PATTERN [FILE]...",options:["-E, --extended-regexp PATTERN is an extended regular expression","-F, --fixed-strings PATTERN is a set of newline-separated strings","-i, --ignore-case ignore case distinctions","-v, --invert-match select non-matching lines","-w, --word-regexp match only whole words","-x, --line-regexp match only whole lines","-c, --count print only a count of matching lines","-l, --files-with-matches print only names of files with matches","-L, --files-without-match print names of files with no matches","-m NUM, --max-count=NUM stop after NUM matches","-n, --line-number print line number with output lines","-h, --no-filename suppress the file name prefix on output","-o, --only-matching show only nonempty parts of lines that match","-q, --quiet, --silent suppress all normal output","-r, -R, --recursive search directories recursively","-A NUM print NUM lines of trailing context","-B NUM print NUM lines of leading context","-C NUM print NUM lines of context","-e PATTERN use PATTERN for matching"," --include=GLOB search only files matching GLOB"," --exclude=GLOB skip files matching GLOB"," --exclude-dir=DIR skip directories matching DIR"," --help display this help and exit"]},H={name:"grep",async execute(s,e){if(G(s))return q(J);let i=!1,o=!1,f=!1,a=!1,$=!1,d=!1,h=!1,m=!1,p=!1,g=!1,M=!1,P=!1,T=!1,y=!1,R=0,l=0,w=0,c=[],n=[],x=[],N=null,I=[];for(let u=0;u<s.length;u++){let r=s[u];if(r.startsWith("-")&&r!=="-"){if(r==="-e"&&u+1<s.length){N=s[++u];continue}if(r.startsWith("--include=")){c.push(r.slice(10));continue}if(r.startsWith("--exclude=")){n.push(r.slice(10));continue}if(r.startsWith("--exclude-dir=")){x.push(r.slice(14));continue}if(r.startsWith("--max-count=")){R=parseInt(r.slice(12),10);continue}let C=r.match(/^-m(\d+)$/);if(C){R=parseInt(C[1],10);continue}if(r==="-m"&&u+1<s.length){R=parseInt(s[++u],10);continue}let L=r.match(/^-([ABC])(\d+)$/);if(L){let t=parseInt(L[2],10);L[1]==="A"?w=t:L[1]==="B"?l=t:L[1]==="C"&&(l=t,w=t);continue}if((r==="-A"||r==="-B"||r==="-C")&&u+1<s.length){let t=parseInt(s[++u],10);r==="-A"?w=t:r==="-B"?l=t:(l=t,w=t);continue}let S=r.startsWith("--")?[r]:r.slice(1).split("");for(let t of S)if(t==="i"||t==="--ignore-case")i=!0;else if(t==="n"||t==="--line-number")o=!0;else if(t==="v"||t==="--invert-match")f=!0;else if(t==="c"||t==="--count")a=!0;else if(t==="l"||t==="--files-with-matches")$=!0;else if(t==="L"||t==="--files-without-match")d=!0;else if(t==="r"||t==="R"||t==="--recursive")h=!0;else if(t==="w"||t==="--word-regexp")m=!0;else if(t==="x"||t==="--line-regexp")p=!0;else if(t==="E"||t==="--extended-regexp")g=!0;else if(t==="F"||t==="--fixed-strings")M=!0;else if(t==="o"||t==="--only-matching")P=!0;else if(t==="h"||t==="--no-filename")T=!0;else if(t==="q"||t==="--quiet"||t==="--silent")y=!0;else{if(t.startsWith("--"))return U("grep",t);if(t.length===1)return U("grep",`-${t}`)}}else N===null?N=r:I.push(r)}if(N===null)return{stdout:"",stderr:`grep: missing pattern
3
- `,exitCode:2};let E;M?E=N.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):g?E=N:E=K(N),m&&(E=`\\b${E}\\b`),p&&(E=`^${E}$`);let F;try{F=new RegExp(E,i?"gi":"g")}catch{return{stdout:"",stderr:`grep: invalid regular expression: ${N}
4
- `,exitCode:2}}if(I.length===0&&e.stdin){let u=D(e.stdin,F,f,o,a,"",P,l,w,R);return y?{stdout:"",stderr:"",exitCode:u.matched?0:1}:{stdout:u.output,stderr:"",exitCode:u.matched?0:1}}if(I.length===0)return{stdout:"",stderr:`grep: no input files
5
- `,exitCode:2};let A="",O="",b=!1,k=!1,B=[];for(let u of I)if(u.includes("*")||u.includes("?")||u.includes("[")){let r=await V(u,e);if(h)for(let C of r){let L=await Q(C,e,c,n,x);B.push(...L)}else B.push(...r)}else if(h){let r=await Q(u,e,c,n,x);B.push(...r)}else B.push(u);let z=(B.length>1||h)&&!T;for(let u of B){let r=u.split("/").pop()||u;if(!(n.length>0&&!h&&n.some(C=>v(r,C,{stripQuotes:!0})))&&!(c.length>0&&!h&&!c.some(C=>v(r,C,{stripQuotes:!0}))))try{let C=e.fs.resolvePath(e.cwd,u);if((await e.fs.stat(C)).isDirectory){h||(O+=`grep: ${u}: Is a directory
6
- `);continue}let S=await e.fs.readFile(C),t=D(S,F,f,o,a,z?u:"",P,l,w,R);if(t.matched){if(b=!0,y)return{stdout:"",stderr:"",exitCode:0};$?A+=`${u}
7
- `:d||(A+=t.output)}else d?A+=`${u}
8
- `:a&&!$&&(A+=t.output)}catch{O+=`grep: ${u}: No such file or directory
9
- `,k=!0}}let W;return k?W=2:d?W=A.length>0?0:1:W=b?0:1,y?{stdout:"",stderr:"",exitCode:W}:{stdout:A,stderr:O,exitCode:W}}};function K(s){let e="",i=0;for(;i<s.length;){let o=s[i];if(o==="\\"&&i+1<s.length){let f=s[i+1];if(f==="|"||f==="("||f===")"){e+=f,i+=2;continue}else if(f==="{"||f==="}"){e+=`\\${f}`,i+=2;continue}}o==="+"||o==="?"||o==="|"||o==="("||o===")"||o==="{"||o==="}"?e+=`\\${o}`:e+=o,i++}return e}function D(s,e,i,o,f,a,$=!1,d=0,h=0,m=0){let p=s.split(`
10
- `),g=p.length,M=g>0&&p[g-1]===""?g-1:g;if(f){let l=0;for(let c=0;c<M;c++)e.lastIndex=0,e.test(p[c])!==i&&l++;return{output:`${a?`${a}:${l}`:String(l)}
11
- `,matched:l>0}}if(d===0&&h===0){let l=[],w=!1,c=0;for(let n=0;n<M&&!(m>0&&c>=m);n++){let x=p[n];if(e.lastIndex=0,e.test(x)!==i)if(w=!0,c++,$){e.lastIndex=0;for(let I=e.exec(x);I!==null;I=e.exec(x))l.push(a?`${a}:${I[0]}`:I[0]),I[0].length===0&&e.lastIndex++}else o?l.push(a?`${a}:${n+1}:${x}`:`${n+1}:${x}`):l.push(a?`${a}:${x}`:x)}return{output:l.length>0?`${l.join(`
12
- `)}
13
- `:"",matched:w}}let P=[],T=0,y=new Set,R=[];for(let l=0;l<M&&!(m>0&&T>=m);l++)e.lastIndex=0,e.test(p[l])!==i&&(R.push(l),T++);for(let l of R){for(let c=Math.max(0,l-d);c<l;c++)if(!y.has(c)){y.add(c);let n=p[c];o&&(n=`${c+1}-${n}`),a&&(n=`${a}-${n}`),P.push(n)}if(!y.has(l)){y.add(l);let c=p[l];if($){e.lastIndex=0;for(let n=e.exec(c);n!==null;n=e.exec(c))P.push(a?`${a}:${n[0]}`:n[0]),n[0].length===0&&e.lastIndex++}else{let n=c;o&&(n=`${l+1}:${n}`),a&&(n=`${a}:${n}`),P.push(n)}}let w=Math.min(M-1,l+h);for(let c=l+1;c<=w;c++)if(!y.has(c)){y.add(c);let n=p[c];o&&(n=`${c+1}-${n}`),a&&(n=`${a}-${n}`),P.push(n)}}return{output:P.length>0?`${P.join(`
14
- `)}
15
- `:"",matched:T>0}}async function Q(s,e,i=[],o=[],f=[]){let a=e.fs.resolvePath(e.cwd,s),$=[];try{if(!(await e.fs.stat(a)).isDirectory){let p=s.split("/").pop()||s;return o.length>0&&o.some(g=>v(p,g,{stripQuotes:!0}))?[]:i.length>0&&!i.some(g=>v(p,g,{stripQuotes:!0}))?[]:[s]}let h=s.split("/").pop()||s;if(f.length>0&&f.some(p=>v(h,p,{stripQuotes:!0})))return[];let m=await e.fs.readdir(a);for(let p of m){if(p.startsWith("."))continue;let g=s==="."?p:`${s}/${p}`,M=await Q(g,e,i,o,f);$.push(...M)}}catch{}return $}async function V(s,e){let i=[],o=s.lastIndexOf("/"),f,a;if(o===-1?(f=e.cwd,a=s):(f=s.slice(0,o)||"/",a=s.slice(o+1)),s.includes("**")){let d=s.split("**"),h=d[0].replace(/\/$/,"")||".",m=d[1]||"";return await j(h,m,e,i),i}let $=e.fs.resolvePath(e.cwd,f);try{let d=await e.fs.readdir($);for(let h of d)if(v(h,a,{stripQuotes:!0})){let m=o===-1?h:`${f}/${h}`;i.push(m)}}catch{}return i.sort()}async function j(s,e,i,o){let f=i.fs.resolvePath(i.cwd,s);try{if(!(await i.fs.stat(f)).isDirectory){let d=s.split("/").pop()||"";if(e){let h=e.replace(/^\//,"");v(d,h,{stripQuotes:!0})&&o.push(s)}return}let $=await i.fs.readdir(f);for(let d of $){let h=s==="."?d:`${s}/${d}`,m=i.fs.resolvePath(i.cwd,h);if((await i.fs.stat(m)).isDirectory)await j(h,e,i,o);else if(e){let g=e.replace(/^\//,"");v(d,g,{stripQuotes:!0})&&o.push(h)}}}catch{}}var Z={name:"fgrep",async execute(s,e){return H.execute(["-F",...s],e)}},_={name:"egrep",async execute(s,e){return H.execute(["-E",...s],e)}};export{_ as egrepCommand,Z as fgrepCommand,H as grepCommand};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as i,b as r,c as n}from"./chunk-J7BCMQDI.js";import{a as t,b as a}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";var h={name:"head",summary:"output the first part of files",usage:"head [OPTION]... [FILE]...",options:["-c, --bytes=NUM print the first NUM bytes","-n, --lines=NUM print the first NUM lines (default 10)","-q, --quiet never print headers giving file names","-v, --verbose always print headers giving file names"," --help display this help and exit"]},u={name:"head",async execute(s,o){if(a(s))return t(h);let e=i(s,"head");if(!e.ok)return e.error;let{lines:p,bytes:l}=e.options;return r(o,e.options,"head",d=>n(d,p,l))}};export{u as headCommand};
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env node
2
- import"./chunk-5KNEBKYN.js";var c={"File operations":["ls","cat","head","tail","wc","touch","mkdir","rm","cp","mv","ln","chmod","stat","readlink"],"Text processing":["grep","sed","awk","sort","uniq","cut","tr","tee","diff"],Search:["find"],"Navigation & paths":["pwd","basename","dirname","tree","du"],"Environment & shell":["echo","printf","env","printenv","export","alias","unalias","history","clear","true","false","bash","sh"],"Data processing":["xargs","jq","base64","date"],Network:["curl","html-to-markdown"]};function l(t){let e=[],n=new Set(t);e.push(`Available commands:
3
- `);let s=[];for(let[o,r]of Object.entries(c)){let a=r.filter(i=>n.has(i));if(a.length>0){e.push(` ${o}:`),e.push(` ${a.join(", ")}
4
- `);for(let i of a)n.delete(i)}}for(let o of n)s.push(o);return s.length>0&&(e.push(" Other:"),e.push(` ${s.sort().join(", ")}
5
- `)),e.push("Use '<command> --help' for details on a specific command."),`${e.join(`
6
- `)}
7
- `}var d={name:"help",async execute(t,e){if(t.includes("--help")||t.includes("-h"))return{stdout:`help - display available commands
8
-
9
- Usage: help [command]
10
-
11
- Options:
12
- -h, --help Show this help message
13
-
14
- If a command name is provided, shows help for that command.
15
- Otherwise, lists all available commands.
16
- `,stderr:"",exitCode:0};if(t.length>0&&e.exec){let s=t[0];return e.exec(`${s} --help`)}let n=e.getRegisteredCommands?.()??[];return{stdout:l(n),stderr:"",exitCode:0}}};export{d as helpCommand};
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env node
2
- import"./chunk-5KNEBKYN.js";var r={"File operations":["ls","cat","head","tail","wc","touch","mkdir","rm","cp","mv","ln","chmod","stat","readlink"],"Text processing":["grep","sed","awk","sort","uniq","cut","tr","tee","diff"],Search:["find"],"Navigation & paths":["pwd","basename","dirname","tree","du"],"Environment & shell":["echo","printf","env","printenv","export","alias","unalias","history","clear","true","false","bash","sh"],"Data processing":["xargs","jq","base64","date"],Network:["curl","html-to-markdown"]};function l(t){let e=[],n=new Set(t);e.push(`Available commands:
3
- `);let s=[];for(let[o,c]of Object.entries(r)){let a=c.filter(i=>n.has(i));if(a.length>0){e.push(` ${o}:`),e.push(` ${a.join(", ")}
4
- `);for(let i of a)n.delete(i)}}for(let o of n)s.push(o);return s.length>0&&(e.push(" Other:"),e.push(` ${s.sort().join(", ")}
5
- `)),e.push("Use '<command> --help' for details on a specific command."),`${e.join(`
6
- `)}
7
- `}var d={name:"help",async execute(t,e){if(t.includes("--help")||t.includes("-h"))return{stdout:`help - display available commands
8
-
9
- Usage: help [command]
10
-
11
- Options:
12
- -h, --help Show this help message
13
-
14
- If a command name is provided, shows help for that command.
15
- Otherwise, lists all available commands.
16
- `,stderr:"",exitCode:0};if(t.length>0&&e.exec){let s=t[0];return e.exec(`${s} --help`,{cwd:e.cwd})}let n=e.getRegisteredCommands?.()??[];return{stdout:l(n),stderr:"",exitCode:0}}};export{d as helpCommand};
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as i,b as h}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";var d={name:"history",summary:"display command history",usage:"history [n]",options:["-c clear the history list"," --help display this help and exit"]},l="BASH_HISTORY",m={name:"history",async execute(e,n){if(h(e))return i(d);let a=n.env[l]||"[]",t;try{t=JSON.parse(a)}catch{t=[]}if(e[0]==="-c")return n.env[l]="[]",{stdout:"",stderr:"",exitCode:0};let s=t.length;e[0]&&/^\d+$/.test(e[0])&&(s=Math.min(parseInt(e[0],10),t.length));let c=t.length-s,r="";for(let o=c;o<t.length;o++){let y=(o+1).toString().padStart(5," ");r+=`${y} ${t[o]}
3
- `}return{stdout:r,stderr:"",exitCode:0}}};export{m as historyCommand};