brsh 3.10.2 → 3.10.4

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.
@@ -281,5 +281,199 @@ describe('WASM requirements auto-discovery', () => {
281
281
  await p;
282
282
  expect(shell.lastCode).toBe(0);
283
283
  });
284
+
285
+ function buildTermiosTestWasm(initialLflag) {
286
+ const uleb = (n) => {
287
+ const out = [];
288
+ do {
289
+ let b = n & 0x7f;
290
+ n >>>= 7;
291
+ if (n) b |= 0x80;
292
+ out.push(b);
293
+ } while (n);
294
+ return out;
295
+ };
296
+ const sleb = (n) => {
297
+ const out = [];
298
+ let more = true;
299
+ while (more) {
300
+ let b = n & 0x7f;
301
+ n >>= 7;
302
+ if ((n === 0 && (b & 0x40) === 0) || (n === -1 && (b & 0x40) !== 0)) more = false;
303
+ else b |= 0x80;
304
+ out.push(b);
305
+ }
306
+ return out;
307
+ };
308
+ const str = (s) => {
309
+ const b = Buffer.from(s, 'utf8');
310
+ return [...uleb(b.length), ...b];
311
+ };
312
+ const sec = (id, body) => [id, ...uleb(body.length), ...body];
313
+ const vec = (items) => [...uleb(items.length), ...items.flat()];
314
+ const fnBody = (locals, instrs) => {
315
+ const b = [...vec(locals), ...instrs, 0x0b];
316
+ return [...uleb(b.length), ...b];
317
+ };
318
+
319
+ const types = sec(1, vec([
320
+ [0x60, 0, 0],
321
+ [0x60, 0, 1, 0x7f],
322
+ [0x60, 1, 0x7f, 0],
323
+ [0x60, 2, 0x7f, 0x7f, 0],
324
+ [0x60, 4, 0x7f, 0x7f, 0x7f, 0x7f, 1, 0x7f],
325
+ ]));
326
+ const imports = sec(2, vec([
327
+ [...str('wasi_snapshot_preview1'), ...str('clock_nanosleep'), 0x00, 4],
328
+ [...str('wasi_snapshot_preview1'), ...str('fd_read'), 0x00, 4],
329
+ [...str('wasi_snapshot_preview1'), ...str('fd_write'), 0x00, 4],
330
+ ]));
331
+ const funcs = sec(3, vec([3, 1, 2, 0, 2, 0, 1, 0]));
332
+ const mem = sec(5, vec([[0x00, 1]]));
333
+ const globals = sec(6, vec([
334
+ [0x7f, 1, 0x41, ...sleb(0), 0x0b],
335
+ [0x7f, 1, 0x41, ...sleb(initialLflag), 0x0b],
336
+ ]));
337
+ const exports = sec(7, vec([
338
+ [...str('memory'), 0x02, 0],
339
+ [...str('set_terminal_size'), 0x00, 3],
340
+ [...str('get_termios_lflag'), 0x00, 4],
341
+ [...str('asyncify_start_unwind'), 0x00, 5],
342
+ [...str('asyncify_stop_unwind'), 0x00, 6],
343
+ [...str('asyncify_start_rewind'), 0x00, 7],
344
+ [...str('asyncify_stop_rewind'), 0x00, 8],
345
+ [...str('asyncify_get_state'), 0x00, 9],
346
+ [...str('_start'), 0x00, 10],
347
+ ]));
348
+
349
+ const startInstrs = initialLflag === 1
350
+ ? [
351
+ 0x41, ...sleb(256), 0x42, ...sleb(5000000000), 0x37, 3, 0,
352
+ 0x41, 0, 0x41, 0, 0x41, ...sleb(256), 0x41, ...sleb(264), 0x10, 0, 0x1a
353
+ ]
354
+ : [
355
+ 0x03, 0x40,
356
+ 0x41, ...sleb(128), 0x41, ...sleb(160), 0x36, 2, 0,
357
+ 0x41, ...sleb(132), 0x41, 1, 0x36, 2, 0,
358
+ 0x41, 0, 0x41, ...sleb(128), 0x41, 1, 0x41, ...sleb(136), 0x10, 1, 0x1a,
359
+ 0x23, 0, 0x41, 1, 0x46, 0x04, 0x40, 0x0f, 0x0b,
360
+ 0x41, ...sleb(160), 0x2d, 0, 0, 0x21, 0,
361
+ 0x20, 0, 0x41, 0x18, 0x46, 0x04, 0x40, 0x0f, 0x0b,
362
+ 0x20, 0, 0x41, ...sleb(0x73), 0x46, 0x04, 0x40, 0x41, 1, 0x24, 1, 0x0b,
363
+ 0x20, 0, 0x41, 3, 0x46, 0x04, 0x40,
364
+ 0x41, ...sleb(300), 0x41, ...sleb(0x585445), 0x36, 2, 0,
365
+ 0x41, ...sleb(140), 0x41, ...sleb(300), 0x36, 2, 0,
366
+ 0x41, ...sleb(144), 0x41, 3, 0x36, 2, 0,
367
+ 0x41, 1, 0x41, ...sleb(140), 0x41, 1, 0x41, ...sleb(148), 0x10, 2, 0x1a,
368
+ 0x0b,
369
+ 0x0c, 0,
370
+ 0x0b
371
+ ];
372
+
373
+ const code = sec(10, vec([
374
+ fnBody([], []),
375
+ fnBody([], [0x23, 1]),
376
+ fnBody([], [0x41, 1, 0x24, 0]),
377
+ fnBody([], [0x41, 0, 0x24, 0]),
378
+ fnBody([], [0x41, 2, 0x24, 0]),
379
+ fnBody([], [0x41, 0, 0x24, 0]),
380
+ fnBody([], [0x23, 0]),
381
+ fnBody([[1, 0x7f]], startInstrs),
382
+ ]));
383
+
384
+ return new Uint8Array([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, ...types, ...imports, ...funcs, ...mem, ...globals, ...exports, ...code]);
385
+ }
386
+
387
+ it('terminates cbreak WASM command (ISIG enabled) on Ctrl+C immediately, restores screen, and aborts parent launcher script', async () => {
388
+ const cbreakWasm = buildTermiosTestWasm(1);
389
+ const shell = await createShell({
390
+ filesystem: {
391
+ bin: {
392
+ 'cbreak-game': cbreakWasm,
393
+ 'launch-game': '#!/bin/sh\ncbreak-game\necho "AFTER_GAME" > /after.txt\n'
394
+ }
395
+ },
396
+ permissions: {
397
+ '/bin/cbreak-game': 0o755,
398
+ '/bin/launch-game': 0o755
399
+ }
400
+ });
401
+
402
+ // 1. Direct WASM execution: Ctrl+C via stream write (\x03) cancels 5s clock_nanosleep immediately
403
+ const out1 = [];
404
+ const onOut1 = c => out1.push(String(c));
405
+ shell.stdout.on('data', onOut1);
406
+
407
+ const t0 = Date.now();
408
+ const p1 = shell.onCommand('cbreak-game');
409
+ await new Promise(r => setTimeout(r, 30));
410
+
411
+ shell.write('\x03');
412
+ await p1;
413
+ const elapsed = Date.now() - t0;
414
+ shell.stdout.off('data', onOut1);
415
+
416
+ expect(shell.lastCode).toBe(130);
417
+ expect(elapsed).toBeLessThan(1000);
418
+ expect(out1.join('')).toContain('\x1b[?1049h');
419
+ expect(out1.join('')).toContain('\x1b[?1049l');
420
+ expect(out1.join('')).not.toContain('^C\r\n');
421
+
422
+ // 2. Via shell script wrapper (like freedoom): Ctrl+C kills child + script without running subsequent lines
423
+ const p2 = shell.onCommand('launch-game');
424
+ await new Promise(r => setTimeout(r, 40));
425
+
426
+ shell.write('\x03');
427
+ await p2;
428
+
429
+ expect(shell.lastCode).toBe(130);
430
+ expect(shell.context.fs.exists('/after.txt')).toBe(false);
431
+
432
+ // 3. Ctrl+C via shell.onInput('^C') also delivers SIGINT cleanly
433
+ const p3 = shell.onCommand('cbreak-game');
434
+ await new Promise(r => setTimeout(r, 30));
435
+ shell.onInput('^C');
436
+ await p3;
437
+ expect(shell.lastCode).toBe(130);
438
+ });
439
+
440
+ it('passes Ctrl+C (\\x03) as raw input when WASM clears ISIG (~ISIG) and honors dynamic ISIG re-enablement', async () => {
441
+ const rawWasm = buildTermiosTestWasm(0);
442
+ const shell = await createShell({
443
+ filesystem: {
444
+ bin: {
445
+ 'raw-editor': rawWasm
446
+ }
447
+ },
448
+ permissions: {
449
+ '/bin/raw-editor': 0o755
450
+ }
451
+ });
452
+
453
+ const chunks = [];
454
+ const onData = c => chunks.push(String(c));
455
+ shell.stdout.on('data', onData);
456
+
457
+ const p = shell.onCommand('raw-editor');
458
+ await new Promise(r => setTimeout(r, 30));
459
+
460
+ // While lflag == 0 (~ISIG), Ctrl+C is delivered as byte 0x03 ("ETX" written to stdout)
461
+ shell.write('\x03');
462
+ await new Promise(r => setTimeout(r, 30));
463
+ expect(chunks.join('')).toContain('ETX');
464
+ expect(shell.runningCommand).toBeDefined();
465
+
466
+ // Sending 's' toggles lflag to 1 (re-enabling ISIG dynamically at runtime)
467
+ shell.write('s');
468
+ await new Promise(r => setTimeout(r, 20));
469
+
470
+ // Subsequent Ctrl+C now terminates with SIGINT (130)
471
+ shell.write('\x03');
472
+ await p;
473
+ shell.stdout.off('data', onData);
474
+
475
+ expect(shell.lastCode).toBe(130);
476
+ });
284
477
  });
