@poe-platform/safe-bash 0.1.629 → 0.1.631

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 (377) hide show
  1. package/README.md +2 -2
  2. package/dist/office-package/compression.d.ts +19 -0
  3. package/dist/office-package/compression.js +186 -0
  4. package/dist/office-package/runtime.d.ts +11 -0
  5. package/dist/office-package/runtime.js +28 -0
  6. package/dist/safe-bash/chunks/{bz2-B2RXT4EX.js → bz2-ACU4EOVE.js} +2 -2
  7. package/dist/safe-bash/chunks/chunk-2E4KBFO6.js +239 -0
  8. package/dist/safe-bash/chunks/chunk-2E4KBFO6.js.map +7 -0
  9. package/dist/safe-bash/chunks/chunk-3E5M2WEL.js +33 -0
  10. package/dist/safe-bash/chunks/chunk-3E5M2WEL.js.map +7 -0
  11. package/dist/safe-bash/chunks/{chunk-WPEMUXV4.js → chunk-3LD67SER.js} +12 -10
  12. package/dist/safe-bash/chunks/{chunk-WPEMUXV4.js.map → chunk-3LD67SER.js.map} +1 -1
  13. package/dist/safe-bash/chunks/{chunk-6LSSEOG7.js → chunk-6HNK7Q66.js} +11 -7
  14. package/dist/safe-bash/chunks/{chunk-6LSSEOG7.js.map → chunk-6HNK7Q66.js.map} +1 -1
  15. package/dist/safe-bash/chunks/{chunk-AD7UAP5B.js → chunk-7EEWZY5S.js} +10 -8
  16. package/dist/safe-bash/chunks/{chunk-AD7UAP5B.js.map → chunk-7EEWZY5S.js.map} +1 -1
  17. package/dist/safe-bash/chunks/{chunk-RNKTWFEM.js → chunk-CDBQXRWL.js} +3 -3
  18. package/dist/safe-bash/chunks/{chunk-UYX72YHY.js → chunk-CHHAB5SS.js} +10 -74
  19. package/dist/safe-bash/chunks/{chunk-UYX72YHY.js.map → chunk-CHHAB5SS.js.map} +3 -3
  20. package/dist/safe-bash/chunks/{chunk-KYNRHYHP.js → chunk-EI4X5ETX.js} +15 -13
  21. package/dist/safe-bash/chunks/{chunk-KYNRHYHP.js.map → chunk-EI4X5ETX.js.map} +1 -1
  22. package/dist/safe-bash/chunks/{chunk-KZ7QCYNT.js → chunk-GIBLUW2U.js} +13 -9
  23. package/dist/safe-bash/chunks/{chunk-KZ7QCYNT.js.map → chunk-GIBLUW2U.js.map} +1 -1
  24. package/dist/safe-bash/chunks/chunk-GPV7ZFYS.js +1528 -0
  25. package/dist/safe-bash/chunks/chunk-GPV7ZFYS.js.map +7 -0
  26. package/dist/safe-bash/chunks/{chunk-N5CYTGBN.js → chunk-H3E67KTZ.js} +13 -9
  27. package/dist/safe-bash/chunks/{chunk-N5CYTGBN.js.map → chunk-H3E67KTZ.js.map} +1 -1
  28. package/dist/safe-bash/chunks/{chunk-AFH57PPL.js → chunk-IEKESMO4.js} +3 -3
  29. package/dist/safe-bash/chunks/{chunk-DPJWEGIX.js → chunk-JLBIUYT3.js} +2 -2
  30. package/dist/safe-bash/chunks/chunk-JZDO5MC3.js +77 -0
  31. package/dist/safe-bash/chunks/chunk-JZDO5MC3.js.map +7 -0
  32. package/dist/safe-bash/chunks/{chunk-GFZKQIPL.js → chunk-LA6BX562.js} +8 -6
  33. package/dist/safe-bash/chunks/{chunk-GFZKQIPL.js.map → chunk-LA6BX562.js.map} +1 -1
  34. package/dist/safe-bash/chunks/{chunk-PVJJFCGA.js → chunk-M3GPCYSP.js} +2 -2
  35. package/dist/safe-bash/chunks/{chunk-FWDMJTQO.js → chunk-NDCZ3UBP.js} +13 -9
  36. package/dist/safe-bash/chunks/{chunk-FWDMJTQO.js.map → chunk-NDCZ3UBP.js.map} +1 -1
  37. package/dist/safe-bash/chunks/{chunk-2KL6W6NB.js → chunk-O2EVBRKF.js} +1 -2
  38. package/dist/safe-bash/chunks/chunk-OFT77XIB.js +389 -0
  39. package/dist/safe-bash/chunks/chunk-OFT77XIB.js.map +7 -0
  40. package/dist/safe-bash/chunks/{chunk-PCLOK32J.js → chunk-PC6BEIAF.js} +13 -9
  41. package/dist/safe-bash/chunks/{chunk-PCLOK32J.js.map → chunk-PC6BEIAF.js.map} +1 -1
  42. package/dist/safe-bash/chunks/{chunk-3M5F7LD5.js → chunk-QWKP7ZU7.js} +13 -9
  43. package/dist/safe-bash/chunks/{chunk-3M5F7LD5.js.map → chunk-QWKP7ZU7.js.map} +1 -1
  44. package/dist/safe-bash/chunks/chunk-THXJ6CLF.js +53 -0
  45. package/dist/safe-bash/chunks/chunk-THXJ6CLF.js.map +7 -0
  46. package/dist/safe-bash/chunks/{chunk-HHJSJWUD.js → chunk-V73A742N.js} +57 -15
  47. package/dist/safe-bash/chunks/chunk-V73A742N.js.map +7 -0
  48. package/dist/safe-bash/chunks/{chunk-4BYUV5PA.js → chunk-VN3ZGME3.js} +12 -8
  49. package/dist/safe-bash/chunks/{chunk-4BYUV5PA.js.map → chunk-VN3ZGME3.js.map} +1 -1
  50. package/dist/safe-bash/chunks/chunk-WECHUK3Y.js +4285 -0
  51. package/dist/safe-bash/chunks/chunk-WECHUK3Y.js.map +7 -0
  52. package/dist/safe-bash/chunks/{chunk-X55AMTNM.js → chunk-WIOEUR7D.js} +14 -10
  53. package/dist/safe-bash/chunks/{chunk-X55AMTNM.js.map → chunk-WIOEUR7D.js.map} +1 -1
  54. package/dist/safe-bash/chunks/chunk-WPIOO4NX.js +443 -0
  55. package/dist/safe-bash/chunks/chunk-WPIOO4NX.js.map +7 -0
  56. package/dist/safe-bash/chunks/{chunk-C7QNJ3D4.js → chunk-WYTI64IU.js} +2 -2
  57. package/dist/safe-bash/chunks/{xz-AVXFDXW4.js → xz-U4QDTPZL.js} +2 -2
  58. package/dist/safe-bash/chunks/{zstd-R6RPHJYO.js → zstd-OG5RPYXO.js} +2 -2
  59. package/dist/safe-bash/commands/archive/zip/crc.d.ts +2 -0
  60. package/dist/safe-bash/commands/archive/zip/crc.d.ts.map +1 -0
  61. package/dist/safe-bash/commands/archive/zip/crc.js +7 -0
  62. package/dist/safe-bash/commands/archive/zip/crc.js.map +1 -0
  63. package/dist/safe-bash/commands/archive/zip/crypto.d.ts +4 -0
  64. package/dist/safe-bash/commands/archive/zip/crypto.d.ts.map +1 -0
  65. package/dist/safe-bash/commands/archive/zip/crypto.js +34 -0
  66. package/dist/safe-bash/commands/archive/zip/crypto.js.map +1 -0
  67. package/dist/safe-bash/commands/archive/zip/help.d.ts +3 -0
  68. package/dist/safe-bash/commands/archive/zip/help.d.ts.map +1 -0
  69. package/dist/safe-bash/commands/archive/zip/help.js +87 -0
  70. package/dist/safe-bash/commands/archive/zip/help.js.map +1 -0
  71. package/dist/safe-bash/commands/archive/zip/move.d.ts +12 -0
  72. package/dist/safe-bash/commands/archive/zip/move.d.ts.map +1 -0
  73. package/dist/safe-bash/commands/archive/zip/move.js +60 -0
  74. package/dist/safe-bash/commands/archive/zip/move.js.map +1 -0
  75. package/dist/safe-bash/commands/archive/zip/options.js +5 -5
  76. package/dist/safe-bash/commands/archive/zip/options.js.map +1 -1
  77. package/dist/safe-bash/commands/archive/zip-format.d.ts +1 -1
  78. package/dist/safe-bash/commands/archive/zip-format.d.ts.map +1 -1
  79. package/dist/safe-bash/commands/archive/zip-format.js +14 -17
  80. package/dist/safe-bash/commands/archive/zip-format.js.map +1 -1
  81. package/dist/safe-bash/commands/archive/zip.d.ts.map +1 -1
  82. package/dist/safe-bash/commands/archive/zip.js +45 -15
  83. package/dist/safe-bash/commands/archive/zip.js.map +1 -1
  84. package/dist/safe-bash/commands/bytes/compression/bounded-codec.d.ts +2 -0
  85. package/dist/safe-bash/commands/bytes/compression/bounded-codec.d.ts.map +1 -1
  86. package/dist/safe-bash/commands/bytes/compression/bounded-codec.js +4 -0
  87. package/dist/safe-bash/commands/bytes/compression/bounded-codec.js.map +1 -1
  88. package/dist/safe-bash/commands/bytes/compression/codec.d.ts +4 -24
  89. package/dist/safe-bash/commands/bytes/compression/codec.d.ts.map +1 -1
  90. package/dist/safe-bash/commands/bytes/compression/codec.js +12 -168
  91. package/dist/safe-bash/commands/bytes/compression/codec.js.map +1 -1
  92. package/dist/safe-bash/commands/cmp.js +1 -1
  93. package/dist/safe-bash/commands/cmp.js.map +1 -1
  94. package/dist/safe-bash/commands/csplit/index.browser.js +10 -7
  95. package/dist/safe-bash/commands/docx/index.browser.js +54 -0
  96. package/dist/safe-bash/commands/docx/index.browser.js.map +7 -0
  97. package/dist/safe-bash/commands/docx/index.d.ts +25 -0
  98. package/dist/safe-bash/commands/docx/index.d.ts.map +1 -0
  99. package/dist/safe-bash/commands/docx/index.js +42 -0
  100. package/dist/safe-bash/commands/docx/index.js.map +1 -0
  101. package/dist/safe-bash/commands/docx/io.d.ts +15 -0
  102. package/dist/safe-bash/commands/docx/io.d.ts.map +1 -0
  103. package/dist/safe-bash/commands/docx/io.js +16 -0
  104. package/dist/safe-bash/commands/docx/io.js.map +1 -0
  105. package/dist/safe-bash/commands/factor/index.browser.js +7 -5
  106. package/dist/safe-bash/commands/filesystem.d.ts.map +1 -1
  107. package/dist/safe-bash/commands/filesystem.js +9 -1
  108. package/dist/safe-bash/commands/filesystem.js.map +1 -1
  109. package/dist/safe-bash/commands/getopt/index.browser.js +7 -5
  110. package/dist/safe-bash/commands/hexdump/index.browser.js +8 -6
  111. package/dist/safe-bash/commands/iconv/index.browser.js +8 -6
  112. package/dist/safe-bash/commands/line-endings/index.browser.js +10 -7
  113. package/dist/safe-bash/commands/llm/index.browser.js +10 -8
  114. package/dist/safe-bash/commands/llm/providers/index.browser.js +3 -3
  115. package/dist/safe-bash/commands/network/index.browser.js +11 -8
  116. package/dist/safe-bash/commands/node/browser.d.ts +2 -0
  117. package/dist/safe-bash/commands/node/browser.d.ts.map +1 -0
  118. package/dist/safe-bash/commands/node/browser.js +2 -0
  119. package/dist/safe-bash/commands/node/browser.js.map +1 -0
  120. package/dist/safe-bash/commands/node/index.browser.js +18 -0
  121. package/dist/safe-bash/commands/node/index.browser.js.map +7 -0
  122. package/dist/safe-bash/commands/node/safejs.d.ts +6 -0
  123. package/dist/safe-bash/commands/node/safejs.d.ts.map +1 -1
  124. package/dist/safe-bash/commands/node/safejs.js +25 -1
  125. package/dist/safe-bash/commands/node/safejs.js.map +1 -1
  126. package/dist/safe-bash/commands/op/index.browser.js +3 -3
  127. package/dist/safe-bash/commands/op/index.js +0 -1
  128. package/dist/safe-bash/commands/op/index.js.map +2 -2
  129. package/dist/safe-bash/commands/pptx/index.d.ts +29 -0
  130. package/dist/safe-bash/commands/pptx/index.d.ts.map +1 -0
  131. package/dist/safe-bash/commands/pptx/index.js +153 -0
  132. package/dist/safe-bash/commands/pptx/index.js.map +1 -0
  133. package/dist/safe-bash/commands/pr/index.browser.js +8 -6
  134. package/dist/safe-bash/commands/predicates.js +1 -1
  135. package/dist/safe-bash/commands/python/execution.d.ts +3 -0
  136. package/dist/safe-bash/commands/python/execution.d.ts.map +1 -0
  137. package/dist/safe-bash/commands/python/execution.js +193 -0
  138. package/dist/safe-bash/commands/python/execution.js.map +1 -0
  139. package/dist/safe-bash/commands/python/index.browser.js +21 -0
  140. package/dist/safe-bash/commands/python/index.browser.js.map +7 -0
  141. package/dist/safe-bash/commands/python/index.d.ts +49 -0
  142. package/dist/safe-bash/commands/python/index.d.ts.map +1 -0
  143. package/dist/safe-bash/commands/python/index.js +317 -0
  144. package/dist/safe-bash/commands/python/index.js.map +1 -0
  145. package/dist/safe-bash/commands/python/installation.d.ts +9 -0
  146. package/dist/safe-bash/commands/python/installation.d.ts.map +1 -0
  147. package/dist/safe-bash/commands/python/installation.js +80 -0
  148. package/dist/safe-bash/commands/python/installation.js.map +1 -0
  149. package/dist/safe-bash/commands/python/invocation.d.ts +10 -0
  150. package/dist/safe-bash/commands/python/invocation.d.ts.map +1 -0
  151. package/dist/safe-bash/commands/python/invocation.js +81 -0
  152. package/dist/safe-bash/commands/python/invocation.js.map +1 -0
  153. package/dist/safe-bash/commands/python/node.d.ts +12 -0
  154. package/dist/safe-bash/commands/python/node.d.ts.map +1 -0
  155. package/dist/safe-bash/commands/python/node.js +33 -0
  156. package/dist/safe-bash/commands/python/node.js.map +1 -0
  157. package/dist/safe-bash/commands/python/provisioning-runtime.d.ts +5 -0
  158. package/dist/safe-bash/commands/python/provisioning-runtime.d.ts.map +1 -0
  159. package/dist/safe-bash/commands/python/provisioning-runtime.js +179 -0
  160. package/dist/safe-bash/commands/python/provisioning-runtime.js.map +1 -0
  161. package/dist/safe-bash/commands/python/provisioning.d.ts +49 -0
  162. package/dist/safe-bash/commands/python/provisioning.d.ts.map +1 -0
  163. package/dist/safe-bash/commands/python/provisioning.js +320 -0
  164. package/dist/safe-bash/commands/python/provisioning.js.map +1 -0
  165. package/dist/safe-bash/commands/python/reply.d.ts +3 -0
  166. package/dist/safe-bash/commands/python/reply.d.ts.map +1 -0
  167. package/dist/safe-bash/commands/python/reply.js +103 -0
  168. package/dist/safe-bash/commands/python/reply.js.map +1 -0
  169. package/dist/safe-bash/commands/python/worker.browser.js +736 -0
  170. package/dist/safe-bash/commands/python/worker.browser.js.map +7 -0
  171. package/dist/safe-bash/commands/python/worker.d.ts +47 -0
  172. package/dist/safe-bash/commands/python/worker.d.ts.map +1 -0
  173. package/dist/safe-bash/commands/python/worker.js +373 -0
  174. package/dist/safe-bash/commands/python/worker.js.map +1 -0
  175. package/dist/safe-bash/commands/safejs/index.d.ts +5 -17
  176. package/dist/safe-bash/commands/safejs/index.d.ts.map +1 -1
  177. package/dist/safe-bash/commands/safejs/index.js +3 -202
  178. package/dist/safe-bash/commands/safejs/index.js.map +1 -1
  179. package/dist/safe-bash/commands/safejs/runtime.d.ts +15 -0
  180. package/dist/safe-bash/commands/safejs/runtime.d.ts.map +1 -0
  181. package/dist/safe-bash/commands/safejs/runtime.js +190 -0
  182. package/dist/safe-bash/commands/safejs/runtime.js.map +1 -0
  183. package/dist/safe-bash/commands/tsort/index.browser.js +8 -6
  184. package/dist/safe-bash/commands/xml/index.browser.js +9 -7
  185. package/dist/safe-bash/commands/yq/index.browser.js +10 -8
  186. package/dist/safe-bash/commands/yq/index.d.ts.map +1 -1
  187. package/dist/safe-bash/commands/yq/index.js +32 -4
  188. package/dist/safe-bash/commands/yq/index.js.map +1 -1
  189. package/dist/safe-bash/commands/yq/parser.d.ts.map +1 -1
  190. package/dist/safe-bash/commands/yq/parser.js +21 -5
  191. package/dist/safe-bash/commands/yq/parser.js.map +1 -1
  192. package/dist/safe-bash/contracts/command.d.ts +2 -0
  193. package/dist/safe-bash/contracts/command.d.ts.map +1 -1
  194. package/dist/safe-bash/contracts/command.js +6 -2
  195. package/dist/safe-bash/contracts/command.js.map +1 -1
  196. package/dist/safe-bash/contracts/filesystem-descriptor.d.ts +13 -0
  197. package/dist/safe-bash/contracts/filesystem-descriptor.d.ts.map +1 -0
  198. package/dist/safe-bash/contracts/filesystem-descriptor.js +189 -0
  199. package/dist/safe-bash/contracts/filesystem-descriptor.js.map +1 -0
  200. package/dist/safe-bash/contracts/filesystem-output-budget.d.ts +15 -0
  201. package/dist/safe-bash/contracts/filesystem-output-budget.d.ts.map +1 -0
  202. package/dist/safe-bash/contracts/filesystem-output-budget.js +69 -0
  203. package/dist/safe-bash/contracts/filesystem-output-budget.js.map +1 -0
  204. package/dist/safe-bash/contracts/filesystem-output.d.ts +11 -5
  205. package/dist/safe-bash/contracts/filesystem-output.d.ts.map +1 -1
  206. package/dist/safe-bash/contracts/filesystem-output.js +229 -20
  207. package/dist/safe-bash/contracts/filesystem-output.js.map +1 -1
  208. package/dist/safe-bash/contracts/io.d.ts +29 -0
  209. package/dist/safe-bash/contracts/io.d.ts.map +1 -1
  210. package/dist/safe-bash/contracts/io.js +317 -37
  211. package/dist/safe-bash/contracts/io.js.map +1 -1
  212. package/dist/safe-bash/core.browser.js +5963 -6522
  213. package/dist/safe-bash/core.browser.js.map +4 -4
  214. package/dist/safe-bash/core.d.ts +2 -0
  215. package/dist/safe-bash/core.d.ts.map +1 -1
  216. package/dist/safe-bash/core.js +2 -0
  217. package/dist/safe-bash/core.js.map +1 -1
  218. package/dist/safe-bash/index.d.ts +1 -0
  219. package/dist/safe-bash/index.d.ts.map +1 -1
  220. package/dist/safe-bash/index.js +1 -0
  221. package/dist/safe-bash/index.js.map +1 -1
  222. package/dist/safe-bash/opt-in/commands/cmp/compare.js +95 -0
  223. package/dist/safe-bash/opt-in/commands/cmp/index.d.ts +6 -0
  224. package/dist/safe-bash/opt-in/commands/cmp/index.js +99 -0
  225. package/dist/safe-bash/opt-in/commands/cmp/io.js +218 -0
  226. package/dist/safe-bash/opt-in/commands/cmp/options.d.ts +24 -0
  227. package/dist/safe-bash/opt-in/commands/cmp/options.js +195 -0
  228. package/dist/safe-bash/opt-in/commands/dd/conversions.js +152 -0
  229. package/dist/safe-bash/opt-in/commands/dd/index.d.ts +18 -0
  230. package/dist/safe-bash/opt-in/commands/dd/index.js +561 -0
  231. package/dist/safe-bash/opt-in/commands/dd/io.d.ts +31 -0
  232. package/dist/safe-bash/opt-in/commands/dd/io.js +244 -0
  233. package/dist/safe-bash/opt-in/commands/dd/options.js +184 -0
  234. package/dist/safe-bash/opt-in/commands/dd/report.js +69 -0
  235. package/dist/safe-bash/opt-in/commands/install/arguments.js +224 -0
  236. package/dist/safe-bash/opt-in/commands/install/index.d.ts +6 -0
  237. package/dist/safe-bash/opt-in/commands/install/index.js +678 -0
  238. package/dist/safe-bash/opt-in/commands/install/mode.js +71 -0
  239. package/dist/safe-bash/opt-in/commands/install/options.d.ts +36 -0
  240. package/dist/safe-bash/opt-in/commands/install/options.js +27 -0
  241. package/dist/safe-bash/opt-in/commands/shuf/args.js +179 -0
  242. package/dist/safe-bash/opt-in/commands/shuf/index.d.ts +6 -0
  243. package/dist/safe-bash/opt-in/commands/shuf/index.js +20 -0
  244. package/dist/safe-bash/opt-in/commands/shuf/input.js +93 -0
  245. package/dist/safe-bash/opt-in/commands/shuf/options.d.ts +9 -0
  246. package/dist/safe-bash/opt-in/commands/shuf/options.js +8 -0
  247. package/dist/safe-bash/opt-in/commands/shuf/random.js +114 -0
  248. package/dist/safe-bash/opt-in/commands/shuf/shuf.d.ts +3 -0
  249. package/dist/safe-bash/opt-in/commands/shuf/shuf.js +230 -0
  250. package/dist/safe-bash/opt-in/commands/shuf/usage.js +24 -0
  251. package/dist/safe-bash/opt-in/commands/truncate/arguments.js +186 -0
  252. package/dist/safe-bash/opt-in/commands/truncate/index.d.ts +9 -0
  253. package/dist/safe-bash/opt-in/commands/truncate/index.js +244 -0
  254. package/dist/safe-bash/opt-in/commands/yes/index.d.ts +11 -0
  255. package/dist/safe-bash/opt-in/commands/yes/index.js +167 -0
  256. package/dist/safe-bash/opt-in/commands/yq/arguments.js +177 -0
  257. package/dist/safe-bash/opt-in/commands/yq/evaluate.js +564 -0
  258. package/dist/safe-bash/opt-in/commands/yq/expression.js +183 -0
  259. package/dist/safe-bash/opt-in/commands/yq/inplace.js +65 -0
  260. package/dist/safe-bash/opt-in/commands/yq/mike.d.ts +9 -0
  261. package/dist/safe-bash/opt-in/commands/yq/mike.js +192 -0
  262. package/dist/safe-bash/opt-in/commands/yq/native-encoder.js +165 -0
  263. package/dist/safe-bash/opt-in/commands/yq/native-work.d.ts +44 -0
  264. package/dist/safe-bash/opt-in/commands/yq/native-work.js +188 -0
  265. package/dist/safe-bash/opt-in/commands/yq/nodes.js +621 -0
  266. package/dist/safe-bash/opt-in/entrypoints/arrays.d.ts +1 -0
  267. package/dist/safe-bash/opt-in/entrypoints/arrays.js +1 -0
  268. package/dist/safe-bash/opt-in/entrypoints/cmp.d.ts +2 -0
  269. package/dist/safe-bash/opt-in/entrypoints/cmp.js +1 -0
  270. package/dist/safe-bash/opt-in/entrypoints/dd.d.ts +2 -0
  271. package/dist/safe-bash/opt-in/entrypoints/dd.js +1 -0
  272. package/dist/safe-bash/opt-in/entrypoints/devices.d.ts +2 -0
  273. package/dist/safe-bash/opt-in/entrypoints/devices.js +1 -0
  274. package/dist/safe-bash/opt-in/entrypoints/install.d.ts +2 -0
  275. package/dist/safe-bash/opt-in/entrypoints/install.js +1 -0
  276. package/dist/safe-bash/opt-in/entrypoints/jobs.d.ts +1 -0
  277. package/dist/safe-bash/opt-in/entrypoints/jobs.js +1 -0
  278. package/dist/safe-bash/opt-in/entrypoints/mapfile.d.ts +1 -0
  279. package/dist/safe-bash/opt-in/entrypoints/mapfile.js +1 -0
  280. package/dist/safe-bash/opt-in/entrypoints/read.d.ts +2 -0
  281. package/dist/safe-bash/opt-in/entrypoints/read.js +1 -0
  282. package/dist/safe-bash/opt-in/entrypoints/shuf.d.ts +2 -0
  283. package/dist/safe-bash/opt-in/entrypoints/shuf.js +1 -0
  284. package/dist/safe-bash/opt-in/entrypoints/trap.d.ts +2 -0
  285. package/dist/safe-bash/opt-in/entrypoints/trap.js +1 -0
  286. package/dist/safe-bash/opt-in/entrypoints/truncate.d.ts +2 -0
  287. package/dist/safe-bash/opt-in/entrypoints/truncate.js +1 -0
  288. package/dist/safe-bash/opt-in/entrypoints/yes.d.ts +2 -0
  289. package/dist/safe-bash/opt-in/entrypoints/yes.js +1 -0
  290. package/dist/safe-bash/opt-in/entrypoints/yq.d.ts +3 -0
  291. package/dist/safe-bash/opt-in/entrypoints/yq.js +1 -0
  292. package/dist/safe-bash/opt-in/fs/devices/index.d.ts +8 -0
  293. package/dist/safe-bash/opt-in/fs/devices/index.js +292 -0
  294. package/dist/safe-bash/opt-in/optional.d.ts +28 -0
  295. package/dist/safe-bash/opt-in/optional.js +14 -0
  296. package/dist/safe-bash/opt-in/shell/extensions/arrays/index.d.ts +2 -0
  297. package/dist/safe-bash/opt-in/shell/extensions/arrays/index.js +4 -0
  298. package/dist/safe-bash/opt-in/shell/extensions/jobs/index.d.ts +2 -0
  299. package/dist/safe-bash/opt-in/shell/extensions/jobs/index.js +291 -0
  300. package/dist/safe-bash/opt-in/shell/extensions/jobs/state.js +374 -0
  301. package/dist/safe-bash/opt-in/shell/extensions/mapfile/index.d.ts +24 -0
  302. package/dist/safe-bash/opt-in/shell/extensions/mapfile/index.js +338 -0
  303. package/dist/safe-bash/opt-in/shell/extensions/read/index.d.ts +5 -0
  304. package/dist/safe-bash/opt-in/shell/extensions/read/index.js +351 -0
  305. package/dist/safe-bash/opt-in/shell/extensions/trap/index.d.ts +9 -0
  306. package/dist/safe-bash/opt-in/shell/extensions/trap/index.js +210 -0
  307. package/dist/safe-bash/optional-host.d.ts +5 -0
  308. package/dist/safe-bash/optional-host.d.ts.map +1 -0
  309. package/dist/safe-bash/optional-host.js +3 -0
  310. package/dist/safe-bash/optional-host.js.map +1 -0
  311. package/dist/safe-bash/shell/arrays/bindings.d.ts +15 -5
  312. package/dist/safe-bash/shell/arrays/bindings.d.ts.map +1 -1
  313. package/dist/safe-bash/shell/arrays/bindings.js +131 -23
  314. package/dist/safe-bash/shell/arrays/bindings.js.map +1 -1
  315. package/dist/safe-bash/shell/arrays/ledger.d.ts +1 -0
  316. package/dist/safe-bash/shell/arrays/ledger.d.ts.map +1 -1
  317. package/dist/safe-bash/shell/arrays/ledger.js +19 -0
  318. package/dist/safe-bash/shell/arrays/ledger.js.map +1 -1
  319. package/dist/safe-bash/shell/arrays/state.d.ts.map +1 -1
  320. package/dist/safe-bash/shell/arrays/state.js +3 -1
  321. package/dist/safe-bash/shell/arrays/state.js.map +1 -1
  322. package/dist/safe-bash/shell/arrays/syntax.d.ts +4 -1
  323. package/dist/safe-bash/shell/arrays/syntax.d.ts.map +1 -1
  324. package/dist/safe-bash/shell/arrays/syntax.js +3 -3
  325. package/dist/safe-bash/shell/arrays/syntax.js.map +1 -1
  326. package/dist/safe-bash/shell/conditional.js +1 -1
  327. package/dist/safe-bash/shell/descriptors.d.ts +31 -0
  328. package/dist/safe-bash/shell/descriptors.d.ts.map +1 -0
  329. package/dist/safe-bash/shell/descriptors.js +234 -0
  330. package/dist/safe-bash/shell/descriptors.js.map +1 -0
  331. package/dist/safe-bash/shell/diagnostic-name-ranges.d.ts +2 -0
  332. package/dist/safe-bash/shell/diagnostic-name-ranges.d.ts.map +1 -0
  333. package/dist/safe-bash/shell/diagnostic-name-ranges.js +717 -0
  334. package/dist/safe-bash/shell/diagnostic-name-ranges.js.map +1 -0
  335. package/dist/safe-bash/shell/diagnostic-name.d.ts +3 -0
  336. package/dist/safe-bash/shell/diagnostic-name.d.ts.map +1 -0
  337. package/dist/safe-bash/shell/diagnostic-name.js +89 -0
  338. package/dist/safe-bash/shell/diagnostic-name.js.map +1 -0
  339. package/dist/safe-bash/shell/display.js +1 -1
  340. package/dist/safe-bash/shell/display.js.map +1 -1
  341. package/dist/safe-bash/shell/extensions.d.ts +188 -0
  342. package/dist/safe-bash/shell/extensions.d.ts.map +1 -0
  343. package/dist/safe-bash/shell/extensions.js +141 -0
  344. package/dist/safe-bash/shell/extensions.js.map +1 -0
  345. package/dist/safe-bash/shell/input.d.ts +66 -14
  346. package/dist/safe-bash/shell/input.d.ts.map +1 -1
  347. package/dist/safe-bash/shell/input.js +947 -173
  348. package/dist/safe-bash/shell/input.js.map +1 -1
  349. package/dist/safe-bash/shell/parser.d.ts +38 -6
  350. package/dist/safe-bash/shell/parser.d.ts.map +1 -1
  351. package/dist/safe-bash/shell/parser.js +339 -52
  352. package/dist/safe-bash/shell/parser.js.map +1 -1
  353. package/dist/safe-bash/shell/runtime.d.ts +92 -20
  354. package/dist/safe-bash/shell/runtime.d.ts.map +1 -1
  355. package/dist/safe-bash/shell/runtime.js +2547 -689
  356. package/dist/safe-bash/shell/runtime.js.map +1 -1
  357. package/dist/safe-bash/shell/shell.d.ts.map +1 -1
  358. package/dist/safe-bash/shell/shell.js +52 -21
  359. package/dist/safe-bash/shell/shell.js.map +1 -1
  360. package/dist/safe-bash/shell/types.d.ts +4 -0
  361. package/dist/safe-bash/shell/types.d.ts.map +1 -1
  362. package/dist/safe-bash/shell/types.js.map +1 -1
  363. package/package.json +99 -5
  364. package/dist/safe-bash/chunks/chunk-4DBWBEU7.js +0 -194
  365. package/dist/safe-bash/chunks/chunk-4DBWBEU7.js.map +0 -7
  366. package/dist/safe-bash/chunks/chunk-CXMIIXJA.js +0 -178
  367. package/dist/safe-bash/chunks/chunk-CXMIIXJA.js.map +0 -7
  368. package/dist/safe-bash/chunks/chunk-HHJSJWUD.js.map +0 -7
  369. /package/dist/safe-bash/chunks/{bz2-B2RXT4EX.js.map → bz2-ACU4EOVE.js.map} +0 -0
  370. /package/dist/safe-bash/chunks/{chunk-RNKTWFEM.js.map → chunk-CDBQXRWL.js.map} +0 -0
  371. /package/dist/safe-bash/chunks/{chunk-AFH57PPL.js.map → chunk-IEKESMO4.js.map} +0 -0
  372. /package/dist/safe-bash/chunks/{chunk-DPJWEGIX.js.map → chunk-JLBIUYT3.js.map} +0 -0
  373. /package/dist/safe-bash/chunks/{chunk-PVJJFCGA.js.map → chunk-M3GPCYSP.js.map} +0 -0
  374. /package/dist/safe-bash/chunks/{chunk-2KL6W6NB.js.map → chunk-O2EVBRKF.js.map} +0 -0
  375. /package/dist/safe-bash/chunks/{chunk-C7QNJ3D4.js.map → chunk-WYTI64IU.js.map} +0 -0
  376. /package/dist/safe-bash/chunks/{xz-AVXFDXW4.js.map → xz-U4QDTPZL.js.map} +0 -0
  377. /package/dist/safe-bash/chunks/{zstd-R6RPHJYO.js.map → zstd-OG5RPYXO.js.map} +0 -0
