@bendyline/gezel-cli 1.2.8 → 1.2.10

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
@@ -57,7 +57,7 @@ Run `gezel --help`, or `--help` on any command, for every option.
57
57
  | Command | What it does |
58
58
  |---|---|
59
59
  | `gezel` | Open the interactive terminal app for this folder's project |
60
- | `gezel run [prompt…]` | One prompt, one reply, using this project's voorman unless you pass `--gezel <id>`. A sole `-` reads the prompt from stdin |
60
+ | `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 |
61
61
  | `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 |
62
62
  | `gezel <craftbook> …` | Shorthand for `gezel do <craftbook> …`, matched exactly on the craftbook's command name; built-in commands always win |
63
63
  | `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 |
@@ -478,6 +478,7 @@ import {
478
478
  gezelNamesInUse,
479
479
  pickUnusedGezelName,
480
480
  projectLeadGezelId,
481
+ roleForMatching,
481
482
  setLogLevel,
482
483
  setLogOutput
483
484
  } from "@bendyline/gezel";
@@ -17,6 +17,7 @@ import {
17
17
  gezelNamesInUse,
18
18
  pickUnusedGezelName,
19
19
  projectLeadGezelId,
20
+ roleForMatching,
20
21
  setLogLevel,
21
22
  setLogOutput
22
23
  } from "@bendyline/gezel";
@@ -325,7 +326,7 @@ function parseParamFlags(flags) {
325
326
  }
326
327
  function printPlan(plan) {
327
328
  const roles = plan.gezels.map(
328
- (gezel) => `${gezel.templateId}${gezel.voorman ? " (voorman" : " ("}${gezel.reuse ? ", reused)" : gezel.voorman ? ", new)" : "new)"}`
329
+ (gezel) => `${gezel.templateId}${gezel.voorman ? " (crew lead" : " ("}${gezel.reuse ? ", reused)" : gezel.voorman ? ", new)" : "new)"}`
329
330
  );
330
331
  if (roles.length > 0) console.log(` roles: ${roles.join(", ")}`);
331
332
  if (plan.scripts.length > 0) console.log(` scripts: ${plan.scripts.join(", ")}`);
@@ -71,6 +71,7 @@ import {
71
71
  gezelNamesInUse,
72
72
  pickUnusedGezelName,
73
73
  projectLeadGezelId,
74
+ roleForMatching,
74
75
  setLogLevel,
75
76
  setLogOutput
76
77
  } from "@bendyline/gezel";
@@ -735,7 +736,7 @@ async function ensureCliProjectLead(client, projectId) {
735
736
  }
736
737
  const { gezels } = await client.listGezels();
737
738
  let voorman = gezels.find(
738
- (gezel) => gezel.templateId === "voorman" || gezel.role?.trim().toLowerCase() === "voorman"
739
+ (gezel) => gezel.templateId === "voorman" || roleForMatching(gezel.role)?.trim().toLowerCase() === "voorman"
739
740
  );
740
741
  if (!voorman) {
741
742
  const { name, gender } = pickUnusedGezelName(gezelNamesInUse(gezels));
@@ -743,7 +744,7 @@ async function ensureCliProjectLead(client, projectId) {
743
744
  }
744
745
  const updated = await client.updateProject(projectId, { voormanGezelId: voorman.id });
745
746
  if (!updated.voormanGezelId) {
746
- throw new CliError(`project "${updated.name}" has no voorman`);
747
+ throw new CliError(`project "${updated.name}" has no crew lead`);
747
748
  }
748
749
  return updated.voormanGezelId;
749
750
  }
@@ -966,7 +967,8 @@ async function waitForTask(client, ref, options) {
966
967
  () => client.listQuestions(
967
968
  {
968
969
  projectId: task2.projectId,
969
- pending: true
970
+ pending: true,
971
+ taskRefs: [...refs]
970
972
  },
971
973
  signal
972
974
  )
@@ -1340,7 +1342,8 @@ function errorMessage(error) {
1340
1342
  // src/settings-command.ts
1341
1343
  import {
1342
1344
  classifySecurityLevel,
1343
- resolveSecurityPolicy
1345
+ resolveSecurityPolicy,
1346
+ securityCapabilitiesOf
1344
1347
  } from "@bendyline/gezel";
1345
1348
  var SECURITY_LEVEL_LABELS = {
1346
1349
  "super-lockdown": "Super Lockdown",
@@ -1348,17 +1351,33 @@ var SECURITY_LEVEL_LABELS = {
1348
1351
  free: "Unrestricted",
1349
1352
  custom: "Custom"
1350
1353
  };
1351
- function policyWithExternalServices(config, enabled) {
1352
- const current = resolveSecurityPolicy(config);
1353
- const caps = {
1354
- allowFileEdits: current.allowFileEdits,
1355
- allowExternalChat: current.allowExternalChat,
1356
- allowExternalServices: enabled,
1357
- allowScriptExecution: current.allowScriptExecution,
1358
- allowAppNetwork: current.allowAppNetwork
1359
- };
1354
+ function policyWithCapability(config, key, enabled) {
1355
+ const caps = { ...securityCapabilitiesOf(resolveSecurityPolicy(config)), [key]: enabled };
1360
1356
  return { level: classifySecurityLevel(caps), ...caps };
1361
1357
  }
1358
+ function policyWithExternalServices(config, enabled) {
1359
+ return policyWithCapability(config, "allowExternalServices", enabled);
1360
+ }
1361
+ var SECURITY_SWITCHES = [
1362
+ {
1363
+ command: "external-services",
1364
+ key: "allowExternalServices",
1365
+ label: "External services",
1366
+ description: "Show or set on/off for model-initiated external services, including web search"
1367
+ },
1368
+ {
1369
+ command: "run-package-scripts",
1370
+ key: "allowPackageScriptExecution",
1371
+ label: "Run package scripts",
1372
+ description: "Show or set on/off for gezels running package scripts and installed package binaries (outside the sandbox, with network access)"
1373
+ },
1374
+ {
1375
+ command: "edit-package-scripts",
1376
+ key: "allowPackageScriptEdits",
1377
+ label: "Edit package scripts",
1378
+ description: "Show or set on/off for gezels adding or changing the scripts in package.json"
1379
+ }
1380
+ ];
1362
1381
  function enabledValue(state) {
1363
1382
  if (state === void 0) return void 0;
1364
1383
  if (state === "on") return true;
@@ -1366,19 +1385,24 @@ function enabledValue(state) {
1366
1385
  throw new CliError("Use on or off.");
1367
1386
  }
1368
1387
  function registerSecurityCommands(program2, connect) {
1369
- program2.command("security").description("Inspect or explicitly change security settings").command("external-services [state]").description("Show or set on/off for model-initiated external services, including web search").option("--json", "Output the setting as JSON").action(async (state, options) => {
1370
- const enabled = enabledValue(state);
1371
- const client = await connect();
1372
- const config = await client.getConfig();
1373
- const policy = resolveSecurityPolicy(config);
1374
- if (enabled !== void 0) {
1375
- await client.updateConfig({ securityPolicy: policyWithExternalServices(config, enabled) });
1376
- }
1377
- const result = { allowExternalServices: enabled ?? policy.allowExternalServices };
1378
- console.log(
1379
- options.json ? JSON.stringify(result) : `External services: ${result.allowExternalServices ? "on" : "off"}`
1380
- );
1381
- });
1388
+ const security = program2.command("security").description("Inspect or explicitly change security settings");
1389
+ for (const setting of SECURITY_SWITCHES) {
1390
+ security.command(`${setting.command} [state]`).description(setting.description).option("--json", "Output the setting as JSON").action(async (state, options) => {
1391
+ const enabled = enabledValue(state);
1392
+ const client = await connect();
1393
+ const config = await client.getConfig();
1394
+ const policy = resolveSecurityPolicy(config);
1395
+ if (enabled !== void 0) {
1396
+ await client.updateConfig({
1397
+ securityPolicy: policyWithCapability(config, setting.key, enabled)
1398
+ });
1399
+ }
1400
+ const value = enabled ?? policy[setting.key];
1401
+ console.log(
1402
+ options.json ? JSON.stringify({ [setting.key]: value }) : `${setting.label}: ${value ? "on" : "off"}`
1403
+ );
1404
+ });
1405
+ }
1382
1406
  }
1383
1407
  function registerProjectSettingsCommands(env2, connect, projectFor) {
1384
1408
  env2.command("indexing [state]").description("Show or set on/off for background workspace indexing in the current project").option("--json", "Output the project setting as JSON").action(async (state, options) => {
@@ -1403,7 +1427,8 @@ var ENGINE_BINARY = {
1403
1427
  };
1404
1428
  async function ensureCraftbookSetup(client, options) {
1405
1429
  const services = options.needs.services ?? [];
1406
- if (!options.needs.models?.length && services.length === 0) return;
1430
+ const commands = options.needs.commands ?? [];
1431
+ if (!options.needs.models?.length && services.length === 0 && commands.length === 0) return;
1407
1432
  const config = await client.getConfig();
1408
1433
  const models = resolveCraftbookModelNeeds(options.needs.models, {
1409
1434
  ...options.params ? { params: options.params } : {},
@@ -1411,7 +1436,7 @@ async function ensureCraftbookSetup(client, options) {
1411
1436
  defaultProvider: defaultModelEngine(config, options.platform, options.arch)
1412
1437
  });
1413
1438
  const gaps = craftbookSetupGaps(
1414
- { services, models },
1439
+ { services, models, commands },
1415
1440
  await readSetupState(client, config, models)
1416
1441
  );
1417
1442
  if (gaps.length === 0) return;
@@ -1454,6 +1479,18 @@ ${lines.join("\n")}
1454
1479
  if (!yes) stop(gap);
1455
1480
  await client.updateConfig({ securityPolicy: next });
1456
1481
  options.write("External services: on\n");
1482
+ } else if (gap.kind === "package-scripts") {
1483
+ const current = await client.getConfig();
1484
+ const next = policyWithCapability(current, "allowPackageScriptExecution", true);
1485
+ const from = SECURITY_LEVEL_LABELS[resolveSecurityPolicy2(current).level];
1486
+ const to = SECURITY_LEVEL_LABELS[next.level];
1487
+ const change = from === to ? "" : ` This changes your security level from ${from} to ${to}.`;
1488
+ const yes = await prompter.confirm(
1489
+ `Let gezels run package scripts such as ${gap.commands[0]}? They run outside the sandbox, as your account, with network access, and Gezel asks before each new command.${change} [y/N] `
1490
+ );
1491
+ if (!yes) stop(gap);
1492
+ await client.updateConfig({ securityPolicy: next });
1493
+ options.write("Run package scripts: on\n");
1457
1494
  } else if (gap.kind === "web-search") {
1458
1495
  if (gap.keyMissing) {
1459
1496
  options.write(
@@ -1503,7 +1540,7 @@ ${lines.join("\n")}
1503
1540
  for (const gap of downloads) await pullChatModel(client, gap.provider, gap.id, options.write);
1504
1541
  }
1505
1542
  const after = craftbookSetupGaps(
1506
- { services, models },
1543
+ { services, models, commands },
1507
1544
  await readSetupState(client, await client.getConfig(), models)
1508
1545
  );
1509
1546
  if (after.length > 0) {
@@ -1606,6 +1643,7 @@ async function readSetupState(client, config, models) {
1606
1643
  );
1607
1644
  return {
1608
1645
  allowExternalServices: resolveSecurityPolicy2(config).allowExternalServices,
1646
+ allowPackageScriptExecution: resolveSecurityPolicy2(config).allowPackageScriptExecution,
1609
1647
  ...config.webSearch?.provider ? { webSearchProvider: config.webSearch.provider } : {},
1610
1648
  hasBraveSearchApiKey: config.hasBraveSearchApiKey === true,
1611
1649
  installedModels: Object.fromEntries(installed)
@@ -1641,6 +1679,8 @@ function describeGap(gap, sizes) {
1641
1679
  switch (gap.kind) {
1642
1680
  case "external-services":
1643
1681
  return `External services are off, so gezels cannot reach the web${why}.`;
1682
+ case "package-scripts":
1683
+ return `Run package scripts is off, so gezels cannot run ${gap.commands.join(", ")}${why}.`;
1644
1684
  case "web-search":
1645
1685
  return gap.keyMissing ? `Web search needs a Brave Search API key, and none is set${why}.` : `Web search is not set to Brave Search${why}.`;
1646
1686
  case "model": {
@@ -1653,6 +1693,7 @@ function instructions(gaps) {
1653
1693
  const out = [];
1654
1694
  for (const gap of gaps) {
1655
1695
  if (gap.kind === "external-services") out.push("gezel security external-services on");
1696
+ else if (gap.kind === "package-scripts") out.push("gezel security run-package-scripts on");
1656
1697
  else if (gap.kind === "web-search")
1657
1698
  out.push(
1658
1699
  `gezel secret set braveSearchApiKey --env BRAVE_SEARCH_API_KEY --use-for-search (get a key at ${BRAVE_KEY_URL})`
@@ -1984,7 +2025,7 @@ function registerMcpCommands(program2, connect, output = console.log) {
1984
2025
  if (status.state === "configured" && line) {
1985
2026
  lines.push(
1986
2027
  "",
1987
- `${status.label} reaches for its own search first. So it uses Gezel's, add this line to the ${HARNESS_AGENT_FILE[client]} file in a folder you work in:`,
2028
+ `${status.label} reaches for its own search first. So it uses Gezel's, add this line near the top of the ${HARNESS_AGENT_FILE[client]} file in a folder you work in (at the end of a long file it gets overlooked):`,
1988
2029
  "",
