@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,132 @@
1
+ import { p as parseArgs } from "./args-BhoL0JcG.js";
2
+ import { r as resolve, V as VFSError, B as BOLD, a as BLUE, R as RESET } from "./index-GLjTMF7C.js";
3
+ const spec = {
4
+ long: { type: "boolean", short: "l" },
5
+ all: { type: "boolean", short: "a" },
6
+ one: { type: "boolean", short: "1" }
7
+ };
8
+ function formatMode(mode, isDir) {
9
+ const d = isDir ? "d" : "-";
10
+ const perms = [
11
+ mode & 256 ? "r" : "-",
12
+ mode & 128 ? "w" : "-",
13
+ mode & 64 ? "x" : "-",
14
+ mode & 32 ? "r" : "-",
15
+ mode & 16 ? "w" : "-",
16
+ mode & 8 ? "x" : "-",
17
+ mode & 4 ? "r" : "-",
18
+ mode & 2 ? "w" : "-",
19
+ mode & 1 ? "x" : "-"
20
+ ].join("");
21
+ return d + perms;
22
+ }
23
+ function formatDate(ts) {
24
+ const d = new Date(ts);
25
+ const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
26
+ const mon = months[d.getMonth()];
27
+ const day = String(d.getDate()).padStart(2, " ");
28
+ const hour = String(d.getHours()).padStart(2, "0");
29
+ const min = String(d.getMinutes()).padStart(2, "0");
30
+ return `${mon} ${day} ${hour}:${min}`;
31
+ }
32
+ function formatEntry(entry, long) {
33
+ const displayName = entry.type === "directory" ? `${BOLD}${BLUE}${entry.name}${RESET}` : entry.name;
34
+ if (long) {
35
+ const mode = formatMode(entry.mode, entry.type === "directory");
36
+ const size = String(entry.size).padStart(6, " ");
37
+ const date = formatDate(entry.mtime);
38
+ return `${mode} 1 user user ${size} ${date} ${displayName}
39
+ `;
40
+ }
41
+ return displayName;
42
+ }
43
+ function listDirectory(path, flags, ctx) {
44
+ const entries = ctx.vfs.readdirStat(path);
45
+ const filtered = flags.all ? entries : entries.filter((e) => !e.name.startsWith("."));
46
+ filtered.sort((a, b) => a.name.localeCompare(b.name));
47
+ return filtered;
48
+ }
49
+ const command = async (ctx) => {
50
+ const { flags, positional } = parseArgs(ctx.args, spec);
51
+ const targets = positional.length > 0 ? positional : [ctx.cwd];
52
+ let exitCode = 0;
53
+ const fileEntries = [];
54
+ const dirTargets = [];
55
+ for (const target of targets) {
56
+ const targetPath = resolve(ctx.cwd, target);
57
+ try {
58
+ const stat = ctx.vfs.stat(targetPath);
59
+ if (stat.type === "file") {
60
+ fileEntries.push({
61
+ name: target,
62
+ type: stat.type,
63
+ size: stat.size,
64
+ mtime: stat.mtime,
65
+ mode: stat.mode
66
+ });
67
+ } else {
68
+ dirTargets.push(target);
69
+ }
70
+ } catch (e) {
71
+ if (e instanceof VFSError) {
72
+ ctx.stderr.write(`ls: ${e.message}
73
+ `);
74
+ exitCode = 1;
75
+ } else {
76
+ throw e;
77
+ }
78
+ }
79
+ }
80
+ if (fileEntries.length > 0) {
81
+ if (flags.long) {
82
+ for (const entry of fileEntries) {
83
+ ctx.stdout.write(formatEntry(entry, true));
84
+ }
85
+ } else if (flags.one) {
86
+ for (const entry of fileEntries) {
87
+ ctx.stdout.write(formatEntry(entry, false) + "\n");
88
+ }
89
+ } else {
90
+ const names = fileEntries.map((e) => formatEntry(e, false));
91
+ ctx.stdout.write(names.join(" ") + "\n");
92
+ }
93
+ }
94
+ for (let i = 0; i < dirTargets.length; i++) {
95
+ const target = dirTargets[i];
96
+ const targetPath = resolve(ctx.cwd, target);
97
+ if (dirTargets.length > 1 || fileEntries.length > 0) {
98
+ if (fileEntries.length > 0 || i > 0) ctx.stdout.write("\n");
99
+ ctx.stdout.write(`${target}:
100
+ `);
101
+ }
102
+ try {
103
+ const entries = listDirectory(targetPath, flags, ctx);
104
+ if (flags.long) {
105
+ for (const entry of entries) {
106
+ ctx.stdout.write(formatEntry(entry, true));
107
+ }
108
+ } else if (flags.one) {
109
+ for (const entry of entries) {
110
+ ctx.stdout.write(formatEntry(entry, false) + "\n");
111
+ }
112
+ } else {
113
+ const names = entries.map((e) => formatEntry(e, false));
114
+ if (names.length > 0) {
115
+ ctx.stdout.write(names.join(" ") + "\n");
116
+ }
117
+ }
118
+ } catch (e) {
119
+ if (e instanceof VFSError) {
120
+ ctx.stderr.write(`ls: ${e.message}
121
+ `);
122
+ exitCode = 1;
123
+ } else {
124
+ throw e;
125
+ }
126
+ }
127
+ }
128
+ return exitCode;
129
+ };
130
+ export {
131
+ command as default
132
+ };
@@ -1,4 +1,4 @@
1
- const a = {
1
+ const PAGES = {
2
2
  // Shell builtins
3
3
  cd: { synopsis: "cd [DIR]", description: "Change the current working directory to DIR. If DIR is not specified, change to HOME." },
4
4
  pwd: { synopsis: "pwd", description: "Print the current working directory." },
@@ -101,35 +101,54 @@ const a = {
101
101
  // Node.js
102
102
  node: { synopsis: "node [-e CODE] [FILE]", description: "Execute JavaScript using the Node.js-compatible runtime." },
103
103
  pkg: { synopsis: "pkg install|remove|list [PACKAGE]", description: "Package manager for installing and managing packages." }
104
- }, p = async (s) => {
105
- if (s.args.length === 0)
106
- return s.stderr.write(`man: missing command name
107
- `), s.stderr.write(`Usage: man [-k] COMMAND
108
- `), 1;
109
- if (s.args[0] === "-k") {
110
- if (s.args.length < 2)
111
- return s.stderr.write(`man: -k requires a keyword
112
- `), 1;
113
- const n = s.args[1].toLowerCase();
114
- let o = !1;
115
- for (const [r, t] of Object.entries(a))
116
- (r.includes(n) || t.synopsis.toLowerCase().includes(n) || t.description.toLowerCase().includes(n)) && (s.stdout.write(`${r}(1) - ${t.description.split(".")[0]}
117
- `), o = !0);
118
- return o ? 0 : (s.stderr.write(`man: nothing appropriate for "${s.args[1]}"
119
- `), 1);
104
+ };
105
+ const command = async (ctx) => {
106
+ if (ctx.args.length === 0) {
107
+ ctx.stderr.write("man: missing command name\n");
108
+ ctx.stderr.write("Usage: man [-k] COMMAND\n");
109
+ return 1;
110
+ }
111
+ if (ctx.args[0] === "-k") {
112
+ if (ctx.args.length < 2) {
113
+ ctx.stderr.write("man: -k requires a keyword\n");
114
+ return 1;
115
+ }
116
+ const keyword = ctx.args[1].toLowerCase();
117
+ let found = false;
118
+ for (const [name2, page2] of Object.entries(PAGES)) {
119
+ if (name2.includes(keyword) || page2.synopsis.toLowerCase().includes(keyword) || page2.description.toLowerCase().includes(keyword)) {
120
+ ctx.stdout.write(`${name2}(1) - ${page2.description.split(".")[0]}
121
+ `);
122
+ found = true;
123
+ }
124
+ }
125
+ if (!found) {
126
+ ctx.stderr.write(`man: nothing appropriate for "${ctx.args[1]}"
127
+ `);
128
+ return 1;
129
+ }
130
+ return 0;
131
+ }
132
+ const name = ctx.args[0];
133
+ const page = PAGES[name];
134
+ if (!page) {
135
+ ctx.stderr.write(`man: no manual entry for ${name}
136
+ `);
137
+ return 1;
120
138
  }
121
- const i = s.args[0], e = a[i];
122
- return e ? (s.stdout.write(`NAME
123
- ${i} - ${e.description.split(".")[0].toLowerCase()}
139
+ ctx.stdout.write(`NAME
140
+ ${name} - ${page.description.split(".")[0].toLowerCase()}
124
141
 
125
- `), s.stdout.write(`SYNOPSIS
126
- ${e.synopsis}
142
+ `);
143
+ ctx.stdout.write(`SYNOPSIS
144
+ ${page.synopsis}
127
145
 
128
- `), s.stdout.write(`DESCRIPTION
129
- ${e.description}
130
- `), 0) : (s.stderr.write(`man: no manual entry for ${i}
131
- `), 1);
146
+ `);
147
+ ctx.stdout.write(`DESCRIPTION
148
+ ${page.description}
149
+ `);
150
+ return 0;
132
151
  };
133
152
  export {
134
- p as default
153
+ command as default
135
154
  };
@@ -0,0 +1,101 @@
1
+ const mimeTypes = /* @__PURE__ */ new Map([
2
+ // Text
3
+ [".txt", "text/plain"],
4
+ [".md", "text/markdown"],
5
+ [".json", "application/json"],
6
+ [".js", "text/javascript"],
7
+ [".ts", "text/typescript"],
8
+ [".jsx", "text/jsx"],
9
+ [".tsx", "text/tsx"],
10
+ [".css", "text/css"],
11
+ [".html", "text/html"],
12
+ [".xml", "text/xml"],
13
+ [".yaml", "text/yaml"],
14
+ [".yml", "text/yaml"],
15
+ [".toml", "text/toml"],
16
+ [".ini", "text/plain"],
17
+ [".cfg", "text/plain"],
18
+ [".conf", "text/plain"],
19
+ [".sh", "text/x-shellscript"],
20
+ [".bash", "text/x-shellscript"],
21
+ [".zsh", "text/x-shellscript"],
22
+ [".py", "text/x-python"],
23
+ [".rb", "text/x-ruby"],
24
+ [".go", "text/x-go"],
25
+ [".rs", "text/x-rust"],
26
+ [".c", "text/x-c"],
27
+ [".cpp", "text/x-c++"],
28
+ [".h", "text/x-c"],
29
+ [".hpp", "text/x-c++"],
30
+ [".java", "text/x-java"],
31
+ [".csv", "text/csv"],
32
+ [".log", "text/plain"],
33
+ [".env", "text/plain"],
34
+ [".gitignore", "text/plain"],
35
+ [".dockerignore", "text/plain"],
36
+ [".sql", "text/x-sql"],
37
+ [".graphql", "text/x-graphql"],
38
+ [".vue", "text/x-vue"],
39
+ [".svelte", "text/x-svelte"],
40
+ // Images
41
+ [".png", "image/png"],
42
+ [".jpg", "image/jpeg"],
43
+ [".jpeg", "image/jpeg"],
44
+ [".gif", "image/gif"],
45
+ [".svg", "image/svg+xml"],
46
+ [".webp", "image/webp"],
47
+ [".ico", "image/x-icon"],
48
+ [".bmp", "image/bmp"],
49
+ [".tiff", "image/tiff"],
50
+ // Video
51
+ [".mp4", "video/mp4"],
52
+ [".webm", "video/webm"],
53
+ [".avi", "video/x-msvideo"],
54
+ [".mov", "video/quicktime"],
55
+ [".mkv", "video/x-matroska"],
56
+ // Audio
57
+ [".mp3", "audio/mpeg"],
58
+ [".wav", "audio/wav"],
59
+ [".ogg", "audio/ogg"],
60
+ [".flac", "audio/flac"],
61
+ [".aac", "audio/aac"],
62
+ [".m4a", "audio/mp4"],
63
+ // Archives
64
+ [".zip", "application/zip"],
65
+ [".tar", "application/x-tar"],
66
+ [".gz", "application/gzip"],
67
+ [".tgz", "application/gzip"],
68
+ [".bz2", "application/x-bzip2"],
69
+ [".7z", "application/x-7z-compressed"],
70
+ [".rar", "application/vnd.rar"],
71
+ // Binary / Application
72
+ [".pdf", "application/pdf"],
73
+ [".wasm", "application/wasm"],
74
+ [".exe", "application/x-msdownload"],
75
+ [".dll", "application/x-msdownload"],
76
+ [".so", "application/x-sharedlib"],
77
+ [".dylib", "application/x-sharedlib"]
78
+ ]);
79
+ function getMimeType(filename) {
80
+ const dot = filename.lastIndexOf(".");
81
+ if (dot === -1) return "application/octet-stream";
82
+ const ext = filename.slice(dot).toLowerCase();
83
+ return mimeTypes.get(ext) ?? "application/octet-stream";
84
+ }
85
+ function getFileCategory(mime) {
86
+ if (mime.startsWith("text/") || mime === "application/json") return "text";
87
+ if (mime.startsWith("image/")) return "image";
88
+ if (mime.startsWith("video/")) return "video";
89
+ if (mime.startsWith("audio/")) return "audio";
90
+ if (mime === "application/zip" || mime === "application/x-tar" || mime === "application/gzip" || mime === "application/x-bzip2" || mime === "application/x-7z-compressed" || mime === "application/vnd.rar") {
91
+ return "archive";
92
+ }
93
+ return "binary";
94
+ }
95
+ function isBinaryMime(mime) {
96
+ return getFileCategory(mime) !== "text";
97
+ }
98
+ export {
99
+ getMimeType as g,
100
+ isBinaryMime as i
101
+ };
@@ -0,0 +1,31 @@
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
+ 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("mkdir: 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.mkdir(path, { recursive: flags.parents });
17
+ } catch (e) {
18
+ if (e instanceof VFSError) {
19
+ ctx.stderr.write(`mkdir: ${arg}: ${e.message}
20
+ `);
21
+ exitCode = 1;
22
+ } else {
23
+ throw e;
24
+ }
25
+ }
26
+ }
27
+ return exitCode;
28
+ };
29
+ export {
30
+ command as default
31
+ };
@@ -0,0 +1,44 @@
1
+ import { p as parseArgs } from "./args-BhoL0JcG.js";
2
+ import { r as resolve } from "./index-GLjTMF7C.js";
3
+ const spec = {
4
+ directory: { type: "boolean", short: "d" },
5
+ tmpdir: { type: "string", short: "p" }
6
+ };
7
+ function randomChars(n) {
8
+ const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
9
+ let result = "";
10
+ for (let i = 0; i < n; i++) {
11
+ result += chars[Math.floor(Math.random() * chars.length)];
12
+ }
13
+ return result;
14
+ }
15
+ const command = async (ctx) => {
16
+ const { flags, positional } = parseArgs(ctx.args, spec);
17
+ const dir = flags.tmpdir || "/tmp";
18
+ const template = positional[0] || "tmp.XXXXXXXXXX";
19
+ const xMatch = template.match(/X+$/);
20
+ const xCount = xMatch ? xMatch[0].length : 0;
21
+ const name = xCount > 0 ? template.slice(0, -xCount) + randomChars(xCount) : template + "." + randomChars(10);
22
+ const fullPath = resolve(dir, name);
23
+ try {
24
+ try {
25
+ ctx.vfs.stat(dir);
26
+ } catch {
27
+ ctx.vfs.mkdir(dir, { recursive: true });
28
+ }
29
+ if (flags.directory) {
30
+ ctx.vfs.mkdir(fullPath);
31
+ } else {
32
+ ctx.vfs.writeFile(fullPath, "");
33
+ }
34
+ ctx.stdout.write(fullPath + "\n");
35
+ return 0;
36
+ } catch (e) {
37
+ ctx.stderr.write(`mktemp: failed to create ${flags.directory ? "directory" : "file"}: ${e.message}
38
+ `);
39
+ return 1;
40
+ }
41
+ };
42
+ export {
43
+ command as default
44
+ };
@@ -0,0 +1,29 @@
1
+ import { r as resolve, b as basename, V as VFSError } from "./index-GLjTMF7C.js";
2
+ const command = async (ctx) => {
3
+ if (ctx.args.length < 2) {
4
+ ctx.stderr.write("mv: missing operand\n");
5
+ return 1;
6
+ }
7
+ const src = resolve(ctx.cwd, ctx.args[0]);
8
+ let dest = resolve(ctx.cwd, ctx.args[1]);
9
+ try {
10
+ if (ctx.vfs.exists(dest)) {
11
+ const stat = ctx.vfs.stat(dest);
12
+ if (stat.type === "directory") {
13
+ dest = resolve(dest, basename(src));
14
+ }
15
+ }
16
+ ctx.vfs.rename(src, dest);
17
+ return 0;
18
+ } catch (e) {
19
+ if (e instanceof VFSError) {
20
+ ctx.stderr.write(`mv: ${e.message}
21
+ `);
22
+ return 1;
23
+ }
24
+ throw e;
25
+ }
26
+ };
27
+ export {
28
+ command as default
29
+ };