@jerryan/just-bash 3.8.0 → 3.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +5 -15
  3. package/dist/AGENTS.md +2 -2
  4. package/dist/Bash.d.ts +2 -4
  5. package/dist/bin/chunks/builtin-manifest-ORBIZM7I.js +3 -0
  6. package/dist/bin/chunks/{chmod-GX5SYTRL.js → chmod-S4ARARR4.js} +1 -1
  7. package/dist/bin/chunks/chunk-3ASHUC7C.js +44 -0
  8. package/dist/bin/{shell/chunks/chunk-7WBCA2BB.js → chunks/chunk-3DWQCLNP.js} +1 -1
  9. package/dist/bin/{shell/chunks/chunk-3ROYEBJI.js → chunks/chunk-4JPWP5WS.js} +1 -1
  10. package/dist/bin/chunks/{chunk-QFTZKD5O.js → chunk-6TUILMPB.js} +1 -1
  11. package/dist/bin/chunks/{chunk-DRPHNXG7.js → chunk-7LGT4LHQ.js} +1 -1
  12. package/dist/bin/chunks/{chunk-MBREBDZQ.js → chunk-AIWBN36Z.js} +1 -1
  13. package/dist/bin/chunks/chunk-AQKIHX3Q.js +3 -0
  14. package/dist/bin/chunks/chunk-E2O6S35K.js +10 -0
  15. package/dist/bin/chunks/chunk-E54Z6VIE.js +12 -0
  16. package/dist/bin/{shell/chunks/chunk-F2PYTUMR.js → chunks/chunk-F4ACJZIY.js} +7 -6
  17. package/dist/bin/{shell/chunks/chunk-MPFNZYEA.js → chunks/chunk-GKJD4ULC.js} +1 -1
  18. package/dist/bin/{shell/chunks/chunk-QJWFCA7P.js → chunks/chunk-HARVZWUX.js} +1 -1
  19. package/dist/bin/chunks/chunk-IRCAXXH6.js +14 -0
  20. package/dist/bin/chunks/{chunk-T6OIISUC.js → chunk-K65FCSAT.js} +1 -1
  21. package/dist/bin/{shell/chunks/chunk-MF3GVFLC.js → chunks/chunk-L345YZ6R.js} +1 -1
  22. package/dist/bin/{shell/chunks/chunk-6FGMEZZP.js → chunks/chunk-MWQMHODV.js} +1 -1
  23. package/dist/bin/chunks/{chunk-BB5VTPMQ.js → chunk-NSI6LMDS.js} +1 -1
  24. package/dist/bin/{shell/chunks/chunk-ABP4OLJV.js → chunks/chunk-OXEDIWNZ.js} +1 -1
  25. package/dist/bin/chunks/chunk-QKJAAJ7J.js +3 -0
  26. package/dist/bin/chunks/{chunk-KMYJMEON.js → chunk-R7THHH4J.js} +1 -1
  27. package/dist/bin/chunks/chunk-UBA7DOWE.js +3 -0
  28. package/dist/bin/chunks/{chunk-VPSBWWXM.js → chunk-UNCYBFWT.js} +7 -6
  29. package/dist/bin/chunks/chunk-VMVXACZ5.js +6 -0
  30. package/dist/bin/chunks/chunk-Z3TCELKN.js +12 -0
  31. package/dist/bin/chunks/{cp-YLP7ULVT.js → cp-WRBRHVVD.js} +1 -1
  32. package/dist/bin/chunks/{diff-JSJ56EOK.js → diff-YLVT27CZ.js} +1 -1
  33. package/dist/bin/{shell/chunks/du-DH76GZJ3.js → chunks/du-YNAJTGCR.js} +1 -1
  34. package/dist/bin/{shell/chunks/find-MHC4QV6H.js → chunks/find-T3JZPTUX.js} +1 -1
  35. package/dist/bin/chunks/{flag-coverage-2H5CPEM6.js → flag-coverage-LVKHEUTL.js} +1 -1
  36. package/dist/bin/chunks/{gzip-UQZL4R74.js → gzip-EXJSFNCU.js} +1 -1
  37. package/dist/bin/chunks/js-exec-PLUMFEX6.js +99 -0
  38. package/dist/bin/chunks/js-exec-worker.js +4995 -0
  39. package/dist/bin/chunks/{ls-5Z45FV4U.js → ls-LOCOWLZ3.js} +1 -1
  40. package/dist/bin/chunks/{mkdir-YJ3SOVRP.js → mkdir-VHLJ3E65.js} +1 -1
  41. package/dist/bin/chunks/{mv-EOOP2TO3.js → mv-NAMOL2HF.js} +1 -1
  42. package/dist/bin/chunks/python3-J5GXF27H.js +14 -0
  43. package/dist/bin/{shell/chunks/readlink-EJ3IKLWW.js → chunks/readlink-BF435HNQ.js} +1 -1
  44. package/dist/bin/chunks/{rg-WHVR3YDT.js → rg-XF5U7GS2.js} +1 -1
  45. package/dist/bin/{shell/chunks/rm-B4LVIG7A.js → chunks/rm-L4RHENMV.js} +1 -1
  46. package/dist/bin/{shell/chunks/rmdir-PRNISPBA.js → chunks/rmdir-W73C4GEA.js} +1 -1
  47. package/dist/bin/{shell/chunks/sleep-DVFE2GSF.js → chunks/sleep-MOJQBZMY.js} +1 -1
  48. package/dist/bin/{shell/chunks/split-HIFKSV2A.js → chunks/split-2VXPZJJ4.js} +1 -1
  49. package/dist/bin/chunks/{sqlite3-KNN6V2W6.js → sqlite3-3S5HIA5W.js} +1 -1
  50. package/dist/bin/chunks/{timeout-YGFHQJKX.js → timeout-RQOWSWYG.js} +1 -1
  51. package/dist/bin/chunks/{which-4TPGVSBZ.js → which-G7X54RZL.js} +1 -1
  52. package/dist/bin/just-bash.js +243 -242
  53. package/dist/bin/shell/chunks/builtin-manifest-ORBIZM7I.js +3 -0
  54. package/dist/bin/shell/chunks/{chmod-GX5SYTRL.js → chmod-S4ARARR4.js} +1 -1
  55. package/dist/bin/shell/chunks/chunk-3ASHUC7C.js +44 -0
  56. package/dist/bin/{chunks/chunk-7WBCA2BB.js → shell/chunks/chunk-3DWQCLNP.js} +1 -1
  57. package/dist/bin/{chunks/chunk-3ROYEBJI.js → shell/chunks/chunk-4JPWP5WS.js} +1 -1
  58. package/dist/bin/shell/chunks/{chunk-QFTZKD5O.js → chunk-6TUILMPB.js} +1 -1
  59. package/dist/bin/shell/chunks/{chunk-DRPHNXG7.js → chunk-7LGT4LHQ.js} +1 -1
  60. package/dist/bin/shell/chunks/{chunk-MBREBDZQ.js → chunk-AIWBN36Z.js} +1 -1
  61. package/dist/bin/shell/chunks/chunk-AQKIHX3Q.js +3 -0
  62. package/dist/bin/shell/chunks/chunk-E2O6S35K.js +10 -0
  63. package/dist/bin/shell/chunks/chunk-E54Z6VIE.js +12 -0
  64. package/dist/bin/{chunks/chunk-F2PYTUMR.js → shell/chunks/chunk-F4ACJZIY.js} +7 -6
  65. package/dist/bin/{chunks/chunk-MPFNZYEA.js → shell/chunks/chunk-GKJD4ULC.js} +1 -1
  66. package/dist/bin/{chunks/chunk-QJWFCA7P.js → shell/chunks/chunk-HARVZWUX.js} +1 -1
  67. package/dist/bin/shell/chunks/chunk-IRCAXXH6.js +14 -0
  68. package/dist/bin/shell/chunks/{chunk-T6OIISUC.js → chunk-K65FCSAT.js} +1 -1
  69. package/dist/bin/{chunks/chunk-MF3GVFLC.js → shell/chunks/chunk-L345YZ6R.js} +1 -1
  70. package/dist/bin/{chunks/chunk-6FGMEZZP.js → shell/chunks/chunk-MWQMHODV.js} +1 -1
  71. package/dist/bin/shell/chunks/{chunk-BB5VTPMQ.js → chunk-NSI6LMDS.js} +1 -1
  72. package/dist/bin/{chunks/chunk-ABP4OLJV.js → shell/chunks/chunk-OXEDIWNZ.js} +1 -1
  73. package/dist/bin/shell/chunks/chunk-QKJAAJ7J.js +3 -0
  74. package/dist/bin/shell/chunks/{chunk-KMYJMEON.js → chunk-R7THHH4J.js} +1 -1
  75. package/dist/bin/shell/chunks/chunk-UBA7DOWE.js +3 -0
  76. package/dist/bin/shell/chunks/{chunk-VPSBWWXM.js → chunk-UNCYBFWT.js} +7 -6
  77. package/dist/bin/shell/chunks/chunk-VMVXACZ5.js +6 -0
  78. package/dist/bin/shell/chunks/chunk-Z3TCELKN.js +12 -0
  79. package/dist/bin/shell/chunks/{cp-YLP7ULVT.js → cp-WRBRHVVD.js} +1 -1
  80. package/dist/bin/shell/chunks/{diff-JSJ56EOK.js → diff-YLVT27CZ.js} +1 -1
  81. package/dist/bin/{chunks/du-DH76GZJ3.js → shell/chunks/du-YNAJTGCR.js} +1 -1
  82. package/dist/bin/{chunks/find-MHC4QV6H.js → shell/chunks/find-T3JZPTUX.js} +1 -1
  83. package/dist/bin/shell/chunks/{flag-coverage-2H5CPEM6.js → flag-coverage-LVKHEUTL.js} +1 -1
  84. package/dist/bin/shell/chunks/{gzip-UQZL4R74.js → gzip-EXJSFNCU.js} +1 -1
  85. package/dist/bin/shell/chunks/js-exec-PLUMFEX6.js +99 -0
  86. package/dist/bin/shell/chunks/{ls-5Z45FV4U.js → ls-LOCOWLZ3.js} +1 -1
  87. package/dist/bin/shell/chunks/{mkdir-YJ3SOVRP.js → mkdir-VHLJ3E65.js} +1 -1
  88. package/dist/bin/shell/chunks/{mv-EOOP2TO3.js → mv-NAMOL2HF.js} +1 -1
  89. package/dist/bin/shell/chunks/python3-J5GXF27H.js +14 -0
  90. package/dist/bin/{chunks/readlink-EJ3IKLWW.js → shell/chunks/readlink-BF435HNQ.js} +1 -1
  91. package/dist/bin/shell/chunks/{rg-WHVR3YDT.js → rg-XF5U7GS2.js} +1 -1
  92. package/dist/bin/{chunks/rm-B4LVIG7A.js → shell/chunks/rm-L4RHENMV.js} +1 -1
  93. package/dist/bin/{chunks/rmdir-PRNISPBA.js → shell/chunks/rmdir-W73C4GEA.js} +1 -1
  94. package/dist/bin/{chunks/sleep-DVFE2GSF.js → shell/chunks/sleep-MOJQBZMY.js} +1 -1
  95. package/dist/bin/{chunks/split-HIFKSV2A.js → shell/chunks/split-2VXPZJJ4.js} +1 -1
  96. package/dist/bin/shell/chunks/{sqlite3-KNN6V2W6.js → sqlite3-3S5HIA5W.js} +1 -1
  97. package/dist/bin/shell/chunks/{timeout-YGFHQJKX.js → timeout-RQOWSWYG.js} +1 -1
  98. package/dist/bin/shell/chunks/{which-4TPGVSBZ.js → which-G7X54RZL.js} +1 -1
  99. package/dist/bin/shell/shell.js +305 -304
  100. package/dist/bundle/browser.js +637 -611
  101. package/dist/bundle/chunks/builtin-manifest-7MJJDZ2T.js +2 -0
  102. package/dist/bundle/chunks/{chmod-TEY5MD2W.js → chmod-KMFNCMRX.js} +1 -1
  103. package/dist/bundle/chunks/chunk-2A4OZBCS.js +43 -0
  104. package/dist/bundle/chunks/{chunk-SE23TEGG.js → chunk-4CDTAUYP.js} +1 -1
  105. package/dist/bundle/chunks/chunk-4OKRFRMS.js +13 -0
  106. package/dist/bundle/chunks/{chunk-ATGOUOX2.js → chunk-4WRO2G22.js} +1 -1
  107. package/dist/bundle/chunks/{chunk-45QZRGYF.js → chunk-5KOWUQOZ.js} +7 -6
  108. package/dist/bundle/chunks/{chunk-6HO6HX7V.js → chunk-5NUTFEEG.js} +1 -1
  109. package/dist/bundle/chunks/{chunk-N3A4JVFJ.js → chunk-6IA4DXG2.js} +1 -1
  110. package/dist/bundle/chunks/{chunk-WE7BJ7YU.js → chunk-6IFH67ZB.js} +1 -1
  111. package/dist/bundle/chunks/chunk-6L6OYVLY.js +2 -0
  112. package/dist/bundle/chunks/chunk-BMBITA6Y.js +2 -0
  113. package/dist/bundle/chunks/chunk-BS6EJR2R.js +11 -0
  114. package/dist/bundle/chunks/{chunk-S6DNKKUL.js → chunk-CM4T4GB4.js} +1 -1
  115. package/dist/bundle/chunks/{chunk-MWL2I5BV.js → chunk-FXAKF2QS.js} +1 -1
  116. package/dist/bundle/chunks/chunk-H4AFUSSQ.js +9 -0
  117. package/dist/bundle/chunks/{chunk-GNPLDVBD.js → chunk-MMXJJCAE.js} +1 -1
  118. package/dist/bundle/chunks/{chunk-6QAM55HM.js → chunk-NFODJFHN.js} +1 -1
  119. package/dist/bundle/chunks/{chunk-LRFR25IP.js → chunk-O5OYOY3C.js} +7 -6
  120. package/dist/bundle/chunks/{chunk-HCKTU6IR.js → chunk-PASYAXFP.js} +1 -1
  121. package/dist/bundle/chunks/chunk-PS2RJNZZ.js +2 -0
  122. package/dist/bundle/chunks/chunk-THDUQVY3.js +11 -0
  123. package/dist/bundle/chunks/{chunk-DMWNBCXJ.js → chunk-TLPMB3FO.js} +1 -1
  124. package/dist/bundle/chunks/{chunk-FSKXIFYT.js → chunk-Y6UHNLT5.js} +1 -1
  125. package/dist/bundle/chunks/{chunk-XV2V56NQ.js → chunk-YFFU74KY.js} +1 -1
  126. package/dist/bundle/chunks/chunk-ZIQS5QAW.js +5 -0
  127. package/dist/bundle/chunks/{cp-UR762VVT.js → cp-P2D2L6PC.js} +1 -1
  128. package/dist/bundle/chunks/{diff-VDB6RXHO.js → diff-Z3XOLW44.js} +1 -1
  129. package/dist/bundle/chunks/{du-EQKH3UNA.js → du-YBSJVBXP.js} +1 -1
  130. package/dist/bundle/chunks/{find-RLKBCGJR.js → find-IUWEB4XQ.js} +1 -1
  131. package/dist/bundle/chunks/{flag-coverage-UMQ3BWDP.js → flag-coverage-SZ4AUPRQ.js} +1 -1
  132. package/dist/bundle/chunks/{gzip-KC5ENBD2.js → gzip-VUJBDHZ5.js} +1 -1
  133. package/dist/bundle/chunks/js-exec-6RW7WZCG.js +98 -0
  134. package/dist/bundle/chunks/js-exec-worker.js +4995 -0
  135. package/dist/bundle/chunks/{ls-WH5S4PPL.js → ls-ECKG2XHZ.js} +1 -1
  136. package/dist/bundle/chunks/{mkdir-Z6MMWH3D.js → mkdir-YL7XGMD7.js} +1 -1
  137. package/dist/bundle/chunks/{mv-WE7DBLEK.js → mv-IF55A2UD.js} +1 -1
  138. package/dist/bundle/chunks/python3-XHTOW7VA.js +13 -0
  139. package/dist/bundle/chunks/{readlink-JSRKXLLQ.js → readlink-7XGQ3PL7.js} +1 -1
  140. package/dist/bundle/chunks/{rg-JKB7DR66.js → rg-E6H2HACA.js} +1 -1
  141. package/dist/bundle/chunks/{rm-IGPLE632.js → rm-CWLMERIO.js} +1 -1
  142. package/dist/bundle/chunks/{rmdir-3WTXMVKI.js → rmdir-WKKBLZ54.js} +1 -1
  143. package/dist/bundle/chunks/{sleep-PPRBTSVR.js → sleep-25QUPVDK.js} +1 -1
  144. package/dist/bundle/chunks/{split-HUKVGJTW.js → split-NEU2K2YN.js} +1 -1
  145. package/dist/bundle/chunks/{sqlite3-KB3MXTTM.js → sqlite3-KJ5NMKBM.js} +1 -1
  146. package/dist/bundle/chunks/{timeout-C6WDYPLV.js → timeout-37GM7IIL.js} +1 -1
  147. package/dist/bundle/chunks/{which-UWVKETYW.js → which-BP5YY5BR.js} +1 -1
  148. package/dist/bundle/index.cjs +1134 -2660
  149. package/dist/bundle/index.js +210 -209
  150. package/dist/commands/js-exec/js-exec-worker.d.ts +35 -0
  151. package/dist/commands/js-exec/js-exec.d.ts +14 -1
  152. package/dist/commands/which/which.d.ts +10 -0
  153. package/dist/custom-commands.d.ts +5 -0
  154. package/dist/fs/path-utils.d.ts +0 -4
  155. package/dist/fs/vfs-template.d.ts +6 -0
  156. package/dist/interpreter/interpreter.d.ts +1 -1
  157. package/dist/interpreter/types.d.ts +1 -1
  158. package/dist/limits.d.ts +2 -5
  159. package/dist/timers.d.ts +9 -0
  160. package/dist/types.d.ts +9 -4
  161. package/package.json +8 -8
  162. package/dist/bin/chunks/chunk-2NJJXU4K.js +0 -27
  163. package/dist/bin/chunks/chunk-6JUPBMCR.js +0 -13
  164. package/dist/bin/chunks/chunk-CN4JKMTR.js +0 -8
  165. package/dist/bin/chunks/chunk-HWK7KFGB.js +0 -3
  166. package/dist/bin/chunks/chunk-PPVF2N6C.js +0 -3
  167. package/dist/bin/chunks/chunk-RTN6X652.js +0 -11
  168. package/dist/bin/chunks/chunk-RVPTAYDS.js +0 -4
  169. package/dist/bin/chunks/js-exec-T3SAB2B6.js +0 -1651
  170. package/dist/bin/chunks/python3-3ERN3L6S.js +0 -23
  171. package/dist/bin/shell/chunks/chunk-2NJJXU4K.js +0 -27
  172. package/dist/bin/shell/chunks/chunk-6JUPBMCR.js +0 -13
  173. package/dist/bin/shell/chunks/chunk-CN4JKMTR.js +0 -8
  174. package/dist/bin/shell/chunks/chunk-HWK7KFGB.js +0 -3
  175. package/dist/bin/shell/chunks/chunk-PPVF2N6C.js +0 -3
  176. package/dist/bin/shell/chunks/chunk-RTN6X652.js +0 -11
  177. package/dist/bin/shell/chunks/chunk-RVPTAYDS.js +0 -4
  178. package/dist/bin/shell/chunks/js-exec-T3SAB2B6.js +0 -1651
  179. package/dist/bin/shell/chunks/python3-3ERN3L6S.js +0 -23
  180. package/dist/bundle/chunks/chunk-2SMD2AUA.js +0 -3
  181. package/dist/bundle/chunks/chunk-3OBCZP7T.js +0 -12
  182. package/dist/bundle/chunks/chunk-4CC3OZPU.js +0 -2
  183. package/dist/bundle/chunks/chunk-A257L6QO.js +0 -7
  184. package/dist/bundle/chunks/chunk-B6OSJB22.js +0 -26
  185. package/dist/bundle/chunks/chunk-RWQWFXMH.js +0 -10
  186. package/dist/bundle/chunks/chunk-WXPNKIIH.js +0 -2
  187. package/dist/bundle/chunks/js-exec-ZQMIYQTH.js +0 -1650
  188. package/dist/bundle/chunks/python3-QB7OE256.js +0 -22
  189. package/dist/commands/js-exec/run-runtime.d.ts +0 -10
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Worker thread for JavaScript execution via QuickJS.
3
+ * Keeps QuickJS loaded and handles multiple execution requests.
4
+ *
5
+ * Defense-in-depth activates AFTER QuickJS loads (WASM init needs unrestricted JS).
6
+ * User JavaScript code runs inside the QuickJS sandbox with no access to Node.js globals.
7
+ *
8
+ * Build: Bundled to js-exec-worker.js via esbuild (see package.json "build:worker").
9
+ * Run: npx esbuild src/commands/js-exec/js-exec-worker.ts --bundle --platform=node --format=esm --outfile=src/commands/js-exec/js-exec-worker.js --external:quickjs-emscripten
10
+ */
11
+ import { type WorkerDefenseStats } from "../../security/index.js";
12
+ export interface JsExecWorkerInput {
13
+ protocolToken: string;
14
+ sharedBuffer: SharedArrayBuffer;
15
+ jsCode: string;
16
+ cwd: string;
17
+ env: Record<string, string>;
18
+ args: string[];
19
+ scriptPath?: string;
20
+ bootstrapCode?: string;
21
+ isModule?: boolean;
22
+ stripTypes?: boolean;
23
+ timeoutMs?: number;
24
+ /** QuickJS heap limit in bytes. Defaults to 64MB. */
25
+ memoryBytes?: number;
26
+ /** When true, the QuickJS guest gets a `tools` proxy that calls the host's invokeTool hook. */
27
+ hasInvokeTool?: boolean;
28
+ }
29
+ export interface JsExecWorkerOutput {
30
+ protocolToken?: string;
31
+ type?: "initialization-failure";
32
+ success: boolean;
33
+ error?: string;
34
+ defenseStats?: WorkerDefenseStats;
35
+ }
@@ -1,4 +1,17 @@
1
- /** js-exec - Execute JavaScript code via the run package. */
1
+ /**
2
+ * js-exec - Execute JavaScript code via QuickJS (WASM)
3
+ *
4
+ * Runs JavaScript code in an isolated worker thread with access to the
5
+ * virtual filesystem, HTTP, and sub-shell execution via SharedArrayBuffer bridge.
6
+ *
7
+ * This command is Node.js only (uses worker_threads).
8
+ */
2
9
  import type { RuntimeCommand } from "../../types.js";