285
478
 
479
+
package/test/doom.test.js CHANGED
@@ -4,18 +4,24 @@ import path from 'path';
4
4
  import { createShell } from './helpers.js';
5
5
 
6
6
  const DOOM_WASM_CANDIDATES = [
7
+ path.resolve(import.meta.dirname, '../../doom-wasm/dist/doom.wasm'),
7
8
  '/home/antigravity/eliotstocker/doom-wasm/dist/doom.wasm',
8
9
  '/home/antigravity/doom-ascii/dist/doom.wasm',
9
10
  '/tmp/doom-asyncify.wasm'
10
11
  ];
12
+ const DOOM_WAD_CANDIDATES = [
13
+ '/tmp/doom1.wad',
14
+ '/tmp/freedoom1.wad'
15
+ ];
11
16
  const DOOM_WASM_PATH = DOOM_WASM_CANDIDATES.find(p => fs.existsSync(p)) || DOOM_WASM_CANDIDATES[0];
12
- const DOOM_WAD_PATH = '/tmp/doom1.wad';
17
+ const DOOM_WAD_PATH = DOOM_WAD_CANDIDATES.find(p => fs.existsSync(p)) || DOOM_WAD_CANDIDATES[0];
13
18
  const hasDoom = fs.existsSync(DOOM_WASM_PATH) && fs.existsSync(DOOM_WAD_PATH);
