@cavelon/cli 0.1.7 → 0.1.9

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 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 asks the
641
- export for them (`include_tenant_wide`) where the instance takes it, and says
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. An instance that
679
- does not publish that flag imports them with every solution's package, and
680
- `apply` says so. A preview that reaches an active solution, deletes, changes
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
- return o.description + token + (o.multiple ? " Repeatable." : "");
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
- 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 --tenant-wide` sends them back, for the whole tenant.",
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
- if (shared.length || tenantWide)
960
- data.tenant_wide = { sections: shared, imported: sharedImported, left_out: sharedLeftOut };
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 args = spec.preprocess ? spec.preprocess(rest, (message) => early.push(message)) : rest;
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,9 +1,11 @@
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";
6
7
  import { closest } from "./package-references.js";
8
+ import { startSessionUpdateCheck } from "./update-check.js";
7
9
  import { KIT_VERSION } from "./version.js";
8
10
  const INSTRUCTIONS = "Tools for one Cavelon instance, acting with the token a person stored with `cavelon login` " +
9
11
  "(or CAVELON_TOKEN). You never see or pass the token. Tools that start work (kb_upload, test_run, " +
@@ -17,7 +19,7 @@ const INSTRUCTIONS = "Tools for one Cavelon instance, acting with the token a pe
17
19
  "a different change needs a new preview, and confirm: true is refused. The default route " +
18
20
  "(harness_default, activate's make_default) decides which solution the tenant's chat and widget answer with: live traffic, " +
19
21
  "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 tenant_wide, which imports the tenant-wide sections (tenant_settings, " +
22
+ "(its status becomes inactive), and for apply with include_tenant_wide, which imports the tenant-wide sections (tenant_settings, " +
21
23
  "model_registry, …) for every solution of the tenant. " +
22
24
  "chat sends one message to a solution and returns its answer: the way to try one that is not the default route. " +
23
25
  "kb_upload names files that match an active document of the knowledge base; with replace it replaces them, and where the " +
@@ -39,7 +41,9 @@ const INSTRUCTIONS = "Tools for one Cavelon instance, acting with the token a pe
39
41
  "values are set, never a value: a person sets a secret, so tell them the exact `cavelon secrets set <name>` command " +
40
42
  "to run in their terminal, and never ask for, read or pass a secret value. Never approve or decide an approval; " +
41
43
  "that stays with a person. Use docs_search before guessing, " +
42
- "and api_list/api_describe/api for anything without its own tool.";
44
+ "and api_list/api_describe/api for anything without its own tool. " +
45
+ "The first result of a session may carry a warning that cavelon, the Cavelon plugin or this folder's skills are behind " +
46
+ "the latest release, with the commands that update them: pass it on to the person, who runs them; do not run them yourself.";
43
47
  const TOKEN_DESCRIPTION = "Over MCP: the confirm_token this tool's preview returned, which confirms exactly the change it showed; true is refused.";
44
48
  export function toolName(spec) {
45
49
  return spec.mcpTool || undefined;
@@ -93,20 +97,24 @@ export function toolFor(spec) {
93
97
  }
94
98
  function argumentsOf(spec, args, warn) {
95
99
  const properties = Object.keys(inputSchema(spec).properties ?? {});
100
+ const former = new Map(Object.entries(spec.options ?? {})
101
+ .filter(([, o]) => o.formerly && !o.cliOnly)
102
+ .map(([name, o]) => [propertyName(o.formerly), propertyName(name)]));
96
103
  const out = {};
97
104
  for (const [key, value] of Object.entries(args)) {
98
105
  if (properties.includes(key)) {
99
106
  out[key] = value;
100
107
  continue;
101
108
  }
102
- const spelled = propertyName(key);
103
- if (spelled !== key && properties.includes(spelled)) {
104
- warn(`"${key}" is spelled "${spelled}" in this tool's schema; "${key}" is still taken for now and will be refused in a later release.`);
105
- if (!(spelled in args))
106
- out[spelled] = value;
109
+ const now = former.get(key);
110
+ if (now) {
111
+ warn(formerlyWarning(`"${key}"`, `"${now}"`));
112
+ if (!(now in args))
113
+ out[now] = value;
107
114
  continue;
108
115
  }
