@poe-platform/safe-bash 0.1.798 → 0.1.800

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 (942) hide show
  1. package/README.md +34 -18
  2. package/dist/image-ast/index.browser.js +1384 -23
  3. package/dist/image-ast/index.js +1384 -23
  4. package/dist/mp4-ast/types.d.ts +1 -0
  5. package/dist/office-package/zip.d.ts +2 -0
  6. package/dist/office-package/zip.js +1 -1
  7. package/dist/pdf-ast/index.js +1 -1
  8. package/dist/safe-bash/chunks/{chunk-IUTD5FH5.js → chunk-46UISJCK.js} +1 -6
  9. package/dist/safe-bash/chunks/chunk-4SEW2Q6H.js +26 -0
  10. package/dist/safe-bash/chunks/{chunk-AKC46AF6.js → chunk-7YSRXFEG.js} +7 -40
  11. package/dist/safe-bash/chunks/{chunk-KTGR4U57.js → chunk-BHJE5LPZ.js} +1 -2
  12. package/dist/safe-bash/chunks/{chunk-AMTCC256.js → chunk-HHW7MGS2.js} +2 -2
  13. package/dist/safe-bash/chunks/{chunk-ZNAFMYIA.js → chunk-I7L3G3NX.js} +1 -1
  14. package/dist/safe-bash/chunks/{chunk-KMH2DF3I.js → chunk-JJSTTIEZ.js} +6 -1
  15. package/dist/safe-bash/chunks/{chunk-6IBTC4YL.js → chunk-JTLSUJ7V.js} +57 -20
  16. package/dist/safe-bash/chunks/chunk-K2VCOJ2B.js +111 -0
  17. package/dist/safe-bash/chunks/chunk-K4YMYFRJ.js +9802 -0
  18. package/dist/safe-bash/chunks/{chunk-CSNXID73.js → chunk-KW24TAIU.js} +446 -5543
  19. package/dist/safe-bash/chunks/{chunk-ENR3HB2B.js → chunk-NLAW7KDI.js} +0 -1
  20. package/dist/safe-bash/chunks/{chunk-B3DDEDH2.js → chunk-PPYM75Z3.js} +1 -1
  21. package/dist/safe-bash/chunks/{chunk-NX2SQVON.js → chunk-RKKRJ54E.js} +19 -7
  22. package/dist/safe-bash/chunks/{chunk-V3VEATEA.js → chunk-RMWLWH7Q.js} +870 -953
  23. package/dist/safe-bash/chunks/{chunk-JSVX4VIA.js → chunk-TFGRKY43.js} +2 -1
  24. package/dist/safe-bash/chunks/{chunk-T5KKDMYB.js → chunk-TYD7EVUJ.js} +6 -0
  25. package/dist/safe-bash/chunks/{csvkit-W2UEKH6P.js → csvkit-QGP3GAOB.js} +1 -1
  26. package/dist/safe-bash/chunks/{ffmpeg-42CGASMV.js → ffmpeg-JTVH26MK.js} +1 -1
  27. package/dist/safe-bash/chunks/{gh-26GYLH6D.js → gh-I7QX7N5C.js} +1 -1
  28. package/dist/safe-bash/chunks/{git-YREKMUVD.js → git-MA7NKYVP.js} +1 -1
  29. package/dist/safe-bash/chunks/{imagemagick-3YIX4XO2.js → imagemagick-Y4NPWX2Q.js} +1 -1
  30. package/dist/safe-bash/chunks/{implementation-E3YMKU3Z.js → implementation-BWDKOVQJ.js} +1 -1
  31. package/dist/safe-bash/chunks/mmdc-44PELHDG.js +118 -0
  32. package/dist/safe-bash/chunks/{pdfimages-UE2UISP2.js → pdfimages-635TRW4Q.js} +1 -1
  33. package/dist/safe-bash/chunks/{pdfinfo-RGARKLI5.js → pdfinfo-FSDAA2KY.js} +3 -11
  34. package/dist/safe-bash/chunks/{pdftk-JY3WVCCC.js → pdftk-GQ5UH3VG.js} +1 -1
  35. package/dist/safe-bash/chunks/{pdftoppm-GPD3BMPY.js → pdftoppm-YTXQCAYT.js} +1 -1
  36. package/dist/safe-bash/chunks/{pdftotext-K7GQ2QJZ.js → pdftotext-CVA2G7FY.js} +1 -1
  37. package/dist/safe-bash/chunks/{qpdf-F4U7WUSU.js → qpdf-HZMIFG4A.js} +1 -1
  38. package/dist/safe-bash/chunks/{sips-RWENS7X5.js → sips-E7UBDP33.js} +1 -1
  39. package/dist/safe-bash/chunks/{soffice-IT6W2C5F.js → soffice-ELASUWUK.js} +1 -1
  40. package/dist/safe-bash/chunks/{wkhtmltopdf-JYNDAHIZ.js → wkhtmltopdf-EPO6YCMG.js} +1 -1
  41. package/dist/safe-bash/command-chunks/chunk-2FGJYFWZ.js +44 -0
  42. package/dist/safe-bash/command-chunks/chunk-2H4JTFIL.js +53 -0
  43. package/dist/safe-bash/command-chunks/{chunk-THS4YAKG.js → chunk-2QHG43WJ.js} +2 -2
  44. package/dist/safe-bash/command-chunks/chunk-364TMWBT.js +946 -0
  45. package/dist/safe-bash/command-chunks/{chunk-JEPY4UY4.js → chunk-3DT2YOGW.js} +11 -6
  46. package/dist/safe-bash/command-chunks/chunk-3E2OIS2J.js +7037 -0
  47. package/dist/safe-bash/command-chunks/{chunk-AIRGA2SU.js → chunk-3HXDA5PT.js} +1 -1
  48. package/dist/safe-bash/command-chunks/chunk-3LSOYLNV.js +1091 -0
  49. package/dist/safe-bash/command-chunks/{chunk-OAJUAAWH.js → chunk-464RVBGB.js} +3 -3
  50. package/dist/safe-bash/command-chunks/chunk-4B7Y7S6E.js +61 -0
  51. package/dist/safe-bash/command-chunks/{chunk-HRLIAMXC.js → chunk-4C6QI5BQ.js} +3 -2
  52. package/dist/safe-bash/command-chunks/{chunk-25BLI6S6.js → chunk-4Y3WVMK4.js} +1 -14
  53. package/dist/safe-bash/command-chunks/chunk-4ZHMW6F5.js +104 -0
  54. package/dist/safe-bash/command-chunks/{chunk-YMQKVEIF.js → chunk-52PCQXD2.js} +2 -13
  55. package/dist/safe-bash/command-chunks/{chunk-SSBFTMVI.js → chunk-53P53XFM.js} +2 -2
  56. package/dist/safe-bash/command-chunks/{chunk-ZCKDQGKY.js → chunk-5HDSFHGW.js} +1 -1
  57. package/dist/safe-bash/command-chunks/chunk-5LSGEIZY.js +379 -0
  58. package/dist/safe-bash/command-chunks/{chunk-MKQVQMXO.js → chunk-5LU4UCBR.js} +1 -1
  59. package/dist/safe-bash/command-chunks/chunk-5T7CRJHW.js +560 -0
  60. package/dist/safe-bash/command-chunks/chunk-5TBUOBDE.js +346 -0
  61. package/dist/safe-bash/command-chunks/{chunk-AUAF5YBT.js → chunk-5WPI42ZW.js} +0 -7
  62. package/dist/safe-bash/command-chunks/chunk-5XY4DTNG.js +34 -0
  63. package/dist/safe-bash/command-chunks/chunk-5ZMZ573Q.js +140 -0
  64. package/dist/safe-bash/command-chunks/{chunk-2Q7UQ7R4.js → chunk-67IQF5GC.js} +200 -66
  65. package/dist/safe-bash/command-chunks/chunk-67QKREJK.js +347 -0
  66. package/dist/safe-bash/command-chunks/chunk-6EPHJGGF.js +23 -0
  67. package/dist/safe-bash/command-chunks/chunk-6F4XCVON.js +266 -0
  68. package/dist/safe-bash/command-chunks/{chunk-ESMCX3YV.js → chunk-6HMX4CQS.js} +669 -130
  69. package/dist/safe-bash/command-chunks/{chunk-RECJB2BO.js → chunk-7BS66BXN.js} +1 -1
  70. package/dist/safe-bash/command-chunks/{chunk-GRWOVSFK.js → chunk-7D7JRRML.js} +1 -1
  71. package/dist/safe-bash/command-chunks/chunk-7K6JYKPJ.js +422 -0
  72. package/dist/safe-bash/command-chunks/{chunk-E6IYUYVA.js → chunk-7L24L4UO.js} +2 -2
  73. package/dist/safe-bash/command-chunks/chunk-7N2LI2KO.js +206 -0
  74. package/dist/safe-bash/command-chunks/chunk-7RGB363W.js +362 -0
  75. package/dist/safe-bash/command-chunks/{chunk-HBXQWTJR.js → chunk-A5ZAV6DO.js} +1 -1
  76. package/dist/safe-bash/command-chunks/{chunk-LW34AKDM.js → chunk-AB4MXHVS.js} +4 -14
  77. package/dist/safe-bash/command-chunks/{pptx-GBPNWNEP-7EQEVXV5.js → chunk-AI5JAXQF.js} +34820 -18029
  78. package/dist/safe-bash/command-chunks/chunk-AMO3THU4.js +105 -0
  79. package/dist/safe-bash/command-chunks/{chunk-EELNLEEP.js → chunk-AXK3H4PX.js} +1 -1
  80. package/dist/safe-bash/command-chunks/{chunk-Y55OCH37.js → chunk-AYUTO323.js} +3 -10
  81. package/dist/safe-bash/command-chunks/{chunk-DY36FDDC.js → chunk-B5TAOCKD.js} +6 -6
  82. package/dist/safe-bash/command-chunks/chunk-BAGCY35S.js +231 -0
  83. package/dist/safe-bash/command-chunks/chunk-BAXU7B5Z.js +101 -0
  84. package/dist/safe-bash/command-chunks/{chunk-YB6KVU6H.js → chunk-BDBVVZY6.js} +4 -14
  85. package/dist/safe-bash/command-chunks/{chunk-2HOESGFJ.js → chunk-BKCNF5U3.js} +68 -7
  86. package/dist/safe-bash/command-chunks/chunk-BNOU5YQS.js +182 -0
  87. package/dist/safe-bash/command-chunks/{chunk-QAN7KKDZ.js → chunk-BZDDAPSV.js} +1 -1
  88. package/dist/safe-bash/command-chunks/{chunk-HZCPWYWA.js → chunk-BZPAWTUL.js} +1 -1
  89. package/dist/safe-bash/command-chunks/chunk-C7I25AAL.js +25 -0
  90. package/dist/safe-bash/command-chunks/chunk-CKXV2CLD.js +65 -0
  91. package/dist/safe-bash/command-chunks/{chunk-RT2J5ATD.js → chunk-CPPGTBZF.js} +1 -1
  92. package/dist/safe-bash/command-chunks/chunk-CQ5YGOGB.js +150 -0
  93. package/dist/safe-bash/command-chunks/{chunk-5UA3BEGA.js → chunk-D4OP2BR3.js} +72 -24
  94. package/dist/safe-bash/command-chunks/chunk-DB453IE6.js +122 -0
  95. package/dist/safe-bash/command-chunks/chunk-DOKKNRRM.js +87 -0
  96. package/dist/safe-bash/command-chunks/{chunk-2PX5B7T5.js → chunk-DQAVUDDX.js} +2 -2
  97. package/dist/safe-bash/command-chunks/chunk-DT7BCTWY.js +249 -0
  98. package/dist/safe-bash/command-chunks/chunk-E2LB7FRT.js +42 -0
  99. package/dist/safe-bash/command-chunks/chunk-EK6YNAXT.js +343 -0
  100. package/dist/safe-bash/command-chunks/chunk-EQ4HV54N.js +22 -0
  101. package/dist/safe-bash/command-chunks/chunk-ERYJLO6G.js +293 -0
  102. package/dist/safe-bash/command-chunks/{chunk-4ONEXMD3.js → chunk-EUSPTFAX.js} +1 -1
  103. package/dist/safe-bash/command-chunks/chunk-FKKB5X5V.js +97 -0
  104. package/dist/safe-bash/command-chunks/chunk-FXELCPFX.js +195 -0
  105. package/dist/safe-bash/command-chunks/{chunk-HLMUPSM6.js → chunk-GI4CJED2.js} +3 -2
  106. package/dist/safe-bash/command-chunks/{chunk-CU5RLO62.js → chunk-GLOZX57Y.js} +92 -18
  107. package/dist/safe-bash/command-chunks/chunk-GMIHJYDG.js +331 -0
  108. package/dist/safe-bash/command-chunks/chunk-H622NS6Z.js +11 -0
  109. package/dist/safe-bash/command-chunks/{chunk-QGVOS3EY.js → chunk-HFII3QYO.js} +1 -1
  110. package/dist/safe-bash/command-chunks/{chunk-5EWTQJSC.js → chunk-HHP343KT.js} +1 -1
  111. package/dist/safe-bash/command-chunks/{chunk-WBJKOTSP.js → chunk-HMOZ6XVJ.js} +1 -1
  112. package/dist/safe-bash/command-chunks/{chunk-AVSPNLWV.js → chunk-I237SNW5.js} +1 -1
  113. package/dist/safe-bash/command-chunks/{chunk-4MS5WZJC.js → chunk-IKS2YXZQ.js} +3 -3
  114. package/dist/safe-bash/command-chunks/{chunk-CZVBYCB5.js → chunk-IL53SJL4.js} +2 -12
  115. package/dist/safe-bash/command-chunks/{chunk-VZ64JXHC.js → chunk-IR2BY7EL.js} +21 -6
  116. package/dist/safe-bash/command-chunks/chunk-IYPAQ7PH.js +42 -0
  117. package/dist/safe-bash/command-chunks/chunk-JN7WIP6S.js +94 -0
  118. package/dist/safe-bash/command-chunks/chunk-JNZ3CVAE.js +147 -0
  119. package/dist/safe-bash/command-chunks/{chunk-HLBX5IRS.js → chunk-JQ74HC37.js} +24 -32
  120. package/dist/safe-bash/command-chunks/{chunk-2LLZBNLL.js → chunk-JWE54GHQ.js} +1 -1
  121. package/dist/safe-bash/command-chunks/{chunk-QLDIP3OP.js → chunk-JZSNU2MY.js} +2 -2
  122. package/dist/safe-bash/command-chunks/chunk-KFVV7ZJO.js +216 -0
  123. package/dist/safe-bash/command-chunks/{chunk-G4PNVO6Z.js → chunk-KP7AO66M.js} +1 -1
  124. package/dist/safe-bash/command-chunks/chunk-KWESKQHR.js +25 -0
  125. package/dist/safe-bash/command-chunks/chunk-KYSPGS33.js +41 -0
  126. package/dist/safe-bash/command-chunks/{chunk-C7IHMJEW.js → chunk-KZC5UWFF.js} +2 -2
  127. package/dist/safe-bash/command-chunks/chunk-L6DVEBW3.js +553 -0
  128. package/dist/safe-bash/command-chunks/chunk-LC2MFKT4.js +2489 -0
  129. package/dist/safe-bash/command-chunks/chunk-LE5LZNHE.js +204 -0
  130. package/dist/safe-bash/command-chunks/chunk-MDH5T4OS.js +41 -0
  131. package/dist/safe-bash/command-chunks/chunk-MM6HU6CX.js +20 -0
  132. package/dist/safe-bash/command-chunks/{chunk-MYJAZ3U2.js → chunk-MPL2466A.js} +2 -2
  133. package/dist/safe-bash/command-chunks/{chunk-3TANKHBX.js → chunk-MRW5HD2D.js} +1 -6
  134. package/dist/safe-bash/command-chunks/{chunk-3WKA57FA.js → chunk-N5FGCXQJ.js} +1 -9
  135. package/dist/safe-bash/command-chunks/{chunk-VZHRZMS7.js → chunk-NAY27PXB.js} +1 -1
  136. package/dist/safe-bash/command-chunks/chunk-NCD7PEWH.js +298 -0
  137. package/dist/safe-bash/command-chunks/chunk-NFGI5IGF.js +266 -0
  138. package/dist/safe-bash/command-chunks/{chunk-U3ONEICA.js → chunk-NXEQ3ESQ.js} +7 -11
  139. package/dist/safe-bash/command-chunks/{chunk-3VGGYEDH.js → chunk-ORYGZYKW.js} +4 -3
  140. package/dist/safe-bash/command-chunks/{chunk-OLQG7ZCN.js → chunk-PEF7K3UQ.js} +136 -75
  141. package/dist/safe-bash/command-chunks/{chunk-HVI6ALJF.js → chunk-PFAADCB5.js} +2 -4
  142. package/dist/safe-bash/command-chunks/chunk-PII4YEZW.js +123 -0
  143. package/dist/safe-bash/command-chunks/{chunk-JG5W2ENK.js → chunk-PJJUYO3R.js} +5 -5
  144. package/dist/safe-bash/command-chunks/{chunk-VKQCNX32.js → chunk-PTT3I223.js} +1 -1
  145. package/dist/safe-bash/command-chunks/chunk-Q3DII3Q7.js +174 -0
  146. package/dist/safe-bash/command-chunks/chunk-Q3EWDEUQ.js +185 -0
  147. package/dist/safe-bash/command-chunks/{chunk-JXU2N6GN.js → chunk-Q7Q5GM5S.js} +2 -2
  148. package/dist/safe-bash/command-chunks/{chunk-Z5TFSVNU.js → chunk-QAKKSRNV.js} +1 -1
  149. package/dist/safe-bash/command-chunks/{chunk-2FUAW6GO.js → chunk-QI7LGHJJ.js} +58 -9
  150. package/dist/safe-bash/command-chunks/{chunk-6BETHLXZ.js → chunk-QJAFJP2G.js} +1 -1
  151. package/dist/safe-bash/command-chunks/chunk-QNIMV57G.js +63 -0
  152. package/dist/safe-bash/command-chunks/{chunk-KAHH4XOU.js → chunk-QNXI2UP6.js} +1 -1
  153. package/dist/safe-bash/command-chunks/{chunk-AC6X7Q4I.js → chunk-QP4R6GLA.js} +6 -9
  154. package/dist/safe-bash/command-chunks/{chunk-LPORMIZS.js → chunk-QWIDNAAK.js} +8 -8
  155. package/dist/safe-bash/command-chunks/chunk-RVLO4DYT.js +35 -0
  156. package/dist/safe-bash/command-chunks/{chunk-X2YQLGKS.js → chunk-SAMH7SQE.js} +4 -4
  157. package/dist/safe-bash/command-chunks/chunk-SEM36PG5.js +11 -0
  158. package/dist/safe-bash/command-chunks/chunk-STC3LEWJ.js +634 -0
  159. package/dist/safe-bash/command-chunks/chunk-SVULUDOP.js +331 -0
  160. package/dist/safe-bash/command-chunks/{chunk-WYOL5JNT.js → chunk-SX2X3IH4.js} +4 -4
  161. package/dist/safe-bash/command-chunks/chunk-TEVJJPTC.js +1392 -0
  162. package/dist/safe-bash/command-chunks/{chunk-6N5V4VBN.js → chunk-TYCGMRLM.js} +2 -2
  163. package/dist/safe-bash/command-chunks/chunk-UG7SMZFF.js +178 -0
  164. package/dist/safe-bash/command-chunks/{chunk-PRCT7FKJ.js → chunk-UMDIOL3O.js} +3 -3
  165. package/dist/safe-bash/command-chunks/chunk-UXSR5BZH.js +136 -0
  166. package/dist/safe-bash/command-chunks/chunk-V6BEDRMQ.js +112 -0
  167. package/dist/safe-bash/command-chunks/chunk-V6MSPQLA.js +362 -0
  168. package/dist/safe-bash/command-chunks/{chunk-J4PEQWSF.js → chunk-VGG2DL5Q.js} +0 -1
  169. package/dist/safe-bash/command-chunks/{chunk-SG424QWS.js → chunk-VL67NWNS.js} +1 -1
  170. package/dist/safe-bash/command-chunks/chunk-WB5SVIG7.js +1034 -0
  171. package/dist/safe-bash/command-chunks/{src-UJOWAS2S.js → chunk-WD3ERGRY.js} +77 -277
  172. package/dist/safe-bash/command-chunks/{chunk-YFSDDFGV.js → chunk-WH627NJL.js} +446 -53
  173. package/dist/safe-bash/command-chunks/chunk-WNE7FPVR.js +236 -0
  174. package/dist/safe-bash/command-chunks/{chunk-UKS2XJZI.js → chunk-WPYIOKE3.js} +4 -4
  175. package/dist/safe-bash/command-chunks/chunk-XETLEHZP.js +1227 -0
  176. package/dist/safe-bash/command-chunks/chunk-XIIBTGC5.js +580 -0
  177. package/dist/safe-bash/command-chunks/chunk-XJXU3VVH.js +737 -0
  178. package/dist/safe-bash/command-chunks/{chunk-JCVXAX2G.js → chunk-XWZBMJ5B.js} +1 -1
  179. package/dist/safe-bash/command-chunks/chunk-Y5INTD6S.js +220 -0
  180. package/dist/safe-bash/command-chunks/{chunk-23XLM73P.js → chunk-YEOPI5SK.js} +1 -1
  181. package/dist/safe-bash/command-chunks/{chunk-PPOIPMY4.js → chunk-YGC6OS5O.js} +3 -56
  182. package/dist/safe-bash/command-chunks/chunk-YJDV76GL.js +262 -0
  183. package/dist/safe-bash/command-chunks/chunk-YOF7R4OY.js +80 -0
  184. package/dist/safe-bash/command-chunks/chunk-Z7RVSD5K.js +594 -0
  185. package/dist/safe-bash/command-chunks/chunk-ZHUWOUWB.js +618 -0
  186. package/dist/safe-bash/command-chunks/{chunk-OGUMMTTD.js → chunk-ZJBR5Q5I.js} +4 -4
  187. package/dist/safe-bash/command-chunks/{model-store-L35QTZMJ.js → model-store-WPKMRPV4.js} +2 -2
  188. package/dist/safe-bash/command-chunks/pptx-7G52EJ6L-4JACH5FB.js +625 -0
  189. package/dist/safe-bash/command-chunks/python-worker-source-TYOFJMCW.js +4 -0
  190. package/dist/safe-bash/command-chunks/src-ICMQISAA.js +501 -0
  191. package/dist/safe-bash/commands/archive/create.d.ts +1 -17
  192. package/dist/safe-bash/commands/archive/create.js +1 -252
  193. package/dist/safe-bash/commands/archive/extract.d.ts +1 -11
  194. package/dist/safe-bash/commands/archive/extract.js +1 -640
  195. package/dist/safe-bash/commands/archive/format.d.ts +1 -32
  196. package/dist/safe-bash/commands/archive/format.js +1 -225
  197. package/dist/safe-bash/commands/archive/index.d.ts +5 -10
  198. package/dist/safe-bash/commands/archive/index.js +6 -931
  199. package/dist/safe-bash/commands/archive/listing.d.ts +1 -2
  200. package/dist/safe-bash/commands/archive/listing.js +1 -21
  201. package/dist/safe-bash/commands/archive/modes.d.ts +1 -5
  202. package/dist/safe-bash/commands/archive/modes.js +1 -182
  203. package/dist/safe-bash/commands/archive/options.d.ts +1 -53
  204. package/dist/safe-bash/commands/archive/options.js +1 -462
  205. package/dist/safe-bash/commands/archive/stream.d.ts +1 -22
  206. package/dist/safe-bash/commands/archive/stream.js +1 -188
  207. package/dist/safe-bash/commands/archive/transform.d.ts +1 -16
  208. package/dist/safe-bash/commands/archive/transform.js +1 -85
  209. package/dist/safe-bash/commands/archive/unzip/arguments.d.ts +1 -53
  210. package/dist/safe-bash/commands/archive/unzip/arguments.js +1 -322
  211. package/dist/safe-bash/commands/archive/unzip/safety.d.ts +1 -32
  212. package/dist/safe-bash/commands/archive/unzip/safety.js +1 -295
  213. package/dist/safe-bash/commands/archive/unzip.d.ts +1 -3
  214. package/dist/safe-bash/commands/archive/unzip.js +1 -398
  215. package/dist/safe-bash/commands/archive/zip/aes.d.ts +1 -17
  216. package/dist/safe-bash/commands/archive/zip/aes.js +1 -156
  217. package/dist/safe-bash/commands/archive/zip/comments.d.ts +1 -17
  218. package/dist/safe-bash/commands/archive/zip/comments.js +1 -83
  219. package/dist/safe-bash/commands/archive/zip/crc.d.ts +1 -1
  220. package/dist/safe-bash/commands/archive/zip/crc.js +1 -1
  221. package/dist/safe-bash/commands/archive/zip/crypto.d.ts +1 -19
  222. package/dist/safe-bash/commands/archive/zip/crypto.js +1 -118
  223. package/dist/safe-bash/commands/archive/zip/dates.d.ts +1 -4
  224. package/dist/safe-bash/commands/archive/zip/dates.js +1 -66
  225. package/dist/safe-bash/commands/archive/zip/environment.d.ts +1 -2
  226. package/dist/safe-bash/commands/archive/zip/environment.js +1 -62
  227. package/dist/safe-bash/commands/archive/zip/grow.d.ts +1 -3
  228. package/dist/safe-bash/commands/archive/zip/grow.js +1 -2
  229. package/dist/safe-bash/commands/archive/zip/help.d.ts +1 -4
  230. package/dist/safe-bash/commands/archive/zip/help.js +1 -182
  231. package/dist/safe-bash/commands/archive/zip/line-endings.d.ts +1 -2
  232. package/dist/safe-bash/commands/archive/zip/line-endings.js +1 -194
  233. package/dist/safe-bash/commands/archive/zip/log.d.ts +1 -22
  234. package/dist/safe-bash/commands/archive/zip/log.js +1 -159
  235. package/dist/safe-bash/commands/archive/zip/lzma.d.ts +1 -9
  236. package/dist/safe-bash/commands/archive/zip/lzma.js +1 -40
  237. package/dist/safe-bash/commands/archive/zip/move.d.ts +1 -11
  238. package/dist/safe-bash/commands/archive/zip/move.js +1 -59
  239. package/dist/safe-bash/commands/archive/zip/names.d.ts +1 -2
  240. package/dist/safe-bash/commands/archive/zip/names.js +1 -33
  241. package/dist/safe-bash/commands/archive/zip/options.d.ts +1 -13
  242. package/dist/safe-bash/commands/archive/zip/options.js +1 -124
  243. package/dist/safe-bash/commands/archive/zip/repair.d.ts +1 -10
  244. package/dist/safe-bash/commands/archive/zip/repair.js +1 -392
  245. package/dist/safe-bash/commands/archive/zip/safety.d.ts +1 -54
  246. package/dist/safe-bash/commands/archive/zip/safety.js +1 -360
  247. package/dist/safe-bash/commands/archive/zip/sfx.d.ts +1 -4
  248. package/dist/safe-bash/commands/archive/zip/sfx.js +1 -52
  249. package/dist/safe-bash/commands/archive/zip/test-command.d.ts +1 -5
  250. package/dist/safe-bash/commands/archive/zip/test-command.js +1 -101
  251. package/dist/safe-bash/commands/archive/zip/volumes.d.ts +1 -21
  252. package/dist/safe-bash/commands/archive/zip/volumes.js +1 -281
  253. package/dist/safe-bash/commands/archive/zip/zip64.d.ts +1 -30
  254. package/dist/safe-bash/commands/archive/zip/zip64.js +1 -227
  255. package/dist/safe-bash/commands/archive/zip-format.d.ts +1 -68
  256. package/dist/safe-bash/commands/archive/zip-format.js +1 -1075
  257. package/dist/safe-bash/commands/archive/zip.d.ts +1 -3
  258. package/dist/safe-bash/commands/archive/zip.js +1 -1523
  259. package/dist/safe-bash/commands/awk/index.d.ts +2 -0
  260. package/dist/safe-bash/commands/awk/index.js +2 -0
  261. package/dist/safe-bash/commands/bytes/compression/index.js +2 -1
  262. package/dist/safe-bash/commands/curl/index.d.ts +2 -0
  263. package/dist/safe-bash/commands/curl/index.js +2 -0
  264. package/dist/safe-bash/commands/diff/index.d.ts +2 -0
  265. package/dist/safe-bash/commands/diff/index.js +2 -0
  266. package/dist/safe-bash/commands/diff-patch/diff-format.d.ts +1 -10
  267. package/dist/safe-bash/commands/diff-patch/diff-format.js +1 -237
  268. package/dist/safe-bash/commands/diff-patch/diff-options.d.ts +1 -38
  269. package/dist/safe-bash/commands/diff-patch/diff-options.js +1 -261
  270. package/dist/safe-bash/commands/diff-patch/diff-output.d.ts +1 -20
  271. package/dist/safe-bash/commands/diff-patch/diff-output.js +1 -290
  272. package/dist/safe-bash/commands/diff-patch/diff.d.ts +1 -2
  273. package/dist/safe-bash/commands/diff-patch/diff.js +1 -656
  274. package/dist/safe-bash/commands/diff-patch/index.d.ts +4 -5
  275. package/dist/safe-bash/commands/diff-patch/index.js +8 -333
  276. package/dist/safe-bash/commands/diff-patch/patch-envelope.d.ts +1 -2
  277. package/dist/safe-bash/commands/diff-patch/patch-envelope.js +1 -63
  278. package/dist/safe-bash/commands/diff-patch/patch-formats.d.ts +1 -7
  279. package/dist/safe-bash/commands/diff-patch/patch-formats.js +1 -264
  280. package/dist/safe-bash/commands/diff-patch/patch-gnu-paths.d.ts +1 -41
  281. package/dist/safe-bash/commands/diff-patch/patch-gnu-paths.js +1 -263
  282. package/dist/safe-bash/commands/diff-patch/patch-gnu-reject.d.ts +1 -3
  283. package/dist/safe-bash/commands/diff-patch/patch-gnu-reject.js +1 -100
  284. package/dist/safe-bash/commands/diff-patch/patch-path.d.ts +1 -3
  285. package/dist/safe-bash/commands/diff-patch/patch-path.js +1 -91
  286. package/dist/safe-bash/commands/diff-patch/patch-publication.d.ts +1 -13
  287. package/dist/safe-bash/commands/diff-patch/patch-publication.js +1 -107
  288. package/dist/safe-bash/commands/diff-patch/patch.d.ts +1 -2
  289. package/dist/safe-bash/commands/diff-patch/patch.js +1 -653
  290. package/dist/safe-bash/commands/diff-patch/shared.d.ts +1 -55
  291. package/dist/safe-bash/commands/diff-patch/shared.js +1 -276
  292. package/dist/safe-bash/commands/diff-patch/unified.d.ts +1 -52
  293. package/dist/safe-bash/commands/diff-patch/unified.js +1 -385
  294. package/dist/safe-bash/commands/directory-admission.d.ts +1 -3
  295. package/dist/safe-bash/commands/directory-admission.js +1 -26
  296. package/dist/safe-bash/commands/find/index.d.ts +2 -0
  297. package/dist/safe-bash/commands/find/index.js +2 -0
  298. package/dist/safe-bash/commands/find-format.d.ts +1 -20
  299. package/dist/safe-bash/commands/find-format.js +1 -161
  300. package/dist/safe-bash/commands/find.d.ts +2 -18
  301. package/dist/safe-bash/commands/find.js +2 -1236
  302. package/dist/safe-bash/commands/gzip/index.d.ts +2 -0
  303. package/dist/safe-bash/commands/gzip/index.js +2 -0
  304. package/dist/safe-bash/commands/line-endings/index.browser.js +1 -1
  305. package/dist/safe-bash/commands/line-endings/index.d.ts +1 -1
  306. package/dist/safe-bash/commands/line-endings/index.js +1 -262
  307. package/dist/safe-bash/commands/llm/index.browser.js +3 -1
  308. package/dist/safe-bash/commands/mdq/index.browser.js +2 -2
  309. package/dist/safe-bash/commands/metadata/chmod.d.ts +1 -4
  310. package/dist/safe-bash/commands/metadata/chmod.js +2 -63
  311. package/dist/safe-bash/commands/network/aggregate.d.ts +1 -4
  312. package/dist/safe-bash/commands/network/aggregate.js +1 -23
  313. package/dist/safe-bash/commands/network/args.d.ts +1 -68
  314. package/dist/safe-bash/commands/network/args.js +1 -321
  315. package/dist/safe-bash/commands/network/authorizer.d.ts +1 -6
  316. package/dist/safe-bash/commands/network/authorizer.js +1 -33
  317. package/dist/safe-bash/commands/network/body.d.ts +1 -9
  318. package/dist/safe-bash/commands/network/body.js +1 -393
  319. package/dist/safe-bash/commands/network/curl.d.ts +3 -13
  320. package/dist/safe-bash/commands/network/curl.js +6 -693
  321. package/dist/safe-bash/commands/network/deadline.d.ts +1 -2
  322. package/dist/safe-bash/commands/network/deadline.js +1 -14
  323. package/dist/safe-bash/commands/network/decode.d.ts +1 -2
  324. package/dist/safe-bash/commands/network/decode.js +1 -79
  325. package/dist/safe-bash/commands/network/fetch-transport.d.ts +1 -7
  326. package/dist/safe-bash/commands/network/fetch-transport.js +1 -94
  327. package/dist/safe-bash/commands/network/form-content-type.d.ts +1 -5
  328. package/dist/safe-bash/commands/network/form-content-type.js +1 -63
  329. package/dist/safe-bash/commands/network/form-headers.d.ts +1 -2
  330. package/dist/safe-bash/commands/network/form-headers.js +1 -35
  331. package/dist/safe-bash/commands/network/glob.d.ts +1 -7
  332. package/dist/safe-bash/commands/network/glob.js +1 -134
  333. package/dist/safe-bash/commands/network/index.browser.js +2 -10
  334. package/dist/safe-bash/commands/network/input.d.ts +1 -5
  335. package/dist/safe-bash/commands/network/input.js +1 -276
  336. package/dist/safe-bash/commands/network/output.d.ts +1 -6
  337. package/dist/safe-bash/commands/network/output.js +1 -131
  338. package/dist/safe-bash/commands/network/private-address.d.ts +1 -1
  339. package/dist/safe-bash/commands/network/private-address.js +1 -44
  340. package/dist/safe-bash/commands/network/shared.d.ts +1 -14
  341. package/dist/safe-bash/commands/network/shared.js +1 -71
  342. package/dist/safe-bash/commands/network/types.d.ts +1 -37
  343. package/dist/safe-bash/commands/network/types.js +1 -31
  344. package/dist/safe-bash/commands/network/url.d.ts +1 -2
  345. package/dist/safe-bash/commands/network/url.js +1 -30
  346. package/dist/safe-bash/commands/network/wget.d.ts +3 -3
  347. package/dist/safe-bash/commands/network/wget.js +10 -331
  348. package/dist/safe-bash/commands/node/index.browser.js +4 -5
  349. package/dist/safe-bash/commands/node/index.d.ts +3 -3
  350. package/dist/safe-bash/commands/node/index.js +5 -0
  351. package/dist/safe-bash/commands/node/safejs.d.ts +3 -3
  352. package/dist/safe-bash/commands/node/safejs.js +6 -1
  353. package/dist/safe-bash/commands/node/types.d.ts +1 -1
  354. package/dist/safe-bash/commands/node/unconfigured.d.ts +3 -0
  355. package/dist/safe-bash/commands/node/unconfigured.js +10 -0
  356. package/dist/safe-bash/commands/op/index.browser.js +2 -2
  357. package/dist/safe-bash/commands/patch/index.d.ts +2 -0
  358. package/dist/safe-bash/commands/patch/index.js +2 -0
  359. package/dist/safe-bash/commands/pdfinfo/index.js +2 -1
  360. package/dist/safe-bash/commands/predicates.js +3 -4
  361. package/dist/safe-bash/commands/python/index.browser.js +5 -5
  362. package/dist/safe-bash/commands/python/llm-capability.d.ts +1 -0
  363. package/dist/safe-bash/commands/python/llm-capability.js +27 -7
  364. package/dist/safe-bash/commands/python/llm-module.js +11 -0
  365. package/dist/safe-bash/commands/python/manifest.d.ts +1 -0
  366. package/dist/safe-bash/commands/python/manifest.js +9 -5
  367. package/dist/safe-bash/commands/python/provisioning.js +1 -1
  368. package/dist/safe-bash/commands/regex-execution/matching.js +1 -2
  369. package/dist/safe-bash/commands/regex-execution/public.browser.js +5 -5
  370. package/dist/safe-bash/commands/search/index.d.ts +1 -1
  371. package/dist/safe-bash/commands/search/index.js +1 -347
  372. package/dist/safe-bash/commands/search/portable.d.ts +2 -2
  373. package/dist/safe-bash/commands/search/portable.js +3 -2
  374. package/dist/safe-bash/commands/sed/index.d.ts +2 -0
  375. package/dist/safe-bash/commands/sed/index.js +2 -0
  376. package/dist/safe-bash/commands/tar/index.d.ts +2 -0
  377. package/dist/safe-bash/commands/tar/index.js +2 -0
  378. package/dist/safe-bash/commands/text-programs/awk-inspection.d.ts +1 -19
  379. package/dist/safe-bash/commands/text-programs/awk-inspection.js +1 -50
  380. package/dist/safe-bash/commands/text-programs/awk-pipes.d.ts +2 -0
  381. package/dist/safe-bash/commands/text-programs/awk-pipes.js +2 -0
  382. package/dist/safe-bash/commands/text-programs/awk-pretty.d.ts +1 -3
  383. package/dist/safe-bash/commands/text-programs/awk-pretty.js +1 -197
  384. package/dist/safe-bash/commands/text-programs/awk-quote.d.ts +1 -2
  385. package/dist/safe-bash/commands/text-programs/awk-quote.js +1 -15
  386. package/dist/safe-bash/commands/text-programs/awk-reader.d.ts +1 -42
  387. package/dist/safe-bash/commands/text-programs/awk-reader.js +1 -449
  388. package/dist/safe-bash/commands/text-programs/awk-retention.d.ts +1 -13
  389. package/dist/safe-bash/commands/text-programs/awk-retention.js +1 -51
  390. package/dist/safe-bash/commands/text-programs/awk-runtime.d.ts +1 -150
  391. package/dist/safe-bash/commands/text-programs/awk-runtime.js +1 -2627
  392. package/dist/safe-bash/commands/text-programs/awk-syntax.d.ts +1 -142
  393. package/dist/safe-bash/commands/text-programs/awk-syntax.js +1 -509
  394. package/dist/safe-bash/commands/text-programs/awk-values.d.ts +1 -32
  395. package/dist/safe-bash/commands/text-programs/awk-values.js +1 -386
  396. package/dist/safe-bash/commands/text-programs/awk.d.ts +1 -3
  397. package/dist/safe-bash/commands/text-programs/awk.js +1 -361
  398. package/dist/safe-bash/commands/text-programs/inplace.d.ts +1 -16
  399. package/dist/safe-bash/commands/text-programs/inplace.js +1 -155
  400. package/dist/safe-bash/commands/text-programs/sed.d.ts +1 -3
  401. package/dist/safe-bash/commands/text-programs/sed.js +1 -1647
  402. package/dist/safe-bash/commands/text.js +1 -25
  403. package/dist/safe-bash/commands/unzip/index.d.ts +2 -0
  404. package/dist/safe-bash/commands/unzip/index.js +2 -0
  405. package/dist/safe-bash/commands/wget/index.d.ts +2 -0
  406. package/dist/safe-bash/commands/wget/index.js +2 -0
  407. package/dist/safe-bash/commands/yq/index.browser.js +7 -2
  408. package/dist/safe-bash/commands/yq/index.d.ts +1 -6
  409. package/dist/safe-bash/commands/yq/index.js +1 -36
  410. package/dist/safe-bash/commands/zip/index.d.ts +2 -0
  411. package/dist/safe-bash/commands/zip/index.js +2 -0
  412. package/dist/safe-bash/core.browser.js +1 -1
  413. package/dist/safe-bash/core.d.ts +8 -1
  414. package/dist/safe-bash/core.js +7 -1
  415. package/dist/safe-bash/fs/s3/index.d.ts +2 -2
  416. package/dist/safe-bash/fs/s3/index.js +1 -1
  417. package/dist/safe-bash/full-core.browser.js +254 -223
  418. package/dist/safe-bash/jobs.browser.js +2 -2
  419. package/dist/safe-bash/lazy-mmdc.d.ts +6 -0
  420. package/dist/safe-bash/lazy-mmdc.js +23 -0
  421. package/dist/safe-bash/opt-in/commands/dd/index.js +4 -13
  422. package/dist/safe-bash/opt-in/commands/yq/mike.js +6 -13
  423. package/dist/safe-bash/opt-in/commands/yq/native-work.d.ts +1 -0
  424. package/dist/safe-bash/opt-in/commands/yq/native-work.js +19 -1
  425. package/dist/safe-bash/opt-in/optional/commands/shuf/input.js +3 -21
  426. package/dist/safe-bash/opt-in/optional/commands/shuf/shuf.js +4 -27
  427. package/dist/safe-bash/optional-host.browser.js +8 -4
  428. package/dist/safe-bash/optional-host.d.ts +1 -1
  429. package/dist/safe-bash/optional-host.js +1 -1
  430. package/dist/safe-bash/playwright/ability-execution.js +3 -2
  431. package/dist/safe-bash/playwright/adapter.js +1 -1
  432. package/dist/safe-bash/playwright/controller.js +9 -8
  433. package/dist/safe-bash/playwright/modal-capabilities.js +2 -1
  434. package/dist/safe-bash/playwright/native-json-snapshot.js +4 -3
  435. package/dist/safe-bash/playwright/native-snapshot.js +5 -4
  436. package/dist/safe-bash/playwright/open-options.js +3 -3
  437. package/dist/safe-bash/playwright/resource-limit.d.ts +2 -0
  438. package/dist/safe-bash/playwright/resource-limit.js +4 -0
  439. package/dist/safe-bash/playwright/session-configuration.js +8 -3
  440. package/dist/safe-bash/playwright/snapshot.js +8 -7
  441. package/dist/safe-bash/playwright/standard-capabilities.js +5 -4
  442. package/dist/safe-bash/plugins/index.browser.js +14 -16
  443. package/dist/safe-bash/registry-entry.browser.js +14 -16
  444. package/dist/safe-bash/shell/arrays/bindings.d.ts +3 -5
  445. package/dist/safe-bash/shell/arrays/bindings.js +6 -2
  446. package/dist/safe-bash/shell/input.js +16 -14
  447. package/dist/safe-bash/shell/runtime.d.ts +3 -0
  448. package/dist/safe-bash/shell/runtime.js +316 -64
  449. package/dist/safe-bash/shell/types.d.ts +2 -0
  450. package/dist/safe-bash/shell/value-state.js +17 -2
  451. package/dist/safe-bash/shell/worker-limits.js +1 -0
  452. package/dist/safe-bash/shell-entry.browser.js +13 -15
  453. package/dist/safe-bash/trap.browser.d.ts +3 -0
  454. package/dist/safe-bash/trap.browser.js +14 -0
  455. package/dist/safe-bash/worker/host.js +1 -1
  456. package/dist/safe-bash-command-apply-patch/apply.js +2 -2
  457. package/dist/safe-bash-command-apply-patch/index.js +3 -3
  458. package/dist/safe-bash-command-awk/LICENSE +21 -0
  459. package/dist/safe-bash-command-awk/awk-inspection.d.ts +19 -0
  460. package/dist/safe-bash-command-awk/awk-inspection.js +9 -0
  461. package/dist/safe-bash-command-awk/awk-pipes.d.ts +19 -0
  462. package/dist/safe-bash-command-awk/awk-pipes.js +8 -0
  463. package/dist/safe-bash-command-awk/awk-pretty.d.ts +3 -0
  464. package/dist/safe-bash-command-awk/awk-pretty.js +8 -0
  465. package/dist/safe-bash-command-awk/awk-quote.d.ts +2 -0
  466. package/dist/safe-bash-command-awk/awk-quote.js +7 -0
  467. package/dist/safe-bash-command-awk/awk-reader.d.ts +42 -0
  468. package/dist/safe-bash-command-awk/awk-reader.js +9 -0
  469. package/dist/safe-bash-command-awk/awk-retention.d.ts +13 -0
  470. package/dist/safe-bash-command-awk/awk-retention.js +7 -0
  471. package/dist/safe-bash-command-awk/awk-runtime.d.ts +151 -0
  472. package/dist/safe-bash-command-awk/awk-runtime.js +11 -0
  473. package/dist/safe-bash-command-awk/awk-syntax.d.ts +144 -0
  474. package/dist/safe-bash-command-awk/awk-syntax.js +14 -0
  475. package/dist/safe-bash-command-awk/awk-values.d.ts +32 -0
  476. package/dist/safe-bash-command-awk/awk-values.js +35 -0
  477. package/dist/safe-bash-command-awk/awk.d.ts +3 -0
  478. package/dist/safe-bash-command-awk/awk.js +16 -0
  479. package/dist/safe-bash-command-awk/index.d.ts +7 -0
  480. package/dist/safe-bash-command-awk/index.js +36 -0
  481. package/dist/safe-bash-command-bc/index.d.ts +4 -0
  482. package/dist/safe-bash-command-bc/index.js +15 -176
  483. package/dist/safe-bash-command-column/column.js +3 -3
  484. package/dist/safe-bash-command-column/index.js +3 -3
  485. package/dist/safe-bash-command-column/layout.js +2 -2
  486. package/dist/safe-bash-command-csplit/command.js +2 -2
  487. package/dist/safe-bash-command-csplit/index.js +2 -2
  488. package/dist/safe-bash-command-csvkit/contracts.d.ts +1 -0
  489. package/dist/safe-bash-command-csvkit/csvpy-interpreter.d.ts +2 -1
  490. package/dist/safe-bash-command-csvkit/default-csvpy.d.ts +11 -0
  491. package/dist/safe-bash-command-csvkit/errors.js +22 -0
  492. package/dist/safe-bash-command-csvkit/index.d.ts +1 -0
  493. package/dist/safe-bash-command-csvkit/index.js +172 -4
  494. package/dist/safe-bash-command-csvkit/python-worker-browser.d.ts +3 -0
  495. package/dist/safe-bash-command-csvkit/python-worker-browser.js +16 -0
  496. package/dist/safe-bash-command-csvkit/python-worker-contract.d.ts +20 -0
  497. package/dist/safe-bash-command-csvkit/python-worker-node.d.ts +3 -0
  498. package/dist/safe-bash-command-csvkit/python-worker-node.js +9 -0
  499. package/dist/safe-bash-command-csvkit/runtime.d.ts +1 -0
  500. package/dist/safe-bash-command-curl/LICENSE +21 -0
  501. package/dist/safe-bash-command-curl/curl.d.ts +13 -0
  502. package/dist/safe-bash-command-curl/curl.js +9 -0
  503. package/dist/safe-bash-command-curl/index.d.ts +6 -0
  504. package/dist/safe-bash-command-curl/index.js +26 -0
  505. package/dist/safe-bash-command-dd/index.js +4 -13
  506. package/dist/safe-bash-command-diff/LICENSE +21 -0
  507. package/dist/safe-bash-command-diff/diff-format.d.ts +10 -0
  508. package/dist/safe-bash-command-diff/diff-format.js +10 -0
  509. package/dist/safe-bash-command-diff/diff-options.d.ts +38 -0
  510. package/dist/safe-bash-command-diff/diff-options.js +7 -0
  511. package/dist/safe-bash-command-diff/diff-output.d.ts +20 -0
  512. package/dist/safe-bash-command-diff/diff-output.js +19 -0
  513. package/dist/safe-bash-command-diff/diff.d.ts +2 -0
  514. package/dist/safe-bash-command-diff/diff.js +10 -0
  515. package/dist/safe-bash-command-diff/index.d.ts +8 -0
  516. package/dist/safe-bash-command-diff/index.js +34 -0
  517. package/dist/safe-bash-command-diff/sync.d.ts +2 -0
  518. package/dist/safe-bash-command-diff/sync.js +9 -0
  519. package/dist/safe-bash-command-diff3/index.js +5 -5
  520. package/dist/safe-bash-command-docx/index.d.ts +4 -4
  521. package/dist/safe-bash-command-docx/index.js +12 -5
  522. package/dist/safe-bash-command-dos2unix/index.d.ts +1 -0
  523. package/dist/safe-bash-command-dos2unix/index.js +225 -1
  524. package/dist/safe-bash-command-dos2unix/sync.d.ts +1 -0
  525. package/dist/safe-bash-command-du/budget.d.ts +0 -2
  526. package/dist/safe-bash-command-du/budget.js +1 -1
  527. package/dist/safe-bash-command-du/du.js +2 -2
  528. package/dist/safe-bash-command-du/index.js +2 -2
  529. package/dist/safe-bash-command-exiftool/index.js +2 -2
  530. package/dist/safe-bash-command-factor/command.js +2 -2
  531. package/dist/safe-bash-command-factor/index.js +2 -2
  532. package/dist/safe-bash-command-ffmpeg/index.js +86 -94
  533. package/dist/safe-bash-command-file/index.js +4 -4
  534. package/dist/safe-bash-command-file/shared.d.ts +0 -2
  535. package/dist/safe-bash-command-file/shared.js +1 -1
  536. package/dist/safe-bash-command-find/LICENSE +21 -0
  537. package/dist/safe-bash-command-find/find-format.d.ts +20 -0
  538. package/dist/safe-bash-command-find/find-format.js +9 -0
  539. package/dist/safe-bash-command-find/find.d.ts +18 -0
  540. package/dist/safe-bash-command-find/find.js +10 -0
  541. package/dist/safe-bash-command-find/index.d.ts +13 -0
  542. package/dist/safe-bash-command-find/index.js +45 -0
  543. package/dist/safe-bash-command-fmt/index.js +10 -19
  544. package/dist/safe-bash-command-git/git_rust.wasm +0 -0
  545. package/dist/safe-bash-command-git/index.js +5 -7
  546. package/dist/safe-bash-command-git/wasm.generated.js +1 -1
  547. package/dist/safe-bash-command-gzip/LICENSE +21 -0
  548. package/dist/safe-bash-command-gzip/index.d.ts +11 -0
  549. package/dist/safe-bash-command-gzip/index.js +94 -0
  550. package/dist/safe-bash-command-html-to-markdown/budget.d.ts +0 -3
  551. package/dist/safe-bash-command-html-to-markdown/budget.js +1 -1
  552. package/dist/safe-bash-command-html-to-markdown/entities.js +3 -3
  553. package/dist/safe-bash-command-html-to-markdown/index.js +11 -11
  554. package/dist/safe-bash-command-html-to-markdown/input.js +5 -5
  555. package/dist/safe-bash-command-html-to-markdown/parser.js +4 -4
  556. package/dist/safe-bash-command-html-to-markdown/render.js +5 -5
  557. package/dist/safe-bash-command-html-to-markdown/text.js +2 -2
  558. package/dist/safe-bash-command-htmlq/index.js +12 -8
  559. package/dist/safe-bash-command-iconv/command.js +5 -5
  560. package/dist/safe-bash-command-iconv/index.js +5 -5
  561. package/dist/safe-bash-command-iconv/internal.d.ts +0 -2
  562. package/dist/safe-bash-command-iconv/internal.js +1 -1
  563. package/dist/safe-bash-command-iconv/lifecycle.js +2 -2
  564. package/dist/safe-bash-command-iconv/options.js +2 -2
  565. package/dist/safe-bash-command-iconv/reader.js +2 -2
  566. package/dist/safe-bash-command-imagemagick/index.js +22 -30
  567. package/dist/safe-bash-command-jq/index.js +1 -1
  568. package/dist/safe-bash-command-jq/jq.js +1 -1
  569. package/dist/safe-bash-command-llm/command.js +1 -1
  570. package/dist/safe-bash-command-llm/index.d.ts +1 -0
  571. package/dist/safe-bash-command-llm/index.js +16 -14
  572. package/dist/safe-bash-command-llm/openai.js +3 -3
  573. package/dist/safe-bash-command-llm/providers/index.js +3 -3
  574. package/dist/safe-bash-command-llm/providers/openai.js +3 -3
  575. package/dist/safe-bash-command-llm/stored-schema.d.ts +10 -0
  576. package/dist/safe-bash-command-mmdc/index.js +13 -604
  577. package/dist/safe-bash-command-mmdc/settings.d.ts +2 -0
  578. package/dist/safe-bash-command-mmdc/settings.js +7 -0
  579. package/dist/safe-bash-command-numfmt/index.js +4 -18
  580. package/dist/safe-bash-command-pandoc/command.js +4 -3
  581. package/dist/safe-bash-command-pandoc/defaults.d.ts +1 -0
  582. package/dist/safe-bash-command-pandoc/index.js +4 -3
  583. package/dist/safe-bash-command-pandoc/lua-filters.js +1 -1
  584. package/dist/safe-bash-command-pandoc/types.d.ts +3 -1
  585. package/dist/safe-bash-command-patch/LICENSE +21 -0
  586. package/dist/safe-bash-command-patch/index.d.ts +8 -0
  587. package/dist/safe-bash-command-patch/index.js +38 -0
  588. package/dist/safe-bash-command-patch/patch-envelope.d.ts +2 -0
  589. package/dist/safe-bash-command-patch/patch-envelope.js +7 -0
  590. package/dist/safe-bash-command-patch/patch-formats.d.ts +7 -0
  591. package/dist/safe-bash-command-patch/patch-formats.js +9 -0
  592. package/dist/safe-bash-command-patch/patch-gnu-paths.d.ts +41 -0
  593. package/dist/safe-bash-command-patch/patch-gnu-paths.js +26 -0
  594. package/dist/safe-bash-command-patch/patch-gnu-reject.d.ts +3 -0
  595. package/dist/safe-bash-command-patch/patch-gnu-reject.js +7 -0
  596. package/dist/safe-bash-command-patch/patch-path.d.ts +3 -0
  597. package/dist/safe-bash-command-patch/patch-path.js +11 -0
  598. package/dist/safe-bash-command-patch/patch-publication.d.ts +13 -0
  599. package/dist/safe-bash-command-patch/patch-publication.js +7 -0
  600. package/dist/safe-bash-command-patch/patch.d.ts +2 -0
  601. package/dist/safe-bash-command-patch/patch.js +14 -0
  602. package/dist/safe-bash-command-patch/sync.d.ts +2 -0
  603. package/dist/safe-bash-command-patch/sync.js +7 -0
  604. package/dist/safe-bash-command-patch/unified.d.ts +52 -0
  605. package/dist/safe-bash-command-patch/unified.js +16 -0
  606. package/dist/safe-bash-command-pdfimages/index.js +37 -16
  607. package/dist/safe-bash-command-pdfinfo/index.d.ts +0 -23
  608. package/dist/safe-bash-command-pdfinfo/index.js +20 -772
  609. package/dist/safe-bash-command-pdftk/index.js +37 -9
  610. package/dist/safe-bash-command-pdftoppm/index.js +50 -20
  611. package/dist/safe-bash-command-pdftotext/index.js +10 -2
  612. package/dist/safe-bash-command-pptx/index.d.ts +4 -4
  613. package/dist/safe-bash-command-pptx/index.js +11 -5
  614. package/dist/safe-bash-command-pr/command.js +5 -5
  615. package/dist/safe-bash-command-pr/format.js +2 -2
  616. package/dist/safe-bash-command-pr/index.js +7 -7
  617. package/dist/safe-bash-command-pr/internal.d.ts +0 -2
  618. package/dist/safe-bash-command-pr/internal.js +1 -1
  619. package/dist/safe-bash-command-pr/io.js +2 -2
  620. package/dist/safe-bash-command-pr/options.js +2 -2
  621. package/dist/safe-bash-command-qpdf/index.js +26 -13
  622. package/dist/safe-bash-command-rg/index.d.ts +1 -0
  623. package/dist/safe-bash-command-rg/index.js +222 -1
  624. package/dist/safe-bash-command-rg/rg-command.js +1 -1
  625. package/dist/safe-bash-command-rg/sync.d.ts +1 -0
  626. package/dist/safe-bash-command-sed/LICENSE +21 -0
  627. package/dist/safe-bash-command-sed/index.d.ts +7 -0
  628. package/dist/safe-bash-command-sed/index.js +28 -0
  629. package/dist/safe-bash-command-sed/inplace.d.ts +16 -0
  630. package/dist/safe-bash-command-sed/inplace.js +9 -0
  631. package/dist/safe-bash-command-sed/sed.d.ts +3 -0
  632. package/dist/safe-bash-command-sed/sed.js +8 -0
  633. package/dist/safe-bash-command-shuf/input.js +3 -21
  634. package/dist/safe-bash-command-shuf/shuf.js +4 -27
  635. package/dist/safe-bash-command-sips/index.js +111 -35
  636. package/dist/safe-bash-command-soffice/index.js +4 -4
  637. package/dist/safe-bash-command-split/index.js +3 -3
  638. package/dist/safe-bash-command-split/io.d.ts +0 -2
  639. package/dist/safe-bash-command-split/io.js +1 -1
  640. package/dist/safe-bash-command-split/outputs.js +2 -2
  641. package/dist/safe-bash-command-split/split.js +3 -3
  642. package/dist/safe-bash-command-sqlite3/engine.d.ts +1 -2
  643. package/dist/safe-bash-command-sqlite3/index.js +152 -452
  644. package/dist/safe-bash-command-ssconvert/commands.js +1 -1
  645. package/dist/safe-bash-command-ssconvert/formats/ods.js +2 -2
  646. package/dist/safe-bash-command-ssconvert/formats/xlsx.js +3 -3
  647. package/dist/safe-bash-command-ssconvert/index.js +5 -5
  648. package/dist/safe-bash-command-tar/LICENSE +21 -0
  649. package/dist/safe-bash-command-tar/create.d.ts +17 -0
  650. package/dist/safe-bash-command-tar/create.js +14 -0
  651. package/dist/safe-bash-command-tar/extract.d.ts +11 -0
  652. package/dist/safe-bash-command-tar/extract.js +14 -0
  653. package/dist/safe-bash-command-tar/format.d.ts +32 -0
  654. package/dist/safe-bash-command-tar/format.js +19 -0
  655. package/dist/safe-bash-command-tar/index.d.ts +8 -0
  656. package/dist/safe-bash-command-tar/index.js +550 -0
  657. package/dist/safe-bash-command-tar/listing.d.ts +2 -0
  658. package/dist/safe-bash-command-tar/listing.js +7 -0
  659. package/dist/safe-bash-command-tar/modes.d.ts +5 -0
  660. package/dist/safe-bash-command-tar/modes.js +16 -0
  661. package/dist/safe-bash-command-tar/options.d.ts +53 -0
  662. package/dist/safe-bash-command-tar/options.js +10 -0
  663. package/dist/safe-bash-command-tar/stream.d.ts +22 -0
  664. package/dist/safe-bash-command-tar/stream.js +15 -0
  665. package/dist/safe-bash-command-tar/transform.d.ts +16 -0
  666. package/dist/safe-bash-command-tar/transform.js +9 -0
  667. package/dist/safe-bash-command-tree/arguments.js +3 -3
  668. package/dist/safe-bash-command-tree/charset.js +1 -1
  669. package/dist/safe-bash-command-tree/index.js +4 -4
  670. package/dist/safe-bash-command-tree/io.d.ts +0 -1
  671. package/dist/safe-bash-command-tree/io.js +1 -1
  672. package/dist/safe-bash-command-tree/pattern.js +2 -2
  673. package/dist/safe-bash-command-tree/tree.js +4 -4
  674. package/dist/safe-bash-command-tsort/command.js +4 -4
  675. package/dist/safe-bash-command-tsort/graph.js +2 -2
  676. package/dist/safe-bash-command-tsort/index.js +4 -4
  677. package/dist/safe-bash-command-tsort/internal.d.ts +0 -2
  678. package/dist/safe-bash-command-tsort/internal.js +1 -1
  679. package/dist/safe-bash-command-tsort/io.js +2 -2
  680. package/dist/safe-bash-command-unzip/LICENSE +21 -0
  681. package/dist/safe-bash-command-unzip/index.d.ts +7 -0
  682. package/dist/safe-bash-command-unzip/index.js +39 -0
  683. package/dist/safe-bash-command-unzip/sync.d.ts +3 -0
  684. package/dist/safe-bash-command-unzip/sync.js +9 -0
  685. package/dist/safe-bash-command-unzip/unzip/safety.d.ts +32 -0
  686. package/dist/safe-bash-command-unzip/unzip/safety.js +7 -0
  687. package/dist/safe-bash-command-unzip/unzip.d.ts +3 -0
  688. package/dist/safe-bash-command-unzip/unzip.js +8 -0
  689. package/dist/safe-bash-command-wget/LICENSE +21 -0
  690. package/dist/safe-bash-command-wget/index.d.ts +6 -0
  691. package/dist/safe-bash-command-wget/index.js +26 -0
  692. package/dist/safe-bash-command-wget/wget.d.ts +3 -0
  693. package/dist/safe-bash-command-wget/wget.js +7 -0
  694. package/dist/safe-bash-command-xan/argv.d.ts +4 -1
  695. package/dist/safe-bash-command-xan/argv.js +1 -1
  696. package/dist/safe-bash-command-xan/commands.js +4 -3
  697. package/dist/safe-bash-command-xan/index.js +15 -14
  698. package/dist/safe-bash-command-xan/io.js +2 -2
  699. package/dist/safe-bash-command-xmllint/index.js +189 -49
  700. package/dist/safe-bash-command-xz/index.js +3 -2
  701. package/dist/safe-bash-command-xz/options.d.ts +9 -1
  702. package/dist/safe-bash-command-xz/options.js +3 -1
  703. package/dist/safe-bash-command-yq/index.d.ts +4 -11
  704. package/dist/safe-bash-command-yq/index.js +3367 -670
  705. package/dist/safe-bash-command-yq/mike.js +6 -13
  706. package/dist/safe-bash-command-yq/native-work.d.ts +1 -0
  707. package/dist/safe-bash-command-yq/native-work.js +19 -1
  708. package/dist/safe-bash-command-yq/query.d.ts +11 -0
  709. package/dist/safe-bash-command-yq/query.js +735 -0
  710. package/dist/safe-bash-command-zip/LICENSE +21 -0
  711. package/dist/safe-bash-command-zip/index.d.ts +7 -0
  712. package/dist/safe-bash-command-zip/index.js +38 -0
  713. package/dist/safe-bash-command-zip/sync.d.ts +3 -0
  714. package/dist/safe-bash-command-zip/sync.js +9 -0
  715. package/dist/safe-bash-command-zip/zip.d.ts +3 -0
  716. package/dist/safe-bash-command-zip/zip.js +7 -0
  717. package/dist/safe-bash-compression-engine/files.js +4 -4
  718. package/dist/safe-bash-compression-engine/index.js +2 -2
  719. package/dist/safe-bash-compression-engine/operand.js +6 -6
  720. package/dist/safe-bash-compression-engine/stream.js +2 -2
  721. package/dist/safe-bash-compression-engine/zstd-decode.js +1 -1
  722. package/dist/safe-bash-contracts/command.js +1 -1
  723. package/dist/safe-bash-contracts/diagnostics.js +4 -4
  724. package/dist/safe-bash-contracts/escaping.js +11 -11
  725. package/dist/safe-bash-contracts/filesystem-descriptor.js +1 -1
  726. package/dist/safe-bash-contracts/filesystem-output.js +8 -8
  727. package/dist/safe-bash-contracts/index.js +34 -34
  728. package/dist/safe-bash-contracts/io.js +2 -2
  729. package/dist/safe-bash-contracts/output.js +3 -3
  730. package/dist/safe-bash-diff-engine/LICENSE +21 -0
  731. package/dist/safe-bash-diff-engine/index.d.ts +1 -0
  732. package/dist/safe-bash-diff-engine/index.js +24 -0
  733. package/dist/safe-bash-diff-engine/shared.d.ts +53 -0
  734. package/dist/safe-bash-diff-engine/shared.js +19 -0
  735. package/dist/safe-bash-io-engine/commands/archive/internal.d.ts +0 -1
  736. package/dist/safe-bash-io-engine/commands/archive/internal.js +3 -7
  737. package/dist/safe-bash-io-engine/commands/directory-admission.d.ts +3 -0
  738. package/dist/safe-bash-io-engine/commands/directory-admission.js +34 -0
  739. package/dist/safe-bash-io-engine/commands/mode-change.d.ts +4 -0
  740. package/dist/safe-bash-io-engine/commands/mode-change.js +60 -0
  741. package/dist/safe-bash-io-engine/commands/text-programs/shared.js +20 -31
  742. package/dist/safe-bash-io-engine/shell/pattern.js +8 -13
  743. package/dist/safe-bash-io-engine/shell/string-operations.d.ts +0 -2
  744. package/dist/safe-bash-io-engine/shell/string-operations.js +1 -1
  745. package/dist/safe-bash-line-ending-engine/internal.d.ts +0 -2
  746. package/dist/safe-bash-line-ending-engine/internal.js +1 -9
  747. package/dist/safe-bash-markdown-engine/commonmark-blocks.js +4 -4
  748. package/dist/safe-bash-markdown-engine/commonmark-inlines.js +4 -4
  749. package/dist/safe-bash-markdown-engine/commonmark-syntax.js +2 -2
  750. package/dist/safe-bash-markdown-engine/gfm-syntax.js +3 -3
  751. package/dist/safe-bash-markdown-engine/index.js +7 -7
  752. package/dist/safe-bash-mcp/index.browser.d.ts +6 -0
  753. package/dist/safe-bash-mcp/index.browser.js +1 -0
  754. package/dist/safe-bash-mcp/index.d.ts +12 -0
  755. package/dist/safe-bash-mcp/index.js +1558 -36
  756. package/dist/safe-bash-network-engine/LICENSE +21 -0
  757. package/dist/safe-bash-network-engine/aggregate.d.ts +4 -0
  758. package/dist/safe-bash-network-engine/aggregate.js +37 -0
  759. package/dist/safe-bash-network-engine/args.d.ts +68 -0
  760. package/dist/safe-bash-network-engine/args.js +19 -0
  761. package/dist/safe-bash-network-engine/authorizer.d.ts +6 -0
  762. package/dist/safe-bash-network-engine/authorizer.js +8 -0
  763. package/dist/safe-bash-network-engine/body.d.ts +9 -0
  764. package/dist/safe-bash-network-engine/body.js +374 -0
  765. package/dist/safe-bash-network-engine/deadline.d.ts +2 -0
  766. package/dist/safe-bash-network-engine/deadline.js +7 -0
  767. package/dist/safe-bash-network-engine/decode.d.ts +2 -0
  768. package/dist/safe-bash-network-engine/decode.js +81 -0
  769. package/dist/safe-bash-network-engine/fetch-transport.d.ts +7 -0
  770. package/dist/safe-bash-network-engine/fetch-transport.js +9 -0
  771. package/dist/safe-bash-network-engine/form-content-type.d.ts +5 -0
  772. package/dist/safe-bash-network-engine/form-content-type.js +8 -0
  773. package/dist/safe-bash-network-engine/form-headers.d.ts +2 -0
  774. package/dist/safe-bash-network-engine/form-headers.js +10 -0
  775. package/dist/safe-bash-network-engine/glob.d.ts +7 -0
  776. package/dist/safe-bash-network-engine/glob.js +124 -0
  777. package/dist/safe-bash-network-engine/index.d.ts +3 -0
  778. package/dist/safe-bash-network-engine/index.js +26 -0
  779. package/dist/safe-bash-network-engine/input.d.ts +5 -0
  780. package/dist/safe-bash-network-engine/input.js +255 -0
  781. package/dist/safe-bash-network-engine/output.d.ts +6 -0
  782. package/dist/safe-bash-network-engine/output.js +132 -0
  783. package/dist/safe-bash-network-engine/platform-portable.d.ts +5 -0
  784. package/dist/safe-bash-network-engine/platform-portable.js +19 -0
  785. package/dist/safe-bash-network-engine/private-address.d.ts +1 -0
  786. package/dist/safe-bash-network-engine/private-address.js +7 -0
  787. package/dist/safe-bash-network-engine/shared.d.ts +14 -0
  788. package/dist/safe-bash-network-engine/shared.js +23 -0
  789. package/dist/safe-bash-network-engine/types.d.ts +37 -0
  790. package/dist/safe-bash-network-engine/types.js +11 -0
  791. package/dist/safe-bash-network-engine/url.d.ts +2 -0
  792. package/dist/safe-bash-network-engine/url.js +8 -0
  793. package/dist/safe-bash-query-engine/capture.d.ts +1 -0
  794. package/dist/safe-bash-query-engine/capture.js +9 -7
  795. package/dist/safe-bash-query-engine/dates.d.ts +5 -1
  796. package/dist/safe-bash-query-engine/dates.js +10 -2
  797. package/dist/safe-bash-query-engine/delpaths.js +5 -5
  798. package/dist/safe-bash-query-engine/formats.js +3 -3
  799. package/dist/safe-bash-query-engine/index.js +15 -15
  800. package/dist/safe-bash-query-engine/indices.js +5 -5
  801. package/dist/safe-bash-query-engine/input.d.ts +1 -2
  802. package/dist/safe-bash-query-engine/input.js +2 -4
  803. package/dist/safe-bash-query-engine/interpreter.d.ts +5 -0
  804. package/dist/safe-bash-query-engine/interpreter.js +13 -13
  805. package/dist/safe-bash-query-engine/limits.js +1 -1
  806. package/dist/safe-bash-query-engine/parser.d.ts +8 -1
  807. package/dist/safe-bash-query-engine/parser.js +2 -2
  808. package/dist/safe-bash-query-engine/query-core.js +15 -15
  809. package/dist/safe-bash-query-engine/recurse.js +2 -2
  810. package/dist/safe-bash-query-engine/regex.d.ts +4 -2
  811. package/dist/safe-bash-query-engine/regex.js +10 -5
  812. package/dist/safe-bash-query-engine/split.js +2 -2
  813. package/dist/safe-bash-query-engine/splits.d.ts +1 -1
  814. package/dist/safe-bash-query-engine/splits.js +7 -6
  815. package/dist/safe-bash-query-engine/values.js +4 -4
  816. package/dist/safe-bash-regex-engine/ere/limits.d.ts +0 -1
  817. package/dist/safe-bash-regex-engine/ere/limits.js +1 -1
  818. package/dist/safe-bash-regex-engine/ere/matcher.js +9 -9
  819. package/dist/safe-bash-regex-engine/ere/syntax.js +2 -2
  820. package/dist/safe-bash-regex-engine/execution/bounded-provider.js +2 -4
  821. package/dist/safe-bash-regex-engine/index.js +2 -2
  822. package/dist/safe-bash-regex-engine/text/regex.d.ts +1 -0
  823. package/dist/safe-bash-regex-engine/text/regex.js +2 -2
  824. package/dist/safe-bash-search-engine/ergonomic-regex.d.ts +12 -2
  825. package/dist/safe-bash-search-engine/ergonomic-regex.js +2 -2
  826. package/dist/safe-bash-search-engine/glob.js +2 -2
  827. package/dist/safe-bash-search-engine/grep.js +2 -2
  828. package/dist/safe-bash-search-engine/matcher.d.ts +6 -2
  829. package/dist/safe-bash-search-engine/matcher.js +30 -8
  830. package/dist/safe-bash-search-engine/options.js +1 -1
  831. package/dist/safe-bash-search-engine/output.d.ts +3 -2
  832. package/dist/safe-bash-search-engine/output.js +111 -30
  833. package/dist/safe-bash-search-engine/shared.d.ts +2 -0
  834. package/dist/safe-bash-search-engine/shared.js +2 -2
  835. package/dist/safe-bash-search-engine/walk.js +11 -10
  836. package/dist/safe-bash-text-stream-engine/stream-format/shared.d.ts +0 -2
  837. package/dist/safe-bash-text-stream-engine/stream-format/shared.js +1 -9
  838. package/dist/safe-bash-xml-engine/document.d.ts +1 -1
  839. package/dist/safe-bash-xml-engine/document.js +3 -3
  840. package/dist/safe-bash-xml-engine/evaluate.d.ts +1 -0
  841. package/dist/safe-bash-xml-engine/evaluate.js +4 -1
  842. package/dist/safe-bash-xml-engine/index.js +8 -6
  843. package/dist/safe-bash-xml-engine/io.js +1 -1
  844. package/dist/safe-bash-xml-engine/limits.d.ts +2 -2
  845. package/dist/safe-bash-xml-engine/limits.js +1 -1
  846. package/dist/safe-bash-xml-engine/predicate.d.ts +57 -0
  847. package/dist/safe-bash-xml-engine/query.d.ts +3 -15
  848. package/dist/safe-bash-xml-engine/query.js +3 -2
  849. package/dist/safe-bash-zip-engine/LICENSE +21 -0
  850. package/dist/safe-bash-zip-engine/index.d.ts +1 -0
  851. package/dist/safe-bash-zip-engine/index.js +32 -0
  852. package/dist/safe-bash-zip-engine/unzip/arguments.d.ts +53 -0
  853. package/dist/safe-bash-zip-engine/unzip/arguments.js +270 -0
  854. package/dist/safe-bash-zip-engine/zip/aes.d.ts +17 -0
  855. package/dist/safe-bash-zip-engine/zip/aes.js +15 -0
  856. package/dist/safe-bash-zip-engine/zip/comments.d.ts +17 -0
  857. package/dist/safe-bash-zip-engine/zip/comments.js +77 -0
  858. package/dist/safe-bash-zip-engine/zip/crc.d.ts +1 -0
  859. package/dist/safe-bash-zip-engine/zip/crc.js +7 -0
  860. package/dist/safe-bash-zip-engine/zip/crypto.d.ts +19 -0
  861. package/dist/safe-bash-zip-engine/zip/crypto.js +16 -0
  862. package/dist/safe-bash-zip-engine/zip/dates.d.ts +4 -0
  863. package/dist/safe-bash-zip-engine/zip/dates.js +68 -0
  864. package/dist/safe-bash-zip-engine/zip/environment.d.ts +2 -0
  865. package/dist/safe-bash-zip-engine/zip/environment.js +60 -0
  866. package/dist/safe-bash-zip-engine/zip/grow.d.ts +3 -0
  867. package/dist/safe-bash-zip-engine/zip/grow.js +7 -0
  868. package/dist/safe-bash-zip-engine/zip/help.d.ts +4 -0
  869. package/dist/safe-bash-zip-engine/zip/help.js +194 -0
  870. package/dist/safe-bash-zip-engine/zip/line-endings.d.ts +2 -0
  871. package/dist/safe-bash-zip-engine/zip/line-endings.js +165 -0
  872. package/dist/safe-bash-zip-engine/zip/log.d.ts +22 -0
  873. package/dist/safe-bash-zip-engine/zip/log.js +153 -0
  874. package/dist/safe-bash-zip-engine/zip/lzma.d.ts +9 -0
  875. package/dist/safe-bash-zip-engine/zip/lzma.js +7 -0
  876. package/dist/safe-bash-zip-engine/zip/move.d.ts +11 -0
  877. package/dist/safe-bash-zip-engine/zip/move.js +57 -0
  878. package/dist/safe-bash-zip-engine/zip/names.d.ts +2 -0
  879. package/dist/safe-bash-zip-engine/zip/names.js +37 -0
  880. package/dist/safe-bash-zip-engine/zip/options.d.ts +13 -0
  881. package/dist/safe-bash-zip-engine/zip/options.js +23 -0
  882. package/dist/safe-bash-zip-engine/zip/repair.d.ts +10 -0
  883. package/dist/safe-bash-zip-engine/zip/repair.js +348 -0
  884. package/dist/safe-bash-zip-engine/zip/safety.d.ts +54 -0
  885. package/dist/safe-bash-zip-engine/zip/safety.js +19 -0
  886. package/dist/safe-bash-zip-engine/zip/sfx.d.ts +4 -0
  887. package/dist/safe-bash-zip-engine/zip/sfx.js +58 -0
  888. package/dist/safe-bash-zip-engine/zip/test-command.d.ts +5 -0
  889. package/dist/safe-bash-zip-engine/zip/test-command.js +98 -0
  890. package/dist/safe-bash-zip-engine/zip/volumes.d.ts +21 -0
  891. package/dist/safe-bash-zip-engine/zip/volumes.js +255 -0
  892. package/dist/safe-bash-zip-engine/zip/zip64.d.ts +30 -0
  893. package/dist/safe-bash-zip-engine/zip/zip64.js +25 -0
  894. package/dist/safe-bash-zip-engine/zip-format.d.ts +68 -0
  895. package/dist/safe-bash-zip-engine/zip-format.js +27 -0
  896. package/dist/safe-playwright-cloudflare/browser-codegen.generated.d.ts +7 -7
  897. package/dist/safe-playwright-cloudflare/browser-codegen.generated.js +866 -8069
  898. package/dist/safe-playwright-cloudflare/browser-run-code-budget.d.ts +0 -1
  899. package/dist/safe-playwright-cloudflare/browser-run-code-budget.js +0 -2
  900. package/dist/safe-playwright-cloudflare/browser-trace-archive.d.ts +5 -1
  901. package/dist/safe-playwright-cloudflare/browser-trace-archive.js +2 -1
  902. package/dist/safe-playwright-cloudflare/browser-trace-budget.js +2 -2
  903. package/dist/safe-playwright-cloudflare/shell-browser-resource.d.ts +2 -0
  904. package/dist/safe-playwright-cloudflare/shell-browser-resource.js +3 -11
  905. package/dist/safe-playwright-cloudflare/shell-playwright.d.ts +2 -0
  906. package/dist/safe-playwright-cloudflare/shell-playwright.js +1 -1
  907. package/dist/spreadsheet-engine/io/publication.d.ts +1 -0
  908. package/package.json +163 -14
  909. package/dist/safe-bash/chunks/chunk-O4ZUCRGN.js +0 -13
  910. package/dist/safe-bash/chunks/chunk-S264DZO2.js +0 -243
  911. package/dist/safe-bash/chunks/chunk-WVG5SHHQ.js +0 -12
  912. package/dist/safe-bash/chunks/chunk-XH26YVGW.js +0 -23027
  913. package/dist/safe-bash/chunks/chunk-ZW6K2J7P.js +0 -2652
  914. package/dist/safe-bash/command-chunks/chunk-BIXLZ3OG.js +0 -14342
  915. package/dist/safe-bash/command-chunks/chunk-DUYJE2HY.js +0 -14
  916. package/dist/safe-bash/command-chunks/chunk-JHVZYB4R.js +0 -181
  917. package/dist/safe-bash/command-chunks/chunk-ULZ7HIZP.js +0 -40
  918. package/dist/safe-bash/command-chunks/chunk-XS3PGJU2.js +0 -343
  919. package/dist/safe-bash/command-chunks/chunk-XTZALMLR.js +0 -488
  920. package/dist/safe-bash/commands/archive/zip/aes-primitives-unavailable.d.ts +0 -2
  921. package/dist/safe-bash/commands/archive/zip/aes-primitives-unavailable.js +0 -3
  922. package/dist/safe-bash/commands/archive/zip/aes-primitives.d.ts +0 -2
  923. package/dist/safe-bash/commands/archive/zip/aes-primitives.js +0 -3
  924. package/dist/safe-bash/commands/xml/document.d.ts +0 -2
  925. package/dist/safe-bash/commands/xml/document.js +0 -2
  926. package/dist/safe-bash/commands/xml/evaluate.d.ts +0 -2
  927. package/dist/safe-bash/commands/xml/evaluate.js +0 -2
  928. package/dist/safe-bash/commands/xml/json.d.ts +0 -2
  929. package/dist/safe-bash/commands/xml/json.js +0 -2
  930. package/dist/safe-bash/commands/xml/limits.d.ts +0 -2
  931. package/dist/safe-bash/commands/xml/limits.js +0 -2
  932. package/dist/safe-bash/commands/xml/query.d.ts +0 -2
  933. package/dist/safe-bash/commands/xml/query.js +0 -2
  934. package/dist/safe-bash/chunks/{chunk-NHOXKQNE.js → chunk-QVSRRNZT.js} +3 -3
  935. package/dist/safe-bash/command-chunks/{chunk-FIUFIDAO.js → chunk-2JRBIDAD.js} +3 -3
  936. package/dist/safe-bash/command-chunks/{chunk-TYVCKQDH.js → chunk-J5SN3PZ3.js} +3 -3
  937. package/dist/safe-bash/command-chunks/{chunk-2ENZ6JGA.js → chunk-KEV7C3KH.js} +3 -3
  938. package/dist/safe-bash/command-chunks/{chunk-S62HELHU.js → chunk-PL6O4K6W.js} +3 -3
  939. package/dist/safe-bash/command-chunks/{chunk-2WRTLCGK.js → chunk-QZF3SINC.js} +4 -4
  940. package/dist/safe-bash/command-chunks/{chunk-X7TM3AKW.js → chunk-U6G67N23.js} +3 -3
  941. package/dist/safe-bash/command-chunks/{chunk-DDLQ5YDB.js → chunk-YHFXOX6U.js} +9 -9
  942. package/dist/safe-bash/command-chunks/{chunk-DQMOM72Z.js → chunk-ZRRBXU3M.js} +4 -4
