@lifo-sh/core 0.5.0 → 0.5.6

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 (292) hide show
  1. package/dist/args-BhoL0JcG.js +58 -0
  2. package/dist/awk-DahiO6Jl.js +170 -0
  3. package/dist/base64-Dj_AnQAH.js +92 -0
  4. package/dist/basename-D8sjWfzX.js +14 -0
  5. package/dist/bc-CCuJi0IY.js +230 -0
  6. package/dist/browser-B0dadKCA.js +43 -0
  7. package/dist/cal-DQsLvArw.js +85 -0
  8. package/dist/cat-KYGveROo.js +32 -0
  9. package/dist/chmod-gYZdg3Kv.js +81 -0
  10. package/dist/chown-DoPi7NLO.js +32 -0
  11. package/dist/commands/net/curl.d.ts +2 -2
  12. package/dist/commands/net/curl.d.ts.map +1 -1
  13. package/dist/commands/net/forward.d.ts +14 -0
  14. package/dist/commands/net/forward.d.ts.map +1 -0
  15. package/dist/commands/net/host.d.ts +14 -0
  16. package/dist/commands/net/host.d.ts.map +1 -0
  17. package/dist/commands/net/ifconfig.d.ts +8 -0
  18. package/dist/commands/net/ifconfig.d.ts.map +1 -0
  19. package/dist/commands/net/ip.d.ts +14 -0
  20. package/dist/commands/net/ip.d.ts.map +1 -0
  21. package/dist/commands/net/netstat.d.ts +8 -0
  22. package/dist/commands/net/netstat.d.ts.map +1 -0
  23. package/dist/commands/net/ports.d.ts +8 -0
  24. package/dist/commands/net/ports.d.ts.map +1 -0
  25. package/dist/commands/net/route.d.ts +8 -0
  26. package/dist/commands/net/route.d.ts.map +1 -0
  27. package/dist/commands/net/test-registry.d.ts +8 -0
  28. package/dist/commands/net/test-registry.d.ts.map +1 -0
  29. package/dist/commands/net/tunnel-v2.d.ts +4 -0
  30. package/dist/commands/net/tunnel-v2.d.ts.map +1 -0
  31. package/dist/commands/net/tunnel.d.ts +6 -0
  32. package/dist/commands/net/tunnel.d.ts.map +1 -0
  33. package/dist/commands/registry.d.ts +1 -0
  34. package/dist/commands/registry.d.ts.map +1 -1
  35. package/dist/commands/system/kill.d.ts +2 -2
  36. package/dist/commands/system/kill.d.ts.map +1 -1
  37. package/dist/commands/system/lifo.d.ts +19 -2
  38. package/dist/commands/system/lifo.d.ts.map +1 -1
  39. package/dist/commands/system/newtab.d.ts +8 -0
  40. package/dist/commands/system/newtab.d.ts.map +1 -0
  41. package/dist/commands/system/node.d.ts +3 -2
  42. package/dist/commands/system/node.d.ts.map +1 -1
  43. package/dist/commands/system/npm.d.ts +20 -7
  44. package/dist/commands/system/npm.d.ts.map +1 -1
  45. package/dist/commands/system/ps.d.ts +3 -2
  46. package/dist/commands/system/ps.d.ts.map +1 -1
  47. package/dist/commands/system/systemctl.d.ts +4 -0
  48. package/dist/commands/system/systemctl.d.ts.map +1 -0
  49. package/dist/commands/system/top.d.ts +2 -2
  50. package/dist/commands/system/top.d.ts.map +1 -1
  51. package/dist/commands/system/watch.d.ts.map +1 -1
  52. package/dist/commands/system/whoami.d.ts.map +1 -1
  53. package/dist/commands/types.d.ts +3 -2
  54. package/dist/commands/types.d.ts.map +1 -1
  55. package/dist/cp-BP7-nkZi.js +29 -0
  56. package/dist/cut-Dg3Sxlw_.js +84 -0
  57. package/dist/date-DqL4oCg8.js +91 -0
  58. package/dist/df-CEHqyq91.js +47 -0
  59. package/dist/diff-aYLFp43G.js +250 -0
  60. package/dist/dig-0_V5UoWW.js +91 -0
  61. package/dist/dirname-ByojkmnI.js +14 -0
  62. package/dist/du-feoEC53Q.js +89 -0
  63. package/dist/env-CIcDulqw.js +10 -0
  64. package/dist/fastfetch-CRfsfb4t.js +378 -0
  65. package/dist/file-BHHCgjt9.js +79 -0
  66. package/dist/find-C-pGJyTZ.js +63 -0
  67. package/dist/free-DCkGta9v.js +33 -0
  68. package/dist/grep-Bv7fu1qw.js +179 -0
  69. package/dist/gunzip-BZk2000a.js +57 -0
  70. package/dist/gzip-D55LwDu8.js +70 -0
  71. package/dist/head-CQQ8pAha.js +66 -0
  72. package/dist/hostname-Ba0tnCzG.js +8 -0
  73. package/dist/index-GLjTMF7C.js +22717 -0
  74. package/dist/index.d.ts +44 -17
  75. package/dist/index.d.ts.map +1 -1
  76. package/dist/index.js +99 -72
  77. package/dist/less-C-8XcQ_A.js +294 -0
  78. package/dist/ln-CpXREm6e.js +15 -0
  79. package/dist/ls-Ce1mcASB.js +132 -0
  80. package/dist/{man-Dg26tZ-a.js → man-DjxHeM01.js} +46 -27
  81. package/dist/mime-B5knsVEw.js +101 -0
  82. package/dist/mkdir-CtDdaiaM.js +31 -0
  83. package/dist/mktemp-DwAY8Lz2.js +44 -0
  84. package/dist/mv-vS020rcy.js +29 -0
  85. package/dist/nano-DKfqXthq.js +445 -0
  86. package/dist/nl-DHh-MmKX.js +66 -0
  87. package/dist/ping-BQO3Z9CT.js +72 -0
  88. package/dist/pkg/PackageManager.d.ts +2 -2
  89. package/dist/pkg/PackageManager.d.ts.map +1 -1
  90. package/dist/pkg/lifo-dev.d.ts +6 -6
  91. package/dist/pkg/lifo-dev.d.ts.map +1 -1
  92. package/dist/pkg/lifo-runtime.d.ts +3 -3
  93. package/dist/pkg/lifo-runtime.d.ts.map +1 -1
  94. package/dist/pkg/loader.d.ts +2 -2
  95. package/dist/pkg/loader.d.ts.map +1 -1
  96. package/dist/printf-CdBVx2dT.js +81 -0
  97. package/dist/realpath-CZ_ja3FL.js +27 -0
  98. package/dist/rev-KZ9O5vNS.js +42 -0
  99. package/dist/rm-dW7YB25j.js +48 -0
  100. package/dist/rmdir-Db2wctQ6.js +42 -0
  101. package/dist/runtime/ContextSerialization.d.ts +7 -0
  102. package/dist/runtime/ContextSerialization.d.ts.map +1 -0
  103. package/dist/runtime/ProcessExecutor.d.ts +14 -0
  104. package/dist/runtime/ProcessExecutor.d.ts.map +1 -0
  105. package/dist/runtime/command-worker.d.ts +9 -0
  106. package/dist/runtime/command-worker.d.ts.map +1 -0
  107. package/dist/sandbox/Sandbox.d.ts +1 -2
  108. package/dist/sandbox/Sandbox.d.ts.map +1 -1
  109. package/dist/sandbox/SandboxFs.d.ts +2 -2
  110. package/dist/sandbox/SandboxFs.d.ts.map +1 -1
  111. package/dist/sandbox/types.d.ts +1 -2
  112. package/dist/sandbox/types.d.ts.map +1 -1
  113. package/dist/sed-BK_pjM2M.js +142 -0
  114. package/dist/seq-B0yurkx9.js +64 -0
  115. package/dist/sha256sum-BP0l9D35.js +85 -0
  116. package/dist/shell/ProcessRegistry.d.ts +152 -0
  117. package/dist/shell/ProcessRegistry.d.ts.map +1 -0
  118. package/dist/shell/ProcessRegistry.example.d.ts +8 -0
  119. package/dist/shell/ProcessRegistry.example.d.ts.map +1 -0
  120. package/dist/shell/ProcessRegistry.test.d.ts +2 -0
  121. package/dist/shell/ProcessRegistry.test.d.ts.map +1 -0
  122. package/dist/shell/Shell.d.ts +13 -4
  123. package/dist/shell/Shell.d.ts.map +1 -1
  124. package/dist/shell/completer.d.ts +2 -2
  125. package/dist/shell/completer.d.ts.map +1 -1
  126. package/dist/shell/expander.d.ts +2 -2
  127. package/dist/shell/expander.d.ts.map +1 -1
  128. package/dist/shell/history.d.ts +2 -2
  129. package/dist/shell/history.d.ts.map +1 -1
  130. package/dist/shell/interpreter.d.ts +8 -2
  131. package/dist/shell/interpreter.d.ts.map +1 -1
  132. package/dist/shell/test-builtin.d.ts +2 -2
  133. package/dist/shell/test-builtin.d.ts.map +1 -1
  134. package/dist/sl-BmMNz7ir.js +200 -0
  135. package/dist/sleep-C_3mjcFi.js +25 -0
  136. package/dist/sort-DYZuiMaO.js +87 -0
  137. package/dist/stat-CXSSmsrA.js +38 -0
  138. package/dist/strings-BwqQy-zL.js +63 -0
  139. package/dist/tac-CuZSbu_c.js +32 -0
  140. package/dist/tail-DH7xR0rW.js +62 -0
  141. package/dist/tar-AnR03GXP.js +155 -0
  142. package/dist/tee-ByHsMExU.js +29 -0
  143. package/dist/touch-CcmnMpg5.js +26 -0
  144. package/dist/tr-D_cg13q8.js +92 -0
  145. package/dist/tree-Ck1ymlSv.js +64 -0
  146. package/dist/uname-07bQ7DTD.js +50 -0
  147. package/dist/uniq-BHkwpex3.js +76 -0
  148. package/dist/unzip-DVjk3GA4.js +91 -0
  149. package/dist/uptime-ujk4Nb77.js +17 -0
  150. package/dist/utils/archive.d.ts +2 -2
  151. package/dist/utils/archive.d.ts.map +1 -1
  152. package/dist/utils/glob.d.ts +2 -2
  153. package/dist/utils/glob.d.ts.map +1 -1
  154. package/dist/wc-CK9Flybx.js +98 -0
  155. package/dist/wget-Cww1uNE2.js +84 -0
  156. package/dist/{which-D3u0cwyh.js → which-CJwCjtVK.js} +25 -14
  157. package/dist/whoami-EHyrQ1q-.js +25 -0
  158. package/dist/xargs-I1ZWqhOp.js +40 -0
  159. package/dist/yes-XolnW6bp.js +11 -0
  160. package/dist/zip-BTmRwUYQ.js +40 -0
  161. package/package.json +16 -10
  162. package/dist/args-CG6b9cZt.js +0 -43
  163. package/dist/awk-CC_Qo0hQ.js +0 -123
  164. package/dist/base64-BBckAmkE.js +0 -72
  165. package/dist/basename-BIICW06y.js +0 -12
  166. package/dist/bc-BYiKVTNg.js +0 -200
  167. package/dist/cal-DPULSAhj.js +0 -56
  168. package/dist/cat-Jv35D4BV.js +0 -29
  169. package/dist/chmod-Bh-u8XOr.js +0 -56
  170. package/dist/chown-Dv7xfl2a.js +0 -28
  171. package/dist/cp-CB-sGTRH.js +0 -19
  172. package/dist/cut-B79kgCm4.js +0 -65
  173. package/dist/date-C8NB8v8G.js +0 -86
  174. package/dist/df-CeZb4WOr.js +0 -34
  175. package/dist/diff-D5Ej-JEe.js +0 -150
  176. package/dist/dig-BEJ8Ky96.js +0 -69
  177. package/dist/dirname-w2Y6csox.js +0 -13
  178. package/dist/du-UupzdKc_.js +0 -77
  179. package/dist/env-DXzvDKsN.js +0 -9
  180. package/dist/fastfetch-aPM9Z3ym.js +0 -310
  181. package/dist/file-DOl4Wjtc.js +0 -70
  182. package/dist/find-C0T-P7sl.js +0 -36
  183. package/dist/free-DAxE4b2U.js +0 -23
  184. package/dist/grep-Blwrv9k5.js +0 -147
  185. package/dist/gunzip-R7EtgP15.js +0 -47
  186. package/dist/gzip-BxF7M1np.js +0 -57
  187. package/dist/head-CJwcsX18.js +0 -53
  188. package/dist/hostname-BxU2S3nT.js +0 -8
  189. package/dist/index-BjKSFBDg.js +0 -8640
  190. package/dist/kernel/index.d.ts +0 -26
  191. package/dist/kernel/index.d.ts.map +0 -1
  192. package/dist/kernel/persistence/PersistenceManager.d.ts +0 -12
  193. package/dist/kernel/persistence/PersistenceManager.d.ts.map +0 -1
  194. package/dist/kernel/persistence/backends.d.ts +0 -22
  195. package/dist/kernel/persistence/backends.d.ts.map +0 -1
  196. package/dist/kernel/persistence/index.d.ts +0 -6
  197. package/dist/kernel/persistence/index.d.ts.map +0 -1
  198. package/dist/kernel/persistence/serializer.d.ts +0 -21
  199. package/dist/kernel/persistence/serializer.d.ts.map +0 -1
  200. package/dist/kernel/samples.d.ts +0 -3
  201. package/dist/kernel/samples.d.ts.map +0 -1
  202. package/dist/kernel/storage/BlobStore.d.ts +0 -31
  203. package/dist/kernel/storage/BlobStore.d.ts.map +0 -1
  204. package/dist/kernel/storage/ContentStore.d.ts +0 -52
  205. package/dist/kernel/storage/ContentStore.d.ts.map +0 -1
  206. package/dist/kernel/storage/index.d.ts +0 -7
  207. package/dist/kernel/storage/index.d.ts.map +0 -1
  208. package/dist/kernel/vfs/VFS.d.ts +0 -64
  209. package/dist/kernel/vfs/VFS.d.ts.map +0 -1
  210. package/dist/kernel/vfs/index.d.ts +0 -7
  211. package/dist/kernel/vfs/index.d.ts.map +0 -1
  212. package/dist/kernel/vfs/providers/DevProvider.d.ts +0 -11
  213. package/dist/kernel/vfs/providers/DevProvider.d.ts.map +0 -1
  214. package/dist/kernel/vfs/providers/NativeFsProvider.d.ts +0 -63
  215. package/dist/kernel/vfs/providers/NativeFsProvider.d.ts.map +0 -1
  216. package/dist/kernel/vfs/providers/ProcProvider.d.ts +0 -14
  217. package/dist/kernel/vfs/providers/ProcProvider.d.ts.map +0 -1
  218. package/dist/kernel/vfs/types.d.ts +0 -70
  219. package/dist/kernel/vfs/types.d.ts.map +0 -1
  220. package/dist/less-B0gFLJ_7.js +0 -230
  221. package/dist/ln-Bf3f3jVA.js +0 -11
  222. package/dist/ls-YnhMRefh.js +0 -106
  223. package/dist/mkdir-DY1P3Jxj.js +0 -27
  224. package/dist/mktemp-BRzo2c8y.js +0 -31
  225. package/dist/mv-bH08L-F_.js +0 -19
  226. package/dist/nano-CueO2oS0.js +0 -304
  227. package/dist/nl-D26SSOD4.js +0 -51
  228. package/dist/node-compat/buffer.d.ts +0 -44
  229. package/dist/node-compat/buffer.d.ts.map +0 -1
  230. package/dist/node-compat/child_process.d.ts +0 -10
  231. package/dist/node-compat/child_process.d.ts.map +0 -1
  232. package/dist/node-compat/console.d.ts +0 -21
  233. package/dist/node-compat/console.d.ts.map +0 -1
  234. package/dist/node-compat/crypto.d.ts +0 -17
  235. package/dist/node-compat/crypto.d.ts.map +0 -1
  236. package/dist/node-compat/events.d.ts +0 -19
  237. package/dist/node-compat/events.d.ts.map +0 -1
  238. package/dist/node-compat/fs.d.ts +0 -175
  239. package/dist/node-compat/fs.d.ts.map +0 -1
  240. package/dist/node-compat/http.d.ts +0 -87
  241. package/dist/node-compat/http.d.ts.map +0 -1
  242. package/dist/node-compat/index.d.ts +0 -19
  243. package/dist/node-compat/index.d.ts.map +0 -1
  244. package/dist/node-compat/os.d.ts +0 -39
  245. package/dist/node-compat/os.d.ts.map +0 -1
  246. package/dist/node-compat/path.d.ts +0 -58
  247. package/dist/node-compat/path.d.ts.map +0 -1
  248. package/dist/node-compat/process.d.ts +0 -62
  249. package/dist/node-compat/process.d.ts.map +0 -1
  250. package/dist/node-compat/stream.d.ts +0 -36
  251. package/dist/node-compat/stream.d.ts.map +0 -1
  252. package/dist/node-compat/string_decoder.d.ts +0 -11
  253. package/dist/node-compat/string_decoder.d.ts.map +0 -1
  254. package/dist/node-compat/timers.d.ts +0 -16
  255. package/dist/node-compat/timers.d.ts.map +0 -1
  256. package/dist/node-compat/url.d.ts +0 -53
  257. package/dist/node-compat/url.d.ts.map +0 -1
  258. package/dist/node-compat/util.d.ts +0 -27
  259. package/dist/node-compat/util.d.ts.map +0 -1
  260. package/dist/node-compat/zlib.d.ts +0 -66
  261. package/dist/node-compat/zlib.d.ts.map +0 -1
  262. package/dist/ping-DtVEwwda.js +0 -50
  263. package/dist/printf-Cc2o7KZx.js +0 -70
  264. package/dist/realpath-BH29Lem_.js +0 -24
  265. package/dist/rev-ySwmRf_K.js +0 -39
  266. package/dist/rm-D7iWUUE2.js +0 -37
  267. package/dist/rmdir-BLtdNjt1.js +0 -35
  268. package/dist/sed-DwBPYYFb.js +0 -95
  269. package/dist/seq-B01YKIbO.js +0 -37
  270. package/dist/sha256sum-DED6ePiU.js +0 -64
  271. package/dist/sl-Dv4iPBN6.js +0 -138
  272. package/dist/sleep-B4C3fZiR.js +0 -19
  273. package/dist/sort-OXqZY83v.js +0 -64
  274. package/dist/stat-BvwNpE5B.js +0 -29
  275. package/dist/strings-BesRwUt_.js +0 -42
  276. package/dist/tac-D4BMSdj9.js +0 -31
  277. package/dist/tail-xVmLkzJK.js +0 -52
  278. package/dist/tar-BHRJ0-4j.js +0 -120
  279. package/dist/tee-DxygINEJ.js +0 -17
  280. package/dist/touch-DCb9Qn5q.js +0 -23
  281. package/dist/tr-DsCiwSIu.js +0 -60
  282. package/dist/tree-4QpgsnA0.js +0 -46
  283. package/dist/uname-BCn8HlJD.js +0 -37
  284. package/dist/uniq-xmgE0zRj.js +0 -54
  285. package/dist/unzip-CDKcoB0B.js +0 -81
  286. package/dist/uptime-CgBJegqU.js +0 -8
  287. package/dist/wc-B-jNRfLa.js +0 -69
  288. package/dist/wget-CO-45JoL.js +0 -53
  289. package/dist/whoami-Y18wqme3.js +0 -25
  290. package/dist/xargs-DfbCRFFd.js +0 -35
  291. package/dist/yes-DXEyHHD2.js +0 -10
  292. package/dist/zip-Cu1DzbAu.js +0 -33