109
- const near = closest(key, properties);
116
+ const spelled = propertyName(key);
117
+ const near = spelled !== key && properties.includes(spelled) ? spelled : closest(key, properties);
110
118
  throw new CavelonError(ExitCode.usage, {
111
119
  code: "unknown_argument",
112
120
  message: `${spec.mcpTool} has no argument "${key}"; nothing was done.${near ? ` Did you mean "${near}"?` : ""}`,
@@ -150,24 +158,21 @@ function missingRequired(spec, args) {
150
158
  function mcpIo(io) {
151
159
  return { ...io, stdout: { write: () => true, isTTY: false } };
152
160
  }
153
- export function createMcpServer(io, commands) {
161
+ export function createMcpServer(io, commands, updates = {}) {
154
162
  const tools = commands.filter((c) => c.mcpTool);
155
163
  const byName = new Map(tools.map((c) => [toolName(c), c]));
156
164
  const server = new Server({ name: "cavelon", version: KIT_VERSION }, { capabilities: { tools: {} }, instructions: INSTRUCTIONS });
165
+ const notice = startSessionUpdateCheck(io, updates);
157
166
  server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: tools.map(toolFor) }));
158
- server.setRequestHandler(CallToolRequestSchema, async (request) => {
159
- const spec = byName.get(request.params.name);
160
- const given = (request.params.arguments ?? {});
161
- const fail = (error) => ({
162
- isError: true,
163
- content: [{ type: "text", text: JSON.stringify({ error: asCavelonError(error).toJSON() }) }],
164
- });
167
+ async function call(name, given) {
168
+ const spec = byName.get(name);
169
+ const fail = (error) => ({ isError: true, body: { error: asCavelonError(error).toJSON() } });
165
170
  if (!spec)
166
- return fail(new Error(`Unknown tool ${request.params.name}.`));
167
- const spelling = [];
171
+ return fail(new Error(`Unknown tool ${name}.`));
172
+ const renamed = [];
168
173
  let args;
169
174
  try {
170
- args = argumentsOf(spec, given, (message) => spelling.push(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 spelling)
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));
@@ -189,11 +194,24 @@ export function createMcpServer(io, commands) {
189
194
  if (result.exitCode)
190
195
  data.exit_code = result.exitCode;
191
196
  }
192
- return { content: [{ type: "text", text: JSON.stringify(data ?? null) }] };
197
+ return { body: data ?? null };
193
198
  }
194
199
  catch (error) {
195
200
  return fail(error);
196
201
  }
202
+ }
203
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
204
+ const warning = notice.forCall(() => server.getClientVersion()?.name);
205
+ const { body, isError } = await call(request.params.name, (request.params.arguments ?? {}));
206
+ let out = body;
207
+ const text = await warning;
208
+ if (text) {
209
+ if (out && typeof out === "object" && !Array.isArray(out))
210
+ out = withWarnings(out, [text]);
211
+ else
212
+ notice.keep();
213
+ }
214
+ return { ...(isError ? { isError } : {}), content: [{ type: "text", text: JSON.stringify(out) }] };
197
215
  });
198
216
  return server;
199
217
  }
@@ -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 [];
@@ -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),
@@ -29,6 +29,11 @@ use it when you parse the result.
29
29
  `--env` and `--tenant`). Never ask for the value, never pipe or pass one yourself; there is
30
30
  no MCP tool for it. Plain-text variables you may set with `cavelon variables
31
31
  set <name> <value>` when the value is not a credential.
32
+ - **Pass on an update warning.** The first MCP result of a session may warn
33
+ that `cavelon`, the Cavelon plugin or this folder's skills are behind the
34
+ latest release (`… is out; this is …`, `The Cavelon plugin is …`), with the
35
+ commands that update them. Tell the person, with those commands, before you
36
+ go on; they run them (an update takes effect in a new session), you do not.
32
37
  - **Read the limits before you plan a solution:** `cavelon limits` (the
33
38
  `limits` tool over MCP). It lists what this instance allows the tenant
