@cavelon/cli 0.2.1 → 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/api-approval-policy.js +43 -0
- package/dist/automation-policy.js +45 -0
- package/dist/automation-settings.js +35 -0
- package/dist/command.js +2 -0
- package/dist/commands/api.js +27 -13
- package/dist/commands/index.js +4 -1
- package/dist/commands/loops.js +9 -6
- package/dist/commands/setup.js +112 -8
- package/dist/commands/solution.js +23 -9
- package/dist/confirm-token.js +8 -5
- package/dist/context.js +3 -0
- package/dist/kit-codes.js +1 -0
- package/dist/main.js +13 -0
- package/dist/mcp.js +22 -30
- package/dist/native-assets/manifest.json +1 -1
- package/dist/setup-agents.js +91 -12
- package/dist/skills/cavelon-authoring/SKILL.md +6 -4
- package/dist/skills/cavelon-long-running/SKILL.md +11 -4
- package/dist/skills/cavelon-loop/SKILL.md +58 -29
- package/dist/skills/cavelon-testing/SKILL.md +3 -1
- package/package.json +1 -1
package/dist/confirm-token.js
CHANGED
|
@@ -39,6 +39,9 @@ async function gateOf(ctx, input, tool, change, options) {
|
|
|
39
39
|
const given = input.options.confirm;
|
|
40
40
|
const driven = drivenByAgent(ctx);
|
|
41
41
|
const tokenGiven = typeof given === "string" && given !== "";
|
|
42
|
+
if (options.automatic && !options.person && given === undefined) {
|
|
43
|
+
return { confirmed: true, fields: {}, confirm: (command) => command };
|
|
44
|
+
}
|
|
42
45
|
const approve = () => {
|
|
43
46
|
if (!driven)
|
|
44
47
|
ctx.approved = { guarded: Boolean(options.person) };
|
|
@@ -86,7 +89,7 @@ async function gateOf(ctx, input, tool, change, options) {
|
|
|
86
89
|
confirmed: false,
|
|
87
90
|
fields: { confirm_token: token, token_required: true },
|
|
88
91
|
confirm,
|
|
89
|
-
mismatch: `--confirm alone does not confirm when a coding agent runs cavelon. Nothing was changed:
|
|
92
|
+
mismatch: `--confirm alone does not confirm when a coding agent runs cavelon. Nothing was changed: review this preview against the requested work, then run the command below, which carries this change's token.`,
|
|
90
93
|
exitCode: ExitCode.needsAction,
|
|
91
94
|
};
|
|
92
95
|
}
|
|
@@ -134,7 +137,7 @@ export function needsPerson(command) {
|
|
|
134
137
|
});
|
|
135
138
|
}
|
|
136
139
|
export function confirmThroughClient(tool, token) {
|
|
137
|
-
return `
|
|
140
|
+
return `Call ${tool} again with the same arguments and confirm: "${token}": the client asks the person to approve exactly this change. Do not ask for an additional chat confirmation; nothing changes without the dialog's yes.`;
|
|
138
141
|
}
|
|
139
142
|
export function confirmInTerminal(command) {
|
|
140
143
|
return `${command} (the person runs it in their own terminal: a coding agent cannot confirm this change)`;
|
|
@@ -143,16 +146,16 @@ export function shellTokenRequired(command) {
|
|
|
143
146
|
return new CavelonError(ExitCode.needsAction, {
|
|
144
147
|
code: "confirm_token_required",
|
|
145
148
|
message: "--confirm alone does not confirm when a coding agent runs cavelon; nothing was changed.",
|
|
146
|
-
hint: `Run \`${command}\` without --confirm
|
|
149
|
+
hint: `Run \`${command}\` without --confirm and review the preview. Follow needs_person when present; otherwise confirm the requested work with the token it prints.`,
|
|
147
150
|
});
|
|
148
151
|
}
|
|
149
152
|
export function confirmTokenRequired(tool) {
|
|
150
153
|
return new CavelonError(ExitCode.usage, {
|
|
151
154
|
code: "confirm_token_required",
|
|
152
155
|
message: `${tool} confirms only with the confirm_token its preview returned, not with true; nothing was changed.`,
|
|
153
|
-
hint: `Call ${tool} without confirm
|
|
156
|
+
hint: `Call ${tool} without confirm and review the preview. Follow needs_person when present; otherwise call it again for the requested work with confirm set to its confirm_token.`,
|
|
154
157
|
});
|
|
155
158
|
}
|
|
156
159
|
export function confirmWith(tool, token) {
|
|
157
|
-
return `
|
|
160
|
+
return `Review this preview against the requested work, then call ${tool} again with the same arguments and confirm: "${token}" to make exactly this change. No additional person approval is required.`;
|
|
158
161
|
}
|
package/dist/context.js
CHANGED
|
@@ -10,6 +10,7 @@ import { promises as fs } from "node:fs";
|
|
|
10
10
|
import { checkPrivatePaths, solutionPaths } from "./file-boundary.js";
|
|
11
11
|
import { privateDirs as kitPrivateDirs } from "./paths.js";
|
|
12
12
|
import path from "node:path";
|
|
13
|
+
import { yoloScope } from "./automation-policy.js";
|
|
13
14
|
export function createContext(io, globals, mode = "cli") {
|
|
14
15
|
const warnings = [];
|
|
15
16
|
useShell(detectShell(io.env));
|
|
@@ -76,6 +77,8 @@ export function createContext(io, globals, mode = "cli") {
|
|
|
76
77
|
return contractsPromise;
|
|
77
78
|
},
|
|
78
79
|
};
|
|
80
|
+
if (globals.yolo && !globals.yoloScope)
|
|
81
|
+
globals.yoloScope = yoloScope(ctx).catch(() => undefined);
|
|
79
82
|
return ctx;
|
|
80
83
|
}
|
|
81
84
|
export function withWarnings(data, warnings) {
|
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,8 +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,
|
|
62
|
+
yolo,
|
|
50
63
|
instance: typeof parsed.options.instance === "string" ? parsed.options.instance : undefined,
|
|
51
64
|
tenant: typeof parsed.options.tenant === "string" ? parsed.options.tenant : undefined,
|
|
52
65
|
solutionEnv: spec.options?.env && typeof parsed.options.env === "string" ? parsed.options.env : undefined,
|
package/dist/mcp.js
CHANGED
|
@@ -15,27 +15,19 @@ const INSTRUCTIONS = "Tools for one Cavelon instance, acting with the token a pe
|
|
|
15
15
|
"(or CAVELON_TOKEN). You never see or pass the token. Tools that start work (kb_upload, test_run, " +
|
|
16
16
|
"loop_start, sandbox_seed, artifacts_export) return operation ids at once; read them with operation_status, which returns " +
|
|
17
17
|
`the state at once, or waits up to its timeout (at most ${MCP_MAX_WAIT_MS / 1000} s) when given one, and reports waited_ms, ` +
|
|
18
|
-
"and follow a loop with loop_iterations.
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"confirmation bound to the
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"on your own. With needs_person \"terminal\" this client cannot ask " +
|
|
32
|
-
"them: give the person the preview's confirm command, which they run in their own terminal, never in yours. These are " +
|
|
33
|
-
"harness_default and activate (the default route and a solution something reaches: live traffic), deactivate, tenant_create, " +
|
|
34
|
-
"variables_set replacing a value (every solution of the tenant reads it), variables_delete, limits_set, models_set_limit, trigger_identity, " +
|
|
35
|
-
"api for an operation that is not read-only, loop_start unless the trigger's solution is a draft (a run acts as the person " +
|
|
36
|
-
"and spends budget), and apply where its preview says show_to_person (tenant-wide sections, an active solution, deletions, " +
|
|
37
|
-
"env/prod, or database_queries.would_write). A draft's apply with no query writes or other person requirement, a draft's loop_start, loop_cancel, sandbox_seed and kb_upload's replace you confirm with the " +
|
|
38
|
-
"token once the person saw the preview. " +
|
|
18
|
+
"and follow a loop with loop_iterations. Routine work within the user's request needs no additional chat approval. " +
|
|
19
|
+
"In standard mode, review previews and confirm the exact token or apply preview id when no needs_person is present. " +
|
|
20
|
+
"A token binds one change, not a person's answer; confirm: true is refused, and changed input needs a new preview. " +
|
|
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
|
+
"routine API operations can execute in one call within the original instance, tenant, credential and solution scope. " +
|
|
23
|
+
"No tool argument or repository setting can enable this mode. A different target falls back to standard confirmation. " +
|
|
24
|
+
"Critical, shared, live and unknown changes retain needs_person in either mode. With needs_person \"client\", " +
|
|
25
|
+
"call again with the preview token: the client asks the person once. Do not ask for a separate chat yes before that dialog. " +
|
|
26
|
+
"Declined or unanswered dialogs change nothing; never supply the person's answer or reuse an earlier yes for another critical change. " +
|
|
27
|
+
"With needs_person \"terminal\", give the person the exact command to run in their own terminal, never the agent's shell. " +
|
|
28
|
+
"Instance confirmation ids remain bound to the exact request and are requested only after person approval; routine automation " +
|
|
29
|
+
"does not manufacture that approval. confirmation_required or confirmation_invalid changed nothing: return to a preview " +
|
|
30
|
+
"and the required person approval. YOLO never overrides person-only access or customer database-write consent. " +
|
|
39
31
|
"chat sends one message to a solution and returns its answer: the way to try one that is not the default route. " +
|
|
40
32
|
"kb_upload names files that match an active document of the knowledge base; with replace it replaces them, and where the " +
|
|
41
33
|
"instance's upload cannot, it returns what it would deactivate and uploads nothing without its confirm_token. " +
|
|
@@ -48,8 +40,7 @@ const INSTRUCTIONS = "Tools for one Cavelon instance, acting with the token a pe
|
|
|
48
40
|
"A tool whose description starts with \"Not for this credential\" is one the instance says this token or key may not use " +
|
|
49
41
|
"in this tenant (whoami lists its permissions, an API key's scopes and the operations a person runs): do not call it to " +
|
|
50
42
|
"find out; tell the person who does it. api_list marks such operations (may_send false) and leaves them out with usable. " +
|
|
51
|
-
"Run from your shell, cavelon's api command applies the same
|
|
52
|
-
"its preview printed. Tools read and write files only " +
|
|
43
|
+
"Run from your shell, cavelon's api command applies the same policy. Tools read and write files only " +
|
|
53
44
|
"inside the solution folder (the folder of cavelon.yaml, or the one the server started in), never in cavelon's own " +
|
|
54
45
|
"directories. In a repository with several solutions, pass solution_dir to select a folder inside the server's startup workspace. " +
|
|
55
46
|
"Use the same solution_dir for preview, confirmation and follow-up tools; harness selects an instance solution, not its local folder. Never infer a folder from a harness name. " +
|
|
@@ -73,7 +64,7 @@ const INSTRUCTIONS = "Tools for one Cavelon instance, acting with the token a pe
|
|
|
73
64
|
"that stays with a person. Use docs_search before guessing, " +
|
|
74
65
|
"and api_list/api_describe/api for anything without its own tool. " +
|
|
75
66
|
"use_tenant chooses the tenant for this MCP session only and never changes the tenant stored for the person; every preview " +
|
|
76
|
-
"names the instance,
|
|
67
|
+
"names the instance, tenant and mode it acts on (its target); check these against the requested work. " +
|
|
77
68
|
"The first result of a session may carry a warning that cavelon, the Cavelon plugin or this folder's skills are behind " +
|
|
78
69
|
"the latest release, with the commands that update them: pass it on to the person, who runs them; do not run them yourself.";
|
|
79
70
|
export function mcpInstructions(commands) {
|
|
@@ -246,15 +237,16 @@ async function askThroughClient(server, message, relatedRequestId) {
|
|
|
246
237
|
function mcpIo(io) {
|
|
247
238
|
return { ...io, stdout: { write: () => true, isTTY: false } };
|
|
248
239
|
}
|
|
249
|
-
export function createMcpServer(io, commands, updates = {}) {
|
|
240
|
+
export function createMcpServer(io, commands, updates = {}, startup = {}) {
|
|
250
241
|
const tools = commands.filter((c) => c.mcpTool);
|
|
251
242
|
const byName = new Map(tools.map((c) => [toolName(c), c]));
|
|
252
243
|
const server = new Server({ name: "cavelon", version: KIT_VERSION }, { capabilities: { tools: { listChanged: true } }, instructions: mcpInstructions(commands) });
|
|
253
244
|
const notice = startSessionUpdateCheck(io, updates);
|
|
254
245
|
const sessionTenants = new Map();
|
|
246
|
+
const launch = createContext(mcpIo(io), { ...startup, json: true }, "mcp").globals;
|
|
255
247
|
async function credentialAccess() {
|
|
256
248
|
const read = (async () => {
|
|
257
|
-
const ctx = createContext(mcpIo(io), { json: true, sessionTenants }, "mcp");
|
|
249
|
+
const ctx = createContext(mcpIo(io), { ...launch, json: true, sessionTenants }, "mcp");
|
|
258
250
|
const session = await ctx.session();
|
|
259
251
|
if (!session.url || !session.token)
|
|
260
252
|
return undefined;
|
|
@@ -294,7 +286,7 @@ export function createMcpServer(io, commands, updates = {}) {
|
|
|
294
286
|
return fail(usageError(`Missing ${missing.join(", ")}.`));
|
|
295
287
|
}
|
|
296
288
|
const tenant = !ownsTenant(spec) && typeof args.tenant === "string" ? args.tenant : undefined;
|
|
297
|
-
const solutionEnv = spec.options?.env && typeof args.env === "string" ? args.env :
|
|
289
|
+
const solutionEnv = spec.options?.env && typeof args.env === "string" ? args.env : launch.solutionEnv;
|
|
298
290
|
let folder;
|
|
299
291
|
try {
|
|
300
292
|
folder = await solutionDirectory(io, args.solution_dir);
|
|
@@ -302,14 +294,14 @@ export function createMcpServer(io, commands, updates = {}) {
|
|
|
302
294
|
catch (error) {
|
|
303
295
|
return fail(error);
|
|
304
296
|
}
|
|
305
|
-
const ctx = createContext(mcpIo(folder.io), { json: true, tenant, solutionEnv, sessionTenants }, "mcp");
|
|
297
|
+
const ctx = createContext(mcpIo(folder.io), { ...launch, json: true, tenant: tenant ?? launch.tenant, solutionEnv: solutionEnv ?? launch.solutionEnv, sessionTenants }, "mcp");
|
|
306
298
|
if (clientAsks(server))
|
|
307
299
|
ctx.askPerson = (message) => askThroughClient(server, message, requestId);
|
|
308
300
|
for (const message of renamed)
|
|
309
301
|
ctx.warn(message);
|
|
310
302
|
try {
|
|
311
|
-
const chosen = tenant ?? (await ctx.session().then((s) => (s.tenantSource === "session" ? s.tenant : undefined), () => undefined));
|
|
312
|
-
const { result, warnings } = await printingFor({ mode: "mcp", commands, solutionDir: folder.selected, personCwd: folder.directory, ...(spec.storesTarget ? {} : { tenant: chosen, env: solutionEnv }) }, async () => {
|
|
303
|
+
const chosen = tenant ?? launch.tenant ?? (await ctx.session().then((s) => (s.tenantSource === "session" || s.tenantSource?.startsWith("env/") ? s.tenant : undefined), () => undefined));
|
|
304
|
+
const { result, warnings } = await printingFor({ mode: "mcp", commands, solutionDir: folder.selected, personCwd: folder.directory, ...(spec.storesTarget ? {} : { instance: launch.instance, tenant: chosen, env: solutionEnv }) }, async () => {
|
|
313
305
|
try {
|
|
314
306
|
const done = await spec.run(ctx, inputFrom(spec, args));
|
|
315
307
|
return { result: { ...done, data: spokenHints(done.data) }, warnings: ctx.warnings.map(spoken) };
|
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())));
|
|
@@ -50,7 +50,8 @@ for a public widget), **propose the change; the person decides.**
|
|
|
50
50
|
- Run `cavelon limits set <key> <value>` without `--confirm` (MCP: `limits_set`
|
|
51
51
|
without `confirm`). It changes nothing and shows the old and the new value,
|
|
52
52
|
the operation it would send and the permissions it needs. Show that to the
|
|
53
|
-
person with your reason (what fails or waits now)
|
|
53
|
+
person with your reason (what fails or waits now). Over MCP, use the native
|
|
54
|
+
approval described next without asking for a separate chat yes.
|
|
54
55
|
- The confirm is the person's. Over MCP, call `limits_set` again with the
|
|
55
56
|
same arguments and `confirm` set to the preview's `confirm_token`: the
|
|
56
57
|
client then asks the person, and nothing changes without their yes. From
|
|
@@ -121,9 +122,10 @@ endpoint.
|
|
|
121
122
|
file). For one row's limit, prefer `cavelon models set-limit`.
|
|
122
123
|
|
|
123
124
|
**Propose a limit; the person decides.** Say which value you would set and
|
|
124
|
-
why (what the endpoint serves, which rows share it, what waits or fails now)
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
why (what the endpoint serves, which rows share it, what waits or fails now).
|
|
126
|
+
Over MCP, use one native approval without a preliminary chat yes. From your
|
|
127
|
+
shell, give the person the printed `models set-limit` confirmation command to
|
|
128
|
+
run in their own terminal; never run it on their behalf. A limit
|
|
127
129
|
`cavelon limits` names as the operator's (the run caps, the slot waits, the
|
|
128
130
|
licence) is not yours or the tenant's to change: tell the person who changes
|
|
129
131
|
it and where, as the output says.
|
|
@@ -66,12 +66,19 @@ cavelon wait <operation-id> --timeout 90s # exit 0 done, 1 failed, 5
|
|
|
66
66
|
|
|
67
67
|
A loop started from `cavelon` runs **as the person whose token it is**, checked
|
|
68
68
|
again on every iteration, and spends the tenant's budget. So `loop start`
|
|
69
|
-
previews first and starts nothing without `--confirm`. For a trigger of a
|
|
69
|
+
previews first and normally starts nothing without `--confirm`. For a trigger of a
|
|
70
70
|
draft solution, run the confirm command it prints (from your shell it carries
|
|
71
71
|
the preview's token; over MCP call `loop_start` again with `confirm` set to its
|
|
72
72
|
`confirm_token`). Any other run needs the person's yes (`needs_person` in the
|
|
73
73
|
preview): over MCP the client asks them when you confirm with the token; from
|
|
74
|
-
your shell the preview names the command they run in their own terminal.
|
|
74
|
+
your shell the preview names the command they run in their own terminal.
|
|
75
|
+
Do not ask for a separate chat approval before the native dialog. Reading and
|
|
76
|
+
confirming a routine draft preview within the requested work needs no extra
|
|
77
|
+
question. Explicit `--yolo` can combine preview and start for a trigger of the
|
|
78
|
+
selected draft solution within the process's original scope. It follows the
|
|
79
|
+
cavelon-loop skill's critical-change rules and grants no extra budget or
|
|
80
|
+
standing authority.
|
|
81
|
+
If `loop start` exits 8 (a timeout, a cut
|
|
75
82
|
connection), the run may have started: retry only with the
|
|
76
83
|
`--idempotency-key <key>` its error names, never without it, or a second run
|
|
77
84
|
starts and spends the budget again. `cavelon trace <operation-id>` reads the
|
|
@@ -130,8 +137,8 @@ Two reasons end work for capacity; each has its code in `cavelon explain`:
|
|
|
130
137
|
`max_concurrent_requests` and no slot freed within
|
|
131
138
|
`model_endpoint_slot_wait_seconds`. Retry later, or, if the endpoint can serve
|
|
132
139
|
more, propose raising the Model Registry row's `max_concurrent_requests`
|
|
133
|
-
(`cavelon models list` shows it).
|
|
134
|
-
|
|
140
|
+
(`cavelon models list` shows it). Preview `cavelon models set-limit
|
|
141
|
+
<model_id> <n>` for the person's decision: over MCP the client asks the person
|
|
135
142
|
when you confirm with the token; from your shell the person runs the confirm
|
|
136
143
|
command it prints in their own terminal.
|
|
137
144
|
|
|
@@ -86,7 +86,8 @@ use it when you parse the result.
|
|
|
86
86
|
chose, which may be another one. The commands `cavelon` prints carry the
|
|
87
87
|
`--tenant` (and `--env`) you gave, confirm lines included; run them as printed.
|
|
88
88
|
Every preview names where it acts (`acts on:`, `target` in `--json`): the
|
|
89
|
-
instance, the tenant and the mode;
|
|
89
|
+
instance, the tenant and the mode; check it against the requested work.
|
|
90
|
+
Include it whenever a change needs personal approval.
|
|
90
91
|
Over MCP, `use_tenant` chooses the tenant for this session only and never
|
|
91
92
|
changes the person's stored tenant. A tenant API key in `CAVELON_TOKEN` acts
|
|
92
93
|
only in its own tenant: a command that names another is refused with
|
|
@@ -275,11 +276,12 @@ successful activation's `took_default_route` and corresponding from/name
|
|
|
275
276
|
fields report the actual effect, which may differ. `status` shows the
|
|
276
277
|
preview too.
|
|
277
278
|
|
|
278
|
-
-
|
|
279
|
-
|
|
280
|
-
-
|
|
281
|
-
|
|
282
|
-
|
|
279
|
+
- Make the solution the default only when the user's request calls for it.
|
|
280
|
+
If the intended routing is unclear, ask; it changes live traffic.
|
|
281
|
+
- `cavelon activate --make-default` (or `cavelon harness default <solution>`)
|
|
282
|
+
previews the change, naming the current default. For a requested route
|
|
283
|
+
change, proceed directly to its approval step without another chat yes.
|
|
284
|
+
You cannot approve it yourself: over MCP the client asks the person when you
|
|
283
285
|
call the tool with the preview's token; from your shell the person runs the
|
|
284
286
|
confirm command it printed in their own terminal. `harness default` refuses a draft
|
|
285
287
|
(`solution_not_active`, exit 4): only an active solution can be the
|
|
@@ -299,14 +301,18 @@ preview too.
|
|
|
299
301
|
route; the default route itself is refused until another solution is the
|
|
300
302
|
default.
|
|
301
303
|
|
|
302
|
-
##
|
|
304
|
+
## Confirm routine work; ask once for critical changes
|
|
303
305
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
+
A technical preview is not a request for a chat approval. Within the user's
|
|
307
|
+
requested work, read and confirm a preview that needs no person without
|
|
308
|
+
asking them again or showing every intermediate preview. For `apply`, check
|
|
309
|
+
`show_to_person: false` and no `needs_person` requirement. This includes
|
|
310
|
+
`apply` to a draft solution in a test environment (no query
|
|
306
311
|
writes or other reason to show it to a person), `loop start` of a trigger
|
|
307
312
|
of a draft solution, `loop cancel` and `sandbox seed` of a test run or Sandbox
|
|
308
|
-
you started,
|
|
309
|
-
the person
|
|
313
|
+
you started, `kb upload --replace`, and known routine `api` operations.
|
|
314
|
+
Summarize the outcome with the work. A preview needs the person's decision
|
|
315
|
+
when:
|
|
310
316
|
|
|
311
317
|
- the preview lists an active solution under "reaches active", or the target
|
|
312
318
|
solution is active;
|
|
@@ -331,14 +337,15 @@ budget), `limits set`, `models set-limit`, `trigger identity` (standing
|
|
|
331
337
|
authority for a trigger), `harness default`, `activate --make-default`,
|
|
332
338
|
`activate` of a solution its preview says a channel or trigger reaches,
|
|
333
339
|
whose activation takes the default route, or whose reach or route effect is unknown,
|
|
334
|
-
`deactivate` (they move live traffic), and `api`
|
|
335
|
-
|
|
340
|
+
`deactivate` (they move live traffic), and `api` outside its known routine
|
|
341
|
+
operations, `cavelon` does not take your confirm as theirs. Their preview
|
|
336
342
|
says how in `needs_person`:
|
|
337
343
|
|
|
338
|
-
- `"client"` (over MCP, where your client can ask the person):
|
|
339
|
-
|
|
340
|
-
to its token (for `apply`, the preview id). The client
|
|
341
|
-
to approve exactly that change
|
|
344
|
+
- `"client"` (over MCP, where your client can ask the person): call the tool
|
|
345
|
+
again with the same arguments and `confirm` set
|
|
346
|
+
to its token (for `apply`, the preview id). The client presents the preview
|
|
347
|
+
and asks the person to approve exactly that change. Do not first ask for a
|
|
348
|
+
separate chat yes. Nothing changes without their answer. A no,
|
|
342
349
|
or no answer within 10 minutes, returns `confirm_declined` (exit code 5):
|
|
343
350
|
ask the person what they want instead of trying again.
|
|
344
351
|
- `"terminal"` (your shell, or a client that cannot ask): the preview's
|
|
@@ -352,9 +359,9 @@ or active trigger reaches it and readiness explicitly publishes
|
|
|
352
359
|
null, the kit reads the matching list row; an unreadable list, missing row
|
|
353
360
|
or missing count keeps reach unknown and needs the person.
|
|
354
361
|
|
|
355
|
-
Asking the person is the kit's responsibility alone.
|
|
356
|
-
|
|
357
|
-
different change. This includes creating, changing or deleting a database
|
|
362
|
+
Asking the person is the kit's responsibility alone. Use one personal approval
|
|
363
|
+
for each critical change; never answer on their behalf or reuse a previous
|
|
364
|
+
yes for a different change. This includes creating, changing or deleting a database
|
|
358
365
|
query and imports that create or change one, even on a draft.
|
|
359
366
|
|
|
360
367
|
Where the instance publishes `confirmations.enforced`, after the person's
|
|
@@ -369,6 +376,27 @@ or `confirmation_invalid` (exit code 5) means the instance changed nothing:
|
|
|
369
376
|
show the person the preview again and let them confirm it (in the client's
|
|
370
377
|
dialog or their own terminal), never retry on your own.
|
|
371
378
|
|
|
379
|
+
**YOLO is explicitly enabled by the person.** A CLI invocation may start with
|
|
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
|
|
385
|
+
routine work then previews and executes internally; do not add a question
|
|
386
|
+
of your own. It is not a tool argument or repository setting, and you must
|
|
387
|
+
not enable it to work around a refusal. Its allowance is bound to the
|
|
388
|
+
process's original instance, resolved tenant, credential, local solution
|
|
389
|
+
folder, selected solution, environment and bindings. A different MCP target
|
|
390
|
+
uses normal policy; returning to the original scope may use its allowance
|
|
391
|
+
again. Eligible work includes ordinary draft imports, known routine API
|
|
392
|
+
operations and starting a trigger of the selected draft solution. Existing
|
|
393
|
+
tenant budgets still apply. Critical changes still ask once. Saved database queries, live or shared changes,
|
|
394
|
+
production and deleting imports stay critical. YOLO does not automatically
|
|
395
|
+
confirm Sandbox replacement, document replacement, run cancellation or
|
|
396
|
+
connection deletion. Permissions, secret handling, person-only operations,
|
|
397
|
+
server request binding and end-user database write consent remain unchanged.
|
|
398
|
+
Your host's own shell/tool approvals are separate.
|
|
399
|
+
|
|
372
400
|
**Over MCP, confirm with the preview's token.** `api`, `tenant_create`,
|
|
373
401
|
`variables_set` where it replaces a value, `loop_start`, `limits_set`,
|
|
374
402
|
`models_set_limit`, `loop_cancel`, `sandbox_seed`, `trigger_identity`,
|
|
@@ -376,12 +404,12 @@ dialog or their own terminal), never retry on your own.
|
|
|
376
404
|
trigger reaches, whose activation takes the default route or whose reach or
|
|
377
405
|
route effect is unknown, or with `make_default`, and
|
|
378
406
|
`kb_upload` where it would deactivate documents return a `confirm_token` with
|
|
379
|
-
their preview.
|
|
407
|
+
their preview. Read
|
|
380
408
|
the preview, then call the tool again with the same arguments and `confirm`
|
|
381
409
|
set to that token; it makes exactly the change shown, after the person's yes
|
|
382
410
|
where the preview says `needs_person`. `confirm: true` is
|
|
383
411
|
refused (`confirm_token_required`), and a token of another change returns the
|
|
384
|
-
new preview with `token_mismatch` (exit code 4):
|
|
412
|
+
new preview with `token_mismatch` (exit code 4): review that one instead. Tool
|
|
385
413
|
arguments are spelled in snake_case (`make_default`, `keep_both`, `dry_run`);
|
|
386
414
|
an argument a tool does not list is refused (`unknown_argument`) with the
|
|
387
415
|
closest one named. Over MCP the next steps a tool returns (hints, `next`,
|
|
@@ -392,8 +420,9 @@ make the call as written, filling a value in angle brackets (a
|
|
|
392
420
|
**From your shell, `--confirm` takes the same token, where you may confirm.**
|
|
393
421
|
Run by a coding agent, `loop start` of a draft's trigger, `loop cancel`,
|
|
394
422
|
`sandbox seed` and `kb upload --replace` print their preview with a confirm
|
|
395
|
-
token and the command that confirms it (`… --confirm <token>`).
|
|
396
|
-
preview, then run exactly that command
|
|
423
|
+
token and the command that confirms it (`… --confirm <token>`). Read the
|
|
424
|
+
preview, then run exactly that command within the authorized work. Changes
|
|
425
|
+
that need the person's yes
|
|
397
426
|
print no token and name the command the person runs in their own terminal. A
|
|
398
427
|
bare `--confirm`, as the docs show it for a person's terminal, changes nothing
|
|
399
428
|
from your shell and exits 5; a token of another change exits 4 with the new
|
|
@@ -404,11 +433,11 @@ preview. A line printed before its preview exists ends in
|
|
|
404
433
|
**`cavelon api` from your shell has the guards of the MCP `api` tool**, since
|
|
405
434
|
`cavelon` sees that a coding agent runs it:
|
|
406
435
|
|
|
407
|
-
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
token (`confirm_needs_person`). Over MCP
|
|
411
|
-
person's
|
|
436
|
+
- Known routine mutations print a preview and token you may confirm within
|
|
437
|
+
the requested work without a separate chat approval. Critical or unknown
|
|
438
|
+
mutations instead name the person's own-terminal command; you cannot send
|
|
439
|
+
those yourself with a token (`confirm_needs_person`). Over MCP they require
|
|
440
|
+
the person's answer in the native dialog.
|
|
412
441
|
- It refuses an operation the instance keeps for a person
|
|
413
442
|
(`operation_for_a_person`) and a body that sets a field the instance marks as
|
|
414
443
|
a secret value (`secret_field_for_a_person`), with or without `--confirm`,
|
|
@@ -312,7 +312,9 @@ the body does the same, but needs the id and a confirm. `cavelon deactivate
|
|
|
312
312
|
--harness <solution>` takes an active solution out of live traffic again; it
|
|
313
313
|
previews first and is the person's decision: show the preview; over MCP the
|
|
314
314
|
client asks them when you confirm with its token, and from your shell they run
|
|
315
|
-
the confirm command in their own terminal.
|
|
315
|
+
the confirm command in their own terminal. Do not add a separate chat approval
|
|
316
|
+
before that native dialog; an explicitly enabled YOLO mode still asks for this
|
|
317
|
+
critical change. When every suite passes,
|
|
316
318
|
`cavelon activate --harness <name or slug>` goes through the readiness gate; if the
|
|
317
319
|
token may not activate, a person activates in the Admin. A solution that a
|
|
318
320
|
channel or an active trigger reaches goes live for them at once, so its
|