@bendyline/gezel-cli 1.0.5 → 1.0.7
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 +3 -3
- package/dist/app-author-command.js +464 -0
- package/dist/app-command.js +685 -0
- package/dist/bin/gezel-main.js +732 -25
- package/dist/handboek-export.js +729 -35
- package/dist/knowledge-command.js +351 -0
- package/dist/tui/index.js +692 -77
- package/package.json +10 -9
package/dist/tui/index.js
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
import { render } from "ink";
|
|
5
5
|
|
|
6
6
|
// src/tui/App.tsx
|
|
7
|
+
import {
|
|
8
|
+
pickRandomNameWithGender as pickRandomNameWithGender2
|
|
9
|
+
} from "@bendyline/gezel";
|
|
7
10
|
import { Box as Box6, Text as Text6, useApp, useInput as useInput4, useStdout } from "ink";
|
|
8
11
|
import { useCallback as useCallback2, useEffect as useEffect4, useMemo, useRef as useRef3, useState as useState5 } from "react";
|
|
9
12
|
|
|
@@ -195,6 +198,236 @@ function useBufferedState(initial, intervalMs) {
|
|
|
195
198
|
return [rendered, setImmediate, setBuffered];
|
|
196
199
|
}
|
|
197
200
|
|
|
201
|
+
// src/tui/managed-apps.ts
|
|
202
|
+
var MANAGED_APP_TARGETS = [
|
|
203
|
+
{
|
|
204
|
+
id: "vscode",
|
|
205
|
+
label: "VS Code",
|
|
206
|
+
aliases: ["vscode", "code", "vs-code"],
|
|
207
|
+
description: "add Gezel to VS Code\u2019s built-in model picker"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
id: "pi",
|
|
211
|
+
label: "pi",
|
|
212
|
+
aliases: ["pi"],
|
|
213
|
+
description: "add Gezel models and the managed pi extension"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
id: "opencode",
|
|
217
|
+
label: "OpenCode",
|
|
218
|
+
aliases: ["opencode", "open-code"],
|
|
219
|
+
description: "add Gezel settings and the managed OpenCode plugin"
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
id: "codex",
|
|
223
|
+
label: "Codex",
|
|
224
|
+
aliases: ["codex"],
|
|
225
|
+
description: "add a managed Gezel profile to Codex"
|
|
226
|
+
}
|
|
227
|
+
];
|
|
228
|
+
var ManagedAppCommandError = class extends Error {
|
|
229
|
+
constructor(message) {
|
|
230
|
+
super(message);
|
|
231
|
+
this.name = "ManagedAppCommandError";
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
function resolveManagedApp(value) {
|
|
235
|
+
const normalized = value.trim().toLowerCase();
|
|
236
|
+
return MANAGED_APP_TARGETS.find((target) => target.aliases.includes(normalized))?.id ?? null;
|
|
237
|
+
}
|
|
238
|
+
function managedAppUsage(command) {
|
|
239
|
+
return `usage: /${command} ${MANAGED_APP_TARGETS.map((target) => target.id).join("|")}`;
|
|
240
|
+
}
|
|
241
|
+
async function connectManagedApp(client, app) {
|
|
242
|
+
switch (app) {
|
|
243
|
+
case "vscode":
|
|
244
|
+
return connectVSCode(client);
|
|
245
|
+
case "pi":
|
|
246
|
+
return connectPi(client);
|
|
247
|
+
case "opencode":
|
|
248
|
+
return connectOpenCode(client);
|
|
249
|
+
case "codex":
|
|
250
|
+
return connectCodex(client);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
async function disconnectManagedApp(client, app) {
|
|
254
|
+
switch (app) {
|
|
255
|
+
case "vscode": {
|
|
256
|
+
const status = await client.getVSCodeSetupStatus();
|
|
257
|
+
if (!status.canRemove) return { app, message: "VS Code is not connected to Gezel." };
|
|
258
|
+
await client.removeVSCodeSetup();
|
|
259
|
+
return { app, message: "disconnected VS Code; other providers and conversations were kept." };
|
|
260
|
+
}
|
|
261
|
+
case "pi": {
|
|
262
|
+
const status = await client.getPiSetupStatus();
|
|
263
|
+
if (!status.canRemove && !status.extension.canRemove) {
|
|
264
|
+
return { app, message: "pi is not connected to Gezel." };
|
|
265
|
+
}
|
|
266
|
+
await client.removePiSetup();
|
|
267
|
+
return {
|
|
268
|
+
app,
|
|
269
|
+
message: "disconnected pi; its Gezel roster, credential, and managed extension were removed."
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
case "opencode": {
|
|
273
|
+
const status = await client.getOpenCodeSetupStatus();
|
|
274
|
+
if (!status.canRemove && !status.plugin.canRemove) {
|
|
275
|
+
return { app, message: "OpenCode is not connected to Gezel." };
|
|
276
|
+
}
|
|
277
|
+
await client.removeOpenCodeSetup();
|
|
278
|
+
return {
|
|
279
|
+
app,
|
|
280
|
+
message: "disconnected OpenCode; Gezel\u2019s settings, credential, and managed plugin were removed."
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
case "codex": {
|
|
284
|
+
const status = await client.getCodexSetupStatus();
|
|
285
|
+
if (!status.canRemove) return { app, message: "Codex is not connected to Gezel." };
|
|
286
|
+
await client.removeCodexSetup();
|
|
287
|
+
return {
|
|
288
|
+
app,
|
|
289
|
+
message: "disconnected Codex; other profiles, settings, and conversations were kept."
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
async function listConnectedManagedApps(client) {
|
|
295
|
+
const [vscode, pi, opencode, codex] = await Promise.all([
|
|
296
|
+
client.getVSCodeSetupStatus(),
|
|
297
|
+
client.getPiSetupStatus(),
|
|
298
|
+
client.getOpenCodeSetupStatus(),
|
|
299
|
+
client.getCodexSetupStatus()
|
|
300
|
+
]);
|
|
301
|
+
return [
|
|
302
|
+
...vscode.canRemove ? ["vscode"] : [],
|
|
303
|
+
...pi.canRemove || pi.extension.canRemove ? ["pi"] : [],
|
|
304
|
+
...opencode.canRemove || opencode.plugin.canRemove ? ["opencode"] : [],
|
|
305
|
+
...codex.canRemove ? ["codex"] : []
|
|
306
|
+
];
|
|
307
|
+
}
|
|
308
|
+
async function connectVSCode(client) {
|
|
309
|
+
let status = await client.getVSCodeSetupStatus();
|
|
310
|
+
const enabled = await enableConnectedAppsIfNeeded(client, status.endpointsEnabled);
|
|
311
|
+
if (enabled) status = await client.getVSCodeSetupStatus();
|
|
312
|
+
if (status.state !== "configured") {
|
|
313
|
+
assertSafeToConfigure(status, "VS Code");
|
|
314
|
+
const profile2 = status.profiles.find((candidate) => candidate.id === status.configuredProfileId) ?? status.profiles[0];
|
|
315
|
+
if (!profile2) throw new ManagedAppCommandError("VS Code has no profile Gezel can configure.");
|
|
316
|
+
status = await client.configureVSCode({ profileId: profile2.id });
|
|
317
|
+
}
|
|
318
|
+
const profile = status.profiles.find((candidate) => candidate.id === status.configuredProfileId) ?? status.profiles[0];
|
|
319
|
+
return {
|
|
320
|
+
app: "vscode",
|
|
321
|
+
message: [
|
|
322
|
+
`connected VS Code${profile ? ` (${profile.label})` : ""} to Gezel at ${status.bridge.baseUrl}.`,
|
|
323
|
+
enabled ? "Connected Apps serving was enabled." : "",
|
|
324
|
+
"If VS Code is open, run \u201CDeveloper: Reload Window\u201D once to load the provider."
|
|
325
|
+
].filter(Boolean).join(" ")
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
async function connectPi(client) {
|
|
329
|
+
let status = await client.getPiSetupStatus();
|
|
330
|
+
const enabled = await enableConnectedAppsIfNeeded(client, status.endpointsEnabled);
|
|
331
|
+
if (enabled) status = await client.getPiSetupStatus();
|
|
332
|
+
if (status.state !== "configured") {
|
|
333
|
+
assertSafeToConfigure(status, "pi");
|
|
334
|
+
const model = preferredModel(status);
|
|
335
|
+
status = await client.configurePi({ model: model.id });
|
|
336
|
+
}
|
|
337
|
+
let extensionNote = "";
|
|
338
|
+
if (status.extension.canInstall && !status.extension.canReplace) {
|
|
339
|
+
status = await client.installPiExtension();
|
|
340
|
+
extensionNote = "The managed pi extension was installed.";
|
|
341
|
+
} else if (status.extension.canReplace) {
|
|
342
|
+
extensionNote = "A conflicting pi extension was preserved; use the desktop Settings flow to review it.";
|
|
343
|
+
} else if (status.extension.state === "unsupported") {
|
|
344
|
+
extensionNote = "pi was not found, so use the launch command after installing it.";
|
|
345
|
+
}
|
|
346
|
+
return {
|
|
347
|
+
app: "pi",
|
|
348
|
+
message: integrationSuccessMessage("pi", status, enabled, extensionNote)
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
async function connectOpenCode(client) {
|
|
352
|
+
let status = await client.getOpenCodeSetupStatus();
|
|
353
|
+
const enabled = await enableConnectedAppsIfNeeded(client, status.endpointsEnabled);
|
|
354
|
+
if (enabled) status = await client.getOpenCodeSetupStatus();
|
|
355
|
+
if (status.state !== "configured") {
|
|
356
|
+
assertSafeToConfigure(status, "OpenCode");
|
|
357
|
+
const model = preferredModel(status);
|
|
358
|
+
status = await client.configureOpenCode({ model: model.id });
|
|
359
|
+
}
|
|
360
|
+
let pluginNote = "";
|
|
361
|
+
if (status.plugin.canInstall && !status.plugin.canReplace) {
|
|
362
|
+
status = await client.installOpenCodePlugin();
|
|
363
|
+
pluginNote = "The managed OpenCode plugin was installed.";
|
|
364
|
+
} else if (status.plugin.canReplace) {
|
|
365
|
+
pluginNote = "A conflicting OpenCode plugin was preserved; use the desktop Settings flow to review it.";
|
|
366
|
+
} else if (status.plugin.state === "unsupported") {
|
|
367
|
+
pluginNote = "OpenCode was not found, so use the launch command after installing it.";
|
|
368
|
+
}
|
|
369
|
+
return {
|
|
370
|
+
app: "opencode",
|
|
371
|
+
message: integrationSuccessMessage("OpenCode", status, enabled, pluginNote)
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
async function connectCodex(client) {
|
|
375
|
+
let status = await client.getCodexSetupStatus();
|
|
376
|
+
const enabled = await enableConnectedAppsIfNeeded(client, status.endpointsEnabled);
|
|
377
|
+
if (enabled) status = await client.getCodexSetupStatus();
|
|
378
|
+
if (status.state !== "configured") {
|
|
379
|
+
assertSafeToConfigure(status, "Codex");
|
|
380
|
+
const model = preferredModel(status);
|
|
381
|
+
status = await client.configureCodex({ model: model.id });
|
|
382
|
+
}
|
|
383
|
+
return {
|
|
384
|
+
app: "codex",
|
|
385
|
+
message: integrationSuccessMessage("Codex", status, enabled)
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
async function enableConnectedAppsIfNeeded(client, endpointsEnabled) {
|
|
389
|
+
if (endpointsEnabled) return false;
|
|
390
|
+
const config = await client.getConfig();
|
|
391
|
+
await client.updateConfig({
|
|
392
|
+
openaiEndpoints: {
|
|
393
|
+
...config.openaiEndpoints,
|
|
394
|
+
enabled: true
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
return true;
|
|
398
|
+
}
|
|
399
|
+
function preferredModel(status) {
|
|
400
|
+
const model = status.models.find((candidate) => candidate.id === status.configuredModel) ?? status.models.find((candidate) => candidate.id === status.recommendedModel) ?? status.models[0];
|
|
401
|
+
if (!model) {
|
|
402
|
+
throw new ManagedAppCommandError(
|
|
403
|
+
"No compatible local gezel or tool-capable model is available for this integration."
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
return model;
|
|
407
|
+
}
|
|
408
|
+
function assertSafeToConfigure(status, label) {
|
|
409
|
+
if (status.state === "conflict") {
|
|
410
|
+
throw new ManagedAppCommandError(
|
|
411
|
+
`${label} setup has a conflict${status.message ? `: ${status.message}` : "."} Nothing was overwritten; use Settings \u2192 Connected Apps to review and repair it.`
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
if (status.state === "unavailable" || !status.canConfigure) {
|
|
415
|
+
const reason = status.message ?? status.reasons[0];
|
|
416
|
+
throw new ManagedAppCommandError(
|
|
417
|
+
reason ? `${label} cannot be connected: ${reason}` : `${label} cannot be connected right now.`
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
function integrationSuccessMessage(label, status, enabled, extra = "") {
|
|
422
|
+
const selected = status.models.find((candidate) => candidate.id === status.configuredModel);
|
|
423
|
+
return [
|
|
424
|
+
`connected ${label} to Gezel at ${status.bridge.baseUrl}${selected ? `; default ${selected.label}` : ""}.`,
|
|
425
|
+
enabled ? "Connected Apps serving was enabled." : "",
|
|
426
|
+
extra,
|
|
427
|
+
`Start it with: ${status.launchCommand}`
|
|
428
|
+
].filter(Boolean).join(" ");
|
|
429
|
+
}
|
|
430
|
+
|
|
198
431
|
// src/tui/open-command.ts
|
|
199
432
|
var MAX_RECENT_REFERENCES = 12;
|
|
200
433
|
function rememberCliOpenReferences(current, observed, max = MAX_RECENT_REFERENCES) {
|
|
@@ -240,8 +473,14 @@ function referencesFromMessage(message, projectId) {
|
|
|
240
473
|
for (const tool of message.toolCalls ?? []) {
|
|
241
474
|
references.push(...referencesFromTool(tool, projectId));
|
|
242
475
|
}
|
|
243
|
-
|
|
244
|
-
|
|
476
|
+
if (message.referencedFiles?.length) {
|
|
477
|
+
for (const file of message.referencedFiles) {
|
|
478
|
+
references.push(reference(file.kind, file.path, projectId));
|
|
479
|
+
}
|
|
480
|
+
} else {
|
|
481
|
+
for (const path of message.referencedArtifacts ?? []) {
|
|
482
|
+
references.push(reference("artifact", path, projectId));
|
|
483
|
+
}
|
|
245
484
|
}
|
|
246
485
|
return references;
|
|
247
486
|
}
|
|
@@ -303,7 +542,7 @@ var SLASH_COMMAND_WORDWHEEL_SIZE = 4;
|
|
|
303
542
|
var SLASH_COMMANDS = [
|
|
304
543
|
{ name: "help", description: "show the command reference" },
|
|
305
544
|
{ name: "project", description: "switch active project" },
|
|
306
|
-
{ name: "gezel", description: "switch
|
|
545
|
+
{ name: "gezel", description: "switch gezel, or bring a role onto the project" },
|
|
307
546
|
{ name: "allow", description: "allow a project permission" },
|
|
308
547
|
{ name: "disallow", description: "disallow a project permission" },
|
|
309
548
|
{ name: "show", description: "show optional chat details" },
|
|
@@ -316,6 +555,8 @@ var SLASH_COMMANDS = [
|
|
|
316
555
|
{ name: "do", description: "do a task from a craftbook" },
|
|
317
556
|
{ name: "continue", description: "process due and active project tasks" },
|
|
318
557
|
{ name: "nightshift", description: "start, stop, or list night-shift work" },
|
|
558
|
+
{ name: "connect", description: "connect a local app to Gezel" },
|
|
559
|
+
{ name: "disconnect", description: "remove Gezel from a connected local app" },
|
|
319
560
|
{ name: "focus", description: "send into another active chat" },
|
|
320
561
|
{ name: "cli", description: "make bare input run shell commands" },
|
|
321
562
|
{ name: "chat", description: "make bare input message your gezel" },
|
|
@@ -372,6 +613,20 @@ function parseProjectPermissionName(input) {
|
|
|
372
613
|
return PROJECT_PERMISSIONS.find((permission) => permission.name === normalized)?.name;
|
|
373
614
|
}
|
|
374
615
|
function suggestSlashWordwheel(input, craftbooks, recentReferences = []) {
|
|
616
|
+
const appMatch = input.match(/^\/(connect|disconnect)\s+(.*)$/i);
|
|
617
|
+
if (appMatch) {
|
|
618
|
+
const command = (appMatch[1] ?? "").toLowerCase();
|
|
619
|
+
const query = (appMatch[2] ?? "").trim().toLowerCase();
|
|
620
|
+
return MANAGED_APP_TARGETS.filter(
|
|
621
|
+
(target) => target.id.startsWith(query) || target.aliases.some((alias) => alias.startsWith(query))
|
|
622
|
+
).map((target) => ({
|
|
623
|
+
key: `${command}:${target.id}`,
|
|
624
|
+
label: `/${command} ${target.id}`,
|
|
625
|
+
description: command === "connect" ? target.description : `remove Gezel\u2019s managed ${target.label} setup`,
|
|
626
|
+
submit: `/${command} ${target.id}`,
|
|
627
|
+
completion: `/${command} ${target.id}`
|
|
628
|
+
}));
|
|
629
|
+
}
|
|
375
630
|
const openMatch = input.match(/^\/open\s+(.*)$/i);
|
|
376
631
|
if (openMatch) {
|
|
377
632
|
const query = normalizeCliOpenLookup(openMatch[1] ?? "");
|
|
@@ -1251,16 +1506,16 @@ var TABLE_LOGO = [
|
|
|
1251
1506
|
" | /|____________|\\",
|
|
1252
1507
|
" o /_| |_\\"
|
|
1253
1508
|
].join("\n");
|
|
1254
|
-
var
|
|
1255
|
-
user: "white",
|
|
1256
|
-
pending: "yellow",
|
|
1257
|
-
assistant: "cyan",
|
|
1258
|
-
thinking: "
|
|
1259
|
-
write: "yellow",
|
|
1260
|
-
tool: "yellow",
|
|
1261
|
-
note: "magenta",
|
|
1262
|
-
error: "red",
|
|
1263
|
-
shell: void 0
|
|
1509
|
+
var CHAT_FEED_ROW_STYLES = {
|
|
1510
|
+
user: { color: "white", dimColor: false },
|
|
1511
|
+
pending: { color: "yellow", dimColor: true },
|
|
1512
|
+
assistant: { color: "cyan", dimColor: false },
|
|
1513
|
+
thinking: { color: "magentaBright", dimColor: false },
|
|
1514
|
+
write: { color: "yellow", dimColor: true },
|
|
1515
|
+
tool: { color: "yellow", dimColor: false },
|
|
1516
|
+
note: { color: "magenta", dimColor: false },
|
|
1517
|
+
error: { color: "red", dimColor: false },
|
|
1518
|
+
shell: { color: void 0, dimColor: false }
|
|
1264
1519
|
};
|
|
1265
1520
|
function ChatFeed(props) {
|
|
1266
1521
|
const { rows, gezels, boring, focusedSessionId, visible = 16 } = props;
|
|
@@ -1277,6 +1532,7 @@ function ChatFeed(props) {
|
|
|
1277
1532
|
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "/help for commands" })
|
|
1278
1533
|
] })
|
|
1279
1534
|
] }) : shown.map((row) => {
|
|
1535
|
+
const rowStyle = CHAT_FEED_ROW_STYLES[row.kind];
|
|
1280
1536
|
if (row.kind === "shell" && row.sessionId.startsWith("term-")) {
|
|
1281
1537
|
return /* @__PURE__ */ jsx(Text, { wrap: "wrap", children: clip(row.text) }, row.key);
|
|
1282
1538
|
}
|
|
@@ -1285,20 +1541,13 @@ function ChatFeed(props) {
|
|
|
1285
1541
|
return /* @__PURE__ */ jsxs(Box, { flexDirection: "row", children: [
|
|
1286
1542
|
/* @__PURE__ */ jsx(Text, { dimColor: !isFocused, color: isFocused ? "green" : void 0, children: isFocused ? "\u258E" : " " }),
|
|
1287
1543
|
/* @__PURE__ */ jsxs(Text, { wrap: "wrap", children: [
|
|
1288
|
-
/* @__PURE__ */ jsxs(Text, { bold: true, color:
|
|
1544
|
+
/* @__PURE__ */ jsxs(Text, { bold: true, color: rowStyle.color, children: [
|
|
1289
1545
|
who,
|
|
1290
1546
|
": "
|
|
1291
1547
|
] }),
|
|
1292
|
-
/* @__PURE__ */ jsx(
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
color: KIND_COLOR[row.kind],
|
|
1296
|
-
dimColor: row.kind === "pending" || row.kind === "thinking" || row.kind === "write",
|
|
1297
|
-
children: clip(
|
|
1298
|
-
row.taskEvent ? taskEventText(row, gezels, boring) : row.kind === "assistant" ? humanizeToolMarkup(row.text) : row.text
|
|
1299
|
-
)
|
|
1300
|
-
}
|
|
1301
|
-
)
|
|
1548
|
+
/* @__PURE__ */ jsx(Text, { color: rowStyle.color, dimColor: rowStyle.dimColor, children: clip(
|
|
1549
|
+
row.taskEvent ? taskEventText(row, gezels, boring) : row.kind === "assistant" ? humanizeToolMarkup(row.text) : row.text
|
|
1550
|
+
) })
|
|
1302
1551
|
] })
|
|
1303
1552
|
] }, row.key);
|
|
1304
1553
|
}) });
|
|
@@ -1373,13 +1622,18 @@ function Picker(props) {
|
|
|
1373
1622
|
] }) : null,
|
|
1374
1623
|
visibleItems.map((item, offset) => {
|
|
1375
1624
|
const itemIndex = start + offset;
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1625
|
+
const previousSection = offset === 0 ? void 0 : visibleItems[offset - 1]?.section;
|
|
1626
|
+
const showSection = item.section !== void 0 && item.section !== previousSection;
|
|
1627
|
+
return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", children: [
|
|
1628
|
+
showSection ? /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: item.section }) : null,
|
|
1629
|
+
/* @__PURE__ */ jsxs2(Text2, { color: itemIndex === index ? "green" : void 0, children: [
|
|
1630
|
+
itemIndex === index ? "\u276F " : " ",
|
|
1631
|
+
item.label,
|
|
1632
|
+
item.hint ? /* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
|
|
1633
|
+
" \u2014 ",
|
|
1634
|
+
item.hint
|
|
1635
|
+
] }) : null
|
|
1636
|
+
] })
|
|
1383
1637
|
] }, item.value);
|
|
1384
1638
|
}),
|
|
1385
1639
|
start + visibleItems.length < items.length ? /* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
|
|
@@ -1682,7 +1936,7 @@ function StandardQuestionPrompt(props) {
|
|
|
1682
1936
|
const visibleOptions = options.slice(windowStart, windowStart + QUESTION_OPTION_WINDOW_SIZE);
|
|
1683
1937
|
const submit = async (body) => {
|
|
1684
1938
|
if (submitting) return;
|
|
1685
|
-
if (!body.writeIn && (!body.selectedChoices || body.selectedChoices.length === 0)) {
|
|
1939
|
+
if (!body.writeIn && (!body.selectedChoices || body.selectedChoices.length === 0) && body.declined !== true && body.silentSkip !== true) {
|
|
1686
1940
|
setError("Choose an option or supply your own response.");
|
|
1687
1941
|
return;
|
|
1688
1942
|
}
|
|
@@ -1710,12 +1964,20 @@ function StandardQuestionPrompt(props) {
|
|
|
1710
1964
|
(input, key) => {
|
|
1711
1965
|
if (submitting) return;
|
|
1712
1966
|
if (writing) {
|
|
1713
|
-
if (key.escape
|
|
1714
|
-
|
|
1715
|
-
|
|
1967
|
+
if (key.escape) {
|
|
1968
|
+
if (choices.length > 0) {
|
|
1969
|
+
setWriting(false);
|
|
1970
|
+
setError(null);
|
|
1971
|
+
} else {
|
|
1972
|
+
void submit({ silentSkip: true });
|
|
1973
|
+
}
|
|
1716
1974
|
}
|
|
1717
1975
|
return;
|
|
1718
1976
|
}
|
|
1977
|
+
if (key.escape) {
|
|
1978
|
+
void submit({ silentSkip: true });
|
|
1979
|
+
return;
|
|
1980
|
+
}
|
|
1719
1981
|
if (key.upArrow) {
|
|
1720
1982
|
setOptionIndex((index) => index <= 0 ? Math.max(0, options.length - 1) : index - 1);
|
|
1721
1983
|
return;
|
|
@@ -1763,7 +2025,7 @@ function StandardQuestionPrompt(props) {
|
|
|
1763
2025
|
] }),
|
|
1764
2026
|
/* @__PURE__ */ jsxs5(Text5, { dimColor: true, children: [
|
|
1765
2027
|
"Enter submit",
|
|
1766
|
-
choices.length > 0 ? " \xB7 Esc return to choices" : ""
|
|
2028
|
+
choices.length > 0 ? " \xB7 Esc return to choices" : " \xB7 Esc skip"
|
|
1767
2029
|
] })
|
|
1768
2030
|
] }) : /* @__PURE__ */ jsxs5(Fragment3, { children: [
|
|
1769
2031
|
visibleOptions.map((option, visibleIndex) => {
|
|
@@ -1780,7 +2042,8 @@ function StandardQuestionPrompt(props) {
|
|
|
1780
2042
|
"\u2191/\u2193 choose \xB7 Enter ",
|
|
1781
2043
|
multiSelect ? "toggle/submit" : "answer",
|
|
1782
2044
|
multiSelect ? " \xB7 Space toggle" : "",
|
|
1783
|
-
options.length > QUESTION_OPTION_WINDOW_SIZE ? ` \xB7 ${activeOptionIndex + 1}/${options.length}` : ""
|
|
2045
|
+
options.length > QUESTION_OPTION_WINDOW_SIZE ? ` \xB7 ${activeOptionIndex + 1}/${options.length}` : "",
|
|
2046
|
+
" \xB7 Esc skip"
|
|
1784
2047
|
] })
|
|
1785
2048
|
] }),
|
|
1786
2049
|
submitting ? /* @__PURE__ */ jsx4(Text5, { color: "yellow", children: "Submitting\u2026" }) : null,
|
|
@@ -1803,10 +2066,18 @@ function NpmInstallApprovalPrompt(props) {
|
|
|
1803
2066
|
const [submitting, setSubmitting] = useState4(false);
|
|
1804
2067
|
const [error, setError] = useState4(null);
|
|
1805
2068
|
const currentPackage = packages[packageIndex];
|
|
1806
|
-
const
|
|
2069
|
+
const answer = async (body) => {
|
|
1807
2070
|
if (submitting) return;
|
|
1808
2071
|
setError(null);
|
|
1809
2072
|
setSubmitting(true);
|
|
2073
|
+
try {
|
|
2074
|
+
onAnswered(await client.answerQuestion(question.id, body));
|
|
2075
|
+
} catch (err) {
|
|
2076
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
2077
|
+
setSubmitting(false);
|
|
2078
|
+
}
|
|
2079
|
+
};
|
|
2080
|
+
const submit = (nextDecisions) => {
|
|
1810
2081
|
const body = packages.length === 0 ? { declined: true } : {
|
|
1811
2082
|
npmInstallDecisions: packages.map((entry, index) => ({
|
|
1812
2083
|
package: entry.package,
|
|
@@ -1814,18 +2085,17 @@ function NpmInstallApprovalPrompt(props) {
|
|
|
1814
2085
|
decision: nextDecisions[index] ?? "decline"
|
|
1815
2086
|
}))
|
|
1816
2087
|
};
|
|
1817
|
-
|
|
1818
|
-
onAnswered(await client.answerQuestion(question.id, body));
|
|
1819
|
-
} catch (err) {
|
|
1820
|
-
setError(err instanceof Error ? err.message : String(err));
|
|
1821
|
-
setSubmitting(false);
|
|
1822
|
-
}
|
|
2088
|
+
void answer(body);
|
|
1823
2089
|
};
|
|
1824
2090
|
useInput3(
|
|
1825
2091
|
(_input, key) => {
|
|
1826
2092
|
if (submitting) return;
|
|
2093
|
+
if (key.escape) {
|
|
2094
|
+
void answer({ silentSkip: true });
|
|
2095
|
+
return;
|
|
2096
|
+
}
|
|
1827
2097
|
if (!currentPackage) {
|
|
1828
|
-
if (key.return)
|
|
2098
|
+
if (key.return) submit([]);
|
|
1829
2099
|
return;
|
|
1830
2100
|
}
|
|
1831
2101
|
if (key.upArrow) {
|
|
@@ -1855,7 +2125,7 @@ function NpmInstallApprovalPrompt(props) {
|
|
|
1855
2125
|
nextDecisions[packageIndex] = decision;
|
|
1856
2126
|
setDecisions(nextDecisions);
|
|
1857
2127
|
if (packageIndex >= packages.length - 1) {
|
|
1858
|
-
|
|
2128
|
+
submit(nextDecisions);
|
|
1859
2129
|
return;
|
|
1860
2130
|
}
|
|
1861
2131
|
const nextPackageIndex = packageIndex + 1;
|
|
@@ -1898,12 +2168,13 @@ function NpmInstallApprovalPrompt(props) {
|
|
|
1898
2168
|
}),
|
|
1899
2169
|
/* @__PURE__ */ jsxs5(Text5, { dimColor: true, children: [
|
|
1900
2170
|
"\u2191/\u2193 choose \xB7 Enter answer",
|
|
1901
|
-
packageIndex > 0 ? " \xB7 \u2190 previous package" : ""
|
|
2171
|
+
packageIndex > 0 ? " \xB7 \u2190 previous package" : "",
|
|
2172
|
+
" \xB7 Esc skip"
|
|
1902
2173
|
] })
|
|
1903
2174
|
] }) : /* @__PURE__ */ jsxs5(Fragment3, { children: [
|
|
1904
2175
|
/* @__PURE__ */ jsx4(Text5, { color: "red", children: "This approval has no package details." }),
|
|
1905
2176
|
/* @__PURE__ */ jsx4(Text5, { color: "cyan", children: "\u203A Decline and dismiss" }),
|
|
1906
|
-
/* @__PURE__ */ jsx4(Text5, { dimColor: true, children: "Enter dismiss" })
|
|
2177
|
+
/* @__PURE__ */ jsx4(Text5, { dimColor: true, children: "Enter dismiss \xB7 Esc skip" })
|
|
1907
2178
|
] }),
|
|
1908
2179
|
submitting ? /* @__PURE__ */ jsx4(Text5, { color: "yellow", children: "Submitting\u2026" }) : null,
|
|
1909
2180
|
error ? /* @__PURE__ */ jsx4(Text5, { color: "red", children: error }) : null
|
|
@@ -1918,7 +2189,10 @@ function toggleSet(current, value) {
|
|
|
1918
2189
|
|
|
1919
2190
|
// src/tui/craftbook-start.ts
|
|
1920
2191
|
import {
|
|
2192
|
+
CRAFTBOOK_CATEGORY_FAMILY_META,
|
|
2193
|
+
CRAFTBOOK_CATEGORY_META,
|
|
1921
2194
|
CRAFTBOOK_ROLE_META,
|
|
2195
|
+
resolveCraftbookCategory,
|
|
1922
2196
|
visibleCatalogItems
|
|
1923
2197
|
} from "@bendyline/gezel";
|
|
1924
2198
|
function normalizeCraftbooks(items, showWorkInProgressFeatures = false) {
|
|
@@ -1936,7 +2210,8 @@ function normalizeCraftbooks(items, showWorkInProgressFeatures = false) {
|
|
|
1936
2210
|
source: item.sourceId === "project" ? "project" : item.sourceId === "local" ? "local" : "bundled",
|
|
1937
2211
|
stepCount: manifest.steps.length,
|
|
1938
2212
|
tags: manifest.tags ?? [],
|
|
1939
|
-
role: manifest.role ?? "general"
|
|
2213
|
+
role: manifest.role ?? "general",
|
|
2214
|
+
category: resolveCraftbookCategory(manifest)
|
|
1940
2215
|
});
|
|
1941
2216
|
}
|
|
1942
2217
|
return [...byId.values()].sort((left, right) => left.name.localeCompare(right.name));
|
|
@@ -1964,15 +2239,34 @@ function craftbookCategories(books, suggestedIds, projectType) {
|
|
|
1964
2239
|
bookIds: projectBooks
|
|
1965
2240
|
});
|
|
1966
2241
|
}
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
2242
|
+
const starterMeta = CRAFTBOOK_ROLE_META.find((role) => role.id === "project-starter");
|
|
2243
|
+
if (starterMeta) {
|
|
2244
|
+
const bookIds = new Set(
|
|
2245
|
+
books.filter((book) => book.role === "project-starter").map((book) => book.id)
|
|
2246
|
+
);
|
|
2247
|
+
if (bookIds.size > 0) {
|
|
2248
|
+
categories.push({
|
|
2249
|
+
id: `role:${starterMeta.id}`,
|
|
2250
|
+
label: starterMeta.label,
|
|
2251
|
+
hint: countLabel(bookIds.size),
|
|
2252
|
+
bookIds
|
|
2253
|
+
});
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
for (const family of CRAFTBOOK_CATEGORY_FAMILY_META) {
|
|
2257
|
+
for (const meta of CRAFTBOOK_CATEGORY_META) {
|
|
2258
|
+
if (meta.family !== family.id) continue;
|
|
2259
|
+
const bookIds = new Set(
|
|
2260
|
+
books.filter((book) => book.category === meta.id).map((book) => book.id)
|
|
2261
|
+
);
|
|
2262
|
+
if (bookIds.size === 0) continue;
|
|
2263
|
+
categories.push({
|
|
2264
|
+
id: `category:${meta.id}`,
|
|
2265
|
+
label: meta.label,
|
|
2266
|
+
hint: family.id === "universal" ? countLabel(bookIds.size) : `${family.label} \xB7 ${countLabel(bookIds.size)}`,
|
|
2267
|
+
bookIds
|
|
2268
|
+
});
|
|
2269
|
+
}
|
|
1976
2270
|
}
|
|
1977
2271
|
categories.push({
|
|
1978
2272
|
id: "all",
|
|
@@ -2002,6 +2296,167 @@ function craftbookStartRequest(book) {
|
|
|
2002
2296
|
};
|
|
2003
2297
|
}
|
|
2004
2298
|
|
|
2299
|
+
// src/tui/gezel-picker.ts
|
|
2300
|
+
import {
|
|
2301
|
+
getProjectType,
|
|
2302
|
+
resolveProjectTypeId
|
|
2303
|
+
} from "@bendyline/gezel";
|
|
2304
|
+
var GEZEL_VALUE_PREFIX = "gezel:";
|
|
2305
|
+
var TEMPLATE_VALUE_PREFIX = "template:";
|
|
2306
|
+
var CORE_ROLE_ORDER = [
|
|
2307
|
+
"voorman",
|
|
2308
|
+
"builder",
|
|
2309
|
+
"developer",
|
|
2310
|
+
"reviewer",
|
|
2311
|
+
"planner",
|
|
2312
|
+
"researcher",
|
|
2313
|
+
"designer",
|
|
2314
|
+
"copywriter",
|
|
2315
|
+
"meester",
|
|
2316
|
+
"image-generator",
|
|
2317
|
+
"video-generator"
|
|
2318
|
+
];
|
|
2319
|
+
var SECTION_IN_PROJECT = "In this project";
|
|
2320
|
+
var SECTION_RECOMMENDED = "Recommended for this project";
|
|
2321
|
+
var SECTION_OTHER_GEZELS = "Your other gezels";
|
|
2322
|
+
var SECTION_CORE = "Core roles";
|
|
2323
|
+
var SECTION_MORE = "More roles";
|
|
2324
|
+
var DEFAULT_HINT_WIDTH = 76;
|
|
2325
|
+
function clip2(text, width) {
|
|
2326
|
+
const flat = text.replace(/\s+/g, " ").trim();
|
|
2327
|
+
if (flat.length <= width) return flat;
|
|
2328
|
+
return `${flat.slice(0, Math.max(1, width - 1)).trimEnd()}\u2026`;
|
|
2329
|
+
}
|
|
2330
|
+
function roleIdentity(value) {
|
|
2331
|
+
return (value ?? "").trim().toLowerCase();
|
|
2332
|
+
}
|
|
2333
|
+
function displayName(gezel, roleBasedNameOnly) {
|
|
2334
|
+
if (roleBasedNameOnly) return gezel.roleBasedName ?? gezel.role ?? gezel.id;
|
|
2335
|
+
return gezel.name;
|
|
2336
|
+
}
|
|
2337
|
+
function affinityRanks(project) {
|
|
2338
|
+
const type = getProjectType(resolveProjectTypeId(project ?? {}));
|
|
2339
|
+
const out = /* @__PURE__ */ new Map();
|
|
2340
|
+
let rank = 0;
|
|
2341
|
+
const add = (role) => {
|
|
2342
|
+
if (!out.has(role.templateId)) out.set(role.templateId, { rank: rank++, reason: role.reason });
|
|
2343
|
+
};
|
|
2344
|
+
for (const role of type?.gezelRoles.default ?? []) add(role);
|
|
2345
|
+
for (const role of type?.gezelRoles.suggested ?? []) add(role);
|
|
2346
|
+
return out;
|
|
2347
|
+
}
|
|
2348
|
+
function gezelHint(gezel, templatesById, roleBasedNameOnly) {
|
|
2349
|
+
const role = roleBasedNameOnly ? void 0 : gezel.roleBasedName ?? gezel.role;
|
|
2350
|
+
const about = gezel.description ?? (gezel.templateId ? templatesById.get(gezel.templateId)?.description : void 0);
|
|
2351
|
+
return [role, about].filter(Boolean).join(" \xB7 ");
|
|
2352
|
+
}
|
|
2353
|
+
function buildGezelPickerItems(inputs) {
|
|
2354
|
+
const {
|
|
2355
|
+
gezels,
|
|
2356
|
+
templates,
|
|
2357
|
+
memberIds,
|
|
2358
|
+
project,
|
|
2359
|
+
roleBasedNameOnly = false,
|
|
2360
|
+
hintWidth = DEFAULT_HINT_WIDTH
|
|
2361
|
+
} = inputs;
|
|
2362
|
+
const templatesById = new Map(templates.map((t) => [t.id, t]));
|
|
2363
|
+
const members = new Set(memberIds);
|
|
2364
|
+
const affinity = affinityRanks(project);
|
|
2365
|
+
const filledTemplateIds = new Set(gezels.flatMap((g) => g.templateId ? [g.templateId] : []));
|
|
2366
|
+
const filledRoleIdentities = new Set(
|
|
2367
|
+
gezels.flatMap((g) => [roleIdentity(g.role), roleIdentity(g.roleBasedName)].filter(Boolean))
|
|
2368
|
+
);
|
|
2369
|
+
const coreRank = new Map(CORE_ROLE_ORDER.map((id, index) => [id, index]));
|
|
2370
|
+
const items = [];
|
|
2371
|
+
const push = (section, item) => {
|
|
2372
|
+
items.push({ ...item, section });
|
|
2373
|
+
};
|
|
2374
|
+
const gezelItem = (gezel) => ({
|
|
2375
|
+
label: displayName(gezel, roleBasedNameOnly),
|
|
2376
|
+
value: `${GEZEL_VALUE_PREFIX}${gezel.id}`,
|
|
2377
|
+
hint: clip2(gezelHint(gezel, templatesById, roleBasedNameOnly), hintWidth)
|
|
2378
|
+
});
|
|
2379
|
+
const templateItem = (template, reason) => ({
|
|
2380
|
+
label: template.name,
|
|
2381
|
+
value: `${TEMPLATE_VALUE_PREFIX}${template.id}`,
|
|
2382
|
+
hint: clip2(reason ?? template.description, hintWidth)
|
|
2383
|
+
});
|
|
2384
|
+
const onProject = gezels.filter((g) => members.has(g.id));
|
|
2385
|
+
for (const gezel of sortByName(onProject, roleBasedNameOnly)) {
|
|
2386
|
+
push(SECTION_IN_PROJECT, gezelItem(gezel));
|
|
2387
|
+
}
|
|
2388
|
+
const offProject = gezels.filter((g) => !members.has(g.id));
|
|
2389
|
+
const affinityFor = (gezel) => {
|
|
2390
|
+
if (gezel.templateId && affinity.has(gezel.templateId)) return affinity.get(gezel.templateId);
|
|
2391
|
+
for (const [templateId, entry] of affinity) {
|
|
2392
|
+
const template = templatesById.get(templateId);
|
|
2393
|
+
if (!template) continue;
|
|
2394
|
+
if (roleIdentity(template.role) === roleIdentity(gezel.role) || roleIdentity(template.name) === roleIdentity(gezel.roleBasedName)) {
|
|
2395
|
+
return entry;
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
return void 0;
|
|
2399
|
+
};
|
|
2400
|
+
const recommendedGezels = offProject.flatMap((gezel) => {
|
|
2401
|
+
const entry = affinityFor(gezel);
|
|
2402
|
+
return entry ? [{ gezel, entry }] : [];
|
|
2403
|
+
}).sort((a, b) => a.entry.rank - b.entry.rank);
|
|
2404
|
+
const recommendedGezelIds = new Set(recommendedGezels.map((r) => r.gezel.id));
|
|
2405
|
+
const availableTemplates = templates.filter(
|
|
2406
|
+
(template) => !filledTemplateIds.has(template.id) && !filledRoleIdentities.has(roleIdentity(template.role)) && !filledRoleIdentities.has(roleIdentity(template.name))
|
|
2407
|
+
);
|
|
2408
|
+
const recommendedTemplates = availableTemplates.flatMap((template) => {
|
|
2409
|
+
const entry = affinity.get(template.id);
|
|
2410
|
+
return entry ? [{ template, entry }] : [];
|
|
2411
|
+
}).sort((a, b) => a.entry.rank - b.entry.rank);
|
|
2412
|
+
const recommendedTemplateIds = new Set(recommendedTemplates.map((r) => r.template.id));
|
|
2413
|
+
for (const { gezel, entry } of recommendedGezels) {
|
|
2414
|
+
push(SECTION_RECOMMENDED, { ...gezelItem(gezel), hint: clip2(entry.reason, hintWidth) });
|
|
2415
|
+
}
|
|
2416
|
+
for (const { template, entry } of recommendedTemplates) {
|
|
2417
|
+
push(SECTION_RECOMMENDED, templateItem(template, entry.reason));
|
|
2418
|
+
}
|
|
2419
|
+
for (const gezel of sortByName(
|
|
2420
|
+
offProject.filter((g) => !recommendedGezelIds.has(g.id)),
|
|
2421
|
+
roleBasedNameOnly
|
|
2422
|
+
)) {
|
|
2423
|
+
push(SECTION_OTHER_GEZELS, gezelItem(gezel));
|
|
2424
|
+
}
|
|
2425
|
+
const remaining = availableTemplates.filter((t) => !recommendedTemplateIds.has(t.id));
|
|
2426
|
+
const core = remaining.filter((t) => coreRank.has(t.id)).sort((a, b) => (coreRank.get(a.id) ?? 0) - (coreRank.get(b.id) ?? 0));
|
|
2427
|
+
const more = remaining.filter((t) => !coreRank.has(t.id)).sort((a, b) => a.name.localeCompare(b.name));
|
|
2428
|
+
for (const template of core) push(SECTION_CORE, templateItem(template));
|
|
2429
|
+
for (const template of more) push(SECTION_MORE, templateItem(template));
|
|
2430
|
+
return items;
|
|
2431
|
+
}
|
|
2432
|
+
function sortByName(gezels, roleBasedNameOnly) {
|
|
2433
|
+
return [...gezels].sort(
|
|
2434
|
+
(a, b) => displayName(a, roleBasedNameOnly).localeCompare(displayName(b, roleBasedNameOnly))
|
|
2435
|
+
);
|
|
2436
|
+
}
|
|
2437
|
+
function resolveGezelArg(arg, inputs) {
|
|
2438
|
+
const query = arg.trim().toLowerCase();
|
|
2439
|
+
if (!query) return { kind: "unknown" };
|
|
2440
|
+
const { gezels, templates } = inputs;
|
|
2441
|
+
const gezelKeys = (g) => [g.id, g.name, g.roleBasedName, g.role].map(roleIdentity).filter(Boolean);
|
|
2442
|
+
const templateKeys = (t) => [t.id, t.role, t.name].map(roleIdentity).filter(Boolean);
|
|
2443
|
+
const exactGezel = gezels.find((g) => gezelKeys(g).includes(query));
|
|
2444
|
+
if (exactGezel) return { kind: "gezel", gezelId: exactGezel.id };
|
|
2445
|
+
const exactTemplate = templates.find((t) => templateKeys(t).includes(query));
|
|
2446
|
+
if (exactTemplate) return { kind: "template", templateId: exactTemplate.id };
|
|
2447
|
+
const prefixGezels = gezels.filter((g) => gezelKeys(g).some((k) => k.startsWith(query)));
|
|
2448
|
+
if (prefixGezels.length === 1) return { kind: "gezel", gezelId: prefixGezels[0].id };
|
|
2449
|
+
if (prefixGezels.length > 1) {
|
|
2450
|
+
return { kind: "ambiguous", labels: prefixGezels.map((g) => g.name) };
|
|
2451
|
+
}
|
|
2452
|
+
const prefixTemplates = templates.filter((t) => templateKeys(t).some((k) => k.startsWith(query)));
|
|
2453
|
+
if (prefixTemplates.length === 1) return { kind: "template", templateId: prefixTemplates[0].id };
|
|
2454
|
+
if (prefixTemplates.length > 1) {
|
|
2455
|
+
return { kind: "ambiguous", labels: prefixTemplates.map((t) => t.name) };
|
|
2456
|
+
}
|
|
2457
|
+
return { kind: "unknown" };
|
|
2458
|
+
}
|
|
2459
|
+
|
|
2005
2460
|
// src/tui/model-picker.ts
|
|
2006
2461
|
import {
|
|
2007
2462
|
formatModelAttribution as formatModelAttribution2
|
|
@@ -2414,7 +2869,8 @@ function useTerminalSize() {
|
|
|
2414
2869
|
return size;
|
|
2415
2870
|
}
|
|
2416
2871
|
var HELP = [
|
|
2417
|
-
"/project \u2014 switch project /
|
|
2872
|
+
"/project \u2014 switch project /model \u2014 switch engine + model",
|
|
2873
|
+
"/gezel \u2014 switch gezel or bring on a role /gezel <role or name> \u2014 go straight there",
|
|
2418
2874
|
"/model download \u2014 choose and download a new on-device model",
|
|
2419
2875
|
"/allow edits \u2014 allow tool edits /disallow edits \u2014 make tool edits read-only",
|
|
2420
2876
|
"/allow codexedits|claudeedits \u2014 allow provider-native project edits",
|
|
@@ -2428,6 +2884,8 @@ var HELP = [
|
|
|
2428
2884
|
"/do \u2014 choose a craftbook and start it as a task",
|
|
2429
2885
|
"/continue \u2014 process due schedules and active tasks in this project",
|
|
2430
2886
|
"/nightshift start|stop|list \u2014 manage Night Shift",
|
|
2887
|
+
"/connect vscode|pi|opencode|codex \u2014 connect a local app to Gezel",
|
|
2888
|
+
"/disconnect [vscode|pi|opencode|codex] \u2014 remove one managed app setup",
|
|
2431
2889
|
"/focus \u2014 send into another active chat /cli \u2014 CLI mode /chat \u2014 chat mode",
|
|
2432
2890
|
"!cmd \u2014 run shell @tools \u2014 list tools @tool <name> {json} \u2014 run a tool",
|
|
2433
2891
|
"/clear \u2014 clear feed /quit \u2014 exit",
|
|
@@ -2457,6 +2915,8 @@ function App(props) {
|
|
|
2457
2915
|
const [modelDownloadReturn, setModelDownloadReturn] = useState5(null);
|
|
2458
2916
|
const [modelChoicesLoading, setModelChoicesLoading] = useState5(false);
|
|
2459
2917
|
const [threadsLoading, setThreadsLoading] = useState5(false);
|
|
2918
|
+
const [gezelPickerItems, setGezelPickerItems] = useState5([]);
|
|
2919
|
+
const [roleTemplates, setRoleTemplates] = useState5([]);
|
|
2460
2920
|
const [pendingQuestions, setPendingQuestions] = useState5([]);
|
|
2461
2921
|
const [projectId, setProjectId] = useState5(props.initialProjectId);
|
|
2462
2922
|
const [projectName, setProjectName] = useState5(props.initialProjectName);
|
|
@@ -2488,7 +2948,8 @@ function App(props) {
|
|
|
2488
2948
|
const wordwheelRows = wordwheelCount > 0 ? Math.min(SLASH_COMMAND_WORDWHEEL_SIZE, wordwheelCount) + 1 : 0;
|
|
2489
2949
|
const questionRows = pendingQuestion ? Math.min(QUESTION_OPTION_WINDOW_SIZE, Math.max(1, questionOptionCount(pendingQuestion))) + 4 : 0;
|
|
2490
2950
|
const modelPickerWindowSize = Math.max(4, Math.min(10, termRows - 12));
|
|
2491
|
-
const
|
|
2951
|
+
const gezelPickerWindowSize = Math.max(4, Math.min(10, termRows - 17));
|
|
2952
|
+
const inventoryPickerRows = overlay === "model" || overlay === "model-download" || overlay === "start-category" || overlay === "start-craftbook" ? modelPickerWindowSize + 5 : overlay === "gezel" ? gezelPickerWindowSize + 10 : 0;
|
|
2492
2953
|
const visibleRows = Math.max(
|
|
2493
2954
|
4,
|
|
2494
2955
|
termRows - 7 - wordwheelRows - questionRows - inventoryPickerRows
|
|
@@ -2694,6 +3155,119 @@ function App(props) {
|
|
|
2694
3155
|
},
|
|
2695
3156
|
[client, ensureSession, note, projectId, projects, setRows, setTurns]
|
|
2696
3157
|
);
|
|
3158
|
+
const loadRoleTemplates = useCallback2(async () => {
|
|
3159
|
+
if (roleTemplates.length > 0) return roleTemplates;
|
|
3160
|
+
try {
|
|
3161
|
+
const { items } = await client.listCatalogItems("gezel-template");
|
|
3162
|
+
const byId = /* @__PURE__ */ new Map();
|
|
3163
|
+
for (const item of items) {
|
|
3164
|
+
const manifest = item.manifest;
|
|
3165
|
+
if (manifest.kind !== "gezel-template" || byId.has(manifest.id)) continue;
|
|
3166
|
+
byId.set(manifest.id, {
|
|
3167
|
+
id: manifest.id,
|
|
3168
|
+
name: manifest.name,
|
|
3169
|
+
role: manifest.role,
|
|
3170
|
+
description: manifest.description
|
|
3171
|
+
});
|
|
3172
|
+
}
|
|
3173
|
+
const loaded = [...byId.values()];
|
|
3174
|
+
setRoleTemplates(loaded);
|
|
3175
|
+
return loaded;
|
|
3176
|
+
} catch (err) {
|
|
3177
|
+
note(`could not load the role catalog: ${errMsg(err)}`, "error");
|
|
3178
|
+
return [];
|
|
3179
|
+
}
|
|
3180
|
+
}, [client, note, roleTemplates]);
|
|
3181
|
+
const promoteSoloProject = useCallback2(
|
|
3182
|
+
async (joinedGezelId) => {
|
|
3183
|
+
try {
|
|
3184
|
+
const project = await client.getProject(projectId);
|
|
3185
|
+
if (project.mode !== "solo") return;
|
|
3186
|
+
if (project.voormanGezelId === joinedGezelId) return;
|
|
3187
|
+
await client.updateProject(projectId, { mode: "crew" });
|
|
3188
|
+
note("this job is now a crew project \u2014 gezels here can delegate and recruit.");
|
|
3189
|
+
} catch (err) {
|
|
3190
|
+
note(`could not switch this job to a crew project: ${errMsg(err)}`, "error");
|
|
3191
|
+
}
|
|
3192
|
+
},
|
|
3193
|
+
[client, note, projectId]
|
|
3194
|
+
);
|
|
3195
|
+
const useGezel = useCallback2(
|
|
3196
|
+
async (gezelId) => {
|
|
3197
|
+
if (gezelId === activeGezelId) return;
|
|
3198
|
+
try {
|
|
3199
|
+
const { added } = await client.addGezelToProject(projectId, gezelId);
|
|
3200
|
+
if (added) await promoteSoloProject(gezelId);
|
|
3201
|
+
} catch (err) {
|
|
3202
|
+
note(`could not add to the project roster: ${errMsg(err)}`, "error");
|
|
3203
|
+
}
|
|
3204
|
+
setActiveGezelId(gezelId);
|
|
3205
|
+
setThreads([]);
|
|
3206
|
+
setActiveThreadTitle(null);
|
|
3207
|
+
await ensureSession(gezelId, projectId);
|
|
3208
|
+
},
|
|
3209
|
+
[activeGezelId, client, ensureSession, note, projectId, promoteSoloProject]
|
|
3210
|
+
);
|
|
3211
|
+
const recruitGezel = useCallback2(
|
|
3212
|
+
async (templateId) => {
|
|
3213
|
+
note(`recruiting ${templateId}\u2026`);
|
|
3214
|
+
try {
|
|
3215
|
+
const { name, gender } = pickRandomNameWithGender2();
|
|
3216
|
+
const gezel = await client.createGezelFromTemplate(templateId, { name, gender });
|
|
3217
|
+
await refreshGezels();
|
|
3218
|
+
note(`${gezel.name} joined the project as ${gezel.role ?? templateId}.`);
|
|
3219
|
+
await useGezel(gezel.id);
|
|
3220
|
+
} catch (err) {
|
|
3221
|
+
note(`could not recruit ${templateId}: ${errMsg(err)}`, "error");
|
|
3222
|
+
}
|
|
3223
|
+
},
|
|
3224
|
+
[client, note, refreshGezels, useGezel]
|
|
3225
|
+
);
|
|
3226
|
+
const openGezelPicker = useCallback2(async () => {
|
|
3227
|
+
const templates = await loadRoleTemplates();
|
|
3228
|
+
let project = null;
|
|
3229
|
+
try {
|
|
3230
|
+
project = await client.getProject(projectId);
|
|
3231
|
+
} catch {
|
|
3232
|
+
}
|
|
3233
|
+
setGezelPickerItems(
|
|
3234
|
+
buildGezelPickerItems({
|
|
3235
|
+
gezels,
|
|
3236
|
+
templates,
|
|
3237
|
+
memberIds: [
|
|
3238
|
+
// Without the project record we only know the gezel we are talking
|
|
3239
|
+
// to. Claiming the whole roster is "in this project" would be a
|
|
3240
|
+
// guess the header presents as fact.
|
|
3241
|
+
...project?.gezelIds ?? (activeGezelId ? [activeGezelId] : []),
|
|
3242
|
+
...project?.voormanGezelId ? [project.voormanGezelId] : []
|
|
3243
|
+
],
|
|
3244
|
+
...project ? { project } : {},
|
|
3245
|
+
roleBasedNameOnly: boring,
|
|
3246
|
+
hintWidth: Math.max(24, shellColumns - 34)
|
|
3247
|
+
})
|
|
3248
|
+
);
|
|
3249
|
+
setOverlay("gezel");
|
|
3250
|
+
}, [activeGezelId, boring, client, gezels, loadRoleTemplates, projectId, shellColumns]);
|
|
3251
|
+
const ensureGezelByName = useCallback2(
|
|
3252
|
+
async (arg) => {
|
|
3253
|
+
const templates = await loadRoleTemplates();
|
|
3254
|
+
const resolved = resolveGezelArg(arg, { gezels, templates });
|
|
3255
|
+
switch (resolved.kind) {
|
|
3256
|
+
case "gezel":
|
|
3257
|
+
return useGezel(resolved.gezelId);
|
|
3258
|
+
case "template":
|
|
3259
|
+
return recruitGezel(resolved.templateId);
|
|
3260
|
+
case "ambiguous":
|
|
3261
|
+
return note(
|
|
3262
|
+
`"${arg}" matches ${resolved.labels.join(", ")} \u2014 be more specific.`,
|
|
3263
|
+
"error"
|
|
3264
|
+
);
|
|
3265
|
+
default:
|
|
3266
|
+
return note(`no gezel or role matches "${arg}". Type /gezel to browse.`, "error");
|
|
3267
|
+
}
|
|
3268
|
+
},
|
|
3269
|
+
[gezels, loadRoleTemplates, note, recruitGezel, useGezel]
|
|
3270
|
+
);
|
|
2697
3271
|
const openModelPicker = useCallback2(async () => {
|
|
2698
3272
|
if (!activeGezelId || !activeGezel) return note("no active gezel yet.", "error");
|
|
2699
3273
|
if (activeGezel.fixedFunction) {
|
|
@@ -3209,8 +3783,11 @@ function App(props) {
|
|
|
3209
3783
|
return;
|
|
3210
3784
|
case "project":
|
|
3211
3785
|
return setOverlay("project");
|
|
3212
|
-
case "gezel":
|
|
3213
|
-
|
|
3786
|
+
case "gezel": {
|
|
3787
|
+
const target = rest.trim();
|
|
3788
|
+
if (target) return ensureGezelByName(target);
|
|
3789
|
+
return openGezelPicker();
|
|
3790
|
+
}
|
|
3214
3791
|
case "allow":
|
|
3215
3792
|
await applyProjectPermission(rest, true);
|
|
3216
3793
|
return;
|
|
@@ -3364,6 +3941,44 @@ function App(props) {
|
|
|
3364
3941
|
}
|
|
3365
3942
|
return;
|
|
3366
3943
|
}
|
|
3944
|
+
case "connect": {
|
|
3945
|
+
const app = resolveManagedApp(rest);
|
|
3946
|
+
if (!app) return note(managedAppUsage("connect"), "error");
|
|
3947
|
+
note(`connecting ${app}\u2026`);
|
|
3948
|
+
try {
|
|
3949
|
+
const result = await connectManagedApp(client, app);
|
|
3950
|
+
note(result.message);
|
|
3951
|
+
} catch (err) {
|
|
3952
|
+
note(`could not connect ${app}: ${errMsg(err)}`, "error");
|
|
3953
|
+
}
|
|
3954
|
+
return;
|
|
3955
|
+
}
|
|
3956
|
+
case "disconnect": {
|
|
3957
|
+
let app = resolveManagedApp(rest);
|
|
3958
|
+
if (!rest.trim()) {
|
|
3959
|
+
try {
|
|
3960
|
+
const connected = await listConnectedManagedApps(client);
|
|
3961
|
+
if (connected.length === 0) return note("no managed local apps are connected.");
|
|
3962
|
+
if (connected.length > 1) {
|
|
3963
|
+
return note(
|
|
3964
|
+
`more than one app is connected (${connected.join(", ")}); ${managedAppUsage("disconnect")}`,
|
|
3965
|
+
"error"
|
|
3966
|
+
);
|
|
3967
|
+
}
|
|
3968
|
+
app = connected[0] ?? null;
|
|
3969
|
+
} catch (err) {
|
|
3970
|
+
return note(`could not inspect connected apps: ${errMsg(err)}`, "error");
|
|
3971
|
+
}
|
|
3972
|
+
}
|
|
3973
|
+
if (!app) return note(managedAppUsage("disconnect"), "error");
|
|
3974
|
+
try {
|
|
3975
|
+
const result = await disconnectManagedApp(client, app);
|
|
3976
|
+
note(result.message);
|
|
3977
|
+
} catch (err) {
|
|
3978
|
+
note(`could not disconnect ${app}: ${errMsg(err)}`, "error");
|
|
3979
|
+
}
|
|
3980
|
+
return;
|
|
3981
|
+
}
|
|
3367
3982
|
case "focus":
|
|
3368
3983
|
return setOverlay("focus");
|
|
3369
3984
|
case "cli":
|
|
@@ -3390,8 +4005,10 @@ function App(props) {
|
|
|
3390
4005
|
applyChatDetailVisibility,
|
|
3391
4006
|
client,
|
|
3392
4007
|
craftbooks,
|
|
4008
|
+
ensureGezelByName,
|
|
3393
4009
|
note,
|
|
3394
4010
|
exit,
|
|
4011
|
+
openGezelPicker,
|
|
3395
4012
|
openModelDownloadPicker,
|
|
3396
4013
|
openModelPicker,
|
|
3397
4014
|
openThreadPicker,
|
|
@@ -3552,6 +4169,7 @@ function App(props) {
|
|
|
3552
4169
|
return;
|
|
3553
4170
|
}
|
|
3554
4171
|
if (key.escape) {
|
|
4172
|
+
if (pendingQuestion) return;
|
|
3555
4173
|
if (turns.size > 0 || activeRuns.size > 0) {
|
|
3556
4174
|
void cancelActiveRef.current().then((did) => did && note("interrupted."));
|
|
3557
4175
|
} else if (pendingInput) {
|
|
@@ -3564,9 +4182,7 @@ function App(props) {
|
|
|
3564
4182
|
}
|
|
3565
4183
|
}
|
|
3566
4184
|
},
|
|
3567
|
-
{
|
|
3568
|
-
isActive: overlay === null && (!pendingQuestion || pendingInput !== null || taskPrompt !== null)
|
|
3569
|
-
}
|
|
4185
|
+
{ isActive: overlay === null }
|
|
3570
4186
|
);
|
|
3571
4187
|
if (status) {
|
|
3572
4188
|
return /* @__PURE__ */ jsx5(Box6, { flexDirection: "column", padding: 1, children: /* @__PURE__ */ jsx5(Text6, { color: status.startsWith("Failed") ? "red" : "cyan", children: status }) });
|
|
@@ -3594,20 +4210,17 @@ function App(props) {
|
|
|
3594
4210
|
overlay === "gezel" ? /* @__PURE__ */ jsx5(
|
|
3595
4211
|
Picker,
|
|
3596
4212
|
{
|
|
3597
|
-
title: "Switch gezel",
|
|
3598
|
-
items:
|
|
3599
|
-
|
|
3600
|
-
value: g.id,
|
|
3601
|
-
hint: g.role
|
|
3602
|
-
})),
|
|
4213
|
+
title: "Switch gezel, or bring on a role",
|
|
4214
|
+
items: gezelPickerItems,
|
|
4215
|
+
windowSize: gezelPickerWindowSize,
|
|
3603
4216
|
onCancel: () => setOverlay(null),
|
|
3604
|
-
onSelect: (
|
|
4217
|
+
onSelect: (value2) => {
|
|
3605
4218
|
setOverlay(null);
|
|
3606
|
-
if (
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
void
|
|
4219
|
+
if (value2.startsWith(TEMPLATE_VALUE_PREFIX)) {
|
|
4220
|
+
void recruitGezel(value2.slice(TEMPLATE_VALUE_PREFIX.length));
|
|
4221
|
+
return;
|
|
4222
|
+
}
|
|
4223
|
+
void useGezel(value2.slice(GEZEL_VALUE_PREFIX.length));
|
|
3611
4224
|
}
|
|
3612
4225
|
}
|
|
3613
4226
|
) : null,
|
|
@@ -4630,6 +5243,8 @@ function nativeLabel(engine) {
|
|
|
4630
5243
|
return "local runtime helper";
|
|
4631
5244
|
case "ds4-server":
|
|
4632
5245
|
return "ds4";
|
|
5246
|
+
case "duckdb":
|
|
5247
|
+
return "data query engine";
|
|
4633
5248
|
}
|
|
4634
5249
|
}
|
|
4635
5250
|
function accessoryKindLabel(model) {
|