1989
2030
  ` ${line}`
1990
2031
  );
@@ -2240,20 +2281,32 @@ function stderrProgress() {
2240
2281
  // src/tui/gezel-picker.ts
2241
2282
  import {
2242
2283
  getProjectType,
2284
+ legacyRoleKey,
2285
+ plainRoleTitle,
2243
2286
  resolveProjectTypeId
2244
2287
  } from "@bendyline/gezel";
2245
2288
  function roleIdentity(value) {
2246
- return (value ?? "").trim().toLowerCase();
2289
+ const raw = (value ?? "").trim();
2290
+ return (legacyRoleKey(raw) ?? legacyRoleKey(raw.replace(/-/g, " ")) ?? raw).toLowerCase();
2291
+ }
2292
+ function argKeys(values) {
2293
+ return [
2294
+ ...new Set(
2295
+ values.flatMap((value) => [(value ?? "").trim().toLowerCase(), roleIdentity(value)])
2296
+ )
2297
+ ].filter(Boolean);
2247
2298
  }
2248
2299
  function resolveGezelArg(arg, inputs) {
2249
2300
  const query = arg.trim().toLowerCase();
2250
2301
  if (!query) return { kind: "unknown" };
2251
2302
  const { gezels, templates } = inputs;
2252
- const gezelKeys = (g) => [g.id, g.name, g.roleBasedName, g.role].map(roleIdentity).filter(Boolean);
2253
- const templateKeys = (t) => [t.id, t.role, t.name].map(roleIdentity).filter(Boolean);
2254
- const exactGezel = gezels.find((g) => gezelKeys(g).includes(query));
2303
+ const queryRole = roleIdentity(query);
2304
+ const gezelKeys = (g) => argKeys([g.id, g.name, g.roleBasedName, g.role]);
2305
+ const templateKeys = (t) => argKeys([t.id, t.role, t.name]);
2306
+ const exact = (keys) => keys.includes(query) || keys.includes(queryRole);
2307
+ const exactGezel = gezels.find((g) => exact(gezelKeys(g)));
2255
2308
  if (exactGezel) return { kind: "gezel", gezelId: exactGezel.id };
2256
- const exactTemplate = templates.find((t) => templateKeys(t).includes(query));
2309
+ const exactTemplate = templates.find((t) => exact(templateKeys(t)));
2257
2310
  if (exactTemplate) return { kind: "template", templateId: exactTemplate.id };
2258
2311
  const prefixGezels = gezels.filter((g) => gezelKeys(g).some((k) => k.startsWith(query)));
2259
2312
  if (prefixGezels.length === 1) return { kind: "gezel", gezelId: prefixGezels[0].id };
@@ -2263,7 +2316,7 @@ function resolveGezelArg(arg, inputs) {
2263
2316
  const prefixTemplates = templates.filter((t) => templateKeys(t).some((k) => k.startsWith(query)));
2264
2317
  if (prefixTemplates.length === 1) return { kind: "template", templateId: prefixTemplates[0].id };
2265
2318
  if (prefixTemplates.length > 1) {
2266
- return { kind: "ambiguous", labels: prefixTemplates.map((t) => t.name) };
2319
+ return { kind: "ambiguous", labels: prefixTemplates.map((t) => plainRoleTitle(t.name)) };
2267
2320
  }
2268
2321
  return { kind: "unknown" };
2269
2322
  }
@@ -3446,7 +3499,7 @@ program.command("mode [mode]").description("Show or set AI activity (read-only,
3446
3499
  const current = cliEngagementModeOption(updated.aiEngagementMode);
3447
3500
  console.log(`AI mode \u2192 ${current.name} \u2014 ${current.description}`);
3448
3501
  });
3449
- program.command("run [prompt...]").description("Run a prompt through a gezel and print the reply (use - to read stdin)").option("-g, --gezel <ref>", "gezel id or name (default: this project's voorman)").addHelpText(
3502
+ program.command("run [prompt...]").description("Run a prompt through a gezel and print the reply (use - to read stdin)").option("-g, --gezel <ref>", "gezel id or name (default: this project's crew lead)").addHelpText(
3450
3503
  "after",
3451
3504
  `
3452
3505
  Examples:
@@ -9,6 +9,7 @@ import { CatalogService } from "@bendyline/gezel-catalog";
9
9
  import {
10
10
  OG_CARD_HEIGHT,
11
11
  OG_CARD_WIDTH,
12
+ bundledGildeDataDir,
12
13
  createHandboekEngine,
13
14
  findHandboekContent,
14
15
  ogKicker,
@@ -1510,7 +1511,7 @@ async function runHandboekExport(opts) {
1510
1511
  "no handboek content tree found \u2014 run from a gezel checkout or install, or set GEZEL_HANDBOEK_DIR"
1511
1512
  );
1512
1513
  }
1513
- const catalog = new CatalogService();
1514
+ const catalog = new CatalogService(void 0, { contentRoot: bundledGildeDataDir });
1514
1515
  const engine = createHandboekEngine({
1515
1516
  catalog,
1516
1517
  device: siteDeviceInfo,
@@ -1561,7 +1562,13 @@ async function runHandboekExport(opts) {
1561
1562
  continue;
1562
1563
  }
1563
1564
  const depth = entry.id.split("/").length;
1564
- const markdown = rewriteSiteLinks(article.markdown, entry.id, ids, byStem);
1565
+ const markdown = rewriteSiteLinks(
1566
+ article.markdown,
1567
+ entry.id,
1568
+ ids,
1569
+ byStem,
1570
+ (asset) => existsSync2(join4(contentDir, asset))
1571
+ );
1565
1572
  const parsed = parseMarkdown(markdown);
1566
1573
  const demo = demos.get(entry.id);
1567
1574
  const art = entry.id.startsWith("craftbook/") ? site.craftbookArt.get(entry.id.slice("craftbook/".length)) : void 0;
@@ -1661,7 +1668,7 @@ function normalizeBase(base) {
1661
1668
  if (!trimmed) return void 0;
1662
1669
  return trimmed.endsWith("/") ? trimmed : `${trimmed}/`;
1663
1670
  }
1664
- function rewriteSiteLinks(markdown, pageId, ids, byStem) {
1671
+ function rewriteSiteLinks(markdown, pageId, ids, byStem, hasAsset = () => true) {
1665
1672
  const prefix = up(pageId.split("/").length);
1666
1673
  return markdown.replace(/\]\(([^()\s]+)\)/g, (whole, rawTarget) => {
1667
1674
  if (/^[a-z][a-z0-9+.-]*:/i.test(rawTarget) || rawTarget.startsWith("//") || rawTarget.startsWith("#")) {
@@ -1670,7 +1677,7 @@ function rewriteSiteLinks(markdown, pageId, ids, byStem) {
1670
1677
  const [path, suffix = ""] = splitLinkSuffix(rawTarget);
1671
1678
  const candidate = path.replace(/^(\.\.?\/)+/, "");
1672
1679
  if (candidate.startsWith("assets/")) {
1673
- return `](${prefix}${candidate}${suffix})`;
1680
+ return hasAsset(candidate) ? `](${prefix}${candidate}${suffix})` : `](${PUBLISHED_HANDBOEK}${candidate}${suffix})`;
1674
1681
  }
1675
1682
  const article = candidate.replace(/\.md$/, "");
1676
1683
  const target = ids.has(article) ? article : byStem.get(article.split("/").pop() ?? "");
@@ -1682,6 +1689,7 @@ function splitLinkSuffix(raw) {
1682
1689
  const idx = raw.search(/[?#]/);
1683
1690
  return idx === -1 ? [raw, ""] : [raw.slice(0, idx), raw.slice(idx)];
1684
1691
  }
1692
+ var PUBLISHED_HANDBOEK = "https://gezel.com/docs/";
1685
1693
  var up = (depth) => "../".repeat(depth);
1686
1694
  var esc = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
1687
1695
  function extractBody(page) {
@@ -41,6 +41,7 @@ import {
41
41
  gezelNamesInUse,
42
42
  pickUnusedGezelName,
43
43
  projectLeadGezelId,
44
+ roleForMatching,
44
45
  setLogLevel,
45
46
  setLogOutput
46
47
  } from "@bendyline/gezel";
package/dist/tui/index.js CHANGED
@@ -23,6 +23,7 @@ import {
23
23
  gezelNamesInUse,
24
24
  pickUnusedGezelName,
25
25
  projectLeadGezelId,
26
+ roleForMatching,
26
27
  setLogLevel,
27
28
  setLogOutput
28
29
  } from "@bendyline/gezel";
@@ -84,7 +85,7 @@ async function ensureCliProjectLead(client, projectId) {
84
85
  }
85
86
  const { gezels } = await client.listGezels();
86
87
  let voorman = gezels.find(
87
- (gezel) => gezel.templateId === "voorman" || gezel.role?.trim().toLowerCase() === "voorman"
88
+ (gezel) => gezel.templateId === "voorman" || roleForMatching(gezel.role)?.trim().toLowerCase() === "voorman"
88
89
  );
89
90
  if (!voorman) {
90
91
  const { name, gender } = pickUnusedGezelName(gezelNamesInUse(gezels));
@@ -92,7 +93,7 @@ async function ensureCliProjectLead(client, projectId) {
92
93
  }
93
94
  const updated = await client.updateProject(projectId, { voormanGezelId: voorman.id });
94
95
  if (!updated.voormanGezelId) {
95
- throw new CliError(`project "${updated.name}" has no voorman`);
96
+ throw new CliError(`project "${updated.name}" has no crew lead`);
96
97
  }
97
98
  return updated.voormanGezelId;
98
99
  }
@@ -2334,6 +2335,8 @@ function craftbookStartRequest(book) {
2334
2335
  // src/tui/gezel-picker.ts
2335
2336
  import {
2336
2337
  getProjectType,
2338
+ legacyRoleKey,
2339
+ plainRoleTitle,
2337
2340
  resolveProjectTypeId
2338
2341
  } from "@bendyline/gezel";
2339
2342
  var GEZEL_VALUE_PREFIX = "gezel:";
@@ -2363,7 +2366,15 @@ function clip2(text, width) {
2363
2366
  return `${flat.slice(0, Math.max(1, width - 1)).trimEnd()}\u2026`;
2364
2367
  }
2365
2368
  function roleIdentity(value) {
2366
- return (value ?? "").trim().toLowerCase();
2369
+ const raw = (value ?? "").trim();
2370
+ return (legacyRoleKey(raw) ?? legacyRoleKey(raw.replace(/-/g, " ")) ?? raw).toLowerCase();
2371
+ }
2372
+ function argKeys(values) {
2373
+ return [
2374
+ ...new Set(
2375
+ values.flatMap((value) => [(value ?? "").trim().toLowerCase(), roleIdentity(value)])
2376
+ )
2377
+ ].filter(Boolean);
2367
2378
  }
2368
2379
  function displayName(gezel, roleBasedNameOnly) {
2369
2380
  if (roleBasedNameOnly) return gezel.roleBasedName ?? gezel.role ?? gezel.id;
@@ -2412,7 +2423,7 @@ function buildGezelPickerItems(inputs) {
2412
2423
  hint: clip2(gezelHint(gezel, templatesById, roleBasedNameOnly), hintWidth)
2413
2424
  });
2414
2425
  const templateItem = (template, reason) => ({
2415
- label: template.name,
2426
+ label: plainRoleTitle(template.name),
2416
2427
  value: `${TEMPLATE_VALUE_PREFIX}${template.id}`,
2417
2428
  hint: clip2(reason ?? template.description, hintWidth)
2418
2429
  });
@@ -2459,7 +2470,7 @@ function buildGezelPickerItems(inputs) {
2459
2470
  }
2460
2471
  const remaining = availableTemplates.filter((t) => !recommendedTemplateIds.has(t.id));
2461
2472
  const core = remaining.filter((t) => coreRank.has(t.id)).sort((a, b) => (coreRank.get(a.id) ?? 0) - (coreRank.get(b.id) ?? 0));
2462
- const more = remaining.filter((t) => !coreRank.has(t.id)).sort((a, b) => a.name.localeCompare(b.name));
2473
+ const more = remaining.filter((t) => !coreRank.has(t.id)).sort((a, b) => plainRoleTitle(a.name).localeCompare(plainRoleTitle(b.name)));
2463
2474
  for (const template of core) push(SECTION_CORE, templateItem(template));
2464
2475
  for (const template of more) push(SECTION_MORE, templateItem(template));
2465
2476
  return items;
@@ -2473,11 +2484,13 @@ function resolveGezelArg(arg, inputs) {
2473
2484
  const query = arg.trim().toLowerCase();
2474
2485
  if (!query) return { kind: "unknown" };
2475
2486
  const { gezels, templates } = inputs;
2476
- const gezelKeys = (g) => [g.id, g.name, g.roleBasedName, g.role].map(roleIdentity).filter(Boolean);
2477
- const templateKeys = (t) => [t.id, t.role, t.name].map(roleIdentity).filter(Boolean);
2478
- const exactGezel = gezels.find((g) => gezelKeys(g).includes(query));
2487
+ const queryRole = roleIdentity(query);
2488
+ const gezelKeys = (g) => argKeys([g.id, g.name, g.roleBasedName, g.role]);
2489
+ const templateKeys = (t) => argKeys([t.id, t.role, t.name]);
2490
+ const exact = (keys) => keys.includes(query) || keys.includes(queryRole);
2491
+ const exactGezel = gezels.find((g) => exact(gezelKeys(g)));
2479
2492
  if (exactGezel) return { kind: "gezel", gezelId: exactGezel.id };
2480
- const exactTemplate = templates.find((t) => templateKeys(t).includes(query));
2493
+ const exactTemplate = templates.find((t) => exact(templateKeys(t)));
2481
2494
  if (exactTemplate) return { kind: "template", templateId: exactTemplate.id };
2482
2495
  const prefixGezels = gezels.filter((g) => gezelKeys(g).some((k) => k.startsWith(query)));
2483
2496
  if (prefixGezels.length === 1) return { kind: "gezel", gezelId: prefixGezels[0].id };
@@ -2487,7 +2500,7 @@ function resolveGezelArg(arg, inputs) {
2487
2500
  const prefixTemplates = templates.filter((t) => templateKeys(t).some((k) => k.startsWith(query)));
2488
2501
  if (prefixTemplates.length === 1) return { kind: "template", templateId: prefixTemplates[0].id };
2489
2502
  if (prefixTemplates.length > 1) {
2490
- return { kind: "ambiguous", labels: prefixTemplates.map((t) => t.name) };
2503
+ return { kind: "ambiguous", labels: prefixTemplates.map((t) => plainRoleTitle(t.name)) };
2491
2504
  }
2492
2505
  return { kind: "unknown" };
2493
2506
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bendyline/gezel-cli",
3
- "version": "1.2.8",
3
+ "version": "1.2.10",
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,15 +44,15 @@
44
44
  "!dist/**/*.map"
45
45
  ],
46
46
  "dependencies": {
47
- "@bendyline/gezel": "1.2.8",
48
- "@bendyline/gezel-app-sdk": "1.1.8",
49
- "@bendyline/gezel-catalog": "1.2.8",
50
- "@bendyline/gezel-client": "1.2.8",
51
- "@bendyline/gezel-knowledge": "1.2.8",
52
- "@bendyline/gezel-service": "1.2.8",
53
- "@bendyline/squisq": "2.13.1",
54
- "@bendyline/squisq-formats": "2.8.2",
55
- "@bendyline/squisq-react": "2.12.10",
47
+ "@bendyline/gezel": "1.2.10",
48
+ "@bendyline/gezel-app-sdk": "1.1.10",
49
+ "@bendyline/gezel-catalog": "1.2.10",
50
+ "@bendyline/gezel-client": "1.2.10",
51
+ "@bendyline/gezel-knowledge": "1.2.9",
52
+ "@bendyline/gezel-service": "1.2.10",
53
+ "@bendyline/squisq": "2.13.5",
54
+ "@bendyline/squisq-formats": "2.8.6",
55
+ "@bendyline/squisq-react": "2.12.15",
56
56
  "commander": "^15.0.0",
57
57
  "ink": "^7.1.1",
58
58
  "ink-text-input": "^6.0.0",
@@ -69,7 +69,7 @@
69
69
  "build": "tsup && node scripts/verify-build.mjs",
70
70
  "dev": "tsup --watch",
71
71
  "typecheck": "tsc --noEmit",
72
- "clean": "rm -rf dist .turbo",
72
+ "clean": "node ../../scripts/clean-dirs.mjs dist .turbo",
73
73
  "test": "vitest run"
74
74
  }
75
75
  }