10
+ /** @internal Set the idle-teardown delay — for focused lifecycle tests only. */
11
+ export declare function _setJsExecWorkerIdleTimeoutMsForTests(ms: number): void;
12
+ /** @internal Whether the shared worker is currently alive — for tests only. */
13
+ export declare function _hasSharedJsExecWorkerForTests(): boolean;
14
+ /** @internal Reset singleton worker state — for focused protocol tests only. */
15
+ export declare function _resetJsExecWorkerForTests(): void;
3
16
  export declare const jsExecCommand: RuntimeCommand;
4
17
  export declare const nodeStubCommand: RuntimeCommand;
@@ -1,3 +1,13 @@
1
+ /**
2
+ * which - Locate a command
3
+ *
4
+ * Resolution order:
5
+ * 1. VFS PATH search (sandboxed filesystem)
6
+ * 2. Shell builtins (echo, cd, etc.) — only when no file found
7
+ *
8
+ * On miss, prints a helpful message to stderr explaining that the
9
+ * command is not available in this sandboxed bash environment.
10
+ */
1
11
  import type { RuntimeCommand } from "../../types.js";
2
12
  export declare const whichCommand: RuntimeCommand;
3
13
  import type { CommandFuzzInfo } from "../fuzz-flags-types.js";
@@ -21,6 +21,11 @@ export interface LazyCommand {
21
21
  * trusted by default for compatibility with existing host integrations.
22
22
  */
23
23
  trusted?: boolean;
24
+ /**
25
+ * Set to true when the command handles --version itself. When unset,
26
+ * the dispatch intercepts --version and returns "<cmd> (just-bash)".
27
+ */
28
+ handlesOwnVersion?: boolean;
24
29
  load: () => Promise<Command>;
25
30
  }
