brsh 3.3.1 → 3.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brsh",
3
- "version": "3.3.1",
3
+ "version": "3.5.0",
4
4
  "description": "A unix like shell written in javascript",
5
5
  "main": "./dist/shell.min.js",
6
6
  "module": "./dist/shell.es.js",
package/test/wbt.test.js CHANGED
@@ -6,7 +6,7 @@ const require = createRequire(import.meta.url);
6
6
  const path = require('path');
7
7
  const fs = require('fs');
8
8
  const Wbt = require('../lib/wbt/index.js');
9
- const { wllamaInstances } = require('../lib/wbt/packages/wllama.js');
9
+ const { wllamaInstances, DEFAULT_MODEL_URL, MODEL_ALIASES, resolveModelSpec } = require('../lib/wbt/packages/wllama.js');
10
10
 
11
11
  const NANO_WASM_PATH = path.resolve(import.meta.dirname, '../../nano-wasm/dist/nano.wasm');
12
12
  const NANO_WASM_BYTES = (() => {
@@ -1176,7 +1176,8 @@ describe('WBT Wllama v3 WASM & WebGPU package (`wllama`, `llama`, `llama-cli`)',
1176
1176
  expect(noStreamRes.output.join('\n')).toContain('Reply(WebGPU,turns=1): No stream');
1177
1177
  expect(noStreamTokens.length).toBe(0);
1178
1178
 
1179
- // Test status indication (loading model, running inference)
1179
+ // Test status indication (loading model weights, running inference)
1180
+ wllamaInstances.clear();
1180
1181
  const statusUpdates = [];
1181
1182
  const onStatus = (chunk) => statusUpdates.push(chunk);
1182
1183
  shell.stderr.on('data', onStatus);
@@ -1188,8 +1189,9 @@ describe('WBT Wllama v3 WASM & WebGPU package (`wllama`, `llama`, `llama-cli`)',
1188
1189
 
1189
1190
  shell.stderr.removeListener('data', onStatus);
1190
1191
  const combinedStatus = statusUpdates.join('');
1191
- expect(combinedStatus).toMatch(/Loading model|Loaded model/);
1192
+ expect(combinedStatus).toContain('Loading model (tinyllama.gguf) weights');
1192
1193
  expect(combinedStatus).toContain('Running inference');
1194
+ expect(combinedStatus).toMatch(/\[.*\]/);
1193
1195
  });
1194
1196
 
1195
1197
  it('supports Hugging Face model loading (--hf / hf:), embeddings (wllama embed), info, and bench', async () => {
@@ -1294,6 +1296,39 @@ describe('WBT Wllama v3 WASM & WebGPU package (`wllama`, `llama`, `llama-cli`)',
1294
1296
  expect(modelsRes.output.join('\n')).toContain('/var/cache/wllama/Qwen2.5-0.5B-Instruct-GGUF-Q4_K_M.gguf');
1295
1297
  expect(modelsRes.output.join('\n')).toContain('persisted (fs)');
1296
1298
  });
1299
+
1300
+ it('defaults to SmolLM2 model and supports friendly model aliases like smol and qwen', async () => {
1301
+ // Verify default model URL is SmolLM2-135M rather than stories
1302
+ expect(DEFAULT_MODEL_URL).toContain('SmolLM2-135M-Instruct');
1303
+ expect(DEFAULT_MODEL_URL).not.toContain('stories');
1304
+
1305
+ // Verify resolveModelSpec helper maps empty input to SmolLM2 default
1306
+ const defaultSpec = resolveModelSpec();
1307
+ expect(defaultSpec.url).toBe(DEFAULT_MODEL_URL);
1308
+ expect(defaultSpec.url).toContain('SmolLM2-135M-Instruct-Q4_K_M.gguf');
1309
+
1310
+ // Verify smol and qwen aliases
1311
+ const smolSpec = resolveModelSpec('smol');
1312
+ expect(smolSpec.url).toBe(MODEL_ALIASES.smol);
1313
+ const qwenSpec = resolveModelSpec('qwen');
1314
+ expect(qwenSpec.url).toBe(MODEL_ALIASES.qwen);
1315
+ expect(qwenSpec.url).toContain('qwen2.5-0.5b-instruct-q4_k_m.gguf');
1316
+
1317
+ // Run wllama with no -m flag (uses default SmolLM2 model)
1318
+ const defaultRes = await run(shell, 'wllama -p "Default model prompt"');
1319
+ expect(defaultRes.exitCode).toBe(0);
1320
+ expect(defaultRes.output.join('\n')).toContain('Reply(WebGPU,turns=1): Default model prompt');
1321
+
1322
+ // Run wllama pull using alias 'qwen'
1323
+ const pullQwenRes = await run(shell, 'wllama pull qwen -q');
1324
+ expect(pullQwenRes.exitCode).toBe(0);
1325
+ expect(shell.context.fs.exists('/var/cache/wllama/qwen2.5-0.5b-instruct-q4_k_m.gguf')).toBe(true);
1326
+
1327
+ // Run wllama using alias 'qwen' with -m
1328
+ const qwenRes = await run(shell, 'wllama -m qwen -p "Hello Qwen"');
1329
+ expect(qwenRes.exitCode).toBe(0);
1330
+ expect(qwenRes.output.join('\n')).toContain('Reply(WebGPU,turns=1): Hello Qwen');
1331
+ });
1297
1332
  });
1298
1333
 
1299
1334
  describe('WBT GNU nano WASM package (nano / nano-wasm)', () => {