@cavelon/cli 0.1.7 → 0.1.8
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 +12 -9
- package/dist/command.js +32 -1
- package/dist/commands/solution.js +59 -32
- package/dist/main.js +3 -2
- package/dist/mcp.js +15 -10
- package/dist/package-check.js +21 -4
- package/dist/preview-report.js +10 -0
- package/dist/skills/cavelon-authoring/SKILL.md +4 -0
- package/dist/skills/cavelon-loop/SKILL.md +7 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -127,10 +127,10 @@ Every command takes `--json` (one JSON document on stdout, errors included),
|
|
|
127
127
|
| `chat <message> [--harness] [--env] [--session <id>] [--timeout 90s]` | changing | Send one message to a solution and print its answer, with the session to continue and the conversation to trace; tries a draft or an active solution that is not the default route. |
|
|
128
128
|
| `deactivate [--harness] [--env] [--confirm [<token>]]` | changing (destructive) | Take an active solution out of live traffic: its status becomes `inactive` (not `draft`); previews first. |
|
|
129
129
|
| `init [--harness [--new]] [--agents <list>] [--hook] [--update] [--from <file> [--force]]` | changing (files) | Make this folder a solution: `cavelon.yaml`, `package/`, `tests/`, `env/`, `.cavelon/`; on a terminal it asks for the tenant and the solution (or a new one by name); a name close to an existing solution's is refused unless `--new`; `--from` writes a package file into it. |
|
|
130
|
-
| `pull [--harness] [--force] [--tenant-wide]` | changing (files) | Write the instance's package into `package/` and `tests/`, the inventory into `.cavelon/`. A solution's tenant-wide sections only with `--tenant-wide`, which says when the export carries none. |
|
|
130
|
+
| `pull [--harness] [--force] [--include-tenant-wide]` | changing (files) | Write the instance's package into `package/` and `tests/`, the inventory into `.cavelon/`. A solution's tenant-wide sections only with `--include-tenant-wide`, which says when the export carries none. |
|
|
131
131
|
| `validate [--offline] [--strict]` | read-only | Check the package files against the cached package schema, their references, unknown fields and models; `--strict` fails on warnings. |
|
|
132
132
|
| `schema [<section>[.<field>…] \| <type>] [--offline]` | read-only | The package schema's sections, or the fields of a section, a nested field (`agents.handoffs`) or a type, with a minimal example. |
|
|
133
|
-
| `apply [--env] [--harness] [--mode] [--tenant-wide]` | changing | Preview the files against the instance; prints and stores a preview id. A solution's tenant-wide sections go along only with `--tenant-wide`, for the whole tenant. |
|
|
133
|
+
| `apply [--env] [--harness] [--mode] [--include-tenant-wide]` | changing | Preview the files against the instance; prints and stores a preview id. A solution's tenant-wide sections go along only with `--include-tenant-wide`, for the whole tenant. |
|
|
134
134
|
| `apply --confirm <preview-id>` | changing | Import exactly that preview; a stale one, or one the import's own check refuses (it names the blockers), exits 4. |
|
|
135
135
|
| `explain <code>` | read-only | Look a code up in the instance's error catalog. |
|
|
136
136
|
| `variables list` / `variables get <name>` | read-only | The tenant's plain-text variables (`{{var:…}}`) with their values. |
|
|
@@ -637,9 +637,9 @@ cavelon activate --harness support
|
|
|
637
637
|
which). Files of sections the schema does not know are kept byte for byte. A
|
|
638
638
|
solution's pull leaves the tenant-wide sections out of the folder (those the
|
|
639
639
|
schema marks `x-cavelon-scope: tenant`; on an instance that marks none,
|
|
640
|
-
`tenant_settings` and `model_registry`) unless `--tenant-wide`, which
|
|
641
|
-
export for them (`include_tenant_wide`) where the instance takes
|
|
642
|
-
when the export carries none. A file of one already there is kept (listed
|
|
640
|
+
`tenant_settings` and `model_registry`) unless `--include-tenant-wide`, which
|
|
641
|
+
asks the export for them (`include_tenant_wide`) where the instance takes
|
|
642
|
+
it, and says when the export carries none. A file of one already there is kept (listed
|
|
643
643
|
under `kept`). It refuses when package files have uncommitted changes
|
|
644
644
|
(exit 4) unless `--force`, and writes the tenant's solutions, knowledge bases,
|
|
645
645
|
tools, test suites and sandboxes to `.cavelon/inventory.md`.
|
|
@@ -674,10 +674,13 @@ cavelon activate --harness support
|
|
|
674
674
|
(with `--name` as `package/harnesses.yaml` names that harness); preview again
|
|
675
675
|
after it. `runtime_bindings` from the env file
|
|
676
676
|
bind the package's runtime requirements. A solution's import leaves the
|
|
677
|
-
package's tenant-wide sections out; `--tenant-wide` sends them
|
|
678
|
-
(`include_tenant_wide`), for every solution of the tenant
|
|
679
|
-
|
|
680
|
-
`
|
|
677
|
+
package's tenant-wide sections out; `--include-tenant-wide` sends them
|
|
678
|
+
(`include_tenant_wide`), for every solution of the tenant, and the confirm
|
|
679
|
+
replays the flag with the preview it stored. The preview shows the
|
|
680
|
+
instance's `tenant_wide` report: the sections it left out, or the active
|
|
681
|
+
solutions they reach when applied. An instance that does not publish that
|
|
682
|
+
flag imports them with every solution's package, and `apply` says so.
|
|
683
|
+
(`--tenant-wide`, the flag's name in 0.1.7, is still taken with a warning.) A preview that reaches an active solution, deletes, changes
|
|
681
684
|
tenant-wide sections or goes to `env/prod` says to show it to a person first.
|
|
682
685
|
- **`explain <code>`** looks a rule code or API error code up in the instance's
|
|
683
686
|
error catalog (and the codes `validate` reports itself): meaning, fix and docs
|
package/dist/command.js
CHANGED
|
@@ -1,4 +1,34 @@
|
|
|
1
1
|
import { usageError } from "./errors.js";
|
|
2
|
+
export function formerlyWarning(given, now) {
|
|
3
|
+
return `${given} is now ${now}; ${given} is still taken for now and will be refused in a later release.`;
|
|
4
|
+
}
|
|
5
|
+
export function renameFormerOptions(spec, args, warn) {
|
|
6
|
+
const former = new Map(Object.entries(spec.options ?? {})
|
|
7
|
+
.filter(([, o]) => o.formerly)
|
|
8
|
+
.map(([name, o]) => [o.formerly, name]));
|
|
9
|
+
if (!former.size)
|
|
10
|
+
return args;
|
|
11
|
+
const warned = new Set();
|
|
12
|
+
const out = [];
|
|
13
|
+
for (let i = 0; i < args.length; i++) {
|
|
14
|
+
const arg = args[i];
|
|
15
|
+
if (arg === "--") {
|
|
16
|
+
out.push(...args.slice(i));
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
const flag = arg.startsWith("--") ? arg.slice(2).split("=")[0] : undefined;
|
|
20
|
+
const now = flag !== undefined ? former.get(flag) : undefined;
|
|
21
|
+
if (!now) {
|
|
22
|
+
out.push(arg);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (!warned.has(flag))
|
|
26
|
+
warn(formerlyWarning(`--${flag}`, `--${now}`));
|
|
27
|
+
warned.add(flag);
|
|
28
|
+
out.push(`--${now}${arg.slice(2 + flag.length)}`);
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
2
32
|
export const GLOBAL_OPTIONS = {
|
|
3
33
|
json: { type: "boolean", description: "Print one JSON document instead of text." },
|
|
4
34
|
instance: { type: "string", value: "<url>", description: "The instance URL (overrides CAVELON_URL and cavelon.yaml)." },
|
|
@@ -13,7 +43,8 @@ export function optionDescription(name, o) {
|
|
|
13
43
|
const token = o.type === "boolean" && o.mcpToken
|
|
14
44
|
? ` In a person's terminal the flag alone confirms; run by a coding agent, \`--${name} <token>\` with the token its preview printed (the bare flag only shows the preview there, exit 5).`
|
|
15
45
|
: "";
|
|
16
|
-
|
|
46
|
+
const former = o.formerly ? ` Formerly \`--${o.formerly}\`, still taken with a warning.` : "";
|
|
47
|
+
return o.description + token + (o.multiple ? " Repeatable." : "") + former;
|
|
17
48
|
}
|
|
18
49
|
export function stringOption(input, name) {
|
|
19
50
|
const value = input.options[name];
|
|
@@ -20,7 +20,7 @@ import { cliFix, similarCodes } from "../code-hints.js";
|
|
|
20
20
|
import { KIT_ERROR_CODES } from "../kit-codes.js";
|
|
21
21
|
import { pairOrderHint, pairOrderPointer } from "../pair-order.js";
|
|
22
22
|
import { readPackage, tenantWideSections, writePackage } from "../package-files.js";
|
|
23
|
-
import { blockerDetails, blockerLines, changeLines, fieldChanges, locateBlockers, notApplied, notAppliedLines } from "../preview-report.js";
|
|
23
|
+
import { blockerDetails, blockerLines, changeLines, fieldChanges, locateBlockers, notApplied, notAppliedLines, tenantWideReport } from "../preview-report.js";
|
|
24
24
|
import { readPrincipal } from "../principal.js";
|
|
25
25
|
import { CASE_STATUSES, caseStatus, TESTING_PAGE } from "../results.js";
|
|
26
26
|
import { KNOWLEDGE_OUTCOME_AREA, KNOWLEDGE_OUTCOME_PAGE, KNOWLEDGE_OUTCOMES, knowledgeOutcome } from "../trace-view.js";
|
|
@@ -189,7 +189,7 @@ export const pull = {
|
|
|
189
189
|
"spells out that the file leaves out (an empty list, a default) is no change. A test suite goes back to the file it was\n" +
|
|
190
190
|
"pulled into or applied from, whatever its name. Files of sections the schema does not know are kept byte for byte.\n" +
|
|
191
191
|
"A solution's pull leaves the tenant-wide sections (the tenant's settings, its model list) out of the folder, unless\n" +
|
|
192
|
-
"--tenant-wide; it says when the export carries none. Refuses when package files have uncommitted changes, unless --force;\n" +
|
|
192
|
+
"--include-tenant-wide; it says when the export carries none. Refuses when package files have uncommitted changes, unless --force;\n" +
|
|
193
193
|
"outside a git repository, when a file it would overwrite or remove changed since the last pull. A file as the last pull\n" +
|
|
194
194
|
"or apply left it (digests in .cavelon/) counts as unchanged, committed or not.",
|
|
195
195
|
readOnly: false,
|
|
@@ -201,12 +201,13 @@ export const pull = {
|
|
|
201
201
|
options: {
|
|
202
202
|
harness: { type: "string", value: "<harness>", description: "The solution to export, by name, slug or id; its slug is recorded in cavelon.yaml when it names none." },
|
|
203
203
|
force: { type: "boolean", description: "Overwrite package files that have uncommitted changes since the last pull or apply." },
|
|
204
|
-
"tenant-wide": {
|
|
204
|
+
"include-tenant-wide": {
|
|
205
205
|
type: "boolean",
|
|
206
|
-
|
|
206
|
+
formerly: "tenant-wide",
|
|
207
|
+
description: "With a solution, also write the tenant-wide sections (tenant_settings, model_registry, …): asked of the export where the instance takes include_tenant_wide. Only `apply --include-tenant-wide` sends them back, for the whole tenant.",
|
|
207
208
|
},
|
|
208
209
|
},
|
|
209
|
-
examples: ["cavelon pull --harness support", "cavelon pull && git status --short -- package tests"],
|
|
210
|
+
examples: ["cavelon pull --harness support", "cavelon pull --include-tenant-wide", "cavelon pull && git status --short -- package tests"],
|
|
210
211
|
async run(ctx, input) {
|
|
211
212
|
const session = await ctx.session();
|
|
212
213
|
const project = requireSolution(session, stringOption(input, "harness"));
|
|
@@ -224,9 +225,9 @@ export const pull = {
|
|
|
224
225
|
harness = await findHarness(ctx, ref);
|
|
225
226
|
}
|
|
226
227
|
const scope = harness ? "agent_graph" : "full_config";
|
|
227
|
-
const tenantWide = boolOption(input, "tenant-wide");
|
|
228
|
+
const tenantWide = boolOption(input, "include-tenant-wide");
|
|
228
229
|
if (tenantWide && !harness)
|
|
229
|
-
ctx.warn("--tenant-wide applies to a solution's pull; the tenant's full configuration carries the tenant-wide sections anyway.");
|
|
230
|
+
ctx.warn("--include-tenant-wide applies to a solution's pull; the tenant's full configuration carries the tenant-wide sections anyway.");
|
|
230
231
|
const askTenantWide = Boolean(harness) && tenantWide && (await takesTenantWide(ctx, "export"));
|
|
231
232
|
const exported = await callStable(ctx, "GET", EXPORT_ROUTE, "exporting packages", {
|
|
232
233
|
query: { scope, harness_id: harness?.id, ...(askTenantWide ? { [INCLUDE_TENANT_WIDE]: true } : {}) },
|
|
@@ -270,7 +271,7 @@ export const pull = {
|
|
|
270
271
|
for (const file of report.kept) {
|
|
271
272
|
const section = path.posix.basename(file).replace(/\.(ya?ml|json)$/i, "");
|
|
272
273
|
ctx.warn(report.tenant_wide.includes(section)
|
|
273
|
-
? `Kept ${file} as it is: it holds a tenant-wide section, which pull leaves out of a solution's folder. apply leaves it out too, and \`apply --tenant-wide\` sends it for the whole tenant; remove the file unless you mean that.`
|
|
274
|
+
? `Kept ${file} as it is: it holds a tenant-wide section, which pull leaves out of a solution's folder. apply leaves it out too, and \`apply --include-tenant-wide\` sends it for the whole tenant; remove the file unless you mean that.`
|
|
274
275
|
: `Kept ${file}: its section is not in this instance's package schema.`);
|
|
275
276
|
}
|
|
276
277
|
for (const section of report.refused)
|
|
@@ -285,13 +286,13 @@ export const pull = {
|
|
|
285
286
|
...report.removed.map((f) => `removed ${f}`),
|
|
286
287
|
`${report.unchanged.length} file${report.unchanged.length === 1 ? "" : "s"} unchanged.`,
|
|
287
288
|
...(report.tenant_wide.length
|
|
288
|
-
? [`Left out the tenant-wide section${report.tenant_wide.length === 1 ? "" : "s"} ${report.tenant_wide.join(", ")} (--tenant-wide writes them).`]
|
|
289
|
+
? [`Left out the tenant-wide section${report.tenant_wide.length === 1 ? "" : "s"} ${report.tenant_wide.join(", ")} (--include-tenant-wide writes them).`]
|
|
289
290
|
: []),
|
|
290
291
|
...(pulledShared
|
|
291
292
|
? [
|
|
292
293
|
pulledShared.length
|
|
293
|
-
? `Tenant-wide: ${pulledShared.join(", ")} (shared by every solution of the tenant; only \`apply --tenant-wide\` sends them back).`
|
|
294
|
-
: `The export carries no tenant-wide sections${askTenantWide ? "" : " (this instance's export does not take include_tenant_wide)"}, so --tenant-wide wrote none.`,
|
|
294
|
+
? `Tenant-wide: ${pulledShared.join(", ")} (shared by every solution of the tenant; only \`apply --include-tenant-wide\` sends them back).`
|
|
295
|
+
: `The export carries no tenant-wide sections${askTenantWide ? "" : " (this instance's export does not take include_tenant_wide)"}, so --include-tenant-wide wrote none.`,
|
|
295
296
|
]
|
|
296
297
|
: []),
|
|
297
298
|
`Inventory: ${inventory.file} (${inventory.counts.map((c) => `${c.count} ${c.label}`).join(", ")})`,
|
|
@@ -733,8 +734,16 @@ async function confirmPreview(ctx, project, previewId, allowStale) {
|
|
|
733
734
|
const summary = (result.summary ?? {});
|
|
734
735
|
const flags = targetFlags(session, stored.env ?? session.envFile?.name);
|
|
735
736
|
const still = setCommands(stored.preview, flags);
|
|
737
|
+
const sharedSent = stored.request[INCLUDE_TENANT_WIDE] === true;
|
|
738
|
+
const sharedReport = sharedSent ? tenantWideReport(stored.preview.tenant_wide) : undefined;
|
|
739
|
+
const sharedReaches = sharedReport?.reaches_active_solutions ?? [];
|
|
740
|
+
const sharedText = sharedSent
|
|
741
|
+
? `${sharedReport?.sections.length ? sharedReport.sections.join(", ") : "the package's tenant-wide sections"}, for every solution of the tenant` +
|
|
742
|
+
(sharedReaches.length ? ` (active: ${list(sharedReaches, 10)})` : "")
|
|
743
|
+
: undefined;
|
|
736
744
|
const text = keyValues([
|
|
737
745
|
["applied", `preview ${stored.preview_id}${stored.harness ? ` to ${stored.harness.slug}` : ""}${stored.env ? ` (env ${stored.env})` : ""}`],
|
|
746
|
+
["tenant-wide", sharedText],
|
|
738
747
|
["created", counts(summary?.creates) || undefined],
|
|
739
748
|
["updated", counts(summary?.updates) || undefined],
|
|
740
749
|
["deleted", counts(summary?.deletes) || undefined],
|
|
@@ -743,6 +752,8 @@ async function confirmPreview(ctx, project, previewId, allowStale) {
|
|
|
743
752
|
["set variables", still.variables.length ? indented(still.variables) : undefined],
|
|
744
753
|
]);
|
|
745
754
|
const data = { applied: true, preview_id: stored.preview_id, env: stored.env, harness: stored.harness, result };
|
|
755
|
+
if (sharedSent)
|
|
756
|
+
data.tenant_wide = { applied: true, sections: sharedReport?.sections ?? null, reaches_active_solutions: sharedReaches };
|
|
746
757
|
if (still.secrets.length || still.variables.length)
|
|
747
758
|
data.set_commands = still;
|
|
748
759
|
return { data, text };
|
|
@@ -830,7 +841,11 @@ function packageHarnessName(pkg, slug) {
|
|
|
830
841
|
const name = typeof entry?.name === "string" ? entry.name.trim() : "";
|
|
831
842
|
return name ? name.slice(0, 255) : undefined;
|
|
832
843
|
}
|
|
833
|
-
function personReason(preview, harness, mode, env, shared = []) {
|
|
844
|
+
function personReason(preview, harness, mode, env, shared = [], sharedReaches = []) {
|
|
845
|
+
if (shared.length) {
|
|
846
|
+
const reaching = sharedReaches.length ? `, reaching the active solution${sharedReaches.length === 1 ? "" : "s"} ${list(sharedReaches, 5)}` : "";
|
|
847
|
+
return `changes what the whole tenant shares (${list(shared, 5)})${reaching}`;
|
|
848
|
+
}
|
|
834
849
|
const active = (preview.impact?.active_harnesses ?? []).map((h) => h.harness_slug ?? h.name).filter((n) => Boolean(n));
|
|
835
850
|
if (harness?.status === "active" && !active.includes(harness.slug))
|
|
836
851
|
active.unshift(harness.slug);
|
|
@@ -838,8 +853,6 @@ function personReason(preview, harness, mode, env, shared = []) {
|
|
|
838
853
|
return `reaches the active solution${active.length === 1 ? "" : "s"} ${list(active, 5)}`;
|
|
839
854
|
if (preview.impact?.active_harnesses?.length)
|
|
840
855
|
return "reaches an active solution";
|
|
841
|
-
if (shared.length)
|
|
842
|
-
return `changes what the whole tenant shares (${list(shared, 5)})`;
|
|
843
856
|
if (counts(preview.summary?.deletes) || mode === "replace")
|
|
844
857
|
return "deletes";
|
|
845
858
|
if (env === "prod")
|
|
@@ -859,7 +872,7 @@ export const apply = {
|
|
|
859
872
|
"hold, not their formatting; --allow-stale imports what the preview showed anyway), and one older than a day. So does\n" +
|
|
860
873
|
"an import its own check refuses when it applies, naming each blocker. --discard <id|all> forgets stored previews;\n" +
|
|
861
874
|
"`cavelon status` lists them with when each expires.\n" +
|
|
862
|
-
"A solution's import leaves the package's tenant-wide sections (tenant_settings, model_registry, …) out; --tenant-wide\n" +
|
|
875
|
+
"A solution's import leaves the package's tenant-wide sections (tenant_settings, model_registry, …) out; --include-tenant-wide\n" +
|
|
863
876
|
"imports them, for every solution of the tenant. An instance that does not publish include_tenant_wide imports them with\n" +
|
|
864
877
|
"every solution's package, and apply says so.",
|
|
865
878
|
readOnly: false,
|
|
@@ -875,15 +888,16 @@ export const apply = {
|
|
|
875
888
|
},
|
|
876
889
|
discard: { type: "string", value: "<preview-id|all>", description: "Forget this stored preview, or all of them; changes nothing on the instance." },
|
|
877
890
|
mode: { type: "string", value: "<mode>", description: "overwrite (default) or replace (deletes what the package does not hold)." },
|
|
878
|
-
"tenant-wide": {
|
|
891
|
+
"include-tenant-wide": {
|
|
879
892
|
type: "boolean",
|
|
893
|
+
formerly: "tenant-wide",
|
|
880
894
|
description: "With a solution, also import the package's tenant-wide sections (tenant_settings, model_registry, …): they change for every solution of the tenant, so a person sees the preview first.",
|
|
881
895
|
},
|
|
882
896
|
},
|
|
883
897
|
examples: [
|
|
884
898
|
"cavelon apply --env test",
|
|
885
899
|
"cavelon apply --confirm <preview-id>",
|
|
886
|
-
"cavelon apply --env test --tenant-wide",
|
|
900
|
+
"cavelon apply --env test --include-tenant-wide",
|
|
887
901
|
"cavelon apply --env prod --json",
|
|
888
902
|
"cavelon apply --discard all",
|
|
889
903
|
],
|
|
@@ -932,23 +946,16 @@ export const apply = {
|
|
|
932
946
|
request.harness_id = harness.id;
|
|
933
947
|
if (envFile && Object.keys(envFile.runtimeBindings).length)
|
|
934
948
|
request.runtime_bindings = envFile.runtimeBindings;
|
|
935
|
-
const tenantWide = boolOption(input, "tenant-wide");
|
|
949
|
+
const tenantWide = boolOption(input, "include-tenant-wide");
|
|
936
950
|
const solutionImport = Boolean(harness) && scope !== "full_config";
|
|
937
951
|
if (tenantWide && !solutionImport)
|
|
938
|
-
ctx.warn("--tenant-wide applies to a solution's import; this one goes to the whole tenant anyway.");
|
|
952
|
+
ctx.warn("--include-tenant-wide applies to a solution's import; this one goes to the whole tenant anyway.");
|
|
939
953
|
const shared = solutionImport ? [...tenantWideSections(schema)].filter((section) => section in disk.package) : [];
|
|
940
954
|
const takes = solutionImport && (tenantWide || shared.length > 0) && (await takesTenantWide(ctx, "import"));
|
|
941
955
|
if (tenantWide && takes)
|
|
942
956
|
request[INCLUDE_TENANT_WIDE] = true;
|
|
943
|
-
const sharedImported = tenantWide || !takes ? shared : [];
|
|
944
|
-
const sharedLeftOut = tenantWide || !takes ? [] : shared;
|
|
945
957
|
if (tenantWide && solutionImport && !shared.length)
|
|
946
|
-
ctx.warn("--tenant-wide: the package holds no tenant-wide section, so this import changes nothing the whole tenant shares.");
|
|
947
|
-
if (sharedImported.length) {
|
|
948
|
-
const files = sectionFiles(disk, sharedImported).join(", ");
|
|
949
|
-
ctx.warn(`${files} ${sharedImported.length === 1 ? "holds a section" : "hold sections"} the whole tenant shares: this import changes ${sharedImported.join(", ")} for every solution of the tenant` +
|
|
950
|
-
(takes ? "." : " (this instance does not publish include_tenant_wide and imports them with every solution's package); remove the file unless that is meant."));
|
|
951
|
-
}
|
|
958
|
+
ctx.warn("--include-tenant-wide: the package holds no tenant-wide section, so this import changes nothing the whole tenant shares.");
|
|
952
959
|
const client = await ctx.client();
|
|
953
960
|
const preview = await callStable(ctx, "POST", "/api/v1/agent-graph/import/preview", "previewing imports", {
|
|
954
961
|
body: request,
|
|
@@ -956,12 +963,32 @@ export const apply = {
|
|
|
956
963
|
});
|
|
957
964
|
const target = harness ? { id: harness.id, slug: harness.slug } : null;
|
|
958
965
|
const data = { previewed: true, ...preview, env: envFile?.name ?? null, harness: target };
|
|
959
|
-
|
|
960
|
-
|
|
966
|
+
const reported = solutionImport ? tenantWideReport(preview.tenant_wide) : undefined;
|
|
967
|
+
const sections = reported?.sections ?? shared;
|
|
968
|
+
const applied = reported ? reported.applied : tenantWide || !takes;
|
|
969
|
+
const sharedImported = applied ? sections : [];
|
|
970
|
+
const sharedLeftOut = applied ? [] : sections;
|
|
971
|
+
const reaches = reported?.reaches_active_solutions ?? [];
|
|
972
|
+
if (sharedImported.length) {
|
|
973
|
+
const files = sectionFiles(disk, sharedImported).join(", ") || sharedImported.join(", ");
|
|
974
|
+
ctx.warn(`${files} ${sharedImported.length === 1 ? "holds a section" : "hold sections"} the whole tenant shares: this import changes ${sharedImported.join(", ")} for every solution of the tenant` +
|
|
975
|
+
(takes ? "." : " (this instance does not publish include_tenant_wide and imports them with every solution's package); remove the file unless that is meant."));
|
|
976
|
+
}
|
|
977
|
+
if (sections.length || tenantWide) {
|
|
978
|
+
data.tenant_wide = {
|
|
979
|
+
sections,
|
|
980
|
+
applied,
|
|
981
|
+
imported: sharedImported,
|
|
982
|
+
left_out: sharedLeftOut,
|
|
983
|
+
reaches_active_solutions: reaches,
|
|
984
|
+
reported_by: reported ? "instance" : "kit",
|
|
985
|
+
};
|
|
986
|
+
}
|
|
987
|
+
const reachText = reaches.length ? `the active solution${reaches.length === 1 ? "" : "s"} ${list(reaches, 10)}` : "";
|
|
961
988
|
const sharedLine = sharedImported.length
|
|
962
|
-
? `tenant-wide: ${sharedImported.join(", ")} change for every solution of the tenant`
|
|
989
|
+
? `tenant-wide: ${sharedImported.join(", ")} change for every solution of the tenant${reachText ? `, reaching ${reachText}` : ""}`
|
|
963
990
|
: sharedLeftOut.length
|
|
964
|
-
? `tenant-wide: ${sharedLeftOut.join(", ")} left out (\`cavelon apply --tenant-wide\` imports them, for every solution of the tenant)`
|
|
991
|
+
? `tenant-wide: ${sharedLeftOut.join(", ")} left out (\`cavelon apply --include-tenant-wide\` imports them, for every solution of the tenant${reachText ? `; they would reach ${reachText}` : ""})`
|
|
965
992
|
: undefined;
|
|
966
993
|
const flags = targetFlags(session);
|
|
967
994
|
const commands = setCommands(preview, flags);
|
|
@@ -1029,7 +1056,7 @@ export const apply = {
|
|
|
1029
1056
|
const expired = (await listPreviews(project.root, ctx.io.now())).filter((old) => old.expired);
|
|
1030
1057
|
await retirePreviews(project.root, expired.map((old) => ({ preview_id: old.preview_id, reason: "expired", at })));
|
|
1031
1058
|
}
|
|
1032
|
-
const reason = personReason(preview, harness, mode, envFile?.name, sharedImported);
|
|
1059
|
+
const reason = personReason(preview, harness, mode, envFile?.name, sharedImported, reaches);
|
|
1033
1060
|
data.show_to_person = Boolean(reason);
|
|
1034
1061
|
const confirmLine = preview.preview_id ? `${cavelonCommand("apply", "--confirm", preview.preview_id)}${flags}` : undefined;
|
|
1035
1062
|
const text = [
|
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseArgs } from "node:util";
|
|
2
|
-
import { GLOBAL_OPTIONS, optionDescription, optionFlag } from "./command.js";
|
|
2
|
+
import { GLOBAL_OPTIONS, optionDescription, optionFlag, renameFormerOptions } from "./command.js";
|
|
3
3
|
import { createContext, withWarnings } from "./context.js";
|
|
4
4
|
import { CONFIRM_TOKEN } from "./confirm-token.js";
|
|
5
5
|
import { asCavelonError, ExitCode, usageError } from "./errors.js";
|
|
@@ -36,7 +36,8 @@ export async function run(argv, io, commands = COMMANDS, updates = {}) {
|
|
|
36
36
|
}
|
|
37
37
|
const { spec, rest } = found;
|
|
38
38
|
const early = [];
|
|
39
|
-
const
|
|
39
|
+
const renamed = renameFormerOptions(spec, rest, (message) => early.push(message));
|
|
40
|
+
const args = spec.preprocess ? spec.preprocess(renamed, (message) => early.push(message)) : renamed;
|
|
40
41
|
const parsed = parse(spec, args);
|
|
41
42
|
if (parsed.options.help === true) {
|
|
42
43
|
io.stdout.write(commandHelp(spec));
|
package/dist/mcp.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
2
|
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import { formerlyWarning } from "./command.js";
|
|
3
4
|
import { MCP_MAX_WAIT_MS } from "./commands/async.js";
|
|
4
5
|
import { createContext, withWarnings } from "./context.js";
|
|
5
6
|
import { asCavelonError, CavelonError, ExitCode, usageError } from "./errors.js";
|
|
@@ -17,7 +18,7 @@ const INSTRUCTIONS = "Tools for one Cavelon instance, acting with the token a pe
|
|
|
17
18
|
"a different change needs a new preview, and confirm: true is refused. The default route " +
|
|
18
19
|
"(harness_default, activate's make_default) decides which solution the tenant's chat and widget answer with: live traffic, " +
|
|
19
20
|
"so ask the person, and confirm only with their yes; the same goes for deactivate, which takes a solution out of live traffic " +
|
|
20
|
-
"(its status becomes inactive), and for apply with
|
|
21
|
+
"(its status becomes inactive), and for apply with include_tenant_wide, which imports the tenant-wide sections (tenant_settings, " +
|
|
21
22
|
"model_registry, …) for every solution of the tenant. " +
|
|
22
23
|
"chat sends one message to a solution and returns its answer: the way to try one that is not the default route. " +
|
|
23
24
|
"kb_upload names files that match an active document of the knowledge base; with replace it replaces them, and where the " +
|
|
@@ -93,20 +94,24 @@ export function toolFor(spec) {
|
|
|
93
94
|
}
|
|
94
95
|
function argumentsOf(spec, args, warn) {
|
|
95
96
|
const properties = Object.keys(inputSchema(spec).properties ?? {});
|
|
97
|
+
const former = new Map(Object.entries(spec.options ?? {})
|
|
98
|
+
.filter(([, o]) => o.formerly && !o.cliOnly)
|
|
99
|
+
.map(([name, o]) => [propertyName(o.formerly), propertyName(name)]));
|
|
96
100
|
const out = {};
|
|
97
101
|
for (const [key, value] of Object.entries(args)) {
|
|
98
102
|
if (properties.includes(key)) {
|
|
99
103
|
out[key] = value;
|
|
100
104
|
continue;
|
|
101
105
|
}
|
|
102
|
-
const
|
|
103
|
-
if (
|
|
104
|
-
warn(`"${key}"
|
|
105
|
-
if (!(
|
|
106
|
-
out[
|
|
106
|
+
const now = former.get(key);
|
|
107
|
+
if (now) {
|
|
108
|
+
warn(formerlyWarning(`"${key}"`, `"${now}"`));
|
|
109
|
+
if (!(now in args))
|
|
110
|
+
out[now] = value;
|
|
107
111
|
continue;
|
|
108
112
|
}
|
|
109
|
-
const
|
|
113
|
+
const spelled = propertyName(key);
|
|
114
|
+
const near = spelled !== key && properties.includes(spelled) ? spelled : closest(key, properties);
|
|
110
115
|
throw new CavelonError(ExitCode.usage, {
|
|
111
116
|
code: "unknown_argument",
|
|
112
117
|
message: `${spec.mcpTool} has no argument "${key}"; nothing was done.${near ? ` Did you mean "${near}"?` : ""}`,
|
|
@@ -164,10 +169,10 @@ export function createMcpServer(io, commands) {
|
|
|
164
169
|
});
|
|
165
170
|
if (!spec)
|
|
166
171
|
return fail(new Error(`Unknown tool ${request.params.name}.`));
|
|
167
|
-
const
|
|
172
|
+
const renamed = [];
|
|
168
173
|
let args;
|
|
169
174
|
try {
|
|
170
|
-
args = argumentsOf(spec, given, (message) =>
|
|
175
|
+
args = argumentsOf(spec, given, (message) => renamed.push(message));
|
|
171
176
|
}
|
|
172
177
|
catch (error) {
|
|
173
178
|
return fail(error);
|
|
@@ -179,7 +184,7 @@ export function createMcpServer(io, commands) {
|
|
|
179
184
|
const tenant = !ownsTenant(spec) && typeof args.tenant === "string" ? args.tenant : undefined;
|
|
180
185
|
const solutionEnv = spec.options?.env && typeof args.env === "string" ? args.env : undefined;
|
|
181
186
|
const ctx = createContext(mcpIo(io), { json: true, tenant, solutionEnv }, "mcp");
|
|
182
|
-
for (const message of
|
|
187
|
+
for (const message of renamed)
|
|
183
188
|
ctx.warn(message);
|
|
184
189
|
try {
|
|
185
190
|
const result = await spec.run(ctx, inputFrom(spec, args));
|
package/dist/package-check.js
CHANGED
|
@@ -54,14 +54,16 @@ export const KIT_CODES = [
|
|
|
54
54
|
code: ENDPOINT_LIMIT_CODE,
|
|
55
55
|
area: "package",
|
|
56
56
|
message: "A Model Registry row sets max_concurrent_requests without a base_url.",
|
|
57
|
-
hint: "The limit belongs to a self-hosted endpoint: add the row's base_url, or remove max_concurrent_requests (empty means no limit)."
|
|
57
|
+
hint: "The limit belongs to a self-hosted endpoint: add the row's base_url, or remove max_concurrent_requests (empty means no limit). " +
|
|
58
|
+
"In a solution's folder, apply sends model_registry only with --include-tenant-wide, for the whole tenant; `cavelon models set-limit` changes one row's limit without a package.",
|
|
58
59
|
docs: PACKAGE_DOCS,
|
|
59
60
|
},
|
|
60
61
|
{
|
|
61
62
|
code: ENDPOINT_LIMIT_NOT_CARRIED,
|
|
62
63
|
area: "package",
|
|
63
64
|
message: "This instance's package format does not carry max_concurrent_requests on Model Registry rows.",
|
|
64
|
-
hint: "The import ignores it. Set it on the row in the Admin's model form, or with PATCH /api/v1/model-registry/{model_registry_id}."
|
|
65
|
+
hint: "The import ignores it. Set it on the row in the Admin's model form, or with `cavelon models set-limit` (PATCH /api/v1/model-registry/{model_registry_id}). " +
|
|
66
|
+
"In a solution's folder, apply sends model_registry only with --include-tenant-wide, for the whole tenant.",
|
|
65
67
|
docs: PACKAGE_DOCS,
|
|
66
68
|
},
|
|
67
69
|
{
|
|
@@ -151,7 +153,7 @@ export const KIT_CODES = [
|
|
|
151
153
|
code: TENANT_WIDE_CODE,
|
|
152
154
|
area: "package",
|
|
153
155
|
message: "A solution's folder holds a section the whole tenant shares, such as tenant_settings or model_registry.",
|
|
154
|
-
hint: "`cavelon apply` leaves it out of the solution's import; `cavelon apply --tenant-wide` sends it, and then every solution of the tenant sees the change. " +
|
|
156
|
+
hint: "`cavelon apply` leaves it out of the solution's import; `cavelon apply --include-tenant-wide` sends it, and then every solution of the tenant sees the change. " +
|
|
155
157
|
"Remove the file unless that is meant. An instance that does not publish include_tenant_wide imports it with every apply.",
|
|
156
158
|
docs: PACKAGE_DOCS,
|
|
157
159
|
},
|
|
@@ -316,6 +318,7 @@ export function checkPackage(disk, options) {
|
|
|
316
318
|
findings.push(...checkUncheckedAssertions(disk, options.schema));
|
|
317
319
|
findings.push(...checkSolutionSlug(disk, options.solution));
|
|
318
320
|
findings.push(...checkTenantWide(disk, options.schema, options.solution));
|
|
321
|
+
noteTenantWide(findings, options.schema, options.solution);
|
|
319
322
|
for (const finding of findings) {
|
|
320
323
|
const entry = findingEntry(options.catalog, finding.code);
|
|
321
324
|
if (!entry)
|
|
@@ -676,11 +679,25 @@ function checkTenantWide(disk, schema, solution) {
|
|
|
676
679
|
severity: "warning",
|
|
677
680
|
file: Array.isArray(source) ? source[0]?.file : source?.file,
|
|
678
681
|
path: section,
|
|
679
|
-
message: `${section} is shared by the whole tenant, not this solution's: apply leaves it out unless --tenant-wide, which changes it for every solution ` +
|
|
682
|
+
message: `${section} is shared by the whole tenant, not this solution's: apply leaves it out unless --include-tenant-wide, which changes it for every solution ` +
|
|
680
683
|
"(an instance that does not publish include_tenant_wide imports it with every apply). Remove the file unless that is meant.",
|
|
681
684
|
};
|
|
682
685
|
});
|
|
683
686
|
}
|
|
687
|
+
function noteTenantWide(findings, schema, solution) {
|
|
688
|
+
if (!solution)
|
|
689
|
+
return;
|
|
690
|
+
const shared = tenantWideSections(schema);
|
|
691
|
+
for (const finding of findings) {
|
|
692
|
+
if (finding.code === TENANT_WIDE_CODE || !finding.path)
|
|
693
|
+
continue;
|
|
694
|
+
const section = /^\/?([A-Za-z0-9_]+)/.exec(finding.path)?.[1];
|
|
695
|
+
if (!section || !shared.has(section))
|
|
696
|
+
continue;
|
|
697
|
+
finding.message +=
|
|
698
|
+
` ${section} is tenant-wide: a solution's apply leaves it out unless --include-tenant-wide, which changes it for every solution of the tenant.`;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
684
701
|
function checkSolutionSlug(disk, solution) {
|
|
685
702
|
if (!solution || UUID.test(solution))
|
|
686
703
|
return [];
|
package/dist/preview-report.js
CHANGED
|
@@ -150,3 +150,13 @@ export function notAppliedLines(list) {
|
|
|
150
150
|
})
|
|
151
151
|
.join("") + (list.length > 20 ? `\n … ${list.length - 20} more (--json)` : "");
|
|
152
152
|
}
|
|
153
|
+
export function tenantWideReport(raw) {
|
|
154
|
+
if (!isObject(raw) || !Array.isArray(raw.sections))
|
|
155
|
+
return undefined;
|
|
156
|
+
const sections = raw.sections.map(text).filter((s) => s !== null);
|
|
157
|
+
const reaches = Array.isArray(raw.reaches_active_solutions) ? raw.reaches_active_solutions : [];
|
|
158
|
+
const names = reaches
|
|
159
|
+
.map((h) => (isObject(h) ? (text(h.slug) ?? text(h.harness_slug) ?? text(h.name) ?? text(h.id)) : text(h)))
|
|
160
|
+
.filter((n) => n !== null);
|
|
161
|
+
return { sections, applied: raw.applied === true, reaches_active_solutions: [...new Set(names)] };
|
|
162
|
+
}
|
|
@@ -112,6 +112,10 @@ endpoint.
|
|
|
112
112
|
preview's token, `--confirm <token>`). It refuses a row without a `base_url`.
|
|
113
113
|
Where this instance's package format does not carry the field, `validate`
|
|
114
114
|
warns that the import ignores it; set it this way instead.
|
|
115
|
+
- `model_registry` is tenant-wide: in a solution's folder, `cavelon apply`
|
|
116
|
+
leaves it out of the import unless `--include-tenant-wide`, which changes it
|
|
117
|
+
for every solution of the tenant (`validate` says so on each finding in the
|
|
118
|
+
file). For one row's limit, prefer `cavelon models set-limit`.
|
|
115
119
|
|
|
116
120
|
**Propose a limit; the person decides.** Say which value you would set and
|
|
117
121
|
why (what the endpoint serves, which rows share it, what waits or fails now),
|
|
@@ -76,8 +76,10 @@ use it when you parse the result.
|
|
|
76
76
|
suite goes back to the file it came from, whatever its name. A solution's
|
|
77
77
|
pull leaves the tenant-wide sections (the tenant's settings, its model
|
|
78
78
|
list) out of the folder, and `apply` leaves them out of the solution's
|
|
79
|
-
import. `pull --tenant-wide` writes them; `apply
|
|
80
|
-
|
|
79
|
+
import. `pull --include-tenant-wide` writes them; `apply
|
|
80
|
+
--include-tenant-wide` (the MCP tool's `include_tenant_wide`) imports them,
|
|
81
|
+
for every solution of the tenant, so only with the person's say-so; its
|
|
82
|
+
preview names the active solutions the change reaches.
|
|
81
83
|
`validate` warns about a tenant-wide file in the folder
|
|
82
84
|
(`tenant_wide_section`); on an instance that does not publish
|
|
83
85
|
`include_tenant_wide`, `apply` imports such a file anyway and says so:
|
|
@@ -201,8 +203,9 @@ show the preview to the person, and confirm only after they agree, when:
|
|
|
201
203
|
- the environment is `prod` (`--env prod`), or the preview deletes anything
|
|
202
204
|
(`--mode replace`);
|
|
203
205
|
- the preview changes tenant-wide sections (`tenant-wide: … change for every
|
|
204
|
-
solution of the tenant
|
|
205
|
-
imports them anyway): every
|
|
206
|
+
solution of the tenant, reaching the active solutions …`, after
|
|
207
|
+
`--include-tenant-wide` or on an instance that imports them anyway): every
|
|
208
|
+
solution of the tenant sees the change;
|
|
206
209
|
- the preview lists target needs (secrets, grants, identities): only a person
|
|
207
210
|
can provide them, with `cavelon secrets set <name>` or in the Admin.
|
|
208
211
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cavelon/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
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",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@eslint/js": "^10.0.1",
|
|
45
45
|
"@types/node": "^20.19.0",
|
|
46
46
|
"eslint": "^10.12.0",
|
|
47
|
-
"typescript": "~
|
|
47
|
+
"typescript": "~6.0.3",
|
|
48
48
|
"typescript-eslint": "^8.71.0",
|
|
49
49
|
"vitest": "^4.0.0"
|
|
50
50
|
}
|