26
31
  /** Inputs for a complete standalone command context, primarily for tests. */
@@ -30,10 +30,6 @@ export declare function validatePath(path: string, operation: string): void;
30
30
  * Get the directory name of a normalized virtual path.
31
31
  */
32
32
  export declare function dirname(path: string): string;
33
- /**
34
- * Resolve a relative path against a base directory.
35
- * If `path` is absolute, it is normalized and returned directly.
36
- */
37
33
  export declare function resolvePath(base: string, path: string): string;
38
34
  /**
39
35
  * Join a parent path with a child name.
@@ -20,6 +20,12 @@ export interface VfsTemplateOptions {
20
20
  * default.
21
21
  */
22
22
  maxMemoryBytes?: number;
23
+ /**
24
+ * When true, overlay mounts are read-only: writes through the
25
+ * overlay fail with EROFS. Forks can read the host filesystem
26
+ * but cannot modify it. Default: false.
27
+ */
28
+ readOnly?: boolean;
23
29
  }
24
30
  /**
25
31
  * Template for cheap parallel forks (see
@@ -38,7 +38,7 @@ export interface InterpreterOptions {
38
38
  /** Bootstrap JavaScript code for js-exec */
39
39
  jsBootstrapCode?: string;
40
40
  /** Tool invoker hook for js-exec's `tools` proxy */