@@ -0,0 +1,183 @@
1
+ import { MikeError } from "./native-work.js";
2
+ const 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 };
3
+ const functions = new Set(["select", "map", "has", "length", "keys", "tag", "type", "kind", "style", "documentIndex", "di", "fileIndex", "fi", "filename", "env", "strenv", "del", "not"]);
4
+ export function compileExpression(source) {
5
+ if (Buffer.byteLength(source) > 8192)
6
+ throw new MikeError("yq limit exceeded: expression bytes");
7
+ const tokens = [];
8
+ let offset = 0;
9
+ while (offset < source.length) {
10
+ const character = source[offset];
11
+ if (/\s/u.test(character)) {
12
+ offset++;
13
+ continue;
14
+ }
15
+ const start = offset;
16
+ if (character === "#") {
17
+ while (offset < source.length && source[offset] !== "\n")
18
+ offset++;
19
+ continue;
20
+ }
21
+ if (character === '"') {
22
+ offset++;
23
+ let escaped = false;
24
+ while (offset < source.length) {
25
+ const next = source[offset++];
26
+ if (!escaped && next === '"')
27
+ break;
28
+ if (!escaped && next === "\\")
29
+ escaped = true;
30
+ else
31
+ escaped = false;
32
+ }
33
+ const text = source.slice(start, offset);
34
+ try {
35
+ JSON.parse(text);
36
+ }
37
+ catch {
38
+ throw new MikeError("bad expression, please check expression syntax");
39
+ }
40
+ tokens.push({ text, offset: start, kind: "string" });
41
+ continue;
42
+ }
43
+ const number = /^(?:[0-9]+(?:\.[0-9]+)?)(?:[eE][+-]?[0-9]+)?/u.exec(source.slice(offset));
44
+ if (number) {
45
+ tokens.push({ text: number[0], offset, kind: "number" });
46
+ offset += number[0].length;
47
+ continue;
48
+ }
49
+ const name = /^[A-Za-z_][A-Za-z_0-9-]*/u.exec(source.slice(offset));
50
+ if (name) {
51
+ tokens.push({ text: name[0], offset, kind: "name" });
52
+ offset += name[0].length;
53
+ continue;
54
+ }
55
+ const symbol = /^(?:\|=|=c|\+=|-=|\*=|\/=|==|!=|>=|<=|\/\/|\.\.|[.\[\]{}(),:|+*/%<>=-])/u.exec(source.slice(offset));
56
+ if (!symbol)
57
+ throw new MikeError(`1:${offset + 1}: lexer: invalid input text ${JSON.stringify(source.slice(offset))}`);
58
+ tokens.push({ text: symbol[0], offset, kind: "symbol" });
59
+ offset += symbol[0].length;
60
+ }
61
+ tokens.push({ text: "", offset, kind: "end" });
62
+ let position = 0;
63
+ let nesting = 0;
64
+ const peek = () => tokens[position];
65
+ const take = () => tokens[position++];
66
+ const expect = (text) => { if (take().text !== text)
67
+ throw new MikeError("bad expression, please check expression syntax"); };
68
+ const literal = (value) => ({ kind: "literal", value });
69
+ const parse = (minimum = 0) => {
70
+ if (++nesting > 64)
71
+ throw new MikeError("yq limit exceeded: expression depth");
72
+ const token = take();
73
+ let result;
74
+ if (token.text === ".") {
75
+ result = { kind: "identity" };
76
+ if (peek().kind === "name" || peek().kind === "string") {
77
+ const key = take();
78
+ result = { kind: "field", base: result, key: literal(key.kind === "string" ? JSON.parse(key.text) : key.text) };
79
+ }
80
+ }
81
+ else if (token.text === "..")
82
+ result = { kind: "recursive" };
83
+ else if (token.text === "(") {
84
+ result = { kind: "group", body: parse() };
85
+ expect(")");
86
+ }
87
+ else if (token.text === "[") {
88
+ result = peek().text === "]" ? { kind: "array" } : { kind: "array", body: parse() };
89
+ expect("]");
90
+ }
91
+ else if (token.text === "{") {
92
+ const fields = [];
93
+ while (peek().text !== "}") {
94
+ const key = take();
95
+ if (key.kind === "name")
96
+ throw new MikeError(`1:${key.offset + 1}: lexer: invalid input text ${JSON.stringify(source.slice(key.offset))}`);
97
+ if (key.kind !== "string")
98
+ throw new MikeError("bad expression, please check expression syntax");
99
+ expect(":");
100
+ fields.push({ key: literal(key.kind === "string" ? JSON.parse(key.text) : key.text), value: parse(3) });
101
+ if (peek().text !== ",")
102
+ break;
103
+ take();
104
+ }
105
+ expect("}");
106
+ result = { kind: "object", fields };
107
+ }
108
+ else if (token.text === "-")
109
+ result = { kind: "binary", operator: "*", left: literal(-1n), right: parse(10) };
110
+ else if (token.kind === "number")
111
+ result = literal(/[.eE]/u.test(token.text) ? Number(token.text) : BigInt(token.text));
112
+ else if (token.kind === "string")
113
+ result = literal(JSON.parse(token.text));
114
+ else if (["true", "false", "null"].includes(token.text))
115
+ result = literal(JSON.parse(token.text));
116
+ else if (functions.has(token.text)) {
117
+ const args = [];
118
+ if (peek().text === "(") {
119
+ take();
120
+ if (token.text === "env" || token.text === "strenv")
121
+ args.push(literal(take().text));
122
+ else if (peek().text !== ")")
123
+ args.push(parse());
124
+ expect(")");
125
+ }
126
+ const needsArgument = ["select", "map", "has", "env", "strenv", "del"].includes(token.text);
127
+ if (needsArgument && args.length === 0)
128
+ throw new MikeError(`'${token.text}' expects 1 arg but received none`);
129
+ if (!needsArgument && args.length)
130
+ throw new MikeError("bad expression, please check expression syntax");
131
+ result = { kind: "call", name: token.text, args };
132
+ }
133
+ else if (token.kind === "end" && tokens.some(item => item.text === "["))
134
+ throw new MikeError("bad expression, could not find matching `]`");
135
+ else
136
+ throw new MikeError(`1:${token.offset + 1}: lexer: invalid input text ${JSON.stringify(source.slice(token.offset))}`);
137
+ while (true) {
138
+ if (peek().text === ".") {
139
+ take();
140
+ const key = take();
141
+ result = { kind: "field", base: result, key: literal(key.kind === "string" ? JSON.parse(key.text) : key.text) };
142
+ continue;
143
+ }
144
+ if (peek().text === "[") {
145
+ take();
146
+ if (peek().text === "]")
147
+ result = { kind: "pipe", operator: "|", left: result, right: { kind: "iterate" } };
148
+ else {
149
+ const start = peek().text === ":" ? literal(0n) : parse();
150
+ if (peek().text === ":") {
151
+ take();
152
+ const end = peek().text === "]" ? { kind: "call", name: "length", args: [] } : parse();
153
+ result = { kind: "slice", base: result, start, end };
154
+ }
155
+ else
156
+ result = { kind: "field", base: result, key: start };
157
+ }
158
+ expect("]");
159
+ continue;
160
+ }
161
+ if ((peek().text === "tag" || peek().text === "style") && minimum <= 3) {
162
+ result = { kind: "pipe", operator: "|", left: result, right: { kind: "call", name: take().text, args: [] } };
163
+ continue;
164
+ }
165
+ const operator = peek().text;
166
+ const priority = priorities[operator];
167
+ if (priority === undefined || priority < minimum)
168
+ break;
169
+ take();
170
+ if (operator === "//" && peek().text === "=")
171
+ throw new MikeError("'//' expects 2 args but there is 1");
172
+ result = { kind: operator === "|" ? "pipe" : "binary", operator, left: result, right: parse(priority + (priority === 3 ? 0 : 1)) };
173
+ }
174
+ nesting--;
175
+ return result;
176
+ };
177
+ if (!source.trim())
178
+ return { kind: "identity" };
179
+ const result = parse();
180
+ if (peek().kind !== "end")
181
+ throw new MikeError("bad expression, please check expression syntax");
182
+ return result;
183
+ }
@@ -0,0 +1,65 @@
1
+ import { randomBytes } from "node:crypto";
2
+ import { retainFileSystemCleanup } from "@poe-platform/safe-fs/core";
3
+ import { FsError } from "@poe-platform/safe-bash/contracts/index";
4
+ import { writeFileOutputCounted } from "@poe-platform/safe-bash/contracts/filesystem-output";
5
+ import { MikeError } from "./native-work.js";
6
+ export async function publishInPlace(path, data, original, work) {
7
+ const fs = work.context.fs;
8
+ const parent = path.slice(0, path.lastIndexOf("/")) || "/";
9
+ const temporary = `${parent === "/" ? "" : parent}/.yq-${randomBytes(12).toString("hex")}`;
10
+ let created = false;
11
+ const capabilities = fs.capabilitiesFor ? await work.track(fs.capabilitiesFor(parent, { signal: work.signal })) : fs.capabilities;
12
+ work.assertOpen();
13
+ if (!capabilities.write || !capabilities.exclusiveCreate || !capabilities.remove)
14
+ throw new MikeError("in-place update requires VFS write, exclusive creation and removal capabilities");
15
+ const outputContext = { signal: work.signal, ...(work.context.registerCleanup ? { registerCleanup: work.context.registerCleanup } : {}) };
16
+ let settled;
17
+ const writerDone = new Promise(resolve => { settled = resolve; });
18
+ work.register(retainFileSystemCleanup(fs, async (cleanup) => {
19
+ await writerDone;
20
+ if (created) {
21
+ try {
22
+ await cleanup.rm(temporary);
23
+ }
24
+ catch (error) {
25
+ if (!(error instanceof FsError) || error.code !== "ENOENT")
26
+ throw error;
27
+ }
28
+ }
29
+ }, { maxOperations: 1 }));
30
+ try {
31
+ await work.track(writeFileOutputCounted(outputContext, data, async () => {
32
+ await fs.writeFile(temporary, data, { flag: "wx", mode: original.mode & 0o7777, signal: work.signal });
33
+ created = true;
34
+ return data.byteLength;
35
+ }));
36
+ }
37
+ finally {
38
+ settled();
39
+ }
40
+ work.assertOpen();
41
+ if (fs.chmod && capabilities.permissions) {
42
+ await work.track(fs.chmod(temporary, original.mode & 0o7777, { signal: work.signal }));
43
+ work.assertOpen();
44
+ }
45
+ const target = await work.track(fs.lstat(path, { signal: work.signal }));
46
+ work.assertOpen();
47
+ if (target.type !== "symlink" && capabilities.rename) {
48
+ try {
49
+ await work.track(fs.rename(temporary, path, { signal: work.signal }));
50
+ created = false;
51
+ work.assertOpen();
52
+ return;
53
+ }
54
+ catch (error) {
55
+ work.assertOpen();
56
+ if (!(error instanceof FsError))
57
+ throw error;
58
+ }
59
+ }
60
+ await work.track(writeFileOutputCounted(outputContext, data, async () => {
61
+ await fs.writeFile(path, data, { flag: "w", signal: work.signal });
62
+ return data.byteLength;
63
+ }));
64
+ work.assertOpen();
65
+ }
@@ -0,0 +1,9 @@
1
+ import { type CommandDefinition, type VirtualShellPlugin } from "@poe-platform/safe-bash/contracts/index";
2
+ import { type MikeLimits } from "./native-work.js";
3
+ export interface MikeYqOptions {
4
+ readonly limits?: Partial<MikeLimits>;
5
+ readonly replace?: boolean;
6
+ }
7
+ export declare function createMikeYqCommand(options?: MikeYqOptions): CommandDefinition;
8
+ export declare function createMikeYqCommands(options?: MikeYqOptions): readonly CommandDefinition[];
9
+ export declare function mikeYqCommands(options?: MikeYqOptions): VirtualShellPlugin;
@@ -0,0 +1,192 @@
1
+ import { commandRuntimeIdentity, FsError } from "@poe-platform/safe-bash/contracts/index";
2
+ import { mikeCommandMode, mikeFormat, mikeHelp, mikeUsage, mikeEvalHelp, mikeAllHelp, parseMikeArguments } from "./arguments.js";
3
+ import { compileExpression } from "./expression.js";
4
+ import { Evaluator } from "./evaluate.js";
5
+ import { decodeDocuments, loadYaml, root, scalar, truth } from "./nodes.js";
6
+ import { encodeNative } from "./native-encoder.js";
7
+ import { limitsFor, MikeError, NativeWork } from "./native-work.js";
8
+ import { publishInPlace } from "./inplace.js";
9
+ function pathOf(context, name) {
10
+ if (name.includes("\0"))
11
+ throw new MikeError("path contains NUL");
12
+ return name.startsWith("/") ? name : `${context.cwd.endsWith("/") ? context.cwd : `${context.cwd}/`}${name}`;
13
+ }
14
+ async function runCommand(context, limits, work) {
15
+ const commandMode = mikeCommandMode(context.args);
16
+ try {
17
+ const options = parseMikeArguments(context);
18
+ if (options.help || options.version) {
19
+ const text = options.help ? commandMode === "eval-all" ? mikeAllHelp : commandMode === "eval" ? mikeEvalHelp : mikeHelp : "yq (safe-bash; bounded Mike Farah v4.53.3 profile)\n";
20
+ work.output(Buffer.byteLength(text));
21
+ await work.write(Buffer.from(text));
22
+ return { exitCode: 0 };
23
+ }
24
+ let expression = options.expression;
25
+ const operands = [...options.operands];
26
+ if (expression === undefined && operands.length && operands[0] !== "-") {
27
+ let exists = false;
28
+ try {
29
+ exists = (await work.track(context.fs.stat(pathOf(context, operands[0]), { signal: work.signal }))).type !== "directory";
30
+ }
31
+ catch (error) {
32
+ work.assertOpen();
33
+ if (!(error instanceof FsError))
34
+ throw error;
35
+ }
36
+ if (!exists)
37
+ expression = operands.shift();
38
+ }
39
+ expression ??= ".";
40
+ if (options.inplace && (!operands.length || operands[0] === "-"))
41
+ throw new MikeError("write in place flag only applicable when giving an expression and at least one file");
42
+ if (options.nullInput && operands.length)
43
+ throw new MikeError("cannot pass files in when using null-input flag");
44
+ const inputOption = mikeFormat(options.input);
45
+ const outputOption = mikeFormat(options.output);
46
+ const inferred = operands[0]?.toLowerCase().endsWith(".json") ? "json" : "yaml";
47
+ const format = inputOption === "auto" ? inferred : inputOption;
48
+ const output = outputOption === "auto" ? inputOption === "auto" ? inferred : "yaml" : outputOption;
49
+ const program = compileExpression(expression);
50
+ const yaml = await work.track(loadYaml());
51
+ work.assertOpen();
52
+ const evaluator = new Evaluator(yaml, work, options.mergeSpec);
53
+ const results = [];
54
+ let qualified = false;
55
+ let previous;
56
+ let original;
57
+ if (options.inplace) {
58
+ original = await work.track(context.fs.stat(pathOf(context, operands[0]), { signal: work.signal }));
59
+ work.assertOpen();
60
+ }
61
+ const print = async (candidates) => {
62
+ for (const candidate of candidates) {
63
+ await work.tick();
64
+ const separator = previous && (previous.fileIndex !== candidate.document.fileIndex || previous.documentIndex !== candidate.document.documentIndex) && output === "yaml" && !options.noDoc ? "---\n" : "";
65
+ const text = separator + await encodeNative(candidate, { format: output, indent: options.indent, unwrap: options.unwrap ?? output === "yaml", compactSequence: options.compactSequence }, yaml, work);
66
+ work.output(Buffer.byteLength(text));
67
+ if (options.inplace)
68
+ results.push(text);
69
+ else
70
+ await work.write(Buffer.from(text));
71
+ qualified ||= truth(candidate.node, yaml);
72
+ previous = candidate.document;
73
+ }
74
+ };
75
+ const all = [];
76
+ if (options.nullInput) {
77
+ const doc = new yaml.Document();
78
+ doc.contents = scalar(yaml, work, null);
79
+ await print(await evaluator.run(program, [root({ doc, filename: "", fileIndex: 0, documentIndex: 0, format: "yaml" })]));
80
+ }
81
+ else {
82
+ for (const [fileIndex, filename] of (operands.length ? operands : ["-"]).entries()) {
83
+ let bytes;
84
+ if (filename === "-")
85
+ bytes = await work.collect(() => context.stdin);
86
+ else {
87
+ const path = pathOf(context, filename);
88
+ try {
89
+ if (context.fs.readStream)
90
+ bytes = await work.collect(() => context.fs.readStream(path, { signal: work.signal }));
91
+ else {
92
+ bytes = await work.track(context.fs.readFile(path, { signal: work.signal, maxBytes: limits.maxInputBytes }));
93
+ work.input(bytes.length);
94
+ }
95
+ }
96
+ catch (error) {
97
+ work.assertOpen();
98
+ if (error instanceof FsError) {
99
+ 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];
100
+ if (description)
101
+ throw new MikeError(`${error.code === "EISDIR" ? "read" : "open"} ${filename}: ${description}`);
102
+ }
103
+ throw error;
104
+ }
105
+ }
106
+ work.assertOpen();
107
+ let text;
108
+ try {
109
+ text = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
110
+ }
111
+ catch {
112
+ throw new MikeError(`bad file '${filename}': invalid UTF-8`);
113
+ }
114
+ await decodeDocuments(text, filename, fileIndex, format, yaml, work, async (document) => {
115
+ if (options.all) {
116
+ if (all.length >= limits.maxDocuments)
117
+ throw new MikeError("yq limit exceeded: maxDocuments");
118
+ all.push(root(document));
119
+ }
120
+ else
121
+ await print(await evaluator.run(program, [root(document)]));
122
+ });
123
+ }
124
+ if (options.all)
125
+ await print(await evaluator.run(program, all));
126
+ }
127
+ if (options.exitStatus && !qualified)
128
+ throw new MikeError("no matches found");
129
+ if (options.inplace)
130
+ await publishInPlace(pathOf(context, operands[0]), Buffer.from(results.join("")), original, work);
131
+ return { exitCode: 0 };
132
+ }
133
+ catch (error) {
134
+ context.signal.throwIfAborted();
135
+ work.assertOpen();
136
+ if (error instanceof MikeError) {
137
+ const selected = commandMode === "eval-all" ? mikeAllHelp : commandMode === "eval" ? mikeEvalHelp : undefined;
138
+ const usage = selected ? selected.slice(selected.indexOf("Usage:")) + "\n" : mikeUsage;
139
+ const message = `Error: ${error.message}\n${error.usage ? usage : ""}`;
140
+ await work.write(Buffer.from(Buffer.byteLength(message) <= 65536 ? message : "Error: yq diagnostic exceeds safety limit\n"), true);
141
+ return { exitCode: 1 };
142
+ }
143
+ if (error instanceof FsError) {
144
+ await work.write(Buffer.from(Buffer.byteLength(error.message) < 65520 ? `Error: ${error.message}\n` : "Error: yq diagnostic exceeds safety limit\n"), true);
145
+ return { exitCode: 1 };
146
+ }
147
+ throw error;
148
+ }
149
+ }
150
+ async function execute(context, limits) {
151
+ const work = new NativeWork(context, limits);
152
+ let result;
153
+ let primary;
154
+ let failed = false;
155
+ try {
156
+ result = await runCommand(context, limits, work);
157
+ }
158
+ catch (error) {
159
+ failed = true;
160
+ primary = error;
161
+ }
162
+ try {
163
+ await work.close();
164
+ }
165
+ catch (error) {
166
+ if (!failed) {
167
+ failed = true;
168
+ primary = error;
169
+ }
170
+ }
171
+ context.signal.throwIfAborted();
172
+ if (failed)
173
+ throw primary;
174
+ return result;
175
+ }
176
+ export function createMikeYqCommand(options = {}) {
177
+ if (!options || typeof options !== "object" || Array.isArray(options) || Object.keys(options).some(key => key !== "limits" && key !== "replace") || options.replace !== undefined && typeof options.replace !== "boolean")
178
+ throw new TypeError("invalid yq options");
179
+ const limits = limitsFor(options.limits);
180
+ return Object.freeze({ name: "yq", runtimeIdentity: commandRuntimeIdentity, async execute(context) { return execute(context, limits); } });
181
+ }
182
+ export function createMikeYqCommands(options = {}) {
183
+ return Object.freeze([createMikeYqCommand(options)]);
184
+ }
185
+ export function mikeYqCommands(options = {}) {
186
+ const definitions = createMikeYqCommands(options);
187
+ const replace = options.replace ?? false;
188
+ return Object.freeze({ name: "mike-yq-commands", setup(host) {
189
+ for (const definition of definitions)
190
+ host.commands.register(definition, { replace });
191
+ } });
192
+ }
@@ -0,0 +1,165 @@
1
+ import { cloneNode, dereference, inspectNode } from "./nodes.js";
2
+ import { mikeLimits, MikeError } from "./native-work.js";
3
+ export async function encodeNative(candidate, options, yaml, work) {
4
+ await inspectNode(candidate.node, yaml, work);
5
+ if (options.indent > work.limits.maxOutputBytes)
6
+ throw new MikeError("yq limit exceeded: maxOutputBytes");
7
+ const spacing = Math.max(0, options.indent);
8
+ const chunks = [];
9
+ let bytes = 0;
10
+ const append = (text) => {
11
+ const incoming = Buffer.byteLength(text);
12
+ if (incoming > work.limits.maxOutputBytes - bytes)
13
+ throw new MikeError("yq limit exceeded: maxOutputBytes");
14
+ bytes += incoming;
15
+ chunks.push(text);
16
+ };
17
+ const indent = (depth) => {
18
+ const count = spacing * depth;
19
+ if (count > work.limits.maxOutputBytes - bytes)
20
+ throw new MikeError("yq limit exceeded: maxOutputBytes");
21
+ append(" ".repeat(count));
22
+ };
23
+ const primitive = (node) => {
24
+ if (!yaml.isScalar(node) || node.value == null)
25
+ return "null";
26
+ if (typeof node.value === "bigint")
27
+ return node.value.toString();
28
+ if (typeof node.value === "number" && !Number.isFinite(node.value))
29
+ return node.value === Infinity ? ".inf" : node.value === -Infinity ? "-.inf" : ".nan";
30
+ return String(node.value);
31
+ };
32
+ if (options.format === "yaml" && yaml.isScalar(candidate.node) && candidate.node.value === null && (candidate.node.source === "" || candidate.document.filename === "")) {
33
+ return candidate.document.doc.directives?.docStart && candidate.node === candidate.document.doc.contents ? "---\n" : "\n";
34
+ }
35
+ if (options.unwrap && yaml.isScalar(candidate.node))
36
+ return `${candidate.node.source ?? primitive(candidate.node)}\n`;
37
+ if (options.format === "json") {
38
+ const write = async (current, depth) => {
39
+ await work.tick();
40
+ work.depth(depth);
41
+ const base = dereference(current, yaml, work);
42
+ const node = base.node;
43
+ if (yaml.isScalar(node)) {
44
+ if (typeof node.value === "number" && !Number.isFinite(node.value)) {
45
+ 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`);
46
+ }
47
+ 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);
48
+ 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";
49
+ if (typeof node.value === "string" && (custom || typed)) {
50
+ const text = node.value;
51
+ if (/^[+-]?[0-9]+$/u.test(text))
52
+ append(BigInt(text).toString());
53
+ else if (/^[+-]?[0-9]+\.[0-9]+$/u.test(text))
54
+ append(JSON.stringify(Number(text)));
55
+ else if (["true", "false", "null"].includes(text))
56
+ append(text);
57
+ else
58
+ throw new MikeError(`cannot encode ${node.tag} value as JSON`);
59
+ }
60
+ 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))
61
+ append(node.source);
62
+ else
63
+ append(typeof node.value === "string" ? JSON.stringify(node.value) : primitive(node));
64
+ return;
65
+ }
66
+ if (yaml.isAlias(node))
67
+ throw new MikeError("cyclic YAML alias");
68
+ const map = yaml.isMap(node);
69
+ append(map ? "{" : "[");
70
+ const items = node.items;
71
+ for (let index = 0; index < items.length; index++) {
72
+ if (index)
73
+ append(",");
74
+ if (spacing) {
75
+ append("\n");
76
+ indent(depth + 1);
77
+ }
78
+ let child;
79
+ if (map) {
80
+ const pair = node.items[index];
81
+ if (!yaml.isScalar(pair.key))
82
+ throw new MikeError("cannot encode complex YAML key as JSON");
83
+ append(JSON.stringify(String(pair.key.value)));
84
+ append(spacing ? ": " : ":");
85
+ child = pair.value;
86
+ }
87
+ else
88
+ child = items[index];
89
+ await write({ node: child, document: current.document }, depth + 1);
90
+ }
91
+ if (items.length && spacing) {
92
+ append("\n");
93
+ indent(depth);
94
+ }
95
+ append(map ? "}" : "]");
96
+ };
97
+ await write(candidate, 0);
98
+ append("\n");
99
+ return chunks.join("");
100
+ }
101
+ if (options.indent < 0)
102
+ throw new MikeError("indent must not be negative");
103
+ const pending = [{ node: candidate.node, depth: 0 }];
104
+ let projected = 0;
105
+ while (pending.length) {
106
+ const { node, depth } = pending.pop();
107
+ await work.tick();
108
+ projected += 32 + depth * Math.max(options.indent, 2) + 6 * Buffer.byteLength(node.comment ?? "") + 6 * Buffer.byteLength(node.commentBefore ?? "");
109
+ if (yaml.isScalar(node))
110
+ projected += 6 * Buffer.byteLength(String(node.value));
111
+ else if (yaml.isMap(node))
112
+ for (const pair of node.items) {
113
+ if (yaml.isScalar(pair.key) && pair.key.value === "<<" && pair.key.type === "PLAIN")
114
+ pair.key.tag = "tag:yaml.org,2002:merge";
115
+ pending.push({ node: pair.key, depth: depth + 1 }, { node: pair.value, depth: depth + 1 });
116
+ }
117
+ else if (yaml.isSeq(node))
118
+ for (const child of node.items)
119
+ pending.push({ node: child, depth: depth + 1 });
120
+ if (projected > mikeLimits.maxOutputBytes)
121
+ throw new MikeError("yq limit exceeded: maxOutputBytes");
122
+ }
123
+ work.assertOpen();
124
+ const doc = new yaml.Document();
125
+ doc.schema.tags = doc.schema.tags.map(tag => {
126
+ if (!tag.stringify)
127
+ return tag;
128
+ const original = tag.stringify;
129
+ const stringify = (item, context, onComment, onChompKeep) => {
130
+ const node = item;
131
+ if (yaml.isScalar(node) && typeof node.value !== "string" && node.source)
132
+ return node.source;
133
+ return yaml.isCollection(node) ? node.toString(context, onComment, onChompKeep) : original(item, context, onComment, onChompKeep);
134
+ };
135
+ return { ...tag, stringify };
136
+ });
137
+ doc.contents = await cloneNode(candidate.node, yaml, work);
138
+ const formatting = [doc.contents];
139
+ while (formatting.length) {
140
+ const node = formatting.pop();
141
+ await work.tick();
142
+ if (work.implicitTags.has(node) && node.tag?.startsWith("tag:yaml.org,2002:"))
143
+ delete node.tag;
144
+ if (yaml.isScalar(node) && (node.type === "QUOTE_DOUBLE" || node.type === "QUOTE_SINGLE"))
145
+ node.value = node.source ?? String(node.value);
146
+ else if (yaml.isMap(node))
147
+ for (const pair of node.items) {
148
+ if (yaml.isNode(pair.key))
149
+ formatting.push(pair.key);
150
+ if (yaml.isNode(pair.value))
151
+ formatting.push(pair.value);
152
+ }
153
+ else if (yaml.isSeq(node))
154
+ for (const child of node.items)
155
+ if (yaml.isNode(child))
156
+ formatting.push(child);
157
+ }
158
+ if (candidate.node === candidate.document.doc.contents) {
159
+ doc.commentBefore = candidate.document.doc.commentBefore;
160
+ doc.comment = candidate.document.doc.comment;
161
+ }
162
+ const text = doc.toString({ indent: options.indent === 0 ? 4 : Math.max(2, options.indent), indentSeq: !options.compactSequence, flowCollectionPadding: false, lineWidth: 0, verifyAliasOrder: false });
163
+ append(text);
164
+ return chunks.join("");
165
+ }
@@ -0,0 +1,44 @@
1
+ import { type ByteSource, type CommandContext, type InvocationCleanup } from "@poe-platform/safe-bash/contracts/index";
2
+ export declare const mikeLimits: Readonly<{
3
+ maxInputBytes: number;
4
+ maxDocumentBytes: number;
5
+ maxScalarBytes: number;
6
+ maxNodes: 100000;
7
+ maxParserNodes: 4096;
8
+ maxDepth: 64;
9
+ maxAliases: 1024;
10
+ maxDocuments: 1024;
11
+ maxOutputBytes: number;
12
+ maxSteps: 8000000;
13
+ }>;
14
+ export type MikeLimits = {
15
+ readonly [Key in keyof typeof mikeLimits]: number;
16
+ };
17
+ export declare class MikeError extends Error {
18
+ readonly usage: boolean;
19
+ constructor(message: string, usage?: boolean);
20
+ }
21
+ export declare function limitsFor(options?: Partial<MikeLimits>): MikeLimits;
22
+ export declare class NativeWork {
23
+ #private;
24
+ readonly context: CommandContext;
25
+ readonly limits: MikeLimits;
26
+ readonly implicitTags: WeakSet<object>;
27
+ readonly controller: AbortController;
28
+ readonly signal: AbortSignal;
29
+ constructor(context: CommandContext, limits: MikeLimits);
30
+ assertOpen(): void;
31
+ tick(units?: number): Promise<void>;
32
+ input(bytes: number): void;
33
+ node(count?: number): void;
34
+ alias(): void;
35
+ document(): void;
36
+ depth(depth: number): void;
37
+ output(bytes: number): void;
38
+ register(cleanup: InvocationCleanup): void;
39
+ track<Value>(promise: Promise<Value>): Promise<Value>;
40
+ acquire<Value>(start: () => Value | Promise<Value>, release: (value: Value) => void | Promise<void>): Promise<Value>;
41
+ collect(start: () => ByteSource): Promise<Uint8Array>;
42
+ write(bytes: Uint8Array, stderr?: boolean): Promise<void>;
43
+ close(): Promise<void>;
44
+ }