19
+ const hasDoom1Demo = fs.existsSync(DOOM_WASM_PATH) && fs.existsSync('/tmp/doom1.wad');
14
20
 
15
21
  describe('Doom in brsh', () => {
16
- it.skipIf(!hasDoom)('executes doom timedemo benchmark cleanly to completion', async () => {
22
+ it.skipIf(!hasDoom1Demo)('executes doom timedemo benchmark cleanly to completion', async () => {
17
23
  const doomWasm = fs.readFileSync(DOOM_WASM_PATH);
18
- const doomWad = fs.readFileSync(DOOM_WAD_PATH);
24
+ const doomWad = fs.readFileSync('/tmp/doom1.wad');
19
25
  const shell = await createShell({
20
26
  filesystem: {
21
27
  bin: { 'doom': doomWasm },
@@ -36,4 +42,57 @@ describe('Doom in brsh', () => {
36
42
  expect(allOut).toContain('DOOM ASCII');
37
43
  expect(allOut).toMatch(/timed \d+ gametics/);
38
44
  }, 30000);
45
+
46
+ it.skipIf(!hasDoom)('exits interactive doom and freedoom cleanly on Ctrl+C (SIGINT, exit code 130)', async () => {
47
+ const doomWasm = new Uint8Array(fs.readFileSync(DOOM_WASM_PATH));
48
+ const doomWad = new Uint8Array(fs.readFileSync(DOOM_WAD_PATH));
49
+ const mod = new WebAssembly.Module(doomWasm);
50
+ expect(WebAssembly.Module.exports(mod).map(e => e.name)).toContain('get_termios_lflag');
51
+
52
+ const shell = await createShell({
53
+ filesystem: {
54
+ usr: {
55
+ lib: {
56
+ doom: {
57
+ 'doom.wasm': doomWasm,
58
+ 'freedoom': '#!/bin/sh\ndoom -iwad /usr/share/games/doom/game.wad -nosound\n',
59
+ 'package.json': JSON.stringify({ name: 'doom', bin: 'doom', interactive: true })
60
+ }
61
+ },
62
+ share: {
63
+ games: {
64
+ doom: {
65
+ 'game.wad': doomWad
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+ });
72
+ shell.context.fs.createSymlink('/usr/lib/doom/doom.wasm', '/bin/doom');
73
+ shell.context.fs.setMode('/usr/lib/doom/doom.wasm', 0o755);
74
+ shell.context.fs.createSymlink('/usr/lib/doom/freedoom', '/bin/freedoom');
75
+ shell.context.fs.setMode('/usr/lib/doom/freedoom', 0o755);
76
+
77
+ const chunks = [];
78
+ const onData = chunk => chunks.push(String(chunk));
79
+ shell.stdout.on('data', onData);
80
+
81
+ const runPromise = shell.onCommand('freedoom');
82
+ await new Promise(r => setTimeout(r, 350));
83
+
84
+ expect(shell.runningCommand).toBeDefined();
85
+ expect(shell.runningCommand.isRaw).toBe(false);
86
+ expect(shell.runningCommand._inAltScreen).toBe(true);
87
+
88
+ shell.write('\x03');
89
+ await runPromise;
90
+ shell.stdout.off('data', onData);
91
+
92
+ const out = chunks.join('');
93
+ expect(shell.lastCode).toBe(130);
94
+ expect(out).toContain('\x1b[?1049h');
95
+ expect(out).toContain('\x1b[?1049l\x1b[?25h');
96
+ expect(out).not.toContain('^C\r\n');
97
+ }, 30000);
39
98
  });
Binary file
package/test/wbt.test.js CHANGED
@@ -1150,6 +1150,43 @@ describe('WBT Wllama v3 WASM & WebGPU package (`wllama`, `llama`, `llama-cli`)',
1150
1150
  expect(runHelpRes.output.join('\n')).toContain('Usage: wllama');
1151
1151
  });
1152
1152
 
1153
+ it('installs wllama from the built ESM browser bundle without __dirname', async () => {
1154
+ const { default: BundledWbt } = await import('../dist/wbt.es.js');
1155
+ const ConfiguredBundledWbt = BundledWbt.configure({
1156
+ fetch: async (url) => {
1157
+ if (url.endsWith('.wasm')) {
1158
+ return {
1159
+ ok: true,
1160
+ status: 200,
1161
+ arrayBuffer: async () => new Uint8Array([0x00, 0x61, 0x73, 0x6d]).buffer
1162
+ };
1163
+ }
1164
+ throw new Error(`Unexpected fetch: ${url}`);
1165
+ }
1166
+ });
1167
+
1168
+ const browserShell = await createShell({ filesystem: { home: {} } });
1169
+ browserShell.context.setCommand(ConfiguredBundledWbt);
1170
+
1171
+ const installRes = await run(browserShell, 'wbt install wllama');
1172
+ expect(installRes.exitCode).toBe(0);
1173
+ expect(browserShell.context.fs.exists('/bin/wllama')).toBe(true);
1174
+ expect(browserShell.context.fs.exists('/bin/llama')).toBe(true);
1175
+ expect(browserShell.context.fs.exists('/bin/llama-cli')).toBe(true);
1176
+
1177
+ const helpRes = await run(browserShell, 'wllama --help');
1178
+ expect(helpRes.exitCode).toBe(0);
1179
+ expect(helpRes.output.join('\n')).toContain('Usage: wllama');
1180
+
1181
+ // Also verify generated __source can be evaluated without Node require() via globalThis.__brshWllamaAdapter
1182
+ const WllamaCmd = browserShell.context.fs.getFileByPath('/usr/lib/wllama/wllama.js');
1183
+ expect(typeof WllamaCmd).toBe('function');
1184
+ expect(typeof WllamaCmd.__source).toBe('string');
1185
+ const mod = { exports: {} };
1186
+ new Function('module', 'exports', 'require', WllamaCmd.__source)(mod, mod.exports, undefined);
1187
+ expect(typeof mod.exports).toBe('function');
1188
+ });
1189
+
1153
1190
  it('runs one-shot chat completions from a local filesystem .gguf model, piped stdin, or -f file with WebGPU or --no-gpu', async () => {
1154
1191
  const res1 = await run(
1155
1192
  shell,
@@ -1399,19 +1436,24 @@ describe('WBT GNU nano WASM package (nano / nano-wasm)', () => {
1399
1436
  expect(showRes.exitCode).toBe(0);
1400
1437
  expect(showRes.output.join('\n')).toContain('Package: nano');
1401
1438
  expect(showRes.output.join('\n')).toContain('Version: 8.0.1');
1402
- expect(showRes.output.join('\n')).toContain('Aliases: nano-wasm');
1439
+ expect(showRes.output.join('\n')).toContain('Aliases: nano-wasm, pico');
1403
1440
 
1404
1441
  const showAliasRes = await run(shell, 'wbt show nano-wasm');
1405
1442
  expect(showAliasRes.exitCode).toBe(0);
1406
1443
  expect(showAliasRes.output.join('\n')).toContain('Package: nano');
1444
+
1445
+ const showPicoRes = await run(shell, 'wbt show pico');
1446
+ expect(showPicoRes.exitCode).toBe(0);
1447
+ expect(showPicoRes.output.join('\n')).toContain('Package: nano');
1407
1448
  });
1408
1449
 
1409
- it('installs nano and nano-wasm into /bin and runs --version and --help', async () => {
1450
+ it('installs nano, nano-wasm, and pico into /bin and runs --version and --help', async () => {
1410
1451
  const installRes = await run(shell, 'wbt install nano');
1411
1452
  expect(installRes.exitCode).toBe(0);
1412
1453
  expect(shell.context.fs.exists('/usr/lib/nano/nano.wasm')).toBe(true);
1413
1454
  expect(shell.context.fs.exists('/bin/nano')).toBe(true);
1414
1455
  expect(shell.context.fs.exists('/bin/nano-wasm')).toBe(true);
1456
+ expect(shell.context.fs.exists('/bin/pico')).toBe(true);
1415
1457
 
1416
1458
  const verRes = await run(shell, 'nano --version');
1417
1459
  expect(verRes.exitCode).toBe(0);
@@ -1424,6 +1466,10 @@ describe('WBT GNU nano WASM package (nano / nano-wasm)', () => {
1424
1466
  const aliasVerRes = await run(shell, 'nano-wasm --version');
1425
1467
  expect(aliasVerRes.exitCode).toBe(0);
1426
1468
  expect(aliasVerRes.output.join('\n')).toMatch(/GNU nano, version 8\.0|nano.*8\.0\.[0-9]+.*wasm/i);
1469
+
1470
+ const picoVerRes = await run(shell, 'pico --version');
1471
+ expect(picoVerRes.exitCode).toBe(0);
1472
+ expect(picoVerRes.output.join('\n')).toMatch(/GNU nano, version 8\.0|nano.*8\.0\.[0-9]+.*wasm/i);
1427
1473
  });
1428
1474
 
1429
1475
  it('supports wbt run nano --version without permanently installing', async () => {
@@ -1433,16 +1479,18 @@ describe('WBT GNU nano WASM package (nano / nano-wasm)', () => {
1433
1479
  expect(shell.context.fs.exists('/bin/nano')).toBe(false);
1434
1480
  });
1435
1481
 
1436
- it('removes nano and unregisters both nano and nano-wasm from /bin', async () => {
1437
- await run(shell, 'wbt install nano-wasm');
1482
+ it('removes nano and unregisters nano, nano-wasm, and pico from /bin', async () => {
1483
+ await run(shell, 'wbt install pico');
1438
1484
  expect(shell.context.fs.exists('/bin/nano')).toBe(true);
1439
1485
  expect(shell.context.fs.exists('/bin/nano-wasm')).toBe(true);
1486
+ expect(shell.context.fs.exists('/bin/pico')).toBe(true);
1440
1487
  expect(shell.context.fs.exists('/usr/lib/nano/nano.wasm')).toBe(true);
1441
1488
 
1442
1489
  const rmRes = await run(shell, 'wbt remove nano');
1443
1490
  expect(rmRes.exitCode).toBe(0);
1444
1491
  expect(shell.context.fs.exists('/bin/nano')).toBe(false);
1445
1492
  expect(shell.context.fs.exists('/bin/nano-wasm')).toBe(false);
1493
+ expect(shell.context.fs.exists('/bin/pico')).toBe(false);
1446
1494
  expect(shell.context.fs.exists('/usr/lib/nano/nano.wasm')).toBe(false);
1447
1495
  });
1448
1496
 
@@ -1541,6 +1589,47 @@ describe('WBT GNU nano WASM package (nano / nano-wasm)', () => {
1541
1589
  expect(saved).toContain('Hello from stream!');
1542
1590
  expect(saved).not.toContain('HHeelllloo');
1543
1591
  });
1592
+
1593
+ it('delivers Ctrl+C (\\x03) as raw input to nano (~ISIG) without killing nano', async () => {
1594
+ if (!NANO_WASM_BYTES) return;
1595
+ const mod = new WebAssembly.Module(NANO_WASM_BYTES);
1596
+ const exportNames = WebAssembly.Module.exports(mod).map(e => e.name);
1597
+ expect(exportNames).toContain('get_termios_lflag');
1598
+
1599
+ await run(shell, 'wbt install nano');
1600
+
1601
+ const stdoutChunks = [];
1602
+ const onData = (chunk) => stdoutChunks.push(String(chunk));
1603
+ shell.stdout.on('data', onData);
1604
+
1605
+ const cmdPromise = shell.onCommand('nano /ctrlc-test.txt');
1606
+ await new Promise(r => setTimeout(r, 80));
1607
+
1608
+ for (const ch of 'Nano raw mode') {
1609
+ shell.write(ch);
1610
+ await new Promise(r => setTimeout(r, 5));
1611
+ }
1612
+ await new Promise(r => setTimeout(r, 30));
1613
+
1614
+ // In GNU nano, Ctrl+C (\x03) shows cursor position in the status bar instead of exiting
1615
+ shell.write('\x03');
1616
+ await new Promise(r => setTimeout(r, 40));
1617
+ expect(shell.runningCommand).toBeDefined();
1618
+ expect(stdoutChunks.join('')).toMatch(/line\s+1|col\s+14/i);
1619
+
1620
+ // Save (Ctrl+O, Enter) and exit (Ctrl+X) cleanly
1621
+ shell.write('\x0f');
1622
+ await new Promise(r => setTimeout(r, 30));
1623
+ shell.write('\r');
1624
+ await new Promise(r => setTimeout(r, 30));
1625
+ shell.write('\x18');
1626
+
1627
+ await cmdPromise;
1628
+ shell.stdout.off('data', onData);
1629
+
1630
+ expect(shell.lastCode).toBe(0);
1631
+ expect(shell.context.fs.getFileByPath('/ctrlc-test.txt')).toContain('Nano raw mode');
1632
+ });
1544
1633
  });
1545
1634
 
1546
1635
  describe('WBT filesystem installer architecture (installer, not runtime)', () => {
@@ -1636,6 +1725,36 @@ describe('WBT filesystem installer architecture (installer, not runtime)', () =>
1636
1725
  expect(execRes.exitCode).toBe(0);
1637
1726
  });
1638
1727
 
1728
+ it('registers vim package from eliotstocker/vim-wasm with vi and vim-wasm aliases', async () => {
1729
+ const searchRes = await run(shell, 'wbt search vim');
1730
+ expect(searchRes.exitCode).toBe(0);
1731
+ expect(searchRes.output.join('\n')).toContain('vim');
1732
+
1733
+ const showRes = await run(shell, 'wbt show vim');
1734
+ expect(showRes.exitCode).toBe(0);
1735
+ expect(showRes.output.join('\n')).toContain('Package: vim');
1736
+ expect(showRes.output.join('\n')).toContain('Version: 9.1.0700');
1737
+ expect(showRes.output.join('\n')).toContain('Aliases: vi, vim-wasm');
1738
+
1739
+ const showViRes = await run(shell, 'wbt show vi');
1740
+ expect(showViRes.exitCode).toBe(0);
1741
+ expect(showViRes.output.join('\n')).toContain('Package: vim');
1742
+
1743
+ const installRes = await run(shell, 'wbt install vi');
1744
+ expect(installRes.exitCode).toBe(0);
1745
+ expect(shell.context.fs.exists('/usr/lib/vim/vim.wasm')).toBe(true);
1746
+ expect(shell.context.fs.isSymlink('/bin/vim')).toBe(true);
1747
+ expect(shell.context.fs.isSymlink('/bin/vi')).toBe(true);
1748
+ expect(shell.context.fs.isSymlink('/bin/vim-wasm')).toBe(true);
1749
+
1750
+ const rmRes = await run(shell, 'wbt remove vim');
1751
+ expect(rmRes.exitCode).toBe(0);
1752
+ expect(shell.context.fs.exists('/bin/vim')).toBe(false);
1753
+ expect(shell.context.fs.exists('/bin/vi')).toBe(false);
1754
+ expect(shell.context.fs.exists('/bin/vim-wasm')).toBe(false);
1755
+ expect(shell.context.fs.exists('/usr/lib/vim/vim.wasm')).toBe(false);
1756
+ });
1757
+
1639
1758
  it('registers doom package with aliases doom-wasm, doom-ascii, and freedoom launcher script', async () => {
1640
1759
  const BaseWbt = createTestWbt();
1641
1760
  const registry = BaseWbt.DEFAULT_REGISTRY;