@bendyline/gezel-cli 1.1.2 → 1.2.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/README.md CHANGED
@@ -101,7 +101,7 @@ gezel secret set openaiApiKey --stdin < /path/to/private-key-file
101
101
  gezel secret remove openaiApiKey
102
102
  ```
103
103
 
104
- `--use-for-search` also selects Brave (or Tavily for `tavilyApiKey`) as the
104
+ `--use-for-search` (with `braveSearchApiKey`) also selects Brave as the
105
105
  search provider while preserving its other settings. Without it, setting a
106
106
  credential leaves provider selection unchanged. `secret list` gives the supported
107
107
  names and whether each is configured; credentials are write-only and never
@@ -210,10 +210,12 @@ The CLI does not bundle model weights or native inference engines; those are
210
210
  downloaded only on demand when you opt into on-device models. Straight away
211
211
  you can use:
212
212
 
213
- - The interactive TUI (`gezel`) and one-shot prompts (`gezel run "…"`)
213
+ - The interactive TUI (`gezel`), which walks you through choosing a model on
214
+ first use, and one-shot prompts (`gezel run "…"`) once a model is set up.
215
+ Until then `run` downloads nothing: it names the setup commands and exits.
214
216
  - Cloud providers — OpenAI, Anthropic, GitHub Copilot, and any
215
217
  OpenAI-compatible endpoint
216
- - Gezel and project management (`gezel agent`, `gezel env`, `gezel task`)
218
+ - Gezel and project management (`gezel agent`, `gezel project`, `gezel task`)
217
219
  - Skills and handbook export (`gezel skills convert`, `gezel handboek export`) —
218
220
  these need no running daemon at all
219
221
 
@@ -261,14 +263,14 @@ Run `gezel --help` for the full list. The most-used ones:
261
263
  | `gezel run [prompt…]` | One-shot prompt in the current directory's project, using its voorman by default; optionally `--gezel <id>` / `--project <folder>` |
262
264
  | `gezel do <craftbook…>` | Start a craftbook as an immediately dispatched task in the current directory's project; accepts its id or display name |
263
265
  | `gezel workflow <name-or-file> [args…]` | Run an explicitly trusted repository workflow from `.gezel/workflows/<name>.mjs` or a module path |
264
- | `gezel secret list / set / remove` | Manage write-only provider credentials, including Brave and Tavily search keys |
266
+ | `gezel secret list / set / remove` | Manage write-only provider credentials, including the Brave search key |
265
267
  | `gezel task wait <ref>` / `resume <ref>` | Follow a task to completion, or retry a paused task and follow it |
266
268
  | `gezel task notes <ref> --warnings` | Read task notes and runtime warnings from its recent sessions |
267
269
  | `gezel start` / `stop` / `status` | Use or inspect the selected service. `stop` is the same hard stop as the desktop UX: cancel work, unload local engines, and switch to Reactive. `stop --daemon` shuts down a user-owned daemon process itself. `start --web` serves the browser UI. On hosts without a Gezel machine service, a started daemon prefers the canonical port 6228 (ephemeral fallback) so third-party OpenAI clients get a stable `https://127.0.0.1:6228/v1` base URL; with a machine service installed, the service owns 6228 and started daemons use an ephemeral port (`--port` pins one explicitly). |
268
270
  | `gezel doctor` | Report on the local install |
269
271
  | `gezel mode [read-only\|reactive\|reactive+tasks\|full-play]` | Show or change how much AI activity is allowed |
270
272
  | `gezel agent list\|create\|show` | Manage your gezels |
271
- | `gezel env list\|create\|install` | Manage projects and their packages |
273
+ | `gezel project list\|create\|install` | Manage projects and their packages (`gezel env` is the same command) |
272
274
  | `gezel task list\|create\|show` | Manage tasks |
273
275
  | `gezel model list\|pull\|export` | Manage on-device chat models. `export <id> [file]` downloads the catalog model if needed, then writes a portable, checksum-verified `.gezmodel` you can move to another machine |
274
276
  | `gezel native install\|list\|status` | Manage native engine binaries |
