typescript-virtual-container 1.4.0 → 1.4.1

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 (102) hide show
  1. package/builds/self-standalone.js +184 -300
  2. package/builds/self-standalone.js.map +3 -3
  3. package/builds/standalone-wo-sftp.js +155 -271
  4. package/builds/standalone-wo-sftp.js.map +3 -3
  5. package/builds/standalone.js +149 -265
  6. package/builds/standalone.js.map +3 -3
  7. package/dist/VirtualPackageManager/index.d.ts.map +1 -1
  8. package/dist/VirtualPackageManager/index.js +29 -1
  9. package/dist/commands/curl.d.ts.map +1 -1
  10. package/dist/commands/curl.js +2 -1
  11. package/dist/commands/gzip.d.ts.map +1 -1
  12. package/dist/commands/gzip.js +6 -0
  13. package/dist/commands/man.d.ts.map +1 -1
  14. package/dist/commands/man.js +30 -136
  15. package/dist/commands/neofetch.d.ts.map +1 -1
  16. package/dist/commands/neofetch.js +6 -0
  17. package/dist/commands/wget.d.ts.map +1 -1
  18. package/dist/commands/wget.js +11 -1
  19. package/package.json +2 -2
  20. package/src/VirtualPackageManager/index.ts +29 -1
  21. package/src/commands/curl.ts +2 -1
  22. package/src/commands/gzip.ts +7 -0
  23. package/src/commands/man.ts +38 -143
  24. package/src/commands/manuals/adduser.txt +11 -0
  25. package/src/commands/manuals/apt-cache.txt +12 -0
  26. package/src/commands/manuals/apt.txt +20 -0
  27. package/src/commands/manuals/awk.txt +13 -0
  28. package/src/commands/manuals/cat.txt +14 -0
  29. package/src/commands/manuals/cd.txt +16 -0
  30. package/src/commands/manuals/chmod.txt +16 -0
  31. package/src/commands/manuals/clear.txt +10 -0
  32. package/src/commands/manuals/cp.txt +10 -0
  33. package/src/commands/manuals/curl.txt +20 -0
  34. package/src/commands/manuals/date.txt +14 -0
  35. package/src/commands/manuals/declare.txt +12 -0
  36. package/src/commands/manuals/deluser.txt +10 -0
  37. package/src/commands/manuals/df.txt +10 -0
  38. package/src/commands/manuals/dpkg-query.txt +11 -0
  39. package/src/commands/manuals/dpkg.txt +14 -0
  40. package/src/commands/manuals/du.txt +11 -0
  41. package/src/commands/manuals/echo.txt +11 -0
  42. package/src/commands/manuals/false.txt +10 -0
  43. package/src/commands/manuals/find.txt +11 -0
  44. package/src/commands/manuals/free.txt +12 -0
  45. package/src/commands/manuals/grep.txt +13 -0
  46. package/src/commands/manuals/groups.txt +10 -0
  47. package/src/commands/manuals/gzip.txt +11 -0
  48. package/src/commands/manuals/head.txt +10 -0
  49. package/src/commands/manuals/help.txt +11 -0
  50. package/src/commands/manuals/history.txt +11 -0
  51. package/src/commands/manuals/hostname.txt +10 -0
  52. package/src/commands/manuals/id.txt +10 -0
  53. package/src/commands/manuals/kill.txt +13 -0
  54. package/src/commands/manuals/ls.txt +20 -0
  55. package/src/commands/manuals/lsb_release.txt +14 -0
  56. package/src/commands/manuals/mkdir.txt +10 -0
  57. package/src/commands/manuals/mv.txt +10 -0
  58. package/src/commands/manuals/nano.txt +11 -0
  59. package/src/commands/manuals/neofetch.txt +10 -0
  60. package/src/commands/manuals/node.txt +13 -0
  61. package/src/commands/manuals/npm.txt +13 -0
  62. package/src/commands/manuals/npx.txt +13 -0
  63. package/src/commands/manuals/passwd.txt +11 -0
  64. package/src/commands/manuals/ping.txt +10 -0
  65. package/src/commands/manuals/printf.txt +11 -0
  66. package/src/commands/manuals/ps.txt +10 -0
  67. package/src/commands/manuals/pwd.txt +10 -0
  68. package/src/commands/manuals/python3.txt +13 -0
  69. package/src/commands/manuals/readlink.txt +10 -0
  70. package/src/commands/manuals/return.txt +10 -0
  71. package/src/commands/manuals/rm.txt +10 -0
  72. package/src/commands/manuals/sed.txt +11 -0
  73. package/src/commands/manuals/set.txt +11 -0
  74. package/src/commands/manuals/shift.txt +10 -0
  75. package/src/commands/manuals/sleep.txt +10 -0
  76. package/src/commands/manuals/sort.txt +12 -0
  77. package/src/commands/manuals/source.txt +11 -0
  78. package/src/commands/manuals/ssh.txt +11 -0
  79. package/src/commands/manuals/stat.txt +10 -0
  80. package/src/commands/manuals/su.txt +13 -0
  81. package/src/commands/manuals/sudo.txt +11 -0
  82. package/src/commands/manuals/tail.txt +10 -0
  83. package/src/commands/manuals/tar.txt +19 -0
  84. package/src/commands/manuals/tee.txt +10 -0
  85. package/src/commands/manuals/test.txt +11 -0
  86. package/src/commands/manuals/touch.txt +11 -0
  87. package/src/commands/manuals/tr.txt +10 -0
  88. package/src/commands/manuals/trap.txt +10 -0
  89. package/src/commands/manuals/true.txt +10 -0
  90. package/src/commands/manuals/type.txt +10 -0
  91. package/src/commands/manuals/uname.txt +12 -0
  92. package/src/commands/manuals/uniq.txt +12 -0
  93. package/src/commands/manuals/unset.txt +10 -0
  94. package/src/commands/manuals/uptime.txt +11 -0
  95. package/src/commands/manuals/wc.txt +12 -0
  96. package/src/commands/manuals/wget.txt +12 -0
  97. package/src/commands/manuals/which.txt +10 -0
  98. package/src/commands/manuals/whoami.txt +10 -0
  99. package/src/commands/manuals/xargs.txt +10 -0
  100. package/src/commands/neofetch.ts +7 -0
  101. package/src/commands/wget.ts +12 -1
  102. package/tests/new-features.test.ts +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/VirtualPackageManager/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,iBAAiB,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAIhE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IACjC,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAC;IACb,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,YAAY,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,CAAC,EAAE,OAAO,CAAA;KAAO,GAC5B;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;IAiHvC;;;;;;;;;;;;OAYG;IACI,MAAM,CACZ,KAAK,EAAE,MAAM,EAAE,EACf,IAAI,GAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO,GAC7C;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;IA4DvC;;;;;;OAMG;IACI,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,EAAE;IAUhD;;;;;;OAMG;IACI,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;CAiBxC"}