34
39
  (upload size and file types, agent turns, tool calls, timeouts, rate limits,
@@ -76,8 +81,10 @@ use it when you parse the result.
76
81
  suite goes back to the file it came from, whatever its name. A solution's
77
82
  pull leaves the tenant-wide sections (the tenant's settings, its model
78
83
  list) out of the folder, and `apply` leaves them out of the solution's
79
- import. `pull --tenant-wide` writes them; `apply --tenant-wide` imports
80
- them, for every solution of the tenant, so only with the person's say-so.
84
+ import. `pull --include-tenant-wide` writes them; `apply
85
+ --include-tenant-wide` (the MCP tool's `include_tenant_wide`) imports them,
86
+ for every solution of the tenant, so only with the person's say-so; its
87
+ preview names the active solutions the change reaches.
81
88
  `validate` warns about a tenant-wide file in the folder
82
89
  (`tenant_wide_section`); on an instance that does not publish
83
90
  `include_tenant_wide`, `apply` imports such a file anyway and says so:
@@ -201,8 +208,9 @@ show the preview to the person, and confirm only after they agree, when:
201
208
  - the environment is `prod` (`--env prod`), or the preview deletes anything
202
209
  (`--mode replace`);
203
210
  - the preview changes tenant-wide sections (`tenant-wide: … change for every
204
- solution of the tenant`, after `--tenant-wide` or on an instance that
205
- imports them anyway): every solution of the tenant sees the change;
211
+ solution of the tenant, reaching the active solutions …`, after
212
+ `--include-tenant-wide` or on an instance that imports them anyway): every
213
+ solution of the tenant sees the change;
206
214
  - the preview lists target needs (secrets, grants, identities): only a person
207
215
  can provide them, with `cavelon secrets set <name>` or in the Admin.
208
216
 
@@ -1,11 +1,20 @@
1
+ import fs from "node:fs/promises";
1
2
  import path from "node:path";
2
- import { NPM_PACKAGE, REPOSITORY } from "./install.js";
3
- import { readJsonFile, writeFileAtomic } from "./fsutil.js";
3
+ import { SKILL_ROOTS } from "./agents.js";
4
+ import { currentInstall, NPM_PACKAGE, REPOSITORY } from "./install.js";
5
+ import { readJsonFile, readTextFile, writeFileAtomic } from "./fsutil.js";
6
+ import { isGenerated } from "./markers.js";
4
7
  import { cacheDir } from "./paths.js";
8
+ import { findProject } from "./project.js";
9
+ import { KIT_VERSION } from "./version.js";
5
10
  export const DAY_MS = 24 * 60 * 60 * 1000;
6
11
  export const CHECK_TIMEOUT_MS = 1500;
7
12
  const MAX_BODY = 1024 * 1024;
8
13
  const STATE_FILE = "update-check.json";
14
+ export const PLUGIN_VERSION_VARIABLE = "CAVELON_PLUGIN_VERSION";
15
+ export const CLAUDE_PLUGIN_ROOT_VARIABLE = "CLAUDE_PLUGIN_ROOT";
16
+ const PLUGIN_NAME = "cavelon";
17
+ const UPDATING_DOCS = `https://github.com/${REPOSITORY}/blob/main/docs/installation.md#updating`;
9
18
  const SOURCES = {
10
19
  github: { url: `https://api.github.com/repos/${REPOSITORY}/releases/latest`, field: "tag_name" },
11
20
  npm: { url: `https://registry.npmjs.org/${NPM_PACKAGE}/latest`, field: "version" },
@@ -37,7 +46,14 @@ export function startUpdateCheck(request) {
37
46
  }
38
47
  async function check(request) {
39
48
  const { io, install, version } = request;
40
- const source = install.source;
49
+ return withState(io, install.source, version, request.fetch ?? fetch, (state, now) => {
50
+ if (!state.latest || !newer(state.latest, version) || within(state.notified_at, now))
51
+ return undefined;
52
+ state.notified_at = now.toISOString();
53
+ return noticeText(state.latest, version, install);
54
+ });
55
+ }
56
+ async function withState(io, source, version, fetchImpl, use) {
41
57
  const file = path.join(cacheDir(io.env), STATE_FILE);
42
58
  const state = (await readJsonFile(file)) ?? {};
43
59
  const now = io.now();
@@ -49,18 +65,14 @@ async function check(request) {
49
65
  }
50
66
  if (!within(state.checked_at, now)) {
51
67
  state.checked_at = now.toISOString();
52
- const latest = await latestVersion(source, version, request.fetch ?? fetch).catch(() => undefined);
68
+ const latest = await latestVersion(source, version, fetchImpl).catch(() => undefined);
53
69
  if (latest)
54
70
  state.latest = latest;
55
71
  }
56
- let notice;
57
- if (state.latest && newer(state.latest, version) && !within(state.notified_at, now)) {
58
- notice = noticeText(state.latest, version, install);
59
- state.notified_at = now.toISOString();
60
- }
72
+ const result = use(state, now);
61
73
  if (JSON.stringify(state) !== before)
62
74
  await writeFileAtomic(file, `${JSON.stringify(state, null, 2)}\n`, 0o600, 0o700);
63
- return notice;
75
+ return result;
64
76
  }
65
77
  function within(stamp, now) {
66
78
  const at = stamp ? Date.parse(stamp) : NaN;
@@ -116,3 +128,137 @@ export function noticeText(latest, version, install) {
116
128
  return `${head} Update with:\n ${install.update}\n`;
117
129
  return `${head}${install.advice ? ` ${install.advice}` : ""}\n`;
118
130
  }
131
+ export function sessionQuietReason(io, install) {
132
+ if (setTo(io.env.CAVELON_NO_UPDATE_CHECK))
133
+ return "CAVELON_NO_UPDATE_CHECK";
134
+ if (CI_VARIABLES.some((name) => setTo(io.env[name])))
135
+ return "ci";
136
+ if (install.method === "source")
137
+ return "source";
138
+ return undefined;
139
+ }
140
+ export function startSessionUpdateCheck(io, options = {}) {
141
+ const install = options.install ?? currentInstall(io.env);
142
+ const version = options.version ?? KIT_VERSION;
143
+ if (sessionQuietReason(io, install))
144
+ return { forCall: async () => undefined, keep: () => undefined };
145
+ let facts;
146
+ let settled = false;
147
+ const gathered = Promise.all([
148
+ pluginVersion(io.env)
149
+ .catch(() => undefined)
150
+ .then((plugin) => {
151
+ const source = install.source ?? (plugin ? "github" : undefined);
152
+ const latest = source ? withState(io, source, version, options.fetch ?? fetch, (state) => state.latest).catch(() => undefined) : undefined;
153
+ return Promise.all([plugin, latest]);
154
+ }),
155
+ initSkillsVersion(io.cwd).catch(() => undefined),
156
+ ]).then(([[plugin, latest], skills]) => {
157
+ facts = { plugin, latest, skills };
158
+ settled = true;
159
+ });
160
+ let first = true;
161
+ let delivered = false;
162
+ return {
163
+ async forCall(client) {
164
+ if (delivered)
165
+ return undefined;
166
+ if (first) {
167
+ first = false;
168
+ await bounded(gathered, CHECK_TIMEOUT_MS);
169
+ }
170
+ if (delivered || !settled)
171
+ return undefined;
172
+ delivered = true;
173
+ return facts && sessionWarning({ ...facts, version, install, client: client() });
174
+ },
175
+ keep() {
176
+ delivered = false;
177
+ },
178
+ };
179
+ }
180
+ function bounded(promise, ms) {
181
+ let timer;
182
+ const timeout = new Promise((resolve) => {
183
+ timer = setTimeout(resolve, ms);
184
+ });
185
+ return Promise.race([promise.then(() => undefined), timeout]).finally(() => clearTimeout(timer));
186
+ }
187
+ export async function pluginVersion(env) {
188
+ const said = parseVersion(env[PLUGIN_VERSION_VARIABLE] ?? "")?.text;
189
+ if (said)
190
+ return said;
191
+ const root = env[CLAUDE_PLUGIN_ROOT_VARIABLE];
192
+ if (!root || !path.isAbsolute(root))
193
+ return undefined;
194
+ const manifest = await readJsonFile(path.join(root, ".claude-plugin", "plugin.json"));
195
+ if (manifest?.name !== PLUGIN_NAME || typeof manifest.version !== "string")
196
+ return undefined;
197
+ return parseVersion(manifest.version)?.text;
198
+ }
199
+ const INIT_MARK = /written by `cavelon init --agents` \(cavelon ([0-9][0-9A-Za-z.-]{0,80})\)/;
200
+ const SKILL_FOLDER = /^cavelon-[a-z0-9-]{1,64}$/;
201
+ async function initSkillsVersion(cwd) {
202
+ const root = (await findProject(cwd))?.root ?? cwd;
203
+ let oldest;
204
+ for (const skillRoot of SKILL_ROOTS) {
205
+ let names;
206
+ try {
207
+ names = await fs.readdir(path.join(root, skillRoot));
208
+ }
209
+ catch {
210
+ continue;
211
+ }
212
+ for (const name of names.filter((n) => SKILL_FOLDER.test(n))) {
213
+ const text = await readTextFile(path.join(root, skillRoot, name, "SKILL.md"));
214
+ if (!isGenerated(text))
215
+ continue;
216
+ const found = parseVersion(INIT_MARK.exec(text)?.[1] ?? "")?.text;
217
+ if (found && (!oldest || newer(oldest, found)))
218
+ oldest = found;
219
+ }
220
+ }
221
+ return oldest;
222
+ }
223
+ const PLUGIN_UPDATE = {
224
+ claude: "`claude plugin marketplace update cavelon-dev-kit` and `claude plugin update cavelon@cavelon-dev-kit`",
225
+ codex: "`codex plugin marketplace upgrade cavelon-dev-kit` and `codex plugin add cavelon@cavelon-dev-kit`",
226
+ };
227
+ function pluginUpdate(client) {
228
+ const name = client?.toLowerCase() ?? "";
229
+ if (name.includes("claude"))
230
+ return PLUGIN_UPDATE.claude;
231
+ if (name.includes("codex"))
232
+ return PLUGIN_UPDATE.codex;
233
+ return undefined;
234
+ }
235
+ export function sessionWarning(facts) {
236
+ const { version, install, plugin, skills } = facts;
237
+ const latest = facts.latest && install.source && newer(facts.latest, version) ? facts.latest : undefined;
238
+ const newest = facts.latest && newer(facts.latest, version) ? facts.latest : version;
239
+ const pluginBehind = plugin !== undefined && newer(newest, plugin);
240
+ const skillsBehind = skills !== undefined && newer(latest ?? version, skills);
241
+ if (!latest && !pluginBehind && !skillsBehind)
242
+ return undefined;
243
+ const said = [];
244
+ const asks = [];
245
+ if (latest) {
246
+ said.push(`cavelon ${latest} is out; this is ${version}.`);
247
+ asks.push(install.update ? `Update cavelon with \`${install.update}\`.` : (install.advice ?? `Update cavelon to ${latest}.`));
248
+ }
249
+ if (pluginBehind) {
250
+ said.push(`The Cavelon plugin is ${plugin}${latest ? "" : `, older than cavelon ${newest}`}.`);
251
+ const commands = pluginUpdate(facts.client);
252
+ asks.push(commands ? `Update the plugin with ${commands}.` : `Update the plugin: in Claude Code with ${PLUGIN_UPDATE.claude}; in Codex with ${PLUGIN_UPDATE.codex}.`);
253
+ }
254
+ else if (latest && plugin === undefined && pluginUpdate(facts.client)) {
255
+ asks.push(`If they use the Cavelon plugin, also update it with ${pluginUpdate(facts.client)}.`);
256
+ }
257
+ if (skillsBehind) {
258
+ said.push(`The skills \`cavelon init --agents\` wrote in this solution folder are from cavelon ${skills}.`);
259
+ asks.push(`Run \`cavelon init --update\` in it${latest ? " after updating cavelon" : ""}, and commit the result.`);
260
+ }
261
+ if (latest || pluginBehind)
262
+ asks.push("Then start a new agent session.");
263
+ return `${said.join(" ")} Tell the user: ${asks.join(" ")} More: ${UPDATING_DOCS}`;
264
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cavelon/cli",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
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": "~5.9.3",
47
+ "typescript": "~6.0.3",
48
48
  "typescript-eslint": "^8.71.0",
49
49
  "vitest": "^4.0.0"
50
50
  }