@@ -286,6 +286,7 @@ import {
286
286
  createTrustingFetch,
287
287
  discoverOrSpawn,
288
288
  electronNativeBinCandidates,
289
+ ensureProjectForFolder as ensureClientProjectForFolder,
289
290
  isProcessAlive,
290
291
  readRuntime,
291
292
  readSystemServiceEndpoint,
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/app-command.ts
4
- import { readFile as readFile2 } from "fs/promises";
4
+ import { readFile as readFile2, realpath } from "fs/promises";
5
5
  import { isAbsolute, join as join2, resolve as resolve2 } from "path";
6
6
  import { compareSemver } from "@bendyline/gezel";
7
7
 
@@ -23,6 +23,7 @@ import {
23
23
  createTrustingFetch,
24
24
  discoverOrSpawn,
25
25
  electronNativeBinCandidates,
26
+ ensureProjectForFolder as ensureClientProjectForFolder,
26
27
  isProcessAlive,
27
28
  readRuntime,
28
29
  readSystemServiceEndpoint,
@@ -39,25 +40,15 @@ var CliError = class extends Error {
39
40
  };
40
41
  async function ensureProjectForFolder(client, folderPath) {
41
42
  const wd = resolve(folderPath);
42
- const eq = (a, b) => !!a && (process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b);
43
- const { projects } = await client.listProjects();
44
- const exact = projects.find((p) => eq(p.workingDir, wd));
45
- if (exact) return exact.id;
46
43
  const name = basename(wd) || "workspace";
47
- const orphan = projects.find((p) => !p.workingDir && p.name === name);
48
- if (orphan) {
49
- await client.setProjectWorkingDir(orphan.id, wd);
50
- return orphan.id;
51
- }
52
- const created = await client.createProject({
53
- name,
44
+ const result = await ensureClientProjectForFolder(client, wd, {
45
+ mode: "solo",
46
+ source: "cli",
54
47
  description: `CLI workspace at ${wd}`,
55
48
  about: `${name} \u2014 working directory ${wd}. Fill in who this project is for, what's in scope, and what's explicitly out of scope.`,
56
- missionObjectives: `${name} \u2014 fill in concrete success criteria for this project.`,
57
- mode: "solo",
58
- workingDir: wd
49
+ missionObjectives: `${name} \u2014 fill in concrete success criteria for this project.`
59
50
  });
60
- return created.id;
51
+ return result.projectId;
61
52
  }
62
53
 
63
54
  // src/app-command.ts
@@ -306,11 +297,12 @@ async function runAppSetEnabled(client, appId, enabled) {
306
297
  throw new CliError(apiMessage(err));
307
298
  }
308
299
  }
309
- function findProjectForFolder(projects, folder) {
310
- const wd = resolve2(folder);
311
- return projects.find(
312
- (project) => !!project.workingDir && (process.platform === "win32" ? project.workingDir.toLowerCase() === wd.toLowerCase() : project.workingDir === wd)
313
- );
300
+ async function findProjectForFolder(projects, folder) {
301
+ const requested = resolve2(folder);
302
+ const real = await realpath(requested).catch(() => requested);
303
+ const fold = (p) => process.platform === "win32" || process.platform === "darwin" ? p.toLowerCase() : p;
304
+ const wanted = /* @__PURE__ */ new Set([fold(requested), fold(real)]);
305
+ return projects.find((project) => !!project.workingDir && wanted.has(fold(project.workingDir)));
314
306
  }
315
307
  function parseParamFlags(flags) {
316
308
  const params = {};
@@ -398,7 +390,7 @@ async function runAppApply(client, appId, folder, opts) {
398
390
  }
399
391
  const params = parseParamFlags(opts.param ?? []);
400
392
  const { projects } = await client.listProjects();
401
- const existing = findProjectForFolder(projects, folder);
393
+ const existing = await findProjectForFolder(projects, folder);
402
394
  const projectId = existing?.id ?? await ensureProjectForFolder(client, folder);
403
395
  const project = await client.getProject(projectId);
404
396
  if (!opts.json) {
@@ -453,7 +445,7 @@ async function runAppApply(client, appId, folder, opts) {
453
445
  }
454
446
  async function runAppStatus(client, folder, opts) {
455
447
  const { projects } = await client.listProjects();
456
- const project = findProjectForFolder(projects, folder);
448
+ const project = await findProjectForFolder(projects, folder);
457
449
  if (!project) {
458
450
  console.log(`No gezel project is linked to ${resolve2(folder)}.`);
459
451
  console.log("Apply an app here with: gezel app apply <appId>");
@@ -509,7 +501,7 @@ async function openUrlInBrowser(url) {
509
501
  async function resolveServeProject(client, appId, folder) {
510
502
  const { projects } = await client.listProjects();
511
503
  if (!appId) {
512
- const existing = findProjectForFolder(projects, folder);
504
+ const existing = await findProjectForFolder(projects, folder);
513
505
  const projectId = existing?.id ?? await ensureProjectForFolder(client, folder);
514
506
  const project = await client.getProject(projectId);
515
507
  if (!project.projectType) {
@@ -2,7 +2,13 @@
2
2
 
3
3
  // src/bin/gezel.ts
4
4
  import { basename as basename4, isAbsolute as isAbsolutePath, join as joinPath } from "path";
5
- import { GEZEL_VERSION, getLogOutput, setLogOutput } from "@bendyline/gezel";
5
+ import {
6
+ GEZEL_VERSION,
7
+ getLogLevel,
8
+ getLogOutput,
9
+ setLogLevel,
10
+ setLogOutput
11
+ } from "@bendyline/gezel";
6
12
  import {
7
13
  GezelApiError as GezelApiError3,
8
14
  streamChatEvents
@@ -20,6 +26,37 @@ import {
20
26
  import { resolveOnDeviceProvider } from "@bendyline/gezel/native";
21
27
  import { Command } from "commander";
22
28
 
29
+ // src/cli-errors.ts
30
+ function formatCliFailure(err, env2 = process.env) {
31
+ if (!(err instanceof Error)) return null;
32
+ if (err.name === "CliError") return err.message;
33
+ if (err.name !== "GezelApiError" || env2.GEZEL_DEBUG === "1") return null;
34
+ const { status, details } = err;
35
+ const request = /\bon ([A-Z]+ \S+)/.exec(err.message)?.[1];
36
+ const serviceText = detailText(details);
37
+ if (status === 404) {
38
+ const what = serviceText && serviceText.toLowerCase() !== "not found" ? serviceText : void 0;
39
+ return `error: not found${what ? `: ${what}` : request ? ` (${request})` : ""}`;
40
+ }
41
+ const lines = [`error: ${serviceText ?? err.message}`];
42
+ if (serviceText && request) lines.push(`(Gezel service answered ${status ?? "?"} to ${request})`);
43
+ lines.push("Set GEZEL_DEBUG=1 to see the full error.");
44
+ return lines.join("\n");
45
+ }
46
+ function isNotFound(err) {
47
+ return err instanceof Error && err.name === "GezelApiError" && err.status === 404;
48
+ }
49
+ function detailText(details) {
50
+ if (typeof details === "string" && details.trim()) return details.trim();
51
+ if (details && typeof details === "object") {
52
+ for (const key of ["message", "error"]) {
53
+ const value = details[key];
54
+ if (typeof value === "string" && value.trim()) return value.trim();
55
+ }
56
+ }
57
+ return void 0;
58
+ }
59
+
23
60
  // src/connection.ts
24
61
  import { createHash, randomUUID } from "crypto";
25
62
  import { chmod, mkdir, readFile, rm, writeFile } from "fs/promises";
@@ -38,6 +75,7 @@ import {
38
75
  createTrustingFetch,
39
76
  discoverOrSpawn,
40
77
  electronNativeBinCandidates,
78
+ ensureProjectForFolder as ensureClientProjectForFolder,
41
79
  isProcessAlive,
42
80
  readRuntime,
43
81
  readSystemServiceEndpoint,
@@ -503,25 +541,15 @@ function fileTokenStorage(storageKey) {
503
541
  }
504
542
  async function ensureProjectForFolder(client, folderPath) {
505
543
  const wd = resolve(folderPath);
506
- const eq = (a, b) => !!a && (process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b);
507
- const { projects } = await client.listProjects();
508
- const exact = projects.find((p) => eq(p.workingDir, wd));
509
- if (exact) return exact.id;
510
544
  const name = basename(wd) || "workspace";
511
- const orphan = projects.find((p) => !p.workingDir && p.name === name);
512
- if (orphan) {
513
- await client.setProjectWorkingDir(orphan.id, wd);
514
- return orphan.id;
515
- }
516
- const created = await client.createProject({
517
- name,
545
+ const result = await ensureClientProjectForFolder(client, wd, {
546
+ mode: "solo",
547
+ source: "cli",
518
548
  description: `CLI workspace at ${wd}`,
519
549
  about: `${name} \u2014 working directory ${wd}. Fill in who this project is for, what's in scope, and what's explicitly out of scope.`,
520
- missionObjectives: `${name} \u2014 fill in concrete success criteria for this project.`,
521
- mode: "solo",
522
- workingDir: wd
550
+ missionObjectives: `${name} \u2014 fill in concrete success criteria for this project.`
523
551
  });
524
- return created.id;
552
+ return result.projectId;
525
553
  }
526
554
  async function ensureCliProjectLead(client, projectId) {
527
555
  const project = await client.getProject(projectId);
@@ -570,7 +598,8 @@ async function resolveTuiProject(client, globals) {
570
598
  }
571
599
 
572
600
  // src/craftbook-command.ts
573
- import { AwakeBudget } from "@bendyline/gezel";
601
+ import { setTimeout as delay } from "timers/promises";
602
+ import { createAwakeTimeout } from "@bendyline/gezel";
574
603
 
575
604
  // src/tui/craftbook-start.ts
576
605
  import {
@@ -666,37 +695,89 @@ function parseCraftbookParams(book, tokens) {
666
695
  }
667
696
  return params;
668
697
  }
698
+ var READ_RETRY_DELAYS = [250, 750, 1500];
699
+ function transientTaskReadError(error) {
700
+ const codes = /ECONNRESET|ECONNREFUSED|ECONNABORTED|EPIPE|ETIMEDOUT|EHOSTUNREACH|ENETUNREACH|EAI_AGAIN|UND_ERR_(?:SOCKET|CONNECT_TIMEOUT)|NGHTTP2_ENHANCE_YOUR_CALM|Connect Timeout Error|socket hang up|other side closed/;
701
+ if (error instanceof Error && error.name === "GezelApiError") {
702
+ const apiError = error;
703
+ return apiError.status === 0 && apiError.details?.kind === "transport" && apiError.details.readRetryExhausted !== true && typeof apiError.details.cause === "string" && codes.test(apiError.details.cause);
704
+ }
705
+ return error instanceof TypeError && error.cause instanceof Error && codes.test(`${error.cause.code ?? ""} ${error.cause.message}`);
706
+ }
707
+ async function readTaskObservation(read, budget, signal) {
708
+ for (let retries = 0; ; retries++) {
709
+ signal.throwIfAborted();
710
+ if (retries > 0 && budget.expired()) throw new CliError("Task observation timed out.");
711
+ try {
712
+ return await read();
713
+ } catch (error) {
714
+ signal.throwIfAborted();
715
+ if (!transientTaskReadError(error) || retries >= READ_RETRY_DELAYS.length || budget.expired())
716
+ throw error;
717
+ await sleepWithinBudget(READ_RETRY_DELAYS[retries], budget, signal);
718
+ }
719
+ }
720
+ }
721
+ async function sleepWithinBudget(backoffMs, budget, signal) {
722
+ if (budget.remainingMs() > backoffMs) {
723
+ await delay(backoffMs, void 0, { signal });
724
+ return;
725
+ }
726
+ while (!budget.expired()) {
727
+ await delay(Math.max(1, budget.remainingMs()), void 0, { signal });
728
+ }
729
+ }
669
730
  async function waitForTask(client, ref, options) {
670
- const budget = new AwakeBudget(options.timeoutMs);
731
+ const timeout = createAwakeTimeout(options.timeoutMs, { pollMs: 100 });
732
+ const budget = timeout.budget;
733
+ const signal = options.signal ? AbortSignal.any([options.signal, timeout.signal]) : timeout.signal;
671
734
  let previous = "";
672
- for (; ; ) {
673
- const task2 = await client.getTaskByRef(ref);
674
- const progress = `${task2.status}:${task2.activeStepId}`;
675
- if (progress !== previous) {
676
- options.onProgress?.(task2);
677
- previous = progress;
678
- }
679
- if (task2.status === "complete") return { task: task2, outcome: "complete", exitCode: 0 };
680
- if (task2.status === "canceled") return { task: task2, outcome: "canceled", exitCode: 1 };
681
- if (task2.status === "paused" || task2.status === "draft")
682
- return { task: task2, outcome: "blocked", exitCode: 2 };
683
- const refs = /* @__PURE__ */ new Set([task2.ref]);
684
- if (task2.fanout || task2.craftbook.spawn || task2.craftbook.cliWorkflow) {
685
- const { tasks } = await client.listTaskChildren(task2.projectId, task2.num);
686
- if (!task2.craftbook.cliWorkflow && !tasks.some((child) => child.status === "active") && tasks.some((child) => child.status === "paused" || child.status === "canceled"))
735
+ let lastTask;
736
+ const read = (operation) => readTaskObservation(operation, budget, signal);
737
+ try {
738
+ for (; ; ) {
739
+ const task2 = await read(() => client.getTaskByRef(ref, signal));
740
+ lastTask = task2;
741
+ const progress = `${task2.status}:${task2.activeStepId}`;
742
+ if (progress !== previous) {
743
+ options.onProgress?.(task2);
744
+ previous = progress;
745
+ }
746
+ if (task2.status === "complete") return { task: task2, outcome: "complete", exitCode: 0 };
747
+ if (task2.status === "canceled") return { task: task2, outcome: "canceled", exitCode: 1 };
748
+ if (task2.status === "paused" || task2.status === "draft")
687
749
  return { task: task2, outcome: "blocked", exitCode: 2 };
688
- if (!task2.craftbook.cliWorkflow) for (const child of tasks) refs.add(child.ref);
689
- }
690
- if (client.listQuestions) {
691
- const { questions } = await client.listQuestions({
692
- projectId: task2.projectId,
693
- pending: true
694
- });
695
- const questionIds = questions.filter((q) => q.taskRef && refs.has(q.taskRef)).map((q) => q.id);
696
- if (questionIds.length) return { task: task2, outcome: "blocked", exitCode: 2, questionIds };
750
+ const refs = /* @__PURE__ */ new Set([task2.ref]);
751
+ if (task2.fanout || task2.craftbook.spawn || task2.craftbook.cliWorkflow) {
752
+ const { tasks } = await read(
753
+ () => client.listTaskChildren(task2.projectId, task2.num, void 0, signal)
754
+ );
755
+ if (!task2.craftbook.cliWorkflow && !tasks.some((child) => child.status === "active") && tasks.some((child) => child.status === "paused" || child.status === "canceled"))
756
+ return { task: task2, outcome: "blocked", exitCode: 2 };
757
+ if (!task2.craftbook.cliWorkflow) for (const child of tasks) refs.add(child.ref);
758
+ }
759
+ if (client.listQuestions) {
760
+ const { questions } = await read(
761
+ () => client.listQuestions(
762
+ {
763
+ projectId: task2.projectId,
764
+ pending: true
765
+ },
766
+ signal
767
+ )
768
+ );
769
+ const questionIds = questions.filter((q) => q.taskRef && refs.has(q.taskRef)).map((q) => q.id);
770
+ if (questionIds.length) return { task: task2, outcome: "blocked", exitCode: 2, questionIds };
771
+ }
772
+ if (budget.expired()) return { task: task2, outcome: "timeout", exitCode: 3 };
773
+ await delay(Math.min(options.pollMs ?? 1e3, budget.remainingMs()), void 0, { signal });
697
774
  }
698
- if (budget.expired()) return { task: task2, outcome: "timeout", exitCode: 3 };
699
- await new Promise((resolve6) => setTimeout(resolve6, options.pollMs ?? 1e3));
775
+ } catch (error) {
776
+ options.signal?.throwIfAborted();
777
+ if (budget.expired() && lastTask) return { task: lastTask, outcome: "timeout", exitCode: 3 };
778
+ throw error;
779
+ } finally {
780
+ timeout.dispose();
700
781
  }
701
782
  }
702
783
 
@@ -981,6 +1062,11 @@ function formatGb(bytes) {
981
1062
  return (bytes / 1e9).toFixed(2);
982
1063
  }
983
1064
 
1065
+ // src/native-command.ts
1066
+ import {
1067
+ NativeEngineNameSchema
1068
+ } from "@bendyline/gezel";
1069
+
984
1070
  // src/tui/bootstrap.ts
985
1071
  import {
986
1072
  computeModelFit,
@@ -1004,6 +1090,14 @@ function parseNativeVariant(value) {
1004
1090
  if (NATIVE_VARIANTS.includes(value)) return value;
1005
1091
  throw new CliError(`--variant must be one of ${NATIVE_VARIANTS.join(", ")} (got "${value}")`);
1006
1092
  }
1093
+ function parseNativeEngine(value) {
1094
+ if (value === void 0) return void 0;
1095
+ const parsed = NativeEngineNameSchema.safeParse(value);
1096
+ if (parsed.success) return parsed.data;
1097
+ throw new CliError(
1098
+ `--engine must be one of ${NativeEngineNameSchema.options.join(", ")} (got "${value}")`
1099
+ );
1100
+ }
1007
1101
  function formatNativeStatus(status) {
1008
1102
  const installed = new Set(
1009
1103
  status.engines.filter((engine) => engine.installed).map((engine) => engine.name)
@@ -1013,7 +1107,9 @@ function formatNativeStatus(status) {
1013
1107
  `release: native-v${status.release} (${status.pinned ? "verified pin" : "unpinned \u2014 downloads disabled"})`,
1014
1108
  `platform: ${status.platformKey ?? "unsupported \u2014 downloads unavailable"}`,
1015
1109
  `llama backend: ${status.llamaBackend ?? "automatic"}`,
1016
- `toolkit: ${toolkitInstalled}/${NATIVE_TOOLKIT.length} installed`
1110
+ // Name the members: `native list` shows every engine the release carries
1111
+ // (ds4, duckdb too), so a bare "0/4" read as a miscount beside it.
1112
+ `toolkit: ${toolkitInstalled}/${NATIVE_TOOLKIT.length} installed (${NATIVE_TOOLKIT.join(", ")}; see \`gezel native list\` for every engine)`
1017
1113
  ].join("\n");
1018
1114
  }
1019
1115
  function formatNativeList(status) {
@@ -1040,7 +1136,7 @@ async function installNativeToolkit(client, options) {
1040
1136
  );
1041
1137
  }
1042
1138
  const llamaVariant = options.variant ?? status.llamaBackend;
1043
- for (const engine of NATIVE_TOOLKIT) {
1139
+ for (const engine of options.engines ?? NATIVE_TOOLKIT) {
1044
1140
  await ensureOneEngine(client, engine, llamaVariant, options.output);
1045
1141
  }
1046
1142
  return client.getNativeEngineStatus();
@@ -1114,6 +1210,84 @@ function errorMessage(error) {
1114
1210
  return error instanceof Error ? error.message : String(error);
1115
1211
  }
1116
1212
 
1213
+ // src/run-readiness.ts
1214
+ var READY = { ready: true };
1215
+ async function settledFirstRunConfig(client, options = {}) {
1216
+ const attempts = options.attempts ?? 12;
1217
+ const delayMs = options.delayMs ?? 250;
1218
+ let config = await client.getConfig();
1219
+ for (let attempt = 0; attempt < attempts; attempt += 1) {
1220
+ if (config.firstRunCompleted || config.provider !== "copilot") return config;
1221
+ await new Promise((resolve6) => setTimeout(resolve6, delayMs));
1222
+ config = await client.getConfig();
1223
+ }
1224
+ return config;
1225
+ }
1226
+ async function checkRunReadiness(client, gezelId, env2 = process.env) {
1227
+ if (env2.GEZEL_MOCK_PROVIDER === "1") return READY;
1228
+ const config = await settledFirstRunConfig(client);
1229
+ let provider = config.provider;
1230
+ if (gezelId) {
1231
+ try {
1232
+ const { parsed } = await client.getGezel(gezelId);
1233
+ if (parsed.frontmatter.provider) provider = parsed.frontmatter.provider;
1234
+ } catch {
1235
+ }
1236
+ }
1237
+ if (provider !== "llama-cpp" && provider !== "mlx") return READY;
1238
+ if (provider === "llama-cpp" && (config.llamaCppBaseUrl || config.llamaCppModelPath)) {
1239
+ return READY;
1240
+ }
1241
+ if (provider === "mlx" && (config.mlxBaseUrl || config.mlxModelPath)) return READY;
1242
+ const native2 = await client.getNativeEngineStatus();
1243
+ if (!native2.platformKey) return READY;
1244
+ const installed = provider === "mlx" ? await client.listMlxModels() : await client.listLlamaCppModels();
1245
+ const installedIds = installed.models.map((model2) => model2.id);
1246
+ const pinned = config.defaultModel?.[provider];
1247
+ const engineMissing = provider === "llama-cpp" && !native2.engines.some((engine) => engine.name === "llama-server" && engine.installed);
1248
+ const modelReady = pinned ? installedIds.includes(pinned) : installedIds.length > 0;
1249
+ if (!engineMissing && modelReady) return READY;
1250
+ return {
1251
+ ready: false,
1252
+ message: formatRunSetupMessage({
1253
+ provider,
1254
+ engineMissing,
1255
+ pinned,
1256
+ installedIds
1257
+ })
1258
+ };
1259
+ }
1260
+ function formatRunSetupMessage(input) {
1261
+ const { provider, engineMissing, pinned, installedIds } = input;
1262
+ const steps = [];
1263
+ if (engineMissing) steps.push("gezel native install");
1264
+ if (pinned && !installedIds.includes(pinned)) {
1265
+ steps.push(`gezel model pull ${pinned}${provider === "mlx" ? " --provider mlx" : ""}`);
1266
+ } else if (!pinned && installedIds.length === 0) {
1267
+ steps.push("gezel model list (then: gezel model pull <id>)");
1268
+ }
1269
+ const lines = [];
1270
+ if (pinned && !installedIds.includes(pinned) && installedIds.length > 0) {
1271
+ lines.push(`Your selected on-device model, ${pinned}, isn't downloaded yet.`);
1272
+ } else if (engineMissing && installedIds.length > 0 && (!pinned || installedIds.includes(pinned))) {
1273
+ lines.push("Gezel's on-device engine isn't installed yet.");
1274
+ } else {
1275
+ lines.push("Gezel isn't set up to chat yet: this device doesn't have an on-device model.");
1276
+ }
1277
+ lines.push("", "Run `gezel` to choose a model and download it, step by step.");
1278
+ if (steps.length > 0) {
1279
+ lines.push("", "Or set it up directly:", ...steps.map((step) => ` ${step}`));
1280
+ }
1281
+ lines.push(
1282
+ "",
1283
+ "To use a cloud model instead, save a key (for example",
1284
+ "`gezel secret set openaiApiKey --stdin`), then run `gezel` and pick it with /model.",
1285
+ "",
1286
+ "Nothing was downloaded."
1287
+ );
1288
+ return lines.join("\n");
1289
+ }
1290
+
1117
1291
  // src/secrets-command.ts
1118
1292
  import { GezelApiError as GezelApiError2 } from "@bendyline/gezel-client";
1119
1293
  var credentialFlags = {
@@ -1187,14 +1361,15 @@ function registerSecretCommands(program2, connect, output = console.log) {
1187
1361
  options.json ? JSON.stringify({ credentials }) : credentials.map((c) => `${c.name} ${c.configured ? "configured" : "not configured"}`).join("\n")
1188
1362
  );
1189
1363
  });
1190
- secret.command("set <name>").description("Save a provider credential in the service credential store").option("--env <VARIABLE>", "Read the value from this environment variable").option("--stdin", "Read the value from piped stdin").option(
1191
- "--use-for-search",
1192
- "Also select this Brave or Tavily credential as the web search provider"
1193
- ).option("--json", "Output status as JSON without the value").action(async (name, options) => {
1364
+ secret.command("set <name>").description("Save a provider credential in the service credential store").option("--env <VARIABLE>", "Read the value from this environment variable").option("--stdin", "Read the value from piped stdin").option("--use-for-search", "Also select this Brave credential as the web search provider").option("--json", "Output status as JSON without the value").action(async (name, options) => {
1194
1365
  const key = credentialName(name);
1195
- const provider = key === "braveSearchApiKey" ? "brave" : key === "tavilyApiKey" ? "tavily" : void 0;
1366
+ if (options.useForSearch && key === "tavilyApiKey")
1367
+ throw new CliError(
1368
+ "Tavily search is not available yet. Save the key without --use-for-search, and use braveSearchApiKey (or the built-in Wikipedia search) for now."
1369
+ );
1370
+ const provider = key === "braveSearchApiKey" ? "brave" : void 0;
1196
1371
  if (options.useForSearch && !provider)
1197
- throw new CliError("--use-for-search requires braveSearchApiKey or tavilyApiKey.");
1372
+ throw new CliError("--use-for-search requires braveSearchApiKey.");
1198
1373
  const value = await readSecretInput(options);
1199
1374
  const client = await connect();
1200
1375
  const patch = { [key]: value };
@@ -1459,6 +1634,51 @@ function resolveRestoreSelection(review, opts) {
1459
1634
  return { items, skipped };
1460
1635
  }
1461
1636
 
1637
+ // src/unknown-command.ts
1638
+ function unknownCommandMessage(operands, known) {
1639
+ const word = operands[0] ?? "";
1640
+ const lines = [`error: unknown command '${word}'`];
1641
+ const looksLikePrompt = operands.length > 1 || /\s/.test(word) || word.length > 24;
1642
+ const suggestion = looksLikePrompt ? void 0 : closestCommand(word, known);
1643
+ if (suggestion) lines.push(`(Did you mean ${suggestion}?)`);
1644
+ if (looksLikePrompt) {
1645
+ lines.push('To send a prompt, use: gezel run "<prompt>"');
1646
+ }
1647
+ lines.push("Run `gezel --help` to see every command.");
1648
+ return lines.join("\n");
1649
+ }
1650
+ function closestCommand(word, known) {
1651
+ const target = word.toLowerCase();
1652
+ if (!target) return void 0;
1653
+ const limit = Math.max(1, Math.floor(target.length * 0.4));
1654
+ let best;
1655
+ for (const name of known) {
1656
+ const distance = editDistance(target, name.toLowerCase());
1657
+ if (distance > limit) continue;
1658
+ if (!best || distance < best.distance) best = { name, distance };
1659
+ }
1660
+ return best?.name;
1661
+ }
1662
+ function editDistance(a, b) {
1663
+ const rows = a.length + 1;
1664
+ const cols = b.length + 1;
1665
+ const d = Array.from(
1666
+ { length: rows },
1667
+ (_, i) => Array.from({ length: cols }, (_2, j) => i === 0 ? j : j === 0 ? i : 0)
1668
+ );
1669
+ for (let i = 1; i < rows; i += 1) {
1670
+ for (let j = 1; j < cols; j += 1) {
1671
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
1672
+ let value = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
1673
+ if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
1674
+ value = Math.min(value, d[i - 2][j - 2] + 1);
1675
+ }
1676
+ d[i][j] = value;
1677
+ }
1678
+ }
1679
+ return d[a.length][b.length];
1680
+ }
1681
+
1462
1682
  // src/workflow-command.ts
1463
1683
  import { realpath } from "fs/promises";
1464
1684
  import { isAbsolute as isAbsolute2, relative, resolve as resolve5 } from "path";
@@ -1530,12 +1750,12 @@ async function runWorkflow(client, projectId, workspace, file, args, log = conso
1530
1750
 
1531
1751
  // src/bin/gezel.ts
1532
1752
  var program = new Command();
1533
- program.name("gezel").description("Gezel \u2014 build a community of agents that do things.").version(GEZEL_VERSION).option(
1753
+ program.name("gezel").description("Gezel \u2014 assemble a team of AI companions (gezels) and put them to work.").version(GEZEL_VERSION).option(
1534
1754
  "--connect <url>",
1535
1755
  "Connect to this Gezel service (first use asks for approval in the Gezel app)."
1536
- ).option("--token <token>", "Bearer token for --connect (must have CLI access).").option(
1756
+ ).option("--token <token>", "Bearer token for --connect (must have CLI access).").option("--http1", "Use HTTP/1.1 for daemon requests, keeping TLS certificate validation.").option(
1537
1757
  "--standalone",
1538
- "Skip legacy full-product machine-service compatibility and use the per-user daemon."
1758
+ "Always use your own per-user Gezel service, even if an older machine-wide install is present."
1539
1759
  ).option("--home <dir>", "Use this user-owned Gezel home (default: $GEZEL_HOME or ~/.gezel).").option(
1540
1760
  "--project [folder]",
1541
1761
  "Use this folder as the active project (default and bare flag: cwd)."
@@ -1546,9 +1766,23 @@ registerSecurityCommands(program, () => connectOwned(cliGlobals()));
1546
1766
  program.hook("preAction", () => {
1547
1767
  const globals = cliGlobals();
1548
1768
  validateGlobals(globals);
1769
+ if (globals.http1) process.env.GEZEL_HTTP_VERSION = "1.1";
1549
1770
  applyHome(globals);
1550
1771
  });
1551
1772
  program.action(async () => {
1773
+ if (program.args.length > 0) {
1774
+ const known = program.commands.flatMap((command) => [command.name(), ...command.aliases()]);
1775
+ throw new CliError(unknownCommandMessage(program.args, known));
1776
+ }
1777
+ if (!process.stdin.isTTY || !process.stdout.isTTY) {
1778
+ throw new CliError(
1779
+ [
1780
+ "The interactive Gezel terminal needs a terminal window, and this one is not interactive.",
1781
+ 'For a one-shot reply, use: gezel run "<prompt>"',
1782
+ "Run `gezel --help` to see every command."
1783
+ ].join("\n")
1784
+ );
1785
+ }
1552
1786
  const globals = cliGlobals();
1553
1787
  resolveDevHome(globals);
1554
1788
  const connection = await connectForTui(globals);
@@ -1696,7 +1930,7 @@ async function startForeground(env2) {
1696
1930
  process.off("SIGTERM", requestStop);
1697
1931
  }
1698
1932
  }
1699
- program.command("status").description("Show daemon status").action(async () => {
1933
+ program.command("status").description("Show daemon status (exits 1 when gezeld is not running or not healthy)").action(async () => {
1700
1934
  const globals = cliGlobals();
1701
1935
  if (globals.connect) {
1702
1936
  const client2 = await connectOwned(globals);
@@ -1732,11 +1966,16 @@ program.command("status").description("Show daemon status").action(async () => {
1732
1966
  const runtime = await readRuntime2();
1733
1967
  if (!runtime) {
1734
1968
  console.log("gezeld is not running");
1969
+ process.exitCode = 1;
1735
1970
  return;
1736
1971
  }
1737
1972
  const alive = isProcessAlive2(runtime.pid);
1973
+ if (!alive) {
1974
+ console.log(`gezeld is not running (stale runtime record for pid ${runtime.pid})`);
1975
+ process.exitCode = 1;
1976
+ return;
1977
+ }
1738
1978
  console.log(`gezeld pid=${runtime.pid} port=${runtime.port} alive=${alive}`);
1739
- if (!alive) return;
1740
1979
  const client = new GezelClient2({
1741
1980
  baseUrl: runtime.baseUrl,
1742
1981
  // Health is intentionally unauthenticated; diagnostics do not need to
@@ -1752,17 +1991,21 @@ program.command("status").description("Show daemon status").action(async () => {
1752
1991
  );
1753
1992
  } catch (err) {
1754
1993
  console.error(`health failed: ${err.message}`);
1994
+ process.exitCode = 1;
1755
1995
  }
1756
1996
  });
1757
- program.command("stop").description("Hard stop all AI work and switch Gezel to Reactive mode").option("--daemon", "Shut down the user-owned daemon process itself").action(async (opts) => {
1997
+ program.command("stop").description(
1998
+ "Hard stop all AI work and switch Gezel to Reactive mode; gezeld keeps running (use --daemon to shut it down)"
1999
+ ).option("--daemon", "Shut down the user-owned daemon process itself").action(async (opts) => {
1758
2000
  const globals = cliGlobals();
1759
2001
  if (opts.daemon) {
1760
2002
  await stopUserDaemon(globals);
1761
2003
  return;
1762
2004
  }
2005
+ let userRuntime = null;
1763
2006
  if (!globals.connect && !await findHealthySystemService(globals)) {
1764
- const runtime = await readRuntime2();
1765
- if (!runtime || !isProcessAlive2(runtime.pid)) {
2007
+ userRuntime = await readRuntime2();
2008
+ if (!userRuntime || !isProcessAlive2(userRuntime.pid)) {
1766
2009
  console.log("Gezel has no running AI work to stop.");
1767
2010
  return;
1768
2011
  }
@@ -1777,7 +2020,32 @@ program.command("stop").description("Hard stop all AI work and switch Gezel to R
1777
2020
  console.log(
1778
2021
  `Hard stop complete: ${details.join(", ")}. Local engines unloaded; Gezel is Reactive.`
1779
2022
  );
2023
+ if (userRuntime) {
2024
+ console.log(
2025
+ `gezeld is still running (pid ${userRuntime.pid}); run \`gezel stop --daemon\` to shut it down.`
2026
+ );
2027
+ }
1780
2028
  });
2029
+ async function clearStaleRuntime(stoppedPid) {
2030
+ const { readFile: readFile3, rm: rm3 } = await import("fs/promises");
2031
+ const { gezelPaths: gezelPaths2 } = await import("@bendyline/gezel/paths");
2032
+ const runtime = gezelPaths2().runtime;
2033
+ const recorded = Number.parseInt(
2034
+ (await readFile3(runtime.pid, "utf8").catch(() => "")).trim(),
2035
+ 10
2036
+ );
2037
+ if (recorded !== stoppedPid || isProcessAlive2(stoppedPid)) return;
2038
+ await Promise.all(
2039
+ [
2040
+ runtime.pid,
2041
+ runtime.port,
2042
+ runtime.token,
2043
+ runtime.cert,
2044
+ runtime.fingerprint,
2045
+ runtime.webUiToken
2046
+ ].map((path) => rm3(path, { force: true }))
2047
+ );
2048
+ }
1781
2049
  async function stopUserDaemon(globals) {
1782
2050
  if (globals.connect) {
1783
2051
  throw new CliError("gezel stop --daemon cannot stop an explicit remote service.");
@@ -1796,6 +2064,7 @@ async function stopUserDaemon(globals) {
1796
2064
  }
1797
2065
  const stopped = await stopProcessByPid(runtime.pid);
1798
2066
  if (stopped) {
2067
+ await clearStaleRuntime(runtime.pid);
1799
2068
  console.log(`stopped gezeld pid=${runtime.pid}`);
1800
2069
  } else {
1801
2070
  console.error(`failed to confirm gezeld pid=${runtime.pid} stopped`);
@@ -1829,6 +2098,8 @@ program.command("run [prompt...]").description("Run a prompt through a gezel and
1829
2098
  }
1830
2099
  const previousLogOutput = getLogOutput();
1831
2100
  setLogOutput("stderr");
2101
+ const previousLogLevel = getLogLevel();
2102
+ if (!process.env.GEZEL_LOG_LEVEL && previousLogLevel === "info") setLogLevel("warn");
1832
2103
  let conn;
1833
2104
  let removeSignalCleanup;
1834
2105
  try {
@@ -1843,6 +2114,12 @@ program.command("run [prompt...]").description("Run a prompt through a gezel and
1843
2114
  const { client } = conn;
1844
2115
  const projectId = await resolveRunProject(client, cliGlobals());
1845
2116
  const gezelId = opts.gezel ?? await ensureCliProjectLead(client, projectId);
2117
+ const readiness = await checkRunReadiness(client, gezelId);
2118
+ if (!readiness.ready) {
2119
+ console.error(readiness.message);
2120
+ process.exitCode = 1;
2121
+ return;
2122
+ }
1846
2123
  const session = await client.createChatSession({ gezelId, projectId });
1847
2124
  await client.sendToChatSession(session.id, prompt);
1848
2125
  let printed = false;
@@ -1874,6 +2151,7 @@ ${ev.error}`);
1874
2151
  if (conn?.stop) await conn.stop();
1875
2152
  } finally {
1876
2153
  setLogOutput(previousLogOutput);
2154
+ setLogLevel(previousLogLevel);
1877
2155
  }
1878
2156
  }
1879
2157
  });
@@ -1978,7 +2256,7 @@ async function printTaskWait(client, ref, opts) {
1978
2256
  console.log(opts.json ? JSON.stringify(result) : `${result.task.ref}: ${result.outcome}`);
1979
2257
  process.exitCode = result.exitCode;
1980
2258
  }
1981
- var agent = program.command("agent").description("Manage agents");
2259
+ var agent = program.command("agent").description("Manage your gezels (your AI companions)");
1982
2260
  agent.command("output-limit <id> [tokens]").description(
1983
2261
  "Show or set one gezel's output-token limit, including reasoning; auto clears its override"
1984
2262
  ).option("--json", "Output the per-gezel override as JSON").action(async (id, tokens, opts) => {
@@ -2001,24 +2279,26 @@ agent.command("output-limit <id> [tokens]").description(
2001
2279
  opts.json ? JSON.stringify(result) : `${id}: ${result.outputTokens === null ? "auto (inherits model/profile defaults)" : `${result.outputTokens} output tokens, including reasoning`}`
2002
2280
  );
2003
2281
  });
2004
- agent.command("list").description("List agents").action(async () => {
2282
+ agent.command("list").description("List your gezels").action(async () => {
2005
2283
  const client = await connectOwned(cliGlobals());
2006
2284
  const res = await client.listGezels();
2007
2285
  for (const a of res.gezels) {
2008
2286
  console.log(`${a.id.padEnd(20)} ${a.name}`);
2009
2287
  }
2010
2288
  });
2011
- agent.command("create <name>").description("Create a new agent").option("-d, --description <text>", "description").option("-m, --model <model>", "model identifier").action(async (name, opts) => {
2289
+ agent.command("create <name>").description("Create a new gezel").option("-d, --description <text>", "description").option("-m, --model <model>", "model identifier").action(async (name, opts) => {
2012
2290
  const client = await connectOwned(cliGlobals());
2013
2291
  const created = await client.createGezel({ name, ...opts });
2014
- console.log(`created agent ${created.id}`);
2292
+ console.log(`created gezel ${created.id}`);
2015
2293
  });
2016
- agent.command("show <id>").description("Show an agent").action(async (id) => {
2294
+ agent.command("show <id>").description("Show one gezel").action(async (id) => {
2017
2295
  const client = await connectOwned(cliGlobals());
2018
- const a = await client.getGezel(id);
2296
+ const a = await client.getGezel(id).catch((err) => {
2297
+ throw isNotFound(err) ? new CliError(`No gezel with id "${id}". Run \`gezel agent list\` to see your gezels.`) : err;
2298
+ });
2019
2299
  console.log(a.parsed.source);
2020
2300
  });
2021
- var env = program.command("env").description("Manage projects");
2301
+ var env = program.command("env").alias("project").description("Manage projects (also available as `gezel project`)");
2022
2302
  registerProjectSettingsCommands(
2023
2303
  env,
2024
2304
  () => connectOwned(cliGlobals()),
@@ -2457,7 +2737,9 @@ task.command("create <projectId> <title>").description("Create a task with a sin
2457
2737
  );
2458
2738
  task.command("show <ref>").description("Show one task (format: projectId/num)").action(async (ref) => {
2459
2739
  const client = await connectOwned(cliGlobals());
2460
- const t = await client.getTaskByRef(ref);
2740
+ const t = await client.getTaskByRef(ref).catch((err) => {
2741
+ throw isNotFound(err) ? new CliError(`No task "${ref}". Run \`gezel task list\` to see task references.`) : err;
2742
+ });
2461
2743
  console.log(JSON.stringify(t, null, 2));
2462
2744
  });
2463
2745
  task.command("notes <ref>").description("Read task notes, including pause reasons and failed checks").option("--warnings", "Also include model/runtime warnings from the latest 20 task sessions").option("--json", "Output the notes as JSON").action(async (ref, opts) => {
@@ -2590,15 +2872,21 @@ program.command("create-audio [text...]").description("Synthesize speech from te
2590
2872
  );
2591
2873
  });
2592
2874
  var native = program.command("native").description("Manage native engine binaries");
2593
- native.command("install").description("Download, verify, and activate the native inference toolkit").option("--variant <backend>", "llama.cpp backend: cuda | vulkan | metal | cpu").action(async (opts) => {
2875
+ native.command("install").description(
2876
+ "Download, verify, and activate the native inference toolkit (or one engine with --engine)"
2877
+ ).option("--variant <backend>", "llama.cpp backend: cuda | vulkan | metal | cpu").option("--engine <name>", "install only this engine, e.g. duckdb or llama-server").action(async (opts) => {
2594
2878
  const variant = parseNativeVariant(opts.variant);
2879
+ const engine = parseNativeEngine(opts.engine);
2595
2880
  const client = await connectOwned(cliGlobals());
2596
2881
  const installed = await installNativeToolkit(client, {
2597
2882
  ...variant ? { variant } : {},
2883
+ ...engine ? { engines: [engine] } : {},
2598
2884
  output: { writeProgress: (text) => process.stderr.write(text) }
2599
2885
  });
2600
- console.log(`native toolkit ready
2601
- ${formatNativeStatus(installed)}`);
2886
+ console.log(
2887
+ `${engine ? `${engine} ready` : "native toolkit ready"}
2888
+ ${formatNativeStatus(installed)}`
2889
+ );
2602
2890
  });
2603
2891
  native.command("list").description("List native executables and their install state").action(async () => {
2604
2892
  const client = await connectOwned(cliGlobals());
@@ -2889,7 +3177,10 @@ Wrote ${outPath}`);
2889
3177
  program.command("restore <file>").description("Restore gezels, projects, and documents from a backup file").option("--list", "Show what the backup holds without restoring anything").option(
2890
3178
  "--only <item...>",
2891
3179
  "Restore just these items, by id (repeatable, e.g. --only tamsin roof-survey)"
2892
- ).option("--replace", "Overwrite items that already exist here").option("--settings", "Also restore preferences from the backup").action(
3180
+ ).option("--replace", "Overwrite items that already exist here").option(
3181
+ "--settings",
3182
+ "Also restore which gezels hold roles such as the meester (never providers, folders or security)"
3183
+ ).action(
2893
3184
  async (file, opts) => {
2894
3185
  const client = await connectOwned(cliGlobals());
2895
3186
  const review = await client.scanRestore({ path: resolvePath(file) });
@@ -2949,9 +3240,11 @@ async function pollStorageJob(client, jobId) {
2949
3240
  await new Promise((r) => setTimeout(r, 250));
2950
3241
  }
2951
3242
  }
3243
+ program.allowExcessArguments();
2952
3244
  program.parseAsync(process.argv).catch((err) => {
2953
- if (err instanceof CliError || err instanceof Error && err.name === "CliError") {
2954
- console.error(err.message);
3245
+ const friendly = formatCliFailure(err);
3246
+ if (friendly !== null) {
3247
+ console.error(friendly);
2955
3248
  } else {
2956
3249
  console.error(err);
2957
3250
  }
@@ -442,6 +442,7 @@ body.hb {
442
442
  .hb-article .hb-scorecard-suite-title { font-size: 0.95rem; margin: 1.25rem 0 0.5rem; }
443
443
  .hb-scorecard-stamp { font-size: 0.85rem; margin: 0 0 0.75rem; }
444
444
  .hb-article .hb-scorecard-withheld,
445
+ .hb-article .hb-scorecard-memory-note,
445
446
  .hb-article .hb-scorecard-taskcount {
446
447
  font-size: 0.82rem;
447
448
  color: var(--hb-ink-muted);
@@ -42,6 +42,7 @@ import {
42
42
  createTrustingFetch,
43
43
  discoverOrSpawn,
44
44
  electronNativeBinCandidates,
45
+ ensureProjectForFolder as ensureClientProjectForFolder,
45
46
  isProcessAlive,
46
47
  readRuntime,
47
48
  readSystemServiceEndpoint,
package/dist/tui/index.js CHANGED
@@ -28,6 +28,7 @@ import {
28
28
  createTrustingFetch,
29
29
  discoverOrSpawn,
30
30
  electronNativeBinCandidates,
31
+ ensureProjectForFolder as ensureClientProjectForFolder,
31
32
  isProcessAlive,
32
33
  readRuntime,
33
34
  readSystemServiceEndpoint,
@@ -2649,6 +2650,7 @@ var PROVIDER_ORDER = [
2649
2650
  "mlx",
2650
2651
  "llama-cpp",
2651
2652
  "ds4",
2653
+ "apple-foundation-models",
2652
2654
  "ollama",
2653
2655
  "copilot",
2654
2656
  "openai",
@@ -2672,6 +2674,10 @@ function modelProviderLabel(provider) {
2672
2674
  return "Ollama";
2673
2675
  case "llama-cpp":
2674
2676
  return "llama.cpp";
2677
+ case "apple-foundation-models":
2678
+ return "Apple Intelligence";
2679
+ case "android-mlkit":
2680
+ return "Android system AI";
2675
2681
  case "mlx":
2676
2682
  return "MLX";
2677
2683
  case "ds4":
@@ -2687,6 +2693,7 @@ function configuredModelProviders(config, opts) {
2687
2693
  const ds4PlatformAvailable = Boolean(config.ds4BaseUrl) || opts.platform === "linux" || opts.platform === "darwin" && opts.arch === "arm64";
2688
2694
  const ds4MemoryAvailable = Boolean(config.ds4BaseUrl) || opts.totalRamBytes === null || opts.totalRamBytes >= 45 * 1024 ** 3;
2689
2695
  if (ds4PlatformAvailable && ds4MemoryAvailable) providers.push("ds4");
2696
+ if (config.appleFoundationModelsStatus?.installed) providers.push("apple-foundation-models");
2690
2697
  providers.push("ollama");
2691
2698
  if (opts.copilotAvailable !== false) providers.push("copilot");
2692
2699
  if (config.hasOpenaiApiKey) providers.push("openai");
@@ -4657,6 +4664,21 @@ function formatTaskDetails(task, gezels, boring) {
4657
4664
  import { formatModelAttribution as formatModelAttribution3 } from "@bendyline/gezel";
4658
4665
  import { Box as Box7, Text as Text7, useApp as useApp2, useInput as useInput5 } from "ink";
4659
4666
  import { useCallback as useCallback3, useEffect as useEffect5, useState as useState6 } from "react";
4667
+
4668
+ // src/run-readiness.ts
4669
+ async function settledFirstRunConfig(client, options = {}) {
4670
+ const attempts = options.attempts ?? 12;
4671
+ const delayMs = options.delayMs ?? 250;
4672
+ let config = await client.getConfig();
4673
+ for (let attempt = 0; attempt < attempts; attempt += 1) {
4674
+ if (config.firstRunCompleted || config.provider !== "copilot") return config;
4675
+ await new Promise((resolve2) => setTimeout(resolve2, delayMs));
4676
+ config = await client.getConfig();
4677
+ }
4678
+ return config;
4679
+ }
4680
+
4681
+ // src/tui/components/BootstrapGate.tsx
4660
4682
  import { Fragment as Fragment4, jsx as jsx6, jsxs as jsxs7 } from "react/jsx-runtime";
4661
4683
  var MAX_ALTERNATIVE_MODELS = 6;
4662
4684
  function BootstrapGate(props) {
@@ -5129,15 +5151,6 @@ function ProgressBar({ pct }) {
5129
5151
  "]"
5130
5152
  ] });
5131
5153
  }
5132
- async function settledFirstRunConfig(client) {
5133
- let config = await client.getConfig();
5134
- for (let attempt = 0; attempt < 12; attempt += 1) {
5135
- if (config.firstRunCompleted || config.provider !== "copilot") return config;
5136
- await delay(250);
5137
- config = await client.getConfig();
5138
- }
5139
- return config;
5140
- }
5141
5154
  async function installNativeToolkit(client, status, missing, setScreen) {
5142
5155
  for (let index = 0; index < missing.length; index += 1) {
5143
5156
  const engine = missing[index];
@@ -5286,9 +5299,6 @@ function fitLabel(fit) {
5286
5299
  function errorMessage(error) {
5287
5300
  return error instanceof Error ? error.message : String(error);
5288
5301
  }
5289
- function delay(ms) {
5290
- return new Promise((resolve2) => setTimeout(resolve2, ms));
5291
- }
5292
5302
 
5293
5303
  // src/tui/memory-diagnostics.ts
5294
5304
  import { appendFile, mkdir as mkdir2 } from "fs/promises";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bendyline/gezel-cli",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
4
4
  "description": "The `gezel` command-line tool.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -44,15 +44,15 @@
44
44
  "!dist/**/*.map"
45
45
  ],
46
46
  "dependencies": {
47
- "@bendyline/gezel": "1.1.2",
48
- "@bendyline/gezel-app-sdk": "1.0.10",
49
- "@bendyline/gezel-catalog": "1.1.2",
50
- "@bendyline/gezel-client": "1.1.2",
51
- "@bendyline/gezel-knowledge": "1.1.2",
52
- "@bendyline/gezel-service": "1.1.2",
53
- "@bendyline/squisq": "2.11.5",
54
- "@bendyline/squisq-formats": "2.6.5",
55
- "@bendyline/squisq-react": "2.11.5",
47
+ "@bendyline/gezel": "1.2.0",
48
+ "@bendyline/gezel-app-sdk": "1.1.0",
49
+ "@bendyline/gezel-catalog": "1.2.0",
50
+ "@bendyline/gezel-client": "1.2.0",
51
+ "@bendyline/gezel-knowledge": "1.2.0",
52
+ "@bendyline/gezel-service": "1.2.0",
53
+ "@bendyline/squisq": "2.11.11",
54
+ "@bendyline/squisq-formats": "2.6.11",
55
+ "@bendyline/squisq-react": "2.11.13",
56
56
  "commander": "^15.0.0",
57
57
  "ink": "^7.1.1",
58
58
  "ink-text-input": "^6.0.0",