@cavelon/cli 0.2.8 → 0.2.10
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/commands/publication.js +49 -8
- package/dist/confirm-token.js +2 -2
- package/dist/kit-codes.js +1 -0
- package/dist/mcp.js +5 -4
- package/dist/native-assets/manifest.json +1 -1
- package/dist/setup-agents.js +9 -4
- package/dist/skills/cavelon-loop/SKILL.md +9 -2
- package/dist/update-check.js +1 -1
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ import { CavelonError, ExitCode, usageError } from "../errors.js";
|
|
|
5
5
|
import { clip, keyValues, table } from "../format.js";
|
|
6
6
|
import { harnessNotFoundError, lookupHarness } from "../harness-ref.js";
|
|
7
7
|
import { callOperation, workflowOperation } from "../invoke.js";
|
|
8
|
+
import { canonical } from "../package-files.js";
|
|
8
9
|
import { cavelonCommand } from "../printed.js";
|
|
9
10
|
const BASE = "/api/v1/harnesses/{harness_id}";
|
|
10
11
|
const READ = `${BASE}/publication`;
|
|
@@ -31,18 +32,47 @@ async function read(ctx, id, snapshot) {
|
|
|
31
32
|
const { doc, op } = await operation(ctx, READ);
|
|
32
33
|
const result = await callOperation(ctx, await ctx.client(), doc, op, { params: { harness_id: [id], ...(snapshot ? { snapshot_id: [snapshot] } : {}) } });
|
|
33
34
|
const p = result.data;
|
|
34
|
-
if (!p || !Number.isSafeInteger(p.published_version) || p.published_version < 0 || !Number.isSafeInteger(p.draft_revision) || p.draft_revision < 0 || typeof p.has_draft !== "boolean" || !Array.isArray(p.changes) || !Array.isArray(p.readiness?.blockers) || !Number.isSafeInteger(p.waiting_runs_affected) || p.waiting_runs_affected < 0 || !Array.isArray(p.review_run_ids) || p.review_run_ids.some(id => typeof id !== "string") || !Array.isArray(p.waiting_runs) || !Array.isArray(p.published_snapshots) || typeof p.can_rollback !== "boolean") {
|
|
35
|
+
if (!p || !Number.isSafeInteger(p.published_version) || p.published_version < 0 || !Number.isSafeInteger(p.draft_revision) || p.draft_revision < 0 || typeof p.has_draft !== "boolean" || !Array.isArray(p.changes) || !Array.isArray(p.readiness?.blockers) || [p.readiness.warnings, p.readiness.checks].some(value => value !== undefined && !Array.isArray(value)) || !Number.isSafeInteger(p.waiting_runs_affected) || p.waiting_runs_affected < 0 || !Array.isArray(p.review_run_ids) || p.review_run_ids.some(id => typeof id !== "string") || !Array.isArray(p.waiting_runs) || !Array.isArray(p.published_snapshots) || typeof p.can_rollback !== "boolean") {
|
|
35
36
|
throw new CavelonError(ExitCode.failure, { code: "publication_state_unknown", message: "The instance did not describe a complete publication state; nothing was changed.", hint: "Read the solution's publication state in the Admin or update the instance." });
|
|
36
37
|
}
|
|
37
38
|
return p;
|
|
38
39
|
}
|
|
40
|
+
function findingsText(label, findings) {
|
|
41
|
+
if (!findings?.length)
|
|
42
|
+
return "";
|
|
43
|
+
const lines = findings.slice(0, 20).map(finding => {
|
|
44
|
+
if (finding && typeof finding === "object") {
|
|
45
|
+
const f = finding;
|
|
46
|
+
if (typeof f.label === "string" && typeof f.state === "string" && typeof f.detail === "string") {
|
|
47
|
+
return clip(`${f.label} (${f.state}): ${f.detail}${Array.isArray(f.items) && f.items.length ? ` ${JSON.stringify(f.items)}` : ""}`, 500);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return clip(JSON.stringify(finding), 500);
|
|
51
|
+
});
|
|
52
|
+
if (findings.length > 20)
|
|
53
|
+
lines.push(`${findings.length - 20} more findings; read --json for the full review before approving.`);
|
|
54
|
+
return `\n\n${label}:\n${lines.join("\n")}`;
|
|
55
|
+
}
|
|
39
56
|
function stateText(p) {
|
|
40
57
|
return keyValues([
|
|
41
58
|
["published", `v${p.published_version}`],
|
|
42
59
|
["draft", p.has_draft ? `${p.draft_change_count} unpublished changes (revision ${p.draft_revision})` : "none"],
|
|
43
60
|
["readiness blockers", p.readiness.blockers.length],
|
|
61
|
+
["readiness warnings", p.readiness.warnings?.length ?? "not reported"],
|
|
44
62
|
["waiting runs affected", p.waiting_runs_affected],
|
|
45
|
-
]) + (p.
|
|
63
|
+
]) + findingsText("Blockers", p.readiness.blockers) + findingsText("Warnings", p.readiness.warnings) + findingsText("Readiness checks", p.readiness.checks) + (p.waiting_runs.length ? `\n\nWaiting runs:\n${table(p.waiting_runs.slice(0, 20), ["id", "node_name"])}` : "") + (p.changes.length ? `\n\n${table(p.changes.slice(0, 50), ["entity", "name", "action", "id"])}` : "") + (p.changes.length > 50 ? `\n${p.changes.length - 50} more changes; --json includes all.` : "");
|
|
64
|
+
}
|
|
65
|
+
function readinessReview(p) {
|
|
66
|
+
const sorted = (values) => values ? [...values].sort((a, b) => canonical(a).localeCompare(canonical(b))) : null;
|
|
67
|
+
return { ready_to_activate: p.readiness.ready_to_activate ?? null, blockers: sorted(p.readiness.blockers), warnings: sorted(p.readiness.warnings), checks: sorted(p.readiness.checks) };
|
|
68
|
+
}
|
|
69
|
+
function publishRisks(p) {
|
|
70
|
+
return [
|
|
71
|
+
"Publishing risks:",
|
|
72
|
+
"New live requests will use the reviewed draft; this is not a test run.",
|
|
73
|
+
...(p.waiting_runs_affected ? [`The instance reports ${p.waiting_runs_affected} affected waiting runs; review the listed runs.`] : []),
|
|
74
|
+
...(p.readiness.warnings?.length ? ["Readiness warnings remain. Publish only if you accept the warnings shown above."] : []),
|
|
75
|
+
].join("\n");
|
|
46
76
|
}
|
|
47
77
|
export const publication = {
|
|
48
78
|
name: "harness publication",
|
|
@@ -78,6 +108,11 @@ function mutationBody(action, p, snapshot) {
|
|
|
78
108
|
}
|
|
79
109
|
return body;
|
|
80
110
|
}
|
|
111
|
+
function reviewedChange(harnessId, action, p, snapshot) {
|
|
112
|
+
const changes = [...p.changes].sort((a, b) => (a.entity + ":" + a.id).localeCompare(b.entity + ":" + b.id));
|
|
113
|
+
const waiting = [...p.waiting_runs].sort((a, b) => a.id.localeCompare(b.id));
|
|
114
|
+
return { harness: harnessId, body: mutationBody(action, p, snapshot), changes, waiting_runs: waiting, has_draft: p.has_draft, ...(action !== "discard-draft" ? { readiness: readinessReview(p), waiting_runs_affected: p.waiting_runs_affected } : {}) };
|
|
115
|
+
}
|
|
81
116
|
function commandWords(action, input, harness, snapshot) {
|
|
82
117
|
const words = [...ACTIONS[action].words, "--harness", harness.slug];
|
|
83
118
|
const env = stringOption(input, "env");
|
|
@@ -107,11 +142,11 @@ async function checkMutationAccess(ctx, action) {
|
|
|
107
142
|
if (permission.allowed === false)
|
|
108
143
|
throw new CavelonError(ExitCode.unauthorized, { code: "permission_missing", message: "This credential cannot perform the publication change; nothing was changed.", hint: whoInstead(access, permission) });
|
|
109
144
|
}
|
|
110
|
-
function previewResult(harness, p, gate,
|
|
145
|
+
function previewResult(harness, p, gate, review, words, snapshot) {
|
|
111
146
|
const confirm = gate.confirm(cavelonCommand(...words));
|
|
112
147
|
return {
|
|
113
148
|
data: { changed: false, harness, publication: p, ...(snapshot ? { rollback_snapshot: snapshot } : {}), confirm, ...gate.fields },
|
|
114
|
-
text: [
|
|
149
|
+
text: [review, gate.where, ...(gate.mismatch ? [gate.mismatch] : []), `Show this to a person; with their yes: ${confirm}`].join("\n"),
|
|
115
150
|
...(gate.exitCode ? { exitCode: gate.exitCode } : {}),
|
|
116
151
|
};
|
|
117
152
|
}
|
|
@@ -135,11 +170,17 @@ async function runChange(ctx, input, action) {
|
|
|
135
170
|
const body = mutationBody(action, p, snapshot);
|
|
136
171
|
const words = commandWords(action, input, harness, snapshot);
|
|
137
172
|
const consequence = consequenceOf(action, harness, p, snapshot);
|
|
138
|
-
const
|
|
139
|
-
const
|
|
140
|
-
const gate = await confirmation(ctx, input, tool, {
|
|
173
|
+
const review = `${consequence}\n${stateText(p)}${action === "publish" ? `\n\n${publishRisks(p)}` : ""}`;
|
|
174
|
+
const change = reviewedChange(harness.id, action, p, snapshot);
|
|
175
|
+
const gate = await confirmation(ctx, input, tool, change, { person: { what: review, words, ...(action === "publish" ? { approval: { title: "Publish this solution", description: "I reviewed this draft, accept any remaining warnings and the effects on live traffic and affected waiting runs, and approve this publication." } } : {}) } });
|
|
141
176
|
if (!gate.confirmed)
|
|
142
|
-
return previewResult(harness, p, gate,
|
|
177
|
+
return previewResult(harness, p, gate, review, words, snapshot);
|
|
178
|
+
if (action === "publish" && ctx.mode === "mcp") {
|
|
179
|
+
const current = await read(ctx, harness.id);
|
|
180
|
+
if (canonical(change) !== canonical(reviewedChange(harness.id, action, current))) {
|
|
181
|
+
throw new CavelonError(ExitCode.conflict, { code: "publication_review_changed", message: "The publication review changed while awaiting approval; nothing was published.", hint: "Read the updated publication findings and request a fresh preview and personal approval." });
|
|
182
|
+
}
|
|
183
|
+
}
|
|
143
184
|
const result = await callOperation(ctx, await ctx.client(), doc, op, { params: { harness_id: [harness.id] }, body });
|
|
144
185
|
const data = result.data;
|
|
145
186
|
const warnings = Array.isArray(data.warnings) ? data.warnings.map(w => clip(String(w), 500)) : [];
|
package/dist/confirm-token.js
CHANGED
|
@@ -71,7 +71,7 @@ async function gateOf(ctx, input, tool, change, options) {
|
|
|
71
71
|
if (!tokenGiven)
|
|
72
72
|
return { confirmed: false, fields, confirm };
|
|
73
73
|
if (given === token) {
|
|
74
|
-
await personApproves(ctx, driven, { tool, what: person.what, command }, options);
|
|
74
|
+
await personApproves(ctx, driven, { tool, what: person.what, command, approval: person.approval }, options);
|
|
75
75
|
return { confirmed: true, fields: {}, confirm };
|
|
76
76
|
}
|
|
77
77
|
return {
|
|
@@ -113,7 +113,7 @@ export async function personApproves(ctx, driven, change, target = {}) {
|
|
|
113
113
|
if (personRoute(ctx, driven) === "terminal")
|
|
114
114
|
throw needsPerson(change.command);
|
|
115
115
|
const where = targetLine(await actingTarget(ctx, target));
|
|
116
|
-
const answer = await ctx.askPerson([change.what, where, `A coding agent asks to make this change through cavelon (${change.tool}). Approve only this exact change.`].filter(Boolean).join("\n"));
|
|
116
|
+
const answer = await ctx.askPerson([change.approval?.title, change.what, where, change.approval?.description, `A coding agent asks to make this change through cavelon (${change.tool}). Approve only this exact change.`].filter(Boolean).join("\n"), change.approval);
|
|
117
117
|
if (answer === "approved") {
|
|
118
118
|
ctx.approved = { guarded: change.guarded ?? true };
|
|
119
119
|
return;
|
package/dist/kit-codes.js
CHANGED
|
@@ -2,6 +2,7 @@ import { printMode } from "./printed.js";
|
|
|
2
2
|
export const KIT_ERROR_CODES = [
|
|
3
3
|
{ code: "invalid_trace_export", area: "cli", message: "The instance did not return a JSON trace and integrity manifest; no export was kept.", hint: "Retry the export; if it repeats, report the command and instance version without sharing sensitive trace contents." },
|
|
4
4
|
{ code: "publication_state_unknown", area: "cli", message: "The instance did not describe complete version, draft, readiness or affected-run state; nothing was changed.", hint: "Review publication in the Admin or update the instance before publishing from the kit." },
|
|
5
|
+
{ code: "publication_review_changed", area: "cli", message: "The publication review changed while awaiting approval; nothing was published.", hint: "Read the updated publication findings and request a fresh preview and personal approval." },
|
|
5
6
|
{ code: "held_for_privacy_review", area: "cli", message: "This document is held for privacy review; it is not indexed or readable.", hint: "A person with knowledge_bases.manage_documents reviews and releases it in the Admin. Tokens and API keys cannot release it; YOLO does not change this." },
|
|
6
7
|
{ code: "document_file_for_a_person", area: "cli", message: "This document file is restricted or not agent-readable.", hint: "A person with knowledge_bases.manage_documents opens it in the Admin. The privacy vault and conversion report are never returned to agents." },
|
|
7
8
|
{ code: "not_logged_in", area: "cli", message: "There is no token for the instance.", hint: "A person runs `cavelon login` (or sets CAVELON_URL and CAVELON_TOKEN); an agent never handles the token." },
|
package/dist/mcp.js
CHANGED
|
@@ -228,9 +228,10 @@ function clientAsks(server) {
|
|
|
228
228
|
const elicitation = server.getClientCapabilities()?.elicitation;
|
|
229
229
|
return Boolean(elicitation && (elicitation.form || Object.keys(elicitation).length === 0));
|
|
230
230
|
}
|
|
231
|
-
async function askThroughClient(server, message, relatedRequestId) {
|
|
231
|
+
async function askThroughClient(server, message, relatedRequestId, approval) {
|
|
232
232
|
try {
|
|
233
|
-
const
|
|
233
|
+
const requestedSchema = approval ? { ...APPROVAL_SCHEMA, properties: { approve: { ...APPROVAL_SCHEMA.properties.approve, ...approval } } } : APPROVAL_SCHEMA;
|
|
234
|
+
const result = await server.elicitInput({ mode: "form", message, requestedSchema }, { timeout: PERSON_WAIT_MS, relatedRequestId });
|
|
234
235
|
if (result.action === "accept" && result.content?.approve === true)
|
|
235
236
|
return "approved";
|
|
236
237
|
if (result.action === "decline" || result.action === "accept" && result.content?.approve === false)
|
|
@@ -304,8 +305,8 @@ export function createMcpServer(io, commands, updates = {}, startup = {}) {
|
|
|
304
305
|
}
|
|
305
306
|
const ctx = createContext(mcpIo(folder.io), { ...launch, json: true, tenant: tenant ?? launch.tenant, solutionEnv: solutionEnv ?? launch.solutionEnv, sessionTenants }, "mcp");
|
|
306
307
|
if (!clientUiUnavailable && clientAsks(server))
|
|
307
|
-
ctx.askPerson = async (message) => {
|
|
308
|
-
const answer = await askThroughClient(server, message, requestId);
|
|
308
|
+
ctx.askPerson = async (message, approval) => {
|
|
309
|
+
const answer = await askThroughClient(server, message, requestId, approval);
|
|
309
310
|
if (answer === "unavailable")
|
|
310
311
|
clientUiUnavailable = true;
|
|
311
312
|
return answer;
|
package/dist/setup-agents.js
CHANGED
|
@@ -174,8 +174,8 @@ async function pluginState(kind, program, env) {
|
|
|
174
174
|
return { marketplace: names.includes(MARKETPLACE), installed: Boolean(mine), enabled: mine?.enabled !== false };
|
|
175
175
|
}
|
|
176
176
|
const installed = (plugins.value?.installed ?? []).find((p) => p.pluginId === PLUGIN_ID && p.installed !== false);
|
|
177
|
-
const
|
|
178
|
-
return { marketplace:
|
|
177
|
+
const marketplace = (markets.value?.marketplaces ?? []).find((m) => m.name === MARKETPLACE);
|
|
178
|
+
return { marketplace: Boolean(marketplace), installed: Boolean(installed), enabled: installed?.enabled !== false, marketplaceSource: marketplace?.marketplaceSource };
|
|
179
179
|
}
|
|
180
180
|
function firstLine(text) {
|
|
181
181
|
return (text.split(/\r?\n/).find((l) => l.trim()) ?? "").trim().slice(0, 300);
|
|
@@ -292,8 +292,13 @@ export async function planAgent(agent, found, env, command, skills, platform = p
|
|
|
292
292
|
if (!state.marketplace && commands.marketplaceAdd.length) {
|
|
293
293
|
plan.changes.push({ kind: "marketplace", summary: "add the Cavelon plugin marketplace", target: display(program, commands.marketplaceAdd), outcome: "planned" });
|
|
294
294
|
}
|
|
295
|
-
if (update && state.marketplace && commands.marketplaceUpdate.length)
|
|
296
|
-
|
|
295
|
+
if (update && state.marketplace && commands.marketplaceUpdate.length) {
|
|
296
|
+
const local = kind === "codex" && state.marketplaceSource?.sourceType === "local";
|
|
297
|
+
plan.changes.push(local
|
|
298
|
+
? { kind: "marketplace", summary: "keep the local Cavelon plugin marketplace", target: state.marketplaceSource?.source ?? MARKETPLACE, outcome: "unchanged",
|
|
299
|
+
reason: "refresh the plugin from the existing local files; unpack the new offline release or update your checkout first to use a newer version" }
|
|
300
|
+
: { kind: "marketplace", summary: "refresh the Cavelon plugin marketplace", target: display(program, commands.marketplaceUpdate), outcome: "planned", refresh: true });
|
|
301
|
+
}
|
|
297
302
|
const refresh = update && state.installed && state.enabled;
|
|
298
303
|
plan.changes.push({
|
|
299
304
|
kind: "plugin",
|
|
@@ -158,8 +158,15 @@ When the instance advertises solution publication, an active solution's scoped
|
|
|
158
158
|
graph apply writes an unpublished draft. Read the explicit `publication`
|
|
159
159
|
report; older instances keep their previous behavior. Inspect it with
|
|
160
160
|
`cavelon harness publication <solution> --json`, run tests and fix readiness,
|
|
161
|
-
then review `cavelon publish --harness <solution>`.
|
|
162
|
-
|
|
161
|
+
then review `cavelon publish --harness <solution>`. Show the person the pending
|
|
162
|
+
edits, blockers, remaining warnings, readiness checks and affected waiting runs
|
|
163
|
+
before requesting publication. Blockers must be fixed; the person's single
|
|
164
|
+
publish form can accept remaining warnings and live-traffic effects. Call
|
|
165
|
+
`solution_publish` with the preview's token to open that form, without asking
|
|
166
|
+
for an extra chat yes. A client without a usable form returns an own-terminal
|
|
167
|
+
command. Changed findings need a fresh review, including changes while the
|
|
168
|
+
form was open. Publication changes live traffic and always needs the person's
|
|
169
|
+
fresh MCP/own-terminal confirmation,
|
|
163
170
|
including in YOLO. Never force it from the kit. Conflicting versions, revisions
|
|
164
171
|
or affected waiting runs require a fresh review. Shared tenant resources keep
|
|
165
172
|
their existing behavior and are not isolated by the graph draft.
|
package/dist/update-check.js
CHANGED
|
@@ -222,7 +222,7 @@ async function initSkillsVersion(cwd) {
|
|
|
222
222
|
}
|
|
223
223
|
const PLUGIN_UPDATE = {
|
|
224
224
|
claude: "`claude plugin marketplace update cavelon-dev-kit` and `claude plugin update cavelon@cavelon-dev-kit`",
|
|
225
|
-
codex: "`
|
|
225
|
+
codex: "`cavelon setup --update --agents codex`",
|
|
226
226
|
};
|
|
227
227
|
const INSTALL_DOCS = `https://github.com/${REPOSITORY}/blob/main/docs/install`;
|
|
228
228
|
function pluginUpdate(client) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cavelon/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
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",
|