z1llm 0.0.1 → 0.1.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 Zero1LLM
3
+ Copyright (c) 2026 Zeronex Systems Private Limited
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,5 +1,85 @@
1
1
  # z1llm
2
2
 
3
- The official Zero1LLM CLI, coming soon, see https://www.zero1llm.ai
3
+ Zero1LLM from the terminal: your models, chat, pictures and videos. It talks to the Zero1LLM app on this computer,
4
+ so the app must be open with **Settings → Local API** on.
4
5
 
5
- This 0.0.1 release is a placeholder that holds the name. It contains no code.
6
+ ```sh
7
+ npm install -g z1llm
8
+ z1llm key # paste the key from Zero1LLM → Settings → Local API (once)
9
+ z1llm status
10
+ ```
11
+
12
+ `zero1llm` is a second name for the same command, and `npm install -g zero1llm` installs this too.
13
+
14
+ ## Commands
15
+
16
+ ```
17
+ z1llm status is Zero1LLM open, the Local API on, your key found
18
+ z1llm key [--clear] save your API key once (or remove it)
19
+
20
+ z1llm models your models; loaded ones marked
21
+ z1llm load [model] load a model, with a progress bar
22
+ z1llm eject [model] unload a model, freeing its memory
23
+
24
+ z1llm ask "question" one answer, formatted, then done
25
+ -m, --model <name> which model (default: the app's current one)
26
+ --web search the web first
27
+ --no-save keep it out of the app's sidebar
28
+ --plain the model alone, without the app's chat (no web, memory or tools)
29
+
30
+ z1llm chat [model] a back-and-forth chat; type / for its commands:
31
+ /web turn web search on or off
32
+ /model [name] switch model (a list, or part of its name)
33
+ /clear start a new chat, clearing the screen (/new too)
34
+ /exit leave (or Ctrl+D)
35
+ Shift+Enter a new line (Apple's Terminal: Option+Enter, with "Use Option as Meta key");
36
+ pasted lines go as one message
37
+
38
+ z1llm image "a fox" [--shape 16:9] [-o fox.png] saved in ~/Pictures/Zero1LLM
39
+ z1llm video "waves" [--seconds 5] [--shape portrait] saved in ~/Movies/Zero1LLM (Mac) or ~/Videos/Zero1LLM
40
+ -o <path> a file to save it as, or a folder to save it in
41
+
42
+ z1llm help [command]
43
+ z1llm version
44
+ ```
45
+
46
+ Every command takes `--json` for output a script can read.
47
+
48
+ When the app asks (Allow a tool? Or the AI's own questions), you pick from a list: ↑↓ and Enter, a number, Space to tick
49
+ when several answers fit, or type in the last row. Pictures, videos and documents a chat makes are saved in
50
+ `~/Pictures/Zero1LLM`, `~/Movies/Zero1LLM` (or `~/Videos/Zero1LLM`) and `~/Documents/Zero1LLM`, with the path shown.
51
+
52
+ ## Choosing a model
53
+
54
+ You never need a model's full name:
55
+
56
+ - **Part of it** is enough: `z1llm load qwen`. When it matches several, a list opens with just those.
57
+ - **Leave it out** to pick from a list: type to filter, ↑↓ to move, Enter to choose, Esc to cancel.
58
+ - **A typo** gets the closest names: `No model "gemmma". Did you mean Gemma 4 E2B or Gemma 4 26B?`
59
+
60
+ In a script (no terminal) there is no list: the command fails with the suggestions instead of waiting.
61
+
62
+ ## Pipes and scripts
63
+
64
+ ```sh
65
+ cat notes.txt | z1llm ask "summarise this"
66
+ z1llm ask "Capital of France? One word." --plain -m qwen > answer.txt
67
+ z1llm models --json | jq '.local[] | select(.state == "loaded") | .name'
68
+ ```
69
+
70
+ Answers go to stdout and spinners and questions to stderr, so redirecting the output keeps only the answer. A command
71
+ that fails exits with 1.
72
+
73
+ ## The key
74
+
75
+ `z1llm key` checks the key with the app and keeps it in `~/.config/z1llm/config.json` (`%APPDATA%\z1llm\config.json`
76
+ on Windows), readable only by you. `ZERO1LLM_API_KEY`, when set, is used instead; `ZERO1LLM_BASE_URL` sets the address
77
+ when the app isn't found by itself.
78
+
79
+ ## Updates
80
+
81
+ Once a day `z1llm` asks npm whether there's a newer version and, if there is, says so after the command:
82
+ `Update available: 0.1.0 → 0.1.1 · npm install -g z1llm`. Never in a script, with `--json` or on CI; set
83
+ `Z1LLM_NO_UPDATE_CHECK=1` to turn it off.
84
+
85
+ For your own programs, use the SDK the command is built on: [`@zero1llm/sdk`](https://www.npmjs.com/package/@zero1llm/sdk).
package/dist/brand.js ADDED
@@ -0,0 +1,2 @@
1
+ // The command's name, as `CLI_NAME` in Zero1LLM's brand (a test checks they match; a rename edits both, CLAUDE.md).
2
+ export const CLI_NAME = 'z1llm';
package/dist/choose.js ADDED
@@ -0,0 +1,105 @@
1
+ // Choosing a model without typing its exact name: part of the name finds it, a typo gets suggestions, and in a
2
+ // terminal a list to pick from (type to filter, arrows, Enter).
3
+ import { B, C, DIM, rawKeys, redrawn } from './terminal.js';
4
+ const norm = (s) => s.toLowerCase().replace(/[^a-z0-9]/g, '');
5
+ /** The choices whose name or id holds every word typed ("gem 26" → Gemma 4 26B). */
6
+ function filtered(query, choices) {
7
+ const words = query.split(/\s+/).map(norm).filter(Boolean);
8
+ return choices.filter(c => {
9
+ const hay = `${norm(c.name)}|${norm(c.id)}`;
10
+ return words.every(w => hay.includes(w));
11
+ });
12
+ }
13
+ /** Edit distance: letters added, removed or changed to turn `a` into `b`. */
14
+ function distance(a, b) {
15
+ let prev = Array.from({ length: b.length + 1 }, (_, j) => j);
16
+ for (let i = 1; i <= a.length; i++) {
17
+ const row = [i];
18
+ for (let j = 1; j <= b.length; j++)
19
+ row[j] = Math.min(prev[j] + 1, row[j - 1] + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
20
+ prev = row;
21
+ }
22
+ return prev[b.length];
23
+ }
24
+ /** How far `q` is from the closest stretch of `name` about as long as it ("gemmma" is 1 from "gemma" in "gemma4e2b"). */
25
+ function closest(q, name) {
26
+ let best = distance(q, name);
27
+ for (let len = Math.max(1, q.length - 1); len <= q.length + 1; len++) {
28
+ for (let at = 0; at + len <= name.length; at++)
29
+ best = Math.min(best, distance(q, name.slice(at, at + len)));
30
+ }
31
+ return best;
32
+ }
33
+ /** What a typed name points at: one model, several to pick from, or none (with the closest names, at most 3). */
34
+ export function match(query, choices) {
35
+ const q = query.trim().toLowerCase();
36
+ const exact = choices.find(c => [c.id.toLowerCase(), c.name.toLowerCase(), c.id.toLowerCase().replace(/^local\//, '')].includes(q));
37
+ if (exact)
38
+ return { found: exact };
39
+ const hits = filtered(q, choices);
40
+ if (hits.length === 1)
41
+ return { found: hits[0] };
42
+ if (hits.length > 1)
43
+ return { several: hits };
44
+ // A typo: names whose closest stretch is at most a third of the letters off.
45
+ const nq = norm(q);
46
+ const near = choices
47
+ .map(c => ({ c, d: closest(nq, norm(c.name)), whole: distance(nq, norm(c.name)) }))
48
+ .filter(x => x.d <= Math.max(1, Math.floor(nq.length / 3)))
49
+ .sort((a, b) => a.d - b.d || a.whole - b.whole);
50
+ return { none: near.slice(0, 3).map(x => x.c) };
51
+ }
52
+ /** "A, B or C" */
53
+ export const either = (choices) => choices.map(c => c.name).join(', ').replace(/, ([^,]*)$/, ' or $1');
54
+ const SHOWN = 10;
55
+ /** A list in the terminal: type to filter, ↑↓ to move, Enter to choose; Esc or Ctrl+C gives undefined. */
56
+ export function pick(title, choices, filter = '') {
57
+ const view = redrawn();
58
+ let at = 0;
59
+ const width = Math.max(...choices.map(c => c.name.length));
60
+ const draw = () => {
61
+ const list = filtered(filter, choices);
62
+ at = Math.max(0, Math.min(at, list.length - 1));
63
+ const top = Math.max(0, Math.min(at - SHOWN + 1, list.length - SHOWN));
64
+ const lines = [`${C('?')} ${B(title)} ${filter || DIM('(type to filter, ↑↓ to move, Enter to choose)')}`];
65
+ if (!list.length)
66
+ lines.push(DIM(' No model matches.'));
67
+ list.slice(top, top + SHOWN).forEach((c, i) => {
68
+ const here = top + i === at;
69
+ lines.push(`${here ? C('❯') : ' '} ${here ? C(c.name.padEnd(width)) : c.name.padEnd(width)}${c.detail ? ` ${DIM(c.detail)}` : ''}`);
70
+ });
71
+ if (list.length > SHOWN)
72
+ lines.push(DIM(` ${list.length} models: type to narrow`));
73
+ view.draw(lines);
74
+ return list;
75
+ };
76
+ return new Promise(resolve => {
77
+ let list = draw();
78
+ const finish = (c) => {
79
+ stop();
80
+ view.erase();
81
+ if (c)
82
+ process.stderr.write(`${C('✔')} ${B(title)} ${c.name}\n`);
83
+ resolve(c);
84
+ };
85
+ const stop = rawKeys((s, key) => {
86
+ if (key.name === 'escape' || (key.ctrl && key.name === 'c'))
87
+ return finish(undefined);
88
+ if (key.name === 'return')
89
+ return list[at] ? finish(list[at]) : undefined;
90
+ if (key.name === 'up')
91
+ at = Math.max(0, at - 1);
92
+ else if (key.name === 'down')
93
+ at = Math.max(0, Math.min(list.length - 1, at + 1));
94
+ else if (key.name === 'backspace')
95
+ filter = filter.slice(0, -1);
96
+ else if (s && !key.ctrl && s >= ' ' && s.length === 1) {
97
+ filter += s;
98
+ at = 0;
99
+ }
100
+ else
101
+ return;
102
+ list = draw();
103
+ }, true);
104
+ });
105
+ }