@@ -1,735 +1,3432 @@
1
- import {
2
- encodeJson,
3
- encodeRaw,
4
- encodeYaml
5
- } from "../safe-bash/command-chunks/chunk-6XMBTEUK.js";
6
- import {
7
- parseYamlDocuments
8
- } from "../safe-bash/command-chunks/chunk-LHIOAFWW.js";
9
1
  import {
10
2
  parseTomlDocument
11
3
  } from "../safe-bash/command-chunks/chunk-L22T3H7L.js";
12
4
  import {
13
- YqLedger,
14
- resolveYqLimits,
15
- yqCaps
5
+ YqLedger
16
6
  } from "../safe-bash/command-chunks/chunk-EMPU65ZK.js";
17
- import {
18
- YqError,
19
- fromJqLimit
20
- } from "../safe-bash/command-chunks/chunk-DW2F3N6R.js";
7
+ import "../safe-bash/command-chunks/chunk-DW2F3N6R.js";
21
8
  import {
22
9
  init_buffer
23
10
  } from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
24
11
 
25
12
  // packages/safe-bash-command-yq/src/index.ts
26
13
  init_buffer();
27
- import { utf8ByteLength, utf8Encoder } from "../safe-bash-query-engine/bytes.js";
28
- import { escapeText } from "../safe-bash-query-engine/escaping.js";
29
- import { pathOf } from "../safe-bash-query-engine/path.js";
30
- import {
31
- commandRuntimeIdentity,
32
- createOutputOperation,
33
- FsError,
34
- getCommandArguments,
35
- readBytes
36
- } from "../safe-bash-contracts/index.js";
37
- import { shellValueByteLength } from "../safe-bash-contracts/value.js";
38
- import { yieldTurn } from "../safe-bash-contracts/yield.js";
39
- import { createYqQuerySession, YqValueFailure } from "../safe-bash-query-engine/query-core.js";
40
- import { interruptible, JqError, JqLimitError, wellFormed } from "../safe-bash-query-engine/limits.js";
41
- var help = "virtual-bash restricted YAML/TOML profile\nusage: yq [eval|e] [OPTION ...] [--] [FILTER [FILE ...]]\n yq [eval|e] --help\n yq [eval|e] --version\noptions:\n -p, --input-format FORMAT FORMAT is yaml (default) or toml\n --input-format=FORMAT same as above\n -o, --output-format FORMAT FORMAT is yaml or json\n --output-format=FORMAT same as above\n -c, --compact-output compact JSON; requires -o json\n -r, --unwrapScalar raw strings; requires -o json\n -h, --help show this help (sole argument)\n --version show profile identity (sole argument)\n";
42
- var version = "virtual-bash restricted YAML/TOML profile\n";
43
- var diagnosticFallback = "yq: limit: DIAGNOSTIC_TRUNCATED\n";
44
- var RawDocumentFramer = class {
45
- #ranges = [];
46
- #offset = 0;
47
- #frameStart = 0;
48
- #frameLine = 0;
49
- #lineStart = 0;
50
- #lineNumber = 0;
51
- #line = "";
52
- #pendingCr = false;
53
- #frameBytes = 0;
54
- #lineBytes = 0;
55
- #lineCouldBeMarker = true;
56
- #markerComment = false;
57
- #leadingWhitespace = true;
58
- #lineHasContent = false;
59
- #bomBytes = 0;
60
- #hasContent = false;
61
- admit(chunk) {
62
- for (const byte of chunk) {
63
- this.#offset++;
64
- if (this.#pendingCr && byte !== 10) {
65
- this.#pendingCr = false;
66
- this.#finishLine(this.#offset - 1);
67
- }
68
- this.#lineBytes++;
69
- if (this.#lineBytes > yqCaps.maxDocumentBytes) throw new YqError("limit", "LIMIT_MAX_DOCUMENT_BYTES", 5);
70
- if (this.#pendingCr) {
71
- this.#pendingCr = false;
72
- this.#finishLine(this.#offset);
73
- continue;
74
- }
75
- if (this.#lineStart === this.#frameStart && this.#lineBytes <= 3) {
76
- const expected = this.#lineBytes === 1 ? 239 : this.#lineBytes === 2 && this.#bomBytes === 1 ? 187 : this.#lineBytes === 3 && this.#bomBytes === 2 ? 191 : void 0;
77
- if (byte === expected) {
78
- this.#bomBytes++;
79
- continue;
80
- }
81
- if (this.#bomBytes > 0) {
82
- this.#lineCouldBeMarker = false;
83
- this.#lineHasContent = true;
84
- this.#leadingWhitespace = false;
85
- }
86
- }
87
- if (this.#leadingWhitespace && byte !== 32 && byte !== 9 && byte !== 13 && byte !== 10) {
88
- this.#lineHasContent = byte !== 35 && byte !== 37;
89
- this.#leadingWhitespace = false;
90
- }
91
- if (this.#lineCouldBeMarker && byte !== 13 && byte !== 10 && !this.#markerComment) {
92
- if (this.#line.length < 3) {
93
- if (this.#line.length === 0 ? byte === 45 || byte === 46 : byte === this.#line.charCodeAt(0)) {
94
- this.#line += String.fromCharCode(byte);
95
- } else {
96
- this.#lineCouldBeMarker = false;
97
- }
98
- } else if (byte === 32 || byte === 9) {
99
- if (this.#line.length === 3) this.#line += " ";
100
- } else if (byte === 35) {
101
- this.#markerComment = true;
102
- } else {
103
- this.#lineCouldBeMarker = false;
104
- }
105
- }
106
- if (!this.#lineCouldBeMarker && this.#lineBytes > yqCaps.maxDocumentBytes - this.#frameBytes) {
107
- throw new YqError("limit", "LIMIT_MAX_DOCUMENT_BYTES", 5);
108
- }
109
- if (byte === 13) this.#pendingCr = true;
110
- else if (byte === 10) this.#finishLine(this.#offset);
14
+
15
+ // packages/safe-bash-command-yq/src/mike.ts
16
+ init_buffer();
17
+ import { utf8ByteLength as utf8ByteLength6, utf8Encoder as utf8Encoder4 } from "../safe-bash-query-engine/bytes.js";
18
+ import { escapeText } from "../safe-bash-contracts/escaping.js";
19
+
20
+ // packages/safe-bash-command-yq/src/formats.ts
21
+ init_buffer();
22
+ import { utf8ByteLength as utf8ByteLength3, utf8Encoder as utf8Encoder2, encodeBase64, decodeBase64 } from "../safe-bash-query-engine/bytes.js";
23
+ import { parseXmlSteps } from "@poe-platform/safe-fs/core";
24
+
25
+ // packages/safe-bash-command-yq/src/nodes.ts
26
+ init_buffer();
27
+ import { utf8ByteLength, utf8Encoder, utf8Decoder } from "../safe-bash-query-engine/bytes.js";
28
+
29
+ // packages/safe-bash-command-yq/src/native-work.ts
30
+ init_buffer();
31
+ import { createOutputOperation } from "../safe-bash-contracts/index.js";
32
+ import { inheritYieldCheckpoint, yieldTurn } from "../safe-bash-contracts/yield.js";
33
+ var mikeLimits = Object.freeze({
34
+ maxInputBytes: Infinity,
35
+ maxDocumentBytes: Infinity,
36
+ maxScalarBytes: Infinity,
37
+ maxNodes: Infinity,
38
+ maxParserNodes: Infinity,
39
+ maxDepth: Infinity,
40
+ maxExpressionDepth: Infinity,
41
+ maxExpressionBytes: Infinity,
42
+ maxAliases: Infinity,
43
+ maxDocuments: Infinity,
44
+ maxOutputBytes: Infinity,
45
+ maxSteps: Infinity
46
+ });
47
+ var MikeError = class extends Error {
48
+ constructor(message, usage = false) {
49
+ super(message);
50
+ this.usage = usage;
51
+ }
52
+ usage;
53
+ };
54
+ function limitsFor(options = {}) {
55
+ if (!options || typeof options !== "object" || Array.isArray(options)) throw new TypeError("invalid yq limits");
56
+ const limits = { ...mikeLimits };
57
+ for (const [name, value2] of Object.entries(options)) {
58
+ if (!Object.hasOwn(limits, name) || value2 !== Infinity && (!Number.isSafeInteger(value2) || value2 < 1)) {
59
+ throw new TypeError(`invalid yq limit: ${name}`);
111
60
  }
61
+ limits[name] = value2;
62
+ }
63
+ return Object.freeze(limits);
64
+ }
65
+ var NativeWork = class {
66
+ constructor(context, limits) {
67
+ this.context = context;
68
+ this.limits = limits;
69
+ inheritYieldCheckpoint(context.signal, this.signal);
70
+ context.registerCleanup?.(() => this.close());
71
+ const abort = () => {
72
+ this.#aborted = true;
73
+ this.controller.abort(context.signal.reason);
74
+ };
75
+ this.signal.addEventListener("abort", () => {
76
+ this.#aborted = true;
77
+ }, { once: true });
78
+ if (context.signal.aborted) abort();
79
+ else context.signal.addEventListener("abort", abort, { once: true });
80
+ this.#cleanup.push(() => {
81
+ context.signal.removeEventListener("abort", abort);
82
+ });
112
83
  }
113
- finish(bytes) {
114
- if (this.#lineBytes > 0) {
115
- this.#pendingCr = false;
116
- this.#finishLine(this.#offset);
84
+ context;
85
+ limits;
86
+ capturePositions = false;
87
+ positions = /* @__PURE__ */ new WeakMap();
88
+ implicitTags = /* @__PURE__ */ new WeakSet();
89
+ headComments = /* @__PURE__ */ new WeakMap();
90
+ controller = new AbortController();
91
+ signal = this.controller.signal;
92
+ #cleanup = [];
93
+ #pending = /* @__PURE__ */ new Set();
94
+ #closing;
95
+ #open = true;
96
+ #aborted = false;
97
+ #steps = 0;
98
+ #yieldAt = 1024;
99
+ #input = 0;
100
+ #nodes = 0;
101
+ #aliases = 0;
102
+ #output = 0;
103
+ #documents = 0;
104
+ assertOpen() {
105
+ if (this.#aborted) {
106
+ this.context.signal.throwIfAborted();
107
+ this.signal.throwIfAborted();
117
108
  }
118
- if (this.#frameStart < this.#offset) this.#ranges.push({ start: this.#frameStart, end: this.#offset, lineOffset: this.#frameLine });
119
- return this.#ranges.map((range) => ({
120
- bytes: bytes.subarray(range.start, range.end),
121
- rawBytes: range.end - range.start,
122
- lineOffset: range.lineOffset
123
- }));
109
+ if (!this.#open) throw new MikeError("yq invocation is closed");
124
110
  }
125
- #finishLine(end) {
126
- const marker = this.#lineCouldBeMarker && this.#line.startsWith("---");
127
- const endMarker = this.#lineCouldBeMarker && this.#line.startsWith("...");
128
- if (marker && this.#hasContent && this.#lineStart > this.#frameStart) {
129
- this.#ranges.push({ start: this.#frameStart, end: this.#lineStart, lineOffset: this.#frameLine });
130
- this.#frameStart = this.#lineStart;
131
- this.#frameLine = this.#lineNumber;
132
- this.#frameBytes = this.#lineBytes;
133
- this.#hasContent = false;
134
- } else {
135
- if (this.#lineBytes > yqCaps.maxDocumentBytes - this.#frameBytes) throw new YqError("limit", "LIMIT_MAX_DOCUMENT_BYTES", 5);
136
- this.#frameBytes += this.#lineBytes;
137
- }
138
- if (this.#lineHasContent && !marker && !endMarker) this.#hasContent = true;
139
- if (endMarker && this.#frameStart < end) {
140
- this.#ranges.push({ start: this.#frameStart, end, lineOffset: this.#frameLine });
141
- this.#frameStart = end;
142
- this.#frameLine = this.#lineNumber + 1;
143
- this.#frameBytes = 0;
144
- this.#hasContent = false;
145
- }
146
- this.#line = "";
147
- this.#lineBytes = 0;
148
- this.#lineCouldBeMarker = true;
149
- this.#markerComment = false;
150
- this.#leadingWhitespace = true;
151
- this.#lineHasContent = false;
152
- this.#bomBytes = 0;
153
- this.#lineStart = end;
154
- this.#lineNumber++;
111
+ tick(units = 1) {
112
+ this.assertOpen();
113
+ this.#steps += units;
114
+ if (!Number.isSafeInteger(this.#steps) || this.#steps > this.limits.maxSteps) throw new MikeError("yq limit exceeded: maxSteps");
115
+ if (this.#steps >= this.#yieldAt) {
116
+ this.#yieldAt = this.#steps + 1024;
117
+ return yieldTurn(this.signal).then(() => {
118
+ this.assertOpen();
119
+ });
120
+ }
155
121
  }
156
- };
157
- var SinkFailure = class {
158
- constructor(reason) {
159
- this.reason = reason;
122
+ input(bytes) {
123
+ this.assertOpen();
124
+ if (bytes > this.limits.maxInputBytes - this.#input) throw new MikeError("yq limit exceeded: maxInputBytes");
125
+ this.#input += bytes;
160
126
  }
161
- reason;
162
- };
163
- var InvocationOwner = class {
164
- #accepting = true;
165
- #callbacks = [];
166
- #closePromise;
167
- assertOpen(signal) {
168
- if (signal.aborted) throw signal.reason;
169
- if (!this.#accepting) throw new Error("yq invocation is closed");
127
+ node(count = 1) {
128
+ this.assertOpen();
129
+ this.#nodes += count;
130
+ if (this.#nodes > this.limits.maxNodes) throw new MikeError("yq limit exceeded: maxNodes");
131
+ }
132
+ alias() {
133
+ if (++this.#aliases > this.limits.maxAliases) throw new MikeError("yq limit exceeded: maxAliases");
134
+ }
135
+ document() {
136
+ this.assertOpen();
137
+ if (++this.#documents > this.limits.maxDocuments) throw new MikeError("yq limit exceeded: maxDocuments");
138
+ }
139
+ depth(depth) {
140
+ if (depth > this.limits.maxDepth) throw new MikeError("yq limit exceeded: maxDepth");
141
+ }
142
+ output(bytes) {
143
+ this.assertOpen();
144
+ if (bytes > this.limits.maxOutputBytes - this.#output) throw new MikeError("yq limit exceeded: maxOutputBytes");
145
+ this.#output += bytes;
170
146
  }
171
147
  register(cleanup) {
172
- if (!this.#accepting) throw new Error("yq invocation is closed");
173
- if (typeof cleanup !== "function") throw new TypeError("cleanup must be callable");
174
- this.#callbacks.push(cleanup);
148
+ this.assertOpen();
149
+ this.#cleanup.push(cleanup);
150
+ }
151
+ track(promise) {
152
+ this.#pending.add(promise);
153
+ void promise.then(() => this.#pending.delete(promise), () => this.#pending.delete(promise));
154
+ return promise;
155
+ }
156
+ async acquire(start, release) {
157
+ this.assertOpen();
158
+ let resource;
159
+ let settled;
160
+ const ready = new Promise((resolve) => {
161
+ settled = resolve;
162
+ });
163
+ let released;
164
+ const dispose = () => released ??= ready.then(async () => {
165
+ if (resource) await release(resource.value);
166
+ });
167
+ this.register(dispose);
168
+ try {
169
+ const value2 = await this.track(Promise.resolve().then(() => {
170
+ this.assertOpen();
171
+ return start();
172
+ }));
173
+ resource = { value: value2 };
174
+ settled();
175
+ this.assertOpen();
176
+ return value2;
177
+ } catch (error) {
178
+ settled();
179
+ await dispose();
180
+ throw error;
181
+ }
182
+ }
183
+ async readFile(path) {
184
+ this.assertOpen();
185
+ const fs = this.context.fs;
186
+ const capabilities = fs.capabilitiesFor ? await this.track(fs.capabilitiesFor(path, { signal: this.signal })) : fs.capabilities;
187
+ this.assertOpen();
188
+ if (fs.readStream && capabilities.streamingRead !== false) {
189
+ return this.collect(() => fs.readStream(path, { signal: this.signal }));
190
+ }
191
+ const bytes = await this.track(fs.readFile(path, {
192
+ signal: this.signal,
193
+ ...Number.isFinite(this.limits.maxInputBytes) ? { maxBytes: this.limits.maxInputBytes } : {}
194
+ }));
195
+ this.input(bytes.length);
196
+ return bytes;
197
+ }
198
+ async collect(start) {
199
+ const iterator = await this.acquire(() => start()[Symbol.asyncIterator](), async (value2) => {
200
+ await value2.return?.();
201
+ });
202
+ const chunks = [];
203
+ let size = 0;
204
+ let chunksSinceYield = 0;
205
+ while (true) {
206
+ this.assertOpen();
207
+ const next = await this.track(Promise.resolve(iterator.next()));
208
+ this.assertOpen();
209
+ if (next.done) break;
210
+ if (!(next.value instanceof Uint8Array)) throw new TypeError("Byte sources must yield Uint8Array chunks");
211
+ this.input(next.value.byteLength);
212
+ if (next.value.byteLength) {
213
+ const copy = new Uint8Array(next.value);
214
+ chunks.push(copy);
215
+ size += copy.length;
216
+ }
217
+ const checkpoint = this.tick();
218
+ chunksSinceYield++;
219
+ if (checkpoint) {
220
+ await checkpoint;
221
+ chunksSinceYield = 0;
222
+ } else if (chunksSinceYield >= 1024) {
223
+ await yieldTurn(this.signal);
224
+ chunksSinceYield = 0;
225
+ this.assertOpen();
226
+ }
227
+ }
228
+ const result = new Uint8Array(size);
229
+ let offset = 0;
230
+ for (const chunk of chunks) {
231
+ result.set(chunk, offset);
232
+ offset += chunk.length;
233
+ {
234
+ const t = this.tick();
235
+ if (t) await t;
236
+ }
237
+ }
238
+ return result;
239
+ }
240
+ async write(bytes, stderr = false) {
241
+ this.assertOpen();
242
+ const operation = createOutputOperation({ signal: this.signal, registerCleanup: (cleanup) => this.register(cleanup) }, stderr ? this.context.stderr : this.context.stdout);
243
+ try {
244
+ await this.track(operation.output.write(bytes));
245
+ this.assertOpen();
246
+ } finally {
247
+ await operation.close();
248
+ }
175
249
  }
176
250
  close() {
177
- if (this.#closePromise) return this.#closePromise;
178
- this.#accepting = false;
179
- this.#closePromise = (async () => {
180
- const results = await Promise.allSettled(this.#callbacks.map(async (cleanup) => cleanup()));
181
- const failures = results.filter((result) => result.status === "rejected").map((result) => result.reason);
182
- if (failures.length === 1) throw failures[0];
183
- if (failures.length > 1) throw new AggregateError(failures, "yq invocation cleanup failed");
251
+ if (this.#closing) return this.#closing;
252
+ this.#open = false;
253
+ this.controller.abort(new MikeError("yq invocation is closed"));
254
+ this.#closing = (async () => {
255
+ const closed = Promise.allSettled(this.#cleanup.map(async (cleanup) => cleanup()));
256
+ while (this.#pending.size) await Promise.allSettled([...this.#pending]);
257
+ const failures = (await closed).filter((result) => result.status === "rejected").map((result) => result.reason);
258
+ if (failures.length) throw new AggregateError(failures, "yq cleanup failed");
184
259
  })();
185
- void this.#closePromise.catch(() => {
260
+ void this.#closing.catch(() => {
186
261
  });
187
- return this.#closePromise;
262
+ return this.#closing;
188
263
  }
189
264
  };
190
- function cli(code) {
191
- return new YqError("cli", code, 2);
265
+
266
+ // packages/safe-bash-command-yq/src/comments.ts
267
+ init_buffer();
268
+ async function recordHeadComments(node, prefix, input, yaml, work) {
269
+ const normalize = (text) => text.split("\n").map((line) => line.startsWith("# ") ? line.slice(2) : line).join("\n");
270
+ const comments = async (tokens) => {
271
+ const parts = [];
272
+ let lineStart = true;
273
+ let skipNewline = false;
274
+ for (const token of tokens) {
275
+ {
276
+ const t = work.tick();
277
+ if (t) await t;
278
+ }
279
+ if (token.type === "comment" && lineStart) parts.push(token.source);
280
+ else if (token.type === "newline") {
281
+ if (parts.length && !skipNewline) parts.push("\n");
282
+ lineStart = true;
283
+ skipNewline = false;
284
+ } else if (token.type === "doc-start" || token.type === "directive") skipNewline = true;
285
+ else if (token.type === "seq-item-ind") lineStart = true;
286
+ else if (token.type !== "space") lineStart = false;
287
+ }
288
+ const text = parts.join("");
289
+ return normalize(text.endsWith("\n") ? text.slice(0, -1) : text);
290
+ };
291
+ let head = "";
292
+ if (input !== void 0) {
293
+ const parts = [];
294
+ let offset = 0;
295
+ let remainder = "";
296
+ while (offset < input.length || remainder) {
297
+ const newline = input.indexOf("\n", offset);
298
+ const end = newline < 0 ? input.length : newline + 1;
299
+ const line = remainder + input.slice(offset, end);
300
+ {
301
+ const t = work.tick(line.length + 1);
302
+ if (t) await t;
303
+ }
304
+ offset = end;
305
+ remainder = "";
306
+ const content = line.endsWith("\r\n") ? line.slice(0, -2) : line.endsWith("\n") ? line.slice(0, -1) : line;
307
+ const trimmed = content.trimStart();
308
+ if (trimmed.trimEnd() === "---") continue;
309
+ if (trimmed.startsWith("---") && (trimmed[3] === " " || trimmed[3] === " ")) {
310
+ remainder = trimmed.slice(3).trimStart();
311
+ continue;
312
+ }
313
+ if (!trimmed || trimmed.startsWith("#") || trimmed.startsWith("%YAML")) parts.push(line);
314
+ else break;
315
+ }
316
+ const text = parts.join("");
317
+ head = normalize(text.endsWith("\n") ? text.slice(0, -1) : text);
318
+ } else head = await comments(prefix);
319
+ const visit = async (current, leading, documentRoot = false) => {
320
+ {
321
+ const t = work.tick();
322
+ if (t) await t;
323
+ }
324
+ const token = current.srcToken;
325
+ const block = token?.type === "block-map" || token?.type === "block-seq";
326
+ if (leading && (!block || documentRoot)) work.headComments.set(current, leading);
327
+ const inherited = block && !documentRoot ? leading : "";
328
+ const combine = (head2) => inherited && head2 ? `${inherited}
329
+ ${head2}` : inherited || head2;
330
+ if (yaml.isMap(current) && (token?.type === "block-map" || token?.type === "flow-collection")) {
331
+ for (let index = 0; index < current.items.length; index++) {
332
+ const pair = current.items[index];
333
+ const item = token.items[index];
334
+ if (!item) continue;
335
+ const head2 = await comments(item.start);
336
+ if (yaml.isNode(pair.key)) await visit(pair.key, index === 0 ? combine(head2) : head2);
337
+ if (yaml.isNode(pair.value)) await visit(pair.value, await comments(item.sep ?? []));
338
+ }
339
+ } else if (yaml.isSeq(current) && (token?.type === "block-seq" || token?.type === "flow-collection")) {
340
+ for (let index = 0; index < current.items.length; index++) {
341
+ const child = current.items[index];
342
+ const item = token.items[index];
343
+ if (yaml.isNode(child) && item) {
344
+ const head2 = await comments(item.start);
345
+ await visit(child, index === 0 ? combine(head2) : head2);
346
+ }
347
+ }
348
+ }
349
+ };
350
+ await visit(node, head, input !== void 0);
192
351
  }
193
- function preflightArguments(context) {
194
- const args = context.args;
195
- if (args.length > yqCaps.maxArgvEntries) throw cli("CLI_ARGV_ENTRIES_LIMIT");
196
- let bytes = 0;
197
- for (const argument of args) {
198
- if (!wellFormed(argument)) throw cli("CLI_INVALID_UNICODE");
199
- const incoming = utf8ByteLength(argument);
200
- if (incoming > yqCaps.maxArgvUtf8Bytes - bytes) throw cli("CLI_ARGV_BYTES_LIMIT");
201
- bytes += incoming;
352
+
353
+ // packages/safe-bash-command-yq/src/nodes.ts
354
+ async function loadYaml() {
355
+ try {
356
+ return await import("../safe-bash/bundled-yaml/index.js");
357
+ } catch {
358
+ throw new MikeError("the optional yaml@2.9.0 peer is required for this yq profile");
202
359
  }
203
- const carrier = getCommandArguments(context);
204
- bytes = 0;
205
- const decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
206
- for (let index = 0; index < args.length; index++) {
207
- const incoming = shellValueByteLength(carrier.values[index]);
208
- if (incoming > yqCaps.maxArgvUtf8Bytes - bytes) throw cli("CLI_ARGV_BYTES_LIMIT");
209
- bytes += incoming;
210
- let decoded;
211
- try {
212
- decoded = decoder.decode(carrier.bytes(index));
213
- } catch {
214
- throw cli("CLI_INVALID_UNICODE");
215
- }
216
- if (decoded !== args[index]) throw cli("CLI_INVALID_UNICODE");
360
+ }
361
+ function scalar(yaml, work, value2, float = false) {
362
+ work.node();
363
+ if (typeof value2 === "string" && utf8ByteLength(value2) > work.limits.maxScalarBytes) throw new MikeError("yq limit exceeded: maxScalarBytes");
364
+ const node = new yaml.Scalar(value2);
365
+ if (float) node.minFractionDigits = 0;
366
+ return node;
367
+ }
368
+ function root(document) {
369
+ return { node: document.doc.contents, document, isDocumentRoot: true };
370
+ }
371
+ function nodeTag(node, yaml) {
372
+ if (node.tag) return node.tag.replace("tag:yaml.org,2002:", "!!");
373
+ if (yaml.isMap(node)) return "!!map";
374
+ if (yaml.isSeq(node)) return "!!seq";
375
+ if (yaml.isAlias(node)) return "";
376
+ const value2 = node.value;
377
+ if (value2 === null || value2 === void 0) return "!!null";
378
+ if (typeof value2 === "boolean") return "!!bool";
379
+ if (typeof value2 === "number" && (node.minFractionDigits !== void 0 || node.format === "EXP" || node.source?.includes("."))) return "!!float";
380
+ if (typeof value2 === "bigint" || typeof value2 === "number" && Number.isInteger(value2)) return "!!int";
381
+ if (typeof value2 === "number") return "!!float";
382
+ return "!!str";
383
+ }
384
+ function truth(node, yaml) {
385
+ return !yaml.isScalar(node) || node.value !== null && node.value !== void 0 && node.value !== false;
386
+ }
387
+ function dereference(candidate, yaml, work) {
388
+ let node = candidate.node;
389
+ const seen = /* @__PURE__ */ new Set();
390
+ while (yaml.isAlias(node)) {
391
+ work.alias();
392
+ if (seen.has(node)) throw new MikeError("cyclic YAML alias");
393
+ seen.add(node);
394
+ const resolved = node.resolve(candidate.document.doc);
395
+ if (!resolved) throw new MikeError(`unknown anchor '${node.source}' referenced`);
396
+ node = resolved;
217
397
  }
398
+ return node === candidate.node ? candidate : { node, document: candidate.document, isDerived: candidate.isDerived ?? false, ...candidate.ancestry ? { ancestry: candidate.ancestry } : {} };
218
399
  }
219
- function isInformationForm(args) {
220
- const offset = args[0] === "eval" || args[0] === "e" ? 1 : 0;
221
- if (args.length !== offset + 1) return void 0;
222
- const token = args[offset];
223
- if (token === "-h" || token === "--help") return "help";
224
- if (token === "--version") return "version";
225
- return void 0;
400
+ async function inspectNode(node, yaml, work, allocate = false) {
401
+ const pending = [{ node, depth: 0 }];
402
+ let count = 0;
403
+ while (pending.length) {
404
+ const current = pending.pop();
405
+ work.depth(current.depth);
406
+ if (++count > work.limits.maxParserNodes) throw new MikeError("yq limit exceeded: maxParserNodes");
407
+ {
408
+ const t = work.tick();
409
+ if (t) await t;
410
+ }
411
+ if (allocate) work.node();
412
+ if (yaml.isScalar(current.node)) {
413
+ if (typeof current.node.value === "string" && utf8ByteLength(current.node.value) > work.limits.maxScalarBytes) throw new MikeError("yq limit exceeded: maxScalarBytes");
414
+ } else if (yaml.isMap(current.node)) {
415
+ for (const pair of current.node.items) {
416
+ if (yaml.isNode(pair.key)) pending.push({ node: pair.key, depth: current.depth + 1 });
417
+ if (yaml.isNode(pair.value)) pending.push({ node: pair.value, depth: current.depth + 1 });
418
+ }
419
+ } else if (yaml.isSeq(current.node)) {
420
+ for (const child of current.node.items) if (yaml.isNode(child)) pending.push({ node: child, depth: current.depth + 1 });
421
+ }
422
+ }
226
423
  }
227
- function parseArguments(args, inputFormat) {
228
- let index = args[0] === "eval" || args[0] === "e" ? 1 : 0;
229
- if (args[0] === "eval-all" || args[0] === "ea") throw cli("CLI_UNSUPPORTED_COMMAND");
230
- let ended = false;
231
- let inputFormatSeen = false;
232
- let format = "yaml";
233
- let explicitJson = false;
234
- let formatSeen = false;
235
- let compact = false;
236
- let compactSeen = false;
237
- let raw = false;
238
- let rawSeen = false;
239
- const operands = [];
240
- const refused = /^(?:-s|-n|-p|-i|--slurp|--null-input|--input-format|--yaml-schema|--schema|--json-schema|--failsafe-schema|--inplace|--in-place|--allow-lossy-write|--write|--split-exp|--front-matter|--xml|--properties|--color-output)(?:=.*)?$/u;
241
- for (; index < args.length; index++) {
242
- const argument = args[index];
243
- if (!ended && argument === "--") {
244
- ended = true;
245
- continue;
424
+ async function cloneNode(node, yaml, work) {
425
+ await inspectNode(node, yaml, work, true);
426
+ work.assertOpen();
427
+ const cloned = node.clone();
428
+ const pending = [{ original: node, cloned }];
429
+ while (pending.length) {
430
+ const current = pending.pop();
431
+ {
432
+ const t = work.tick();
433
+ if (t) await t;
246
434
  }
247
- if (!ended && (argument === "-p" || argument === "--input-format" || argument.startsWith("--input-format="))) {
248
- if (inputFormatSeen) throw cli("CLI_DUPLICATE_OPTION");
249
- const value = argument.startsWith("--input-format=") ? argument.slice("--input-format=".length) : args[++index];
250
- if (value === void 0 || value === "") throw cli("CLI_MISSING_OPTION_VALUE");
251
- if (value !== "yaml" && value !== "toml") throw cli("CLI_INVALID_OPTION_VALUE");
252
- inputFormatSeen = true;
253
- inputFormat = value;
254
- continue;
435
+ if (work.implicitTags.has(current.original)) work.implicitTags.add(current.cloned);
436
+ const position = work.positions.get(current.original);
437
+ if (position) work.positions.set(current.cloned, position);
438
+ const head = work.headComments.get(current.original);
439
+ if (head !== void 0) work.headComments.set(current.cloned, head);
440
+ if (yaml.isMap(current.original) && yaml.isMap(current.cloned)) for (let index = 0; index < current.original.items.length; index++) {
441
+ const original = current.original.items[index];
442
+ const copy = current.cloned.items[index];
443
+ if (yaml.isNode(original.key) && yaml.isNode(copy.key)) pending.push({ original: original.key, cloned: copy.key });
444
+ if (yaml.isNode(original.value) && yaml.isNode(copy.value)) pending.push({ original: original.value, cloned: copy.value });
255
445
  }
256
- if (!ended && (argument === "-o" || argument === "--output-format")) {
257
- if (formatSeen) throw cli("CLI_DUPLICATE_OPTION");
258
- const value = args[++index];
259
- if (value === void 0) throw cli("CLI_MISSING_OPTION_VALUE");
260
- if (value !== "yaml" && value !== "json") throw cli("CLI_INVALID_OPTION_VALUE");
261
- formatSeen = true;
262
- format = value;
263
- explicitJson = value === "json";
264
- continue;
446
+ else if (yaml.isSeq(current.original) && yaml.isSeq(current.cloned)) for (let index = 0; index < current.original.items.length; index++) {
447
+ const original = current.original.items[index];
448
+ const copy = current.cloned.items[index];
449
+ if (yaml.isNode(original) && yaml.isNode(copy)) pending.push({ original, cloned: copy });
265
450
  }
266
- if (!ended && argument.startsWith("--output-format=")) {
267
- if (formatSeen) throw cli("CLI_DUPLICATE_OPTION");
268
- const value = argument.slice("--output-format=".length);
269
- if (value === "") throw cli("CLI_MISSING_OPTION_VALUE");
270
- if (value !== "yaml" && value !== "json") throw cli("CLI_INVALID_OPTION_VALUE");
271
- formatSeen = true;
272
- format = value;
273
- explicitJson = value === "json";
274
- continue;
451
+ }
452
+ return cloned;
453
+ }
454
+ async function replace(candidate, incoming, yaml, work, clobber = false) {
455
+ const node = await cloneNode(incoming, yaml, work);
456
+ const previous = candidate.node;
457
+ const head = work.headComments.get(previous);
458
+ if (head !== void 0 && !work.headComments.has(node)) work.headComments.set(node, head);
459
+ if (previous.comment !== void 0) node.comment = previous.comment;
460
+ if (previous.commentBefore !== void 0) node.commentBefore = previous.commentBefore;
461
+ if (previous.spaceBefore !== void 0) node.spaceBefore = previous.spaceBefore;
462
+ if ("anchor" in previous && "anchor" in node) node.anchor = previous.anchor;
463
+ if (!clobber && previous.tag && (!previous.tag.startsWith("tag:yaml.org,2002:") || nodeTag(node, yaml) === nodeTag(previous, yaml))) {
464
+ node.tag = previous.tag;
465
+ if (work.implicitTags.has(previous)) work.implicitTags.add(node);
466
+ }
467
+ if (yaml.isScalar(node) && yaml.isScalar(previous) && previous.type !== void 0) node.type = previous.type;
468
+ if (candidate.parent) {
469
+ if (yaml.isMap(candidate.parent)) candidate.parent.items[candidate.slot].value = node;
470
+ else candidate.parent.items[candidate.slot] = node;
471
+ } else if (candidate.isDocumentRoot) candidate.document.doc.contents = node;
472
+ candidate.node = node;
473
+ }
474
+ async function admitCst(token, work) {
475
+ const pending = [{ value: token, depth: 0 }];
476
+ let nodes = 0;
477
+ let composed = 0;
478
+ let bytes = 0;
479
+ const maxParserNodes = work.limits.maxParserNodes;
480
+ const maxNodes8 = maxParserNodes * 8;
481
+ const maxDocBytes = work.limits.maxDocumentBytes;
482
+ const maxScalarBytes = work.limits.maxScalarBytes;
483
+ const checkDocBytes = maxDocBytes !== Infinity;
484
+ while (pending.length) {
485
+ const { value: value2, depth } = pending.pop();
486
+ if (!value2 || typeof value2 !== "object") continue;
487
+ {
488
+ const t = work.tick();
489
+ if (t) await t;
275
490
  }
276
- if (!ended && (argument === "-c" || argument === "--compact-output")) {
277
- if (compactSeen) throw cli("CLI_DUPLICATE_OPTION");
278
- compactSeen = true;
279
- compact = true;
491
+ if (Array.isArray(value2)) {
492
+ for (let i = 0; i < value2.length; i++) {
493
+ const child = value2[i];
494
+ if (child && typeof child === "object") pending.push({ value: child, depth });
495
+ }
280
496
  continue;
281
497
  }
282
- if (!ended && (argument === "-r" || argument === "--unwrapScalar")) {
283
- if (rawSeen) throw cli("CLI_DUPLICATE_OPTION");
284
- rawSeen = true;
285
- raw = true;
286
- continue;
498
+ const item = value2;
499
+ const itemType = item.type;
500
+ const collection = itemType === "block-map" || itemType === "block-seq" || itemType === "flow-collection";
501
+ if (collection || itemType === "alias" || itemType === "scalar" || itemType === "single-quoted-scalar" || itemType === "double-quoted-scalar" || itemType === "block-scalar") {
502
+ if (++composed > maxParserNodes) throw new MikeError("yq limit exceeded: maxParserNodes");
503
+ work.node();
504
+ }
505
+ work.depth(depth);
506
+ if (itemType && ++nodes > maxNodes8) throw new MikeError("yq limit exceeded: maxParserNodes");
507
+ if (typeof item.source === "string") {
508
+ if (item.source.length > maxScalarBytes) throw new MikeError("yq limit exceeded: maxScalarBytes");
509
+ if (checkDocBytes) {
510
+ bytes += utf8ByteLength(item.source);
511
+ if (bytes > maxDocBytes) throw new MikeError("yq limit exceeded: maxDocumentBytes");
512
+ }
513
+ }
514
+ const nextDepth = depth + (collection ? 1 : 0);
515
+ for (const key in item) {
516
+ const child = item[key];
517
+ if (child && typeof child === "object") pending.push({ value: child, depth: nextDepth });
287
518
  }
288
- if (!ended && refused.test(argument)) throw cli("CLI_UNSUPPORTED_OPTION");
289
- if (!ended && argument.startsWith("-") && argument !== "-") throw cli("CLI_UNKNOWN_OPTION");
290
- operands.push(argument);
291
- }
292
- if ((compact || raw) && !explicitJson) throw cli("CLI_INCOMPATIBLE_OPTIONS");
293
- const filter = operands[0] ?? ".";
294
- const files = operands.slice(1);
295
- let stdinSeen = false;
296
- for (const file of files) {
297
- if (file === "-") {
298
- if (stdinSeen) throw cli("CLI_DUPLICATE_STDIN");
299
- stdinSeen = true;
300
- } else if (utf8ByteLength(file) > yqCaps.maxVfsOperandPathBytes) throw cli("CLI_VFS_OPERAND_LIMIT");
301
- }
302
- return { inputFormat, format, explicitJson, compact, raw, filter, files };
303
- }
304
- function displayedSource(source) {
305
- if (source === "<stdin>") return source;
306
- const parts = ['"'];
307
- let bytes = 2;
308
- let truncated = false;
309
- for (const character of source) {
310
- const encoded = escapeText(JSON.stringify(character).slice(1, -1), "diagnostic");
311
- const incoming = utf8ByteLength(encoded);
312
- if (incoming > yqCaps.maxDisplayedFilenameBytes - bytes) {
313
- truncated = true;
314
- break;
315
- }
316
- parts.push(encoded);
317
- bytes += incoming;
318
- }
319
- if (truncated) {
320
- while (parts.length > 1 && utf8ByteLength(parts.join("")) + 4 > yqCaps.maxDisplayedFilenameBytes) parts.pop();
321
- parts.push("...");
322
519
  }
323
- parts.push('"');
324
- return parts.join("");
325
520
  }
326
- function diagnostic(error) {
327
- let location = "";
328
- if (error.source !== void 0) {
329
- location = ` at ${displayedSource(error.source)}`;
330
- if (error.line !== void 0 && error.column !== void 0) location += `:${error.line}:${error.column}`;
521
+ async function decodeJsonDocument(source, filename, yaml, work) {
522
+ let offset = 0;
523
+ let nodes = 0;
524
+ const admit = () => {
525
+ if (++nodes > work.limits.maxParserNodes) throw new MikeError("yq limit exceeded: maxParserNodes");
526
+ work.node();
527
+ };
528
+ const fail = (context) => {
529
+ throw new MikeError(`bad file '${filename}': ${context ? `json: ${context} unexpected end of JSON input` : "invalid JSON input"}`);
530
+ };
531
+ const skip = async () => {
532
+ while (offset < source.length && " \r\n".includes(source[offset])) {
533
+ offset++;
534
+ {
535
+ const t = work.tick();
536
+ if (t) await t;
537
+ }
538
+ }
539
+ };
540
+ const string = async () => {
541
+ const start = offset++;
542
+ let escaped = false;
543
+ while (offset < source.length) {
544
+ {
545
+ const t = work.tick();
546
+ if (t) await t;
547
+ }
548
+ const character = source[offset++];
549
+ if (!escaped && character === '"') {
550
+ let value2;
551
+ try {
552
+ value2 = JSON.parse(source.slice(start, offset));
553
+ } catch {
554
+ return fail();
555
+ }
556
+ if (utf8ByteLength(value2) > work.limits.maxScalarBytes) throw new MikeError("yq limit exceeded: maxScalarBytes");
557
+ return utf8Decoder.decode(utf8Encoder.encode(value2));
558
+ }
559
+ if (!escaped && character === "\\") escaped = true;
560
+ else escaped = false;
561
+ }
562
+ return fail();
563
+ };
564
+ const parse = async (depth, context = "null") => {
565
+ await skip();
566
+ {
567
+ const t = work.tick();
568
+ if (t) await t;
569
+ }
570
+ work.depth(depth);
571
+ const character = source[offset];
572
+ if (character === void 0) return fail(context === "value of object" ? "object of object" : context);
573
+ admit();
574
+ if (character === "{") {
575
+ offset++;
576
+ const node = new yaml.YAMLMap();
577
+ await skip();
578
+ if (source[offset] === "}") {
579
+ offset++;
580
+ return node;
581
+ }
582
+ for (; ; ) {
583
+ if (source[offset] !== '"') return fail();
584
+ admit();
585
+ const key = new yaml.Scalar(await string());
586
+ await skip();
587
+ if (source[offset++] !== ":") return fail();
588
+ const value3 = await parse(depth + 1, "value of object");
589
+ node.items.push(new yaml.Pair(key, value3));
590
+ await skip();
591
+ if (source[offset] === "}") {
592
+ offset++;
593
+ return node;
594
+ }
595
+ if (source[offset] === '"') continue;
596
+ if (source[offset++] !== ",") return fail("object of object");
597
+ await skip();
598
+ }
599
+ }
600
+ if (character === "[") {
601
+ offset++;
602
+ const node = new yaml.YAMLSeq();
603
+ await skip();
604
+ if (source[offset] === "]") {
605
+ offset++;
606
+ return node;
607
+ }
608
+ for (; ; ) {
609
+ node.items.push(await parse(depth + 1));
610
+ await skip();
611
+ if (source[offset] === "]") {
612
+ offset++;
613
+ return node;
614
+ }
615
+ if (source[offset++] !== ",") return fail();
616
+ await skip();
617
+ }
618
+ }
619
+ if (character === '"') return new yaml.Scalar(await string());
620
+ if (character === "}" || character === "]" || character === ",") return fail(context);
621
+ const start = offset;
622
+ while (offset < source.length && !' \r\n,]}"'.includes(source[offset])) {
623
+ offset++;
624
+ {
625
+ const t = work.tick();
626
+ if (t) await t;
627
+ }
628
+ }
629
+ let value2;
630
+ try {
631
+ value2 = JSON.parse(source.slice(start, offset));
632
+ } catch {
633
+ return fail();
634
+ }
635
+ if (value2 !== null && typeof value2 !== "number" && typeof value2 !== "boolean") return fail();
636
+ if (typeof value2 === "number" && Number.isFinite(value2)) {
637
+ if (Number.isInteger(value2)) {
638
+ const integer = BigInt(value2);
639
+ const clamped = integer < -(1n << 63n) ? -(1n << 63n) : integer >= 1n << 63n ? (1n << 63n) - 1n : integer;
640
+ if (Number(clamped) === value2) return new yaml.Scalar(clamped);
641
+ }
642
+ const node = new yaml.Scalar(value2);
643
+ const magnitude = Math.abs(value2);
644
+ node.source = (magnitude < 1e-4 || magnitude >= 1e6 ? value2.toExponential() : String(value2)).replace(/e([+-])([0-9])$/u, "e$10$2");
645
+ node.tag = "tag:yaml.org,2002:float";
646
+ work.implicitTags.add(node);
647
+ return node;
648
+ }
649
+ return new yaml.Scalar(value2);
650
+ };
651
+ const contents = await parse(0);
652
+ await skip();
653
+ if (offset !== source.length) fail();
654
+ const doc = new yaml.Document();
655
+ doc.contents = contents;
656
+ return doc;
657
+ }
658
+ async function adaptQuotedIndent(text, filename, yaml, work) {
659
+ const additions = [];
660
+ const failures = /* @__PURE__ */ new Map();
661
+ if (!text.includes('"') && !text.includes("'")) return { text, insertions: [], failures };
662
+ let size = utf8ByteLength(text);
663
+ let sourceOffset = 0;
664
+ let quotedUntil = 0;
665
+ const lexer = new yaml.Lexer();
666
+ const closeQuote = async (start, limit) => {
667
+ const quote = text[start];
668
+ let escaped = false;
669
+ for (let index = start + 1; index < limit; index++) {
670
+ {
671
+ const t = work.tick();
672
+ if (t) await t;
673
+ }
674
+ if (index - start > work.limits.maxScalarBytes) throw new MikeError("yq limit exceeded: maxScalarBytes");
675
+ const character = text[index];
676
+ if (character === "\n") {
677
+ const marker = text.slice(index + 1, index + 4);
678
+ const after = text[index + 4];
679
+ if ((marker === "---" || marker === "...") && (after === void 0 || " \r\n".includes(after))) {
680
+ const line = text.slice(0, start).split("\n").length;
681
+ const column = start - text.lastIndexOf("\n", start);
682
+ const markerLine = text.slice(0, index + 1).split("\n").length;
683
+ if (!failures.has(start)) work.node();
684
+ failures.set(start, `bad file '${filename}': yaml: while scanning a quoted scalar at line ${line}, column ${column}: line ${markerLine}: found unexpected document indicator`);
685
+ return -1;
686
+ }
687
+ }
688
+ if (quote === '"') {
689
+ if (!escaped && character === '"') return index + 1;
690
+ if (!escaped && character === "\\") escaped = true;
691
+ else escaped = false;
692
+ } else if (character === "'") {
693
+ if (text[index + 1] === "'") index++;
694
+ else return index + 1;
695
+ }
696
+ }
697
+ return -1;
698
+ };
699
+ scan: for (let offset = 0; offset <= text.length; offset += 4096) {
700
+ const incomplete = offset + 4096 < text.length;
701
+ await work.tick(Math.min(4096, text.length - offset) + 1);
702
+ for (const lexeme of lexer.lex(text.slice(offset, offset + 4096), incomplete)) {
703
+ {
704
+ const t = work.tick();
705
+ if (t) await t;
706
+ }
707
+ if (lexeme === yaml.CST.DOCUMENT || lexeme === yaml.CST.FLOW_END || lexeme === yaml.CST.SCALAR) continue;
708
+ const start = sourceOffset;
709
+ sourceOffset += lexeme.length;
710
+ if (start < quotedUntil || lexeme[0] !== '"' && lexeme[0] !== "'") continue;
711
+ const closed = await closeQuote(start, sourceOffset);
712
+ if (failures.size) break scan;
713
+ if (closed >= 0) continue;
714
+ const end = await closeQuote(start, text.length);
715
+ if (failures.size) break scan;
716
+ if (end < 0) continue;
717
+ quotedUntil = end;
718
+ const lineStart = text.lastIndexOf("\n", start) + 1;
719
+ let indentation = 0;
720
+ while (text[lineStart + indentation] === " ") {
721
+ indentation++;
722
+ {
723
+ const t = work.tick();
724
+ if (t) await t;
725
+ }
726
+ }
727
+ for (let index = start; index < end; index++) {
728
+ {
729
+ const t = work.tick();
730
+ if (t) await t;
731
+ }
732
+ if (text[index] !== "\n") continue;
733
+ let spaces = 0;
734
+ while (text[index + 1 + spaces] === " ") {
735
+ spaces++;
736
+ {
737
+ const t = work.tick();
738
+ if (t) await t;
739
+ }
740
+ }
741
+ if (spaces > indentation) continue;
742
+ const length = indentation + 1 - spaces;
743
+ if (length > work.limits.maxInputBytes - size) throw new MikeError("yq limit exceeded: maxInputBytes");
744
+ work.node(3);
745
+ additions.push({ offset: index + 1, length });
746
+ size += length;
747
+ }
748
+ }
749
+ if (!incomplete) break;
331
750
  }
332
- return `yq: ${error.category}: ${error.code}${location}
333
- `;
751
+ if (!additions.length) return { text, insertions: [], failures };
752
+ const chunks = [];
753
+ const insertions = [];
754
+ let copied = 0;
755
+ let inserted = 0;
756
+ for (const addition of additions) {
757
+ {
758
+ const t = work.tick(addition.length + 1);
759
+ if (t) await t;
760
+ }
761
+ chunks.push(text.slice(copied, addition.offset), " ".repeat(addition.length));
762
+ insertions.push({ offset: addition.offset + inserted, length: addition.length });
763
+ copied = addition.offset;
764
+ inserted += addition.length;
765
+ }
766
+ chunks.push(text.slice(copied));
767
+ return { text: chunks.join(""), insertions, failures };
334
768
  }
335
- function classifyValueFailure(error) {
336
- const category = error.code.startsWith("ENCODE_") ? "encode" : "schema";
337
- return new YqError(category, error.code, 5);
338
- }
339
- function withSource(error, source) {
340
- if (error.source !== void 0) return error;
341
- return new YqError(error.category, error.code, error.status, source, error.line, error.column);
342
- }
343
- async function collectSource(context, owner, session, sourceName, source, vfs, inputFormat) {
344
- let producer;
345
- let finished = false;
346
- let producerReturn;
347
- const closeProducer = () => {
348
- if (producerReturn) return producerReturn;
349
- if (!producer || finished || !producer.return) return Promise.resolve({ done: true, value: void 0 });
350
- producerReturn = Promise.resolve().then(() => producer.return());
351
- return producerReturn;
769
+ async function decodeDocuments(text, filename, fileIndex, format, yaml, work, onDocument) {
770
+ const documents = [];
771
+ const sources = [];
772
+ const originalText = text;
773
+ let insertions = [];
774
+ let quotedFailures = /* @__PURE__ */ new Map();
775
+ const originalOffset = (offset) => {
776
+ let added = 0;
777
+ for (const insertion of insertions) {
778
+ if (insertion.offset >= offset) break;
779
+ added += Math.min(insertion.length, offset - insertion.offset);
780
+ }
781
+ return offset - added;
352
782
  };
353
- owner.register(async () => {
354
- await closeProducer();
355
- });
356
- let iterator;
357
- let returned;
358
- owner.register(async () => {
359
- if (iterator?.return) {
360
- returned ??= Promise.resolve().then(() => iterator.return());
361
- await returned;
783
+ const position = (offset) => {
784
+ const index = originalOffset(offset);
785
+ const prefix2 = originalText.slice(0, index);
786
+ return { line: prefix2.split("\n").length, column: index - prefix2.lastIndexOf("\n") };
787
+ };
788
+ const accept = async (doc, implicit = false) => {
789
+ work.assertOpen();
790
+ const startOffset = originalOffset(doc.range?.[0] ?? 0);
791
+ const endOffset = originalOffset(doc.range?.[2] ?? text.length);
792
+ for (const [offset, failure] of quotedFailures) if (offset >= startOffset && offset < endOffset) throw new MikeError(failure);
793
+ const error = doc.errors.find((error2) => !(error2.code === "MISSING_CHAR" && error2.message === "Comments must be separated from other tokens by white space characters"));
794
+ if (error) {
795
+ let message = error.message;
796
+ const start = position(doc.contents?.range?.[0] ?? doc.range?.[0] ?? 0);
797
+ if (message.startsWith("Flow sequence") && message.includes("end with a ]")) message = `while parsing a flow node at line ${start.line}: did not find expected node content`;
798
+ else if (message.startsWith("Missing closing") && message.includes("quote")) {
799
+ const end = position(error.pos[0]);
800
+ message = `while scanning a quoted scalar at line ${start.line}: line ${end.line}, column ${end.column}: found unexpected end of stream`;
801
+ } else if (message === "Missing , or : between flow sequence items") message = `while parsing a flow sequence at <unknown position>: line ${start.line}: did not find expected ',' or ']'`;
802
+ else if (error.code === "MULTILINE_IMPLICIT_KEY") {
803
+ let colon = error.pos[1];
804
+ while (text[colon] === " " || text[colon] === " ") {
805
+ colon++;
806
+ {
807
+ const t = work.tick();
808
+ if (t) await t;
809
+ }
810
+ }
811
+ const location = position(colon);
812
+ message = `line ${location.line}, column ${location.column}: mapping values are not allowed in this context`;
813
+ }
814
+ throw new MikeError(`bad file '${filename}': yaml: ${message}`);
362
815
  }
363
- });
364
- iterator = readBytes({ [Symbol.asyncIterator]() {
365
- owner.assertOpen(context.signal);
366
- producer = source[Symbol.asyncIterator]();
367
- return {
368
- async next() {
369
- owner.assertOpen(context.signal);
370
- const next = await producer.next();
371
- if (next.done) finished = true;
372
- return next;
373
- },
374
- return: closeProducer
816
+ work.document();
817
+ if (!doc.contents) {
818
+ const empty = new yaml.Scalar(null);
819
+ empty.source = "";
820
+ work.node();
821
+ doc.contents = empty;
822
+ }
823
+ await inspectNode(doc.contents, yaml, work, true);
824
+ const source = sources.shift();
825
+ if (format === "yaml") await recordHeadComments(doc.contents, source ? [...source.prefix, ...source.token.start] : [], documents.length === 0 ? text : void 0, yaml, work);
826
+ const anchors = /* @__PURE__ */ new Set();
827
+ const pending = [doc.contents];
828
+ while (pending.length) {
829
+ {
830
+ const t = work.tick();
831
+ if (t) await t;
832
+ }
833
+ const node = pending.pop();
834
+ if (work.capturePositions && node.range && format === "yaml") {
835
+ {
836
+ const t = work.tick(node.range[0] + 1);
837
+ if (t) await t;
838
+ }
839
+ let offset = node.range[0];
840
+ if ("anchor" in node && node.anchor) {
841
+ const anchorOffset = text.lastIndexOf(`&${node.anchor}`, offset);
842
+ if (anchorOffset >= startOffset) offset = anchorOffset;
843
+ }
844
+ work.positions.set(node, position(offset));
845
+ }
846
+ if ("anchor" in node && node.anchor) anchors.add(node.anchor);
847
+ if (yaml.isAlias(node)) {
848
+ work.alias();
849
+ if (!anchors.has(node.source)) {
850
+ const location = position((node.range?.[0] ?? 0) + 1);
851
+ throw new MikeError(`bad file '${filename}': yaml: line ${location.line}, column ${location.column}: unknown anchor '${node.source}' referenced`);
852
+ }
853
+ } else if (yaml.isMap(node)) {
854
+ for (let index = node.items.length - 1; index >= 0; index--) {
855
+ const pair = node.items[index];
856
+ if (yaml.isNode(pair.value)) pending.push(pair.value);
857
+ if (yaml.isNode(pair.key)) pending.push(pair.key);
858
+ }
859
+ } else if (yaml.isSeq(node)) {
860
+ for (let index = node.items.length - 1; index >= 0; index--) if (yaml.isNode(node.items[index])) pending.push(node.items[index]);
861
+ }
862
+ }
863
+ const document = { doc, filename: implicit ? "" : filename, fileIndex, documentIndex: documents.length, format };
864
+ documents.push(document);
865
+ await onDocument?.(document);
866
+ };
867
+ if (format === "json") {
868
+ let start = 0;
869
+ let depth = 0;
870
+ let quoted = false;
871
+ let escaped = false;
872
+ let tokens = 0;
873
+ const acceptJson = async (end) => {
874
+ const source = text.slice(start, end).trim();
875
+ start = end;
876
+ if (!source) return;
877
+ if (utf8ByteLength(source) > work.limits.maxDocumentBytes) throw new MikeError("yq limit exceeded: maxDocumentBytes");
878
+ const doc = await decodeJsonDocument(source, filename, yaml, work);
879
+ await accept(doc);
375
880
  };
376
- } }, context.signal)[Symbol.asyncIterator]();
377
- const chunks = [];
378
- const framer = inputFormat === "yaml" ? new RawDocumentFramer() : void 0;
379
- let size = 0;
380
- let chunksSinceYield = 0;
381
- while (true) {
382
- let next;
383
- try {
384
- next = await iterator.next();
385
- } catch (failure) {
386
- if (context.signal.aborted) throw context.signal.reason;
387
- if (vfs && failure instanceof FsError) throw new YqError("vfs", "VFS_INPUT_READ", 2, sourceName);
388
- throw failure;
389
- }
390
- owner.assertOpen(context.signal);
391
- if (next.done) break;
392
- const chunk = next.value;
393
- await session.ownedWork.charge(1);
394
- if (++chunksSinceYield === 1024) {
395
- await yieldTurn(context.signal);
396
- chunksSinceYield = 0;
397
- }
398
- owner.assertOpen(context.signal);
399
- if (chunk.byteLength === 0) continue;
400
- session.ownedWork.admitInputBytes(chunk.byteLength);
401
- if (chunk.byteLength > yqCaps.maxInputBytes - size) throw fromJqLimit(new JqLimitError("maxInputBytes"));
402
- if (inputFormat === "toml" && chunk.byteLength > yqCaps.maxDocumentBytes - size) throw new YqError("limit", "LIMIT_MAX_DOCUMENT_BYTES", 5);
403
- framer?.admit(chunk);
404
- const owned = new Uint8Array(chunk);
405
- owner.assertOpen(context.signal);
406
- chunks.push(owned);
407
- size += owned.byteLength;
408
- }
409
- owner.assertOpen(context.signal);
410
- const bytes = new Uint8Array(size);
411
- let offset = 0;
412
- for (const chunk of chunks) {
413
- bytes.set(chunk, offset);
414
- offset += chunk.byteLength;
415
- }
416
- owner.assertOpen(context.signal);
417
- return framer ? framer.finish(bytes) : [{ bytes, rawBytes: size, lineOffset: 0 }];
418
- }
419
- async function sourceFrames(context, owner, session, sourceName, inputFormat) {
420
- if (sourceName === "-") return collectSource(context, owner, session, "<stdin>", context.stdin, false, inputFormat);
421
- const path = pathOf(context, sourceName);
422
- await session.ownedWork.charge();
423
- owner.assertOpen(context.signal);
424
- let capabilities;
425
- try {
426
- capabilities = context.fs.capabilitiesFor ? await interruptible(() => context.fs.capabilitiesFor(path, { signal: context.signal }), context.signal) : context.fs.capabilities;
427
- } catch (failure) {
428
- if (context.signal.aborted) throw context.signal.reason;
429
- if (failure instanceof FsError) throw new YqError("vfs", "VFS_INPUT_OPEN", 2, sourceName);
430
- throw failure;
431
- }
432
- owner.assertOpen(context.signal);
433
- if (context.fs.readStream && capabilities.streamingRead !== false) {
434
- let source;
435
- try {
436
- source = context.fs.readStream(path, { signal: context.signal });
437
- } catch (failure) {
438
- if (context.signal.aborted) throw context.signal.reason;
439
- if (failure instanceof FsError) throw new YqError("vfs", "VFS_INPUT_OPEN", 2, sourceName);
440
- throw failure;
881
+ for (let index = 0; index < text.length; index++) {
882
+ if ((index & 255) === 0) {
883
+ const t = work.tick(256);
884
+ if (t) await t;
885
+ }
886
+ const character = text[index];
887
+ if (quoted) {
888
+ if (escaped) escaped = false;
889
+ else if (character === "\\") escaped = true;
890
+ else if (character === '"') {
891
+ quoted = false;
892
+ if (depth === 0) await acceptJson(index + 1);
893
+ }
894
+ } else if (character === '"') quoted = true;
895
+ else if (character === "{" || character === "[") {
896
+ depth++;
897
+ work.depth(depth);
898
+ } else if (character === "}" || character === "]") {
899
+ depth--;
900
+ if (depth === 0) {
901
+ await acceptJson(index + 1);
902
+ tokens = 0;
903
+ }
904
+ } else if (/\s/u.test(character) && depth === 0) await acceptJson(index + 1);
905
+ if (!quoted && ",:{}[]".includes(character) && ++tokens > work.limits.maxParserNodes) throw new MikeError("yq limit exceeded: maxParserNodes");
441
906
  }
442
- return collectSource(context, owner, session, sourceName, source, true, inputFormat);
907
+ await acceptJson(text.length);
908
+ return documents;
443
909
  }
444
- let bytes;
445
- try {
446
- bytes = await context.fs.readFile(path, { signal: context.signal, ...Number.isFinite(inputFormat === "toml" ? yqCaps.maxDocumentBytes : yqCaps.maxInputBytes) ? { maxBytes: inputFormat === "toml" ? yqCaps.maxDocumentBytes : yqCaps.maxInputBytes } : {} });
447
- } catch (failure) {
448
- if (context.signal.aborted) throw context.signal.reason;
449
- if (inputFormat === "toml" && failure instanceof FsError && failure.code === "EFBIG") throw new YqError("limit", "LIMIT_MAX_DOCUMENT_BYTES", 5);
450
- if (failure instanceof FsError) throw new YqError("vfs", "VFS_INPUT_READ", 2, sourceName);
451
- throw failure;
452
- }
453
- owner.assertOpen(context.signal);
454
- session.ownedWork.admitInputBytes(bytes.byteLength);
455
- if (inputFormat === "toml") {
456
- if (bytes.byteLength > yqCaps.maxDocumentBytes) throw new YqError("limit", "LIMIT_MAX_DOCUMENT_BYTES", 5);
457
- return [{ bytes: new Uint8Array(bytes), rawBytes: bytes.byteLength, lineOffset: 0 }];
458
- }
459
- const framer = new RawDocumentFramer();
460
- framer.admit(bytes);
461
- const owned = new Uint8Array(bytes);
462
- owner.assertOpen(context.signal);
463
- return framer.finish(owned);
464
- }
465
- function decodeDocument(bytes, inputFormat) {
466
- try {
467
- return new TextDecoder("utf-8", { fatal: true, ignoreBOM: inputFormat === "toml" }).decode(bytes);
468
- } catch {
469
- throw new YqError("input", "INPUT_INVALID_UTF8", 5);
910
+ const admitText = async (input) => {
911
+ let documentBytes = 0;
912
+ for (let offset = 0; offset < input.length; ) {
913
+ const newline = input.indexOf("\n", offset);
914
+ const end = newline < 0 ? input.length : newline + 1;
915
+ if (end - offset > work.limits.maxScalarBytes) throw new MikeError("yq limit exceeded: maxScalarBytes");
916
+ const line = input.slice(offset, end);
917
+ if (/^(?:---|\.\.\.)(?:[ \t\r\n]|$)/u.test(line)) documentBytes = 0;
918
+ documentBytes += utf8ByteLength(line);
919
+ if (documentBytes > work.limits.maxDocumentBytes) throw new MikeError("yq limit exceeded: maxDocumentBytes");
920
+ {
921
+ const t = work.tick(line.length + 1);
922
+ if (t) await t;
923
+ }
924
+ offset = end;
925
+ }
926
+ };
927
+ await admitText(text);
928
+ const adapted = await adaptQuotedIndent(text, filename, yaml, work);
929
+ quotedFailures = adapted.failures;
930
+ if (adapted.text !== text) {
931
+ await admitText(adapted.text);
932
+ text = adapted.text;
933
+ insertions = adapted.insertions;
934
+ }
935
+ const lexer = new yaml.Lexer();
936
+ const parser = new yaml.Parser();
937
+ const composer = new yaml.Composer({ keepSourceTokens: true, intAsBigInt: true, uniqueKeys: false, merge: false, prettyErrors: false, logLevel: "silent" });
938
+ let hasDocument = false;
939
+ let prefix = [];
940
+ const token = async (item) => {
941
+ await admitCst(item, work);
942
+ if (item.type === "document") {
943
+ hasDocument = true;
944
+ sources.push({ token: item, prefix });
945
+ prefix = [];
946
+ } else if (item.type === "comment" || item.type === "newline") prefix.push(item);
947
+ for (const doc of composer.next(item)) await accept(doc);
948
+ };
949
+ for (let offset = 0; offset <= text.length; offset += 4096) {
950
+ await work.tick(Math.min(4096, text.length - offset) + 1);
951
+ const incomplete = offset + 4096 < text.length;
952
+ for (const lexeme of lexer.lex(text.slice(offset, offset + 4096), incomplete)) {
953
+ if (utf8ByteLength(lexeme) > work.limits.maxScalarBytes) throw new MikeError("yq limit exceeded: maxScalarBytes");
954
+ {
955
+ const t = work.tick();
956
+ if (t) await t;
957
+ }
958
+ work.depth(parser.stack.length);
959
+ for (const item of parser.next(lexeme)) await token(item);
960
+ }
961
+ if (!incomplete) break;
470
962
  }
963
+ for (const item of parser.end()) await token(item);
964
+ for (const doc of composer.end(documents.length === 0, text.length)) await accept(doc, !hasDocument);
965
+ return documents;
471
966
  }
472
- async function writeOperation(operation, bytes, owner, callerSignal) {
473
- owner.assertOpen(callerSignal);
474
- try {
475
- await operation.output.write(bytes);
476
- } catch (failure) {
477
- throw new SinkFailure(failure);
478
- }
479
- owner.assertOpen(callerSignal);
480
- }
481
- async function runCommand(context, owner, inputFormat, limits) {
482
- const ledger = new YqLedger(limits);
483
- let session;
484
- let stdout;
485
- let stderr;
486
- const stdoutOperation = () => {
487
- stdout ??= createOutputOperation({ signal: context.signal, registerCleanup: (cleanup) => owner.register(cleanup) }, context.stdout);
488
- return stdout;
967
+
968
+ // packages/safe-bash-command-yq/src/native-encoder.ts
969
+ init_buffer();
970
+ import { utf8ByteLength as utf8ByteLength2 } from "../safe-bash-query-engine/bytes.js";
971
+ async function encodeNative(candidate, options, yaml, work) {
972
+ await inspectNode(candidate.node, yaml, work);
973
+ if (options.indent > work.limits.maxOutputBytes) throw new MikeError("yq limit exceeded: maxOutputBytes");
974
+ const spacing = Math.max(0, options.indent);
975
+ const chunks = [];
976
+ let bytes = 0;
977
+ const append = (text2) => {
978
+ const incoming = utf8ByteLength2(text2);
979
+ if (incoming > work.limits.maxOutputBytes - bytes) throw new MikeError("yq limit exceeded: maxOutputBytes");
980
+ bytes += incoming;
981
+ chunks.push(text2);
489
982
  };
490
- const stderrOperation = () => {
491
- stderr ??= createOutputOperation({ signal: context.signal, registerCleanup: (cleanup) => owner.register(cleanup) }, context.stderr);
492
- return stderr;
983
+ const indent = (depth) => {
984
+ const count = spacing * depth;
985
+ if (count > work.limits.maxOutputBytes - bytes) throw new MikeError("yq limit exceeded: maxOutputBytes");
986
+ append(" ".repeat(count));
493
987
  };
494
- const emitDiagnostic = async (error) => {
495
- const preferred = utf8Encoder.encode(diagnostic(error));
496
- const fallback = utf8Encoder.encode(diagnosticFallback);
497
- const selected = ledger.canAdmitDiagnostic(preferred.byteLength) ? preferred : ledger.canAdmitDiagnostic(fallback.byteLength) ? fallback : void 0;
498
- if (!selected) return;
499
- ledger.admitDiagnostic(selected.byteLength);
500
- session?.ownedWork.admitOutputBytes(selected.byteLength);
501
- await writeOperation(stderrOperation(), selected, owner, context.signal);
988
+ const primitive = (node) => {
989
+ if (!yaml.isScalar(node) || node.value == null) return "null";
990
+ if (typeof node.value === "bigint") return node.value.toString();
991
+ if (typeof node.value === "number" && !Number.isFinite(node.value)) return node.value === Infinity ? ".inf" : node.value === -Infinity ? "-.inf" : ".nan";
992
+ return String(node.value);
502
993
  };
503
- try {
504
- preflightArguments(context);
505
- const info = isInformationForm(context.args);
506
- if (context.args.some((argument) => argument === "-h" || argument === "--help" || argument === "--version") && info === void 0) {
507
- throw cli("CLI_INFO_COMBINATION");
508
- }
509
- if (info) {
510
- const bytes = utf8Encoder.encode(info === "help" ? help : version);
511
- ledger.admitStdout(bytes.byteLength);
512
- await writeOperation(stdoutOperation(), bytes, owner, context.signal);
513
- return { exitCode: 0 };
514
- }
515
- const options = parseArguments(context.args, inputFormat);
516
- if (utf8ByteLength(options.filter) > yqCaps.maxQuerySourceBytes) throw new YqError("limit", "LIMIT_MAX_QUERY_SOURCE_BYTES", 5);
517
- owner.register(async () => session?.close());
518
- session = createYqQuerySession({ signal: context.signal, limits });
519
- try {
520
- session.compileOnce(options.filter);
521
- } catch (failure) {
522
- if (failure instanceof JqLimitError) throw fromJqLimit(failure);
523
- if (failure instanceof JqError) throw new YqError("query", "QUERY_COMPILE_FAILED", 3);
524
- throw failure;
525
- }
526
- const files = options.files.length > 0 ? options.files : ["-"];
527
- let emitted = 0;
528
- for (const file of files) {
529
- const sourceName = file === "-" ? "<stdin>" : file;
530
- let frames;
531
- try {
532
- frames = await sourceFrames(context, owner, session, file, options.inputFormat);
533
- } catch (failure) {
534
- throw failure instanceof YqError ? withSource(failure, sourceName) : failure;
535
- }
536
- owner.assertOpen(context.signal);
537
- for (const frame of frames) {
538
- ledger.admitDocumentBytes(frame.rawBytes);
539
- let input;
540
- try {
541
- input = decodeDocument(frame.bytes, options.inputFormat);
542
- } catch (failure) {
543
- throw failure instanceof YqError ? withSource(failure, sourceName) : failure;
994
+ if (options.format === "yaml" && yaml.isScalar(candidate.node) && candidate.node.value === null && (candidate.node.source === "" || candidate.document.filename === "")) {
995
+ return candidate.document.doc.directives?.docStart && candidate.node === candidate.document.doc.contents ? "---\n" : "\n";
996
+ }
997
+ if (options.unwrap && yaml.isScalar(candidate.node)) return `${candidate.node.source ?? primitive(candidate.node)}
998
+ `;
999
+ if (options.format === "json") {
1000
+ const write = async (current, depth) => {
1001
+ {
1002
+ const t = work.tick();
1003
+ if (t) await t;
1004
+ }
1005
+ work.depth(depth);
1006
+ const base = dereference(current, yaml, work);
1007
+ const node = base.node;
1008
+ if (yaml.isScalar(node)) {
1009
+ if (typeof node.value === "number" && !Number.isFinite(node.value)) {
1010
+ throw new MikeError(`${"json: error calling MarshalJSON for type *yqlib.CandidateNode: ".repeat(depth + 1)}strconv.ParseFloat: parsing ${JSON.stringify(node.source ?? primitive(node))}: invalid syntax`);
544
1011
  }
545
- owner.assertOpen(context.signal);
546
- try {
547
- const documents = options.inputFormat === "toml" ? [await parseTomlDocument(input, session.ownedWork, ledger, frame.rawBytes)] : parseYamlDocuments(input, session.ownedWork, ledger, frame.rawBytes, frame.lineOffset);
548
- for await (const document of documents) {
549
- owner.assertOpen(context.signal);
550
- try {
551
- await session.ownedWork.measure(document);
552
- } catch (failure) {
553
- if (failure instanceof JqLimitError) throw fromJqLimit(failure);
554
- if (failure instanceof YqValueFailure) throw classifyValueFailure(failure);
555
- throw failure;
556
- }
557
- owner.assertOpen(context.signal);
558
- const iterator = session.run(document);
559
- const firstBatchedResult = emitted + 2;
560
- let outBatch;
561
- let outBatchUsed = 0;
562
- const flushOutBatch = async () => {
563
- if (outBatchUsed > 0) {
564
- const slice = outBatch.subarray(0, outBatchUsed);
565
- outBatchUsed = 0;
566
- await writeOperation(stdoutOperation(), slice, owner, context.signal);
567
- }
568
- };
569
- try {
570
- while (true) {
571
- let next;
572
- try {
573
- next = await iterator.next();
574
- } catch (failure) {
575
- await flushOutBatch();
576
- if (context.signal.aborted) throw context.signal.reason;
577
- if (failure instanceof JqLimitError) throw fromJqLimit(failure);
578
- if (failure instanceof JqError) throw new YqError("query", "QUERY_RUNTIME_FAILED", 5, sourceName);
579
- throw failure;
580
- }
581
- owner.assertOpen(context.signal);
582
- if (next.done) break;
583
- try {
584
- const m = session.ownedWork.measureSync ? session.ownedWork.measureSync(next.value) : session.ownedWork.measure(next.value);
585
- if (m instanceof Promise) await m;
586
- } catch (failure) {
587
- await flushOutBatch();
588
- if (failure instanceof JqLimitError) throw fromJqLimit(failure);
589
- if (failure instanceof YqValueFailure) throw classifyValueFailure(failure);
590
- throw failure;
591
- }
592
- owner.assertOpen(context.signal);
593
- session.ownedWork.admitResult();
594
- const separator = emitted === 0 || options.format === "json" ? "" : "---\n";
595
- const suffixBytes = utf8ByteLength(separator) + 1;
596
- const remaining = yqCaps.stdoutCapBytes - ledger.stdoutBytes;
597
- if (suffixBytes > remaining) {
598
- await flushOutBatch();
599
- throw new YqError("limit", "LIMIT_MAX_OUTPUT_BYTES", 5, sourceName);
600
- }
601
- let encoded;
602
- try {
603
- if (options.format === "yaml") {
604
- const e = encodeYaml(next.value, session.ownedWork, remaining - suffixBytes);
605
- encoded = e instanceof Promise ? await e : e;
606
- } else if (options.raw && typeof next.value === "string") {
607
- encoded = await encodeRaw(next.value, session.ownedWork, remaining - 1);
608
- } else {
609
- encoded = await encodeJson(next.value, session.ownedWork, !options.compact, remaining - 1);
610
- }
611
- } catch (failure) {
612
- await flushOutBatch();
613
- if (failure instanceof JqLimitError) throw fromJqLimit(failure);
614
- if (failure instanceof YqValueFailure) throw classifyValueFailure(failure);
615
- throw failure;
616
- }
617
- owner.assertOpen(context.signal);
618
- const encodedBytes = utf8ByteLength(encoded);
619
- const outputBytes = encodedBytes + suffixBytes;
620
- try {
621
- ledger.admitStdout(outputBytes);
622
- session.ownedWork.admitOutputBytes(outputBytes);
623
- } catch (failure) {
624
- await flushOutBatch();
625
- throw failure;
626
- }
627
- owner.assertOpen(context.signal);
628
- if (emitted < firstBatchedResult || outputBytes >= 8192) {
629
- await flushOutBatch();
630
- const output = new Uint8Array(outputBytes);
631
- let offset = 0;
632
- if (separator !== "") offset += utf8Encoder.encodeInto(separator, output).written;
633
- offset += utf8Encoder.encodeInto(encoded, output.subarray(offset)).written;
634
- output[offset] = 10;
635
- owner.assertOpen(context.signal);
636
- await writeOperation(stdoutOperation(), output, owner, context.signal);
637
- } else {
638
- const batch = outBatch ??= new Uint8Array(16384);
639
- if (outBatchUsed + outputBytes > batch.byteLength) await flushOutBatch();
640
- if (separator !== "") outBatchUsed += utf8Encoder.encodeInto(separator, batch.subarray(outBatchUsed)).written;
641
- outBatchUsed += utf8Encoder.encodeInto(encoded, batch.subarray(outBatchUsed)).written;
642
- batch[outBatchUsed++] = 10;
643
- }
644
- emitted++;
645
- }
646
- await flushOutBatch();
647
- } finally {
648
- outBatchUsed = 0;
649
- await iterator.return(void 0);
650
- owner.assertOpen(context.signal);
651
- }
652
- }
653
- } catch (failure) {
654
- throw failure instanceof YqError ? withSource(failure, sourceName) : failure;
1012
+ const custom = node.tag && !node.tag.startsWith("tag:yaml.org,2002:") && typeof node.value === "string" && /^(?:true|false|null|[+-]?[0-9]+(?:\.[0-9]+)?)$/u.test(node.value);
1013
+ const typed = node.tag === "tag:yaml.org,2002:int" || node.tag === "tag:yaml.org,2002:float" || node.tag === "tag:yaml.org,2002:bool" || node.tag === "tag:yaml.org,2002:null";
1014
+ if (typeof node.value === "string" && (custom || typed)) {
1015
+ const text2 = node.value;
1016
+ if (/^[+-]?[0-9]+$/u.test(text2)) append(BigInt(text2).toString());
1017
+ else if (/^[+-]?[0-9]+\.[0-9]+$/u.test(text2)) append(JSON.stringify(Number(text2)));
1018
+ else if (["true", "false", "null"].includes(text2)) append(text2);
1019
+ else throw new MikeError(`cannot encode ${node.tag} value as JSON`);
1020
+ } else if (typeof node.value === "number" && node.tag === "tag:yaml.org,2002:float" && node.source && /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$/u.test(node.source)) append(node.source);
1021
+ else append(typeof node.value === "string" ? JSON.stringify(node.value) : primitive(node));
1022
+ return;
1023
+ }
1024
+ if (yaml.isAlias(node)) throw new MikeError("cyclic YAML alias");
1025
+ const map = yaml.isMap(node);
1026
+ append(map ? "{" : "[");
1027
+ const items = node.items;
1028
+ for (let index = 0; index < items.length; index++) {
1029
+ if (index) append(",");
1030
+ if (spacing) {
1031
+ append("\n");
1032
+ indent(depth + 1);
655
1033
  }
1034
+ let child;
1035
+ if (map) {
1036
+ const pair = node.items[index];
1037
+ if (!yaml.isScalar(pair.key)) throw new MikeError("cannot encode complex YAML key as JSON");
1038
+ append(JSON.stringify(String(pair.key.value)));
1039
+ append(spacing ? ": " : ":");
1040
+ child = pair.value;
1041
+ } else child = items[index];
1042
+ await write({ node: child, document: current.document }, depth + 1);
1043
+ }
1044
+ if (items.length && spacing) {
1045
+ append("\n");
1046
+ indent(depth);
656
1047
  }
1048
+ append(map ? "}" : "]");
1049
+ };
1050
+ await write(candidate, 0);
1051
+ append("\n");
1052
+ return chunks.join("");
1053
+ }
1054
+ if (options.indent < 0) throw new MikeError("indent must not be negative");
1055
+ const pending = [{ node: candidate.node, depth: 0 }];
1056
+ let projected = 0;
1057
+ while (pending.length) {
1058
+ const { node, depth } = pending.pop();
1059
+ {
1060
+ const t = work.tick();
1061
+ if (t) await t;
657
1062
  }
658
- return { exitCode: 0 };
659
- } catch (failure) {
660
- if (context.signal.aborted) throw context.signal.reason;
661
- if (failure instanceof SinkFailure) throw failure.reason;
662
- let normal;
663
- if (failure instanceof YqError) normal = failure;
664
- else if (failure instanceof JqLimitError) normal = fromJqLimit(failure);
665
- else if (failure instanceof YqValueFailure) normal = classifyValueFailure(failure);
666
- if (!normal) throw failure;
667
- await emitDiagnostic(normal);
668
- return { exitCode: normal.status };
669
- }
670
- }
671
- async function execute(context, inputFormat, limits) {
672
- const owner = new InvocationOwner();
673
- context.registerCleanup?.(() => owner.close());
674
- let result;
675
- let primary;
676
- let hasPrimary = false;
677
- try {
678
- result = await runCommand(context, owner, inputFormat, limits);
679
- } catch (failure) {
680
- primary = failure;
681
- hasPrimary = true;
1063
+ projected += 32 + depth * Math.max(options.indent, 2) + 6 * utf8ByteLength2(node.comment ?? "") + 6 * utf8ByteLength2(node.commentBefore ?? "");
1064
+ if (yaml.isScalar(node)) projected += 6 * utf8ByteLength2(String(node.value));
1065
+ else if (yaml.isMap(node)) for (const pair of node.items) {
1066
+ if (yaml.isScalar(pair.key) && pair.key.value === "<<" && pair.key.type === "PLAIN") pair.key.tag = "tag:yaml.org,2002:merge";
1067
+ pending.push({ node: pair.key, depth: depth + 1 }, { node: pair.value, depth: depth + 1 });
1068
+ }
1069
+ else if (yaml.isSeq(node)) for (const child of node.items) pending.push({ node: child, depth: depth + 1 });
1070
+ if (projected > mikeLimits.maxOutputBytes) throw new MikeError("yq limit exceeded: maxOutputBytes");
682
1071
  }
683
- let cleanup;
684
- let hasCleanup = false;
685
- try {
686
- await owner.close();
687
- } catch (failure) {
688
- cleanup = failure;
689
- hasCleanup = true;
690
- }
691
- if (context.signal.aborted) throw context.signal.reason;
692
- if (hasPrimary) throw primary;
693
- if (hasCleanup) throw cleanup;
694
- return result;
695
- }
696
- function admittedOptions(options) {
697
- if (typeof options !== "object" || options === null) throw new TypeError("options must be an object");
698
- if (Object.keys(options).some((key) => key !== "replace" && key !== "inputFormat" && key !== "limits")) throw new TypeError("unsupported yq option");
699
- const { replace = false, inputFormat = "yaml" } = options;
700
- if (typeof replace !== "boolean") throw new TypeError("replace must be a boolean");
701
- if (inputFormat !== "yaml" && inputFormat !== "toml") throw new TypeError("inputFormat must be yaml or toml");
702
- return { replace, inputFormat, limits: resolveYqLimits(options.limits) };
703
- }
704
- function createYqCommand(options = {}) {
705
- const { inputFormat, limits } = admittedOptions(options);
706
- return Object.freeze({
707
- name: "yq",
708
- runtimeIdentity: commandRuntimeIdentity,
709
- description: "Bounded restricted YAML/TOML query and formatter",
710
- execute: (context) => execute(context, inputFormat, limits)
1072
+ work.assertOpen();
1073
+ const doc = new yaml.Document();
1074
+ doc.schema.tags = doc.schema.tags.map((tag) => {
1075
+ if (!tag.stringify) return tag;
1076
+ const original = tag.stringify;
1077
+ const stringify = (item, context, onComment, onChompKeep) => {
1078
+ const node = item;
1079
+ if (yaml.isScalar(node) && typeof node.value !== "string" && node.source) return node.source;
1080
+ return yaml.isCollection(node) ? node.toString(context, onComment, onChompKeep) : original(item, context, onComment, onChompKeep);
1081
+ };
1082
+ return { ...tag, stringify };
711
1083
  });
1084
+ doc.contents = await cloneNode(candidate.node, yaml, work);
1085
+ const formatting = [doc.contents];
1086
+ while (formatting.length) {
1087
+ const node = formatting.pop();
1088
+ {
1089
+ const t = work.tick();
1090
+ if (t) await t;
1091
+ }
1092
+ if (work.implicitTags.has(node) && node.tag?.startsWith("tag:yaml.org,2002:")) delete node.tag;
1093
+ if (options.prettyPrint) {
1094
+ if (yaml.isScalar(node)) node.type = "PLAIN";
1095
+ else if (yaml.isCollection(node)) node.flow = false;
1096
+ }
1097
+ if (yaml.isScalar(node) && (node.type === "QUOTE_DOUBLE" || node.type === "QUOTE_SINGLE")) node.value = node.source ?? String(node.value);
1098
+ else if (yaml.isMap(node)) for (const pair of node.items) {
1099
+ if (yaml.isNode(pair.key)) formatting.push(pair.key);
1100
+ if (yaml.isNode(pair.value)) formatting.push(pair.value);
1101
+ }
1102
+ else if (yaml.isSeq(node)) {
1103
+ for (const child of node.items) if (yaml.isNode(child)) formatting.push(child);
1104
+ }
1105
+ }
1106
+ if (candidate.node === candidate.document.doc.contents) {
1107
+ if (options.preserveDocumentStart && doc.directives) doc.directives.docStart = candidate.document.doc.directives?.docStart ?? null;
1108
+ if (!options.preserveDocumentStart && candidate.document.doc.directives?.docStart && candidate.document.doc.commentBefore != null) {
1109
+ doc.contents.commentBefore = candidate.document.doc.commentBefore + (doc.contents.commentBefore ?? "");
1110
+ } else doc.commentBefore = candidate.document.doc.commentBefore;
1111
+ doc.comment = candidate.document.doc.comment;
1112
+ }
1113
+ const text = doc.toString({ indent: options.indent === 0 ? 4 : Math.max(2, options.indent), indentSeq: !options.compactSequence, flowCollectionPadding: false, lineWidth: 0, verifyAliasOrder: false });
1114
+ append(text);
1115
+ return chunks.join("");
712
1116
  }
713
- function createYqCommands(options = {}) {
714
- return Object.freeze([createYqCommand(options)]);
1117
+
1118
+ // packages/safe-bash-command-yq/src/formats.ts
1119
+ import { Decimal, numberText } from "../safe-bash-query-engine/numbers.js";
1120
+ function mapping(value2) {
1121
+ return value2 !== null && typeof value2 === "object" && !Array.isArray(value2);
715
1122
  }
716
- function yqCommands(options = {}) {
717
- const captured = admittedOptions(options);
718
- const { replace } = captured;
719
- const definitions = createYqCommands(captured);
720
- const plugin = {
721
- name: "yq-commands",
722
- setup(host) {
723
- if (!replace) for (const definition of definitions) {
724
- if (host.commands.has(definition.name)) throw new Error(`Command already registered: ${definition.name}`);
1123
+ async function properties(text, work) {
1124
+ let nodes = 0;
1125
+ const admit = (count) => {
1126
+ if (count > work.limits.maxParserNodes - nodes) throw new MikeError("yq limit exceeded: maxParserNodes");
1127
+ work.node(count);
1128
+ nodes += count;
1129
+ };
1130
+ admit(1);
1131
+ const result = /* @__PURE__ */ Object.create(null);
1132
+ let offset = 0;
1133
+ while (offset < text.length) {
1134
+ const newline = text.indexOf("\n", offset);
1135
+ const end = newline < 0 ? text.length : newline;
1136
+ const line = text.slice(offset, end).trim();
1137
+ offset = end + 1;
1138
+ {
1139
+ const t = work.tick(line.length + 1);
1140
+ if (t) await t;
1141
+ }
1142
+ if (!line || line.startsWith("#") || line.startsWith(";") || line.startsWith("!")) continue;
1143
+ let equal = line.indexOf("=");
1144
+ if (equal < 0) equal = line.indexOf(":");
1145
+ if (equal < 0) throw new MikeError("invalid props entry");
1146
+ const key = line.slice(0, equal).trim();
1147
+ let depth = 1;
1148
+ work.depth(depth);
1149
+ if (1 + 2 * depth > work.limits.maxParserNodes) throw new MikeError("yq limit exceeded: maxParserNodes");
1150
+ for (let index = 0; index < key.length; index++) {
1151
+ {
1152
+ const t = work.tick();
1153
+ if (t) await t;
1154
+ }
1155
+ if (key[index] !== ".") continue;
1156
+ work.depth(++depth);
1157
+ if (1 + 2 * depth > work.limits.maxParserNodes) throw new MikeError("yq limit exceeded: maxParserNodes");
1158
+ }
1159
+ let target = result;
1160
+ let start = 0;
1161
+ while (true) {
1162
+ {
1163
+ const t = work.tick();
1164
+ if (t) await t;
1165
+ }
1166
+ const dot = key.indexOf(".", start);
1167
+ const component = key.slice(start, dot < 0 ? key.length : dot);
1168
+ if (dot < 0) {
1169
+ admit(Object.hasOwn(target, component) ? 1 : 2);
1170
+ target[component] = line.slice(equal + 1).trim();
1171
+ break;
725
1172
  }
726
- for (const definition of definitions) host.commands.register(definition, { replace: replace ?? false });
1173
+ if (!mapping(target[component] ?? null)) {
1174
+ admit(Object.hasOwn(target, component) ? 1 : 2);
1175
+ target[component] = /* @__PURE__ */ Object.create(null);
1176
+ }
1177
+ target = target[component];
1178
+ start = dot + 1;
727
1179
  }
1180
+ }
1181
+ return result;
1182
+ }
1183
+ async function table(text, delimiter, yaml, work) {
1184
+ const rows = [];
1185
+ let row = [], field = "", quoted = false, closed = false;
1186
+ const cell = () => {
1187
+ if (utf8ByteLength3(field) > work.limits.maxScalarBytes) throw new MikeError("yq limit exceeded: maxScalarBytes");
1188
+ row.push(field);
1189
+ field = "";
1190
+ closed = false;
728
1191
  };
729
- return Object.freeze(plugin);
1192
+ for (let index = 0; index < text.length; index++) {
1193
+ {
1194
+ const t = work.tick();
1195
+ if (t) await t;
1196
+ }
1197
+ const char = text[index];
1198
+ if (quoted) {
1199
+ if (char === '"') {
1200
+ if (text[index + 1] === '"') {
1201
+ field += '"';
1202
+ index++;
1203
+ } else {
1204
+ quoted = false;
1205
+ closed = true;
1206
+ }
1207
+ } else field += char;
1208
+ } else if (char === '"' && field === "" && !closed) quoted = true;
1209
+ else if (char === delimiter) cell();
1210
+ else if (char === "\n" || char === "\r") {
1211
+ cell();
1212
+ rows.push(row);
1213
+ row = [];
1214
+ if (char === "\r" && text[index + 1] === "\n") index++;
1215
+ } else {
1216
+ if (closed || char === '"') throw new MikeError("invalid delimited input");
1217
+ field += char;
1218
+ }
1219
+ if (rows.length + row.length > work.limits.maxParserNodes) throw new MikeError("yq limit exceeded: maxParserNodes");
1220
+ }
1221
+ if (quoted) throw new MikeError("unterminated quoted field");
1222
+ if (field || row.length || closed) {
1223
+ cell();
1224
+ rows.push(row);
1225
+ }
1226
+ const headers = rows.shift() ?? [];
1227
+ const result = [];
1228
+ for (const cells of rows) {
1229
+ {
1230
+ const t = work.tick();
1231
+ if (t) await t;
1232
+ }
1233
+ if (cells.length !== headers.length) throw new MikeError("wrong number of fields");
1234
+ const item = /* @__PURE__ */ Object.create(null);
1235
+ for (let index = 0; index < cells.length; index++) {
1236
+ const parsed = yaml.parseDocument(cells[index], { schema: "core" });
1237
+ item[headers[index]] = !parsed.errors.length && yaml.isScalar(parsed.contents) && typeof parsed.contents.value !== "string" ? parsed.contents.value : cells[index];
1238
+ }
1239
+ result.push(item);
1240
+ }
1241
+ return result;
1242
+ }
1243
+ async function xmlValue(element, work, depth = 0) {
1244
+ {
1245
+ const t = work.tick();
1246
+ if (t) await t;
1247
+ }
1248
+ work.depth(depth);
1249
+ const result = /* @__PURE__ */ Object.create(null);
1250
+ for (const attribute of element.attributes) result[`+@${attribute.name}`] = attribute.value;
1251
+ for (const child of element.children) {
1252
+ const value2 = await xmlValue(child, work, depth + 1);
1253
+ if (Object.hasOwn(result, child.name)) {
1254
+ const previous = result[child.name];
1255
+ result[child.name] = Array.isArray(previous) ? [...previous, value2] : [previous, value2];
1256
+ } else result[child.name] = value2;
1257
+ }
1258
+ const text = element.text.trim();
1259
+ if (!Object.keys(result).length) return text;
1260
+ if (text) result["+content"] = text;
1261
+ return result;
1262
+ }
1263
+ async function decodeFormat(text, filename, fileIndex, format, yaml, work, accept) {
1264
+ if (format === "yaml" || format === "json") {
1265
+ await decodeDocuments(text, filename, fileIndex, format, yaml, work, accept);
1266
+ return;
1267
+ }
1268
+ if (utf8ByteLength3(text) > work.limits.maxDocumentBytes) throw new MikeError("yq limit exceeded: maxDocumentBytes");
1269
+ let value2;
1270
+ try {
1271
+ if (format === "csv" || format === "tsv") value2 = await table(text, format === "csv" ? "," : " ", yaml, work);
1272
+ else if (format === "base64") {
1273
+ const clean = text.split("\n").join("").split("\r").join("");
1274
+ let data;
1275
+ try {
1276
+ data = decodeBase64(clean);
1277
+ } catch {
1278
+ throw new MikeError("invalid base64 input");
1279
+ }
1280
+ if (encodeBase64(data) !== clean) throw new MikeError("invalid base64 input");
1281
+ value2 = new TextDecoder("utf-8", { fatal: true }).decode(data);
1282
+ } else if (format === "uri") value2 = decodeURIComponent(text.split("+").join(" "));
1283
+ else if (format === "xml") {
1284
+ const parser = parseXmlSteps(text, { maxDepth: work.limits.maxDepth, maxNodes: work.limits.maxParserNodes, maxTextLength: work.limits.maxScalarBytes });
1285
+ let step = parser.next();
1286
+ while (!step.done) {
1287
+ {
1288
+ const t = work.tick(step.value);
1289
+ if (t) await t;
1290
+ }
1291
+ step = parser.next();
1292
+ }
1293
+ value2 = { [step.value.name]: await xmlValue(step.value, work) };
1294
+ } else if (format === "toml") {
1295
+ const parsed = await parseTomlDocument(text, { charge: async (units) => {
1296
+ const t = work.tick(units);
1297
+ if (t) await t;
1298
+ }, assertOpen: () => work.assertOpen() }, new YqLedger(), utf8ByteLength3(text));
1299
+ const convert = (item) => {
1300
+ if (item instanceof Decimal) return Number(numberText(item));
1301
+ if (Array.isArray(item)) return item.map(convert);
1302
+ if (item && typeof item === "object") return Object.fromEntries(Object.entries(item).map(([key, child]) => [key, convert(child)]));
1303
+ return item;
1304
+ };
1305
+ value2 = convert(parsed);
1306
+ } else if (format === "props") value2 = await properties(text, work);
1307
+ else if (format === "ini") {
1308
+ value2 = /* @__PURE__ */ Object.create(null);
1309
+ let section = value2;
1310
+ for (const source of text.split("\n")) {
1311
+ {
1312
+ const t = work.tick(source.length + 1);
1313
+ if (t) await t;
1314
+ }
1315
+ const line = source.trim();
1316
+ if (!line || line.startsWith("#") || line.startsWith(";") || line.startsWith("!")) continue;
1317
+ if (line.startsWith("[") && line.endsWith("]")) {
1318
+ const name = line.slice(1, -1);
1319
+ section = /* @__PURE__ */ Object.create(null);
1320
+ value2[name] = section;
1321
+ continue;
1322
+ }
1323
+ let equal = line.indexOf("=");
1324
+ if (equal < 0) equal = line.indexOf(":");
1325
+ if (equal < 0) throw new MikeError(`invalid ${format} entry`);
1326
+ section[line.slice(0, equal).trim()] = line.slice(equal + 1).trim();
1327
+ }
1328
+ } else throw new MikeError(`format '${format}' does not support decoding`);
1329
+ } catch (error) {
1330
+ if (error instanceof MikeError) throw error;
1331
+ throw new MikeError(`bad ${format} input: ${error instanceof Error ? error.message : String(error)}`);
1332
+ }
1333
+ await decodeDocuments(JSON.stringify(value2), filename, fileIndex, "json", yaml, work, accept);
1334
+ }
1335
+ async function encodeFormat(candidate, format, yaml, work) {
1336
+ const encoded = await encodeNative(candidate, { format: "json", indent: 0, unwrap: false, compactSequence: false }, yaml, work);
1337
+ const value2 = JSON.parse(encoded);
1338
+ const chunks = [];
1339
+ let size = 0;
1340
+ const append = (text) => {
1341
+ const bytes = utf8ByteLength3(text);
1342
+ if (bytes > work.limits.maxOutputBytes - size) throw new MikeError("yq limit exceeded: maxOutputBytes");
1343
+ size += bytes;
1344
+ chunks.push(text);
1345
+ };
1346
+ const primitive = (item) => item === null ? "" : typeof item === "object" ? JSON.stringify(item) : String(item);
1347
+ if (format === "base64" || format === "uri") {
1348
+ if (typeof value2 !== "string") throw new MikeError(`${format} encoding requires a string`);
1349
+ append(format === "base64" ? encodeBase64(utf8Encoder2.encode(value2)) : encodeURIComponent(value2).split("%20").join("+").split("!").join("%21").split("'").join("%27").split("(").join("%28").split(")").join("%29").split("*").join("%2A"));
1350
+ } else if (format === "csv" || format === "tsv") {
1351
+ if (!Array.isArray(value2)) throw new MikeError("CSV/TSV encoding requires an array");
1352
+ const delimiter = format === "csv" ? "," : " ";
1353
+ const headers = mapping(value2[0] ?? null) ? Object.keys(value2[0]) : void 0;
1354
+ const row = (cells) => {
1355
+ append(cells.map((item) => {
1356
+ const text = primitive(item);
1357
+ return text.includes(delimiter) || text.includes('"') || text.includes("\n") || text.includes("\r") ? '"' + text.split('"').join('""') + '"' : text;
1358
+ }).join(delimiter) + "\n");
1359
+ };
1360
+ if (headers) row(headers);
1361
+ for (const item of value2) {
1362
+ {
1363
+ const t = work.tick();
1364
+ if (t) await t;
1365
+ }
1366
+ if (headers && mapping(item)) row(headers.map((key) => item[key] ?? null));
1367
+ else if (Array.isArray(item)) row(item);
1368
+ else throw new MikeError("CSV/TSV rows must be arrays or maps");
1369
+ }
1370
+ } else if (format === "lua") {
1371
+ const write = async (item, depth) => {
1372
+ {
1373
+ const t = work.tick();
1374
+ if (t) await t;
1375
+ }
1376
+ work.depth(depth);
1377
+ if (item === null) {
1378
+ append("nil");
1379
+ return;
1380
+ }
1381
+ if (typeof item !== "object") {
1382
+ append(JSON.stringify(item));
1383
+ return;
1384
+ }
1385
+ append("{\n");
1386
+ for (const [key, child] of Object.entries(item)) {
1387
+ append(" ".repeat(depth + 1));
1388
+ if (!Array.isArray(item)) append(`[${JSON.stringify(key)}] = `);
1389
+ await write(child, depth + 1);
1390
+ append(";\n");
1391
+ }
1392
+ append(" ".repeat(depth) + "}");
1393
+ };
1394
+ append("return ");
1395
+ await write(value2, 0);
1396
+ append(";\n");
1397
+ } else if (format === "xml") {
1398
+ const escape = (text) => text.split("&").join("&amp;").split("<").join("&lt;").split(">").join("&gt;").split('"').join("&quot;");
1399
+ const write = async (name, item, depth) => {
1400
+ {
1401
+ const t = work.tick();
1402
+ if (t) await t;
1403
+ }
1404
+ work.depth(depth);
1405
+ if (!name || Array.from(name).some((char) => ` <>/ \r
1406
+ ="'`.includes(char))) throw new MikeError("invalid XML element name");
1407
+ if (Array.isArray(item)) {
1408
+ for (const child of item) await write(name, child, depth);
1409
+ return;
1410
+ }
1411
+ append(`<${name}`);
1412
+ if (mapping(item)) {
1413
+ for (const [key, child] of Object.entries(item)) if (key.startsWith("+@")) append(` ${key.slice(2)}="${escape(primitive(child))}"`);
1414
+ }
1415
+ append(">");
1416
+ if (mapping(item)) {
1417
+ const children = Object.entries(item).filter(([key]) => !key.startsWith("+@") && key !== "+content");
1418
+ if (children.length) append("\n");
1419
+ for (const [key, child] of children) {
1420
+ append(" ".repeat((depth + 1) * 2));
1421
+ await write(key, child, depth + 1);
1422
+ }
1423
+ if (item["+content"] !== void 0) append(escape(primitive(item["+content"])));
1424
+ if (children.length) append(" ".repeat(depth * 2));
1425
+ } else append(escape(primitive(item)));
1426
+ append(`</${name}>
1427
+ `);
1428
+ };
1429
+ if (!mapping(value2)) throw new MikeError("XML encoding requires a map");
1430
+ for (const [key, item] of Object.entries(value2)) await write(key, item, 0);
1431
+ } else {
1432
+ if (!mapping(value2)) throw new MikeError(`${format} encoding requires a map`);
1433
+ const flattened = [];
1434
+ const flatten = async (item, path, depth) => {
1435
+ {
1436
+ const t = work.tick();
1437
+ if (t) await t;
1438
+ }
1439
+ work.depth(depth);
1440
+ if (item !== null && typeof item === "object") {
1441
+ for (const [key, child] of Object.entries(item)) await flatten(child, [...path, key], depth + 1);
1442
+ } else flattened.push([path.join(format === "shell" ? "_" : "."), item]);
1443
+ };
1444
+ if (format === "toml" || format === "ini") {
1445
+ const tomlKey = (key) => key && Array.from(key).every((char) => char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char >= "0" && char <= "9" || "_-".includes(char)) ? key : JSON.stringify(key);
1446
+ const tomlValue = async (item, depth) => {
1447
+ {
1448
+ const t = work.tick();
1449
+ if (t) await t;
1450
+ }
1451
+ work.depth(depth);
1452
+ if (item === null) throw new MikeError("TOML cannot encode null");
1453
+ if (Array.isArray(item)) {
1454
+ const items = [];
1455
+ for (const child of item) items.push(await tomlValue(child, depth + 1));
1456
+ return `[${items.join(", ")}]`;
1457
+ }
1458
+ if (mapping(item)) {
1459
+ const entries = [];
1460
+ for (const [key, child] of Object.entries(item)) entries.push(`${tomlKey(key)} = ${await tomlValue(child, depth + 1)}`);
1461
+ return `{ ${entries.join(", ")} }`;
1462
+ }
1463
+ return JSON.stringify(item);
1464
+ };
1465
+ const write = async (item, path, depth) => {
1466
+ {
1467
+ const t = work.tick();
1468
+ if (t) await t;
1469
+ }
1470
+ work.depth(depth);
1471
+ const leaves = Object.entries(item).filter(([, child]) => !mapping(child));
1472
+ const width = Math.max(0, ...leaves.map(([key]) => key.length));
1473
+ if (path.length) append(`[${path.map((key) => format === "toml" ? tomlKey(key) : key).join(".")}]
1474
+ `);
1475
+ for (const [key, child] of leaves) append(`${format === "toml" ? tomlKey(key) : key}${format === "ini" ? " ".repeat(width - key.length) : ""} = ${format === "toml" ? await tomlValue(child, depth + 1) : primitive(child)}
1476
+ `);
1477
+ for (const [key, child] of Object.entries(item)) if (mapping(child)) {
1478
+ append("\n");
1479
+ await write(child, [...path, key], depth + 1);
1480
+ }
1481
+ };
1482
+ await write(value2, [], 0);
1483
+ } else {
1484
+ await flatten(value2, [], 0);
1485
+ for (const [key, item] of flattened) {
1486
+ if (format === "shell") {
1487
+ if (!key || Array.from(key).some((char, index) => !(char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char === "_" || index > 0 && char >= "0" && char <= "9"))) throw new MikeError("invalid shell variable name");
1488
+ const text = primitive(item);
1489
+ const safe = text && Array.from(text).every((char) => char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char >= "0" && char <= "9" || "_./-".includes(char));
1490
+ append(`${key}=${safe ? text : "'" + text.split("'").join("'\\''") + "'"}
1491
+ `);
1492
+ } else append(`${key} = ${primitive(item)}
1493
+ `);
1494
+ }
1495
+ }
1496
+ }
1497
+ return chunks.join("");
1498
+ }
1499
+
1500
+ // packages/safe-bash-command-yq/src/mike.ts
1501
+ import { commandRuntimeIdentity, FsError } from "../safe-bash-contracts/index.js";
1502
+
1503
+ // packages/safe-bash-command-yq/src/arguments.ts
1504
+ init_buffer();
1505
+ import { getCommandArguments } from "../safe-bash-contracts/index.js";
1506
+ var mikeEvalHelp = `yq is a portable command-line data file processor (https://github.com/mikefarah/yq/)
1507
+ See https://mikefarah.gitbook.io/yq/ for detailed documentation and examples.
1508
+
1509
+ ## Evaluate Sequence ##
1510
+ This command iterates over each yaml document from each given file, applies the
1511
+ expression and prints the result in sequence.
1512
+
1513
+ Usage:
1514
+ yq eval [expression] [yaml_file1]... [flags]
1515
+
1516
+ Aliases:
1517
+ eval, e
1518
+
1519
+ Examples:
1520
+
1521
+ # Reads field under the given path for each file
1522
+ yq e '.a.b' f1.yml f2.yml
1523
+
1524
+ # Prints out the file
1525
+ yq e sample.yaml
1526
+
1527
+ # Pipe from STDIN
1528
+ ## use '-' as a filename to pipe from STDIN
1529
+ cat file2.yml | yq e '.a.b' file1.yml - file3.yml
1530
+
1531
+ # Creates a new yaml document
1532
+ ## Note that editing an empty file does not work.
1533
+ yq e -n '.a.b.c = "cat"'
1534
+
1535
+ # Update a file in place
1536
+ yq e '.a.b = "cool"' -i file.yaml
1537
+
1538
+
1539
+ Flags:
1540
+ -h, --help help for eval
1541
+
1542
+ Global Flags:
1543
+ -C, --colors force print with colors
1544
+ --csv-auto-parse parse CSV YAML/JSON values (default true)
1545
+ --csv-separator char CSV Separator character (default ,)
1546
+ --debug-node-info debug node info
1547
+ -e, --exit-status set exit status if there are no matches or null or false is returned
1548
+ --expression string forcibly set the expression argument. Useful when yq argument detection thinks your expression is a file.
1549
+ --from-file string Load expression from specified file.
1550
+ -f, --front-matter string (extract|process) first input as yaml front-matter. Extract will pull out the yaml content, process will run the expression against the yaml content, leaving the remaining data intact
1551
+ --header-preprocess Slurp any header comments and separators before processing expression. (default true)
1552
+ -I, --indent int sets indent level for output (default 2)
1553
+ --ini-preserve-quotes preserve surrounding quotes on INI values during round-trip
1554
+ -i, --inplace update the file in place of first file given.
1555
+ -p, --input-format string [auto|a|yaml|y|kyaml|ky|json|j|props|p|csv|c|tsv|t|xml|x|base64|uri|toml|hcl|h|lua|l|ini|i] parse format for input. (default "auto")
1556
+ --lua-globals output keys as top-level global variables
1557
+ --lua-prefix string prefix (default "return ")
1558
+ --lua-suffix string suffix (default ";\\n")
1559
+ --lua-unquoted output unquoted string keys (e.g. {foo="bar"})
1560
+ -M, --no-colors force print with no colors
1561
+ -N, --no-doc Don't print document separators (---)
1562
+ -0, --nul-output Use NUL char to separate values. If unwrap scalar is also set, fail if unwrapped scalar contains NUL char.
1563
+ -n, --null-input Don't read input, simply evaluate the expression given. Useful for creating docs from scratch.
1564
+ -o, --output-format string [auto|a|yaml|y|kyaml|ky|json|j|props|p|csv|c|tsv|t|xml|x|base64|uri|toml|hcl|h|shell|s|lua|l|ini|i] output format type. (default "auto")
1565
+ -P, --prettyPrint pretty print, shorthand for '... style = ""'
1566
+ --properties-array-brackets use [x] in array paths (e.g. for SpringBoot)
1567
+ --properties-separator string separator to use between keys and values (default " = ")
1568
+ --security-disable-env-ops Disable env related operations.
1569
+ --security-disable-file-ops Disable file related operations (e.g. load)
1570
+ --security-enable-system-operator Enable system operator to allow execution of external commands.
1571
+ --shell-key-separator string separator for shell variable key paths (default "_")
1572
+ -s, --split-exp string print each result (or doc) into a file named (exp). [exp] argument must return a string. You can use $index in the expression as the result counter. The necessary directories will be created.
1573
+ --split-exp-file string Use a file to specify the split-exp expression.
1574
+ --string-interpolation Toggles strings interpolation of \\(exp) (default true)
1575
+ --tsv-auto-parse parse TSV YAML/JSON values (default true)
1576
+ -r, --unwrapScalar unwrap scalar, print the value with no quotes, colours or comments. Defaults to true for yaml (default true)
1577
+ -v, --verbose verbose mode
1578
+ --xml-attribute-prefix string prefix for xml attributes (default "+@")
1579
+ --xml-content-name string name for xml content (if no attribute name is present). (default "+content")
1580
+ --xml-directive-name string name for xml directives (e.g. <!DOCTYPE thing cat>) (default "+directive")
1581
+ --xml-keep-namespace enables keeping namespace after parsing attributes (default true)
1582
+ --xml-proc-inst-prefix string prefix for xml processing instructions (e.g. <?xml version="1"?>) (default "+p_")
1583
+ --xml-raw-token enables using RawToken method instead Token. Commonly disables namespace translations. See https://pkg.go.dev/encoding/xml#Decoder.RawToken for details. (default true)
1584
+ --xml-skip-directives skip over directives (e.g. <!DOCTYPE thing cat>)
1585
+ --xml-skip-proc-inst skip over process instructions (e.g. <?xml version="1"?>)
1586
+ --xml-strict-mode enables strict parsing of XML. See https://pkg.go.dev/encoding/xml for more details.
1587
+ -c, --yaml-compact-seq-indent Use compact sequence indentation where '- ' is considered part of the indentation.
1588
+ --yaml-fix-merge-anchor-to-spec Fix merge anchor to match YAML spec. Will default to true in late 2025
1589
+ `;
1590
+ var mikeAllHelp = `yq is a portable command-line data file processor (https://github.com/mikefarah/yq/)
1591
+ See https://mikefarah.gitbook.io/yq/ for detailed documentation and examples.
1592
+
1593
+ ## Evaluate All ##
1594
+ This command loads _all_ yaml documents of _all_ yaml files and runs expression once
1595
+ Useful when you need to run an expression across several yaml documents or files (like merge).
1596
+ Note that it consumes more memory than eval.
1597
+
1598
+ Usage:
1599
+ yq eval-all [expression] [yaml_file1]... [flags]
1600
+
1601
+ Aliases:
1602
+ eval-all, ea
1603
+
1604
+ Examples:
1605
+
1606
+ # Merge f2.yml into f1.yml (in place)
1607
+ yq eval-all --inplace 'select(fileIndex == 0) * select(fileIndex == 1)' f1.yml f2.yml
1608
+ ## the same command and expression using shortened names:
1609
+ yq ea -i 'select(fi == 0) * select(fi == 1)' f1.yml f2.yml
1610
+
1611
+
1612
+ # Merge all given files
1613
+ yq ea '. as $item ireduce ({}; . * $item )' file1.yml file2.yml ...
1614
+
1615
+ # Pipe from STDIN
1616
+ ## use '-' as a filename to pipe from STDIN
1617
+ cat file2.yml | yq ea '.a.b' file1.yml - file3.yml
1618
+
1619
+
1620
+ Flags:
1621
+ -h, --help help for eval-all
1622
+
1623
+ Global Flags:
1624
+ -C, --colors force print with colors
1625
+ --csv-auto-parse parse CSV YAML/JSON values (default true)
1626
+ --csv-separator char CSV Separator character (default ,)
1627
+ --debug-node-info debug node info
1628
+ -e, --exit-status set exit status if there are no matches or null or false is returned
1629
+ --expression string forcibly set the expression argument. Useful when yq argument detection thinks your expression is a file.
1630
+ --from-file string Load expression from specified file.
1631
+ -f, --front-matter string (extract|process) first input as yaml front-matter. Extract will pull out the yaml content, process will run the expression against the yaml content, leaving the remaining data intact
1632
+ --header-preprocess Slurp any header comments and separators before processing expression. (default true)
1633
+ -I, --indent int sets indent level for output (default 2)
1634
+ --ini-preserve-quotes preserve surrounding quotes on INI values during round-trip
1635
+ -i, --inplace update the file in place of first file given.
1636
+ -p, --input-format string [auto|a|yaml|y|kyaml|ky|json|j|props|p|csv|c|tsv|t|xml|x|base64|uri|toml|hcl|h|lua|l|ini|i] parse format for input. (default "auto")
1637
+ --lua-globals output keys as top-level global variables
1638
+ --lua-prefix string prefix (default "return ")
1639
+ --lua-suffix string suffix (default ";\\n")
1640
+ --lua-unquoted output unquoted string keys (e.g. {foo="bar"})
1641
+ -M, --no-colors force print with no colors
1642
+ -N, --no-doc Don't print document separators (---)
1643
+ -0, --nul-output Use NUL char to separate values. If unwrap scalar is also set, fail if unwrapped scalar contains NUL char.
1644
+ -n, --null-input Don't read input, simply evaluate the expression given. Useful for creating docs from scratch.
1645
+ -o, --output-format string [auto|a|yaml|y|kyaml|ky|json|j|props|p|csv|c|tsv|t|xml|x|base64|uri|toml|hcl|h|shell|s|lua|l|ini|i] output format type. (default "auto")
1646
+ -P, --prettyPrint pretty print, shorthand for '... style = ""'
1647
+ --properties-array-brackets use [x] in array paths (e.g. for SpringBoot)
1648
+ --properties-separator string separator to use between keys and values (default " = ")
1649
+ --security-disable-env-ops Disable env related operations.
1650
+ --security-disable-file-ops Disable file related operations (e.g. load)
1651
+ --security-enable-system-operator Enable system operator to allow execution of external commands.
1652
+ --shell-key-separator string separator for shell variable key paths (default "_")
1653
+ -s, --split-exp string print each result (or doc) into a file named (exp). [exp] argument must return a string. You can use $index in the expression as the result counter. The necessary directories will be created.
1654
+ --split-exp-file string Use a file to specify the split-exp expression.
1655
+ --string-interpolation Toggles strings interpolation of \\(exp) (default true)
1656
+ --tsv-auto-parse parse TSV YAML/JSON values (default true)
1657
+ -r, --unwrapScalar unwrap scalar, print the value with no quotes, colours or comments. Defaults to true for yaml (default true)
1658
+ -v, --verbose verbose mode
1659
+ --xml-attribute-prefix string prefix for xml attributes (default "+@")
1660
+ --xml-content-name string name for xml content (if no attribute name is present). (default "+content")
1661
+ --xml-directive-name string name for xml directives (e.g. <!DOCTYPE thing cat>) (default "+directive")
1662
+ --xml-keep-namespace enables keeping namespace after parsing attributes (default true)
1663
+ --xml-proc-inst-prefix string prefix for xml processing instructions (e.g. <?xml version="1"?>) (default "+p_")
1664
+ --xml-raw-token enables using RawToken method instead Token. Commonly disables namespace translations. See https://pkg.go.dev/encoding/xml#Decoder.RawToken for details. (default true)
1665
+ --xml-skip-directives skip over directives (e.g. <!DOCTYPE thing cat>)
1666
+ --xml-skip-proc-inst skip over process instructions (e.g. <?xml version="1"?>)
1667
+ --xml-strict-mode enables strict parsing of XML. See https://pkg.go.dev/encoding/xml for more details.
1668
+ -c, --yaml-compact-seq-indent Use compact sequence indentation where '- ' is considered part of the indentation.
1669
+ --yaml-fix-merge-anchor-to-spec Fix merge anchor to match YAML spec. Will default to true in late 2025
1670
+ `;
1671
+ var mikeHelp = `yq is a portable command-line data file processor (https://github.com/mikefarah/yq/)
1672
+ See https://mikefarah.gitbook.io/yq/ for detailed documentation and examples.
1673
+
1674
+ Usage:
1675
+ yq [flags]
1676
+ yq [command]
1677
+
1678
+ Examples:
1679
+
1680
+ # yq tries to auto-detect the file format based off the extension, and defaults to YAML if it's unknown (or piping through STDIN)
1681
+ # Use the '-p/--input-format' flag to specify a format type.
1682
+ cat file.xml | yq -p xml
1683
+
1684
+ # read the "stuff" node from "myfile.yml"
1685
+ yq '.stuff' < myfile.yml
1686
+
1687
+ # update myfile.yml in place
1688
+ yq -i '.stuff = "foo"' myfile.yml
1689
+
1690
+ # print contents of sample.json as idiomatic YAML
1691
+ yq -P -oy sample.json
1692
+
1693
+
1694
+ Available Commands:
1695
+ completion Generate the autocompletion script for the specified shell
1696
+ eval (default) Apply the expression to each document in each yaml file in sequence
1697
+ eval-all Loads _all_ yaml documents of _all_ yaml files and runs expression once
1698
+ help Help about any command
1699
+
1700
+ Flags:
1701
+ -C, --colors force print with colors
1702
+ --csv-auto-parse parse CSV YAML/JSON values (default true)
1703
+ --csv-separator char CSV Separator character (default ,)
1704
+ --debug-node-info debug node info
1705
+ -e, --exit-status set exit status if there are no matches or null or false is returned
1706
+ --expression string forcibly set the expression argument. Useful when yq argument detection thinks your expression is a file.
1707
+ --from-file string Load expression from specified file.
1708
+ -f, --front-matter string (extract|process) first input as yaml front-matter. Extract will pull out the yaml content, process will run the expression against the yaml content, leaving the remaining data intact
1709
+ --header-preprocess Slurp any header comments and separators before processing expression. (default true)
1710
+ -h, --help help for yq
1711
+ -I, --indent int sets indent level for output (default 2)
1712
+ --ini-preserve-quotes preserve surrounding quotes on INI values during round-trip
1713
+ -i, --inplace update the file in place of first file given.
1714
+ -p, --input-format string [auto|a|yaml|y|kyaml|ky|json|j|props|p|csv|c|tsv|t|xml|x|base64|uri|toml|hcl|h|lua|l|ini|i] parse format for input. (default "auto")
1715
+ --lua-globals output keys as top-level global variables
1716
+ --lua-prefix string prefix (default "return ")
1717
+ --lua-suffix string suffix (default ";\\n")
1718
+ --lua-unquoted output unquoted string keys (e.g. {foo="bar"})
1719
+ -M, --no-colors force print with no colors
1720
+ -N, --no-doc Don't print document separators (---)
1721
+ -0, --nul-output Use NUL char to separate values. If unwrap scalar is also set, fail if unwrapped scalar contains NUL char.
1722
+ -n, --null-input Don't read input, simply evaluate the expression given. Useful for creating docs from scratch.
1723
+ -o, --output-format string [auto|a|yaml|y|kyaml|ky|json|j|props|p|csv|c|tsv|t|xml|x|base64|uri|toml|hcl|h|shell|s|lua|l|ini|i] output format type. (default "auto")
1724
+ -P, --prettyPrint pretty print, shorthand for '... style = ""'
1725
+ --properties-array-brackets use [x] in array paths (e.g. for SpringBoot)
1726
+ --properties-separator string separator to use between keys and values (default " = ")
1727
+ --security-disable-env-ops Disable env related operations.
1728
+ --security-disable-file-ops Disable file related operations (e.g. load)
1729
+ --security-enable-system-operator Enable system operator to allow execution of external commands.
1730
+ --shell-key-separator string separator for shell variable key paths (default "_")
1731
+ -s, --split-exp string print each result (or doc) into a file named (exp). [exp] argument must return a string. You can use $index in the expression as the result counter. The necessary directories will be created.
1732
+ --split-exp-file string Use a file to specify the split-exp expression.
1733
+ --string-interpolation Toggles strings interpolation of \\(exp) (default true)
1734
+ --tsv-auto-parse parse TSV YAML/JSON values (default true)
1735
+ -r, --unwrapScalar unwrap scalar, print the value with no quotes, colours or comments. Defaults to true for yaml (default true)
1736
+ -v, --verbose verbose mode
1737
+ -V, --version Print version information and quit
1738
+ --xml-attribute-prefix string prefix for xml attributes (default "+@")
1739
+ --xml-content-name string name for xml content (if no attribute name is present). (default "+content")
1740
+ --xml-directive-name string name for xml directives (e.g. <!DOCTYPE thing cat>) (default "+directive")
1741
+ --xml-keep-namespace enables keeping namespace after parsing attributes (default true)
1742
+ --xml-proc-inst-prefix string prefix for xml processing instructions (e.g. <?xml version="1"?>) (default "+p_")
1743
+ --xml-raw-token enables using RawToken method instead Token. Commonly disables namespace translations. See https://pkg.go.dev/encoding/xml#Decoder.RawToken for details. (default true)
1744
+ --xml-skip-directives skip over directives (e.g. <!DOCTYPE thing cat>)
1745
+ --xml-skip-proc-inst skip over process instructions (e.g. <?xml version="1"?>)
1746
+ --xml-strict-mode enables strict parsing of XML. See https://pkg.go.dev/encoding/xml for more details.
1747
+ -c, --yaml-compact-seq-indent Use compact sequence indentation where '- ' is considered part of the indentation.
1748
+ --yaml-fix-merge-anchor-to-spec Fix merge anchor to match YAML spec. Will default to true in late 2025
1749
+
1750
+ Use "yq [command] --help" for more information about a command.
1751
+ `;
1752
+ var mikeUsage = mikeHelp.slice(mikeHelp.indexOf("Usage:")) + "\n";
1753
+ var booleans = {
1754
+ v: "verbose",
1755
+ verbose: "verbose",
1756
+ "debug-node-info": "debugNodeInfo",
1757
+ "header-preprocess": "headerPreprocess",
1758
+ n: "nullInput",
1759
+ "null-input": "nullInput",
1760
+ i: "inplace",
1761
+ inplace: "inplace",
1762
+ e: "exitStatus",
1763
+ "exit-status": "exitStatus",
1764
+ r: "unwrap",
1765
+ unwrapScalar: "unwrap",
1766
+ h: "help",
1767
+ help: "help",
1768
+ V: "version",
1769
+ version: "version",
1770
+ N: "noDoc",
1771
+ "no-doc": "noDoc",
1772
+ c: "compactSequence",
1773
+ "yaml-compact-seq-indent": "compactSequence",
1774
+ "yaml-fix-merge-anchor-to-spec": "mergeSpec",
1775
+ "0": "nulOutput",
1776
+ "nul-output": "nulOutput",
1777
+ P: "prettyPrint",
1778
+ prettyPrint: "prettyPrint",
1779
+ "security-disable-env-ops": "disableEnvOps",
1780
+ "security-disable-file-ops": "disableFileOps"
1781
+ };
1782
+ var values = {
1783
+ "from-file": "fromFile",
1784
+ f: "frontMatter",
1785
+ "front-matter": "frontMatter",
1786
+ s: "splitExpression",
1787
+ "split-exp": "splitExpression",
1788
+ "split-exp-file": "splitFile",
1789
+ p: "input",
1790
+ "input-format": "input",
1791
+ o: "output",
1792
+ "output-format": "output",
1793
+ I: "indent",
1794
+ indent: "indent",
1795
+ expression: "expression"
1796
+ };
1797
+ function mikeCommandMode(args) {
1798
+ for (let index = 0; index < args.length; index++) {
1799
+ const argument = args[index];
1800
+ if (argument === "--") return index + 1 < args.length ? "eval" : "root";
1801
+ if (!argument.startsWith("-") || argument === "-") return argument === "ea" || argument === "eval-all" ? "eval-all" : "eval";
1802
+ const long = argument.startsWith("--");
1803
+ let remaining = argument.slice(long ? 2 : 1);
1804
+ while (remaining) {
1805
+ const equal = remaining.indexOf("=");
1806
+ const name = long ? equal < 0 ? remaining : remaining.slice(0, equal) : remaining[0];
1807
+ if (Object.hasOwn(values, name)) {
1808
+ if (long ? equal < 0 : remaining.length === 1) index++;
1809
+ break;
1810
+ }
1811
+ if (!Object.hasOwn(booleans, name) && name !== "M" && name !== "no-colors") return "root";
1812
+ if (long || remaining[1] === "=") break;
1813
+ remaining = remaining.slice(1);
1814
+ }
1815
+ }
1816
+ return "root";
1817
+ }
1818
+ function parseIndent(value2) {
1819
+ const negative = value2.startsWith("-");
1820
+ let digits = value2.startsWith("+") || negative ? value2.slice(1) : value2;
1821
+ let base = 10;
1822
+ let prefixed = false;
1823
+ if (digits.length > 1 && digits[0] === "0") {
1824
+ prefixed = true;
1825
+ const prefix = digits[1].toLowerCase();
1826
+ base = prefix === "x" ? 16 : prefix === "b" ? 2 : 8;
1827
+ digits = digits.slice(prefix === "x" || prefix === "b" || prefix === "o" ? 2 : 1);
1828
+ }
1829
+ if (prefixed && digits.startsWith("_")) digits = digits.slice(1);
1830
+ let invalid = digits.length === 0;
1831
+ let previousDigit = false;
1832
+ let integer = 0n;
1833
+ const maximum = negative ? 9223372036854775808n : 9223372036854775807n;
1834
+ for (const character of digits) {
1835
+ if (character === "_") {
1836
+ if (!previousDigit) invalid = true;
1837
+ previousDigit = false;
1838
+ continue;
1839
+ }
1840
+ const digit = "0123456789abcdef".indexOf(character.toLowerCase());
1841
+ if (digit < 0 || digit >= base) invalid = true;
1842
+ else if (integer <= maximum) integer = integer * BigInt(base) + BigInt(digit);
1843
+ previousDigit = true;
1844
+ }
1845
+ if (!previousDigit) invalid = true;
1846
+ if (invalid || integer > maximum) throw new MikeError(`invalid argument ${JSON.stringify(value2)} for "-I, --indent" flag: strconv.ParseInt: parsing ${JSON.stringify(value2)}: ${invalid ? "invalid syntax" : "value out of range"}`, true);
1847
+ const result = Number(negative ? -integer : integer);
1848
+ if (!Number.isSafeInteger(result)) throw new MikeError("yq limit exceeded: indent");
1849
+ return result;
1850
+ }
1851
+ function parseMikeArguments(context) {
1852
+ const carrier = getCommandArguments(context);
1853
+ for (let index = 0; index < carrier.args.length; index++) {
1854
+ try {
1855
+ new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(carrier.bytes(index));
1856
+ } catch {
1857
+ throw new MikeError("yq filename/expression bytes must be valid UTF-8");
1858
+ }
1859
+ }
1860
+ const result = {
1861
+ verbose: false,
1862
+ debugNodeInfo: false,
1863
+ all: false,
1864
+ help: false,
1865
+ version: false,
1866
+ nullInput: false,
1867
+ inplace: false,
1868
+ exitStatus: false,
1869
+ input: "auto",
1870
+ output: "auto",
1871
+ indent: 2,
1872
+ unwrap: void 0,
1873
+ noDoc: false,
1874
+ compactSequence: false,
1875
+ mergeSpec: false,
1876
+ disableEnvOps: false,
1877
+ disableFileOps: false,
1878
+ nulOutput: false,
1879
+ prettyPrint: false,
1880
+ expression: void 0,
1881
+ fromFile: void 0,
1882
+ frontMatter: void 0,
1883
+ splitExpression: void 0,
1884
+ splitFile: void 0,
1885
+ headerPreprocess: true,
1886
+ operands: []
1887
+ };
1888
+ let ended = false;
1889
+ for (let index = 0; index < context.args.length; index++) {
1890
+ const argument = context.args[index];
1891
+ if (!ended && argument === "--") {
1892
+ ended = true;
1893
+ continue;
1894
+ }
1895
+ if (!ended && ["eval", "e", "eval-all", "ea"].includes(argument) && result.operands.length === 0) {
1896
+ result.all = argument === "eval-all" || argument === "ea";
1897
+ continue;
1898
+ }
1899
+ if (ended || !argument.startsWith("-") || argument === "-") {
1900
+ result.operands.push(argument);
1901
+ continue;
1902
+ }
1903
+ const long = argument.startsWith("--");
1904
+ let remaining = argument.slice(long ? 2 : 1);
1905
+ while (remaining) {
1906
+ const equal = remaining.indexOf("=");
1907
+ const name = long ? equal < 0 ? remaining : remaining.slice(0, equal) : remaining[0];
1908
+ let attached = long ? equal < 0 ? void 0 : remaining.slice(equal + 1) : remaining.slice(1) || void 0;
1909
+ if (!long && attached?.startsWith("=")) attached = attached.slice(1);
1910
+ const boolean = Object.hasOwn(booleans, name) ? booleans[name] : void 0;
1911
+ if (boolean || name === "M" || name === "no-colors") {
1912
+ const explicit = long ? equal >= 0 : remaining[1] === "=";
1913
+ let enabled = true;
1914
+ if (explicit) {
1915
+ if (["true", "1", "t", "TRUE", "True", "T"].includes(attached)) enabled = true;
1916
+ else if (["false", "0", "f", "FALSE", "False", "F"].includes(attached)) enabled = false;
1917
+ else {
1918
+ const fullName = name === "r" || name === "unwrapScalar" ? "-r, --unwrapScalar" : name === "n" || name === "null-input" ? "-n, --null-input" : `--${name}`;
1919
+ throw new MikeError(`invalid argument ${JSON.stringify(attached)} for "${fullName}" flag: strconv.ParseBool: parsing ${JSON.stringify(attached)}: invalid syntax`, true);
1920
+ }
1921
+ }
1922
+ if (boolean) Object.assign(result, { [boolean]: enabled });
1923
+ remaining = long || explicit ? "" : remaining.slice(1);
1924
+ continue;
1925
+ }
1926
+ const field = Object.hasOwn(values, name) ? values[name] : void 0;
1927
+ if (!field) throw new MikeError(long ? `unknown flag: --${name}` : `unknown shorthand flag: '${name}' in ${argument}`, true);
1928
+ const value2 = attached ?? context.args[++index];
1929
+ if (value2 === void 0) throw new MikeError(long ? `flag needs an argument: --${name}` : `flag needs an argument: '${name}' in ${argument}`, true);
1930
+ if (field === "indent") {
1931
+ result.indent = parseIndent(value2);
1932
+ } else result[field] = value2;
1933
+ remaining = "";
1934
+ }
1935
+ }
1936
+ return result;
1937
+ }
1938
+ function mikeFormat(value2) {
1939
+ if (value2 === "auto" || value2 === "a" || value2 === "") return "auto";
1940
+ if (value2 === "yaml" || value2 === "y") return "yaml";
1941
+ if (value2 === "json" || value2 === "j") return "json";
1942
+ const formats = { xml: "xml", x: "xml", csv: "csv", c: "csv", tsv: "tsv", t: "tsv", props: "props", p: "props", toml: "toml", ini: "ini", i: "ini", lua: "lua", l: "lua", base64: "base64", uri: "uri", shell: "shell", s: "shell" };
1943
+ if (Object.hasOwn(formats, value2)) return formats[value2];
1944
+ if (["hcl", "h", "kyaml", "ky"].includes(value2)) throw new MikeError(`format '${value2}' is not supported by this bounded yq profile`);
1945
+ throw new MikeError(`unknown format '${value2}' please use [yaml|y|kyaml|ky|json|j|props|p|csv|c|tsv|t|xml|x|base64|uri|toml|hcl|h|shell|s|lua|l|ini|i]`);
1946
+ }
1947
+
1948
+ // packages/safe-bash-command-yq/src/expression.ts
1949
+ init_buffer();
1950
+ import { utf8ByteLength as utf8ByteLength4 } from "../safe-bash-query-engine/bytes.js";
1951
+ var priorities = { "|": 1, ",": 2, "=": 3, "=c": 3, "|=": 3, "+=": 3, "-=": 3, "*=": 3, "/=": 3, "//": 4, or: 5, and: 6, "==": 7, "!=": 7, ">": 7, "<": 7, ">=": 7, "<=": 7, "+": 8, "-": 8, "*": 9, "/": 9, "%": 9 };
1952
+ var functions = /* @__PURE__ */ new Set(["path", "select", "map", "has", "length", "keys", "tag", "type", "kind", "style", "head_comment", "anchor", "alias", "documentIndex", "document_index", "di", "fileIndex", "file_index", "fi", "filename", "env", "strenv", "del", "explode", "not", "sort", "sort_by", "reverse", "to_entries", "from_entries", "with_entries", "pick", "upcase", "downcase", "test", "split"]);
1953
+ function compileExpression(source, security = {}) {
1954
+ if (utf8ByteLength4(source) > (security.maxExpressionBytes ?? Infinity)) throw new MikeError("yq limit exceeded: expression bytes");
1955
+ const tokens = [];
1956
+ let offset = 0;
1957
+ while (offset < source.length) {
1958
+ const character = source[offset];
1959
+ if (/\s/u.test(character)) {
1960
+ offset++;
1961
+ continue;
1962
+ }
1963
+ const start = offset;
1964
+ if (source.startsWith("...", offset)) {
1965
+ tokens.push({ text: "...", offset, kind: "symbol" });
1966
+ offset += 3;
1967
+ continue;
1968
+ }
1969
+ if (character === "#") {
1970
+ while (offset < source.length && source[offset] !== "\n") offset++;
1971
+ continue;
1972
+ }
1973
+ if (character === '"') {
1974
+ offset++;
1975
+ let escaped = false;
1976
+ while (offset < source.length) {
1977
+ const next = source[offset++];
1978
+ if (!escaped && next === '"') break;
1979
+ if (!escaped && next === "\\") escaped = true;
1980
+ else escaped = false;
1981
+ }
1982
+ const text = source.slice(start, offset);
1983
+ try {
1984
+ JSON.parse(text);
1985
+ } catch {
1986
+ throw new MikeError("bad expression, please check expression syntax");
1987
+ }
1988
+ tokens.push({ text, offset: start, kind: "string" });
1989
+ continue;
1990
+ }
1991
+ const number = /^(?:[0-9]+(?:\.[0-9]+)?)(?:[eE][+-]?[0-9]+)?/u.exec(source.slice(offset));
1992
+ if (number) {
1993
+ tokens.push({ text: number[0], offset, kind: "number" });
1994
+ offset += number[0].length;
1995
+ continue;
1996
+ }
1997
+ const name = /^[A-Za-z_][A-Za-z_0-9-]*/u.exec(source.slice(offset));
1998
+ if (name) {
1999
+ tokens.push({ text: name[0], offset, kind: "name" });
2000
+ offset += name[0].length;
2001
+ continue;
2002
+ }
2003
+ const symbol = /^(?:\|=|=c|\+=|-=|\*=|\/=|==|!=|>=|<=|\/\/|\.\.|[.[\]{}(),:|+*/%<>=-])/u.exec(source.slice(offset));
2004
+ if (!symbol) throw new MikeError(`1:${offset + 1}: lexer: invalid input text ${JSON.stringify(source.slice(offset))}`);
2005
+ tokens.push({ text: symbol[0], offset, kind: "symbol" });
2006
+ offset += symbol[0].length;
2007
+ }
2008
+ tokens.push({ text: "", offset, kind: "end" });
2009
+ let position = 0;
2010
+ let nesting = 0;
2011
+ const peek = () => tokens[position];
2012
+ const take = () => tokens[position++];
2013
+ const expect = (text) => {
2014
+ if (take().text !== text) throw new MikeError("bad expression, please check expression syntax");
2015
+ };
2016
+ const literal = (value2) => ({ kind: "literal", value: value2 });
2017
+ const parse = (minimum = 0) => {
2018
+ if (++nesting > (security.maxExpressionDepth ?? Infinity)) throw new MikeError("yq limit exceeded: expression depth");
2019
+ const token = take();
2020
+ let result2;
2021
+ if (token.text === ".") {
2022
+ result2 = { kind: "identity" };
2023
+ if (peek().offset === token.offset + 1 && (peek().kind === "name" || peek().kind === "string")) {
2024
+ const key = take();
2025
+ result2 = { kind: "field", base: result2, key: literal(key.kind === "string" ? JSON.parse(key.text) : key.text) };
2026
+ }
2027
+ } else if (token.text === ".." || token.text === "...") result2 = { kind: "recursive", includeKeys: token.text === "..." };
2028
+ else if (token.text === "(") {
2029
+ result2 = { kind: "group", body: parse() };
2030
+ expect(")");
2031
+ } else if (token.text === "[") {
2032
+ result2 = peek().text === "]" ? { kind: "array" } : { kind: "array", body: parse() };
2033
+ expect("]");
2034
+ } else if (token.text === "{") {
2035
+ const fields = [];
2036
+ while (peek().text !== "}") {
2037
+ const key = take();
2038
+ if (key.kind === "name") throw new MikeError(`1:${key.offset + 1}: lexer: invalid input text ${JSON.stringify(source.slice(key.offset))}`);
2039
+ if (key.kind !== "string") throw new MikeError("bad expression, please check expression syntax");
2040
+ expect(":");
2041
+ fields.push({ key: literal(key.kind === "string" ? JSON.parse(key.text) : key.text), value: parse(3) });
2042
+ if (peek().text !== ",") break;
2043
+ take();
2044
+ }
2045
+ expect("}");
2046
+ result2 = { kind: "object", fields };
2047
+ } else if (token.text === "-") {
2048
+ const right = parse(10);
2049
+ result2 = right.kind === "literal" && right.source !== void 0 && (typeof right.value === "number" || typeof right.value === "bigint") ? { kind: "literal", value: -right.value, source: `-${right.source}` } : { kind: "binary", operator: "*", left: literal(-1n), right };
2050
+ } else if (token.kind === "number") result2 = { kind: "literal", value: /[.eE]/u.test(token.text) ? Number(token.text) : BigInt(token.text), source: token.text };
2051
+ else if (token.kind === "string") result2 = literal(JSON.parse(token.text));
2052
+ else if (["true", "false", "null"].includes(token.text)) result2 = literal(JSON.parse(token.text));
2053
+ else if (security.disableEnvOps && ["env", "strenv", "envsubst"].includes(token.text)) throw new MikeError("env operations have been disabled");
2054
+ else if (security.disableFileOps && ["load", "load_str", "load_xml", "load_props", "load_base64"].includes(token.text)) throw new MikeError("file operations have been disabled");
2055
+ else if (functions.has(token.text)) {
2056
+ const args = [];
2057
+ if (peek().text === "(") {
2058
+ take();
2059
+ if (token.text === "env" || token.text === "strenv") args.push(literal(take().text));
2060
+ else if (peek().text !== ")") args.push(parse());
2061
+ expect(")");
2062
+ }
2063
+ const needsArgument = ["select", "map", "has", "env", "strenv", "del", "explode", "sort_by", "with_entries", "pick", "test", "split"].includes(token.text);
2064
+ if (needsArgument && args.length === 0) throw new MikeError(`'${token.text}' expects 1 arg but received none`);
2065
+ if (!needsArgument && args.length) throw new MikeError("bad expression, please check expression syntax");
2066
+ result2 = { kind: "call", name: token.text, args };
2067
+ } else if (token.kind === "end" && tokens.some((item) => item.text === "[")) throw new MikeError("bad expression, could not find matching `]`");
2068
+ else throw new MikeError(`1:${token.offset + 1}: lexer: invalid input text ${JSON.stringify(source.slice(token.offset))}`);
2069
+ while (true) {
2070
+ if (peek().text === ".") {
2071
+ take();
2072
+ const key = take();
2073
+ if (key.kind !== "name" && key.kind !== "string") throw new MikeError("bad expression, please check expression syntax");
2074
+ result2 = { kind: "field", base: result2, key: literal(key.kind === "string" ? JSON.parse(key.text) : key.text) };
2075
+ continue;
2076
+ }
2077
+ if (peek().text === "[") {
2078
+ take();
2079
+ if (peek().text === "]") result2 = { kind: "pipe", operator: "|", left: result2, right: { kind: "iterate" } };
2080
+ else {
2081
+ const start = peek().text === ":" ? literal(0n) : parse();
2082
+ if (peek().text === ":") {
2083
+ take();
2084
+ const end = peek().text === "]" ? { kind: "call", name: "length", args: [] } : parse();
2085
+ result2 = { kind: "slice", base: result2, start, end };
2086
+ } else result2 = { kind: "field", base: result2, key: start };
2087
+ }
2088
+ expect("]");
2089
+ continue;
2090
+ }
2091
+ if ((peek().text === "tag" || peek().text === "style") && minimum <= 3) {
2092
+ result2 = { kind: "pipe", operator: "|", left: result2, right: { kind: "call", name: take().text, args: [] } };
2093
+ continue;
2094
+ }
2095
+ const operator = peek().text;
2096
+ const priority = priorities[operator];
2097
+ if (priority === void 0 || priority < minimum) break;
2098
+ take();
2099
+ if (operator === "//" && peek().text === "=") throw new MikeError("'//' expects 2 args but there is 1");
2100
+ result2 = { kind: operator === "|" ? "pipe" : "binary", operator, left: result2, right: parse(priority + (priority === 3 ? 0 : 1)) };
2101
+ }
2102
+ nesting--;
2103
+ return result2;
2104
+ };
2105
+ if (!source.trim()) return { kind: "identity" };
2106
+ const result = parse();
2107
+ if (peek().kind !== "end") throw new MikeError("bad expression, please check expression syntax");
2108
+ return result;
2109
+ }
2110
+
2111
+ // packages/safe-bash-command-yq/src/evaluate.ts
2112
+ init_buffer();
2113
+ import { utf8ByteLength as utf8ByteLength5, utf8Encoder as utf8Encoder3, compareBytes } from "../safe-bash-query-engine/bytes.js";
2114
+ import { EreLedger } from "../safe-bash-regex-engine/ere/limits.js";
2115
+ import { EreSyntaxError, EreUnsupportedError, EreProfileLimitError } from "../safe-bash-regex-engine/ere/errors.js";
2116
+ import { compileEre } from "../safe-bash-regex-engine/ere/syntax.js";
2117
+ import { prepareUtf8EreSubject } from "../safe-bash-regex-engine/ere/matcher.js";
2118
+ function value(node, yaml) {
2119
+ if (!yaml.isScalar(node)) throw new MikeError("expected a scalar value");
2120
+ const result = node.value;
2121
+ if (result == null) return null;
2122
+ if (typeof result === "string" && node.tag && !node.tag.startsWith("tag:yaml.org,2002:")) {
2123
+ if (/^[+-]?[0-9]+$/u.test(result)) return BigInt(result);
2124
+ if (/^[+-]?0[xX][0-9a-fA-F]+$/u.test(result)) {
2125
+ if (result[0] === "+" || result[0] === "-") throw new MikeError(`strconv.ParseInt: parsing ${JSON.stringify(result)}: invalid syntax`);
2126
+ return BigInt(result);
2127
+ }
2128
+ if (/^[+-]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/u.test(result)) return Number(result);
2129
+ }
2130
+ if (typeof result === "string" && node.tag === "tag:yaml.org,2002:int") {
2131
+ try {
2132
+ return BigInt(result);
2133
+ } catch {
2134
+ throw new MikeError(`invalid integer value ${JSON.stringify(result)}`);
2135
+ }
2136
+ }
2137
+ if (typeof result === "string" && node.tag === "tag:yaml.org,2002:float") return Number(result);
2138
+ if (typeof result === "string" && node.tag === "tag:yaml.org,2002:bool") return result.toLowerCase() === "true";
2139
+ if (["string", "number", "bigint", "boolean"].includes(typeof result)) return result;
2140
+ throw new MikeError("unsupported scalar value");
2141
+ }
2142
+ function scalarText(node, yaml) {
2143
+ if (!yaml.isScalar(node)) throw new MikeError("expected a scalar value");
2144
+ return node.source ?? String(node.value);
2145
+ }
2146
+ var Evaluator = class {
2147
+ constructor(yaml, work, mergeSpec = false) {
2148
+ this.yaml = yaml;
2149
+ this.work = work;
2150
+ this.mergeSpec = mergeSpec;
2151
+ }
2152
+ yaml;
2153
+ work;
2154
+ mergeSpec;
2155
+ #warnedMerge = false;
2156
+ #regex;
2157
+ async match(first, pattern) {
2158
+ {
2159
+ const t = this.work.tick(first.length + pattern.length);
2160
+ if (t) await t;
2161
+ }
2162
+ const name = utf8Encoder3.encode(first);
2163
+ const glob = utf8Encoder3.encode(pattern);
2164
+ let nameIndex = 0;
2165
+ let patternIndex = 0;
2166
+ let restartPattern = 0;
2167
+ let restartName = 0;
2168
+ while (patternIndex < glob.length || nameIndex < name.length) {
2169
+ {
2170
+ const t = this.work.tick();
2171
+ if (t) await t;
2172
+ }
2173
+ if (patternIndex < glob.length) {
2174
+ const character = glob[patternIndex];
2175
+ if (character === 42) {
2176
+ restartPattern = patternIndex;
2177
+ restartName = nameIndex + 1;
2178
+ patternIndex++;
2179
+ continue;
2180
+ }
2181
+ if (nameIndex < name.length && (character === 63 || character === name[nameIndex])) {
2182
+ patternIndex++;
2183
+ nameIndex++;
2184
+ continue;
2185
+ }
2186
+ }
2187
+ if (restartName > 0 && restartName <= name.length) {
2188
+ patternIndex = restartPattern;
2189
+ nameIndex = restartName;
2190
+ continue;
2191
+ }
2192
+ return false;
2193
+ }
2194
+ return true;
2195
+ }
2196
+ child(node, parent, collection, slot) {
2197
+ this.work.node();
2198
+ return {
2199
+ node,
2200
+ document: parent.document,
2201
+ isDerived: collection === void 0 || parent.isDerived === true,
2202
+ ...collection === void 0 ? {} : { parent: collection, slot },
2203
+ ...collection === void 0 ? parent.ancestry ? { ancestry: parent.ancestry } : {} : {
2204
+ ancestry: { parent, key: this.yaml.isMap(collection) ? collection.items[slot].key : slot }
2205
+ }
2206
+ };
2207
+ }
2208
+ async toEntries(input) {
2209
+ const yaml = this.yaml;
2210
+ const base = dereference(input, yaml, this.work);
2211
+ if (!yaml.isCollection(base.node)) throw new MikeError(`to_entries only supports maps and arrays, got ${nodeTag(base.node, yaml)}`);
2212
+ this.work.node();
2213
+ const result = new yaml.YAMLSeq();
2214
+ if (base.node.commentBefore !== void 0) result.commentBefore = base.node.commentBefore;
2215
+ if (base.node.comment !== void 0) result.comment = base.node.comment;
2216
+ for (let index = 0; index < base.node.items.length; index++) {
2217
+ {
2218
+ const t = this.work.tick();
2219
+ if (t) await t;
2220
+ }
2221
+ const item = base.node.items[index];
2222
+ const key = yaml.isMap(base.node) ? item.key : scalar(yaml, this.work, BigInt(index));
2223
+ const member = yaml.isMap(base.node) ? item.value : item;
2224
+ this.work.node();
2225
+ const entry = new yaml.YAMLMap();
2226
+ const copiedKey = await cloneNode(key, yaml, this.work);
2227
+ if (index === 0 && yaml.isMap(base.node) && copiedKey.commentBefore !== void 0) {
2228
+ result.commentBefore = copiedKey.commentBefore;
2229
+ delete copiedKey.commentBefore;
2230
+ }
2231
+ entry.items.push(new yaml.Pair(scalar(yaml, this.work, "key"), copiedKey));
2232
+ entry.items.push(new yaml.Pair(scalar(yaml, this.work, "value"), await cloneNode(member, yaml, this.work)));
2233
+ result.items.push(entry);
2234
+ }
2235
+ return result;
2236
+ }
2237
+ async fromEntries(input) {
2238
+ const yaml = this.yaml;
2239
+ const base = dereference(input, yaml, this.work);
2240
+ if (!yaml.isSeq(base.node)) throw new MikeError("from_entries only supports arrays");
2241
+ this.work.node();
2242
+ const result = new yaml.YAMLMap();
2243
+ if (base.node.flow !== void 0) result.flow = base.node.flow;
2244
+ if (base.node.commentBefore !== void 0) result.commentBefore = base.node.commentBefore;
2245
+ if (base.node.comment !== void 0) result.comment = base.node.comment;
2246
+ for (const item of base.node.items) {
2247
+ {
2248
+ const t = this.work.tick();
2249
+ if (t) await t;
2250
+ }
2251
+ if (!yaml.isNode(item)) throw new MikeError("from_entries expects key/value entries");
2252
+ const entry = dereference(this.child(item, base), yaml, this.work);
2253
+ const fields = await this.entries(entry);
2254
+ const key = fields.get("key");
2255
+ const member = fields.get("value");
2256
+ if (!key || !member) throw new MikeError("from_entries expects key/value entries");
2257
+ result.items.push(new yaml.Pair(await cloneNode(key.node, yaml, this.work), await cloneNode(member.node, yaml, this.work)));
2258
+ }
2259
+ return result;
2260
+ }
2261
+ async sort(input, expression, depth) {
2262
+ const yaml = this.yaml;
2263
+ const base = dereference(input, yaml, this.work);
2264
+ if (!yaml.isCollection(base.node)) throw new MikeError(`cannot sort ${nodeTag(base.node, yaml)}, can only sort arrays or maps`);
2265
+ const result = await cloneNode(base.node, yaml, this.work);
2266
+ const members = [];
2267
+ for (const item of result.items) {
2268
+ {
2269
+ const t = this.work.tick();
2270
+ if (t) await t;
2271
+ }
2272
+ const candidate = this.child(yaml.isMap(result) ? item.value : item, base);
2273
+ const keys = await this.run(expression, [candidate], false, depth + 1);
2274
+ this.work.node(keys.length);
2275
+ members.push({ item, keys: keys.map((key) => dereference(key, yaml, this.work).node) });
2276
+ }
2277
+ const compare = async (first, second) => {
2278
+ for (let index = 0; index < Math.min(first.keys.length, second.keys.length); index++) {
2279
+ {
2280
+ const t = this.work.tick();
2281
+ if (t) await t;
2282
+ }
2283
+ const leftNode = first.keys[index];
2284
+ const rightNode = second.keys[index];
2285
+ const left = yaml.isScalar(leftNode) ? value(leftNode, yaml) : "";
2286
+ const right = yaml.isScalar(rightNode) ? value(rightNode, yaml) : "";
2287
+ if (left === null && right === null) continue;
2288
+ if (left === null) return -1;
2289
+ if (right === null) return 1;
2290
+ if (typeof left === "boolean" && typeof right !== "boolean") return -1;
2291
+ if (typeof left !== "boolean" && typeof right === "boolean") return 1;
2292
+ if (typeof left === "boolean" && typeof right === "boolean" || (typeof left === "number" || typeof left === "bigint") && (typeof right === "number" || typeof right === "bigint")) {
2293
+ if (left < right) return -1;
2294
+ if (left > right) return 1;
2295
+ } else {
2296
+ const leftText = yaml.isScalar(leftNode) ? scalarText(leftNode, yaml) : "";
2297
+ const rightText = yaml.isScalar(rightNode) ? scalarText(rightNode, yaml) : "";
2298
+ {
2299
+ const t = this.work.tick(leftText.length + rightText.length);
2300
+ if (t) await t;
2301
+ }
2302
+ const compared = compareBytes(utf8Encoder3.encode(leftText), utf8Encoder3.encode(rightText));
2303
+ if (compared) return compared;
2304
+ }
2305
+ }
2306
+ return first.keys.length - second.keys.length;
2307
+ };
2308
+ for (let width = 1; width < members.length; width *= 2) {
2309
+ for (let start = 0; start < members.length; start += width * 2) {
2310
+ const end = Math.min(start + width * 2, members.length);
2311
+ const middle = Math.min(start + width, end);
2312
+ this.work.node(end - start);
2313
+ const merged = [];
2314
+ let left = start;
2315
+ let right = middle;
2316
+ while (left < middle || right < end) {
2317
+ {
2318
+ const t = this.work.tick();
2319
+ if (t) await t;
2320
+ }
2321
+ merged.push(right >= end || left < middle && await compare(members[left], members[right]) <= 0 ? members[left++] : members[right++]);
2322
+ }
2323
+ for (let index = 0; index < merged.length; index++) {
2324
+ {
2325
+ const t = this.work.tick();
2326
+ if (t) await t;
2327
+ }
2328
+ members[start + index] = merged[index];
2329
+ }
2330
+ }
2331
+ }
2332
+ if (yaml.isMap(result)) result.items = members.map((member) => member.item);
2333
+ else result.items = members.map((member) => member.item);
2334
+ return result;
2335
+ }
2336
+ async sameKey(left, right, depth) {
2337
+ this.work.depth(depth);
2338
+ {
2339
+ const t = this.work.tick();
2340
+ if (t) await t;
2341
+ }
2342
+ if (nodeTag(left, this.yaml) !== nodeTag(right, this.yaml)) return false;
2343
+ if (this.yaml.isScalar(left) && this.yaml.isScalar(right)) return left.value === right.value;
2344
+ if (this.yaml.isSeq(left) && this.yaml.isSeq(right)) {
2345
+ if (left.items.length !== right.items.length) return false;
2346
+ for (let index = 0; index < left.items.length; index++) {
2347
+ if (!await this.sameKey(left.items[index], right.items[index], depth + 1)) return false;
2348
+ }
2349
+ return true;
2350
+ }
2351
+ if (this.yaml.isMap(left) && this.yaml.isMap(right)) {
2352
+ if (left.items.length !== right.items.length) return false;
2353
+ for (let index = 0; index < left.items.length; index++) {
2354
+ const first = left.items[index], second = right.items[index];
2355
+ if (!await this.sameKey(first.key, second.key, depth + 1) || !await this.sameKey(first.value, second.value, depth + 1)) return false;
2356
+ }
2357
+ return true;
2358
+ }
2359
+ return false;
2360
+ }
2361
+ async warnMerge() {
2362
+ if (!this.#warnedMerge) {
2363
+ this.#warnedMerge = true;
2364
+ const now = /* @__PURE__ */ new Date();
2365
+ const offset = now.getTimezoneOffset();
2366
+ const local = new Date(now.getTime() - offset * 6e4).toISOString().slice(0, -1);
2367
+ const zone = offset === 0 ? "Z" : `${offset < 0 ? "+" : "-"}${String(Math.floor(Math.abs(offset) / 60)).padStart(2, "0")}:${String(Math.abs(offset) % 60).padStart(2, "0")}`;
2368
+ await this.work.write(utf8Encoder3.encode(`time=${local}${zone} level=WARN msg="--yaml-fix-merge-anchor-to-spec is false; causing merge anchors to override the existing values which isn't to the yaml spec. This flag will default to true in late 2025. See https://mikefarah.gitbook.io/yq/operators/traverse-read for more details."
2369
+ `), true);
2370
+ }
2371
+ }
2372
+ async explode(input, depth = 0, active = /* @__PURE__ */ new Set()) {
2373
+ this.work.depth(depth);
2374
+ {
2375
+ const t = this.work.tick();
2376
+ if (t) await t;
2377
+ }
2378
+ const base = dereference(input, this.yaml, this.work);
2379
+ if (active.has(base.node)) throw new MikeError("cyclic YAML alias");
2380
+ active.add(base.node);
2381
+ try {
2382
+ const node = await cloneNode(base.node, this.yaml, this.work);
2383
+ if ("anchor" in node) delete node.anchor;
2384
+ if (this.yaml.isAlias(input.node)) {
2385
+ if (input.node.comment !== void 0) node.comment = input.node.comment;
2386
+ if (input.node.commentBefore !== void 0) node.commentBefore = input.node.commentBefore;
2387
+ if (input.node.spaceBefore !== void 0) node.spaceBefore = input.node.spaceBefore;
2388
+ const head = this.work.headComments.get(input.node);
2389
+ if (head !== void 0) this.work.headComments.set(node, head);
2390
+ }
2391
+ if (this.yaml.isMap(base.node) && this.yaml.isMap(node)) {
2392
+ for (let index = 0; index < base.node.items.length; index++) {
2393
+ const pair = base.node.items[index];
2394
+ if (this.yaml.isNode(pair.key)) node.items[index].key = await this.explode({ ...base, node: pair.key }, depth + 1, active);
2395
+ if (this.yaml.isNode(pair.value)) node.items[index].value = await this.explode({ ...base, node: pair.value }, depth + 1, active);
2396
+ }
2397
+ const isMerge = (pair) => this.yaml.isScalar(pair.key) && (pair.key.tag === "tag:yaml.org,2002:merge" || pair.key.value === "<<" && pair.key.type === "PLAIN");
2398
+ if (node.items.some(isMerge)) {
2399
+ const pairs = [];
2400
+ const add = async (pair, override) => {
2401
+ for (let index = 0; index < pairs.length; index++) {
2402
+ if (await this.sameKey(pairs[index].key, pair.key, depth + 1)) {
2403
+ if (override) pairs[index] = pair;
2404
+ return;
2405
+ }
2406
+ }
2407
+ pairs.push(pair);
2408
+ };
2409
+ const merge = async (pair) => {
2410
+ const sources = this.yaml.isSeq(pair.value) ? pair.value.items : [pair.value];
2411
+ for (const source of sources) {
2412
+ {
2413
+ const t = this.work.tick();
2414
+ if (t) await t;
2415
+ }
2416
+ if (!this.yaml.isMap(source)) throw new MikeError("merge requires a map or sequence of maps");
2417
+ for (const incoming of source.items) await add(incoming, !this.mergeSpec);
2418
+ }
2419
+ };
2420
+ if (this.mergeSpec) {
2421
+ for (const pair of node.items) if (isMerge(pair)) await merge(pair);
2422
+ }
2423
+ for (const pair of node.items) {
2424
+ {
2425
+ const t = this.work.tick();
2426
+ if (t) await t;
2427
+ }
2428
+ if (!isMerge(pair)) await add(pair, true);
2429
+ else if (!this.mergeSpec) {
2430
+ await this.warnMerge();
2431
+ await merge(pair);
2432
+ }
2433
+ }
2434
+ node.items = pairs;
2435
+ }
2436
+ } else if (this.yaml.isSeq(base.node) && this.yaml.isSeq(node)) {
2437
+ for (let index = 0; index < base.node.items.length; index++) {
2438
+ const child = base.node.items[index];
2439
+ if (this.yaml.isNode(child)) node.items[index] = await this.explode({ ...base, node: child }, depth + 1, active);
2440
+ }
2441
+ }
2442
+ return node;
2443
+ } finally {
2444
+ active.delete(base.node);
2445
+ }
2446
+ }
2447
+ async entries(input, depth = 0) {
2448
+ this.work.depth(depth);
2449
+ {
2450
+ const t = this.work.tick();
2451
+ if (t) await t;
2452
+ }
2453
+ const base = dereference(input, this.yaml, this.work);
2454
+ const entries = /* @__PURE__ */ new Map();
2455
+ if (!this.yaml.isMap(base.node)) return entries;
2456
+ const node = base.node;
2457
+ const isMerge = (key) => this.yaml.isScalar(key) && (key.tag === "tag:yaml.org,2002:merge" || key.value === "<<" && key.type === "PLAIN");
2458
+ const merge = async (incoming) => {
2459
+ const source = dereference({ ...base, node: incoming }, this.yaml, this.work);
2460
+ const values2 = this.yaml.isSeq(source.node) ? source.node.items : [source.node];
2461
+ for (let index = 0; index < values2.length; index++) {
2462
+ const selected = values2[this.mergeSpec ? values2.length - 1 - index : index];
2463
+ if (!this.yaml.isNode(selected)) continue;
2464
+ for (const [key, child] of await this.entries({ ...source, node: selected }, depth + 1)) {
2465
+ {
2466
+ const t = this.work.tick();
2467
+ if (t) await t;
2468
+ }
2469
+ entries.set(key, child);
2470
+ }
2471
+ }
2472
+ };
2473
+ if (this.mergeSpec) for (let index = node.items.length - 1; index >= 0; index--) {
2474
+ const pair = node.items[index];
2475
+ {
2476
+ const t = this.work.tick();
2477
+ if (t) await t;
2478
+ }
2479
+ if (isMerge(pair.key) && this.yaml.isNode(pair.value)) await merge(pair.value);
2480
+ }
2481
+ for (const [slot, pair] of node.items.entries()) {
2482
+ {
2483
+ const t = this.work.tick();
2484
+ if (t) await t;
2485
+ }
2486
+ if (isMerge(pair.key)) {
2487
+ if (!this.mergeSpec) {
2488
+ await this.warnMerge();
2489
+ if (this.yaml.isNode(pair.value)) await merge(pair.value);
2490
+ }
2491
+ } else if (this.yaml.isScalar(pair.key) && this.yaml.isNode(pair.value)) entries.set(String(pair.key.value), this.child(pair.value, base, node, slot));
2492
+ }
2493
+ return entries;
2494
+ }
2495
+ async field(input, key, create, omitMissing = false) {
2496
+ let base = dereference(input, this.yaml, this.work);
2497
+ if (this.yaml.isScalar(base.node) && base.node.value == null && create) {
2498
+ const collection = typeof key === "string" ? new this.yaml.YAMLMap() : new this.yaml.YAMLSeq();
2499
+ await replace(base, collection, this.yaml, this.work);
2500
+ }
2501
+ base = dereference(base, this.yaml, this.work);
2502
+ const node = base.node;
2503
+ if (this.yaml.isMap(node)) {
2504
+ if (key === "<<") for (let slot = node.items.length - 1; slot >= 0; slot--) {
2505
+ {
2506
+ const t = this.work.tick();
2507
+ if (t) await t;
2508
+ }
2509
+ const pair = node.items[slot];
2510
+ if (this.yaml.isScalar(pair.key) && String(pair.key.value) === String(key)) return [this.child(pair.value, base, node, slot)];
2511
+ }
2512
+ const existing = (await this.entries(base)).get(String(key));
2513
+ if (existing) return [existing];
2514
+ if (create) {
2515
+ this.work.node(2);
2516
+ if (!node.items.length) node.flow = false;
2517
+ node.items.push(new this.yaml.Pair(new this.yaml.Scalar(key), new this.yaml.Scalar(null)));
2518
+ return [this.child(node.items.at(-1).value, base, node, node.items.length - 1)];
2519
+ }
2520
+ return omitMissing ? [] : [this.child(scalar(this.yaml, this.work, null), base)];
2521
+ }
2522
+ if (this.yaml.isSeq(node)) {
2523
+ const text = typeof key === "number" && Number.isInteger(key) ? `${key}.0` : String(key);
2524
+ const digits = text[0] === "+" || text[0] === "-" ? text.slice(1) : text;
2525
+ const integer = (typeof key === "bigint" || typeof key === "string") && digits.length > 0 && [...digits].every((character) => character >= "0" && character <= "9");
2526
+ if (!integer) throw new MikeError(`cannot index array with '${text}' (strconv.ParseInt: parsing ${JSON.stringify(text)}: invalid syntax)`);
2527
+ let index = Number(key);
2528
+ if (!Number.isSafeInteger(index)) throw new MikeError(`cannot index array with '${String(key)}' (strconv.ParseInt: parsing ${JSON.stringify(String(key))}: invalid syntax)`);
2529
+ if (index < 0) index += node.items.length;
2530
+ if (index < 0) throw new MikeError(`index [${String(key)}] out of range, array size is ${node.items.length}`);
2531
+ if (index >= node.items.length) {
2532
+ if (!create) return [this.child(scalar(this.yaml, this.work, null), base)];
2533
+ if (index >= this.work.limits.maxNodes) throw new MikeError("yq limit exceeded: maxNodes");
2534
+ if (!node.items.length) node.flow = false;
2535
+ while (node.items.length <= index) {
2536
+ node.items.push(scalar(this.yaml, this.work, null));
2537
+ {
2538
+ const t = this.work.tick();
2539
+ if (t) await t;
2540
+ }
2541
+ }
2542
+ }
2543
+ return [index < node.items.length ? this.child(node.items[index], base, node, index) : this.child(scalar(this.yaml, this.work, null), base)];
2544
+ }
2545
+ if (this.yaml.isScalar(node) && node.value == null && (typeof key === "number" || typeof key === "bigint") && key < 0) {
2546
+ throw new MikeError(`index [${String(key)}] out of range, array size is 0`);
2547
+ }
2548
+ return !omitMissing && this.yaml.isScalar(node) && node.value == null ? [this.child(scalar(this.yaml, this.work, null), base)] : [];
2549
+ }
2550
+ async binary(operator, left, right) {
2551
+ {
2552
+ const t = this.work.tick();
2553
+ if (t) await t;
2554
+ }
2555
+ const yaml = this.yaml;
2556
+ if (operator === "+" && nodeTag(left, yaml) === "!!null") return cloneNode(right, yaml, this.work);
2557
+ if ((operator === "*" || operator === "+") && yaml.isMap(left) && yaml.isMap(right)) {
2558
+ const output = await cloneNode(left, yaml, this.work);
2559
+ for (const pair of right.items) {
2560
+ const key = yaml.isScalar(pair.key) ? String(pair.key.value) : "";
2561
+ const existing = output.items.find((item) => yaml.isScalar(item.key) && String(item.key.value) === key);
2562
+ if (existing) existing.value = operator === "*" && yaml.isMap(existing.value) && yaml.isMap(pair.value) ? await this.binary("*", existing.value, pair.value) : await cloneNode(pair.value, yaml, this.work);
2563
+ else output.items.push(new yaml.Pair(await cloneNode(pair.key, yaml, this.work), await cloneNode(pair.value, yaml, this.work)));
2564
+ }
2565
+ return output;
2566
+ }
2567
+ if (operator === "+" && yaml.isSeq(left)) {
2568
+ const result = await cloneNode(left, yaml, this.work);
2569
+ if (!result.items.length) result.flow = false;
2570
+ const members = yaml.isSeq(right) ? right.items : nodeTag(right, yaml) === "!!null" ? [] : [right];
2571
+ for (const node of members) result.items.push(await cloneNode(node, yaml, this.work));
2572
+ return result;
2573
+ }
2574
+ if (operator === "==" || operator === "!=") {
2575
+ let equal = false;
2576
+ if (nodeTag(left, yaml) === "!!null") equal = nodeTag(right, yaml) === "!!null";
2577
+ else if (yaml.isScalar(left) && yaml.isScalar(right)) {
2578
+ equal = await this.match(scalarText(left, yaml), scalarText(right, yaml));
2579
+ }
2580
+ return scalar(yaml, this.work, operator === "==" ? equal : !equal);
2581
+ }
2582
+ const first = value(left, yaml);
2583
+ const second = value(right, yaml);
2584
+ if (operator === "+" && (typeof first === "string" || typeof second === "string")) {
2585
+ const text = scalarText(left, yaml) + (typeof first === "string" && second === null ? "" : scalarText(right, yaml));
2586
+ const result = scalar(yaml, this.work, text);
2587
+ if (yaml.isScalar(result) && yaml.isScalar(left) && left.type !== void 0) result.type = left.type;
2588
+ return result;
2589
+ }
2590
+ if ([">", "<", ">=", "<="].includes(operator)) {
2591
+ if (first === null || second === null) return scalar(yaml, this.work, false);
2592
+ return scalar(yaml, this.work, operator === ">" ? first > second : operator === "<" ? first < second : operator === ">=" ? first >= second : first <= second);
2593
+ }
2594
+ if (typeof first !== "number" && typeof first !== "bigint" || typeof second !== "number" && typeof second !== "bigint") throw new MikeError(`cannot ${operator} ${nodeTag(left, yaml)} with ${nodeTag(right, yaml)}`);
2595
+ if (typeof first === "bigint" && typeof second === "bigint" && operator !== "/") {
2596
+ if (first !== BigInt.asIntN(64, first) || second !== BigInt.asIntN(64, second)) throw new MikeError("integer arithmetic operand is outside int64 range");
2597
+ if (operator === "+") {
2598
+ const sum = BigInt.asIntN(64, first + second);
2599
+ const result = await cloneNode(left, yaml, this.work);
2600
+ if (yaml.isScalar(result)) {
2601
+ result.value = sum;
2602
+ result.source = sum.toString();
2603
+ const spelling = scalarText(left, yaml);
2604
+ if (spelling.startsWith("0x") || spelling.startsWith("0X")) {
2605
+ result.format = "HEX";
2606
+ result.source = `0x${sum.toString(16).toUpperCase()}`;
2607
+ }
2608
+ }
2609
+ return result;
2610
+ }
2611
+ if (operator === "-") return scalar(yaml, this.work, BigInt.asIntN(64, first - second));
2612
+ if (operator === "*") return scalar(yaml, this.work, BigInt.asIntN(64, first * second));
2613
+ if (operator === "%" && second !== 0n) return scalar(yaml, this.work, first % second);
2614
+ }
2615
+ const firstNumber = Number(first);
2616
+ const secondNumber = Number(second);
2617
+ return scalar(yaml, this.work, operator === "+" ? firstNumber + secondNumber : operator === "-" ? firstNumber - secondNumber : operator === "*" ? firstNumber * secondNumber : operator === "/" ? firstNumber / secondNumber : firstNumber % secondNumber, nodeTag(left, yaml) === "!!float" || nodeTag(right, yaml) === "!!float");
2618
+ }
2619
+ async run(expression, inputs, create = false, depth = 0, omitMissing = false) {
2620
+ this.work.depth(depth);
2621
+ {
2622
+ const t = this.work.tick();
2623
+ if (t) await t;
2624
+ }
2625
+ const next = (body, values2 = inputs, writable = create, readOnly = omitMissing) => this.run(body, values2, writable, depth + 1, readOnly);
2626
+ const yaml = this.yaml;
2627
+ if (expression.kind === "identity") return inputs;
2628
+ if (expression.kind === "group") return next(expression.body);
2629
+ if (expression.kind === "literal") return inputs.map((input) => {
2630
+ const node = scalar(yaml, this.work, expression.value, typeof expression.value === "number");
2631
+ if (yaml.isScalar(node) && expression.source !== void 0) node.source = expression.source;
2632
+ return this.child(node, input);
2633
+ });
2634
+ if (expression.kind === "field") {
2635
+ const output2 = [];
2636
+ for (const base of await next(expression.base)) for (const key of await next(expression.key, [base], false)) output2.push(...await this.field(base, value(key.node, yaml), create, omitMissing));
2637
+ return output2;
2638
+ }
2639
+ if (expression.kind === "slice") {
2640
+ const output2 = [];
2641
+ for (const input of await next(expression.base)) {
2642
+ const base = dereference(input, yaml, this.work);
2643
+ const index = async (bound) => {
2644
+ const matches = await next(bound, [base], false);
2645
+ if (matches.length !== 1) throw new MikeError(`expected to find 1 number, got ${matches.length} instead`);
2646
+ const text = String(value(matches[0].node, yaml));
2647
+ if (!/^[+-]?[0-9]+$/u.test(text)) throw new MikeError(`strconv.ParseInt: parsing ${JSON.stringify(text)}: invalid syntax`);
2648
+ const result = BigInt(text);
2649
+ if (result !== BigInt.asIntN(64, result)) throw new MikeError(`strconv.ParseInt: parsing ${JSON.stringify(text)}: value out of range`);
2650
+ return result;
2651
+ };
2652
+ const start = await index(expression.start);
2653
+ const end = await index(expression.end);
2654
+ const clamp = (offset, length) => {
2655
+ const relative = offset < 0n ? offset + BigInt(length) : offset;
2656
+ return relative < 0n ? 0 : relative > BigInt(length) ? length : Number(relative);
2657
+ };
2658
+ if (yaml.isScalar(base.node) && typeof base.node.value === "string") {
2659
+ let length = 0;
2660
+ for (const character of base.node.value) {
2661
+ {
2662
+ const t = this.work.tick(character.length);
2663
+ if (t) await t;
2664
+ }
2665
+ length++;
2666
+ }
2667
+ const first = clamp(start, length);
2668
+ const last = clamp(end, length);
2669
+ const selected = [];
2670
+ let position = 0;
2671
+ for (const character of base.node.value) {
2672
+ {
2673
+ const t = this.work.tick(character.length);
2674
+ if (t) await t;
2675
+ }
2676
+ if (position >= first && position < last) selected.push(character);
2677
+ position++;
2678
+ }
2679
+ const node = await cloneNode(base.node, yaml, this.work);
2680
+ if (yaml.isScalar(node)) {
2681
+ node.value = selected.join("");
2682
+ node.source = node.value;
2683
+ }
2684
+ output2.push(this.child(node, base));
2685
+ } else {
2686
+ const members = [];
2687
+ if (yaml.isSeq(base.node)) for (const member of base.node.items) {
2688
+ {
2689
+ const t = this.work.tick();
2690
+ if (t) await t;
2691
+ }
2692
+ members.push(member);
2693
+ }
2694
+ else if (yaml.isMap(base.node)) for (const pair of base.node.items) {
2695
+ {
2696
+ const t = this.work.tick();
2697
+ if (t) await t;
2698
+ }
2699
+ members.push(pair.key, pair.value);
2700
+ }
2701
+ this.work.node();
2702
+ const node = new yaml.YAMLSeq();
2703
+ if (base.node.tag || !yaml.isSeq(base.node)) node.tag = base.node.tag ?? `tag:yaml.org,2002:${nodeTag(base.node, yaml).slice(2)}`;
2704
+ for (let position = clamp(start, members.length); position < clamp(end, members.length); position++) node.items.push(await cloneNode(members[position], yaml, this.work));
2705
+ output2.push(this.child(node, base));
2706
+ }
2707
+ }
2708
+ return output2;
2709
+ }
2710
+ if (expression.kind === "iterate" || expression.kind === "recursive") {
2711
+ const output2 = [];
2712
+ for (const input of inputs) {
2713
+ if (expression.kind === "recursive") {
2714
+ output2.push(input);
2715
+ if (yaml.isAlias(input.node)) continue;
2716
+ }
2717
+ const base = dereference(input, yaml, this.work);
2718
+ const children = [];
2719
+ if (yaml.isMap(base.node)) {
2720
+ if (expression.kind === "recursive") base.node.items.forEach((pair, slot) => {
2721
+ if (expression.includeKeys) children.push(this.child(pair.key, base));
2722
+ children.push(this.child(pair.value, base, base.node, slot));
2723
+ });
2724
+ else children.push(...(await this.entries(base)).values());
2725
+ } else if (yaml.isSeq(base.node)) base.node.items.forEach((node, slot) => children.push(this.child(node, base, base.node, slot)));
2726
+ if (expression.kind === "recursive") for (const child of children) output2.push(...await next(expression, [child]));
2727
+ else output2.push(...children);
2728
+ }
2729
+ this.work.node(output2.length);
2730
+ return output2;
2731
+ }
2732
+ if (expression.kind === "pipe") return next(expression.right, await next(expression.left));
2733
+ if (expression.kind === "array") {
2734
+ if (!inputs.length) return [];
2735
+ this.work.node();
2736
+ const node = new yaml.YAMLSeq();
2737
+ if (expression.body) for (const candidate of await next(expression.body, inputs, false)) node.items.push(await cloneNode(candidate.node, yaml, this.work));
2738
+ return [this.child(node, inputs[0])];
2739
+ }
2740
+ if (expression.kind === "object") {
2741
+ const output2 = [];
2742
+ for (const input of inputs) {
2743
+ this.work.node();
2744
+ const node = new yaml.YAMLMap();
2745
+ for (const field of expression.fields) {
2746
+ const key = (await next(field.key, [input], false))[0];
2747
+ const candidate = (await next(field.value, [input], false))[0];
2748
+ if (key && candidate) node.items.push(new yaml.Pair(await cloneNode(key.node, yaml, this.work), await cloneNode(candidate.node, yaml, this.work)));
2749
+ }
2750
+ if (node.items.length || !expression.fields.length) output2.push(this.child(node, input));
2751
+ }
2752
+ return output2;
2753
+ }
2754
+ if (expression.kind === "binary") {
2755
+ const operator = expression.operator;
2756
+ if (operator === ",") {
2757
+ const left2 = await next(expression.left);
2758
+ const right2 = await next(expression.right);
2759
+ this.work.node(left2.length + right2.length);
2760
+ return [...left2, ...right2];
2761
+ }
2762
+ if (["=", "=c", "|=", "+=", "-=", "*=", "/="].includes(operator)) {
2763
+ const attribute = expression.left.kind === "pipe" && expression.left.right.kind === "call" && ["tag", "style"].includes(expression.left.right.name) ? expression.left.right.name : void 0;
2764
+ const lhs = attribute && expression.left.kind === "pipe" ? expression.left.left : expression.left;
2765
+ const targets = await next(lhs, inputs, true);
2766
+ const updates = operator === "|=" ? void 0 : await next(expression.right, inputs, false, true);
2767
+ for (const target of targets) {
2768
+ const candidates = updates ?? (await next(expression.right, [target], false)).slice(0, 1);
2769
+ for (const candidate of candidates) {
2770
+ if (attribute) {
2771
+ const text = String(value(candidate.node, yaml));
2772
+ if (attribute === "tag") {
2773
+ if (!target.node.tag || this.work.implicitTags.has(target.node)) this.work.implicitTags.add(target.node);
2774
+ target.node.tag = text.startsWith("!!") ? `tag:yaml.org,2002:${text.slice(2)}` : text;
2775
+ if (yaml.isScalar(target.node) && text === "!!str") target.node.value = scalarText(target.node, yaml);
2776
+ } else {
2777
+ if (!["", "single", "double", "literal", "folded", "flow", "tagged"].includes(text)) throw new MikeError(`unknown style ${text}`);
2778
+ if (yaml.isScalar(target.node)) target.node.type = text === "single" ? "QUOTE_SINGLE" : text === "double" ? "QUOTE_DOUBLE" : text === "literal" ? "BLOCK_LITERAL" : text === "folded" ? "BLOCK_FOLDED" : "PLAIN";
2779
+ else if (yaml.isCollection(target.node)) target.node.flow = text === "flow";
2780
+ }
2781
+ } else {
2782
+ const updated = operator.length === 2 && operator !== "|=" && operator !== "=c" ? await this.binary(operator[0], target.node, candidate.node) : candidate.node;
2783
+ await replace(target, updated, yaml, this.work, operator === "=c");
2784
+ if (operator === "=c") target.node.tag = `tag:yaml.org,2002:${nodeTag(target.node, yaml).slice(2)}`;
2785
+ }
2786
+ }
2787
+ }
2788
+ return inputs.map((input) => input.isDocumentRoot ? { ...input, node: input.document.doc.contents } : input);
2789
+ }
2790
+ const readOnly = omitMissing || ["+", "==", "!="].includes(operator);
2791
+ const left = await next(expression.left, inputs, false, readOnly);
2792
+ if (operator === "//") {
2793
+ const matches = left.filter((candidate) => truth(candidate.node, yaml));
2794
+ return matches.length ? matches : next(expression.right, inputs, false);
2795
+ }
2796
+ const right = await next(expression.right, inputs, false, readOnly);
2797
+ const output2 = [];
2798
+ if (operator === "+" && (!left.length || !right.length)) return left.length ? left : right;
2799
+ if ((operator === "==" || operator === "!=") && inputs.length && (!left.length || !right.length)) {
2800
+ const candidates = left.length ? left : right.length ? right : [inputs[0]];
2801
+ for (const candidate of candidates) {
2802
+ const equal = !left.length && !right.length || nodeTag(candidate.node, yaml) === "!!null";
2803
+ output2.push(this.child(scalar(yaml, this.work, operator === "==" ? equal : !equal), candidate));
2804
+ }
2805
+ return output2;
2806
+ }
2807
+ for (const first of left) for (const second of right) {
2808
+ const node = operator === "and" || operator === "or" ? scalar(yaml, this.work, operator === "and" ? truth(first.node, yaml) && truth(second.node, yaml) : truth(first.node, yaml) || truth(second.node, yaml)) : await this.binary(operator, first.node, second.node);
2809
+ output2.push(this.child(node, first));
2810
+ }
2811
+ return output2;
2812
+ }
2813
+ if (expression.kind !== "call") throw new MikeError("bad expression, please check expression syntax");
2814
+ const output = [];
2815
+ for (const input of inputs) {
2816
+ const name = expression.name;
2817
+ if (name === "explode") {
2818
+ const targets = await next(expression.args[0], [input], false, true);
2819
+ const expanded = [];
2820
+ for (const target of targets) expanded.push(await this.explode(target));
2821
+ for (let index = 0; index < targets.length; index++) {
2822
+ const target = targets[index];
2823
+ await replace(target, expanded[index], yaml, this.work);
2824
+ if ("anchor" in target.node) delete target.node.anchor;
2825
+ if (target === input) input.node = target.node;
2826
+ }
2827
+ output.push(input.isDocumentRoot ? { ...input, node: input.document.doc.contents } : input);
2828
+ continue;
2829
+ }
2830
+ if (name === "path") {
2831
+ this.work.node();
2832
+ const node = new yaml.YAMLSeq();
2833
+ let candidate = input;
2834
+ while (candidate.ancestry) {
2835
+ {
2836
+ const t = this.work.tick();
2837
+ if (t) await t;
2838
+ }
2839
+ const { parent, key } = candidate.ancestry;
2840
+ node.items.push(typeof key === "number" ? scalar(yaml, this.work, BigInt(key)) : await cloneNode(key, yaml, this.work));
2841
+ candidate = parent;
2842
+ }
2843
+ node.items.reverse();
2844
+ output.push(this.child(node, input));
2845
+ continue;
2846
+ }
2847
+ if (name === "head_comment" || name === "anchor" || name === "alias") {
2848
+ const node = input.node;
2849
+ const text = name === "head_comment" ? this.work.headComments.get(node) ?? "" : name === "anchor" ? "anchor" in node ? node.anchor ?? "" : "" : yaml.isAlias(node) ? node.source : yaml.isScalar(node) ? scalarText(node, yaml) : "";
2850
+ output.push(this.child(scalar(yaml, this.work, text), input));
2851
+ continue;
2852
+ }
2853
+ const base = dereference(input, yaml, this.work);
2854
+ if (name === "sort" || name === "sort_by") {
2855
+ output.push(this.child(await this.sort(base, expression.args[0] ?? { kind: "identity" }, depth), input));
2856
+ continue;
2857
+ }
2858
+ if (name === "reverse") {
2859
+ if (!yaml.isSeq(base.node)) throw new MikeError(`cannot reverse ${nodeTag(base.node, yaml)}, can only reverse arrays`);
2860
+ const node = await cloneNode(base.node, yaml, this.work);
2861
+ {
2862
+ const t = this.work.tick(node.items.length);
2863
+ if (t) await t;
2864
+ }
2865
+ node.items.reverse();
2866
+ output.push(this.child(node, input));
2867
+ continue;
2868
+ }
2869
+ if (name === "to_entries" || name === "from_entries") {
2870
+ if (name === "to_entries" && nodeTag(base.node, yaml) === "!!null") continue;
2871
+ output.push(this.child(name === "to_entries" ? await this.toEntries(base) : await this.fromEntries(base), input));
2872
+ continue;
2873
+ }
2874
+ if (name === "with_entries") {
2875
+ if (nodeTag(base.node, yaml) === "!!null") continue;
2876
+ const entries = this.child(await this.toEntries(base), input);
2877
+ const transformed = new yaml.YAMLSeq();
2878
+ this.work.node();
2879
+ if (entries.node.commentBefore !== void 0) transformed.commentBefore = entries.node.commentBefore;
2880
+ if (entries.node.comment !== void 0) transformed.comment = entries.node.comment;
2881
+ for (const entry of await next({ kind: "iterate" }, [entries], false)) {
2882
+ for (const candidate of await next(expression.args[0], [entry], false)) transformed.items.push(await cloneNode(candidate.node, yaml, this.work));
2883
+ }
2884
+ const node = await this.fromEntries(this.child(transformed, input));
2885
+ output.push(this.child(node, input));
2886
+ continue;
2887
+ }
2888
+ if (name === "pick") {
2889
+ if (!yaml.isCollection(base.node)) throw new MikeError("pick only supports maps and arrays");
2890
+ for (const selected of await next(expression.args[0], [input], false)) {
2891
+ const keys = dereference(selected, yaml, this.work);
2892
+ if (!yaml.isSeq(keys.node)) throw new MikeError("pick expects an array of keys");
2893
+ const node = await cloneNode(base.node, yaml, this.work);
2894
+ node.items = [];
2895
+ for (const key of keys.node.items) {
2896
+ {
2897
+ const t = this.work.tick();
2898
+ if (t) await t;
2899
+ }
2900
+ const requested = value(key, yaml);
2901
+ if (yaml.isMap(base.node) && yaml.isMap(node)) {
2902
+ for (const pair of base.node.items) {
2903
+ {
2904
+ const t = this.work.tick();
2905
+ if (t) await t;
2906
+ }
2907
+ if (yaml.isScalar(pair.key) && value(pair.key, yaml) === requested) node.items.push(new yaml.Pair(await cloneNode(pair.key, yaml, this.work), await cloneNode(pair.value, yaml, this.work)));
2908
+ }
2909
+ } else if (yaml.isSeq(base.node) && yaml.isSeq(node)) {
2910
+ const index = nodeTag(key, yaml) === "!!int" ? Number(requested) : NaN;
2911
+ if (Number.isSafeInteger(index) && index >= 0 && index < base.node.items.length) node.items.push(await cloneNode(base.node.items[index], yaml, this.work));
2912
+ }
2913
+ }
2914
+ output.push(this.child(node, input));
2915
+ }
2916
+ continue;
2917
+ }
2918
+ if (name === "upcase" || name === "downcase") {
2919
+ const text = value(base.node, yaml);
2920
+ if (typeof text !== "string") throw new MikeError(`${name} only supports strings`);
2921
+ {
2922
+ const t = this.work.tick(text.length);
2923
+ if (t) await t;
2924
+ }
2925
+ const characters = [];
2926
+ for (const character of text) {
2927
+ {
2928
+ const t = this.work.tick(character.length);
2929
+ if (t) await t;
2930
+ }
2931
+ const converted = name === "upcase" ? character.toUpperCase() : character === "\u0130" ? "i" : character.toLowerCase();
2932
+ characters.push([...converted].length === 1 ? converted : character);
2933
+ }
2934
+ const upper = characters.join("");
2935
+ const node = await cloneNode(base.node, yaml, this.work);
2936
+ if (utf8ByteLength5(upper) > this.work.limits.maxScalarBytes) throw new MikeError("yq limit exceeded: maxScalarBytes");
2937
+ if (yaml.isScalar(node)) {
2938
+ node.value = upper;
2939
+ node.source = upper;
2940
+ }
2941
+ output.push(this.child(node, input));
2942
+ continue;
2943
+ }
2944
+ if (name === "select") {
2945
+ if (!expression.args[0]) throw new MikeError("bad expression, please check expression syntax");
2946
+ if ((await next(expression.args[0], [input], false)).some((candidate) => truth(candidate.node, yaml))) output.push(input);
2947
+ continue;
2948
+ }
2949
+ if (name === "map") {
2950
+ const members = await next({ kind: "iterate" }, [input], false);
2951
+ const node = new yaml.YAMLSeq();
2952
+ this.work.node();
2953
+ for (const member of members) for (const result2 of await next(expression.args[0], [member], false)) node.items.push(await cloneNode(result2.node, yaml, this.work));
2954
+ output.push(this.child(node, input));
2955
+ continue;
2956
+ }
2957
+ if (name === "del") {
2958
+ const slots = /* @__PURE__ */ new Map();
2959
+ for (const candidate of await next(expression.args[0], [input], false)) {
2960
+ {
2961
+ const t = this.work.tick();
2962
+ if (t) await t;
2963
+ }
2964
+ if (!candidate.parent || candidate.slot === void 0) continue;
2965
+ let selected = slots.get(candidate.parent);
2966
+ if (!selected) {
2967
+ selected = /* @__PURE__ */ new Set();
2968
+ slots.set(candidate.parent, selected);
2969
+ }
2970
+ selected.add(candidate.slot);
2971
+ }
2972
+ for (const [parent, selected] of slots) for (const slot of [...selected].sort((left, right) => right - left)) {
2973
+ {
2974
+ const t = this.work.tick();
2975
+ if (t) await t;
2976
+ }
2977
+ parent.items.splice(slot, 1);
2978
+ }
2979
+ output.push(input);
2980
+ continue;
2981
+ }
2982
+ if (name === "env" || name === "strenv") {
2983
+ const key = expression.args[0];
2984
+ if (key?.kind !== "literal") throw new MikeError("bad expression, please check expression syntax");
2985
+ const text = this.work.context.env[String(key.value)] ?? "";
2986
+ if (name === "strenv") output.push(this.child(scalar(yaml, this.work, text), input));
2987
+ else {
2988
+ if (!text) throw new MikeError(`value for env variable '${String(key.value)}' not provided in env()`);
2989
+ const docs = await decodeDocuments(text, "<env>", 0, "yaml", yaml, this.work);
2990
+ output.push(this.child(docs[0].doc.contents, input));
2991
+ }
2992
+ continue;
2993
+ }
2994
+ let result;
2995
+ if (name === "test" || name === "split") {
2996
+ if (nodeTag(base.node, yaml) !== "!!str") throw new MikeError(`cannot ${name} ${nodeTag(base.node, yaml)}, can only ${name} strings`);
2997
+ const text = String(value(base.node, yaml));
2998
+ {
2999
+ const t = this.work.tick(text.length);
3000
+ if (t) await t;
3001
+ }
3002
+ {
3003
+ for (const argument of await next(expression.args[0], [input], false)) {
3004
+ if (nodeTag(argument.node, yaml) !== "!!str") throw new MikeError(`${name} requires a string argument`);
3005
+ const pattern = String(value(argument.node, yaml));
3006
+ {
3007
+ const t = this.work.tick(pattern.length);
3008
+ if (t) await t;
3009
+ }
3010
+ if (name === "split") {
3011
+ const node = new yaml.YAMLSeq();
3012
+ this.work.node();
3013
+ if (!pattern) {
3014
+ for (const part of text) {
3015
+ {
3016
+ const t = this.work.tick();
3017
+ if (t) await t;
3018
+ }
3019
+ node.items.push(scalar(yaml, this.work, part));
3020
+ }
3021
+ } else {
3022
+ let start = 0;
3023
+ while (true) {
3024
+ {
3025
+ const t = this.work.tick();
3026
+ if (t) await t;
3027
+ }
3028
+ const end = text.indexOf(pattern, start);
3029
+ node.items.push(scalar(yaml, this.work, text.slice(start, end < 0 ? text.length : end)));
3030
+ if (end < 0) break;
3031
+ start = end + pattern.length;
3032
+ }
3033
+ }
3034
+ output.push(this.child(node, input));
3035
+ } else {
3036
+ if (pattern.includes("[") && pattern.includes("\\")) throw new MikeError("unsupported yq regex: brackets combined with escapes");
3037
+ const ledger = this.#regex ??= new EreLedger({ maxExpansionBytes: this.work.limits.maxScalarBytes, maxExpansionFields: this.work.limits.maxNodes }, {
3038
+ patternBytes: Infinity,
3039
+ subjectBytes: Infinity,
3040
+ work: this.work.limits.maxSteps,
3041
+ states: Infinity,
3042
+ allocationUnits: Infinity
3043
+ });
3044
+ const before = ledger.usage.work;
3045
+ try {
3046
+ const program = await compileEre(pattern, ledger, this.work.signal);
3047
+ const subject = await prepareUtf8EreSubject(utf8Encoder3.encode(text), ledger, this.work.signal, true);
3048
+ const matched = await subject(program)(0);
3049
+ output.push(this.child(scalar(yaml, this.work, matched !== void 0), input));
3050
+ } catch (error) {
3051
+ this.work.assertOpen();
3052
+ if (error instanceof EreSyntaxError || error instanceof EreUnsupportedError || error instanceof EreProfileLimitError) throw new MikeError(error.message);
3053
+ throw error;
3054
+ } finally {
3055
+ {
3056
+ const t = this.work.tick(ledger.usage.work - before);
3057
+ if (t) await t;
3058
+ }
3059
+ }
3060
+ }
3061
+ }
3062
+ continue;
3063
+ }
3064
+ } else if (name === "tag" || name === "type") result = nodeTag(base.node, yaml);
3065
+ else if (name === "kind") result = yaml.isMap(base.node) ? "map" : yaml.isSeq(base.node) ? "seq" : "scalar";
3066
+ else if (name === "documentIndex" || name === "document_index" || name === "di") result = BigInt(input.document.documentIndex);
3067
+ else if (name === "fileIndex" || name === "file_index" || name === "fi") result = BigInt(input.document.fileIndex);
3068
+ else if (name === "filename") result = input.document.filename;
3069
+ else if (name === "not") result = !truth(base.node, yaml);
3070
+ else if (name === "length") {
3071
+ let length = yaml.isCollection(base.node) ? base.node.items.length : 0;
3072
+ if (yaml.isScalar(base.node) && nodeTag(base.node, yaml) !== "!!null") {
3073
+ const text = scalarText(base.node, yaml);
3074
+ {
3075
+ const t = this.work.tick(text.length);
3076
+ if (t) await t;
3077
+ }
3078
+ length = utf8ByteLength5(text);
3079
+ }
3080
+ result = BigInt(length);
3081
+ } else if (name === "has") {
3082
+ const key = (await next(expression.args[0], [input], false))[0];
3083
+ const keyNode = dereference(key, yaml, this.work).node;
3084
+ result = yaml.isMap(base.node) ? base.node.items.some((pair) => yaml.isScalar(pair.key) && String(pair.key.value) === String(value(key.node, yaml))) : yaml.isSeq(base.node) && nodeTag(keyNode, yaml) === "!!int" && Number(value(keyNode, yaml)) >= 0 && Number(value(keyNode, yaml)) < base.node.items.length;
3085
+ } else if (name === "keys") {
3086
+ if (!yaml.isMap(base.node) && !yaml.isSeq(base.node)) {
3087
+ throw new MikeError(`cannot get keys of ${nodeTag(base.node, yaml)}, keys only works for maps and arrays`);
3088
+ }
3089
+ const node = new yaml.YAMLSeq();
3090
+ this.work.node();
3091
+ if (yaml.isMap(base.node)) for (const pair of base.node.items) {
3092
+ const key = await cloneNode(pair.key, yaml, this.work);
3093
+ delete key.commentBefore;
3094
+ node.items.push(key);
3095
+ }
3096
+ else if (yaml.isSeq(base.node)) base.node.items.forEach((_, index) => node.items.push(scalar(yaml, this.work, BigInt(index))));
3097
+ output.push(this.child(node, input));
3098
+ continue;
3099
+ } else if (name === "style") result = yaml.isScalar(base.node) ? base.node.type === "QUOTE_SINGLE" ? "single" : base.node.type === "QUOTE_DOUBLE" ? "double" : base.node.type === "BLOCK_FOLDED" ? "folded" : base.node.type === "BLOCK_LITERAL" ? "literal" : "" : yaml.isCollection(base.node) && base.node.flow ? "flow" : "";
3100
+ output.push(this.child(scalar(yaml, this.work, result), input));
3101
+ }
3102
+ return output;
3103
+ }
3104
+ };
3105
+
3106
+ // packages/safe-bash-command-yq/src/mike.ts
3107
+ import { writeFileOutputCounted as writeFileOutputCounted2 } from "../safe-bash-contracts/filesystem-output-budget.js";
3108
+
3109
+ // packages/safe-bash-command-yq/src/inplace.ts
3110
+ init_buffer();
3111
+ import { retainFileSystemCleanup } from "@poe-platform/safe-fs/core";
3112
+ import { dirname } from "@poe-platform/safe-fs/core";
3113
+ import { writeFileOutputCounted } from "../safe-bash-contracts/filesystem-output-budget.js";
3114
+ async function captureInPlace(path, work) {
3115
+ const fs = work.context.fs;
3116
+ const resolved = await work.track(fs.realpath(path, { signal: work.signal }));
3117
+ work.assertOpen();
3118
+ const capabilities = fs.capabilitiesFor ? await work.track(fs.capabilitiesFor(resolved, { signal: work.signal })) : fs.capabilities;
3119
+ work.assertOpen();
3120
+ if (!capabilities.atomicFileStaging || !capabilities.atomicStagingAncestry || !fs.createStagedFile || !fs.publishStagedFile || !fs.removeStagedFile) {
3121
+ throw new MikeError("in-place update requires atomic VFS staging and ancestry publication");
3122
+ }
3123
+ const ancestors = [];
3124
+ for (let parent = dirname(resolved); ; parent = dirname(parent)) {
3125
+ const stat = await work.track(fs.lstat(parent, { signal: work.signal }));
3126
+ work.assertOpen();
3127
+ if (stat.type !== "directory") throw new MikeError("in-place target ancestry changed");
3128
+ ancestors.unshift({ path: parent, stat });
3129
+ if (parent === "/") break;
3130
+ }
3131
+ const original = await work.track(fs.lstat(resolved, { signal: work.signal }));
3132
+ work.assertOpen();
3133
+ if (original.type !== "file" || original.nlink !== 1) throw new MikeError("in-place update requires a singly linked regular file");
3134
+ return { path: resolved, original, ancestors };
3135
+ }
3136
+ async function publishInPlace(target, data, work) {
3137
+ const fs = work.context.fs;
3138
+ const directory = dirname(target.path);
3139
+ const parent = target.ancestors.at(-1).stat;
3140
+ let owned;
3141
+ const cleanup = retainFileSystemCleanup(fs, async (view) => {
3142
+ if (owned) await view.removeStagedFile(owned);
3143
+ }, { maxOperations: 1 });
3144
+ const staging = await work.acquire(async () => {
3145
+ let receipt;
3146
+ try {
3147
+ await writeFileOutputCounted({ signal: work.signal, preserveWriteReceipt: true, ...work.context.registerCleanup ? { registerCleanup: work.context.registerCleanup } : {} }, data, async () => {
3148
+ const token = Array.from(globalThis.crypto.getRandomValues(new Uint8Array(12)), (byte) => byte.toString(16).padStart(2, "0")).join("");
3149
+ receipt = await fs.createStagedFile(`${directory === "/" ? "" : directory}/.yq-${token}`, "file", {
3150
+ type: "file",
3151
+ data
3152
+ }, { parent, mode: target.original.mode & 4095, signal: work.signal });
3153
+ owned = receipt;
3154
+ return data.byteLength;
3155
+ });
3156
+ } catch (error) {
3157
+ await cleanup();
3158
+ throw error;
3159
+ }
3160
+ return receipt;
3161
+ }, cleanup);
3162
+ await work.track(fs.publishStagedFile(staging, target.path, {
3163
+ parent,
3164
+ destination: target.original,
3165
+ ancestors: target.ancestors,
3166
+ signal: work.signal
3167
+ }));
3168
+ work.assertOpen();
3169
+ }
3170
+
3171
+ // packages/safe-bash-command-yq/src/mike.ts
3172
+ async function encodeNodeInfo(candidate, yaml, work) {
3173
+ const node = candidate.node;
3174
+ const kind = yaml.isMap(node) ? "MappingNode" : yaml.isSeq(node) ? "SequenceNode" : yaml.isAlias(node) ? "AliasNode" : "ScalarNode";
3175
+ const styles = { QUOTE_DOUBLE: "DoubleQuotedStyle", QUOTE_SINGLE: "SingleQuotedStyle", BLOCK_LITERAL: "LiteralStyle", BLOCK_FOLDED: "FoldedStyle" };
3176
+ const style = yaml.isScalar(node) ? styles[node.type ?? ""] ?? "" : !yaml.isAlias(node) && node.flow ? "FlowStyle" : "";
3177
+ const location = candidate.isDerived ? void 0 : work.positions.get(node);
3178
+ const info = {
3179
+ kind,
3180
+ style,
3181
+ anchor: "anchor" in node ? node.anchor ?? "" : "",
3182
+ tag: nodeTag(node, yaml),
3183
+ value: yaml.isScalar(node) ? String(node.value ?? "") : yaml.isAlias(node) ? node.source : "",
3184
+ line: location?.line ?? 0,
3185
+ column: location?.column ?? 0
3186
+ };
3187
+ {
3188
+ const t = work.tick();
3189
+ if (t) await t;
3190
+ }
3191
+ work.node(17);
3192
+ return yaml.stringify(info, { singleQuote: true }) + "\n";
3193
+ }
3194
+ async function writeVerbose(message, work) {
3195
+ const text = `time=${(/* @__PURE__ */ new Date()).toISOString()} level=DEBUG source=safe-bash/yq msg=${JSON.stringify(message)}
3196
+ `;
3197
+ work.output(utf8ByteLength6(text));
3198
+ await work.write(utf8Encoder4.encode(text), true);
3199
+ }
3200
+ function pathOf(context, name) {
3201
+ if (name.includes("\0")) throw new MikeError("path contains NUL");
3202
+ return name.startsWith("/") ? name : `${context.cwd.endsWith("/") ? context.cwd : `${context.cwd}/`}${name}`;
3203
+ }
3204
+ async function runCommand(context, limits, work) {
3205
+ const commandMode = mikeCommandMode(context.args);
3206
+ try {
3207
+ const options = parseMikeArguments(context);
3208
+ work.capturePositions = options.verbose || options.debugNodeInfo;
3209
+ if (options.help || options.version) {
3210
+ const text = options.help ? commandMode === "eval-all" ? mikeAllHelp : commandMode === "eval" ? mikeEvalHelp : mikeHelp : "yq (safe-bash; bounded Mike Farah v4.53.3 profile)\n";
3211
+ work.output(utf8ByteLength6(text));
3212
+ await work.write(utf8Encoder4.encode(text));
3213
+ return { exitCode: 0 };
3214
+ }
3215
+ const readText = async (filename) => {
3216
+ const path = pathOf(context, filename);
3217
+ const bytes = await work.readFile(path);
3218
+ work.assertOpen();
3219
+ try {
3220
+ return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
3221
+ } catch {
3222
+ throw new MikeError(`bad file '${filename}': invalid UTF-8`);
3223
+ }
3224
+ };
3225
+ let expression = options.fromFile !== void 0 ? await readText(options.fromFile) : options.expression;
3226
+ const splitExpression = options.splitFile !== void 0 ? await readText(options.splitFile) : options.splitExpression;
3227
+ if (options.inplace && splitExpression !== void 0) throw new MikeError("write in place cannot be used with split file");
3228
+ const operands = [...options.operands];
3229
+ if (expression === void 0 && operands.length && operands[0] !== "-") {
3230
+ let exists = false;
3231
+ if (!options.nullInput && !options.inplace && operands.length === 1) {
3232
+ try {
3233
+ exists = (await work.track(context.fs.stat(pathOf(context, operands[0]), { signal: work.signal }))).type !== "directory";
3234
+ } catch (error) {
3235
+ work.assertOpen();
3236
+ if (!(error instanceof FsError)) throw error;
3237
+ }
3238
+ }
3239
+ if (!exists) expression = operands.shift();
3240
+ }
3241
+ expression ??= ".";
3242
+ if (options.inplace && (!operands.length || operands[0] === "-")) throw new MikeError("write in place flag only applicable when giving an expression and at least one file");
3243
+ if (options.nullInput && operands.length) throw new MikeError("cannot pass files in when using null-input flag");
3244
+ const inputOption = mikeFormat(options.input);
3245
+ const outputOption = mikeFormat(options.output);
3246
+ const inferred = operands[0]?.toLowerCase().endsWith(".json") ? "json" : "yaml";
3247
+ const format = inputOption === "auto" ? inferred : inputOption;
3248
+ const output = outputOption === "auto" ? inputOption === "auto" ? inferred : "yaml" : outputOption;
3249
+ const expressionOptions = { ...options, maxExpressionBytes: limits.maxExpressionBytes, maxExpressionDepth: limits.maxExpressionDepth };
3250
+ const program = compileExpression(expression, expressionOptions);
3251
+ if (options.verbose) await writeVerbose(`Compiled expression ${expression}; input=${format}; output=${output}`, work);
3252
+ const splitProgram = splitExpression !== void 0 ? compileExpression(splitExpression, expressionOptions) : void 0;
3253
+ const yaml = await work.track(loadYaml());
3254
+ work.assertOpen();
3255
+ const evaluator = new Evaluator(yaml, work, options.mergeSpec);
3256
+ const results = [];
3257
+ let qualified = false;
3258
+ const frontMatterBodies = /* @__PURE__ */ new Map();
3259
+ let previous;
3260
+ let original;
3261
+ if (options.inplace) {
3262
+ original = await captureInPlace(pathOf(context, operands[0]), work);
3263
+ }
3264
+ const print = async (candidates) => {
3265
+ for (const candidate of candidates) {
3266
+ {
3267
+ const t = work.tick();
3268
+ if (t) await t;
3269
+ }
3270
+ const origin = candidate.isDerived ? { fileIndex: 0, documentIndex: 0 } : candidate.document;
3271
+ const separator = !splitProgram && previous && (previous.fileIndex !== origin.fileIndex || previous.documentIndex !== origin.documentIndex) && output === "yaml" && !options.noDoc ? "---\n" : "";
3272
+ let encoded = options.debugNodeInfo ? await encodeNodeInfo(candidate, yaml, work) : output !== "yaml" && output !== "json" ? await encodeFormat(candidate, output, yaml, work) : await encodeNative(candidate, { format: output, indent: options.indent, unwrap: options.unwrap ?? output === "yaml", compactSequence: options.compactSequence, prettyPrint: options.prettyPrint, preserveDocumentStart: options.headerPreprocess && !options.noDoc }, yaml, work);
3273
+ if (options.verbose) await writeVerbose(`Selected node from ${candidate.document.filename || "stdin"}, document ${candidate.document.documentIndex}: ${await encodeNodeInfo(candidate, yaml, work)}`, work);
3274
+ if (options.nulOutput) {
3275
+ if (encoded.endsWith("\r\n")) encoded = encoded.slice(0, -2);
3276
+ else if (encoded.endsWith("\n") || encoded.endsWith("\r")) encoded = encoded.slice(0, -1);
3277
+ if (encoded.includes("\0")) throw new MikeError("can't serialise value because it contains NUL char and you are using NUL separated output");
3278
+ encoded += "\0";
3279
+ }
3280
+ let text = separator + encoded;
3281
+ const frontMatterBody = frontMatterBodies.get(candidate.document.fileIndex);
3282
+ if (frontMatterBody !== void 0 && options.frontMatter === "process") text = `${text}---
3283
+ ${frontMatterBody}`;
3284
+ work.output(utf8ByteLength6(text));
3285
+ if (splitProgram) {
3286
+ const names = await evaluator.run(splitProgram, [candidate]);
3287
+ if (names.length !== 1 || !yaml.isScalar(names[0].node) || typeof names[0].node.value !== "string") throw new MikeError("split expression must return a string");
3288
+ const path = pathOf(context, `${names[0].node.value}.${output === "yaml" ? "yml" : output}`);
3289
+ const parent = path.slice(0, path.lastIndexOf("/")) || "/";
3290
+ await work.track(context.fs.mkdir(parent, { recursive: true, signal: work.signal }));
3291
+ work.assertOpen();
3292
+ const data = utf8Encoder4.encode(text);
3293
+ await work.track(writeFileOutputCounted2({ signal: work.signal, ...context.registerCleanup ? { registerCleanup: context.registerCleanup } : {} }, data, async () => {
3294
+ await context.fs.writeFile(path, data, { flag: "w", signal: work.signal });
3295
+ return data.length;
3296
+ }));
3297
+ work.assertOpen();
3298
+ } else if (options.inplace) results.push(text);
3299
+ else await work.write(utf8Encoder4.encode(text));
3300
+ qualified ||= truth(candidate.node, yaml);
3301
+ previous = origin;
3302
+ }
3303
+ };
3304
+ const all = [];
3305
+ if (options.nullInput) {
3306
+ const doc = new yaml.Document();
3307
+ doc.contents = scalar(yaml, work, null);
3308
+ await print(await evaluator.run(program, [root({ doc, filename: "", fileIndex: 0, documentIndex: 0, format: "yaml" })]));
3309
+ } else {
3310
+ for (const [fileIndex, filename] of (operands.length ? operands : ["-"]).entries()) {
3311
+ let bytes;
3312
+ if (filename === "-") bytes = await work.collect(() => context.stdin);
3313
+ else {
3314
+ const path = fileIndex === 0 && original ? original.path : pathOf(context, filename);
3315
+ try {
3316
+ bytes = await work.readFile(path);
3317
+ } catch (error) {
3318
+ work.assertOpen();
3319
+ if (error instanceof FsError) {
3320
+ const description = { ENOENT: "no such file or directory", EACCES: "permission denied", ENOTDIR: "not a directory", EISDIR: "is a directory", ELOOP: "too many levels of symbolic links", EIO: "input/output error" }[error.code];
3321
+ if (description) throw new MikeError(`${error.code === "EISDIR" ? "read" : "open"} ${filename}: ${description}`);
3322
+ }
3323
+ throw error;
3324
+ }
3325
+ }
3326
+ work.assertOpen();
3327
+ let text;
3328
+ try {
3329
+ text = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
3330
+ } catch {
3331
+ throw new MikeError(`bad file '${filename}': invalid UTF-8`);
3332
+ }
3333
+ if (options.frontMatter !== void 0 && fileIndex === 0) {
3334
+ const firstEnd = text.indexOf("\n");
3335
+ let end = firstEnd >= 0 && text.slice(0, firstEnd).trimEnd() === "---" ? firstEnd + 1 : 0;
3336
+ while (end < text.length) {
3337
+ {
3338
+ const t = work.tick();
3339
+ if (t) await t;
3340
+ }
3341
+ const newline = text.indexOf("\n", end);
3342
+ const lineEnd = newline < 0 ? text.length : newline;
3343
+ const line = text.slice(end, lineEnd).trimEnd();
3344
+ if (line === "---" || line === "...") {
3345
+ frontMatterBodies.set(fileIndex, text.slice(newline < 0 ? text.length : newline + 1));
3346
+ text = text.slice(0, end);
3347
+ break;
3348
+ }
3349
+ end = newline < 0 ? text.length : newline + 1;
3350
+ }
3351
+ }
3352
+ await decodeFormat(text, filename, fileIndex, options.frontMatter !== void 0 && fileIndex === 0 ? "yaml" : format, yaml, work, async (document) => {
3353
+ if (options.verbose) await writeVerbose(`Parsed ${filename}, document ${document.documentIndex}`, work);
3354
+ if (options.all) {
3355
+ if (all.length >= limits.maxDocuments) throw new MikeError("yq limit exceeded: maxDocuments");
3356
+ all.push(root(document));
3357
+ } else await print(await evaluator.run(program, [root(document)]));
3358
+ });
3359
+ }
3360
+ if (options.all) await print(await evaluator.run(program, all));
3361
+ }
3362
+ if (options.exitStatus && !qualified) throw new MikeError("no matches found");
3363
+ if (options.inplace) await publishInPlace(original, utf8Encoder4.encode(results.join("")), work);
3364
+ return { exitCode: 0 };
3365
+ } catch (error) {
3366
+ context.signal.throwIfAborted();
3367
+ work.assertOpen();
3368
+ if (error instanceof MikeError) {
3369
+ const selected = commandMode === "eval-all" ? mikeAllHelp : commandMode === "eval" ? mikeEvalHelp : void 0;
3370
+ const usage = selected ? selected.slice(selected.indexOf("Usage:")) + "\n" : mikeUsage;
3371
+ const message = escapeText(`Error: ${error.message}
3372
+ ${error.usage ? usage : ""}`, "diagnostic");
3373
+ await work.write(utf8Encoder4.encode(message), true);
3374
+ return { exitCode: 1 };
3375
+ }
3376
+ if (error instanceof FsError) {
3377
+ const message = escapeText(error.message, "diagnostic");
3378
+ await work.write(utf8Encoder4.encode(utf8ByteLength6(message) < 65520 ? `Error: ${message}
3379
+ ` : "Error: yq diagnostic exceeds safety limit\n"), true);
3380
+ return { exitCode: 1 };
3381
+ }
3382
+ throw error;
3383
+ }
3384
+ }
3385
+ async function execute(context, limits) {
3386
+ const work = new NativeWork(context, limits);
3387
+ let result;
3388
+ let primary;
3389
+ let failed = false;
3390
+ try {
3391
+ result = await runCommand(context, limits, work);
3392
+ } catch (error) {
3393
+ failed = true;
3394
+ primary = error;
3395
+ }
3396
+ try {
3397
+ await work.close();
3398
+ } catch (error) {
3399
+ if (!failed) {
3400
+ failed = true;
3401
+ primary = error;
3402
+ }
3403
+ }
3404
+ context.signal.throwIfAborted();
3405
+ if (failed) throw primary;
3406
+ return result;
3407
+ }
3408
+ function createMikeYqCommand(options = {}) {
3409
+ if (!options || typeof options !== "object" || Array.isArray(options) || Object.keys(options).some((key) => key !== "limits" && key !== "replace") || options.replace !== void 0 && typeof options.replace !== "boolean") throw new TypeError("invalid yq options");
3410
+ const limits = limitsFor(options.limits);
3411
+ return Object.freeze({ name: "yq", runtimeIdentity: commandRuntimeIdentity, async execute(context) {
3412
+ return execute(context, limits);
3413
+ } });
3414
+ }
3415
+ function createMikeYqCommands(options = {}) {
3416
+ return Object.freeze([createMikeYqCommand(options)]);
3417
+ }
3418
+ function mikeYqCommands(options = {}) {
3419
+ const definitions = createMikeYqCommands(options);
3420
+ const replace2 = options.replace ?? false;
3421
+ return Object.freeze({ name: "mike-yq-commands", setup(host) {
3422
+ for (const definition of definitions) host.commands.register(definition, { replace: replace2 });
3423
+ } });
730
3424
  }
731
3425
  export {
732
- createYqCommand,
733
- createYqCommands,
734
- yqCommands
3426
+ createMikeYqCommand,
3427
+ createMikeYqCommands,
3428
+ createMikeYqCommand as createYqCommand,
3429
+ createMikeYqCommands as createYqCommands,
3430
+ mikeYqCommands,
3431
+ mikeYqCommands as yqCommands
735
3432
  };