@@ -472,7 +472,35 @@ const PACKAGE_REGISTRY = [
472
472
  mode: 0o755,
473
473
  },
474
474
  ],
475
- },
475
+ }, {
476
+ name: "gzip",
477
+ version: "1.12-2",
478
+ section: "utils",
479
+ description: "GNU compression utility",
480
+ shortDesc: "compression utility",
481
+ installedSizeKb: 128,
482
+ files: [
483
+ {
484
+ path: "/usr/bin/gzip",
485
+ content: "#!/bin/sh\necho 'gzip: virtual stub'\n",
486
+ mode: 0o755,
487
+ },
488
+ ]
489
+ }, {
490
+ name: "neofetch",
491
+ version: "7.1.0-1",
492
+ section: "utils",
493
+ description: "A command-line system information tool written in bash 3.2+",
494
+ shortDesc: "command-line system information tool",
495
+ installedSizeKb: 256,
496
+ files: [
497
+ {
498
+ path: "/usr/bin/neofetch",
499
+ content: "#!/bin/sh\necho 'neofetch: virtual stub'\n",
500
+ mode: 0o755,
501
+ },
502
+ ],
503
+ }
476
504
  ];
477
505
  /**
478
506
  * Pure-TypeScript APT/dpkg package manager backed by a built-in registry.
@@ -1 +1 @@
1
- {"version":3,"file":"curl.d.ts","sourceRoot":"","sources":["../../src/commands/curl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,WAwIzB,CAAC"}
1
+ {"version":3,"file":"curl.d.ts","sourceRoot":"","sources":["../../src/commands/curl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,WAyIzB,CAAC"}
@@ -81,7 +81,8 @@ export const curlCommand = {
81
81
  }
82
82
  let response;
83
83
  try {
84
- response = await fetch(url, fetchOpts);
84
+ const urlWithHttp = url.startsWith("http://") || url.startsWith("https://") ? url : `http://${url}`;
85
+ response = await fetch(urlWithHttp, fetchOpts);
85
86
  }
86
87
  catch (err) {
87
88
  const msg = err instanceof Error ? err.message : String(err);
@@ -1 +1 @@
1
- {"version":3,"file":"gzip.d.ts","sourceRoot":"","sources":["../../src/commands/gzip.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,WAyCzB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,WA0B3B,CAAC"}
1
+ {"version":3,"file":"gzip.d.ts","sourceRoot":"","sources":["../../src/commands/gzip.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,WAgDzB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,WA0B3B,CAAC"}
@@ -9,6 +9,12 @@ export const gzipCommand = {
9
9
  category: "archive",
10
10
  params: ["[-k] [-d] <file>"],
11
11
  run: ({ shell, cwd, args }) => {
12
+ if (!shell.packageManager.isInstalled("gzip")) {
13
+ return {
14
+ stderr: "bash: gzip: command not found\nHint: install it with: apt install gzip\n",
15
+ exitCode: 127,
16
+ };
17
+ }
12
18
  const keepOrig = args.includes("-k") || args.includes("--keep");
13
19
  const decompress = args.includes("-d");
14
20
  const file = args.find((a) => !a.startsWith("-"));
@@ -1 +1 @@
1
- {"version":3,"file":"man.d.ts","sourceRoot":"","sources":["../../src/commands/man.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAiJrD,eAAO,MAAM,UAAU,EAAE,WAoBxB,CAAC"}
1
+ {"version":3,"file":"man.d.ts","sourceRoot":"","sources":["../../src/commands/man.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAwCrD,eAAO,MAAM,UAAU,EAAE,WAoBxB,CAAC"}
@@ -1,144 +1,38 @@
1
- const MAN_PAGES = {
2
- ls: `LS(1) User Commands LS(1)
3
-
4
- NAME
5
- ls - list directory contents
6
-
7
- SYNOPSIS
8
- ls [OPTION]... [FILE]...
9
-
10
- DESCRIPTION
11
- List information about the FILEs (the current directory by default).
12
-
13
- OPTIONS
14
- -l use a long listing format
15
- -a do not ignore entries starting with .
16
- -h with -l, print human readable sizes
17
- -r reverse order while sorting
18
- -t sort by modification time
19
-
20
- AUTHOR
21
- Written by Richard M. Stallman and David MacKenzie.`,
22
- cat: `CAT(1) User Commands CAT(1)
23
-
24
- NAME
25
- cat - concatenate files and print on the standard output
26
-
27
- SYNOPSIS
28
- cat [OPTION]... [FILE]...
29
-
30
- DESCRIPTION
31
- Concatenate FILE(s) to standard output.
32
-
33
- OPTIONS
34
- -n, --number number all output lines
35
- -b, --number-nonblank number nonempty output lines`,
36
- grep: `GREP(1) User Commands GREP(1)
37
-
38
- NAME
39
- grep, egrep, fgrep - print lines that match patterns
40
-
41
- SYNOPSIS
42
- grep [OPTION]... PATTERNS [FILE]...
43
-
44
- OPTIONS
45
- -i, --ignore-case ignore case distinctions in patterns and data
46
- -v, --invert-match select non-matching lines
47
- -n, --line-number print line number with output lines
48
- -r, --recursive read all files under each directory, recursively`,
49
- apt: `APT(8) APT APT(8)
50
-
51
- NAME
52
- apt - command-line interface
53
-
54
- SYNOPSIS
55
- apt [options] command
56
-
57
- DESCRIPTION
58
- apt provides a high-level commandline interface for the package
59
- management system.
60
-
61
- COMMANDS
62
- install pkg... Install packages
63
- remove pkg... Remove packages
64
- update Download package information
65
- upgrade Upgrade installed packages
66
- search term Search in package descriptions
67
- show pkg Show package information
68
- list List packages`,
69
- ssh: `SSH(1) OpenSSH SSH(1)
70
-
71
- NAME
72
- ssh - OpenSSH remote login client
73
-
74
- SYNOPSIS
75
- ssh [-p port] [user@]hostname [command]
76
-
77
- DESCRIPTION
78
- ssh (SSH client) is a program for logging into a remote machine and
79
- for executing commands on a remote machine.`,
80
- curl: `CURL(1) User Commands CURL(1)
81
-
82
- NAME
83
- curl - transfer a URL
84
-
85
- SYNOPSIS
86
- curl [options / URLs]
87
-
88
- DESCRIPTION
89
- curl is a tool for transferring data with URL syntax.
90
-
91
- OPTIONS
92
- -o, --output <file> Write output to <file>
93
- -X, --request <method> Specify request method
94
- -d, --data <data> HTTP POST data
95
- -H, --header <header> Pass custom header
96
- -s, --silent Silent mode
97
- -I, --head Show document info only
98
- -L, --location Follow redirects
99
- -v, --verbose Make the operation more talkative`,
100
- chmod: `CHMOD(1) User Commands CHMOD(1)
101
-
102
- NAME
103
- chmod - change file mode bits
104
-
105
- SYNOPSIS
106
- chmod [OPTION]... MODE[,MODE]... FILE...
107
- chmod [OPTION]... OCTAL-MODE FILE...
108
-
109
- DESCRIPTION
110
- Change the file mode bits of each given file according to MODE.
111
-
112
- EXAMPLES
113
- chmod 755 script.sh rwxr-xr-x
114
- chmod 644 file.txt rw-r--r--
115
- chmod +x script.sh add execute permission`,
116
- tar: `TAR(1) GNU tar Manual TAR(1)
117
-
118
- NAME
119
- tar - an archiving utility
120
-
121
- SYNOPSIS
122
- tar [OPTION...] [FILE]...
123
-
124
- DESCRIPTION
125
- tar saves many files together into a single tape or disk archive,
126
- and can restore individual files from the archive.
127
-
128
- OPTIONS
129
- -c, --create create a new archive
130
- -x, --extract extract files from an archive
131
- -z, --gzip filter the archive through gzip
132
- -f, --file=ARCHIVE use archive file or device ARCHIVE
133
- -v, --verbose verbosely list files processed
134
- -t, --list list the contents of an archive`,
1
+ const MANUAL_ALIASES = {
2
+ gunzip: "gzip",
135
3
  };
4
+ const manualCache = new Map();
5
+ const manualsBaseUrl = new URL("./manuals/", import.meta.url);
6
+ async function dynamicImport(specifier) {
7
+ const importer = new Function("moduleName", "return import(moduleName)");
8
+ return importer(specifier);
9
+ }
10
+ async function loadBundledManual(commandName) {
11
+ const normalized = commandName.toLowerCase();
12
+ const lookupName = MANUAL_ALIASES[normalized] ?? normalized;
13
+ const cacheKey = `builtin:${lookupName}`;
14
+ if (manualCache.has(cacheKey)) {
15
+ return manualCache.get(cacheKey) ?? null;
16
+ }
17
+ try {
18
+ const fsModule = (await dynamicImport("node:fs/promises"));
19
+ const manualUrl = new URL(`${lookupName}.txt`, manualsBaseUrl);
20
+ const content = await fsModule.readFile(manualUrl, "utf8");
21
+ const page = content.replace(/\n$/, "");
22
+ manualCache.set(cacheKey, page);
23
+ return page;
24
+ }
25
+ catch {
26
+ manualCache.set(cacheKey, null);
27
+ return null;
28
+ }
29
+ }
136
30
  export const manCommand = {
137
31
  name: "man",
138
32
  description: "Interface to the system reference manuals",
139
33
  category: "shell",
140
34
  params: ["<command>"],
141
- run: ({ args, shell }) => {
35
+ run: async ({ args, shell }) => {
142
36
  const name = args[0];
143
37
  if (!name)
144
38
  return { stderr: "What manual page do you want?", exitCode: 1 };
@@ -147,7 +41,7 @@ export const manCommand = {
147
41
  if (shell.vfs.exists(manPath)) {
148
42
  return { stdout: shell.vfs.readFile(manPath), exitCode: 0 };
149
43
  }
150
- const page = MAN_PAGES[name.toLowerCase()];
44
+ const page = await loadBundledManual(name);
151
45
  if (page)
152
46
  return { stdout: page, exitCode: 0 };
153
47
  return { stderr: `No manual entry for ${name}`, exitCode: 16 };
@@ -1 +1 @@
1
- {"version":3,"file":"neofetch.d.ts","sourceRoot":"","sources":["../../src/commands/neofetch.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,WAoC7B,CAAC"}
1
+ {"version":3,"file":"neofetch.d.ts","sourceRoot":"","sources":["../../src/commands/neofetch.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,WA2C7B,CAAC"}
@@ -11,6 +11,12 @@ export const neofetchCommand = {
11
11
  category: "system",
12
12
  params: ["[--off]"],
13
13
  run: ({ args, authUser, hostname, shell, env }) => {
14
+ if (!shell.packageManager.isInstalled("neofetch")) {
15
+ return {
16
+ stderr: "bash: neofetch: command not found\nHint: install it with: apt install neofetch\n",
17
+ exitCode: 127,
18
+ };
19
+ }
14
20
  if (ifFlag(args, "--help")) {
15
21
  return {
16
22
  stdout: "Usage: neofetch [--off]",
@@ -1 +1 @@
1
- {"version":3,"file":"wget.d.ts","sourceRoot":"","sources":["../../src/commands/wget.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,WA+HzB,CAAC"}
1
+ {"version":3,"file":"wget.d.ts","sourceRoot":"","sources":["../../src/commands/wget.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,WA0IzB,CAAC"}
@@ -44,7 +44,17 @@ export const wgetCommand = {
44
44
  exitCode: 0,
45
45
  };
46
46
  }
47
- const url = positionals[0];
47
+ const urlWithoutProtocol = positionals[0];
48
+ if (!urlWithoutProtocol) {
49
+ return {
50
+ stderr: "wget: missing URL\nUsage: wget [OPTION]... [URL]...",
51
+ exitCode: 1,
52
+ };
53
+ }
54
+ const url = urlWithoutProtocol.startsWith("http://") ||
55
+ urlWithoutProtocol.startsWith("https://")
56
+ ? urlWithoutProtocol
57
+ : `http://${urlWithoutProtocol}`;
48
58
  if (!url)
49
59
  return {
50
60
  stderr: "wget: missing URL\nUsage: wget [OPTION]... [URL]...",
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "typescript-virtual-container",
3
- "description": "In-memory SSH server with virtual filesystem and typed programmatic API",
3
+ "description": "Scalable Linux emulator with included SSH/SFTP server, virtual filesystem and typed programmatic API for testing, automation, and interactive shell scripting in TypeScript/JavaScript.",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
7
- "version": "1.4.0",
7
+ "version": "1.4.1",
8
8
  "license": "MIT",
9
9
  "repository": {
10
10
  "type": "git",
@@ -556,7 +556,35 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
556
556
  mode: 0o755,
557
557
  },
558
558
  ],
559
- },
559
+ },{
560
+ name: "gzip",
561
+ version: "1.12-2",
562
+ section: "utils",
563
+ description: "GNU compression utility",
564
+ shortDesc: "compression utility",
565
+ installedSizeKb: 128,
566
+ files: [
567
+ {
568
+ path: "/usr/bin/gzip",
569
+ content: "#!/bin/sh\necho 'gzip: virtual stub'\n",
570
+ mode: 0o755,
571
+ },
572
+ ]
573
+ }, {
574
+ name: "neofetch",
575
+ version: "7.1.0-1",
576
+ section: "utils",
577
+ description: "A command-line system information tool written in bash 3.2+",
578
+ shortDesc: "command-line system information tool",
579
+ installedSizeKb: 256,
580
+ files: [
581
+ {
582
+ path: "/usr/bin/neofetch",
583
+ content: "#!/bin/sh\necho 'neofetch: virtual stub'\n",
584
+ mode: 0o755,
585
+ },
586
+ ],
587
+ }
560
588
  ];
561
589
 
562
590
  /**
@@ -97,7 +97,8 @@ export const curlCommand: ShellModule = {
97
97
 
98
98
  let response: Response;
99
99
  try {
100
- response = await fetch(url, fetchOpts);
100
+ const urlWithHttp = url.startsWith("http://") || url.startsWith("https://") ? url : `http://${url}`;
101
+ response = await fetch(urlWithHttp, fetchOpts);
101
102
  } catch (err) {
102
103
  const msg = err instanceof Error ? err.message : String(err);
103
104
  return {
@@ -11,6 +11,13 @@ export const gzipCommand: ShellModule = {
11
11
  category: "archive",
12
12
  params: ["[-k] [-d] <file>"],
13
13
  run: ({ shell, cwd, args }) => {
14
+ if (!shell.packageManager.isInstalled("gzip")) {
15
+ return {
16
+ stderr:
17
+ "bash: gzip: command not found\nHint: install it with: apt install gzip\n",
18
+ exitCode: 127,
19
+ };
20
+ }
14
21
  const keepOrig = args.includes("-k") || args.includes("--keep");
15
22
  const decompress = args.includes("-d");
16
23
  const file = args.find((a) => !a.startsWith("-"));
@@ -1,154 +1,49 @@
1
1
  import type { ShellModule } from "../types/commands";
2
2
 
3
- const MAN_PAGES: Record<string, string> = {
4
- ls: `LS(1) User Commands LS(1)
5
-
6
- NAME
7
- ls - list directory contents
8
-
9
- SYNOPSIS
10
- ls [OPTION]... [FILE]...
11
-
12
- DESCRIPTION
13
- List information about the FILEs (the current directory by default).
14
-
15
- OPTIONS
16
- -l use a long listing format
17
- -a do not ignore entries starting with .
18
- -h with -l, print human readable sizes
19
- -r reverse order while sorting
20
- -t sort by modification time
21
-
22
- AUTHOR
23
- Written by Richard M. Stallman and David MacKenzie.`,
24
-
25
- cat: `CAT(1) User Commands CAT(1)
26
-
27
- NAME
28
- cat - concatenate files and print on the standard output
29
-
30
- SYNOPSIS
31
- cat [OPTION]... [FILE]...
32
-
33
- DESCRIPTION
34
- Concatenate FILE(s) to standard output.
35
-
36
- OPTIONS
37
- -n, --number number all output lines
38
- -b, --number-nonblank number nonempty output lines`,
39
-
40
- grep: `GREP(1) User Commands GREP(1)
41
-
42
- NAME
43
- grep, egrep, fgrep - print lines that match patterns
44
-
45
- SYNOPSIS
46
- grep [OPTION]... PATTERNS [FILE]...
47
-
48
- OPTIONS
49
- -i, --ignore-case ignore case distinctions in patterns and data
50
- -v, --invert-match select non-matching lines
51
- -n, --line-number print line number with output lines
52
- -r, --recursive read all files under each directory, recursively`,
53
-
54
- apt: `APT(8) APT APT(8)
55
-
56
- NAME
57
- apt - command-line interface
58
-
59
- SYNOPSIS
60
- apt [options] command
61
-
62
- DESCRIPTION
63
- apt provides a high-level commandline interface for the package
64
- management system.
65
-
66
- COMMANDS
67
- install pkg... Install packages
68
- remove pkg... Remove packages
69
- update Download package information
70
- upgrade Upgrade installed packages
71
- search term Search in package descriptions
72
- show pkg Show package information
73
- list List packages`,
74
-
75
- ssh: `SSH(1) OpenSSH SSH(1)
76
-
77
- NAME
78
- ssh - OpenSSH remote login client
79
-
80
- SYNOPSIS
81
- ssh [-p port] [user@]hostname [command]
82
-
83
- DESCRIPTION
84
- ssh (SSH client) is a program for logging into a remote machine and
85
- for executing commands on a remote machine.`,
86
-
87
- curl: `CURL(1) User Commands CURL(1)
88
-
89
- NAME
90
- curl - transfer a URL
91
-
92
- SYNOPSIS
93
- curl [options / URLs]
94
-
95
- DESCRIPTION
96
- curl is a tool for transferring data with URL syntax.
97
-
98
- OPTIONS
99
- -o, --output <file> Write output to <file>
100
- -X, --request <method> Specify request method
101
- -d, --data <data> HTTP POST data
102
- -H, --header <header> Pass custom header
103
- -s, --silent Silent mode
104
- -I, --head Show document info only
105
- -L, --location Follow redirects
106
- -v, --verbose Make the operation more talkative`,
107
-
108
- chmod: `CHMOD(1) User Commands CHMOD(1)
109
-
110
- NAME
111
- chmod - change file mode bits
112
-
113
- SYNOPSIS
114
- chmod [OPTION]... MODE[,MODE]... FILE...
115
- chmod [OPTION]... OCTAL-MODE FILE...
116
-
117
- DESCRIPTION
118
- Change the file mode bits of each given file according to MODE.
119
-
120
- EXAMPLES
121
- chmod 755 script.sh rwxr-xr-x
122
- chmod 644 file.txt rw-r--r--
123
- chmod +x script.sh add execute permission`,
124
-
125
- tar: `TAR(1) GNU tar Manual TAR(1)
126
-
127
- NAME
128
- tar - an archiving utility
129
-
130
- SYNOPSIS
131
- tar [OPTION...] [FILE]...
132
-
133
- DESCRIPTION
134
- tar saves many files together into a single tape or disk archive,
135
- and can restore individual files from the archive.
136
-
137
- OPTIONS
138
- -c, --create create a new archive
139
- -x, --extract extract files from an archive
140
- -z, --gzip filter the archive through gzip
141
- -f, --file=ARCHIVE use archive file or device ARCHIVE
142
- -v, --verbose verbosely list files processed
143
- -t, --list list the contents of an archive`,
3
+ const MANUAL_ALIASES: Record<string, string> = {
4
+ gunzip: "gzip",
144
5
  };
145
6
 
7
+ const manualCache = new Map<string, string | null>();
8
+ const manualsBaseUrl = new URL("./manuals/", import.meta.url);
9
+
10
+ async function dynamicImport(specifier: string): Promise<unknown> {
11
+ const importer = new Function(
12
+ "moduleName",
13
+ "return import(moduleName)",
14
+ ) as (moduleName: string) => Promise<unknown>;
15
+ return importer(specifier);
16
+ }
17
+
18
+ async function loadBundledManual(commandName: string): Promise<string | null> {
19
+ const normalized = commandName.toLowerCase();
20
+ const lookupName = MANUAL_ALIASES[normalized] ?? normalized;
21
+ const cacheKey = `builtin:${lookupName}`;
22
+ if (manualCache.has(cacheKey)) {
23
+ return manualCache.get(cacheKey) ?? null;
24
+ }
25
+
26
+ try {
27
+ const fsModule = (await dynamicImport("node:fs/promises")) as {
28
+ readFile: (path: URL, encoding: "utf8") => Promise<string>;
29
+ };
30
+ const manualUrl = new URL(`${lookupName}.txt`, manualsBaseUrl);
31
+ const content = await fsModule.readFile(manualUrl, "utf8");
32
+ const page = content.replace(/\n$/, "");
33
+ manualCache.set(cacheKey, page);
34
+ return page;
35
+ } catch {
36
+ manualCache.set(cacheKey, null);
37
+ return null;
38
+ }
39
+ }
40
+
146
41
  export const manCommand: ShellModule = {
147
42
  name: "man",
148
43
  description: "Interface to the system reference manuals",
149
44
  category: "shell",
150
45
  params: ["<command>"],
151
- run: ({ args, shell }) => {
46
+ run: async ({ args, shell }) => {
152
47
  const name = args[0];
153
48
  if (!name) return { stderr: "What manual page do you want?", exitCode: 1 };
154
49
 
@@ -158,7 +53,7 @@ export const manCommand: ShellModule = {
158
53
  return { stdout: shell.vfs.readFile(manPath), exitCode: 0 };
159
54
  }
160
55
 
161
- const page = MAN_PAGES[name.toLowerCase()];
56
+ const page = await loadBundledManual(name);
162
57
  if (page) return { stdout: page, exitCode: 0 };
163
58
 
164
59
  return { stderr: `No manual entry for ${name}`, exitCode: 16 };
@@ -0,0 +1,11 @@
1
+ ADDUSER(8) User Commands ADDUSER(8)
2
+
3
+ NAME
4
+ adduser - add a user to the system
5
+
6
+ SYNOPSIS
7
+ adduser USERNAME
8
+
9
+ DESCRIPTION
10
+ Create a new user account with a home directory.
11
+ In this environment, prompts for a password interactively.
@@ -0,0 +1,12 @@
1
+ APT-CACHE(8) APT APT-CACHE(8)
2
+
3
+ NAME
4
+ apt-cache - query APT package cache
5
+
6
+ SYNOPSIS
7
+ apt-cache command [args]
8
+
9
+ COMMANDS
10
+ search term search package names/descriptions
11
+ show pkg show package metadata
12
+ policy pkg show package policy and candidate versions
@@ -0,0 +1,20 @@
1
+ APT(8) APT APT(8)
2
+
3
+ NAME
4
+ apt - command-line interface
5
+
6
+ SYNOPSIS
7
+ apt [options] command
8
+
9
+ DESCRIPTION
10
+ apt provides a high-level commandline interface for the package
11
+ management system.
12
+
13
+ COMMANDS
14
+ install pkg... Install packages
15
+ remove pkg... Remove packages
16
+ update Download package information
17
+ upgrade Upgrade installed packages
18
+ search term Search in package descriptions
19
+ show pkg Show package information
20
+ list List packages
@@ -0,0 +1,13 @@
1
+ AWK(1) User Commands AWK(1)
2
+
3
+ NAME
4
+ awk - pattern scanning and processing language
5
+
6
+ SYNOPSIS
7
+ awk [OPTION]... 'PROGRAM' [FILE]...
8
+
9
+ DESCRIPTION
10
+ awk scans each input line, applies PROGRAM rules, and prints results.
11
+
12
+ OPTIONS
13
+ -F fs use fs as input field separator
@@ -0,0 +1,14 @@
1
+ CAT(1) User Commands CAT(1)
2
+
3
+ NAME
4
+ cat - concatenate files and print on the standard output
5
+
6
+ SYNOPSIS
7
+ cat [OPTION]... [FILE]...
8
+
9
+ DESCRIPTION
10
+ Concatenate FILE(s) to standard output.
11
+
12
+ OPTIONS
13
+ -n, --number number all output lines
14
+ -b, --number-nonblank number nonempty output lines