@bendyline/gezel-cli 1.3.0 → 1.3.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.
package/README.md CHANGED
@@ -65,7 +65,7 @@ Run `gezel --help`, or `--help` on any command, for every option.
65
65
  | Command | What it does |
66
66
  |---|---|
67
67
  | `gezel` | Open the interactive terminal app for this folder's project |
68
- | `gezel run [prompt…]` | One prompt, one reply, using this project's crew lead unless you pass `--gezel <id>`. A sole `-` reads the prompt from stdin |
68
+ | `gezel run [prompt…]` | One prompt, one reply, using this project's crew lead unless you pass `--gezel <id>`. A sole `-` reads the prompt from stdin; with a prompt, piped or redirected text is sent after it |
69
69
  | `gezel do <craftbook…>` | Start a craftbook as a task in this folder's project: its name, then required values, `key=value` parameters, and your request. `--wait` follows it to the end |
70
70
  | `gezel <craftbook> …` | Shorthand for `gezel do <craftbook> …`, matched exactly on the craftbook's command name; built-in commands always win |
71
71
  | `gezel craftbook list [words…]` | List the craftbooks `gezel do` can start in this folder's project (command name, title, category); words filter by command, title, and tags. `--json` for scripts |
@@ -74,14 +74,14 @@ Run `gezel --help`, or `--help` on any command, for every option.
74
74
  | `gezel task list\|show\|create` | Tasks across every project |
75
75
  | `gezel task wait\|resume\|pause <ref>` | Follow a task to the end, retry a paused task and follow it, or pause one task. Waiting prints where the result is; `--out <dir>` copies it |
76
76
  | `gezel task notes <ref>` | A task's notes, including pause reasons and failed checks (`--warnings` adds runtime warnings) |
77
- | `gezel agent list\|create\|show\|output-limit` | Manage your crew (the command name is historical) |
77
+ | `gezel agent list\|create\|show\|output-limit` | Manage your crew (the command name is historical); `show` and `output-limit` take a crew member's id or name |
78
78
  | `gezel project list\|create\|install\|indexing\|edits` | Manage projects, their npm packages, background indexing, and whether Gezel may change files in the folder (`gezel env` is the same command) |
79
79
  | `gezel integrations list\|approve\|deny\|token` | The apps connected to this Gezel: answer one that asked to connect, or make and revoke app keys |
80
80
  | `gezel integrations address` | Where other programs reach this Gezel's models |