@@ -0,0 +1,81 @@
1
+ function processFormat(format, args) {
2
+ let result = "";
3
+ let argIdx = 0;
4
+ let i = 0;
5
+ while (i < format.length) {
6
+ if (format[i] === "\\") {
7
+ i++;
8
+ if (i < format.length) {
9
+ switch (format[i]) {
10
+ case "n":
11
+ result += "\n";
12
+ break;
13
+ case "t":
14
+ result += " ";
15
+ break;
16
+ case "\\":
17
+ result += "\\";
18
+ break;
19
+ case "r":
20
+ result += "\r";
21
+ break;
22
+ case "0":
23
+ result += "\0";
24
+ break;
25
+ default:
26
+ result += "\\" + format[i];
27
+ break;
28
+ }
29
+ i++;
30
+ }
31
+ } else if (format[i] === "%") {
32
+ i++;
33
+ if (i >= format.length) break;
34
+ if (format[i] === "%") {
35
+ result += "%";
36
+ i++;
37
+ continue;
38
+ }
39
+ const arg = args[argIdx++] || "";
40
+ switch (format[i]) {
41
+ case "s":
42
+ result += arg;
43
+ break;
44
+ case "d":
45
+ result += String(parseInt(arg, 10) || 0);
46
+ break;
47
+ case "f":
48
+ result += String(parseFloat(arg) || 0);
49
+ break;
50
+ case "x":
51
+ result += (parseInt(arg, 10) || 0).toString(16);
52
+ break;
53
+ case "o":
54
+ result += (parseInt(arg, 10) || 0).toString(8);
55
+ break;
56
+ default:
57
+ result += "%" + format[i];
58
+ break;
59
+ }
60
+ i++;
61
+ } else {
62
+ result += format[i];
63
+ i++;
64
+ }
65
+ }
66
+ return result;
67
+ }
68
+ const command = async (ctx) => {
69
+ if (ctx.args.length === 0) {
70
+ ctx.stderr.write("printf: missing format string\n");
71
+ return 1;
72
+ }
73
+ const format = ctx.args[0];
74
+ const args = ctx.args.slice(1);
75
+ const output = processFormat(format, args);
76
+ ctx.stdout.write(output);
77
+ return 0;
78
+ };
79
+ export {
80
+ command as default
81
+ };
@@ -0,0 +1,27 @@
1
+ import { r as resolve, V as VFSError } from "./index-GLjTMF7C.js";
2
+ const command = async (ctx) => {
3
+ if (ctx.args.length === 0) {
4
+ ctx.stderr.write("realpath: missing operand\n");
5
+ return 1;
6
+ }
7
+ let exitCode = 0;
8
+ for (const arg of ctx.args) {
9
+ const path = resolve(ctx.cwd, arg);
10
+ try {
11
+ ctx.vfs.stat(path);
12
+ ctx.stdout.write(path + "\n");
13
+ } catch (e) {
14
+ if (e instanceof VFSError) {
15
+ ctx.stderr.write(`realpath: ${arg}: ${e.message}
16
+ `);
17
+ exitCode = 1;
18
+ } else {
19
+ throw e;
20
+ }
21
+ }
22
+ }
23
+ return exitCode;
24
+ };
25
+ export {
26
+ command as default
27
+ };
@@ -0,0 +1,42 @@
1
+ import { r as resolve, V as VFSError } from "./index-GLjTMF7C.js";
2
+ import { i as isBinaryMime, g as getMimeType } from "./mime-B5knsVEw.js";
3
+ function reverseLines(text) {
4
+ return text.split("\n").map((line) => [...line].reverse().join("")).join("\n");
5
+ }
6
+ const command = async (ctx) => {
7
+ if (ctx.args.length === 0) {
8
+ if (ctx.stdin) {
9
+ const content = await ctx.stdin.readAll();
10
+ ctx.stdout.write(reverseLines(content));
11
+ return 0;
12
+ }
13
+ ctx.stderr.write("rev: missing operand\n");
14
+ return 1;
15
+ }
16
+ let exitCode = 0;
17
+ for (const arg of ctx.args) {
18
+ const path = resolve(ctx.cwd, arg);
19
+ try {
20
+ ctx.vfs.stat(path);
21
+ if (isBinaryMime(getMimeType(path))) {
22
+ ctx.stderr.write(`rev: ${arg}: binary file, skipping
23
+ `);
24
+ continue;
25
+ }
26
+ const content = ctx.vfs.readFileString(path);
27
+ ctx.stdout.write(reverseLines(content));
28
+ } catch (e) {
29
+ if (e instanceof VFSError) {
30
+ ctx.stderr.write(`rev: ${arg}: ${e.message}
31
+ `);
32
+ exitCode = 1;
33
+ } else {
34
+ throw e;
35
+ }
36
+ }
37
+ }
38
+ return exitCode;
39
+ };
40
+ export {
41
+ command as default
42
+ };
@@ -0,0 +1,48 @@
1
+ import { p as parseArgs } from "./args-BhoL0JcG.js";
2
+ import { r as resolve, V as VFSError } from "./index-GLjTMF7C.js";
3
+ const spec = {
4
+ recursive: { type: "boolean", short: "r" },
5
+ Recursive: { type: "boolean", short: "R" },
6
+ force: { type: "boolean", short: "f" }
7
+ };
8
+ const command = async (ctx) => {
9
+ const { flags, positional } = parseArgs(ctx.args, spec);
10
+ const recursive = flags.recursive || flags.Recursive;
11
+ const force = flags.force;
12
+ if (positional.length === 0) {
13
+ ctx.stderr.write("rm: missing operand\n");
14
+ return 1;
15
+ }
16
+ let exitCode = 0;
17
+ for (const arg of positional) {
18
+ const path = resolve(ctx.cwd, arg);
19
+ try {
20
+ const stat = ctx.vfs.stat(path);
21
+ if (stat.type === "directory") {
22
+ if (!recursive) {
23
+ ctx.stderr.write(`rm: cannot remove '${arg}': Is a directory
24
+ `);
25
+ exitCode = 1;
26
+ continue;
27
+ }
28
+ ctx.vfs.rmdirRecursive(path);
29
+ } else {
30
+ ctx.vfs.unlink(path);
31
+ }
32
+ } catch (e) {
33
+ if (e instanceof VFSError) {
34
+ if (!force) {
35
+ ctx.stderr.write(`rm: ${arg}: ${e.message}
36
+ `);
37
+ exitCode = 1;
38
+ }
39
+ } else {
40
+ throw e;
41
+ }
42
+ }
43
+ }
44
+ return exitCode;
45
+ };
46
+ export {
47
+ command as default
48
+ };
@@ -0,0 +1,42 @@
1
+ import { p as parseArgs } from "./args-BhoL0JcG.js";
2
+ import { r as resolve, i as dirname, V as VFSError } from "./index-GLjTMF7C.js";
3
+ const spec = {
4
+ parents: { type: "boolean", short: "p" }
5
+ };
6
+ const command = async (ctx) => {
7
+ const { flags, positional } = parseArgs(ctx.args, spec);
8
+ if (positional.length === 0) {
9
+ ctx.stderr.write("rmdir: missing operand\n");
10
+ return 1;
11
+ }
12
+ let exitCode = 0;
13
+ for (const arg of positional) {
14
+ const path = resolve(ctx.cwd, arg);
15
+ try {
16
+ ctx.vfs.rmdir(path);
17
+ if (flags.parents) {
18
+ let parent = dirname(path);
19
+ while (parent !== "/" && parent !== ".") {
20
+ try {
21
+ ctx.vfs.rmdir(parent);
22
+ parent = dirname(parent);
23
+ } catch {
24
+ break;
25
+ }
26
+ }
27
+ }
28
+ } catch (e) {
29
+ if (e instanceof VFSError) {
30
+ ctx.stderr.write(`rmdir: ${arg}: ${e.message}
31
+ `);
32
+ exitCode = 1;
33
+ } else {
34
+ throw e;
35
+ }
36
+ }
37
+ }
38
+ return exitCode;
39
+ };
40
+ export {
41
+ command as default
42
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Re-export context serialization from @lifo-sh/kernel.
3
+ * Kept for backwards compatibility with command-worker.ts and other consumers.
4
+ */
5
+ export { serializeContext, bridgeStreamsToWorker, createMessagePortOutputStream, createMessagePortInputStream, createStreamPort, } from '@lifo-sh/kernel/runtime';
6
+ export type { SerializableContext, WorkerMessage, StreamMessage, } from '@lifo-sh/kernel/runtime';
7
+ //# sourceMappingURL=ContextSerialization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContextSerialization.d.ts","sourceRoot":"","sources":["../../src/runtime/ContextSerialization.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACN,gBAAgB,EAChB,qBAAqB,EACrB,6BAA6B,EAC7B,4BAA4B,EAC5B,gBAAgB,GAChB,MAAM,yBAAyB,CAAC;AAEjC,YAAY,EACX,mBAAmB,EACnB,aAAa,EACb,aAAa,GACb,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { CommandRegistry } from '../commands/registry.js';
2
+ import { Kernel, IProcessExecutor } from '@lifo-sh/kernel';
3
+ import { MainThreadExecutor, WorkerExecutor, RoutingExecutor } from '@lifo-sh/kernel/runtime';
4
+ export type ProcessExecutor = IProcessExecutor;
5
+ export { MainThreadExecutor, WorkerExecutor, RoutingExecutor };
6
+ export { serializeContext, bridgeStreamsToWorker, createMessagePortOutputStream, createMessagePortInputStream, } from '@lifo-sh/kernel/runtime';
7
+ export type { WorkerMessage, StreamMessage, SerializableContext } from '@lifo-sh/kernel/runtime';
8
+ /**
9
+ * Factory that creates the right executor for the current environment.
10
+ * This lives in core (not kernel) because it knows the worker URL —
11
+ * the worker script is userspace code that sets up the command registry.
12
+ */
13
+ export declare function createProcessExecutor(kernel: Kernel, registry: CommandRegistry): IProcessExecutor;
14
+ //# sourceMappingURL=ProcessExecutor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProcessExecutor.d.ts","sourceRoot":"","sources":["../../src/runtime/ProcessExecutor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EACN,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGxD,MAAM,MAAM,eAAe,GAAG,gBAAgB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC;AAG/D,OAAO,EACN,gBAAgB,EAChB,qBAAqB,EACrB,6BAA6B,EAC7B,4BAA4B,GAC5B,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEjG;;;;GAIG;AACH,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,eAAe,GACvB,gBAAgB,CAQlB"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Worker script for executing commands in a dedicated thread.
3
+ *
4
+ * Instead of creating its own VFS instance, the worker receives a VFS
5
+ * snapshot from the kernel at command start and uses a WorkerVfsProxy
6
+ * that forwards writes back to the kernel via MessagePort.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=command-worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-worker.d.ts","sourceRoot":"","sources":["../../src/runtime/command-worker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -1,6 +1,5 @@
1
- import { Kernel } from '../kernel/index.js';
1
+ import { Kernel, NativeFsModule } from '@lifo-sh/kernel';
2
2
  import { Shell } from '../shell/Shell.js';
3
- import { NativeFsModule } from '../kernel/vfs/providers/NativeFsProvider.js';
4
3
  import { SandboxOptions, SandboxCommands, SandboxFs } from './types.js';
5
4
  export declare class Sandbox {
6
5
  /** Programmatic command execution */
@@ -1 +1 @@
1
- {"version":3,"file":"Sandbox.d.ts","sourceRoot":"","sources":["../../src/sandbox/Sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAe1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAElF,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAK7E,qBAAa,OAAO;IAClB,qCAAqC;IACrC,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IACnC,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC;IACvB,4BAA4B;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAGrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAEtB,OAAO,CAAC,UAAU,CAAS;IAE3B,OAAO;IAcP,gCAAgC;IAChC,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,EAEnB;IAED;;;OAGG;WACU,MAAM,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IA6G/D;;;;;;;;;;;OAWG;IACH,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,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,EAAE,MAAM,EAEnB;IAED;;;OAGG;WACU,MAAM,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IAqI/D;;;;;;;;;;;OAWG;IACH,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,cAAc,CAAA;KAAE,GAAG,IAAI;IAgCrH;;;;OAIG;IACH,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAKxC;;OAEG;IACG,MAAM,CAAC,SAAS,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAUnD;;OAEG;IACH,MAAM,IAAI,IAAI;IAId;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,UAAU,CAAC;IAI3C;;OAEG;IACG,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrD;;OAEG;IACH,OAAO,IAAI,IAAI;CAGf"}
@@ -1,4 +1,4 @@
1
- import { VFS } from '../kernel/vfs/index.js';
1
+ import { IKernelVfs } from '@lifo-sh/kernel';
2
2
  import { SandboxFs as ISandboxFs } from './types.js';
3
3
  /**
4
4
  * Async wrapper around VFS that matches the industry-standard filesystem API.
@@ -7,7 +7,7 @@ import { SandboxFs as ISandboxFs } from './types.js';
7
7
  export declare class SandboxFsImpl implements ISandboxFs {
8
8
  private vfs;
9
9
  private getCwd;
10
- constructor(vfs: VFS, getCwd: () => string);
10
+ constructor(vfs: IKernelVfs, getCwd: () => string);
11
11
  private resolvePath;
12
12
  readFile(path: string): Promise<string>;
13
13
  readFile(path: string, encoding: null): Promise<Uint8Array>;
@@ -1 +1 @@
1
- {"version":3,"file":"SandboxFs.d.ts","sourceRoot":"","sources":["../../src/sandbox/SandboxFs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,w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G,WAAW,CAAA;KAAE,CAAC,CAAC;IAKnF,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAMxF,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAKrE,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAclE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKtC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMvD,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM5C,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CAAA;KAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAM7F,4DAA4D;IAC5D,OAAO,CAAC,MAAM,CAAC,SAAS,CAA8B;IAEhD,cAAc,IAAI,OAAO,CAAC,UAAU,CAAC;IA0CrC,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAyBtD"}
@@ -1,8 +1,7 @@
1
1
  import { Command } from '../commands/types.js';
2
- import { Kernel } from '../kernel/index.js';
2
+ import { Kernel, NativeFsModule } from '@lifo-sh/kernel';
3
3
  import { Shell } from '../shell/Shell.js';
4
4
  import { ITerminal } from '../terminal/ITerminal.js';
5
- import { NativeFsModule } from '../kernel/vfs/providers/NativeFsProvider.js';
6
5
  export interface SandboxOptions {
7
6
  /** Enable IndexedDB persistence (default: false) */
8
7
  persist?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sandbox/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAIlF,MAAM,WAAW,cAAc;IAC7B,oDAAoD;IACpD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yDAAyD;IACzD,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,sDAAsD;IACtD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC;IAC5C,yGAAyG;IACzG,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;IAC5C;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC;QACb,qEAAqE;QACrE,WAAW,EAAE,MAAM,CAAC;QACpB,oCAAoC;QACpC,QAAQ,EAAE,MAAM,CAAC;QACjB,uDAAuD;QACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,iFAAiF;QACjF,QAAQ,CAAC,EAAE,cAAc,CAAC;KAC3B,CAAC,CAAC;CACJ;AAID,MAAM,WAAW,UAAU;IACzB,yCAAyC;IACzC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,GAAG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E,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CAAA;KAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxF,6CAA6C;IAC7C,cAAc,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;IACtC,yCAAyC;IACzC,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjD;AAID,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;CACd"}
@@ -0,0 +1,142 @@
1
+ import { r as resolve, V as VFSError } from "./index-GLjTMF7C.js";
2
+ import { i as isBinaryMime, g as getMimeType } from "./mime-B5knsVEw.js";
3
+ function parseSedExpr(expr) {
4
+ if (expr === "d") {
5
+ return { type: "d" };
6
+ }
7
+ if (expr === "p") {
8
+ return { type: "p" };
9
+ }
10
+ if (expr.startsWith("s")) {
11
+ const delim = expr[1];
12
+ if (!delim) return null;
13
+ const parts = [];
14
+ let current = "";
15
+ let escaped = false;
16
+ for (let i = 2; i < expr.length; i++) {
17
+ if (escaped) {
18
+ current += expr[i];
19
+ escaped = false;
20
+ } else if (expr[i] === "\\") {
21
+ escaped = true;
22
+ current += "\\";
23
+ } else if (expr[i] === delim) {
24
+ parts.push(current);
25
+ current = "";
26
+ } else {
27
+ current += expr[i];
28
+ }
29
+ }
30
+ parts.push(current);
31
+ if (parts.length < 2) return null;
32
+ const patternStr = parts[0];
33
+ const replacement = parts[1];
34
+ const flagStr = parts[2] || "";
35
+ const globalFlag = flagStr.includes("g");
36
+ const caseInsensitive = flagStr.includes("i");
37
+ let regex;
38
+ try {
39
+ let flags = "";
40
+ if (globalFlag) flags += "g";
41
+ if (caseInsensitive) flags += "i";
42
+ regex = new RegExp(patternStr, flags);
43
+ } catch {
44
+ return null;
45
+ }
46
+ return { type: "s", pattern: regex, replacement, global: globalFlag };
47
+ }
48
+ return null;
49
+ }
50
+ const command = async (ctx) => {
51
+ let inPlace = false;
52
+ const expressions = [];
53
+ const files = [];
54
+ for (let i = 0; i < ctx.args.length; i++) {
55
+ const arg = ctx.args[i];
56
+ if (arg === "-i") {
57
+ inPlace = true;
58
+ } else if (arg === "-e" && i + 1 < ctx.args.length) {
59
+ expressions.push(ctx.args[++i]);
60
+ } else if (expressions.length === 0 && !arg.startsWith("-")) {
61
+ expressions.push(arg);
62
+ } else {
63
+ files.push(arg);
64
+ }
65
+ }
66
+ if (expressions.length === 0) {
67
+ ctx.stderr.write("sed: missing expression\n");
68
+ return 1;
69
+ }
70
+ const parsedExprs = [];
71
+ for (const expr of expressions) {
72
+ const parsed = parseSedExpr(expr);
73
+ if (!parsed) {
74
+ ctx.stderr.write(`sed: invalid expression: ${expr}
75
+ `);
76
+ return 1;
77
+ }
78
+ parsedExprs.push(parsed);
79
+ }
80
+ function processText(text) {
81
+ const lines = text.replace(/\n$/, "").split("\n");
82
+ const output = [];
83
+ for (let line of lines) {
84
+ let deleted = false;
85
+ for (const expr of parsedExprs) {
86
+ if (expr.type === "s" && expr.pattern && expr.replacement !== void 0) {
87
+ line = line.replace(expr.pattern, expr.replacement);
88
+ } else if (expr.type === "d") {
89
+ deleted = true;
90
+ break;
91
+ } else if (expr.type === "p") {
92
+ output.push(line);
93
+ }
94
+ }
95
+ if (!deleted) {
96
+ output.push(line);
97
+ }
98
+ }
99
+ return output.join("\n") + "\n";
100
+ }
101
+ if (files.length === 0) {
102
+ if (ctx.stdin) {
103
+ const text = await ctx.stdin.readAll();
104
+ ctx.stdout.write(processText(text));
105
+ } else {
106
+ ctx.stderr.write("sed: missing file operand\n");
107
+ return 1;
108
+ }
109
+ return 0;
110
+ }
111
+ let exitCode = 0;
112
+ for (const file of files) {
113
+ const path = resolve(ctx.cwd, file);
114
+ try {
115
+ ctx.vfs.stat(path);
116
+ if (isBinaryMime(getMimeType(path))) {
117
+ ctx.stderr.write(`sed: ${file}: binary file, skipping
118
+ `);
119
+ continue;
120
+ }
121
+ const content = ctx.vfs.readFileString(path);
122
+ const result = processText(content);
123
+ if (inPlace) {
124
+ ctx.vfs.writeFile(path, result);
125
+ } else {
126
+ ctx.stdout.write(result);
127
+ }
128
+ } catch (e) {
129
+ if (e instanceof VFSError) {
130
+ ctx.stderr.write(`sed: ${file}: ${e.message}
131
+ `);
132
+ exitCode = 1;
133
+ } else {
134
+ throw e;
135
+ }
136
+ }
137
+ }
138
+ return exitCode;
139
+ };
140
+ export {
141
+ command as default
142
+ };
@@ -0,0 +1,64 @@
1
+ const command = async (ctx) => {
2
+ const args = ctx.args;
3
+ if (args.length === 0) {
4
+ ctx.stderr.write("Usage: seq [-s SEP] [FIRST [INCR]] LAST\n");
5
+ ctx.stderr.write("Print a sequence of numbers.\n");
6
+ return 1;
7
+ }
8
+ let first = 1;
9
+ let increment = 1;
10
+ let last;
11
+ let separator = "\n";
12
+ let equalWidth = false;
13
+ const positional = [];
14
+ for (let i = 0; i < args.length; i++) {
15
+ if (args[i] === "-s" && i + 1 < args.length) {
16
+ separator = args[++i];
17
+ } else if (args[i] === "-w") {
18
+ equalWidth = true;
19
+ } else {
20
+ positional.push(args[i]);
21
+ }
22
+ }
23
+ if (positional.length === 1) {
24
+ last = parseFloat(positional[0]);
25
+ } else if (positional.length === 2) {
26
+ first = parseFloat(positional[0]);
27
+ last = parseFloat(positional[1]);
28
+ } else {
29
+ first = parseFloat(positional[0]);
30
+ increment = parseFloat(positional[1]);
31
+ last = parseFloat(positional[2]);
32
+ }
33
+ if (isNaN(first) || isNaN(increment) || isNaN(last)) {
34
+ ctx.stderr.write("seq: invalid argument\n");
35
+ return 1;
36
+ }
37
+ if (increment === 0) {
38
+ ctx.stderr.write("seq: zero increment\n");
39
+ return 1;
40
+ }
41
+ const results = [];
42
+ const isInt = Number.isInteger(first) && Number.isInteger(increment) && Number.isInteger(last);
43
+ if (increment > 0) {
44
+ for (let n = first; n <= last + 1e-10; n += increment) {
45
+ results.push(isInt ? String(Math.round(n)) : String(n));
46
+ }
47
+ } else {
48
+ for (let n = first; n >= last - 1e-10; n += increment) {
49
+ results.push(isInt ? String(Math.round(n)) : String(n));
50
+ }
51
+ }
52
+ if (results.length > 0) {
53
+ if (equalWidth && isInt) {
54
+ const maxLen = Math.max(...results.map((r) => r.length));
55
+ ctx.stdout.write(results.map((r) => r.padStart(maxLen, "0")).join(separator) + "\n");
56
+ } else {
57
+ ctx.stdout.write(results.join(separator) + "\n");
58
+ }
59
+ }
60
+ return 0;
61
+ };
62
+ export {
63
+ command as default
64
+ };
@@ -0,0 +1,85 @@
1
+ import { r as resolve, V as VFSError } from "./index-GLjTMF7C.js";
2
+ async function sha256(data) {
3
+ const hash = await crypto.subtle.digest("SHA-256", data);
4
+ const bytes = new Uint8Array(hash);
5
+ let hex = "";
6
+ for (let i = 0; i < bytes.length; i++) {
7
+ hex += bytes[i].toString(16).padStart(2, "0");
8
+ }
9
+ return hex;
10
+ }
11
+ const command = async (ctx) => {
12
+ let exitCode = 0;
13
+ let check = false;
14
+ const files = [];
15
+ for (const arg of ctx.args) {
16
+ if (arg === "-c" || arg === "--check") {
17
+ check = true;
18
+ } else {
19
+ files.push(arg);
20
+ }
21
+ }
22
+ if (check && files.length > 0) {
23
+ const path = resolve(ctx.cwd, files[0]);
24
+ let content;
25
+ try {
26
+ content = ctx.vfs.readFileString(path);
27
+ } catch (e) {
28
+ if (e instanceof VFSError) {
29
+ ctx.stderr.write(`sha256sum: ${files[0]}: ${e.message}
30
+ `);
31
+ return 1;
32
+ }
33
+ throw e;
34
+ }
35
+ for (const line of content.trim().split("\n")) {
36
+ const match = line.match(/^([0-9a-f]{64})\s+(.+)$/);
37
+ if (!match) continue;
38
+ const [, expectedHash, fileName] = match;
39
+ const filePath = resolve(ctx.cwd, fileName);
40
+ try {
41
+ const data = ctx.vfs.readFile(filePath);
42
+ const actual = await sha256(data);
43
+ if (actual === expectedHash) {
44
+ ctx.stdout.write(`${fileName}: OK
45
+ `);
46
+ } else {
47
+ ctx.stdout.write(`${fileName}: FAILED
48
+ `);
49
+ exitCode = 1;
50
+ }
51
+ } catch {
52
+ ctx.stdout.write(`${fileName}: FAILED open or read
53
+ `);
54
+ exitCode = 1;
55
+ }
56
+ }
57
+ return exitCode;
58
+ }
59
+ if (files.length === 0) {
60
+ ctx.stderr.write("Usage: sha256sum [-c FILE] FILE...\n");
61
+ ctx.stderr.write("Compute or verify SHA-256 checksums.\n");
62
+ return 1;
63
+ }
64
+ for (const file of files) {
65
+ const path = resolve(ctx.cwd, file);
66
+ try {
67
+ const data = ctx.vfs.readFile(path);
68
+ const hash = await sha256(data);
69
+ ctx.stdout.write(`${hash} ${file}
70
+ `);
71
+ } catch (e) {
72
+ if (e instanceof VFSError) {
73
+ ctx.stderr.write(`sha256sum: ${file}: ${e.message}
74
+ `);
75
+ exitCode = 1;
76
+ } else {
77
+ throw e;
78
+ }
79
+ }
80
+ }
81
+ return exitCode;
82
+ };
83
+ export {
84
+ command as default
85
+ };