@bendyline/gezel-cli 1.2.10 → 1.2.11
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/dist/bin/gezel-main.js +126 -13
- package/package.json +9 -9
package/dist/bin/gezel-main.js
CHANGED
|
@@ -20,7 +20,9 @@ import {
|
|
|
20
20
|
createTrustingFetch as createTrustingFetch2,
|
|
21
21
|
discoverOrSpawn as discoverOrSpawn2,
|
|
22
22
|
isProcessAlive as isProcessAlive2,
|
|
23
|
+
listProcessSnapshots,
|
|
23
24
|
readRuntime as readRuntime2,
|
|
25
|
+
requestDaemonHealth,
|
|
24
26
|
resolveDaemonEntry as resolveDaemonEntry2,
|
|
25
27
|
stopOwnedDaemon as stopOwnedDaemon2,
|
|
26
28
|
stopProcessByPid
|
|
@@ -1404,6 +1406,17 @@ function registerSecurityCommands(program2, connect) {
|
|
|
1404
1406
|
});
|
|
1405
1407
|
}
|
|
1406
1408
|
}
|
|
1409
|
+
function registerGrowthCommand(program2, connect) {
|
|
1410
|
+
program2.command("growth [state]").description("Show or set on/off for gezel growth: XP and the level-ups it offers").option("--json", "Output the setting as JSON").action(async (state, options) => {
|
|
1411
|
+
const enabled = enabledValue(state);
|
|
1412
|
+
const client = await connect();
|
|
1413
|
+
const config = enabled === void 0 ? await client.getConfig() : await client.updateConfig({ growth: { enabled } });
|
|
1414
|
+
const value = config.growth?.enabled !== false;
|
|
1415
|
+
console.log(
|
|
1416
|
+
options.json ? JSON.stringify({ growthEnabled: value }) : `Growth (XP and level-ups): ${value ? "on" : "off"}`
|
|
1417
|
+
);
|
|
1418
|
+
});
|
|
1419
|
+
}
|
|
1407
1420
|
function registerProjectSettingsCommands(env2, connect, projectFor) {
|
|
1408
1421
|
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) => {
|
|
1409
1422
|
const enabled = enabledValue(state);
|
|
@@ -1796,6 +1809,26 @@ function shorthandEcho(id, tail) {
|
|
|
1796
1809
|
return `\u2192 gezel do ${[id, ...tail].map(shellWord).join(" ")}`;
|
|
1797
1810
|
}
|
|
1798
1811
|
|
|
1812
|
+
// src/daemon-stop.ts
|
|
1813
|
+
async function planDaemonStop(input) {
|
|
1814
|
+
const { pid, health } = input;
|
|
1815
|
+
if (pid === null) return { kind: "not-running" };
|
|
1816
|
+
if (!input.alive(pid)) return { kind: "stale" };
|
|
1817
|
+
if (health?.hostedBy === "app") return { kind: "brake" };
|
|
1818
|
+
if (health?.pid !== void 0) {
|
|
1819
|
+
if (health.pid !== pid) return { kind: "mismatch", healthPid: health.pid };
|
|
1820
|
+
if (health.hostedBy === "standalone") return { kind: "kill" };
|
|
1821
|
+
}
|
|
1822
|
+
const command = await input.commandOf(pid);
|
|
1823
|
+
if (command !== null && isGezeldCommand(command)) return { kind: "kill" };
|
|
1824
|
+
if (health) return { kind: "brake" };
|
|
1825
|
+
if (command === null) return { kind: "unconfirmed" };
|
|
1826
|
+
return { kind: "foreign", command };
|
|
1827
|
+
}
|
|
1828
|
+
function isGezeldCommand(command) {
|
|
1829
|
+
return /(?:^|[\\/\s"'])gezeld(?:\.[cm]?js|\.exe)?(?=["'\s]|$)/i.test(command);
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1799
1832
|
// src/engagement-mode.ts
|
|
1800
1833
|
var CLI_ENGAGEMENT_MODES = [
|
|
1801
1834
|
{
|
|
@@ -3094,6 +3127,7 @@ var cliGlobals = () => program.opts();
|
|
|
3094
3127
|
registerSecretCommands(program, () => connectOwned(cliGlobals()));
|
|
3095
3128
|
registerMcpCommands(program, () => connectOwned(cliGlobals()));
|
|
3096
3129
|
registerSecurityCommands(program, () => connectOwned(cliGlobals()));
|
|
3130
|
+
registerGrowthCommand(program, () => connectOwned(cliGlobals()));
|
|
3097
3131
|
program.hook("preAction", () => {
|
|
3098
3132
|
const globals = cliGlobals();
|
|
3099
3133
|
validateGlobals(globals);
|
|
@@ -3433,7 +3467,7 @@ program.command("stop").description(
|
|
|
3433
3467
|
);
|
|
3434
3468
|
}
|
|
3435
3469
|
});
|
|
3436
|
-
async function clearStaleRuntime(stoppedPid) {
|
|
3470
|
+
async function clearStaleRuntime(stoppedPid, opts = {}) {
|
|
3437
3471
|
const { readFile: readFile4, rm: rm3 } = await import("fs/promises");
|
|
3438
3472
|
const { gezelPaths: gezelPaths2 } = await import("@bendyline/gezel/paths");
|
|
3439
3473
|
const runtime = gezelPaths2().runtime;
|
|
@@ -3441,7 +3475,7 @@ async function clearStaleRuntime(stoppedPid) {
|
|
|
3441
3475
|
(await readFile4(runtime.pid, "utf8").catch(() => "")).trim(),
|
|
3442
3476
|
10
|
|
3443
3477
|
);
|
|
3444
|
-
if (recorded !== stoppedPid || isProcessAlive2(stoppedPid)) return;
|
|
3478
|
+
if (recorded !== stoppedPid || !opts.pidReused && isProcessAlive2(stoppedPid)) return;
|
|
3445
3479
|
await Promise.all(
|
|
3446
3480
|
[
|
|
3447
3481
|
runtime.pid,
|
|
@@ -3470,15 +3504,75 @@ async function stopUserDaemon(globals) {
|
|
|
3470
3504
|
return;
|
|
3471
3505
|
}
|
|
3472
3506
|
const runtime = await readRuntime2();
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3507
|
+
const plan = await planDaemonStop({
|
|
3508
|
+
pid: runtime?.pid ?? null,
|
|
3509
|
+
alive: isProcessAlive2,
|
|
3510
|
+
health: runtime ? await runtimeHealth(runtime) : null,
|
|
3511
|
+
commandOf: processCommand
|
|
3512
|
+
});
|
|
3513
|
+
switch (plan.kind) {
|
|
3514
|
+
case "not-running":
|
|
3515
|
+
console.log("gezeld is not running");
|
|
3516
|
+
return;
|
|
3517
|
+
case "stale":
|
|
3518
|
+
await clearStaleRuntime(runtime.pid);
|
|
3519
|
+
console.log("gezeld is not running; removed the runtime files it left behind");
|
|
3520
|
+
return;
|
|
3521
|
+
case "foreign":
|
|
3522
|
+
await clearStaleRuntime(runtime.pid, { pidReused: true });
|
|
3523
|
+
console.log(
|
|
3524
|
+
`gezeld is not running. Its old process id ${runtime.pid} now belongs to another program, which was left alone; removed gezeld's leftover runtime files.`
|
|
3525
|
+
);
|
|
3526
|
+
return;
|
|
3527
|
+
case "unconfirmed":
|
|
3528
|
+
console.error(
|
|
3529
|
+
`gezeld (pid ${runtime.pid}) is not answering, and Gezel could not read the process list to confirm that pid is still gezeld, so it was not stopped.`
|
|
3530
|
+
);
|
|
3531
|
+
process.exitCode = 1;
|
|
3532
|
+
return;
|
|
3533
|
+
case "mismatch":
|
|
3534
|
+
console.error(
|
|
3535
|
+
`The Gezel service on port ${runtime.port} reports pid ${plan.healthPid}, but runtime/pid says ${runtime.pid}; stopped nothing. Run \`gezel status\` to see which is running.`
|
|
3536
|
+
);
|
|
3537
|
+
process.exitCode = 1;
|
|
3538
|
+
return;
|
|
3539
|
+
case "brake": {
|
|
3540
|
+
const result = await (await connectOwned(globals)).emergencyStopChats();
|
|
3541
|
+
console.log(
|
|
3542
|
+
`This Gezel service belongs to the Gezel app, which would start it again, so it keeps running. Stopped its AI work instead (${result.cancelledTurns} active ${result.cancelledTurns === 1 ? "chat" : "chats"}). Quit the Gezel app to shut it down.`
|
|
3543
|
+
);
|
|
3544
|
+
return;
|
|
3545
|
+
}
|
|
3546
|
+
case "kill":
|
|
3547
|
+
if (await stopDaemonPid(runtime.pid)) {
|
|
3548
|
+
console.log(`stopped gezeld pid=${runtime.pid}`);
|
|
3549
|
+
} else {
|
|
3550
|
+
console.error(`failed to confirm gezeld pid=${runtime.pid} stopped`);
|
|
3551
|
+
process.exitCode = 1;
|
|
3552
|
+
}
|
|
3476
3553
|
}
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3554
|
+
}
|
|
3555
|
+
async function runtimeHealth(runtime) {
|
|
3556
|
+
try {
|
|
3557
|
+
const response = await requestDaemonHealth(runtime.baseUrl, {
|
|
3558
|
+
fetch: runtime.cert ? createTrustingFetch2({ cert: runtime.cert }) : globalThis.fetch,
|
|
3559
|
+
timeoutMs: 3e3
|
|
3560
|
+
});
|
|
3561
|
+
if (!response.ok) return null;
|
|
3562
|
+
const body = response.body ?? {};
|
|
3563
|
+
return {
|
|
3564
|
+
...typeof body.pid === "number" ? { pid: body.pid } : {},
|
|
3565
|
+
...body.hostedBy === "app" || body.hostedBy === "standalone" ? { hostedBy: body.hostedBy } : {}
|
|
3566
|
+
};
|
|
3567
|
+
} catch {
|
|
3568
|
+
return null;
|
|
3569
|
+
}
|
|
3570
|
+
}
|
|
3571
|
+
async function processCommand(pid) {
|
|
3572
|
+
try {
|
|
3573
|
+
return (await listProcessSnapshots()).find((entry) => entry.pid === pid)?.command ?? "";
|
|
3574
|
+
} catch {
|
|
3575
|
+
return null;
|
|
3482
3576
|
}
|
|
3483
3577
|
}
|
|
3484
3578
|
program.command("mode [mode]").description("Show or set AI activity (read-only, reactive, reactive+tasks, or full-play)").action(async (requested) => {
|
|
@@ -4485,8 +4579,26 @@ function resolveModelProvider(raw) {
|
|
|
4485
4579
|
}
|
|
4486
4580
|
return resolveOnDeviceProvider3(process.platform, process.arch);
|
|
4487
4581
|
}
|
|
4488
|
-
|
|
4489
|
-
|
|
4582
|
+
var CONCURRENCY_SERVICE_PROVIDERS = [
|
|
4583
|
+
"codex-cli",
|
|
4584
|
+
"anthropic-cli",
|
|
4585
|
+
"copilot",
|
|
4586
|
+
"openai",
|
|
4587
|
+
"anthropic"
|
|
4588
|
+
];
|
|
4589
|
+
model.command("concurrency [slots]").description(
|
|
4590
|
+
"Show or set how many turns a provider runs at once (local inference slots, or a cloud/CLI provider such as codex-cli); auto restores the default"
|
|
4591
|
+
).option(
|
|
4592
|
+
"-p, --provider <engine>",
|
|
4593
|
+
`mlx | llama-cpp | ds4 | ${CONCURRENCY_SERVICE_PROVIDERS.join(" | ")} (default: platform default)`
|
|
4594
|
+
).option("--json", "Output the slot override as JSON").action(async (slots, opts) => {
|
|
4595
|
+
const service = CONCURRENCY_SERVICE_PROVIDERS.find((name) => name === opts.provider);
|
|
4596
|
+
if (!service && opts.provider && !["mlx", "llama-cpp", "ds4"].includes(opts.provider)) {
|
|
4597
|
+
throw new CliError(
|
|
4598
|
+
`--provider must be one of mlx, llama-cpp, ds4, ${CONCURRENCY_SERVICE_PROVIDERS.join(", ")} (got "${opts.provider}")`
|
|
4599
|
+
);
|
|
4600
|
+
}
|
|
4601
|
+
const provider = service ?? resolveModelProvider(opts.provider);
|
|
4490
4602
|
if (slots !== void 0 && slots !== "auto" && (!/^\d+$/.test(slots) || !Number.isSafeInteger(Number(slots)) || Number(slots) < 1)) {
|
|
4491
4603
|
throw new CliError("Concurrency must be a positive integer, or auto.");
|
|
4492
4604
|
}
|
|
@@ -4499,8 +4611,9 @@ model.command("concurrency [slots]").description("Show or set local inference sl
|
|
|
4499
4611
|
await client.updateConfig({ providerConcurrency: concurrency });
|
|
4500
4612
|
}
|
|
4501
4613
|
const result = { provider, slots: concurrency[provider] ?? null };
|
|
4614
|
+
const applies = service ? "applies after a daemon restart" : "applies when idle sessions reload";
|
|
4502
4615
|
console.log(
|
|
4503
|
-
opts.json ? JSON.stringify(result) : `${provider}: ${result.slots ?? "auto"}${result.slots === null ? "" : " inference slots"}${slots === void 0 ? "" :
|
|
4616
|
+
opts.json ? JSON.stringify(result) : `${provider}: ${result.slots ?? "auto"}${result.slots === null ? "" : ` ${service ? "concurrent turns" : "inference slots"}`}${slots === void 0 ? "" : ` (${applies})`}`
|
|
4504
4617
|
);
|
|
4505
4618
|
});
|
|
4506
4619
|
model.command("context <id> [tokens]").description("Show or set a model context window in tokens; use auto to clear an override").option("-p, --provider <engine>", "mlx | llama-cpp | ds4 (default: platform default)").option("--json", "Output the context override as JSON").action(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bendyline/gezel-cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.11",
|
|
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.
|
|
48
|
-
"@bendyline/gezel-app-sdk": "1.1.
|
|
49
|
-
"@bendyline/gezel-catalog": "1.2.
|
|
50
|
-
"@bendyline/gezel-client": "1.2.
|
|
47
|
+
"@bendyline/gezel": "1.2.11",
|
|
48
|
+
"@bendyline/gezel-app-sdk": "1.1.11",
|
|
49
|
+
"@bendyline/gezel-catalog": "1.2.11",
|
|
50
|
+
"@bendyline/gezel-client": "1.2.11",
|
|
51
51
|
"@bendyline/gezel-knowledge": "1.2.9",
|
|
52
|
-
"@bendyline/gezel-service": "1.2.
|
|
53
|
-
"@bendyline/squisq": "2.13.
|
|
54
|
-
"@bendyline/squisq-formats": "2.8.
|
|
55
|
-
"@bendyline/squisq-react": "2.12.
|
|
52
|
+
"@bendyline/gezel-service": "1.2.11",
|
|
53
|
+
"@bendyline/squisq": "2.13.6",
|
|
54
|
+
"@bendyline/squisq-formats": "2.8.7",
|
|
55
|
+
"@bendyline/squisq-react": "2.12.16",
|
|
56
56
|
"commander": "^15.0.0",
|
|
57
57
|
"ink": "^7.1.1",
|
|
58
58
|
"ink-text-input": "^6.0.0",
|