81
81
  | `gezel integrations ollama [on\|off]` | A plain-HTTP port on this computer that needs no key (`http://127.0.0.1:11434/v1`, and Ollama's own paths); off until you turn it on |
82
82
  | `gezel skills list\|import\|convert` | Find SKILL.md skills and turn them into craftbooks |
83
83
  | `gezel app …` | Build, install, apply, and serve AI Apps (`.gezapp`): `new`, `validate`, `pack`, `add`, `update`, `list`, `show`, `apply`, `status`, `serve`, `enable`, `disable`, `remove`, `schemas` |
84
- | `gezel model list\|pull\|use\|export` | On-device chat models. `list --available` shows the catalog models that fit this machine, with sizes; `pull <id>` downloads one, plus the engine it runs on if that is missing; `use <id>` makes chats use a downloaded model (a pull does this itself when no working default is set); `export <id> [file]` writes a portable, checksum-verified `.gezmodel` |
84
+ | `gezel model list\|pull\|use\|export` | On-device chat models. `list` marks the one chats use and the ones another Gezel on this computer shares; `list --available` shows the catalog models that fit this machine, with sizes; `pull <id>` downloads one, plus the engine it runs on if that is missing, and downloads nothing when a shared copy is already here; `use <id>` makes chats use a downloaded model (a pull does this itself when no working default is set); `export <id> [file]` writes a portable, checksum-verified `.gezmodel` |
85
85
  | `gezel model context\|concurrency` | A local model's context window, and how many requests a local engine serves at once |
86
86
  | `gezel native install\|list\|status` | The native engines that run models on this computer |
87
87
  | `gezel image status\|models\|pull\|rm` | Image-generation models |
@@ -140,6 +140,18 @@ stderr. Empty input exits with status 1 before anything starts. Without a sole
140
140
  usage. Until a model is set up, `run` downloads nothing: it names the setup
141
141
  commands and exits.
142
142
 
143
+ With a prompt in its arguments, `run` also sends text piped or redirected to
144
+ it, after the prompt and a blank line:
145
+
146
+ ```bash
147
+ gezel run "Summarize these notes for the board" < notes.txt
148
+ git diff | gezel run "Write a commit message for this change"
149
+ ```
150
+
151
+ A terminal is never read, and a pipe that sends nothing within a moment is
152
+ left unread so a script that keeps stdin open never waits on it. For a slow
153
+ producer, put the whole prompt in the input and use `gezel run -`.
154
+
143
155
  ## Provider keys
144
156
 
145
157
  Provider keys go into the same credential store the desktop app uses, read from
@@ -336,7 +336,7 @@ The loop:
336
336
  1. Edit the files under \`items/\` (schemas: \`gezel app schemas --out schemas\`).
337
337
  2. \`gezel app validate .\`
338
338
  3. \`gezel app pack .\`
339
- 4. \`gezel app add ${id}-1.0.0.gezapp --yes\` then \`gezel app apply ${id}\` in a project folder.
339
+ 4. \`gezel app add ${id}-1.0.0.gezapp --yes\` then \`gezel app apply ${id} --yes\` in a project folder.
340
340
 
341
341
  The keeper uses \`add_record\` to update the seeded \`data.json\` through
342
342
  \`records-store\`. Read failures are errors; they never reset existing data.
@@ -747,7 +747,7 @@ async function runAppNew(id, opts = {}) {
747
747
  console.log(" 1. Edit items/ \u2014 start with the two about.md files and the version manifest.");
748
748
  console.log(` 2. gezel app validate ${id}`);
749
749
  console.log(` 3. gezel app pack ${id}`);
750
- console.log(` 4. gezel app add ${id}-1.0.0.gezapp --yes && gezel app apply ${id}`);
750
+ console.log(` 4. gezel app add ${id}-1.0.0.gezapp --yes && gezel app apply ${id} --yes`);
751
751
  }
752
752
  async function runAppSchemas(opts = {}) {
753
753
  const files = renderGezappAuthoringSchemaFiles();
@@ -314,7 +314,14 @@ async function connectForRun(globals) {
314
314
  process.env.GEZEL_SKIP_SYSTEM_BOOTSTRAP = "1";
315
315
  }
316
316
  const { startService } = await import("@bendyline/gezel-service");
317
- const svc = await startService({ port: 0, role: "user" });
317
+ const levelBeforeService = getLogLevel();
318
+ if (!process.env.GEZEL_LOG_LEVEL) setLogLevel("info");
319
+ const svc = await startService({ port: 0, role: "user", logOutput: "file" }).catch(
320
+ (error) => {
321
+ setLogLevel(levelBeforeService);
322
+ throw error;
323
+ }
324
+ );
318
325
  const scheme = svc.cert ? "https" : "http";
319
326
  const baseUrl = `${scheme}://127.0.0.1:${svc.port}`;
320
327
  const client = new GezelClient({
@@ -328,7 +335,11 @@ async function connectForRun(globals) {
328
335
  let stopPromise;
329
336
  const stop = () => {
330
337
  stopPromise ??= (async () => {
331
- await svc.stop();
338
+ try {
339
+ await svc.stop();
340
+ } finally {
341
+ setLogLevel(levelBeforeService);
342
+ }
332
343
  try {
333
344
  const paths = gezelPaths();
334
345
  const pid = (await readFile(paths.runtime.pid, "utf8")).trim();
@@ -1351,6 +1362,7 @@ import {
1351
1362
  import { resolveOnDeviceProvider } from "@bendyline/gezel/native";
1352
1363
 
1353
1364
  // src/model-pull.ts
1365
+ import { dirname as dirname2 } from "path";
1354
1366
  async function pullChatModel(client, engine, id, writeProgress) {
1355
1367
  let lastPct = -1;
1356
1368
  let pullError;
@@ -1381,6 +1393,16 @@ async function pullChatModel(client, engine, id, writeProgress) {
1381
1393
  else await client.installLlamaCppModel(id, onEvent);
1382
1394
  if (pullError) throw new CliError(`download failed: ${pullError}`);
1383
1395
  }
1396
+ async function findSharedModel(client, engine, id) {
1397
+ if (engine === "mlx") {
1398
+ const { models: models2 } = await client.listMlxModels();
1399
+ const found2 = models2.find((model2) => model2.id === id && model2.readOnly === true);
1400
+ return found2 ? { location: found2.modelDir, updateAvailable: found2.updateAvailable === true } : null;
1401
+ }
1402
+ const { models } = engine === "ds4" ? await client.listDs4Models() : await client.listLlamaCppModels();
1403
+ const found = models.find((model2) => model2.id === id && model2.readOnly === true);
1404
+ return found ? { location: dirname2(found.weightsPath), updateAvailable: found.updateAvailable === true } : null;
1405
+ }
1384
1406
  async function waitForMlxRuntime(client, writeProgress, options = {}) {
1385
1407
  const pollMs = options.pollMs ?? 1e3;
1386
1408
  const now = options.now ?? Date.now;
@@ -2006,6 +2028,32 @@ async function installedChatModels(client, engine) {
2006
2028
  const { models } = engine === "mlx" ? await client.listMlxModels() : engine === "ds4" ? await client.listDs4Models() : await client.listLlamaCppModels();
2007
2029
  return models.map((model2) => model2.id);
2008
2030
  }
2031
+ function chatModelInUse(config, engine, listedIds) {
2032
+ if (config.provider !== engine) return void 0;
2033
+ const external = engine === "mlx" ? config.mlxBaseUrl || config.mlxModelPath : engine === "ds4" ? config.ds4BaseUrl || config.ds4ModelPath : config.llamaCppBaseUrl || config.llamaCppModelPath;
2034
+ if (external) return void 0;
2035
+ const pinned = config.defaultModel?.[engine];
2036
+ if (pinned && listedIds.includes(pinned)) return pinned;
2037
+ if (pinned && engine === "mlx") return void 0;
2038
+ return listedIds[0];
2039
+ }
2040
+ function formatInstalledChatModels(engine, models, config) {
2041
+ if (models.length === 0) {
2042
+ return `(no local ${engine} models \u2014 \`gezel model list --available\` shows ones to download)`;
2043
+ }
2044
+ const inUse = chatModelInUse(
2045
+ config,
2046
+ engine,
2047
+ models.map((model2) => model2.id)
2048
+ );
2049
+ const width = Math.max(28, ...models.map((model2) => model2.id.length));
2050
+ return models.map((model2) => {
2051
+ const notes = [model2.readOnly ? "shared" : "", model2.id === inUse ? "in use" : ""].filter(
2052
+ Boolean
2053
+ );
2054
+ return `${model2.id.padEnd(width)} ${(model2.approxSizeBytes / 1e9).toFixed(2).padStart(6)} GB ${model2.name}${notes.length > 0 ? ` (${notes.join(", ")})` : ""}`;
2055
+ }).join("\n");
2056
+ }
2009
2057
  function providerFlag(engine, platformDefault) {
2010
2058
  return engine === platformDefault ? "" : ` --provider ${engine}`;
2011
2059
  }
@@ -2026,17 +2074,17 @@ async function availableChatModels(client, engine) {
2026
2074
  client.getConfig(),
2027
2075
  client.getNativeEngineStatus?.().catch(() => void 0)
2028
2076
  ]);
2029
- const pinned = config.defaultModel?.[engine];
2077
+ const inUse = chatModelInUse(config, engine, installed);
2030
2078
  const gpuUnmeasured = engine === "llama-cpp" && memory.source === "system-ram-fallback" && !!native2?.platformKey && !native2.engines.some((entry) => entry.name === "llama-server" && entry.installed);
2031
2079
  return {
2032
2080
  ranked: rankChatModels(catalog.items, recoDevice(memory), engine),
2033
2081
  installed: new Set(installed),
2034
- ...pinned ? { pinned } : {},
2082
+ ...inUse ? { inUse } : {},
2035
2083
  ...gpuUnmeasured ? { gpuUnmeasured } : {}
2036
2084
  };
2037
2085
  }
2038
2086
  function formatAvailableChatModels(input) {
2039
- const { engine, ranked, installed, pinned, measured, gpuUnmeasured } = input;
2087
+ const { engine, ranked, installed, inUse, measured, gpuUnmeasured } = input;
2040
2088
  if (ranked.length === 0) return `(no ${engine} chat models in the catalog for this machine)`;
2041
2089
  const width = Math.max(...ranked.map((model2) => model2.id.length));
2042
2090
  const measuredWidth = measured ? Math.max("not measured".length, ...ranked.map((m) => (measured.get(m.id) ?? "").length)) : 0;
@@ -2047,7 +2095,7 @@ function formatAvailableChatModels(input) {
2047
2095
  const notes = [
2048
2096
  index === 0 && !gpuUnmeasured ? "recommended" : "",
2049
2097
  installed.has(model2.id) ? "installed" : "",
2050
- model2.id === pinned ? "in use" : ""
2098
+ model2.id === inUse ? "in use" : ""
2051
2099
  ].filter(Boolean);
2052
2100
  const claim = measured ? ` ${(measured.get(model2.id) ?? "not measured").padEnd(measuredWidth)}` : "";
2053
2101
  lines.push(
@@ -3435,7 +3483,7 @@ import {
3435
3483
 
3436
3484
  // src/generate.ts
3437
3485
  import { mkdir as mkdir2, readFile as readFile4, writeFile as writeFile3 } from "fs/promises";
3438
- import { basename as basename2, dirname as dirname2, resolve as resolve2 } from "path";
3486
+ import { basename as basename2, dirname as dirname3, resolve as resolve2 } from "path";
3439
3487
  async function resolvePromptText(parts, file, label) {
3440
3488
  const inline = (parts ?? []).join(" ").trim();
3441
3489
  if (file) {
@@ -3490,7 +3538,7 @@ async function saveArtifact(client, projectId, artifactPath, output) {
3490
3538
  const blob = await client.fetchProjectArtifactBlob(projectId, rel);
3491
3539
  const bytes = Buffer.from(await blob.arrayBuffer());
3492
3540
  const dest = output ? resolve2(output) : resolve2(process.cwd(), basename2(artifactPath));
3493
- await mkdir2(dirname2(dest), { recursive: true });
3541
+ await mkdir2(dirname3(dest), { recursive: true });
3494
3542
  await writeFile3(dest, bytes);
3495
3543
  return dest;
3496
3544
  }
@@ -3768,7 +3816,7 @@ function registerMcpCommands(program2, connect, output = console.log) {
3768
3816
  // src/model-export.ts
3769
3817
  import { randomUUID as randomUUID2 } from "crypto";
3770
3818
  import { rename, rm as rm2, stat } from "fs/promises";
3771
- import { basename as basename3, dirname as dirname3, isAbsolute, resolve as resolve4 } from "path";
3819
+ import { basename as basename3, dirname as dirname4, isAbsolute, resolve as resolve4 } from "path";
3772
3820
  import {
3773
3821
  modelBytesFromResponse,
3774
3822
  portableGezmodelFilename,
@@ -3811,8 +3859,8 @@ async function exportModelToFile(client, id, options) {
3811
3859
  if (!options.force && await isExistingFile(target)) {
3812
3860
  throw new CliError(`${target} already exists. Pass --force to overwrite it.`);
3813
3861
  }
3814
- if (!await isExistingDirectory(dirname3(target))) {
3815
- throw new CliError(`${dirname3(target)} does not exist.`);
3862
+ if (!await isExistingDirectory(dirname4(target))) {
3863
+ throw new CliError(`${dirname4(target)} does not exist.`);
3816
3864
  }
3817
3865
  let pulled = false;
3818
3866
  if (!await isInstalled(client, engine, id)) {
@@ -3886,15 +3934,28 @@ function progressWriter(stream, options = {}) {
3886
3934
  stream.write(text);
3887
3935
  };
3888
3936
  }
3889
- const intervalMs = options.intervalMs ?? 15e3;
3937
+ const intervalMs = options.intervalMs ?? 6e4;
3890
3938
  const now = options.now ?? Date.now;
3891
3939
  let lastLine = "";
3892
3940
  let lastAt = Number.NEGATIVE_INFINITY;
3941
+ let series;
3893
3942
  return (text) => {
3894
3943
  const finished = text.endsWith("\n");
3895
3944
  const line = text.replace(/\r/g, "").trim();
3896
3945
  if (!line || line === lastLine) return;
3897
- if (!finished && now() - lastAt < intervalMs) return;
3946
+ if (finished) {
3947
+ series = void 0;
3948
+ } else {
3949
+ const percent = /(\d{1,3})%/.exec(line);
3950
+ if (percent) {
3951
+ const label = line.slice(0, percent.index).replace(/\d+/g, "#").trim();
3952
+ const quarter = Math.floor(Number(percent[1]) / 25);
3953
+ if (series?.label === label && (quarter <= series.quarter || quarter > 3)) return;
3954
+ series = { label, quarter };
3955
+ } else if (now() - lastAt < intervalMs) {
3956
+ return;
3957
+ }
3958
+ }
3898
3959
  stream.write(`${line}
3899
3960
  `);
3900
3961
  lastLine = line;
@@ -3964,6 +4025,19 @@ async function resolveRunGezel(client, ref) {
3964
4025
  }
3965
4026
  throw new CliError(`No crew member matches "${ref}". Run \`gezel agent list\` to see your crew.`);
3966
4027
  }
4028
+ async function resolveCrewMember(client, ref) {
4029
+ const wanted = ref.trim();
4030
+ const { gezels } = await client.listGezels();
4031
+ const byId = gezels.find((gezel) => gezel.id === wanted);
4032
+ if (byId) return byId.id;
4033
+ const query = wanted.toLowerCase();
4034
+ const sameName = gezels.filter((gezel) => gezel.name.trim().toLowerCase() === query);
4035
+ if (sameName.length === 1) return sameName[0].id;
4036
+ if (sameName.length > 1) throw ambiguous(ref, sameName);
4037
+ throw new CliError(
4038
+ `No crew member with the id or name "${ref}". Run \`gezel agent list\` to see your crew.`
4039
+ );
4040
+ }
3967
4041
  function ambiguous(ref, candidates) {
3968
4042
  const listed = candidates.map((gezel) => `${gezel.name} (${gezel.id})`).join(", ");
3969
4043
  return new CliError(
@@ -4031,15 +4105,47 @@ var RunProgress = class {
4031
4105
  };
4032
4106
 
4033
4107
  // src/run-prompt.ts
4034
- async function resolveRunPrompt(parts, input = process.stdin) {
4108
+ import { fstatSync } from "fs";
4109
+ var PIPED_FIRST_DATA_MS = 200;
4110
+ var S_IFMT = 61440;
4111
+ var S_IFREG = 32768;
4112
+ var S_IFIFO = 4096;
4113
+ var S_IFSOCK = 49152;
4114
+ function detectStdinKind(stat2 = fstatSync, isTTY = process.stdin.isTTY) {
4115
+ if (isTTY) return "tty";
4116
+ let type;
4117
+ try {
4118
+ type = stat2(0).mode & S_IFMT;
4119
+ } catch {
4120
+ return "none";
4121
+ }
4122
+ if (type === S_IFREG) return "file";
4123
+ if (type === S_IFIFO || type === S_IFSOCK) return "pipe";
4124
+ return "none";
4125
+ }
4126
+ async function resolveRunPrompt(parts, input = process.stdin, options = {}) {
4035
4127
  if (parts?.length !== 1 || parts[0] !== "-") {
4036
4128
  const prompt2 = (parts ?? []).join(" ").trim();
4037
4129
  if (!prompt2) throw new CliError('usage: gezel run "<prompt>" or gezel run -');
4038
- return prompt2;
4130
+ const kind = options.stdinKind ?? (input === process.stdin ? detectStdinKind() : input.isTTY ? "tty" : "none");
4131
+ if (kind !== "file" && kind !== "pipe") return prompt2;
4132
+ const piped = await readPiped(
4133
+ input,
4134
+ kind === "pipe" ? options.firstDataMs ?? PIPED_FIRST_DATA_MS : void 0
4135
+ );
4136
+ return piped?.trim() ? `${prompt2}
4137
+
4138
+ ${piped}` : prompt2;
4039
4139
  }
4040
4140
  if (input.isTTY) {
4041
4141
  throw new CliError("gezel run - requires piped input or a redirected file.");
4042
4142
  }
4143
+ const prompt = await readAll(input);
4144
+ if (!prompt.trim())
4145
+ throw new CliError("gezel run - received empty input. Supply a prompt on stdin.");
4146
+ return prompt;
4147
+ }
4148
+ async function readAll(input) {
4043
4149
  const chunks = [];
4044
4150
  try {
4045
4151
  for await (const chunk of input) {
@@ -4050,10 +4156,54 @@ async function resolveRunPrompt(parts, input = process.stdin) {
4050
4156
  `Could not read prompt from stdin: ${error instanceof Error ? error.message : String(error)}`
4051
4157
  );
4052
4158
  }
4053
- const prompt = Buffer.concat(chunks).toString("utf8");
4054
- if (!prompt.trim())
4055
- throw new CliError("gezel run - received empty input. Supply a prompt on stdin.");
4056
- return prompt;
4159
+ return Buffer.concat(chunks).toString("utf8");
4160
+ }
4161
+ async function readPiped(input, firstDataMs) {
4162
+ const iterator = input[Symbol.asyncIterator]();
4163
+ let first;
4164
+ try {
4165
+ if (firstDataMs === void 0) {
4166
+ first = await iterator.next();
4167
+ } else {
4168
+ let timer;
4169
+ const silent = new Promise((resolve7) => {
4170
+ timer = setTimeout(() => resolve7("silent"), firstDataMs);
4171
+ });
4172
+ const next = iterator.next();
4173
+ const result = await Promise.race([next, silent]).finally(() => clearTimeout(timer));
4174
+ if (result === "silent") {
4175
+ next.catch(() => {
4176
+ });
4177
+ letGo(input);
4178
+ return void 0;
4179
+ }
4180
+ first = result;
4181
+ }
4182
+ } catch (error) {
4183
+ throw new CliError(
4184
+ `Could not read the piped text from stdin: ${error instanceof Error ? error.message : String(error)}`
4185
+ );
4186
+ }
4187
+ if (first.done) return void 0;
4188
+ const chunks = [toBuffer(first.value)];
4189
+ try {
4190
+ for (let next = await iterator.next(); !next.done; next = await iterator.next()) {
4191
+ chunks.push(toBuffer(next.value));
4192
+ }
4193
+ } catch (error) {
4194
+ throw new CliError(
4195
+ `Could not read the piped text from stdin: ${error instanceof Error ? error.message : String(error)}`
4196
+ );
4197
+ }
4198
+ return Buffer.concat(chunks).toString("utf8");
4199
+ }
4200
+ function toBuffer(chunk) {
4201
+ return Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
4202
+ }
4203
+ function letGo(input) {
4204
+ const stream = input;
4205
+ stream.pause?.();
4206
+ stream.unref?.();
4057
4207
  }
4058
4208
 
4059
4209
  // src/run-reply.ts
@@ -4527,7 +4677,7 @@ function resolveRestoreSelection(review, opts) {
4527
4677
  // src/task-output.ts
4528
4678
  import { constants } from "fs";
4529
4679
  import { access, mkdir as mkdir3, writeFile as writeFile4 } from "fs/promises";
4530
- import { dirname as dirname4, isAbsolute as isAbsolute2, join as join4, relative, resolve as resolve5, sep } from "path";
4680
+ import { dirname as dirname5, isAbsolute as isAbsolute2, join as join4, relative, resolve as resolve5, sep } from "path";
4531
4681
  import { taskDeliverableCandidates } from "@bendyline/gezel";
4532
4682
  function madeFiles(files, artifactDir) {
4533
4683
  const made = [];
@@ -4548,7 +4698,7 @@ async function copyTaskOutput(client, projectId, artifactDir, outDir) {
4548
4698
  const target = join4(root, name);
4549
4699
  if (relative(root, target).startsWith("..")) continue;
4550
4700
  const blob = await client.fetchProjectArtifactBlob(projectId, path);
4551
- await mkdir3(dirname4(target), { recursive: true });
4701
+ await mkdir3(dirname5(target), { recursive: true });
4552
4702
  await writeFile4(target, Buffer.from(await blob.arrayBuffer()));
4553
4703
  copied.push(name);
4554
4704
  }
@@ -4748,7 +4898,7 @@ async function runWorkflow(client, projectId, workspace, file, args, log = conso
4748
4898
  ...params ? { params } : {},
4749
4899
  ...book?.paramSchema ? { paramSchema: book.paramSchema } : {},
4750
4900
  prompter: terminalPrompter(),
4751
- write: (text) => process.stderr.write(text)
4901
+ write: stderrProgress()
4752
4902
  });
4753
4903
  return module.run({
4754
4904
  client,
@@ -4841,7 +4991,7 @@ program.name("gezel").description("Gezel \u2014 put AI to work on your files and
4841
4991
  "Use this folder as the active project (default and bare flag: cwd)."
4842
4992
  ).option(
4843
4993
  "--download",
4844
- "Download what a command needs (the on-device engine and the recommended model) without asking, printing each step. Also GEZEL_AUTO_DOWNLOAD=1."
4994
+ "Download what a command needs (the on-device engine and the recommended model, or DuckDB for knowledge export-parquet) without asking, printing each step. Also GEZEL_AUTO_DOWNLOAD=1."
4845
4995
  );
4846
4996
  var cliGlobals = () => program.opts();
4847
4997
  var connectForInspection = (opts) => opts.start === false ? connectRunning(cliGlobals()) : connectOwned(cliGlobals());
@@ -5349,10 +5499,14 @@ program.command("run [prompt...]").description("Send a prompt to Gezel and print
5349
5499
  `
5350
5500
  Examples:
5351
5501
  gezel run "Summarize this project"
5502
+ gezel run "Summarize these notes" < notes.txt
5352
5503
  printf 'Summarize these notes:\\nThe launch is Friday.\\n' | gezel run -
5353
5504
  gezel run - < prompt.txt
5354
5505
 
5355
5506
  A sole - reads UTF-8 stdin to EOF. Empty input is rejected.
5507
+ With a prompt, text piped or redirected to stdin is sent after it,
5508
+ separated by a blank line. A pipe that sends nothing within a moment is
5509
+ left unread; use - to wait for a slow one.
5356
5510
  Replies go to stdout; diagnostics go to stderr.
5357
5511
  With no model set up yet, a run in a terminal first offers to download one,
5358
5512
  then runs the prompt.`
@@ -5378,7 +5532,7 @@ then runs the prompt.`
5378
5532
  const gezelId = opts.gezel ? await resolveRunGezel(client, opts.gezel) : await ensureCliProjectLead(client, projectId);
5379
5533
  let readiness = await checkRunReadiness(client, gezelId);
5380
5534
  if (!readiness.ready && autoDownloadRequested(cliGlobals())) {
5381
- await downloadForRun(client, { gezelId, write: (text) => process.stderr.write(text) });
5535
+ await downloadForRun(client, { gezelId, write: stderrProgress() });
5382
5536
  readiness = await checkRunReadiness(client, gezelId);
5383
5537
  } else if (!readiness.ready && canOfferRunSetup()) {
5384
5538
  const tuiModule = "../tui/index.js";
@@ -5716,13 +5870,14 @@ craftbook.command("show <command...>").description("Show what a craftbook does,
5716
5870
  console.log(opts.json ? JSON.stringify(full) : describeCraftbook(book, full));
5717
5871
  });
5718
5872
  var agent = program.command("agent").description("Manage your crew (your AI companions)");
5719
- agent.command("output-limit <id> [tokens]").description(
5720
- "Show or set one crew member's output-token limit, including reasoning; auto clears its override"
5721
- ).option("--json", "Output the override as JSON").action(async (id, tokens, opts) => {
5873
+ agent.command("output-limit <crew-member> [tokens]").description(
5874
+ "Show or set one crew member's output-token limit (by id or name), including reasoning; auto clears its override"
5875
+ ).option("--json", "Output the override as JSON").action(async (ref, tokens, opts) => {
5722
5876
  if (tokens !== void 0 && tokens !== "auto" && (!/^\d+$/.test(tokens) || !Number.isSafeInteger(Number(tokens)) || Number(tokens) < 1)) {
5723
5877
  throw new CliError("Output limit must be a positive integer, or auto.");
5724
5878
  }
5725
5879
  const client = await connectOwned(cliGlobals());
5880
+ const id = await resolveCrewMember(client, ref);
5726
5881
  const { parsed } = await client.getGezel(id);
5727
5882
  const tuning = { ...parsed.frontmatter.tuning };
5728
5883
  const sampling = { ...tuning.sampling };
@@ -5750,8 +5905,9 @@ agent.command("create <name>").description("Add a crew member").option("-d, --de
5750
5905
  const created = await client.createGezel({ name, ...opts });
5751
5906
  console.log(`created crew member ${created.id}`);
5752
5907
  });
5753
- agent.command("show <id>").description("Show one crew member").action(async (id) => {
5908
+ agent.command("show <crew-member>").description("Show one crew member, by id or name").action(async (ref) => {
5754
5909
  const client = await connectOwned(cliGlobals());
5910
+ const id = await resolveCrewMember(client, ref);
5755
5911
  const a = await client.getGezel(id).catch((err) => {
5756
5912
  throw isNotFound(err) ? new CliError(`No crew member with id "${id}". Run \`gezel agent list\` to see your crew.`) : err;
5757
5913
  });
@@ -5949,8 +6105,21 @@ knowledge.command("export-parquet <path>").description(
5949
6105
  "DuckDB CLI to use (default: $GEZEL_DUCKDB_BIN or the one gezel installed)"
5950
6106
  ).action(async (path, opts) => {
5951
6107
  const { runKnowledgeExportParquet } = await loadKnowledgeCommand();
5952
- await runKnowledgeExportParquet(path, opts);
6108
+ await runKnowledgeExportParquet(
6109
+ path,
6110
+ opts,
6111
+ autoDownloadRequested(cliGlobals()) ? { fetchDuckdb: fetchDuckdbForCli } : {}
6112
+ );
5953
6113
  });
6114
+ async function fetchDuckdbForCli() {
6115
+ process.stderr.write("No DuckDB CLI found; downloading it (--download)\u2026\n");
6116
+ const client = await connectOwned(cliGlobals());
6117
+ const status = await installNativeToolkit(client, {
6118
+ engines: ["duckdb"],
6119
+ output: { writeProgress: stderrProgress() }
6120
+ });
6121
+ return status.engines.find((engine) => engine.name === "duckdb" && engine.installed)?.path;
6122
+ }
5954
6123
  knowledge.command("search <path> <query>").description("Search a catalog file offline (full-text; --semantic adds vector search)").option("--semantic", "embed the query with the catalog profile (loads the model)").option("--latitude <degrees>", "radius center latitude", Number).option("--longitude <degrees>", "radius center longitude", Number).option("--radius-meters <meters>", "subject radius in meters", Number).option("--limit <n>", "maximum results", (v) => Number.parseInt(v, 10), 10).action(async (path, query, opts) => {
5955
6124
  const { runKnowledgeSearch } = await loadKnowledgeCommand();
5956
6125
  await runKnowledgeSearch(path, query, opts);
@@ -6434,18 +6603,11 @@ model.command("list").description("List downloaded chat models, or with --availa
6434
6603
  );
6435
6604
  return;
6436
6605
  }
6437
- const { models } = provider === "mlx" ? await client.listMlxModels() : provider === "ds4" ? await client.listDs4Models() : await client.listLlamaCppModels();
6438
- if (models.length === 0) {
6439
- console.log(
6440
- `(no local ${provider} models \u2014 \`gezel model list --available\` shows ones to download)`
6441
- );
6442
- return;
6443
- }
6444
- for (const m of models) {
6445
- console.log(
6446
- `${m.id.padEnd(28)} ${(m.approxSizeBytes / 1e9).toFixed(2).padStart(6)} GB ${m.name}`
6447
- );
6448
- }
6606
+ const [{ models }, config] = await Promise.all([
6607
+ provider === "mlx" ? client.listMlxModels() : provider === "ds4" ? client.listDs4Models() : client.listLlamaCppModels(),
6608
+ client.getConfig()
6609
+ ]);
6610
+ console.log(formatInstalledChatModels(provider, models, config));
6449
6611
  });
6450
6612
  model.command("pull <id>").description(
6451
6613
  "Download a local chat model from the catalog (e.g. qwen3.5-2b-q4, about 1.5 GB; `gezel model list --available` shows what fits)"
@@ -6454,7 +6616,20 @@ model.command("pull <id>").description(
6454
6616
  const provider = resolveModelProvider(opts.provider);
6455
6617
  const progress = stderrProgress();
6456
6618
  await ensureModelEngines(client, [provider], progress);
6457
- await pullChatModel(client, provider, id, progress);
6619
+ const shared = await findSharedModel(client, provider, id);
6620
+ if (shared) {
6621
+ progress(
6622
+ `${id} is already on this computer in a shared model store, so nothing was downloaded: ${shared.location}
6623
+ `
6624
+ );
6625
+ if (shared.updateAvailable) {
6626
+ progress(
6627
+ "The catalog has a newer version. The Gezel that shares this copy updates it when it updates its models.\n"
6628
+ );
6629
+ }
6630
+ } else {
6631
+ await pullChatModel(client, provider, id, progress);
6632
+ }
6458
6633
  if (provider === "mlx") await waitForMlxRuntime(client, progress);
6459
6634
  if (await pinPulledModel(client, provider, id) === "pinned") {
6460
6635
  process.stderr.write(`${id} is now the default ${provider} model.
@@ -1585,6 +1585,7 @@ import {
1585
1585
  CRAFTBOOK_CATEGORY_META,
1586
1586
  SCORECARD,
1587
1587
  catalogGroundFor as catalogGroundFor2,
1588
+ docbenchRowsFor,
1588
1589
  measuredClaim,
1589
1590
  measuredResultFor,
1590
1591
  measuredRowsFor,
@@ -1766,14 +1767,15 @@ function modelCatalogMarkdown(chat, images, videos, scorecard) {
1766
1767
  "",
1767
1768
  `## Chat models (${chat.length})`,
1768
1769
  "",
1769
- "The models Gezel thinks and writes with, recommended first. **Measured** is the share of tasks the model (or another build of it) passed in its most recent full [scorecard](model-scorecard) round, preferring the general set, with the machine that round ran on. Follow it to every round on the model\u2019s page. Rounds are not comparable with each other, and a number from a workstation is not a promise about a laptop.",
1770
+ "The models Gezel thinks and writes with, recommended first. **Measured** is the share of tasks the model (or another build of it) passed in its most recent full [scorecard](model-scorecard) round, preferring the general set, with the machine that round ran on. Follow it to every round on the model\u2019s page. Rounds are not comparable with each other, and a number from a workstation is not a promise about a laptop. **Docbench** is the build\u2019s score from 0 to 100 on DocBlocks\u2019 document work (review, writing, diagrams, slides, study aids) in its newest [docbench](docbench) round.",
1770
1771
  "",
1771
- "| Model | Measured | Size | Context | Tools | Best for | Runs on | License |",
1772
- "| --- | --- | --- | --- | --- | --- | --- | --- |",
1772
+ "| Model | Measured | Docbench | Size | Context | Tools | Best for | Runs on | License |",
1773
+ "| --- | --- | --- | --- | --- | --- | --- | --- | --- |",
1773
1774
  ...chat.map(
1774
1775
  (m) => row([
1775
1776
  `[${cell(m.name)}](model/${m.id})`,
1776
1777
  measuredCell(scorecard, m.id),
1778
+ docbenchCell(scorecard, m.id),
1777
1779
  formatGB(m.approxSizeBytes),
1778
1780
  formatContext(m.contextWindow),
1779
1781
  m.supportsTools === false ? "No" : "Yes",
@@ -1829,6 +1831,64 @@ function measuredCell(scorecard, modelId) {
1829
1831
  if (!measured) return "Not yet";
1830
1832
  return `[${cell(measuredClaim(measured))}](model/${modelId}#measured-results)`;
1831
1833
  }
1834
+ function docbenchCell(scorecard, modelId) {
1835
+ const latest = docbenchRowsFor(scorecard, modelId)[0];
1836
+ if (!latest) return "Not yet";
1837
+ return `[${Math.round(latest.docbench.score)}](model/${modelId}#docbench)`;
1838
+ }
1839
+ var DOCBENCH_FAMILY_LABELS = [
1840
+ ["review", "Review and feedback"],
1841
+ ["writing", "Writing new content"],
1842
+ ["visuals", "Diagrams and illustrations"],
1843
+ ["presentations", "Presentations"],
1844
+ ["study", "Study aids"],
1845
+ ["narration", "Narration cleanup"]
1846
+ ];
1847
+ function docbenchResultsMarkdown(scorecard, modelId) {
1848
+ const rows = docbenchRowsFor(scorecard, modelId);
1849
+ const latest = rows[0];
1850
+ if (!latest) return [];
1851
+ const { docbench, result, run } = latest;
1852
+ const whole = (value) => String(Math.round(value));
1853
+ const range = (ci) => `${whole(ci[0])}\u2013${whole(ci[1])}`;
1854
+ const engine = SCORECARD_ENGINE_LABELS[result.engine] ?? result.engine;
1855
+ const lines = [
1856
+ "## Docbench",
1857
+ "",
1858
+ `How well this build does DocBlocks\u2019 document work, judged from 0 to 100 in the [docbench](docbench) ${run.scope === "subset" ? "focused re-run" : "round"} of ${run.provenance.startedAt.slice(0, 10)} on ${engine}: **${whole(docbench.score)}** (95% range ${range(docbench.ci)}, band ${docbench.band}). DocBlocks could use ${Math.round(docbench.usableRate * 100)}% of its answers.`,
1859
+ "",
1860
+ "| Group | Score | 95% range |",
1861
+ "| --- | --- | --- |"
1862
+ ];
1863
+ const known = new Set(DOCBENCH_FAMILY_LABELS.map(([id]) => id));
1864
+ const families = [
1865
+ ...DOCBENCH_FAMILY_LABELS,
1866
+ ...Object.keys(docbench.families).filter((id) => !known.has(id)).map((id) => [id, id])
1867
+ ];
1868
+ for (const [id, label] of families) {
1869
+ const family = docbench.families[id];
1870
+ if (family) lines.push(row([label, whole(family.score), range(family.ci)]));
1871
+ }
1872
+ const findings = docbench.tasks["review-general"]?.findings;
1873
+ if (findings) {
1874
+ const one = (value) => value.toFixed(1);
1875
+ lines.push(
1876
+ "",
1877
+ `In general review it found, per document, ${one(findings.low)} small fixes, ${one(findings.medium)} moderate changes and ${one(findings.high)} substantial ones, and added ${one(findings.trivial)} trivial and ${one(findings.wrong)} wrong suggestions.`
1878
+ );
1879
+ }
1880
+ if (rows.length > 1) {
1881
+ lines.push(
1882
+ "",
1883
+ "Earlier results for this build, measured before the one above under their own round\u2019s tests, reviewer and Gezel version:",
1884
+ "",
1885
+ ...rows.slice(1).map(
1886
+ (earlier) => `- ${earlier.run.provenance.startedAt.slice(0, 10)}, pack ${earlier.docbench.packVersion}: ${whole(earlier.docbench.score)}`
1887
+ )
1888
+ );
1889
+ }
1890
+ return lines;
1891
+ }
1832
1892
  var SCORECARD_ENGINE_LABELS = {
1833
1893
  "llama-cpp": "llama.cpp",
1834
1894
  mlx: "MLX",
@@ -1917,6 +1977,8 @@ function chatModelMarkdown(m, scorecard) {
1917
1977
  "",
1918
1978
  ...measuredResultsMarkdown(scorecard, m.id)
1919
1979
  ];
1980
+ const docbench = docbenchResultsMarkdown(scorecard, m.id);
1981
+ if (docbench.length > 0) lines.push("", ...docbench);
1920
1982
  const more = [
1921
1983
  m.upstream ? `[The model\u2019s own page](${m.upstream})` : "",
1922
1984
  "[Every model](model-catalog)",
@@ -467,9 +467,25 @@ async function manifestFor(abs) {
467
467
  const info = await stat(abs).catch(() => null);
468
468
  if (!info) throw new CliError(`no such file or directory: ${abs}`);
469
469
  if (info.isDirectory()) {
470
- return JSON.parse(await readFile2(join2(abs, "manifest.json"), "utf8"));
470
+ let raw;
471
+ try {
472
+ raw = await readFile2(join2(abs, "manifest.json"), "utf8");
473
+ } catch {
474
+ throw new CliError(`${abs} has no manifest.json \u2014 not an extracted catalog`);
475
+ }
476
+ try {
477
+ return JSON.parse(raw);
478
+ } catch {
479
+ throw new CliError(`${join2(abs, "manifest.json")} is not valid JSON`);
480
+ }
481
+ }
482
+ try {
483
+ return await readGezkManifest(abs);
484
+ } catch (err) {
485
+ throw new CliError(
486
+ `${abs} is not a readable .gezk archive: ${err instanceof Error ? err.message : String(err)}`
487
+ );
471
488
  }
472
- return readGezkManifest(abs);
473
489
  }
474
490
  function excerpt(text) {
475
491
  const flat = text.replace(/\s+/g, " ").trim();
@@ -483,7 +499,14 @@ function formatBytes(bytes) {
483
499
  function contentSha256(bytes) {
484
500
  return createHash2("sha256").update(bytes).digest("hex");
485
501
  }
486
- async function runKnowledgeExportParquet(path, opts) {
502
+ function duckdbMissingMessage(version) {
503
+ return [
504
+ "No DuckDB CLI found. To get one:",
505
+ ` gezel native install --engine duckdb (downloads DuckDB ${version}; or run this command again with --download)`,
506
+ " or install DuckDB yourself (https://duckdb.org), on your PATH or named with --duckdb <binary>"
507
+ ].join("\n");
508
+ }
509
+ async function runKnowledgeExportParquet(path, opts, deps = {}) {
487
510
  const { DUCKDB_VERSION, duckdbInstalledBinary } = await import("@bendyline/gezel/native");
488
511
  const { exportCatalogParquet, findDuckdbBinary } = await import("@bendyline/gezel-knowledge");
489
512
  const resolved = resolve2(path);
@@ -492,12 +515,8 @@ async function runKnowledgeExportParquet(path, opts) {
492
515
  const source = info.isDirectory() ? { rootDir: resolved } : { archivePath: resolved };
493
516
  const outDir = opts.out ? resolve2(opts.out) : join2(dirname2(resolved), `${basename2(resolved).replace(/\.gezk$/i, "")}-parquet`);
494
517
  const installed = duckdbInstalledBinary(process.env.GEZEL_HOME ?? join2(homedir2(), ".gezel"));
495
- const binaryPath = opts.duckdb ?? process.env.GEZEL_DUCKDB_BIN?.trim() ?? (await stat(installed).catch(() => null) ? installed : await findDuckdbBinary());
496
- if (!binaryPath) {
497
- throw new CliError(
498
- `no DuckDB CLI found \u2014 open a data feature in gezel once (it installs DuckDB ${DUCKDB_VERSION}), install DuckDB yourself, or pass --duckdb <binary>`
499
- );
500
- }
518
+ const binaryPath = opts.duckdb || process.env.GEZEL_DUCKDB_BIN?.trim() || (await stat(installed).catch(() => null) ? installed : await findDuckdbBinary()) || await deps.fetchDuckdb?.();
519
+ if (!binaryPath) throw new CliError(duckdbMissingMessage(DUCKDB_VERSION));
501
520
  const report = await exportCatalogParquet({
502
521
  source,
503
522
  outDir,
@@ -553,6 +572,7 @@ async function runKnowledgeNearby(path, radius, opts = {}) {
553
572
  }
554
573
  export {
555
574
  contentSha256,
575
+ duckdbMissingMessage,
556
576
  embeddingRuntimeMissingMessage,
557
577
  runKnowledgeBuild,
558
578
  runKnowledgeExportParquet,
package/dist/tui/index.js CHANGED
@@ -4771,6 +4771,9 @@ import {
4771
4771
  } from "@bendyline/gezel";
4772
4772
  import { resolveOnDeviceProvider as resolveOnDeviceProvider2 } from "@bendyline/gezel/native";
4773
4773
 
4774
+ // src/model-pull.ts
4775
+ import { dirname as dirname2 } from "path";
4776
+
4774
4777
  // src/native-command.ts
4775
4778
  import {
4776
4779
  NativeEngineNameSchema
@@ -5079,7 +5082,7 @@ function BootstrapGate(props) {
5079
5082
  );
5080
5083
  if (screen.kind === "ready") return /* @__PURE__ */ jsx6(Fragment4, { children });
5081
5084
  if (screen.kind === "loading") {
5082
- return /* @__PURE__ */ jsx6(BootstrapFrame, { title: "Preparing the workshop", children: /* @__PURE__ */ jsxs7(Text7, { color: "yellow", children: [
5085
+ return /* @__PURE__ */ jsx6(BootstrapFrame, { title: "Getting Gezel ready", children: /* @__PURE__ */ jsxs7(Text7, { color: "yellow", children: [
5083
5086
  "\u25CF ",
5084
5087
  screen.message
5085
5088
  ] }) });
@@ -5147,7 +5150,7 @@ function BootstrapGate(props) {
5147
5150
  },
5148
5151
  ...screen.plan.accessories.length > 0 ? [
5149
5152
  {
5150
- label: `Complete workshop set \u2014 ${bootstrapChatModelLabel(best)} + ${screen.plan.accessories.length} ${screen.plan.accessories.length === 1 ? "helper" : "helpers"}`,
5153
+ label: `Complete set \u2014 ${bootstrapChatModelLabel(best)} + ${screen.plan.accessories.length} ${screen.plan.accessories.length === 1 ? "helper" : "helpers"}`,
5151
5154
  hint: `optional \xB7 ${bestInstalled ? "chat model already available \xB7 " : ""}${workshopDownloadBytes > 0 ? formatDownloadSize(workshopDownloadBytes) : "already available"}${workshopHelperLabels ? ` \xB7 includes ${workshopHelperLabels}` : ""}`,
5152
5155
  value: "bundle"
5153
5156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bendyline/gezel-cli",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "The gezel command-line tool: chat with your gezels, run craftbooks, and manage local models from the terminal.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -44,12 +44,12 @@
44
44
  "!dist/**/*.map"
45
45
  ],
46
46
  "dependencies": {
47
- "@bendyline/gezel": "1.3.0",
48
- "@bendyline/gezel-app-sdk": "1.2.0",
49
- "@bendyline/gezel-catalog": "1.3.0",
50
- "@bendyline/gezel-client": "1.3.0",
47
+ "@bendyline/gezel": "1.3.1",
48
+ "@bendyline/gezel-app-sdk": "1.2.1",
49
+ "@bendyline/gezel-catalog": "1.3.1",
50
+ "@bendyline/gezel-client": "1.3.1",
51
51
  "@bendyline/gezel-knowledge": "1.2.11",
52
- "@bendyline/gezel-service": "1.3.0",
52
+ "@bendyline/gezel-service": "1.3.1",
53
53
  "@bendyline/squisq": "2.13.12",
54
54
  "@bendyline/squisq-formats": "2.8.14",
55
55
  "@bendyline/squisq-react": "2.12.24",