41
- invokeTool?: (path: string, argsJson: string, abortSignal: AbortSignal) => Promise<string>;
41
+ invokeTool?: (path: string, argsJson: string) => Promise<string>;
42
42
  }
43
43
  export declare class Interpreter {
44
44
  private ctx;
@@ -405,5 +405,5 @@ export interface InterpreterContext {
405
405
  * Tool invoker hook. When present, js-exec sets up a `tools` proxy that
406
406
  * routes calls through this callback.
407
407
  */
408
- invokeTool?: (path: string, argsJson: string, abortSignal: AbortSignal) => Promise<string>;
408
+ invokeTool?: (path: string, argsJson: string) => Promise<string>;
409
409
  }
package/dist/limits.d.ts CHANGED
@@ -82,8 +82,8 @@ export interface ExecutionLimits {
82
82
  maxPythonTimeoutMs?: number;
83
83
  /** Maximum JavaScript execution time in milliseconds (normal default: 30000) */
84
84
  maxJsTimeoutMs?: number;
85
- /** Maximum JavaScript host-bridge operations (normal default: 1000000) */
86
- maxJsBridgeRequests?: number;
85
+ /** Maximum QuickJS heap size in bytes (normal default: 64 MiB) */
86
+ maxJsMemoryBytes?: number;
87
87
  /** Maximum glob filesystem operations (normal default: 1000000) */
88
88
  maxGlobOperations?: number;
89
89
  /** Maximum string length in bytes (normal default: 64 MiB) */
@@ -107,7 +107,4 @@ export interface ExecutionLimits {
107
107
  export type ExecutionLimitProfile = "normal" | "hardened";
108
108
  /** Liberal default shared by shell and standalone transform entry points. */
109
109
  export declare const DEFAULT_MAX_SOURCE_BYTES: number;
110
- /**
111
- * Resolve execution limits by merging user-provided limits with defaults.
112
- */
113
110
  export declare function resolveLimits(userLimits?: ExecutionLimits, profile?: ExecutionLimitProfile): Required<ExecutionLimits>;
package/dist/timers.d.ts CHANGED
@@ -1,5 +1,14 @@
1
1
  export declare const _setTimeout: typeof globalThis.setTimeout;
2
2
  export declare const _clearTimeout: typeof globalThis.clearTimeout;
3
+ /**
4
+ * Native setTimeout WITHOUT execution-context binding. `_setTimeout`
5
+ * binds callbacks to the scheduling execution's defense context, which
6
+ * DefenseInDepthBox suppresses once that execution deactivates — correct
7
+ * for intra-execution timers (sleep, fetch deadlines), fatal for host
8
+ * infrastructure callbacks that must fire AFTER the execution ends
9
+ * (e.g. idle teardown of a shared worker). Use this for the latter.
10
+ */
11
+ export declare const _setTimeoutUnbound: typeof globalThis.setTimeout;
3
12
  export interface FiniteTimeoutHandle {
4
13
  cleared: boolean;
5
14
  remainingMs: number;
package/dist/types.d.ts CHANGED
@@ -283,11 +283,10 @@ export interface RuntimeCommandContext {
283
283
  jsBootstrapCode?: string;
284
284
  /**
285
285
  * Tool invoker hook. When present, js-exec sets up a `tools` proxy that
286
- * routes calls through this callback. Receives `(path, argsJson,
287
- * abortSignal)` and returns a JSON result string. Implementations should
288
- * forward the signal to cancelable work.
286
+ * routes calls through this callback. Receives `(path, argsJson)` and
287
+ * returns a JSON result string.
289
288
  */
290
- invokeTool?: (path: string, argsJson: string, abortSignal: AbortSignal) => Promise<string>;
289
+ invokeTool?: (path: string, argsJson: string) => Promise<string>;
291
290
  }
292
291
  /** Legacy standalone context shape used by direct command invocations. */
293
292
  export type CommandContext = Omit<RuntimeCommandContext, "limits" | "executionScope"> & {
@@ -309,6 +308,12 @@ export interface Command {
309
308
  trusted?: boolean;
310
309
  /** @internal Marks host extensions that receive a least-authority budget. */
311
310
  internalIsExtension?: boolean;
311
+ /**
312
+ * Set to true when the command handles --version itself (e.g. python3
313
+ * shows Python's version, not just-bash's). When unset, the dispatch
314
+ * intercepts --version and returns "<cmd> (just-bash)".
315
+ */
316
+ handlesOwnVersion?: boolean;
312
317
  execute(args: string[], ctx: ResolvedCommandContext): Promise<ExecResult>;
313
318
  }
314
319
  export interface RuntimeCommand extends Omit<Command, "execute"> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jerryan/just-bash",
3
- "version": "3.8.0",
3
+ "version": "3.10.0",
4
4
  "description": "A simulated bash environment with virtual filesystem",
5
5
  "repository": {
6
6
  "type": "git",
@@ -77,6 +77,7 @@
77
77
  "fast-check": "^3.23.2",
78
78
  "knip": "^5.88.1",
79
79
  "tsx": "^4.23.12",
80
+ "typescript": "^5.9.3",
80
81
  "vitest": "^4.1.10"
81
82
  },
82
83
  "dependencies": {
@@ -87,14 +88,13 @@
87
88
  "ini": "^6.0.0",
88
89
  "modern-tar": "^0.7.7",
89
90
  "papaparse": "^5.6.0",
91
+ "quickjs-emscripten": "^0.32.0",
90
92
  "re2js": "^1.3.3",
91
- "run": "2.1.3",
92
93
  "seek-bzip": "^2.0.0",
93
94
  "smol-toml": "^1.8.0",
94
95
  "sprintf-js": "^1.1.3",
95
96
  "sql.js": "^1.14.1",
96
97
  "turndown": "^7.2.4",
97
- "typescript": "^5.9.3",
98
98
  "undici": "^7.29.0",
99
99
  "yaml": "^2.9.0"
100
100
  },
@@ -105,12 +105,12 @@
105
105
  "scripts": {
106
106
  "build": "rm -rf dist && tsc && pnpm build:lib && pnpm build:lib:cjs && pnpm build:browser && pnpm build:cli && pnpm build:shell && pnpm build:worker && pnpm build:clean && cp dist/index.d.ts dist/index.d.cts && sed '1,/^-->/d' AGENTS.npm.md > dist/AGENTS.md",
107
107
  "build:clean": "find dist -name '*.test.js' -delete && find dist -name '*.test.d.ts' -delete",
108
- "build:worker": "esbuild src/commands/python3/worker.ts --bundle --platform=node --format=esm --outfile=src/commands/python3/worker.js --external:../../../vendor/cpython-emscripten/* && cp src/commands/python3/worker.js dist/commands/python3/worker.js && mkdir -p dist/bin/chunks && cp src/commands/python3/worker.js dist/bin/chunks/worker.js && mkdir -p dist/bundle/chunks && cp src/commands/python3/worker.js dist/bundle/chunks/worker.js && esbuild src/commands/sqlite3/worker.ts --bundle --platform=node --format=esm --outfile=src/commands/sqlite3/worker.js --external:sql.js && mkdir -p dist/commands/sqlite3 && cp src/commands/sqlite3/worker.js dist/commands/sqlite3/worker.js && cp src/commands/sqlite3/worker.js dist/bin/chunks/sqlite3-worker.js && cp src/commands/sqlite3/worker.js dist/bundle/chunks/sqlite3-worker.js",
109
- "build:lib": "esbuild dist/index.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bundle --chunk-names=chunks/[name]-[hash] --banner:js='import{createRequire} from\"node:module\";const require=createRequire(import.meta.url);' --external:diff --external:sprintf-js --external:turndown --external:sql.js --external:run --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip --external:guarded-fetch",
110
- "build:lib:cjs": "esbuild dist/index.js --bundle --platform=node --format=cjs --minify --outfile=dist/bundle/index.cjs --external:diff --external:sprintf-js --external:turndown --external:sql.js --external:run --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip --external:guarded-fetch",
108
+ "build:worker": "esbuild src/commands/python3/worker.ts --bundle --platform=node --format=esm --outfile=src/commands/python3/worker.js --external:../../../vendor/cpython-emscripten/* && cp src/commands/python3/worker.js dist/commands/python3/worker.js && mkdir -p dist/bin/chunks && cp src/commands/python3/worker.js dist/bin/chunks/worker.js && mkdir -p dist/bundle/chunks && cp src/commands/python3/worker.js dist/bundle/chunks/worker.js && esbuild src/commands/js-exec/js-exec-worker.ts --bundle --platform=node --format=esm --outfile=src/commands/js-exec/js-exec-worker.js --external:quickjs-emscripten && cp src/commands/js-exec/js-exec-worker.js dist/commands/js-exec/js-exec-worker.js && cp src/commands/js-exec/js-exec-worker.js dist/bin/chunks/js-exec-worker.js && cp src/commands/js-exec/js-exec-worker.js dist/bundle/chunks/js-exec-worker.js && esbuild src/commands/sqlite3/worker.ts --bundle --platform=node --format=esm --outfile=src/commands/sqlite3/worker.js --external:sql.js && mkdir -p dist/commands/sqlite3 && cp src/commands/sqlite3/worker.js dist/commands/sqlite3/worker.js && cp src/commands/sqlite3/worker.js dist/bin/chunks/sqlite3-worker.js && cp src/commands/sqlite3/worker.js dist/bundle/chunks/sqlite3-worker.js",
109
+ "build:lib": "esbuild dist/index.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bundle --chunk-names=chunks/[name]-[hash] --banner:js='import{createRequire} from\"node:module\";const require=createRequire(import.meta.url);' --external:diff --external:sprintf-js --external:turndown --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip --external:guarded-fetch",
110
+ "build:lib:cjs": "esbuild dist/index.js --bundle --platform=node --format=cjs --minify --outfile=dist/bundle/index.cjs --external:diff --external:sprintf-js --external:turndown --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip --external:guarded-fetch",
111
111
  "build:browser": "esbuild dist/browser.js --bundle --platform=browser --format=esm --minify --outfile=dist/bundle/browser.js --external:diff --external:sprintf-js --external:turndown --external:undici --external:guarded-fetch --external:node:zlib --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip --define:__BROWSER__=true --alias:node:async_hooks=./src/shims/browser-unsupported.js --alias:node:dns=./src/shims/browser-unsupported.js --alias:node:module=./src/shims/browser-unsupported.js",
112
- "build:cli": "esbuild dist/cli/just-bash.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node\nimport{createRequire} from\"node:module\";const require=createRequire(import.meta.url);' --external:sql.js --external:run --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
113
- "build:shell": "esbuild dist/cli/shell.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin/shell --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node\nimport{createRequire} from\"node:module\";const require=createRequire(import.meta.url);' --external:sql.js --external:run --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
112
+ "build:cli": "esbuild dist/cli/just-bash.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node\nimport{createRequire} from\"node:module\";const require=createRequire(import.meta.url);' --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
113
+ "build:shell": "esbuild dist/cli/shell.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin/shell --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node\nimport{createRequire} from\"node:module\";const require=createRequire(import.meta.url);' --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
114
114
  "validate": "pnpm lint && pnpm knip && pnpm typecheck && pnpm build && pnpm check:worker-sync && pnpm test:run && pnpm test:wasm && pnpm test:dist",
115
115
  "typecheck": "tsc --noEmit",
116
116
  "lint": "pnpm lint:banned",
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env node
2
- import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{b as E}from"./chunk-CPKBPQ2C.js";import{a as M}from"./chunk-NE4R2FVV.js";import{a as A,b as j}from"./chunk-MUFNRCMY.js";var S=class{diff(t,o,e={}){let i;typeof e=="function"?(i=e,e={}):"callback"in e&&(i=e.callback);let s=this.castInput(t,e),f=this.castInput(o,e),a=this.removeEmpty(this.tokenize(s,e)),n=this.removeEmpty(this.tokenize(f,e));return this.diffWithOptionsObj(a,n,e,i)}diffWithOptionsObj(t,o,e,i){var s;let f=d=>{if(d=this.postProcess(d,e),i){setTimeout(function(){i(d)},0);return}else return d},a=o.length,n=t.length,u=1,l=a+n;e.maxEditLength!=null&&(l=Math.min(l,e.maxEditLength));let c=(s=e.timeout)!==null&&s!==void 0?s:1/0,m=Date.now()+c,h=[{oldPos:-1,lastComponent:void 0}],p=this.extractCommon(h[0],o,t,0,e);if(h[0].oldPos+1>=n&&p+1>=a)return f(this.buildValues(h[0].lastComponent,o,t));let C=-1/0,w=1/0,P=()=>{for(let d=Math.max(C,-u);d<=Math.min(w,u);d+=2){let x,y=h[d-1],v=h[d+1];y&&(h[d-1]=void 0);let $=!1;if(v){let I=v.oldPos-d;$=v&&0<=I&&I<a}let N=y&&y.oldPos+1<n;if(!$&&!N){h[d]=void 0;continue}if(!N||$&&y.oldPos<v.oldPos?x=this.addToPath(v,!0,!1,0,e):x=this.addToPath(y,!1,!0,1,e),p=this.extractCommon(x,o,t,d,e),x.oldPos+1>=n&&p+1>=a)return f(this.buildValues(x.lastComponent,o,t))||!0;h[d]=x,x.oldPos+1>=n&&(w=Math.min(w,d-1)),p+1>=a&&(C=Math.max(C,d+1))}u++};if(i)(function d(){setTimeout(function(){if(u>l||Date.now()>m)return i(void 0);P()||d()},0)})();else for(;u<=l&&Date.now()<=m;){let d=P();if(d)return d}}addToPath(t,o,e,i,s){let f=t.lastComponent;return f&&!s.oneChangePerToken&&f.added===o&&f.removed===e?{oldPos:t.oldPos+i,lastComponent:{count:f.count+1,added:o,removed:e,previousComponent:f.previousComponent}}:{oldPos:t.oldPos+i,lastComponent:{count:1,added:o,removed:e,previousComponent:f}}}extractCommon(t,o,e,i,s){let f=o.length,a=e.length,n=t.oldPos,u=n-i,l=0;for(;u+1<f&&n+1<a&&this.equals(e[n+1],o[u+1],s);)u++,n++,l++,s.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return l&&!s.oneChangePerToken&&(t.lastComponent={count:l,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=n,u}equals(t,o,e){return e.comparator?e.comparator(t,o):t===o||!!e.ignoreCase&&t.toLowerCase()===o.toLowerCase()}removeEmpty(t){let o=[];for(let e=0;e<t.length;e++)t[e]&&o.push(t[e]);return o}castInput(t,o){return t}tokenize(t,o){return Array.from(t)}join(t){return t.join("")}postProcess(t,o){return t}get useLongestToken(){return!1}buildValues(t,o,e){let i=[],s;for(;t;)i.push(t),s=t.previousComponent,delete t.previousComponent,t=s;i.reverse();let f=i.length,a=0,n=0,u=0;for(;a<f;a++){let l=i[a];if(l.removed)l.value=this.join(e.slice(u,u+l.count)),u+=l.count;else{if(!l.added&&this.useLongestToken){let c=o.slice(n,n+l.count);c=c.map(function(m,h){let p=e[u+h];return p.length>m.length?p:m}),l.value=this.join(c)}else l.value=this.join(o.slice(n,n+l.count));n+=l.count,l.added||(u+=l.count)}}return i}};var b=class extends S{tokenize(t){return t.slice()}join(t){return t}removeEmpty(t){return t}},z=new b;function T(r,t,o){return z.diff(r,t,o)}var Y=`\
4
- `,D=3;function F(r){if(r==="")return{lines:[],noEol:!1};let t=!r.endsWith(`
5
- `),o=r.split(`
6
- `);return t||o.pop(),{lines:o,noEol:t}}function O(r,t){let o=r.lines.length-1;return r.lines.map((e,i)=>{let s=i===o&&r.noEol?e:`${e}
7
- `;return t?s.toLowerCase():s})}function q(r,t,o){let e=T(O(r,o),O(t,o)),i=[],s=0,f=0,a=0;for(;a<e.length;){let n=e[a];if(!n.added&&!n.removed){s+=n.count??n.value.length,f+=n.count??n.value.length,a++;continue}let u={oldStart:s,oldCount:0,newStart:f,newCount:0};for(;a<e.length&&(e[a].added||e[a].removed);){let l=e[a].count??e[a].value.length;e[a].removed?(u.oldCount+=l,s+=l):(u.newCount+=l,f+=l),a++}i.push(u)}return i}function L(r){if(!/[\s"\u0000-\u001f\u007f]/.test(r))return r;let t='"';for(let o of r)o==='"'||o==="\\"?t+=`\\${o}`:o===" "?t+="\\t":o===`
8
- `?t+="\\n":o==="\r"?t+="\\r":o<" "||o==="\x7F"?t+=`\\${o.charCodeAt(0).toString(8).padStart(3,"0")}`:t+=o;return`${t}"`}function g(r,t,o,e){r.push(`${e}${t.lines[o]}
9
- `),t.noEol&&o===t.lines.length-1&&r.push(Y)}function W(r,t){return t===0?String(r):t===1?String(r+1):`${r+1},${r+t}`}function U(r,t,o){let e=[];for(let i of o){let s=i.oldCount===0?"a":i.newCount===0?"d":"c";e.push(`${W(i.oldStart,i.oldCount)}${s}${W(i.newStart,i.newCount)}
10
- `);for(let f=0;f<i.oldCount;f++)g(e,r,i.oldStart+f,"< ");s==="c"&&e.push(`---
11
- `);for(let f=0;f<i.newCount;f++)g(e,t,i.newStart+f,"> ")}return e.join("")}function k(r,t){let o=[],e=[];for(let i of r){let s=e[e.length-1];s&&i.oldStart-(s.oldStart+s.oldCount)>2*t&&(o.push(e),e=[]),e.push(i)}return e.length>0&&o.push(e),o}function V(r,t,o,e){let i=r[0],s=r[r.length-1];return{oldFrom:Math.max(0,i.oldStart-e),oldTo:Math.min(t.lines.length,s.oldStart+s.oldCount+e),newFrom:Math.max(0,i.newStart-e),newTo:Math.min(o.lines.length,s.newStart+s.newCount+e)}}function _(r,t){let o=t-r;return o===0?`${r},0`:o===1?String(r+1):`${r+1},${o}`}function X(r,t,o,e,i,s){let f=[`--- ${L(r)}
12
- `,`+++ ${L(t)}
13
- `];for(let a of k(i,s)){let n=V(a,o,e,s);f.push(`@@ -${_(n.oldFrom,n.oldTo)} +${_(n.newFrom,n.newTo)} @@
14
- `);let u=n.oldFrom;for(let l of a){for(;u<l.oldStart;u++)g(f,o,u," ");for(let c=0;c<l.oldCount;c++)g(f,o,l.oldStart+c,"-");for(let c=0;c<l.newCount;c++)g(f,e,l.newStart+c,"+");u=l.oldStart+l.oldCount}for(;u<n.oldTo;u++)g(f,o,u," ")}return f.join("")}function H(r,t){let o=t-r;return o===0?String(r):o===1?String(r+1):`${r+1},${t}`}function R(r,t,o,e,i,s){if(!o.some(n=>(s?n.oldCount:n.newCount)>0))return;let a=e;for(let n of o){let u=s?n.oldStart:n.newStart,l=s?n.oldCount:n.newCount;for(;a<u;a++)g(r,t,a," ");let c=n.oldCount>0&&n.newCount>0?"! ":s?"- ":"+ ";for(let m=0;m<l;m++)g(r,t,u+m,c);a=u+l}for(;a<i;a++)g(r,t,a," ")}function B(r,t,o,e,i,s){let f=[`*** ${L(r)}
15
- `,`--- ${L(t)}
16
- `];for(let a of k(i,s)){let n=V(a,o,e,s);f.push(`***************
17
- `),f.push(`*** ${H(n.oldFrom,n.oldTo)} ****
18
- `),R(f,o,a,n.oldFrom,n.oldTo,!0),f.push(`--- ${H(n.newFrom,n.newTo)} ----
19
- `),R(f,e,a,n.newFrom,n.newTo,!1)}return f.join("")}var G={name:"diff",summary:"compare files line by line",usage:"diff [OPTION]... FILE1 FILE2",options:[" --normal output a normal diff (default)","-u, --unified output a unified diff","-c, --context output a context diff","-q, --brief report only whether files differ","-s, --report-identical-files report when files are the same","-i, --ignore-case ignore case differences"," --version output version information and exit"," --help display this help and exit"]},K={normal:{long:"normal",type:"boolean"},unified:{short:"u",long:"unified",type:"boolean"},context:{short:"c",long:"context",type:"boolean"},brief:{short:"q",long:"brief",type:"boolean"},reportSame:{short:"s",long:"report-identical-files",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"},version:{long:"version",type:"boolean"}},ft={name:"diff",async execute(r,t){if(j(r))return A(G);let o=M("diff",r,K);if(!o.ok)return o.error;let e=o.result.flags;if(e.version)return{stdout:`diff (just-bash)
20
- `,stderr:"",exitCode:0};if(Number(e.normal)+Number(e.unified)+Number(e.context)>1)return{stdout:"",stderr:`diff: conflicting output style options
21
- diff: Try 'diff --help' for more information.
22
- `,exitCode:2};let s=e.brief,f=e.reportSame,a=e.ignoreCase,n=o.result.positional;if(n.length<2)return{stdout:"",stderr:`diff: missing operand
23
- `,exitCode:2};let u,l,[c,m]=n;try{u=c==="-"?E(t.stdin):await t.fs.readFile(t.fs.resolvePath(t.cwd,c))}catch{return{stdout:"",stderr:`diff: ${c}: No such file or directory
24
- `,exitCode:2}}try{l=m==="-"?E(t.stdin):await t.fs.readFile(t.fs.resolvePath(t.cwd,m))}catch{return{stdout:"",stderr:`diff: ${m}: No such file or directory
25
- `,exitCode:2}}let h=u,p=l;if(a&&(h=h.toLowerCase(),p=p.toLowerCase()),h===p)return f?{stdout:`Files ${c} and ${m} are identical
26
- `,stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0};if(s)return{stdout:`Files ${c} and ${m} differ
27
- `,stderr:"",exitCode:1};let C=F(u),w=F(l),P=q(C,w,a),d;return e.unified?d=X(c,m,C,w,P,D):e.context?d=B(c,m,C,w,P,D):d=U(C,w,P),{stdout:d,stderr:"",exitCode:1}}},at={name:"diff",flags:[{flag:"--normal",type:"boolean"},{flag:"-u",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-i",type:"boolean"}],needsArgs:!0,minArgs:2};export{ft as a,at as b};
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env node
2
- import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{b as P,c as O,d as T,e as k}from"./chunk-MBREBDZQ.js";import{f as F}from"./chunk-HWK7KFGB.js";import{l as v,m as w}from"./chunk-FUT3X2GJ.js";import{c as S}from"./chunk-OHFB3M3X.js";import{a as E}from"./chunk-NE4R2FVV.js";import{a as D}from"./chunk-I4IRHQDW.js";import{a as $,b as C}from"./chunk-MUFNRCMY.js";var H={name:"cp",summary:"copy files and directories",usage:"cp [OPTION]... SOURCE... DEST",options:["-r, -R, --recursive copy directories recursively","-n, --no-clobber do not overwrite an existing file","-p, --preserve preserve file attributes","-v, --verbose explain what is being done"," --help display this help and exit"]},I={recursive:{short:"r",long:"recursive",type:"boolean"},recursiveUpper:{short:"R",type:"boolean"},noClobber:{short:"n",long:"no-clobber",type:"boolean"},preserve:{short:"p",long:"preserve",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},q={name:"cp",async execute(u,e){if(C(u))return $(H);let s=E("cp",u,I);if(!s.ok)return s.error;let d=s.result.flags.recursive||s.result.flags.recursiveUpper,A=s.result.flags.noClobber,N=s.result.flags.preserve,R=s.result.flags.verbose,p=s.result.positional;if(p.length<2)return{stdout:"",stderr:`cp: missing destination file operand
4
- `,exitCode:1};let m=p.pop()??"",g=p,l=e.fs.resolvePath(e.cwd,m),y="",n="",i=0,h=new T({limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:"cp"}),f=!1;try{f=(await e.fs.stat(l)).isDirectory}catch{}if(g.length>1&&!f)return{stdout:"",stderr:`cp: target '${m}' is not a directory
5
- `,exitCode:1};for(let t of g)try{let o=e.fs.resolvePath(e.cwd,t),a=await e.fs.stat(o),r=l;if(f){let c=t.split("/").pop()||t;r=l==="/"?`/${c}`:`${l}/${c}`}if(a.isDirectory&&!d){n+=`cp: -r not specified; omitting directory '${t}'
6
- `,i=1;continue}if(a.isDirectory){let c=await O(e.fs,o,r,h);if(F(o,r)||c==="inside"){n+=`cp: cannot copy '${t}' into itself, '${r}'
7
- `,i=1;continue}if(c==="unknown"){n+=`cp: cannot safely determine whether '${r}' is inside '${t}'
8
- `,i=1;continue}}if(A)try{await e.fs.stat(r);continue}catch{}let b=await P(e.fs,o,r);if(b==="same"){n+=`cp: '${t}' and '${r}' are the same file
9
- `,i=1;continue}if(b==="unknown"){n+=`cp: cannot safely determine whether '${t}' and '${r}' are the same file
10
- `,i=1;continue}a.isDirectory&&await k({fs:e.fs,root:o,limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:"cp",symlinks:"never",budget:h},()=>{}),await e.fs.cp(o,r,{recursive:d}),R&&(y+=`'${t}' -> '${r}'
11
- `)}catch(o){if(o instanceof v||o instanceof w)throw o;let a=D(o);S(o,"ENOENT")?n+=`cp: cannot stat '${t}': No such file or directory
12
- `:n+=`cp: cannot copy '${t}': ${a}
13
- `,i=1}return{stdout:y,stderr:n,exitCode:i}}},J={name:"cp",flags:[{flag:"-r",type:"boolean"},{flag:"-R",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-p",type:"boolean"},{flag:"-v",type:"boolean"}],needsArgs:!0,minArgs:2};export{q as a,J as b};
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
- import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{c as i}from"./chunk-OHFB3M3X.js";import{a as m}from"./chunk-PBOVSFTJ.js";import{a as c}from"./chunk-NE4R2FVV.js";import{a as l}from"./chunk-I4IRHQDW.js";var k={recursive:{short:"p",long:"parents",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},h={name:"mkdir",async execute(f,s){let r=c("mkdir",f,k);if(!r.ok)return r.error;let g=r.result.flags.recursive,p=r.result.flags.verbose,n=r.result.positional;if(n.length===0)return{stdout:"",stderr:`mkdir: missing operand
4
- `,exitCode:1};let a="",t="",d=0;for(let e of n)try{let o=s.fs.resolvePath(s.cwd,e);await s.fs.mkdir(o,{recursive:g}),p&&(a+=`mkdir: created directory '${e}'
5
- `)}catch(o){let u=l(o);i(o,"ENOENT")?t+=`mkdir: cannot create directory '${e}': No such file or directory
6
- `:i(o,"EEXIST")?t+=`mkdir: cannot create directory '${e}': File exists
7
- `:t+=`mkdir: cannot create directory '${e}': ${m(u)}
8
- `,d=1}return{stdout:a,stderr:t,exitCode:d}}},$={name:"mkdir",flags:[{flag:"-p",type:"boolean"},{flag:"-v",type:"boolean"}],needsArgs:!0};export{h as a,$ as b};
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a as s}from"./chunk-OHFB3M3X.js";var a=40,f=493,d=420,x=511;function o(n){if(!n||n==="/")return"/";let t=n.endsWith("/")&&n!=="/"?n.slice(0,-1):n;t.startsWith("/")||(t=`/${t}`);let r=t.split("/").filter(i=>i&&i!=="."),e=[];for(let i of r)i===".."?e.pop():e.push(i);return`/${e.join("/")}`||"/"}function m(n,t){let r=o(n),e=o(t);return e===r||r==="/"||e.startsWith(`${r}/`)}function $(n,t){if(n.includes("\0"))throw new s("ENOENT",`path contains null byte, ${t} '${n}'`)}function c(n){let t=o(n);if(t==="/")return"/";let r=t.lastIndexOf("/");return r===0?"/":t.slice(0,r)}function p(n,t){if(t.startsWith("/"))return o(t);let r=n==="/"?`/${t}`:`${n}/${t}`;return o(r)}function E(n){return n.replace(/\\/g,"/")}function l(n,t){return n==="/"?`/${t}`:`${n}/${t}`}function D(n,t){if(t.startsWith("/"))return o(t);let r=c(n);return o(l(r,t))}export{a,f as b,d as c,x as d,o as e,m as f,$ as g,c as h,p as i,E as j,l as k,D as l};
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{b as a}from"./chunk-HWI42GQO.js";var s=globalThis.setTimeout.bind(globalThis),l=globalThis.clearTimeout.bind(globalThis),T=globalThis.setInterval.bind(globalThis),f=globalThis.clearInterval.bind(globalThis);function u(e){return typeof e!="function"?e:a.bindCurrentContext(e)}var b=((e,n,...i)=>s(u(e),n,...i)),d=l,c=2147483647;function I(e,n){if(n===Number.POSITIVE_INFINITY)return;let i=u(e),t={cleared:!1,remainingMs:Math.max(0,n),timer:void 0},r=()=>{if(t.cleared)return;let o=Math.min(t.remainingMs,c);t.timer=s(()=>{t.cleared||(t.remainingMs-=o,t.remainingMs>0?r():i())},o)};return r(),t}function _(e){e&&(e.cleared=!0,e.timer!==void 0&&l(e.timer))}export{b as a,d as b,I as c,_ as d};
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{b as N,c as O,d as T,e as k}from"./chunk-MBREBDZQ.js";import{f as P}from"./chunk-HWK7KFGB.js";import{l as w,m as $}from"./chunk-FUT3X2GJ.js";import{c as F}from"./chunk-OHFB3M3X.js";import{a as S}from"./chunk-NE4R2FVV.js";import{a as D}from"./chunk-I4IRHQDW.js";import{a as C,b as E}from"./chunk-MUFNRCMY.js";var H={name:"mv",summary:"move (rename) files",usage:"mv [OPTION]... SOURCE... DEST",options:["-f, --force do not prompt before overwriting","-n, --no-clobber do not overwrite an existing file","-v, --verbose explain what is being done"," --help display this help and exit"]},I={force:{short:"f",long:"force",type:"boolean"},noClobber:{short:"n",long:"no-clobber",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},j={name:"mv",async execute(d,e){if(E(d))return C(H);let r=S("mv",d,I);if(!r.ok)return r.error;let v=r.result.flags.force,g=r.result.flags.noClobber,A=r.result.flags.verbose,p=r.result.positional;if(g&&(v=!1),p.length<2)return{stdout:"",stderr:`mv: missing destination file operand
4
- `,exitCode:1};let l=p.pop()??"",u=p,f=e.fs.resolvePath(e.cwd,l),h="",i="",a=0,b=new T({limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:"mv"}),m=!1;try{m=(await e.fs.stat(f)).isDirectory}catch{}if(u.length>1&&!m)return{stdout:"",stderr:`mv: target '${l}' is not a directory
5
- `,exitCode:1};for(let t of u)try{let o=e.fs.resolvePath(e.cwd,t),c=await e.fs.stat(o),n=f;if(m){let s=t.split("/").pop()||t;n=f==="/"?`/${s}`:`${f}/${s}`}if(c.isDirectory){let s=await O(e.fs,o,n,b);if(P(o,n)||s==="inside"){i+=`mv: cannot move '${t}' into itself, '${n}'
6
- `,a=1;continue}if(s==="unknown"){i+=`mv: cannot safely determine whether '${n}' is inside '${t}'
7
- `,a=1;continue}}if(g)try{await e.fs.stat(n);continue}catch{}let y=await N(e.fs,o,n);if(y==="same")continue;if(y==="unknown"){i+=`mv: cannot safely determine whether '${t}' and '${n}' are the same file
8
- `,a=1;continue}if(c.isDirectory&&await k({fs:e.fs,root:o,limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:"mv",symlinks:"never",budget:b},()=>{}),await e.fs.mv(o,n),A){let s=m?`${l}/${t.split("/").pop()||t}`:l;h+=`renamed '${t}' -> '${s}'
9
- `}}catch(o){if(o instanceof w||o instanceof $)throw o;let c=D(o);F(o,"ENOENT")?i+=`mv: cannot stat '${t}': No such file or directory
10
- `:i+=`mv: cannot move '${t}': ${c}
11
- `,a=1}return{stdout:h,stderr:i,exitCode:a}}},G={name:"mv",flags:[{flag:"-f",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-v",type:"boolean"}],needsArgs:!0,minArgs:2};export{j as a,G as b};
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import{createRequire} from"node:module";const require=createRequire(import.meta.url);
3
- import{a as u}from"./chunk-NE4R2FVV.js";import{a as f,b as h}from"./chunk-MUFNRCMY.js";var g={name:"which",summary:"locate a command",usage:"which [-as] program ...",options:["-a List all instances of executables found","-s No output, just return 0 if found, 1 if not","--help display this help and exit"]},w={showAll:{short:"a",type:"boolean"},silent:{short:"s",type:"boolean"}},A={name:"which",async execute(s,e){if(h(s))return f(g);let t=u("which",s,w);if(!t.ok)return t.error;let c=t.result.flags.showAll,p=t.result.flags.silent,o=t.result.positional;if(o.length===0)return{stdout:"",stderr:"",exitCode:1};let d=(e.env.get("PATH")||"/usr/bin:/bin").split(":"),n="",a=!0;for(let m of o){let l=!1;for(let r of d){if(!r)continue;let i=e.fs.resolvePath(r,m);if(await e.fs.exists(i)&&(l=!0,p||(n+=`${i}
4
- `),!c))break}l||(a=!1)}return{stdout:n,stderr:"",exitCode:a?0:1}}},v={name:"which",flags:[{flag:"-a",type:"boolean"},{flag:"-s",type:"boolean"}],needsArgs:!0};export{A as a,v as b};