@cavelon/cli 0.2.2 → 0.2.3
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 +10 -0
- package/dist/automation-settings.js +35 -0
- package/dist/command.js +1 -0
- package/dist/commands/setup.js +112 -8
- package/dist/kit-codes.js +1 -0
- package/dist/main.js +13 -1
- package/dist/mcp.js +1 -1
- package/dist/native-assets/manifest.json +1 -1
- package/dist/setup-agents.js +91 -12
- package/dist/skills/cavelon-loop/SKILL.md +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,6 +21,16 @@ in Windows PowerShell. With Python, `uvx cavelon` runs the same executable from
|
|
|
21
21
|
PyPI, and `uv tool install cavelon` or `pipx install cavelon` installs it. Then
|
|
22
22
|
`cavelon setup` sets up your coding agents and logs you in.
|
|
23
23
|
|
|
24
|
+
Running the one-line installer again updates the CLI, then asks separately
|
|
25
|
+
whether to refresh Cavelon plugins/skills and enable YOLO for new MCP sessions.
|
|
26
|
+
Enter at the YOLO question keeps your choice. Restart your agent afterwards;
|
|
27
|
+
it launches the tools with that personal mode automatically. Critical changes
|
|
28
|
+
still require approval. Other package managers: update the CLI, then run
|
|
29
|
+
`cavelon setup --update`. Change just the mode with
|
|
30
|
+
`cavelon setup --mcp-mode yolo --yes` or `--mcp-mode standard --yes`.
|
|
31
|
+
Interactive `setup` and `setup --update` offer the same YOLO choice, so
|
|
32
|
+
Homebrew, npm, uv and pipx users do not need to run the installer script.
|
|
33
|
+
|
|
24
34
|
Version 0.1.17 adds Cline, Kilo, Goose and OMP to the OpenCode, Pi and Qwen
|
|
25
35
|
Code integrations. Each has native settings and four skills; guarded changes
|
|
26
36
|
use the qualified client dialog or the person’s own terminal:
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { CavelonError, ExitCode } from "./errors.js";
|
|
4
|
+
import { withoutBom, writePrivateFile } from "./fsutil.js";
|
|
5
|
+
import { configDir } from "./paths.js";
|
|
6
|
+
export async function readMcpMode(env) {
|
|
7
|
+
const file = path.join(configDir(env), "automation.json");
|
|
8
|
+
try {
|
|
9
|
+
const stat = await fs.lstat(file);
|
|
10
|
+
if (!stat.isFile() || stat.isSymbolicLink())
|
|
11
|
+
throw new Error("expected a regular file");
|
|
12
|
+
const value = JSON.parse(withoutBom(await fs.readFile(file, "utf8")));
|
|
13
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
14
|
+
throw new Error("expected an object");
|
|
15
|
+
const settings = value;
|
|
16
|
+
if (settings.format !== 1 || !["standard", "yolo"].includes(String(settings.mcp_mode)))
|
|
17
|
+
throw new Error("unrecognized settings format or mode");
|
|
18
|
+
return settings.mcp_mode;
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
if (error.code === "ENOENT")
|
|
22
|
+
return "standard";
|
|
23
|
+
throw new CavelonError(ExitCode.failure, {
|
|
24
|
+
code: "automation_settings_invalid",
|
|
25
|
+
message: `Cannot read the personal MCP mode in ${file}; leaving this file unchanged.`,
|
|
26
|
+
hint: "Restore a regular JSON file with format: 1 and mcp_mode: standard or yolo, or move it aside and run cavelon setup again.",
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export async function saveMcpMode(env, mode) {
|
|
31
|
+
if (await readMcpMode(env) === mode)
|
|
32
|
+
return false;
|
|
33
|
+
await writePrivateFile(configDir(env), path.join(configDir(env), "automation.json"), JSON.stringify({ format: 1, mcp_mode: mode }, null, 2) + "\n");
|
|
34
|
+
return true;
|
|
35
|
+
}
|
package/dist/command.js
CHANGED
|
@@ -38,6 +38,7 @@ export function ownsTenant(spec) {
|
|
|
38
38
|
export const GLOBAL_OPTIONS = {
|
|
39
39
|
json: { type: "boolean", description: "Print one JSON document instead of text." },
|
|
40
40
|
yolo: { type: "boolean", cliOnly: true, description: "Automatically apply eligible routine changes in this process's selected target; critical changes still need a person." },
|
|
41
|
+
"no-yolo": { type: "boolean", cliOnly: true, description: "Use standard mode for this process, overriding the personal MCP startup mode." },
|
|
41
42
|
instance: { type: "string", value: "<url>", description: "The instance URL (overrides CAVELON_URL and cavelon.yaml)." },
|
|
42
43
|
tenant: { type: "string", value: "<tenant>", description: "Tenant slug, name or id (overrides CAVELON_TENANT and cavelon.yaml)." },
|
|
43
44
|
help: { type: "boolean", short: "h", description: "Show help for the command." },
|
package/dist/commands/setup.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { promises as fs } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { boolOption, listOption } from "../command.js";
|
|
3
|
+
import { boolOption, listOption, stringOption } from "../command.js";
|
|
4
|
+
import { agentVariable } from "../agent-env.js";
|
|
5
|
+
import { readMcpMode, saveMcpMode } from "../automation-settings.js";
|
|
6
|
+
import { findProject } from "../project.js";
|
|
7
|
+
import { init } from "./init.js";
|
|
4
8
|
import { createContext } from "../context.js";
|
|
5
9
|
import { asCavelonError, CavelonError, ExitCode, usageError } from "../errors.js";
|
|
6
10
|
import { readJsonFile, writeFileAtomic } from "../fsutil.js";
|
|
@@ -123,11 +127,11 @@ function normalizeAddress(raw) {
|
|
|
123
127
|
return undefined;
|
|
124
128
|
}
|
|
125
129
|
}
|
|
126
|
-
async function loginStep(ctx) {
|
|
130
|
+
async function loginStep(ctx, nonInteractive = false) {
|
|
127
131
|
const session = await ctx.session();
|
|
128
132
|
if (session.url && session.token)
|
|
129
133
|
return { status: "already", instance: session.url, text: `Already logged in to ${session.url}.` };
|
|
130
|
-
if (!canAsk(ctx)) {
|
|
134
|
+
if (!canAsk(ctx) || nonInteractive) {
|
|
131
135
|
return {
|
|
132
136
|
status: "not_logged_in",
|
|
133
137
|
instance: session.url ?? null,
|
|
@@ -189,13 +193,13 @@ async function runSetup(ctx, input) {
|
|
|
189
193
|
const state = await loadState(env);
|
|
190
194
|
const plans = [];
|
|
191
195
|
for (const { agent, found: where } of chosen)
|
|
192
|
-
plans.push(await planAgent(agent, where, env, command, skills, process.platform, state.agents[agent.name]));
|
|
196
|
+
plans.push(await planAgent(agent, where, env, command, skills, process.platform, state.agents[agent.name], boolOption(input, "update")));
|
|
193
197
|
const pending = plans.some((p) => p.changes.some((c) => c.outcome === "planned"));
|
|
194
198
|
let results = plans.map((plan) => ({ plan, changes: plan.changes }));
|
|
195
199
|
let declined = false;
|
|
196
200
|
if (pending) {
|
|
197
201
|
if (!boolOption(input, "yes")) {
|
|
198
|
-
if (!canAsk(ctx)) {
|
|
202
|
+
if (!canAsk(ctx) || boolOption(input, "non-interactive")) {
|
|
199
203
|
if (!ctx.json)
|
|
200
204
|
ctx.io.stderr.write(`cavelon setup would change this:\n${planText(plans, notFound)}\n`);
|
|
201
205
|
throw confirmationRequired("setup changes your coding agents' settings only when you agree", { agents: plans.map((p) => planJson(p)), server: command });
|
|
@@ -222,7 +226,7 @@ async function runSetup(ctx, input) {
|
|
|
222
226
|
}
|
|
223
227
|
if (recovered)
|
|
224
228
|
await saveState(env, state);
|
|
225
|
-
const loginReport = declined ? undefined : await loginStep(ctx);
|
|
229
|
+
const loginReport = declined || boolOption(input, "update") ? undefined : await loginStep(ctx, boolOption(input, "non-interactive"));
|
|
226
230
|
const failed = results.some((r) => r.changes.some((c) => c.outcome === "failed"));
|
|
227
231
|
const ready = results.filter((r) => r.changes.length && r.changes.every((c) => c.outcome === "done" || c.outcome === "unchanged"));
|
|
228
232
|
const changed = results.filter((r) => r.changes.some((c) => c.outcome === "done"));
|
|
@@ -269,6 +273,85 @@ async function runSetup(ctx, input) {
|
|
|
269
273
|
exitCode,
|
|
270
274
|
};
|
|
271
275
|
}
|
|
276
|
+
async function runUpdate(ctx, input) {
|
|
277
|
+
const project = await findProject(ctx.io.cwd);
|
|
278
|
+
if (project && !boolOption(input, "yes")) {
|
|
279
|
+
if (!canAsk(ctx) || boolOption(input, "non-interactive"))
|
|
280
|
+
throw confirmationRequired("updating also refreshes the current solution's generated setup", { solution: project.root });
|
|
281
|
+
if (!(await confirm(ctx, `Update Cavelon plugins, owned skills and generated setup in ${project.root}?`, true))) {
|
|
282
|
+
return { data: { agents: [], not_found: [], server: await serverCommand(ctx.io.env), declined: true, login: null, next: [] }, text: "Nothing was changed.", exitCode: ExitCode.ok };
|
|
283
|
+
}
|
|
284
|
+
input = { ...input, options: { ...input.options, yes: true } };
|
|
285
|
+
}
|
|
286
|
+
const result = await runSetup(ctx, input);
|
|
287
|
+
if (result.data.declined || !project)
|
|
288
|
+
return result;
|
|
289
|
+
try {
|
|
290
|
+
const project = await init.run(ctx, { positionals: {}, options: { update: true } });
|
|
291
|
+
return { ...result, data: { ...result.data, project: project.data }, text: `${result.text}\n\nCurrent solution:\n${project.text}` };
|
|
292
|
+
}
|
|
293
|
+
catch (error) {
|
|
294
|
+
const err = asCavelonError(error);
|
|
295
|
+
return { ...result, data: { ...result.data, project_error: err.toJSON() }, text: `${result.text}\n\nCurrent solution update failed: ${err.message}`, exitCode: err.exitCode };
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
function interactiveSetup(ctx, input) {
|
|
299
|
+
return canAsk(ctx) && !boolOption(input, "non-interactive") && !agentVariable(ctx.io.env) && !/^(1|true|yes)$/i.test(ctx.io.env.CI ?? "");
|
|
300
|
+
}
|
|
301
|
+
async function chooseMcpMode(ctx, current) {
|
|
302
|
+
ctx.io.stderr.write(`\nMCP YOLO is currently ${current === "yolo" ? "enabled" : "disabled"}. It combines preview and execution for eligible routine changes in the session's selected target. Critical changes still ask for approval.\n`);
|
|
303
|
+
for (;;) {
|
|
304
|
+
const answer = (await readLine(ctx.io, "YOLO for new agent sessions: [y] enable, [n] disable, [Enter] keep current: ")).toLowerCase();
|
|
305
|
+
if (!answer)
|
|
306
|
+
return undefined;
|
|
307
|
+
if (["y", "yes", "j", "ja"].includes(answer))
|
|
308
|
+
return "yolo";
|
|
309
|
+
if (["n", "no", "nein"].includes(answer))
|
|
310
|
+
return "standard";
|
|
311
|
+
ctx.io.stderr.write("Please choose y, n, or Enter.\n");
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
async function offerMcpMode(ctx, input, result) {
|
|
315
|
+
if (!interactiveSetup(ctx, input) || boolOption(input, "yes") || result.data.declined)
|
|
316
|
+
return result;
|
|
317
|
+
try {
|
|
318
|
+
const current = await readMcpMode(ctx.io.env);
|
|
319
|
+
const mode = await chooseMcpMode(ctx, current);
|
|
320
|
+
const changed = mode ? await saveMcpMode(ctx.io.env, mode) : false;
|
|
321
|
+
return { ...result, data: { ...result.data, mcp_mode: mode ?? current, mode_changed: changed }, text: `${result.text}\n\nMCP startup mode: ${mode ?? current}. Restart your coding agent to apply the installed CLI, skills and startup mode.` };
|
|
322
|
+
}
|
|
323
|
+
catch (error) {
|
|
324
|
+
const err = asCavelonError(error);
|
|
325
|
+
return { ...result, data: { ...result.data, mode_error: err.toJSON() }, text: `${result.text}\n\nMCP mode selection incomplete: ${err.message}`, exitCode: err.exitCode };
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
async function runFollowUp(ctx, input) {
|
|
329
|
+
const installer = boolOption(input, "installer");
|
|
330
|
+
let update = boolOption(input, "update");
|
|
331
|
+
let mode = stringOption(input, "mcp-mode");
|
|
332
|
+
const current = await readMcpMode(ctx.io.env);
|
|
333
|
+
const interactive = interactiveSetup(ctx, input);
|
|
334
|
+
if (installer && interactive) {
|
|
335
|
+
if (!update && !boolOption(input, "skip-update"))
|
|
336
|
+
update = await confirm(ctx, "Set up or update Cavelon plugins and skills in your coding agents (and this solution, if present)?", true);
|
|
337
|
+
if (!mode)
|
|
338
|
+
mode = await chooseMcpMode(ctx, current);
|
|
339
|
+
}
|
|
340
|
+
if (!installer && mode && mode !== current && !boolOption(input, "yes")) {
|
|
341
|
+
if (!interactive)
|
|
342
|
+
throw confirmationRequired("the personal MCP startup mode changes only when you agree", { mcp_mode: mode });
|
|
343
|
+
if (!(await confirm(ctx, `Set the MCP startup mode to ${mode}? Critical changes still ask for approval.`, false)))
|
|
344
|
+
mode = undefined;
|
|
345
|
+
}
|
|
346
|
+
const changed = mode ? await saveMcpMode(ctx.io.env, mode) : false;
|
|
347
|
+
const selected = mode ?? current;
|
|
348
|
+
const report = update ? await runUpdate(ctx, { ...input, options: { ...input.options, update: true, ...(installer ? { yes: true } : {}) } }) : undefined;
|
|
349
|
+
return {
|
|
350
|
+
data: { updated_agents: Boolean(report && !report.data.declined && report.exitCode === ExitCode.ok), mcp_mode: selected, mode_changed: changed, ...(report ? { update: report.data } : {}) },
|
|
351
|
+
text: [report?.text, `MCP startup mode: ${selected}.`, "Next: restart your coding agent or reconnect its Cavelon tools to use the installed CLI, skills and startup mode.", ...(!update ? ["Run cavelon setup --update to refresh plugins and skills later; cavelon setup also guides first-time login."] : [])].filter(Boolean).join("\n\n"),
|
|
352
|
+
exitCode: report?.exitCode ?? ExitCode.ok,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
272
355
|
function joinLabels(labels, word = "and") {
|
|
273
356
|
if (labels.length <= 1)
|
|
274
357
|
return labels.join("");
|
|
@@ -421,12 +504,20 @@ export const setup = {
|
|
|
421
504
|
"The server starts as `cavelon mcp` when cavelon is installed, otherwise through npx. --check reports what is set up and\n" +
|
|
422
505
|
"working: each agent's entry, the MCP server starting, and the login. An agent found but never set up for Cavelon is\n" +
|
|
423
506
|
"reported and skipped (exit 0 when the rest works); --strict, or naming it with --agents, counts it.\n" +
|
|
424
|
-
"
|
|
507
|
+
"--update refreshes plugins and owned skills, including the current solution's generated setup, and keeps your login.\n" +
|
|
508
|
+
"--mcp-mode saves a personal startup choice; restart your coding agent to apply it. Critical changes still need approval.\n" +
|
|
509
|
+
"Interactive setup and --update also offer the YOLO choice; Enter preserves it. --yes keeps it unless --mcp-mode is given.\n" +
|
|
510
|
+
"Without a terminal it changes nothing unless --yes, or explicit --installer update/mode choices are given.",
|
|
425
511
|
readOnly: false,
|
|
426
512
|
destructive: true,
|
|
427
513
|
idempotent: true,
|
|
428
514
|
mcpTool: false,
|
|
429
515
|
options: {
|
|
516
|
+
update: { type: "boolean", description: "Refresh agent plugins, owned skills and the current solution's generated setup; keep your login." },
|
|
517
|
+
"mcp-mode": { type: "string", value: "<standard|yolo>", description: "Save the personal mode for new MCP sessions, without editing agent launch commands. Critical changes still need approval." },
|
|
518
|
+
installer: { type: "boolean", description: "Installer follow-up: ask separately about agent updates and YOLO. Without a terminal, keep both unless explicitly selected." },
|
|
519
|
+
"skip-update": { type: "boolean", description: "With --installer: skip the agent update question and leave plugins and skills unchanged." },
|
|
520
|
+
"non-interactive": { type: "boolean", description: "Never ask questions. Installer choices must be passed explicitly; other changes still require --yes." },
|
|
430
521
|
agents: {
|
|
431
522
|
type: "string",
|
|
432
523
|
value: "<list>",
|
|
@@ -442,6 +533,8 @@ export const setup = {
|
|
|
442
533
|
"cavelon setup",
|
|
443
534
|
"cavelon setup --agents claude,codex --instance https://cavelon.example.com --yes",
|
|
444
535
|
"cavelon setup --check",
|
|
536
|
+
"cavelon setup --update",
|
|
537
|
+
"cavelon setup --mcp-mode yolo --yes",
|
|
445
538
|
"cavelon setup --remove",
|
|
446
539
|
],
|
|
447
540
|
async run(ctx, input) {
|
|
@@ -449,10 +542,21 @@ export const setup = {
|
|
|
449
542
|
throw usageError("--check and --remove do not go together.");
|
|
450
543
|
if (boolOption(input, "strict") && !boolOption(input, "check"))
|
|
451
544
|
throw usageError("--strict goes with --check.");
|
|
545
|
+
const followUp = boolOption(input, "installer") || stringOption(input, "mcp-mode") !== undefined;
|
|
546
|
+
if ((followUp || boolOption(input, "update")) && (boolOption(input, "check") || boolOption(input, "remove")))
|
|
547
|
+
throw usageError("Update and MCP mode options do not go with --check or --remove.");
|
|
548
|
+
if (boolOption(input, "skip-update") && (!boolOption(input, "installer") || boolOption(input, "update")))
|
|
549
|
+
throw usageError("--skip-update requires --installer and cannot be combined with --update.");
|
|
550
|
+
if (stringOption(input, "mcp-mode") !== undefined && !["standard", "yolo"].includes(stringOption(input, "mcp-mode")))
|
|
551
|
+
throw usageError("--mcp-mode must be standard or yolo.");
|
|
452
552
|
if (boolOption(input, "check"))
|
|
453
553
|
return runCheck(ctx, input);
|
|
454
554
|
if (boolOption(input, "remove"))
|
|
455
555
|
return runRemove(ctx, input);
|
|
456
|
-
|
|
556
|
+
if (followUp)
|
|
557
|
+
return runFollowUp(ctx, input);
|
|
558
|
+
if (boolOption(input, "update"))
|
|
559
|
+
return offerMcpMode(ctx, input, await runUpdate(ctx, input));
|
|
560
|
+
return offerMcpMode(ctx, input, await runSetup(ctx, input));
|
|
457
561
|
},
|
|
458
562
|
};
|
package/dist/kit-codes.js
CHANGED
|
@@ -33,6 +33,7 @@ export const KIT_ERROR_CODES = [
|
|
|
33
33
|
{ code: "operation_for_a_person", area: "cli", message: "The operation stays with a person (the instance marks it, or it changes a secret, a credential or an approval), so an agent does not send it.", hint: "A person runs it in their own terminal, or in the Admin." },
|
|
34
34
|
{ code: "secret_field_for_a_person", area: "cli", message: "The request sets a field the instance marks as a secret value, so an agent does not send it.", hint: "Leave the field out; a person enters the value with `cavelon secrets set <name>` or in the Admin." },
|
|
35
35
|
{ code: "yes_required", area: "cli", message: "setup changes something and there is no terminal to ask.", hint: "Read the plan it printed, then run it again with --yes." },
|
|
36
|
+
{ code: "automation_settings_invalid", area: "cli", message: "The personal MCP startup settings are unreadable or have an unrecognized format; setup leaves them unchanged and MCP starts in standard mode.", hint: "Restore automation.json in the personal Cavelon config directory with format: 1 and mcp_mode: standard or yolo, or move it aside and run cavelon setup again." },
|
|
36
37
|
{ code: "operations_unavailable", area: "cli", message: "The instance does not offer the operations API.", hint: "Its operator turns it on with OPERATIONS_API_ENABLED." },
|
|
37
38
|
{ code: "not_an_operation_id", area: "cli", message: "That is not an operation id; they start with op_.", hint: "Commands that start work print the operation id; `cavelon status` lists running ones." },
|
|
38
39
|
{ code: "operation_gone", area: "cli", message: "The operation no longer exists on the instance.", hint: "Start the work again; `cavelon status` lists the running operations." },
|
package/dist/main.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { parseArgs } from "node:util";
|
|
2
2
|
import { GLOBAL_OPTIONS, optionDescription, optionFlag, renameFormerOptions } from "./command.js";
|
|
3
3
|
import { agentVariable } from "./agent-env.js";
|
|
4
|
+
import { readMcpMode } from "./automation-settings.js";
|
|
4
5
|
import { createContext, withWarnings } from "./context.js";
|
|
5
6
|
import { CONFIRM_TOKEN } from "./confirm-token.js";
|
|
6
7
|
import { asCavelonError, ExitCode, usageError } from "./errors.js";
|
|
@@ -45,9 +46,20 @@ export async function run(argv, io, commands = COMMANDS, updates = {}) {
|
|
|
45
46
|
io.stdout.write(commandHelp(spec));
|
|
46
47
|
return ExitCode.ok;
|
|
47
48
|
}
|
|
49
|
+
if (parsed.options.yolo && parsed.options["no-yolo"])
|
|
50
|
+
throw usageError("--yolo and --no-yolo do not go together.");
|
|
51
|
+
let yolo = parsed.options.yolo === true;
|
|
52
|
+
if (spec.name === "mcp" && !parsed.options.yolo && !parsed.options["no-yolo"]) {
|
|
53
|
+
try {
|
|
54
|
+
yolo = await readMcpMode(io.env) === "yolo";
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
io.stderr.write(`warning: ${asCavelonError(error).message} Starting in standard mode.\n`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
48
60
|
ctx = createContext(io, {
|
|
49
61
|
json: parsed.options.json === true,
|
|
50
|
-
yolo
|
|
62
|
+
yolo,
|
|
51
63
|
instance: typeof parsed.options.instance === "string" ? parsed.options.instance : undefined,
|
|
52
64
|
tenant: typeof parsed.options.tenant === "string" ? parsed.options.tenant : undefined,
|
|
53
65
|
solutionEnv: spec.options?.env && typeof parsed.options.env === "string" ? parsed.options.env : undefined,
|
package/dist/mcp.js
CHANGED
|
@@ -18,7 +18,7 @@ const INSTRUCTIONS = "Tools for one Cavelon instance, acting with the token a pe
|
|
|
18
18
|
"and follow a loop with loop_iterations. Routine work within the user's request needs no additional chat approval. " +
|
|
19
19
|
"In standard mode, review previews and confirm the exact token or apply preview id when no needs_person is present. " +
|
|
20
20
|
"A token binds one change, not a person's answer; confirm: true is refused, and changed input needs a new preview. " +
|
|
21
|
-
"If
|
|
21
|
+
"If YOLO was enabled at startup by --yolo or the person's Cavelon setup preference, eligible routine draft imports, selected draft loop starts and known " +
|
|
22
22
|
"routine API operations can execute in one call within the original instance, tenant, credential and solution scope. " +
|
|
23
23
|
"No tool argument or repository setting can enable this mode. A different target falls back to standard confirmation. " +
|
|
24
24
|
"Critical, shared, live and unknown changes retain needs_person in either mode. With needs_person \"client\", " +
|
package/dist/setup-agents.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { promises as fs } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { bundledSkills, generatedCopy, INSTALLED_MCP_COMMAND, mcpCommand } from "./agents.js";
|
|
4
|
-
import { readJsonFile, readTextFile, writeFileAtomic } from "./fsutil.js";
|
|
4
|
+
import { readJsonFile, readTextFile, withoutBom, writeFileAtomic } from "./fsutil.js";
|
|
5
5
|
import { findProgram } from "./git.js";
|
|
6
6
|
import { isGenerated, removeBlock, removeJsonEntry, upsertBlock, upsertJsonEntry } from "./markers.js";
|
|
7
7
|
import { cacheDir, homeDir } from "./paths.js";
|
|
@@ -195,6 +195,8 @@ function pluginCommands(kind) {
|
|
|
195
195
|
return {
|
|
196
196
|
marketplaceAdd: [],
|
|
197
197
|
marketplaceRemove: [],
|
|
198
|
+
marketplaceUpdate: [],
|
|
199
|
+
update: ["extensions", "update", GEMINI_EXTENSION],
|
|
198
200
|
install: ["extensions", "install", GEMINI_SOURCE, "--ref", `v${KIT_VERSION}`, "--consent"],
|
|
199
201
|
uninstall: ["extensions", "uninstall", GEMINI_EXTENSION],
|
|
200
202
|
};
|
|
@@ -202,11 +204,79 @@ function pluginCommands(kind) {
|
|
|
202
204
|
return {
|
|
203
205
|
marketplaceAdd: ["plugin", "marketplace", "add", MARKETPLACE_SOURCE],
|
|
204
206
|
marketplaceRemove: ["plugin", "marketplace", "remove", MARKETPLACE],
|
|
207
|
+
marketplaceUpdate: ["plugin", "marketplace", kind === "claude" ? "update" : "upgrade", MARKETPLACE],
|
|
208
|
+
update: kind === "claude" ? ["plugin", "update", PLUGIN_ID, "--scope", "user"] : ["plugin", "add", PLUGIN_ID],
|
|
205
209
|
install: kind === "claude" ? ["plugin", "install", PLUGIN_ID, "--scope", "user"] : ["plugin", "add", PLUGIN_ID],
|
|
206
210
|
uninstall: kind === "claude" ? ["plugin", "uninstall", PLUGIN_ID, "--scope", "user"] : ["plugin", "remove", PLUGIN_ID],
|
|
207
211
|
};
|
|
208
212
|
}
|
|
209
|
-
|
|
213
|
+
async function updateGemini(program, env) {
|
|
214
|
+
const directory = path.join(geminiHome(env), "extensions", GEMINI_EXTENSION);
|
|
215
|
+
const file = path.join(directory, ".gemini-extension-install.json");
|
|
216
|
+
const stat = await fs.lstat(file);
|
|
217
|
+
if (!stat.isFile() || stat.isSymbolicLink())
|
|
218
|
+
throw new Error(`Cannot update ${file}: expected regular extension install metadata.`);
|
|
219
|
+
const metadata = JSON.parse(withoutBom(await fs.readFile(file, "utf8")));
|
|
220
|
+
if (!["git", "github-release"].includes(String(metadata.type)) || ![GEMINI_SOURCE, `${GEMINI_SOURCE}.git`].includes(String(metadata.source))) {
|
|
221
|
+
throw new Error("The Cavelon extension has a custom or local source; update it through that source, or install the published Cavelon extension first.");
|
|
222
|
+
}
|
|
223
|
+
const manifest = await readJsonFile(path.join(directory, "gemini-extension.json"));
|
|
224
|
+
if (manifest?.version === KIT_VERSION)
|
|
225
|
+
return { code: 0, stdout: "Already at this release.", stderr: "" };
|
|
226
|
+
if (manifest?.settings !== undefined)
|
|
227
|
+
throw new Error("This extension declares custom settings; update it in Gemini before using the published Cavelon extension.");
|
|
228
|
+
const enablement = path.join(path.dirname(directory), "extension-enablement.json");
|
|
229
|
+
const readEnablement = async () => {
|
|
230
|
+
const text = await readTextFile(enablement);
|
|
231
|
+
if (text === undefined)
|
|
232
|
+
return { text, value: {} };
|
|
233
|
+
const stat = await fs.lstat(enablement);
|
|
234
|
+
if (!stat.isFile() || stat.isSymbolicLink())
|
|
235
|
+
throw new Error("Expected a regular Gemini enablement file.");
|
|
236
|
+
const value = JSON.parse(withoutBom(text));
|
|
237
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
238
|
+
throw new Error("Unrecognized Gemini enablement settings.");
|
|
239
|
+
return { text, value: value };
|
|
240
|
+
};
|
|
241
|
+
const original = await readEnablement();
|
|
242
|
+
const cwd = await geminiFolder("gemini", env);
|
|
243
|
+
const backup = await fs.mkdtemp(path.join(cwd, "cavelon-update-"));
|
|
244
|
+
await fs.chmod(backup, 0o700).catch(() => undefined);
|
|
245
|
+
await fs.cp(directory, path.join(backup, "extension"), { recursive: true });
|
|
246
|
+
const commands = pluginCommands("gemini");
|
|
247
|
+
let removed = false;
|
|
248
|
+
let success = false;
|
|
249
|
+
try {
|
|
250
|
+
const uninstall = await runProgram(program, commands.uninstall, { env, timeoutMs: RUN_TIMEOUT_MS, cwd });
|
|
251
|
+
if (uninstall.code !== 0)
|
|
252
|
+
return { ...uninstall, error: `Gemini could not replace the old extension. Backup: ${backup}` };
|
|
253
|
+
removed = true;
|
|
254
|
+
const result = await runProgram(program, commands.install, { env, timeoutMs: RUN_TIMEOUT_MS, cwd });
|
|
255
|
+
const installed = await readJsonFile(path.join(directory, "gemini-extension.json"));
|
|
256
|
+
success = result.code === 0 && installed?.version === KIT_VERSION;
|
|
257
|
+
if (!success)
|
|
258
|
+
return { ...result, code: result.code || 1, error: `Gemini did not install Cavelon ${KIT_VERSION}. Previous files are backed up at ${backup}; retry cavelon setup --update --agents gemini in your terminal.` };
|
|
259
|
+
return result;
|
|
260
|
+
}
|
|
261
|
+
finally {
|
|
262
|
+
if (removed && !success) {
|
|
263
|
+
await fs.rm(directory, { recursive: true, force: true });
|
|
264
|
+
await fs.cp(path.join(backup, "extension"), directory, { recursive: true });
|
|
265
|
+
}
|
|
266
|
+
const current = await readEnablement();
|
|
267
|
+
if (Object.hasOwn(original.value, GEMINI_EXTENSION))
|
|
268
|
+
current.value[GEMINI_EXTENSION] = original.value[GEMINI_EXTENSION];
|
|
269
|
+
else
|
|
270
|
+
delete current.value[GEMINI_EXTENSION];
|
|
271
|
+
if (original.text === undefined && !Object.keys(current.value).length)
|
|
272
|
+
await fs.rm(enablement, { force: true });
|
|
273
|
+
else
|
|
274
|
+
await writeKeepingMode(enablement, JSON.stringify(current.value, null, 2) + "\n");
|
|
275
|
+
if (success)
|
|
276
|
+
await fs.rm(backup, { recursive: true, force: true });
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
export async function planAgent(agent, found, env, command, skills, platform = process.platform, record, update = false) {
|
|
210
280
|
const usePlugin = Boolean(agent.plugin && found.program);
|
|
211
281
|
const state = usePlugin ? await pluginState(agent.plugin, found.program, env) : undefined;
|
|
212
282
|
const plan = { agent, found, method: usePlugin ? "plugin" : "files", changes: [] };
|
|
@@ -222,11 +292,16 @@ export async function planAgent(agent, found, env, command, skills, platform = p
|
|
|
222
292
|
if (!state.marketplace && commands.marketplaceAdd.length) {
|
|
223
293
|
plan.changes.push({ kind: "marketplace", summary: "add the Cavelon plugin marketplace", target: display(program, commands.marketplaceAdd), outcome: "planned" });
|
|
224
294
|
}
|
|
295
|
+
if (update && state.marketplace && commands.marketplaceUpdate.length)
|
|
296
|
+
plan.changes.push({ kind: "marketplace", summary: "refresh the Cavelon plugin marketplace", target: display(program, commands.marketplaceUpdate), outcome: "planned", refresh: true });
|
|
297
|
+
const refresh = update && state.installed && state.enabled;
|
|
225
298
|
plan.changes.push({
|
|
226
299
|
kind: "plugin",
|
|
227
|
-
summary:
|
|
228
|
-
target: display(program, commands.install),
|
|
229
|
-
outcome: state.installed ? "unchanged" : "planned",
|
|
300
|
+
summary: `${refresh ? "update" : "install"} the Cavelon ${kind === "gemini" ? "extension" : "plugin"} (skills and tools)`,
|
|
301
|
+
target: refresh && kind === "gemini" ? `${display(program, commands.uninstall)}; ${display(program, commands.install)}` : display(program, refresh ? commands.update : commands.install),
|
|
302
|
+
outcome: state.installed && !refresh ? "unchanged" : "planned",
|
|
303
|
+
...(refresh ? { refresh: true } : {}),
|
|
304
|
+
...(refresh && kind === "gemini" ? { reason: `replace the published extension at v${KIT_VERSION} through Gemini; preserve enablement and back up the previous files` } : {}),
|
|
230
305
|
...(state.installed && !state.enabled ? { reason: `it is installed but turned off; turn it on in ${agent.label}` } : {}),
|
|
231
306
|
});
|
|
232
307
|
}
|
|
@@ -364,10 +439,12 @@ export async function applyPlan(plan, env, command, skills, record) {
|
|
|
364
439
|
if (change.kind === "marketplace" || change.kind === "plugin") {
|
|
365
440
|
const kind = plan.agent.plugin;
|
|
366
441
|
const commands = pluginCommands(kind);
|
|
367
|
-
const args = change.kind === "marketplace" ? commands.marketplaceAdd : commands.install;
|
|
368
|
-
const result =
|
|
442
|
+
const args = change.kind === "marketplace" ? (change.refresh ? commands.marketplaceUpdate : commands.marketplaceAdd) : (change.refresh ? commands.update : commands.install);
|
|
443
|
+
const result = kind === "gemini" && change.refresh
|
|
444
|
+
? await updateGemini(plan.found.program, env)
|
|
445
|
+
: await runProgram(plan.found.program, args, { env, timeoutMs: RUN_TIMEOUT_MS, cwd: await geminiFolder(kind, env) });
|
|
369
446
|
if (result.code !== 0) {
|
|
370
|
-
if (kind === "gemini") {
|
|
447
|
+
if (kind === "gemini" && !change.refresh) {
|
|
371
448
|
const reason = result.error ?? (lastLine(`${result.stdout}\n${result.stderr}`) || `exit ${result.code}`);
|
|
372
449
|
done.push({ ...change, outcome: "skipped", reason: `${reason}; the tools server and skills go into Gemini CLI's files instead` });
|
|
373
450
|
done.push(await mcpChange(plan.agent.mcp, command, true, record));
|
|
@@ -377,10 +454,12 @@ export async function applyPlan(plan, env, command, skills, record) {
|
|
|
377
454
|
done.push({ ...change, outcome: "failed", reason: result.error ?? (firstLine(result.stderr || result.stdout) || `exit ${result.code}`) });
|
|
378
455
|
break;
|
|
379
456
|
}
|
|
380
|
-
if (change.
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
457
|
+
if (!change.refresh) {
|
|
458
|
+
if (change.kind === "marketplace")
|
|
459
|
+
record.marketplace_added = true;
|
|
460
|
+
else
|
|
461
|
+
record.plugin_installed = true;
|
|
462
|
+
}
|
|
384
463
|
done.push({ ...change, outcome: "done" });
|
|
385
464
|
if (kind === "gemini" && change.kind === "plugin")
|
|
386
465
|
done.push(...(await removeFiles(plan.agent, record, skills, new Set())));
|
|
@@ -377,7 +377,11 @@ show the person the preview again and let them confirm it (in the client's
|
|
|
377
377
|
dialog or their own terminal), never retry on your own.
|
|
378
378
|
|
|
379
379
|
**YOLO is explicitly enabled by the person.** A CLI invocation may start with
|
|
380
|
-
`cavelon --yolo …`, or
|
|
380
|
+
`cavelon --yolo …`, or enable MCP YOLO through the installer or their personal
|
|
381
|
+
`cavelon setup --mcp-mode yolo --yes` setting and restart the coding agent.
|
|
382
|
+
An MCP launch may also use `cavelon mcp --yolo`; `--no-yolo` overrides a saved
|
|
383
|
+
preference for that process. Never change this personal preference yourself.
|
|
384
|
+
Eligible
|
|
381
385
|
routine work then previews and executes internally; do not add a question
|
|
382
386
|
of your own. It is not a tool argument or repository setting, and you must
|
|
383
387
|
not enable it to work around a refusal. Its allowance is bound to the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cavelon/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "The cavelon binary: CLI and local MCP server for building Cavelon solutions with a coding agent.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/goodguys-gmbh/cavelon-dev-kit",
|