@lifo-sh/core 0.1.0 → 0.3.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 (115) hide show
  1. package/README.md +65 -0
  2. package/dist/awk-B6L8oRkp.js +123 -0
  3. package/dist/{basename-C33A_Zse.js → basename-CgA_lsvv.js} +1 -1
  4. package/dist/{cat-Crmqa4-2.js → cat-UKg6GIpI.js} +1 -1
  5. package/dist/{chmod-CcGyvoCX.js → chmod-DHB58pfa.js} +1 -1
  6. package/dist/{chown-CErsnGQX.js → chown-D1bGwvZd.js} +1 -1
  7. package/dist/commands/registry.d.ts.map +1 -1
  8. package/dist/commands/text/awk.d.ts.map +1 -1
  9. package/dist/commands/text/cut.d.ts.map +1 -1
  10. package/dist/commands/text/diff.d.ts.map +1 -1
  11. package/dist/commands/text/grep.d.ts.map +1 -1
  12. package/dist/commands/text/head.d.ts.map +1 -1
  13. package/dist/commands/text/nl.d.ts.map +1 -1
  14. package/dist/commands/text/rev.d.ts.map +1 -1
  15. package/dist/commands/text/sed.d.ts.map +1 -1
  16. package/dist/commands/text/sort.d.ts.map +1 -1
  17. package/dist/commands/text/tail.d.ts.map +1 -1
  18. package/dist/commands/text/uniq.d.ts.map +1 -1
  19. package/dist/commands/text/wc.d.ts.map +1 -1
  20. package/dist/commands/vcs/git.d.ts +4 -0
  21. package/dist/commands/vcs/git.d.ts.map +1 -0
  22. package/dist/{cp-CpjwiLUF.js → cp-hsOMjGjb.js} +1 -1
  23. package/dist/cut-BxA2sLod.js +65 -0
  24. package/dist/diff-BgH1-ECz.js +150 -0
  25. package/dist/{dirname-C5L53RA2.js → dirname-BsNcj76E.js} +1 -1
  26. package/dist/{du-B0shJpEL.js → du-Dz7i5Bf4.js} +1 -1
  27. package/dist/{file-C2epVYvH.js → file-CiWscEov.js} +1 -1
  28. package/dist/{find-DA-rpvsC.js → find-CWXxOQ3D.js} +1 -1
  29. package/dist/git-mHSHRpnj.js +603 -0
  30. package/dist/{grep-Bynq2w2E.js → grep-BQsxs32R.js} +33 -26
  31. package/dist/gunzip-DF-BdBEb.js +47 -0
  32. package/dist/{gzip-CkXnPp5J.js → gzip-lYiTGRe_.js} +4 -5
  33. package/dist/head-BtcClCUM.js +53 -0
  34. package/dist/{index-Be1wosKt.js → index-Do_xqri5.js} +2769 -1498
  35. package/dist/index.d.ts +11 -2
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +58 -45
  38. package/dist/kernel/index.d.ts +2 -1
  39. package/dist/kernel/index.d.ts.map +1 -1
  40. package/dist/kernel/persistence/PersistenceManager.d.ts +3 -1
  41. package/dist/kernel/persistence/PersistenceManager.d.ts.map +1 -1
  42. package/dist/kernel/persistence/backends.d.ts +22 -0
  43. package/dist/kernel/persistence/backends.d.ts.map +1 -0
  44. package/dist/kernel/persistence/index.d.ts +6 -0
  45. package/dist/kernel/persistence/index.d.ts.map +1 -0
  46. package/dist/kernel/persistence/serializer.d.ts +8 -0
  47. package/dist/kernel/persistence/serializer.d.ts.map +1 -1
  48. package/dist/kernel/storage/BlobStore.d.ts +31 -0
  49. package/dist/kernel/storage/BlobStore.d.ts.map +1 -0
  50. package/dist/kernel/storage/ContentStore.d.ts +52 -0
  51. package/dist/kernel/storage/ContentStore.d.ts.map +1 -0
  52. package/dist/kernel/storage/index.d.ts +7 -0
  53. package/dist/kernel/storage/index.d.ts.map +1 -0
  54. package/dist/kernel/vfs/VFS.d.ts +31 -3
  55. package/dist/kernel/vfs/VFS.d.ts.map +1 -1
  56. package/dist/kernel/vfs/index.d.ts +4 -1
  57. package/dist/kernel/vfs/index.d.ts.map +1 -1
  58. package/dist/kernel/vfs/providers/NativeFsProvider.d.ts +63 -0
  59. package/dist/kernel/vfs/providers/NativeFsProvider.d.ts.map +1 -0
  60. package/dist/kernel/vfs/types.d.ts +27 -0
  61. package/dist/kernel/vfs/types.d.ts.map +1 -1
  62. package/dist/{ls-CSeazevv.js → ls-BX03h4IP.js} +1 -1
  63. package/dist/{mkdir-B7p8krsP.js → mkdir-DGGZuAyh.js} +1 -1
  64. package/dist/{mktemp-88Nhvd7h.js → mktemp-C537o9DE.js} +1 -1
  65. package/dist/{mv-DRVvz9oK.js → mv-46W3dEtX.js} +1 -1
  66. package/dist/{nl-G2vK3rR3.js → nl-vZH6hOSG.js} +13 -10
  67. package/dist/node-compat/buffer.d.ts +29 -2
  68. package/dist/node-compat/buffer.d.ts.map +1 -1
  69. package/dist/node-compat/fs.d.ts +62 -0
  70. package/dist/node-compat/fs.d.ts.map +1 -1
  71. package/dist/{realpath-C-kisl-F.js → realpath-Ubp4BElh.js} +1 -1
  72. package/dist/rev-Dqg_gF2D.js +39 -0
  73. package/dist/{rm-BXSq9iqP.js → rm-FnbVRwGK.js} +1 -1
  74. package/dist/{rmdir-CWgZ6q8D.js → rmdir-B2a-CeUJ.js} +3 -3
  75. package/dist/sandbox/HeadlessTerminal.d.ts +2 -1
  76. package/dist/sandbox/HeadlessTerminal.d.ts.map +1 -1
  77. package/dist/sandbox/Sandbox.d.ts +31 -0
  78. package/dist/sandbox/Sandbox.d.ts.map +1 -1
  79. package/dist/sandbox/SandboxFs.d.ts +4 -0
  80. package/dist/sandbox/SandboxFs.d.ts.map +1 -1
  81. package/dist/sandbox/types.d.ts +22 -2
  82. package/dist/sandbox/types.d.ts.map +1 -1
  83. package/dist/sed-BHijDEOD.js +95 -0
  84. package/dist/shell/Shell.d.ts +2 -2
  85. package/dist/shell/Shell.d.ts.map +1 -1
  86. package/dist/{sort-B7K83hAD.js → sort-CheGhnUV.js} +19 -14
  87. package/dist/{stat-C0qs7xMV.js → stat-YSBnw2tJ.js} +1 -1
  88. package/dist/tail-9Z1OE7L7.js +52 -0
  89. package/dist/{tar-mMS7gfb-.js → tar-Dc-wpdQT.js} +15 -16
  90. package/dist/{tee-B8bXFHbI.js → tee-C4QkabXH.js} +1 -1
  91. package/dist/terminal/ITerminal.d.ts +10 -0
  92. package/dist/terminal/ITerminal.d.ts.map +1 -0
  93. package/dist/{touch-CdAHKfLv.js → touch-BeFpZeqv.js} +1 -1
  94. package/dist/{tree-BiWLXiUu.js → tree-BiBsUSQR.js} +1 -1
  95. package/dist/uniq-BeGU0UTU.js +54 -0
  96. package/dist/{unzip-DP4I991d.js → unzip-SUXLk4bS.js} +18 -19
  97. package/dist/utils/mime.d.ts +4 -0
  98. package/dist/utils/mime.d.ts.map +1 -0
  99. package/dist/wc-BLupYdzi.js +69 -0
  100. package/dist/{wget-DIPI0-I3.js → wget-ALEPUtGk.js} +1 -1
  101. package/dist/{zip-B_gQ6LXC.js → zip-V6SMbx7b.js} +11 -12
  102. package/package.json +37 -10
  103. package/dist/archive-D220So0m.js +0 -192
  104. package/dist/awk-rMPdpM91.js +0 -118
  105. package/dist/cut-GfN8py4j.js +0 -60
  106. package/dist/diff-2wbVWmCT.js +0 -129
  107. package/dist/gunzip-B9b1Vph1.js +0 -48
  108. package/dist/head-DZJVLF1k.js +0 -48
  109. package/dist/rev-9puwegeh.js +0 -34
  110. package/dist/sed-BRxd2DlZ.js +0 -90
  111. package/dist/tail-CYBTYnn3.js +0 -47
  112. package/dist/terminal/Terminal.d.ts +0 -13
  113. package/dist/terminal/Terminal.d.ts.map +0 -1
  114. package/dist/uniq-BZMOwoCc.js +0 -51
  115. package/dist/wc-CpE5K4ZI.js +0 -60
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # @lifo-sh/core
2
+
3
+ Core engine for [Lifo](https://github.com/lifo-sh/lifo) -- a Linux-like OS that runs natively in JavaScript. Provides the kernel, virtual filesystem, shell, and 60+ commands.
4
+
5
+ Works in both browser and Node.js environments.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @lifo-sh/core
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ### Headless / Programmatic
16
+
17
+ ```typescript
18
+ import { Sandbox } from '@lifo-sh/core';
19
+
20
+ const sandbox = await Sandbox.create();
21
+
22
+ const result = await sandbox.commands.run('echo hello world');
23
+ console.log(result.stdout); // "hello world\n"
24
+
25
+ await sandbox.fs.writeFile('/tmp/greeting.txt', 'Hi there');
26
+ const content = await sandbox.fs.readFile('/tmp/greeting.txt');
27
+ console.log(content); // "Hi there"
28
+ ```
29
+
30
+ ### Browser with Terminal UI
31
+
32
+ ```typescript
33
+ import { Sandbox } from '@lifo-sh/core';
34
+
35
+ // Requires @lifo-sh/ui as an optional peer dependency
36
+ const sandbox = await Sandbox.create({
37
+ terminal: '#terminal-container',
38
+ persist: true,
39
+ });
40
+ ```
41
+
42
+ ## What's Included
43
+
44
+ - **Kernel** -- virtual filesystem (VFS), virtual `/proc` and `/dev` providers, IndexedDB persistence
45
+ - **Shell** -- bash-like interpreter with pipes, redirects, globs, variables, job control, tab completion, history
46
+ - **60+ commands** -- `ls`, `grep`, `awk`, `sed`, `curl`, `node`, `tar`, `find`, and more
47
+ - **Sandbox API** -- high-level `commands.run()` and `fs.*` for programmatic use
48
+ - **Node.js compat layer** -- run JS files with `node script.js` using shimmed `fs`, `path`, `http`, etc.
49
+
50
+ ## Packages
51
+
52
+ | Package | Description |
53
+ |---|---|
54
+ | **@lifo-sh/core** | Kernel, shell, commands, sandbox API |
55
+ | [@lifo-sh/ui](https://www.npmjs.com/package/@lifo-sh/ui) | Terminal UI (xterm.js wrapper) |
56
+ | [lifo-sh](https://www.npmjs.com/package/lifo-sh) | CLI -- run Lifo in your terminal |
57
+
58
+ ## Links
59
+
60
+ - [GitHub](https://github.com/lifo-sh/lifo)
61
+ - [Issues](https://github.com/lifo-sh/lifo/issues)
62
+
63
+ ## License
64
+
65
+ MIT
@@ -0,0 +1,123 @@
1
+ import { r as E, i as N, c as S, V as $ } from "./index-Do_xqri5.js";
2
+ function W(e) {
3
+ const o = [];
4
+ let t = e.trim();
5
+ for (; t.length > 0 && (t = t.trim(), t.length !== 0); ) {
6
+ let s = null, a = "";
7
+ if (t.startsWith("BEGIN"))
8
+ s = "BEGIN", t = t.slice(5).trim();
9
+ else if (t.startsWith("END"))
10
+ s = "END", t = t.slice(3).trim();
11
+ else if (t.startsWith("/")) {
12
+ const n = t.indexOf("/", 1);
13
+ if (n > 0) {
14
+ try {
15
+ s = new RegExp(t.slice(1, n));
16
+ } catch {
17
+ s = null;
18
+ }
19
+ t = t.slice(n + 1).trim();
20
+ }
21
+ }
22
+ if (t.startsWith("{")) {
23
+ let n = 0, l = 0;
24
+ for (; l < t.length; l++)
25
+ if (t[l] === "{") n++;
26
+ else if (t[l] === "}" && (n--, n === 0))
27
+ break;
28
+ a = t.slice(1, l).trim(), t = t.slice(l + 1).trim();
29
+ } else s === null && (a = t, t = "");
30
+ o.push({ pattern: s, action: a });
31
+ }
32
+ return o;
33
+ }
34
+ function m(e, o, t, s, a, n, l) {
35
+ const f = [], p = e.split(";").map((r) => r.trim()).filter(Boolean);
36
+ for (const r of p)
37
+ if (r === "print" || r === "print $0")
38
+ f.push(t);
39
+ else if (r.startsWith("print ")) {
40
+ const h = r.slice(6).trim().split(",").map((g) => g.trim()).map((g) => k(g, o, t, s, a, l));
41
+ f.push(h.join(" "));
42
+ }
43
+ return f.join(`
44
+ `);
45
+ }
46
+ function k(e, o, t, s, a, n) {
47
+ if (e = e.trim(), e.startsWith('"') && e.endsWith('"'))
48
+ return e.slice(1, -1).replace(/\\n/g, `
49
+ `).replace(/\\t/g, " ");
50
+ if (e.startsWith("$")) {
51
+ const l = e.slice(1);
52
+ if (l === "NF")
53
+ return o[a - 1] || "";
54
+ const f = parseInt(l, 10);
55
+ return f === 0 ? t : o[f - 1] || "";
56
+ }
57
+ return e === "NR" ? String(s) : e === "NF" ? String(a) : n.has(e) ? n.get(e) : e;
58
+ }
59
+ const B = async (e) => {
60
+ let o = /\s+/, t = " ", s = "";
61
+ const a = [];
62
+ for (let r = 0; r < e.args.length; r++) {
63
+ const i = e.args[r];
64
+ i === "-F" && r + 1 < e.args.length ? (t = e.args[++r], o = new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))) : i.startsWith("-F") && i.length > 2 ? (t = i.slice(2), o = new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))) : s ? a.push(i) : s = i;
65
+ }
66
+ if (!s)
67
+ return e.stderr.write(`awk: missing program
68
+ `), 1;
69
+ let n = "";
70
+ if (a.length === 0)
71
+ if (e.stdin)
72
+ n = await e.stdin.readAll();
73
+ else
74
+ return e.stderr.write(`awk: missing file operand
75
+ `), 1;
76
+ else
77
+ for (const r of a) {
78
+ const i = E(e.cwd, r);
79
+ try {
80
+ if (e.vfs.stat(i), N(S(i))) {
81
+ e.stderr.write(`awk: ${r}: binary file, skipping
82
+ `);
83
+ continue;
84
+ }
85
+ n += e.vfs.readFileString(i);
86
+ } catch (c) {
87
+ if (c instanceof $)
88
+ return e.stderr.write(`awk: ${r}: ${c.message}
89
+ `), 1;
90
+ throw c;
91
+ }
92
+ }
93
+ const l = W(s), f = n.replace(/\n$/, "").split(`
94
+ `), p = /* @__PURE__ */ new Map();
95
+ for (const r of l)
96
+ if (r.pattern === "BEGIN") {
97
+ const i = m(r.action, [], "", 0, 0, t, p);
98
+ i && e.stdout.write(i + `
99
+ `);
100
+ }
101
+ for (let r = 0; r < f.length; r++) {
102
+ const i = f[r], c = i.split(o).filter((u) => u !== ""), h = r + 1, g = c.length;
103
+ for (const u of l) {
104
+ if (u.pattern === "BEGIN" || u.pattern === "END") continue;
105
+ let d = !0;
106
+ if (u.pattern instanceof RegExp && (d = u.pattern.test(i)), d) {
107
+ const w = m(u.action, c, i, h, g, t, p);
108
+ w && e.stdout.write(w + `
109
+ `);
110
+ }
111
+ }
112
+ }
113
+ for (const r of l)
114
+ if (r.pattern === "END") {
115
+ const i = m(r.action, [], "", f.length, 0, t, p);
116
+ i && e.stdout.write(i + `
117
+ `);
118
+ }
119
+ return 0;
120
+ };
121
+ export {
122
+ B as default
123
+ };
@@ -1,4 +1,4 @@
1
- import { b as a } from "./index-Be1wosKt.js";
1
+ import { b as a } from "./index-Do_xqri5.js";
2
2
  const t = async (s) => {
3
3
  if (s.args.length === 0)
4
4
  return s.stderr.write(`basename: missing operand
@@ -1,4 +1,4 @@
1
- import { r as o, V as a } from "./index-Be1wosKt.js";
1
+ import { r as o, V as a } from "./index-Do_xqri5.js";
2
2
  const d = async (r) => {
3
3
  if (r.args.length === 0) {
4
4
  if (r.stdin) {
@@ -1,4 +1,4 @@
1
- import { r as u, V as l } from "./index-Be1wosKt.js";
1
+ import { r as u, V as l } from "./index-Do_xqri5.js";
2
2
  function h(t, d) {
3
3
  if (/^[0-7]+$/.test(t))
4
4
  return parseInt(t, 8);
@@ -1,5 +1,5 @@
1
1
  import { p as i } from "./args-CG6b9cZt.js";
2
- import { r as c, V as f } from "./index-Be1wosKt.js";
2
+ import { r as c, V as f } from "./index-Do_xqri5.js";
3
3
  const l = {
4
4
  recursive: { type: "boolean", short: "R" }
5
5
  }, d = async (s) => {
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/commands/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAA8B;IAC9C,OAAO,CAAC,IAAI,CAA0D;IAEtE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAI9C,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,GAAG,IAAI;IAIvE,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAezD,IAAI,IAAI,MAAM,EAAE;CAIjB;AAED,wBAAgB,qBAAqB,IAAI,eAAe,CAoFvD"}
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/commands/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAA8B;IAC9C,OAAO,CAAC,IAAI,CAA0D;IAEtE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAI9C,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,GAAG,IAAI;IAIvE,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAezD,IAAI,IAAI,MAAM,EAAE;CAIjB;AAED,wBAAgB,qBAAqB,IAAI,eAAe,CAuFvD"}
@@ -1 +1 @@
1
- {"version":3,"file":"awk.d.ts","sourceRoot":"","sources":["../../../src/commands/text/awk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AA6G3C,QAAA,MAAM,OAAO,EAAE,OA4Fd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"awk.d.ts","sourceRoot":"","sources":["../../../src/commands/text/awk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AA8G3C,QAAA,MAAM,OAAO,EAAE,OAiGd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"cut.d.ts","sourceRoot":"","sources":["../../../src/commands/text/cut.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAsB3C,QAAA,MAAM,OAAO,EAAE,OA6Dd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"cut.d.ts","sourceRoot":"","sources":["../../../src/commands/text/cut.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAuB3C,QAAA,MAAM,OAAO,EAAE,OAkEd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/commands/text/diff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAoO3C,QAAA,MAAM,OAAO,EAAE,OAsDd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/commands/text/diff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAqO3C,QAAA,MAAM,OAAO,EAAE,OAkFd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../../src/commands/text/grep.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAI3C,QAAA,MAAM,OAAO,EAAE,OA2Jd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../../src/commands/text/grep.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAK3C,QAAA,MAAM,OAAO,EAAE,OAkKd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"head.d.ts","sourceRoot":"","sources":["../../../src/commands/text/head.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAI3C,QAAA,MAAM,OAAO,EAAE,OAuDd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"head.d.ts","sourceRoot":"","sources":["../../../src/commands/text/head.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAK3C,QAAA,MAAM,OAAO,EAAE,OA4Dd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"nl.d.ts","sourceRoot":"","sources":["../../../src/commands/text/nl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAU3C,QAAA,MAAM,OAAO,EAAE,OAuDd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"nl.d.ts","sourceRoot":"","sources":["../../../src/commands/text/nl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAW3C,QAAA,MAAM,OAAO,EAAE,OA4Dd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"rev.d.ts","sourceRoot":"","sources":["../../../src/commands/text/rev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAQ3C,QAAA,MAAM,OAAO,EAAE,OA6Bd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"rev.d.ts","sourceRoot":"","sources":["../../../src/commands/text/rev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAS3C,QAAA,MAAM,OAAO,EAAE,OAkCd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sed.d.ts","sourceRoot":"","sources":["../../../src/commands/text/sed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AA+D3C,QAAA,MAAM,OAAO,EAAE,OA0Fd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"sed.d.ts","sourceRoot":"","sources":["../../../src/commands/text/sed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAgE3C,QAAA,MAAM,OAAO,EAAE,OA+Fd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../../src/commands/text/sort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAI3C,QAAA,MAAM,OAAO,EAAE,OA2Ed,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../../src/commands/text/sort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAK3C,QAAA,MAAM,OAAO,EAAE,OAgFd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"tail.d.ts","sourceRoot":"","sources":["../../../src/commands/text/tail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAI3C,QAAA,MAAM,OAAO,EAAE,OAkDd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"tail.d.ts","sourceRoot":"","sources":["../../../src/commands/text/tail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAK3C,QAAA,MAAM,OAAO,EAAE,OAuDd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"uniq.d.ts","sourceRoot":"","sources":["../../../src/commands/text/uniq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAI3C,QAAA,MAAM,OAAO,EAAE,OAgEd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"uniq.d.ts","sourceRoot":"","sources":["../../../src/commands/text/uniq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAK3C,QAAA,MAAM,OAAO,EAAE,OAqEd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"wc.d.ts","sourceRoot":"","sources":["../../../src/commands/text/wc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAI3C,QAAA,MAAM,OAAO,EAAE,OAkFd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"wc.d.ts","sourceRoot":"","sources":["../../../src/commands/text/wc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAK3C,QAAA,MAAM,OAAO,EAAE,OAgGd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Command } from '../types.js';
2
+ declare const gitCommand: Command;
3
+ export default gitCommand;
4
+ //# sourceMappingURL=git.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../../src/commands/vcs/git.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAkB,MAAM,aAAa,CAAC;AAu0B3D,QAAA,MAAM,UAAU,EAAE,OA2CjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -1,4 +1,4 @@
1
- import { r as t, b as n, V as o } from "./index-Be1wosKt.js";
1
+ import { r as t, b as n, V as o } from "./index-Do_xqri5.js";
2
2
  const f = async (s) => {
3
3
  if (s.args.length < 2)
4
4
  return s.stderr.write(`cp: missing operand
@@ -0,0 +1,65 @@
1
+ import { r as d, i as c, c as u, V as g } from "./index-Do_xqri5.js";
2
+ function h(e) {
3
+ const i = [];
4
+ for (const r of e.split(",")) {
5
+ const n = r.split("-");
6
+ if (n.length === 2) {
7
+ const a = parseInt(n[0], 10), o = parseInt(n[1], 10);
8
+ if (!isNaN(a) && !isNaN(o))
9
+ for (let l = a; l <= o; l++) i.push(l);
10
+ } else {
11
+ const a = parseInt(r, 10);
12
+ isNaN(a) || i.push(a);
13
+ }
14
+ }
15
+ return i;
16
+ }
17
+ const w = async (e) => {
18
+ let i = " ", r = "";
19
+ const n = [];
20
+ for (let s = 0; s < e.args.length; s++) {
21
+ const t = e.args[s];
22
+ t === "-d" && s + 1 < e.args.length ? i = e.args[++s] : t === "-f" && s + 1 < e.args.length ? r = e.args[++s] : t.startsWith("-d") && t.length > 2 ? i = t.slice(2) : t.startsWith("-f") && t.length > 2 ? r = t.slice(2) : n.push(t);
23
+ }
24
+ if (!r)
25
+ return e.stderr.write(`cut: you must specify a list of fields
26
+ `), 1;
27
+ const a = h(r);
28
+ function o(s) {
29
+ const t = s.split(i);
30
+ return a.map((f) => t[f - 1] || "").join(i);
31
+ }
32
+ let l = "";
33
+ if (n.length === 0)
34
+ if (e.stdin)
35
+ l = await e.stdin.readAll();
36
+ else
37
+ return e.stderr.write(`cut: missing file operand
38
+ `), 1;
39
+ else
40
+ for (const s of n) {
41
+ const t = d(e.cwd, s);
42
+ try {
43
+ if (e.vfs.stat(t), c(u(t))) {
44
+ e.stderr.write(`cut: ${s}: binary file, skipping
45
+ `);
46
+ continue;
47
+ }
48
+ l += e.vfs.readFileString(t);
49
+ } catch (f) {
50
+ if (f instanceof g)
51
+ return e.stderr.write(`cut: ${s}: ${f.message}
52
+ `), 1;
53
+ throw f;
54
+ }
55
+ }
56
+ const p = l.replace(/\n$/, "").split(`
57
+ `);
58
+ for (const s of p)
59
+ e.stdout.write(o(s) + `
60
+ `);
61
+ return 0;
62
+ };
63
+ export {
64
+ w as default
65
+ };
@@ -0,0 +1,150 @@
1
+ import { p as k } from "./args-CG6b9cZt.js";
2
+ import { r as g, i as m, c as C, V as y } from "./index-Do_xqri5.js";
3
+ const S = {
4
+ unified: { type: "boolean", short: "u" }
5
+ };
6
+ function L(n, f) {
7
+ const d = n.length, s = f.length, i = Array.from({ length: d + 1 }, () => new Array(s + 1).fill(0));
8
+ for (let e = 1; e <= d; e++)
9
+ for (let o = 1; o <= s; o++)
10
+ n[e - 1] === f[o - 1] ? i[e][o] = i[e - 1][o - 1] + 1 : i[e][o] = Math.max(i[e - 1][o], i[e][o - 1]);
11
+ const h = [];
12
+ let l = d, r = s;
13
+ for (; l > 0 || r > 0; )
14
+ l > 0 && r > 0 && n[l - 1] === f[r - 1] ? (h.push({ type: "keep", oldLine: n[l - 1] }), l--, r--) : r > 0 && (l === 0 || i[l][r - 1] >= i[l - 1][r]) ? (h.push({ type: "insert", newLine: f[r - 1] }), r--) : (h.push({ type: "delete", oldLine: n[l - 1] }), l--);
15
+ return h.reverse();
16
+ }
17
+ function j(n) {
18
+ const f = [];
19
+ let d = 0, s = 0, i = 0;
20
+ for (; i < n.length; ) {
21
+ if (n[i].type === "keep") {
22
+ d++, s++, i++;
23
+ continue;
24
+ }
25
+ const l = d, r = s, e = [], o = [];
26
+ for (; i < n.length && n[i].type !== "keep"; )
27
+ n[i].type === "delete" ? (e.push(n[i].oldLine), d++) : (o.push(n[i].newLine), s++), i++;
28
+ const c = e.length === 1 ? `${l + 1}` : e.length > 0 ? `${l + 1},${l + e.length}` : `${l}`, t = o.length === 1 ? `${r + 1}` : o.length > 0 ? `${r + 1},${r + o.length}` : `${r}`;
29
+ if (e.length > 0 && o.length > 0) {
30
+ f.push(`${c}c${t}`);
31
+ for (const p of e) f.push(`< ${p}`);
32
+ f.push("---");
33
+ for (const p of o) f.push(`> ${p}`);
34
+ } else if (e.length > 0) {
35
+ f.push(`${c}d${t}`);
36
+ for (const p of e) f.push(`< ${p}`);
37
+ } else {
38
+ f.push(`${c}a${t}`);
39
+ for (const p of o) f.push(`> ${p}`);
40
+ }
41
+ }
42
+ return f.length > 0 ? f.join(`
43
+ `) + `
44
+ ` : "";
45
+ }
46
+ function v(n, f, d) {
47
+ if (n.every((t) => t.type === "keep")) return "";
48
+ const s = [];
49
+ let i = 0, h = 0;
50
+ for (const t of n)
51
+ t.type === "keep" ? (s.push({ type: "keep", line: t.oldLine, oldIdx: i, newIdx: h }), i++, h++) : t.type === "delete" ? (s.push({ type: "delete", line: t.oldLine, oldIdx: i, newIdx: h }), i++) : (s.push({ type: "insert", line: t.newLine, oldIdx: i, newIdx: h }), h++);
52
+ const l = 3, r = [];
53
+ let e = null, o = -1 / 0;
54
+ for (let t = 0; t < s.length; t++) {
55
+ const p = s[t];
56
+ if (p.type !== "keep") {
57
+ if (!e || t - o > l * 2 + 1) {
58
+ if (e) {
59
+ for (let a = o + 1; a < Math.min(o + 1 + l, s.length); a++)
60
+ s[a].type === "keep" && (e.lines.push(` ${s[a].line}`), e.oldCount++, e.newCount++);
61
+ r.push(e);
62
+ }
63
+ const $ = Math.max(0, t - l);
64
+ let u = 0, w = 0;
65
+ for (let a = 0; a < $; a++)
66
+ s[a].type !== "insert" && u++, s[a].type !== "delete" && w++;
67
+ e = {
68
+ oldStart: u + 1,
69
+ newStart: w + 1,
70
+ oldCount: 0,
71
+ newCount: 0,
72
+ lines: []
73
+ };
74
+ for (let a = $; a < t; a++)
75
+ s[a].type === "keep" && (e.lines.push(` ${s[a].line}`), e.oldCount++, e.newCount++);
76
+ } else if (t - o > 1)
77
+ for (let $ = o + 1; $ < t; $++)
78
+ s[$].type === "keep" && (e.lines.push(` ${s[$].line}`), e.oldCount++, e.newCount++);
79
+ p.type === "delete" ? (e.lines.push(`-${p.line}`), e.oldCount++) : (e.lines.push(`+${p.line}`), e.newCount++), o = t;
80
+ }
81
+ }
82
+ if (e) {
83
+ for (let t = o + 1; t < Math.min(o + 1 + l, s.length); t++)
84
+ s[t].type === "keep" && (e.lines.push(` ${s[t].line}`), e.oldCount++, e.newCount++);
85
+ r.push(e);
86
+ }
87
+ const c = [];
88
+ c.push(`--- ${f}`), c.push(`+++ ${d}`);
89
+ for (const t of r)
90
+ c.push(`@@ -${t.oldStart},${t.oldCount} +${t.newStart},${t.newCount} @@`), c.push(...t.lines);
91
+ return c.join(`
92
+ `) + `
93
+ `;
94
+ }
95
+ const A = async (n) => {
96
+ const { flags: f, positional: d } = k(n.args, S);
97
+ if (d.length < 2)
98
+ return n.stderr.write(`diff: missing operand
99
+ `), 2;
100
+ const s = d[0], i = d[1];
101
+ let h, l;
102
+ const r = g(n.cwd, s), e = g(n.cwd, i), o = m(C(r)), c = m(C(e));
103
+ if (o || c) {
104
+ try {
105
+ n.vfs.stat(r);
106
+ } catch (u) {
107
+ if (u instanceof y)
108
+ return n.stderr.write(`diff: ${s}: ${u.message}
109
+ `), 2;
110
+ throw u;
111
+ }
112
+ try {
113
+ n.vfs.stat(e);
114
+ } catch (u) {
115
+ if (u instanceof y)
116
+ return n.stderr.write(`diff: ${i}: ${u.message}
117
+ `), 2;
118
+ throw u;
119
+ }
120
+ return n.stdout.write(`Binary files ${s} and ${i} differ
121
+ `), 2;
122
+ }
123
+ try {
124
+ h = n.vfs.readFileString(g(n.cwd, s));
125
+ } catch (u) {
126
+ if (u instanceof y)
127
+ return n.stderr.write(`diff: ${s}: ${u.message}
128
+ `), 2;
129
+ throw u;
130
+ }
131
+ try {
132
+ l = n.vfs.readFileString(g(n.cwd, i));
133
+ } catch (u) {
134
+ if (u instanceof y)
135
+ return n.stderr.write(`diff: ${i}: ${u.message}
136
+ `), 2;
137
+ throw u;
138
+ }
139
+ if (h === l)
140
+ return 0;
141
+ const t = h.split(`
142
+ `), p = l.split(`
143
+ `);
144
+ t.length > 0 && t[t.length - 1] === "" && t.pop(), p.length > 0 && p[p.length - 1] === "" && p.pop();
145
+ const $ = L(t, p);
146
+ return f.unified ? n.stdout.write(v($, s, i)) : n.stdout.write(j($)), 1;
147
+ };
148
+ export {
149
+ A as default
150
+ };
@@ -1,4 +1,4 @@
1
- import { d as a } from "./index-Be1wosKt.js";
1
+ import { k as a } from "./index-Do_xqri5.js";
2
2
  const s = async (r) => {
3
3
  if (r.args.length === 0)
4
4
  return r.stderr.write(`dirname: missing operand
@@ -1,4 +1,4 @@
1
- import { r as y, V as g } from "./index-Be1wosKt.js";
1
+ import { r as y, V as g } from "./index-Do_xqri5.js";
2
2
  function u(t) {
3
3
  return t < 1024 ? t + "B" : t < 1024 * 1024 ? (t / 1024).toFixed(1) + "K" : t < 1024 * 1024 * 1024 ? (t / (1024 * 1024)).toFixed(1) + "M" : (t / (1024 * 1024 * 1024)).toFixed(1) + "G";
4
4
  }
@@ -1,4 +1,4 @@
1
- import { r as d, e as c, V as f } from "./index-Be1wosKt.js";
1
+ import { r as d, e as c, V as f } from "./index-Do_xqri5.js";
2
2
  const n = {
3
3
  ".txt": "ASCII text",
4
4
  ".md": "Markdown text",
@@ -1,4 +1,4 @@
1
- import { r as m, V as d, g as p } from "./index-Be1wosKt.js";
1
+ import { r as m, V as d, g as p } from "./index-Do_xqri5.js";
2
2
  const c = async (t) => {
3
3
  let f = ".", i = "", a = "", l = 1 / 0;
4
4
  for (let e = 0; e < t.args.length; e++) {