@bendyline/gezel-cli 0.1.0 → 1.0.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.
@@ -322,7 +322,8 @@ var AREA_BLURBS = {
322
322
  "gezel-roles": "The roles a gezel can take, and what each one is good at.",
323
323
  craftbooks: "Step-by-step recipes your crew can run \u2014 one per job.",
324
324
  "project-types": "Ready-made project setups, each with a crew and a bench.",
325
- technical: "Architecture, file layout, providers, security, and the CLI."
325
+ technical: "Architecture, file layout, providers, security, and the CLI.",
326
+ "whats-new": "What changed in each release, in plain language."
326
327
  };
327
328
  var START_HERE = ["welcome", "the-crew", "projects-and-threads", "craftbooks-overview"];
328
329
  var WORDMARK = "gezel";
package/dist/tui/index.js CHANGED
@@ -7,39 +7,114 @@ import { render } from "ink";
7
7
  import { Box as Box6, Text as Text6, useApp, useInput as useInput4, useStdout } from "ink";
8
8
  import { useCallback, useEffect as useEffect3, useMemo, useRef as useRef2, useState as useState4 } from "react";
9
9
 
10
- // src/tui/active-access.ts
10
+ // src/connection.ts
11
+ import { createHash, randomUUID } from "crypto";
12
+ import { chmod, mkdir, readFile, rm, writeFile } from "fs/promises";
13
+ import { homedir } from "os";
14
+ import { basename, dirname, join, resolve } from "path";
15
+ import { pickRandomNameWithGender } from "@bendyline/gezel";
11
16
  import {
12
- normalizeCodexPermissionMode,
13
- projectWorkspaceWritable,
14
- resolveSandboxCopilot
15
- } from "@bendyline/gezel";
16
- function activeAccessMode(opts) {
17
- const { provider, project, gezel, config } = opts;
18
- if (provider === "codex-cli") {
19
- const mode = normalizeCodexPermissionMode(
20
- project?.codexPermissionMode ?? gezel?.codexPermissionMode ?? gezel?.claudePermissionMode ?? config?.codexCli?.defaultPermissionMode
21
- );
22
- switch (mode) {
23
- case "plan":
24
- return "read-only";
25
- case "edit":
26
- return "editable";
27
- case "reviewed":
28
- return "reviewed edits";
29
- case "full":
30
- return "full access";
31
- }
17
+ GezelSdkError,
18
+ authorizeLocal,
19
+ authorizeLocalOwner
20
+ } from "@bendyline/gezel-app-sdk";
21
+ import {
22
+ GezelApiError,
23
+ GezelClient,
24
+ createTrustingFetch,
25
+ electronNativeBinCandidates,
26
+ isProcessAlive,
27
+ readRuntime,
28
+ readSystemServiceEndpoint,
29
+ resolveDaemonEntry,
30
+ systemSharedAssetsDir
31
+ } from "@bendyline/gezel-client/node";
32
+ import { gezelPaths } from "@bendyline/gezel/paths";
33
+ var CliError = class extends Error {
34
+ constructor(message) {
35
+ super(message);
36
+ this.name = "CliError";
32
37
  }
33
- if (provider === "anthropic-cli") {
34
- const mode = gezel?.claudePermissionMode ?? config?.anthropicCli?.defaultPermissionMode ?? "acceptEdits";
35
- if (mode === "plan") return "read-only";
36
- if (mode === "bypassPermissions") return "full access";
37
- return "editable";
38
+ };
39
+ async function ensureCliProjectLead(client, projectId) {
40
+ const project = await client.getProject(projectId);
41
+ if (project.voormanGezelId) return project.voormanGezelId;
42
+ if (project.mode === "solo" && project.gezelIds?.[0]) return project.gezelIds[0];
43
+ const { gezels } = await client.listGezels();
44
+ let voorman = gezels.find(
45
+ (gezel) => gezel.templateId === "voorman" || gezel.role?.trim().toLowerCase() === "voorman"
46
+ );
47
+ if (!voorman) {
48
+ const { name, gender } = pickRandomNameWithGender();
49
+ voorman = await client.createGezelFromTemplate("voorman", { name, gender });
38
50
  }
39
- if (provider === "copilot" && !resolveSandboxCopilot(config?.sandboxCopilot, gezel?.sandboxCopilot)) {
40
- return "editable";
51
+ const updated = await client.updateProject(projectId, { voormanGezelId: voorman.id });
52
+ if (!updated.voormanGezelId) {
53
+ throw new CliError(`project "${updated.name}" has no voorman`);
41
54
  }
42
- return projectWorkspaceWritable(project) ? "editable" : "read-only";
55
+ return updated.voormanGezelId;
56
+ }
57
+
58
+ // src/engagement-mode.ts
59
+ var CLI_ENGAGEMENT_MODES = [
60
+ {
61
+ name: "read-only",
62
+ mode: "off",
63
+ label: "Read-only",
64
+ description: "AI is paused; browse projects and history without starting AI work."
65
+ },
66
+ {
67
+ name: "reactive",
68
+ mode: "reactive",
69
+ label: "Reactive",
70
+ description: "AI replies to messages; autonomous task work stays paused."
71
+ },
72
+ {
73
+ name: "reactive+tasks",
74
+ mode: "scheduled",
75
+ label: "Reactive + tasks",
76
+ description: "Messages, task work, and schedules run without proactive nudges."
77
+ },
78
+ {
79
+ name: "full-play",
80
+ mode: "proactive",
81
+ label: "Full play",
82
+ description: "Everything runs, including proactive nudges and cross-gezel work."
83
+ }
84
+ ];
85
+ var MODE_ALIASES = {
86
+ "read-only": "off",
87
+ readonly: "off",
88
+ off: "off",
89
+ reactive: "reactive",
90
+ "reactive-only": "reactive",
91
+ "reactive+tasks": "scheduled",
92
+ "tasks+reactive": "scheduled",
93
+ scheduled: "scheduled",
94
+ "full-play": "proactive",
95
+ fullplay: "proactive",
96
+ proactive: "proactive"
97
+ };
98
+ function parseCliEngagementMode(input) {
99
+ const normalized = input.trim().toLowerCase().replace(/\s*\+\s*/g, "+").replace(/[\s_]+/g, "-");
100
+ return MODE_ALIASES[normalized] ?? null;
101
+ }
102
+ function cliEngagementModeOption(mode) {
103
+ return CLI_ENGAGEMENT_MODES.find((option) => option.mode === (mode ?? "proactive"));
104
+ }
105
+ var CLI_ENGAGEMENT_MODE_USAGE = CLI_ENGAGEMENT_MODES.map((option) => option.name).join(
106
+ "|"
107
+ );
108
+
109
+ // src/tui/active-access.ts
110
+ import {
111
+ resolveGezelWorkspaceAccess
112
+ } from "@bendyline/gezel";
113
+ function activeAccessMode(opts) {
114
+ const access = resolveGezelWorkspaceAccess(opts);
115
+ if (access.nativeAccess === "reviewed") return "reviewed edits";
116
+ if (access.nativeAccess === "full") return "full access";
117
+ return access.effectiveWritable ? "editable" : "read-only";
43
118
  }
44
119
 
45
120
  // src/tui/commands.ts
@@ -48,6 +123,7 @@ var SLASH_COMMANDS = [
48
123
  { name: "help", description: "show the command reference" },
49
124
  { name: "project", description: "switch active project" },
50
125
  { name: "gezel", description: "switch active gezel" },
126
+ { name: "mode", description: "set AI activity: read-only through full play" },
51
127
  { name: "model", description: "switch engine and model" },
52
128
  { name: "thread", description: "switch the active chat thread" },
53
129
  { name: "task", description: "list and manage project tasks" },
@@ -71,6 +147,17 @@ var NIGHT_SHIFT_SUBCOMMANDS = [
71
147
  { name: "list", description: "show current and upcoming night-shift work" }
72
148
  ];
73
149
  function suggestSlashWordwheel(input, craftbooks) {
150
+ const modeMatch = input.match(/^\/mode\s+(.*)$/i);
151
+ if (modeMatch) {
152
+ const query = (modeMatch[1] ?? "").trim().toLowerCase();
153
+ return CLI_ENGAGEMENT_MODES.filter((option) => option.name.startsWith(query)).map((option) => ({
154
+ key: `mode:${option.name}`,
155
+ label: `/mode ${option.name}`,
156
+ description: option.description,
157
+ submit: `/mode ${option.name}`,
158
+ completion: `/mode ${option.name}`
159
+ }));
160
+ }
74
161
  const nightShiftMatch = input.match(/^\/nightshift\s+(.*)$/i);
75
162
  if (nightShiftMatch) {
76
163
  const query = (nightShiftMatch[1] ?? "").trim().toLowerCase();
@@ -1212,13 +1299,13 @@ async function consumeWithReconnect(open, handler, signal) {
1212
1299
  }
1213
1300
  }
1214
1301
  function abortableDelay(ms, signal) {
1215
- return new Promise((resolve) => {
1302
+ return new Promise((resolve2) => {
1216
1303
  const timer = setTimeout(done, ms);
1217
1304
  signal.addEventListener("abort", done, { once: true });
1218
1305
  function done() {
1219
1306
  clearTimeout(timer);
1220
1307
  signal.removeEventListener("abort", done);
1221
- resolve();
1308
+ resolve2();
1222
1309
  }
1223
1310
  });
1224
1311
  }
@@ -1240,6 +1327,7 @@ function useTerminalSize() {
1240
1327
  }
1241
1328
  var HELP = [
1242
1329
  "/project \u2014 switch project /gezel \u2014 switch gezel /model \u2014 switch engine + model",
1330
+ "/mode \u2014 choose read-only, reactive, reactive+tasks, or full-play AI activity",
1243
1331
  "/thread \u2014 switch or start a chat thread",
1244
1332
  "/task \u2014 list, inspect, create, edit, assign, or change task status",
1245
1333
  "/start \u2014 choose a craftbook and start it as a task",
@@ -1410,6 +1498,38 @@ function App(props) {
1410
1498
  },
1411
1499
  [client, note]
1412
1500
  );
1501
+ const switchProject = useCallback(
1502
+ async (id) => {
1503
+ setOverlay(null);
1504
+ const project = projects.find((candidate) => candidate.id === id);
1505
+ if (!project || id === projectId) return;
1506
+ try {
1507
+ const gezelId = project.voormanGezelId ?? await ensureCliProjectLead(client, id);
1508
+ setProjectId(id);
1509
+ setProjectName(project.name);
1510
+ setActiveGezelId(gezelId);
1511
+ setRows([]);
1512
+ setTurns(/* @__PURE__ */ new Map());
1513
+ setActiveRuns(/* @__PURE__ */ new Set());
1514
+ setPendingInput(null);
1515
+ setPendingQuestions([]);
1516
+ setThreads([]);
1517
+ setActiveThreadTitle(null);
1518
+ setTasks([]);
1519
+ setCraftbooks([]);
1520
+ setCraftbookProjectType(null);
1521
+ setSuggestedCraftbookIds(/* @__PURE__ */ new Set());
1522
+ setCraftbooksNeedingSetup(/* @__PURE__ */ new Set());
1523
+ setStartCategoryId(null);
1524
+ setManagedTaskRef(null);
1525
+ setTaskPrompt(null);
1526
+ await ensureSession(gezelId, id);
1527
+ } catch (err) {
1528
+ note(`could not switch project: ${errMsg(err)}`, "error");
1529
+ }
1530
+ },
1531
+ [client, ensureSession, note, projectId, projects]
1532
+ );
1413
1533
  const openThreadPicker = useCallback(async () => {
1414
1534
  if (!activeGezelId) return note("no active gezel yet.", "error");
1415
1535
  if (threadsLoading) return;
@@ -1473,15 +1593,17 @@ function App(props) {
1473
1593
  id: p.id,
1474
1594
  name: p.name,
1475
1595
  workingDir: p.workingDir,
1596
+ voormanGezelId: p.voormanGezelId,
1597
+ managedWorkspaceWritePolicy: p.managedWorkspaceWritePolicy,
1476
1598
  allowGezelWrites: p.allowGezelWrites,
1477
- codexPermissionMode: p.codexPermissionMode
1599
+ codexPermissionMode: p.codexPermissionMode,
1600
+ claudePermissionMode: p.claudePermissionMode
1478
1601
  }))
1479
1602
  );
1480
- const gezelId = cfg.meesterGezelId ?? gz.gezels[0]?.id ?? null;
1603
+ const gezelId = props.initialGezelId;
1481
1604
  setActiveGezelId(gezelId);
1482
1605
  setStatus(null);
1483
- if (gezelId) await ensureSession(gezelId, projectId);
1484
- else note("no gezels available \u2014 create one with `gezel agent create`.", "error");
1606
+ await ensureSession(gezelId, projectId);
1485
1607
  } catch (err) {
1486
1608
  if (!cancelled) setStatus(`Failed to connect: ${errMsg(err)}`);
1487
1609
  }
@@ -1577,6 +1699,25 @@ function App(props) {
1577
1699
  const rememberTask = useCallback((task) => {
1578
1700
  setTasks((current) => sortTasks([...current.filter((item) => item.ref !== task.ref), task]));
1579
1701
  }, []);
1702
+ const applyEngagementMode = useCallback(
1703
+ async (requested) => {
1704
+ const next = parseCliEngagementMode(requested);
1705
+ if (!next) {
1706
+ note(`usage: /mode ${CLI_ENGAGEMENT_MODE_USAGE}`, "error");
1707
+ return;
1708
+ }
1709
+ const option = cliEngagementModeOption(next);
1710
+ setOverlay(null);
1711
+ try {
1712
+ const updated = await client.updateConfig({ aiEngagementMode: next });
1713
+ setConfig(updated);
1714
+ note(`AI mode \u2192 ${option.label}. ${option.description}`);
1715
+ } catch (err) {
1716
+ note(`could not change AI mode: ${errMsg(err)}`, "error");
1717
+ }
1718
+ },
1719
+ [client, note]
1720
+ );
1580
1721
  const startCraftbook = useCallback(
1581
1722
  async (book) => {
1582
1723
  setOverlay(null);
@@ -1770,6 +1911,10 @@ function App(props) {
1770
1911
  return setOverlay("project");
1771
1912
  case "gezel":
1772
1913
  return setOverlay("gezel");
1914
+ case "mode":
1915
+ if (!rest.trim()) return setOverlay("engagement-mode");
1916
+ await applyEngagementMode(rest);
1917
+ return;
1773
1918
  case "model": {
1774
1919
  if (!activeGezelId || !activeGezel) return note("no active gezel yet.", "error");
1775
1920
  if (activeGezel.fixedFunction) {
@@ -1919,6 +2064,7 @@ function App(props) {
1919
2064
  [
1920
2065
  activeGezel,
1921
2066
  activeGezelId,
2067
+ applyEngagementMode,
1922
2068
  client,
1923
2069
  config,
1924
2070
  craftbooks,
@@ -2028,29 +2174,7 @@ function App(props) {
2028
2174
  title: "Switch project",
2029
2175
  items: projects.map((p) => ({ label: p.name, value: p.id, hint: p.workingDir })),
2030
2176
  onCancel: () => setOverlay(null),
2031
- onSelect: (id) => {
2032
- setOverlay(null);
2033
- const p = projects.find((x) => x.id === id);
2034
- if (!p || id === projectId) return;
2035
- setProjectId(id);
2036
- setProjectName(p.name);
2037
- setRows([]);
2038
- setTurns(/* @__PURE__ */ new Map());
2039
- setActiveRuns(/* @__PURE__ */ new Set());
2040
- setPendingInput(null);
2041
- setPendingQuestions([]);
2042
- setThreads([]);
2043
- setActiveThreadTitle(null);
2044
- setTasks([]);
2045
- setCraftbooks([]);
2046
- setCraftbookProjectType(null);
2047
- setSuggestedCraftbookIds(/* @__PURE__ */ new Set());
2048
- setCraftbooksNeedingSetup(/* @__PURE__ */ new Set());
2049
- setStartCategoryId(null);
2050
- setManagedTaskRef(null);
2051
- setTaskPrompt(null);
2052
- if (activeGezelId) void ensureSession(activeGezelId, id);
2053
- }
2177
+ onSelect: (id) => void switchProject(id)
2054
2178
  }
2055
2179
  ) : null,
2056
2180
  overlay === "gezel" ? /* @__PURE__ */ jsx6(
@@ -2073,6 +2197,20 @@ function App(props) {
2073
2197
  }
2074
2198
  }
2075
2199
  ) : null,
2200
+ overlay === "engagement-mode" ? /* @__PURE__ */ jsx6(
2201
+ Picker,
2202
+ {
2203
+ title: "Choose AI engagement mode",
2204
+ items: CLI_ENGAGEMENT_MODES.map((option) => ({
2205
+ label: option.label,
2206
+ value: option.name,
2207
+ hint: option.description
2208
+ })),
2209
+ initialValue: cliEngagementModeOption(config?.aiEngagementMode).name,
2210
+ onCancel: () => setOverlay(null),
2211
+ onSelect: (selected) => void applyEngagementMode(selected)
2212
+ }
2213
+ ) : null,
2076
2214
  overlay === "model" ? /* @__PURE__ */ jsx6(
2077
2215
  Picker,
2078
2216
  {
@@ -3078,7 +3216,7 @@ function errorMessage(error) {
3078
3216
  return error instanceof Error ? error.message : String(error);
3079
3217
  }
3080
3218
  function delay(ms) {
3081
- return new Promise((resolve) => setTimeout(resolve, ms));
3219
+ return new Promise((resolve2) => setTimeout(resolve2, ms));
3082
3220
  }
3083
3221
 
3084
3222
  // src/tui/index.tsx
@@ -3090,7 +3228,8 @@ async function launchTui(opts) {
3090
3228
  {
3091
3229
  client: opts.client,
3092
3230
  initialProjectId: opts.projectId,
3093
- initialProjectName: opts.projectName
3231
+ initialProjectName: opts.projectName,
3232
+ initialGezelId: opts.gezelId
3094
3233
  }
3095
3234
  ) }),
3096
3235
  // We own Ctrl+C (interrupt-then-exit); don't let ink exit on the first press.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bendyline/gezel-cli",
3
- "version": "0.1.0",
3
+ "version": "1.0.1",
4
4
  "description": "The `gezel` command-line tool.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -44,18 +44,18 @@
44
44
  "!dist/**/*.map"
45
45
  ],
46
46
  "dependencies": {
47
- "@bendyline/squisq": "2.7.0",
48
- "@bendyline/squisq-formats": "2.4.1",
49
- "@bendyline/squisq-react": "2.7.0",
47
+ "@bendyline/squisq": "2.7.1",
48
+ "@bendyline/squisq-formats": "2.4.3",
49
+ "@bendyline/squisq-react": "2.7.1",
50
50
  "commander": "^15.0.0",
51
51
  "ink": "^7.1.1",
52
52
  "ink-text-input": "^6.0.0",
53
53
  "react": "^19.2.8",
54
- "@bendyline/gezel-catalog": "0.1.0",
55
- "@bendyline/gezel-app-sdk": "0.1.0",
56
- "@bendyline/gezel-client": "0.1.0",
57
- "@bendyline/gezel": "0.1.0",
58
- "@bendyline/gezel-service": "0.1.0"
54
+ "@bendyline/gezel": "1.0.0",
55
+ "@bendyline/gezel-app-sdk": "1.0.0",
56
+ "@bendyline/gezel-client": "1.0.0",
57
+ "@bendyline/gezel-service": "1.0.0",
58
+ "@bendyline/gezel-catalog": "1.0.0"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@types/node": "^24.13.3",