@cavelon/cli 0.1.9 → 0.1.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/branches.js +4 -3
- package/dist/capacity.js +3 -2
- package/dist/code-hints.js +5 -4
- package/dist/command.js +6 -0
- package/dist/commands/api.js +3 -3
- package/dist/commands/async.js +7 -4
- package/dist/commands/chat.js +10 -12
- package/dist/commands/docs.js +5 -3
- package/dist/commands/fmt.js +6 -4
- package/dist/commands/index.js +2 -0
- package/dist/commands/init.js +106 -28
- package/dist/commands/limits-set.js +8 -9
- package/dist/commands/limits.js +4 -3
- package/dist/commands/loops.js +15 -14
- package/dist/commands/models.js +10 -12
- package/dist/commands/sandboxes.js +15 -14
- package/dist/commands/schema.js +6 -5
- package/dist/commands/session.js +27 -15
- package/dist/commands/setup.js +4 -2
- package/dist/commands/solution.js +152 -68
- package/dist/commands/tenants.js +14 -14
- package/dist/commands/values.js +62 -38
- package/dist/commands/work.js +18 -12
- package/dist/confirm-token.js +3 -1
- package/dist/contracts.js +2 -1
- package/dist/default-route.js +1 -1
- package/dist/features.js +2 -1
- package/dist/harness-ref.js +6 -4
- package/dist/http.js +4 -3
- package/dist/invoke.js +3 -2
- package/dist/kit-codes.js +9 -2
- package/dist/limits.js +1 -1
- package/dist/main.js +13 -1
- package/dist/mcp.js +41 -21
- package/dist/openapi.js +5 -2
- package/dist/operations.js +3 -2
- package/dist/package-check.js +10 -4
- package/dist/package-files.js +5 -1
- package/dist/package-format.js +10 -0
- package/dist/preview-report.js +44 -5
- package/dist/printed.js +182 -0
- package/dist/project.js +2 -1
- package/dist/results.js +1 -1
- package/dist/secret-access.js +30 -0
- package/dist/session.js +3 -11
- package/dist/shell.js +0 -3
- package/dist/skills/cavelon-authoring/SKILL.md +9 -2
- package/dist/skills/cavelon-long-running/SKILL.md +1 -1
- package/dist/skills/cavelon-loop/SKILL.md +11 -4
- package/dist/tenant-choice.js +7 -7
- package/dist/trace-view.js +1 -1
- package/package.json +1 -1
|
@@ -24,23 +24,23 @@ import { blockerDetails, blockerLines, changeLines, fieldChanges, locateBlockers
|
|
|
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";
|
|
27
|
-
import {
|
|
27
|
+
import { isUuid, requireInstance } from "../session.js";
|
|
28
28
|
import { listedPages } from "./docs.js";
|
|
29
29
|
import { readInventory, readInventoryKinds, writeInventory } from "./inventory.js";
|
|
30
30
|
import { checkedBy, MODEL_UNKNOWN_CODE, missingInventory, REFERENCE_UNKNOWN_CODE } from "../package-references.js";
|
|
31
|
-
import { cavelonCommand,
|
|
32
|
-
import { secretSetCommand,
|
|
31
|
+
import { cavelonCommand, printedCommand, spoken } from "../printed.js";
|
|
32
|
+
import { secretSetCommand, variableSetCommand } from "./values.js";
|
|
33
|
+
import { maySetSecrets, SECRET_SETTER } from "../secret-access.js";
|
|
33
34
|
const HARNESS_OPTION = { type: "string", value: "<harness>", description: "The solution (harness): its name, slug or id; default: env file, then cavelon.yaml." };
|
|
34
35
|
const ENV_OPTION = { type: "string", value: "<name>", description: "Use env/<name>.yaml: its tenant, solution and runtime bindings." };
|
|
35
36
|
export function requireSolution(session, harness) {
|
|
36
37
|
if (!session.project) {
|
|
37
|
-
const flags = contextFlags(session);
|
|
38
38
|
throw new CavelonError(ExitCode.usage, {
|
|
39
39
|
code: "no_solution",
|
|
40
40
|
message: "This folder is not a Cavelon solution (no cavelon.yaml here or above).",
|
|
41
41
|
hint: harness
|
|
42
|
-
? `Make it the folder of that solution first: ${cavelonCommand("init", "--harness", harness)}
|
|
43
|
-
: `Run
|
|
42
|
+
? `Make it the folder of that solution first: ${cavelonCommand("init", "--harness", harness)}, then run this command again.`
|
|
43
|
+
: `Run \`${cavelonCommand("init")}\`: it asks which solution, or a new one, on a terminal. \`${cavelonCommand("harness", "list")}\` shows the solutions.`,
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
return session.project;
|
|
@@ -58,7 +58,7 @@ function harnessRef(session, input) {
|
|
|
58
58
|
async function findHarness(ctx, ref, source) {
|
|
59
59
|
const { harness, candidates } = await lookupHarness(ctx, ref);
|
|
60
60
|
if (!harness)
|
|
61
|
-
throw harnessNotFoundError(ref, candidates, source
|
|
61
|
+
throw harnessNotFoundError(ref, candidates, source);
|
|
62
62
|
return harness;
|
|
63
63
|
}
|
|
64
64
|
async function cachedFirst(ctx, what, cached, offline, fetch) {
|
|
@@ -276,7 +276,7 @@ export const pull = {
|
|
|
276
276
|
}
|
|
277
277
|
for (const section of report.refused)
|
|
278
278
|
ctx.warn(`Did not write section ${JSON.stringify(section)}: its name is not a plain file name.`);
|
|
279
|
-
const pulledShared = harness && tenantWide ? Object.keys(exported).filter((section) => shared.has(section)) : undefined;
|
|
279
|
+
const pulledShared = harness && tenantWide ? Object.keys(exported).filter((section) => shared.has(section) && !emptyValue(exported[section])) : undefined;
|
|
280
280
|
const rewritten = report.written.length + report.removed.length;
|
|
281
281
|
const lines = [
|
|
282
282
|
`Pulled ${harness ? `solution ${harness.name} (${harness.slug})` : "the tenant's full configuration"} into ${project.layout.package}/` +
|
|
@@ -292,7 +292,9 @@ export const pull = {
|
|
|
292
292
|
? [
|
|
293
293
|
pulledShared.length
|
|
294
294
|
? `Tenant-wide: ${pulledShared.join(", ")} (shared by every solution of the tenant; only \`apply --include-tenant-wide\` sends them back).`
|
|
295
|
-
:
|
|
295
|
+
: Object.keys(exported).some((section) => shared.has(section))
|
|
296
|
+
? "The export's tenant-wide sections are empty: the tenant has none of their settings yet."
|
|
297
|
+
: `The export carries no tenant-wide sections${askTenantWide ? "" : " (this instance's export does not take include_tenant_wide)"}, so --include-tenant-wide wrote none.`,
|
|
296
298
|
]
|
|
297
299
|
: []),
|
|
298
300
|
`Inventory: ${inventory.file} (${inventory.counts.map((c) => `${c.count} ${c.label}`).join(", ")})`,
|
|
@@ -442,11 +444,11 @@ export const validate = {
|
|
|
442
444
|
function valueNeeds(list) {
|
|
443
445
|
return (list ?? []).map((n) => (typeof n === "string" ? { name: n } : n)).filter((n) => typeof n.name === "string" && n.name !== "");
|
|
444
446
|
}
|
|
445
|
-
function setCommands(preview,
|
|
447
|
+
function setCommands(preview, env) {
|
|
446
448
|
const needs = preview.target_needs ?? {};
|
|
447
449
|
return {
|
|
448
|
-
secrets: valueNeeds(needs.secrets).map((n) => secretSetCommand(n.name,
|
|
449
|
-
variables: valueNeeds(needs.variables).map((n) => variableSetCommand(n.name,
|
|
450
|
+
secrets: valueNeeds(needs.secrets).map((n) => secretSetCommand(n.name, env)),
|
|
451
|
+
variables: valueNeeds(needs.variables).map((n) => variableSetCommand(n.name, env)),
|
|
450
452
|
};
|
|
451
453
|
}
|
|
452
454
|
function needLines(needs, command, more) {
|
|
@@ -466,16 +468,16 @@ function counts(map) {
|
|
|
466
468
|
function list(items, max = 10) {
|
|
467
469
|
return items.length > max ? `${items.slice(0, max).join(", ")} and ${items.length - max} more` : items.join(", ");
|
|
468
470
|
}
|
|
469
|
-
function needsLines(needs
|
|
471
|
+
function needsLines(needs) {
|
|
470
472
|
const lines = [];
|
|
471
473
|
const secrets = valueNeeds(needs.secrets);
|
|
472
474
|
if (secrets.length) {
|
|
473
|
-
const each = needLines(secrets, (name) => secretSetCommand(name
|
|
475
|
+
const each = needLines(secrets, (name) => secretSetCommand(name), cavelonCommand("secrets", "list", "--missing"));
|
|
474
476
|
lines.push(["needs secrets", `${each}\n (a person runs these in a terminal, or sets them in the Admin; never the agent)`]);
|
|
475
477
|
}
|
|
476
478
|
const variables = valueNeeds(needs.variables);
|
|
477
479
|
if (variables.length)
|
|
478
|
-
lines.push(["needs variables", needLines(variables, (name) => variableSetCommand(name
|
|
480
|
+
lines.push(["needs variables", needLines(variables, (name) => variableSetCommand(name), cavelonCommand("variables", "list"))]);
|
|
479
481
|
const grants = (needs.oauth_grants ?? []).map((g) => [g.kind, g.tool_slug, g.capability].filter(Boolean).join(" "));
|
|
480
482
|
if (grants.length)
|
|
481
483
|
lines.push(["needs grants", `${list(grants)} (a person connects them in the Admin)`]);
|
|
@@ -487,13 +489,29 @@ function needsLines(needs, flags) {
|
|
|
487
489
|
lines.push(["needs identities", triggers.map((t) => `\n - ${t}`).join("")]);
|
|
488
490
|
return lines;
|
|
489
491
|
}
|
|
492
|
+
function emptyValue(value) {
|
|
493
|
+
if (value === null || value === undefined)
|
|
494
|
+
return true;
|
|
495
|
+
if (Array.isArray(value))
|
|
496
|
+
return value.length === 0;
|
|
497
|
+
return typeof value === "object" && Object.keys(value).length === 0;
|
|
498
|
+
}
|
|
499
|
+
function sectionsChanging(p, sections) {
|
|
500
|
+
if (changesNothing(p))
|
|
501
|
+
return [];
|
|
502
|
+
const s = p.summary ?? {};
|
|
503
|
+
const counted = new Set([s.creates, s.updates, s.deletes].flatMap((map) => Object.entries(map ?? {}).filter(([, n]) => n > 0).map(([kind]) => kind)));
|
|
504
|
+
const objects = fieldChanges(p.changes).map((c) => c.object);
|
|
505
|
+
const found = sections.filter((section) => counted.has(section) || objects.some((o) => o === section || o.startsWith(`${section}:`) || o.startsWith(`${section}.`) || o.startsWith(`${section}[`)));
|
|
506
|
+
return found.length ? found : undefined;
|
|
507
|
+
}
|
|
490
508
|
function changesNothing(p) {
|
|
491
509
|
const s = p.summary;
|
|
492
510
|
if (!s || typeof s !== "object")
|
|
493
511
|
return false;
|
|
494
512
|
return !counts(s.creates) && !counts(s.updates) && !counts(s.deletes) && fieldChanges(p.changes).length === 0;
|
|
495
513
|
}
|
|
496
|
-
export function previewText(p,
|
|
514
|
+
export function previewText(p, context = {}) {
|
|
497
515
|
const lines = [["ready", p.ready ? "yes" : "no"]];
|
|
498
516
|
const s = p.summary ?? {};
|
|
499
517
|
for (const [label, map] of [["creates", s.creates], ["updates", s.updates], ["deletes", s.deletes]]) {
|
|
@@ -532,7 +550,7 @@ export function previewText(p, flags = "", context = {}) {
|
|
|
532
550
|
const limits = Object.entries(budget.limits ?? {}).map(([k, v]) => `${k} ${v}`).join(", ");
|
|
533
551
|
lines.push([`loop ${budget.node_slug}`, `${limits}${budget.worst_case_cost != null ? `; worst case ${JSON.stringify(budget.worst_case_cost)}` : ""}`]);
|
|
534
552
|
}
|
|
535
|
-
lines.push(...needsLines(p.target_needs ?? {}
|
|
553
|
+
lines.push(...needsLines(p.target_needs ?? {}));
|
|
536
554
|
return keyValues(lines);
|
|
537
555
|
}
|
|
538
556
|
function previewReport(p, context) {
|
|
@@ -554,14 +572,14 @@ function sourceFiles(disk) {
|
|
|
554
572
|
function previewIdOption(input) {
|
|
555
573
|
const id = stringOption(input, "confirm");
|
|
556
574
|
if (id !== undefined && !id.trim())
|
|
557
|
-
throw usageError(
|
|
575
|
+
throw usageError(`--confirm needs the preview id that \`${cavelonCommand("apply")}\` printed.`);
|
|
558
576
|
return id?.trim();
|
|
559
577
|
}
|
|
560
578
|
function previewUnknown(previewId) {
|
|
561
579
|
return new CavelonError(ExitCode.usage, {
|
|
562
580
|
code: "preview_unknown",
|
|
563
581
|
message: `No open preview ${previewId} in this solution.`,
|
|
564
|
-
hint:
|
|
582
|
+
hint: `Run \`${cavelonCommand("apply")}\` (with the same --env or --harness) for a new preview and confirm its id; \`${cavelonCommand("status")}\` lists the open ones.`,
|
|
565
583
|
});
|
|
566
584
|
}
|
|
567
585
|
const PREVIEW_STALE = "import_preview_stale";
|
|
@@ -674,7 +692,7 @@ async function confirmPreview(ctx, project, previewId, allowStale) {
|
|
|
674
692
|
const session = await ctx.session();
|
|
675
693
|
if (!stored) {
|
|
676
694
|
const retired = await retiredPreview(project.root, previewId);
|
|
677
|
-
throw retired ? previewRetired(retired,
|
|
695
|
+
throw retired ? previewRetired(retired, cavelonCommand("apply")) : previewUnknown(previewId);
|
|
678
696
|
}
|
|
679
697
|
const now = ctx.io.now().toISOString();
|
|
680
698
|
const retire = (reason) => retirePreviews(project.root, [{ preview_id: stored.preview_id, reason, at: now }]);
|
|
@@ -684,7 +702,7 @@ async function confirmPreview(ctx, project, previewId, allowStale) {
|
|
|
684
702
|
throw new CavelonError(ExitCode.conflict, {
|
|
685
703
|
code: "preview_expired",
|
|
686
704
|
message: `Preview ${previewId} was made at ${stored.created_at} and expired${expiry.expires_at ? ` at ${expiry.expires_at}` : ""}; nothing was imported.`,
|
|
687
|
-
hint: `Run \`${previewAgain(stored
|
|
705
|
+
hint: `Run \`${previewAgain(stored)}\` again, show the new preview, and confirm its id.`,
|
|
688
706
|
details: { preview_id: stored.preview_id, created_at: stored.created_at, expires_at: expiry.expires_at },
|
|
689
707
|
});
|
|
690
708
|
}
|
|
@@ -712,13 +730,13 @@ async function confirmPreview(ctx, project, previewId, allowStale) {
|
|
|
712
730
|
throw new CavelonError(ExitCode.conflict, {
|
|
713
731
|
code: "preview_files_changed",
|
|
714
732
|
message: `The package files changed since preview ${previewId}${changed.length ? ` (${list(changed, 5)})` : ""}; nothing was imported.`,
|
|
715
|
-
hint: `Run \`${previewAgain(stored
|
|
733
|
+
hint: `Run \`${previewAgain(stored)}\` for a preview of the files as they are now, show it, and confirm its id. ` +
|
|
716
734
|
`To import what preview ${previewId} showed instead, add --allow-stale to the confirm.`,
|
|
717
735
|
details: { preview_id: stored.preview_id, files: changed },
|
|
718
736
|
});
|
|
719
737
|
}
|
|
720
738
|
ctx.warn(`The package files changed since this preview${changed.length ? ` (${list(changed, 5)})` : ""}; importing what the preview showed (--allow-stale). ` +
|
|
721
|
-
|
|
739
|
+
`The files keep their changes, which the instance does not hold; run \`${cavelonCommand("apply")}\` to preview them.`);
|
|
722
740
|
}
|
|
723
741
|
try {
|
|
724
742
|
const result = await callStable(ctx, "POST", "/api/v1/agent-graph/import", "importing packages", {
|
|
@@ -732,13 +750,15 @@ async function confirmPreview(ctx, project, previewId, allowStale) {
|
|
|
732
750
|
]);
|
|
733
751
|
await rememberImported(ctx, project, stored, disk, changed);
|
|
734
752
|
const summary = (result.summary ?? {});
|
|
735
|
-
const
|
|
736
|
-
const still = setCommands(stored.preview, flags);
|
|
753
|
+
const still = setCommands(stored.preview, stored.env ?? undefined);
|
|
737
754
|
const sharedSent = stored.request[INCLUDE_TENANT_WIDE] === true;
|
|
738
|
-
const
|
|
755
|
+
const resultReport = tenantWideReport(result.tenant_wide);
|
|
756
|
+
const sharedReport = resultReport ?? (sharedSent ? tenantWideReport(stored.preview.tenant_wide) : undefined);
|
|
757
|
+
const sharedImported = sharedReport ? sharedReport.imports : [];
|
|
739
758
|
const sharedReaches = sharedReport?.reaches_active_solutions ?? [];
|
|
740
|
-
const sharedText = sharedSent
|
|
741
|
-
? `${
|
|
759
|
+
const sharedText = sharedSent || sharedImported.length
|
|
760
|
+
? `${sharedImported.length ? sharedImported.join(", ") : resultReport ? "none" : "the package's tenant-wide sections"}` +
|
|
761
|
+
(sharedImported.length || !resultReport ? ", for every solution of the tenant" : "") +
|
|
742
762
|
(sharedReaches.length ? ` (active: ${list(sharedReaches, 10)})` : "")
|
|
743
763
|
: undefined;
|
|
744
764
|
const text = keyValues([
|
|
@@ -752,8 +772,16 @@ async function confirmPreview(ctx, project, previewId, allowStale) {
|
|
|
752
772
|
["set variables", still.variables.length ? indented(still.variables) : undefined],
|
|
753
773
|
]);
|
|
754
774
|
const data = { applied: true, preview_id: stored.preview_id, env: stored.env, harness: stored.harness, result };
|
|
755
|
-
if (sharedSent)
|
|
756
|
-
data.tenant_wide = {
|
|
775
|
+
if (sharedSent || sharedImported.length) {
|
|
776
|
+
data.tenant_wide = {
|
|
777
|
+
applied: resultReport ? resultReport.applied : true,
|
|
778
|
+
sections: sharedReport?.sections ?? null,
|
|
779
|
+
imported: sharedReport ? sharedImported : null,
|
|
780
|
+
left_out: sharedReport ? sharedReport.left_out : null,
|
|
781
|
+
reaches_active_solutions: sharedReaches,
|
|
782
|
+
reported_by: resultReport ? "import" : sharedReport ? "preview" : "kit",
|
|
783
|
+
};
|
|
784
|
+
}
|
|
757
785
|
if (still.secrets.length || still.variables.length)
|
|
758
786
|
data.set_commands = still;
|
|
759
787
|
return { data, text };
|
|
@@ -764,7 +792,7 @@ async function confirmPreview(ctx, project, previewId, allowStale) {
|
|
|
764
792
|
throw requirementsChanged(error, stored, session, await catalogFor(ctx, false), disk);
|
|
765
793
|
}
|
|
766
794
|
if (error instanceof CavelonError && error.blockerDetails?.length)
|
|
767
|
-
throw withBlockersLocated(error, disk, stored
|
|
795
|
+
throw withBlockersLocated(error, disk, stored);
|
|
768
796
|
if (error instanceof CavelonError && (error.code === "import_preview_stale" || (error.status === 409 && /preview/i.test(error.message)))) {
|
|
769
797
|
await retire("stale");
|
|
770
798
|
const said = error.details?.changed;
|
|
@@ -773,7 +801,7 @@ async function confirmPreview(ctx, project, previewId, allowStale) {
|
|
|
773
801
|
code: error.code === "conflict" ? "import_preview_stale" : error.code,
|
|
774
802
|
status: 409,
|
|
775
803
|
message: `The target changed since preview ${stored.preview_id}${changed.length ? `: ${changed.join("; ")}` : ""}; nothing was imported.`,
|
|
776
|
-
hint: `Run \`${previewAgain(stored
|
|
804
|
+
hint: `Run \`${previewAgain(stored)}\` again, show the new preview, and confirm its id.`,
|
|
777
805
|
docs: error.docs,
|
|
778
806
|
...(changed.length ? { details: { preview_id: stored.preview_id, changed } } : {}),
|
|
779
807
|
});
|
|
@@ -795,17 +823,17 @@ function requirementsChanged(error, stored, session, catalog, disk) {
|
|
|
795
823
|
code: error.code,
|
|
796
824
|
status: error.status,
|
|
797
825
|
message: `The import's requirements changed since preview ${stored.preview_id}; nothing was imported; preview again.`,
|
|
798
|
-
hint: [...known.values(), `Run \`${previewAgain(stored
|
|
826
|
+
hint: [...known.values(), `Run \`${previewAgain(stored)}\` again, show the new preview, and confirm its id.`].join(" "),
|
|
799
827
|
docs: error.docs,
|
|
800
828
|
blockers,
|
|
801
829
|
blockerDetails: details.length ? details : undefined,
|
|
802
830
|
});
|
|
803
831
|
}
|
|
804
|
-
function withBlockersLocated(error, disk, stored
|
|
832
|
+
function withBlockersLocated(error, disk, stored) {
|
|
805
833
|
return new CavelonError(error.exitCode, {
|
|
806
834
|
code: error.code,
|
|
807
835
|
message: `The import's own check refused preview ${stored.preview_id} when it applied; nothing was imported.`,
|
|
808
|
-
hint: error.hint ?? `Fix what each blocker names, run \`${previewAgain(stored
|
|
836
|
+
hint: error.hint ?? `Fix what each blocker names, run \`${previewAgain(stored)}\` again, show the new preview, and confirm its id.`,
|
|
809
837
|
docs: error.docs,
|
|
810
838
|
status: error.status,
|
|
811
839
|
details: error.details,
|
|
@@ -813,9 +841,8 @@ function withBlockersLocated(error, disk, stored, session) {
|
|
|
813
841
|
blockerDetails: locateBlockers(error.blockerDetails ?? [], disk),
|
|
814
842
|
});
|
|
815
843
|
}
|
|
816
|
-
function previewAgain(stored
|
|
817
|
-
|
|
818
|
-
return `cavelon apply${harness}${targetFlags(session, stored.env)}`;
|
|
844
|
+
function previewAgain(stored) {
|
|
845
|
+
return printedCommand(["apply", ...(!stored.env && stored.harness ? ["--harness", stored.harness.slug] : [])], { env: stored.env });
|
|
819
846
|
}
|
|
820
847
|
async function applyTarget(ctx, session, input, pkg) {
|
|
821
848
|
const { ref, source } = harnessRef(session, input);
|
|
@@ -825,13 +852,13 @@ async function applyTarget(ctx, session, input, pkg) {
|
|
|
825
852
|
if (found)
|
|
826
853
|
return found;
|
|
827
854
|
if (!source || source === "option" || isUuid(ref) || !SLUG.test(ref))
|
|
828
|
-
throw harnessNotFoundError(ref, candidates, source
|
|
855
|
+
throw harnessNotFoundError(ref, candidates, source);
|
|
829
856
|
const name = packageHarnessName(pkg, ref) ?? ref;
|
|
830
|
-
const create =
|
|
857
|
+
const create = cavelonCommand("harness", "new", ref, ...(name !== ref ? ["--name", name] : []));
|
|
831
858
|
throw new CavelonError(ExitCode.failure, {
|
|
832
859
|
code: "solution_not_found",
|
|
833
860
|
message: `Solution ${ref}, which ${source} names, is not on the instance yet; apply previews into an existing solution and creates none.`,
|
|
834
|
-
hint: `Create it as a draft: ${create}, then run \`${cavelonCommand("apply")}
|
|
861
|
+
hint: `Create it as a draft: ${create}, then run \`${cavelonCommand("apply")}\` again.`,
|
|
835
862
|
details: { slug: ref, name, create },
|
|
836
863
|
});
|
|
837
864
|
}
|
|
@@ -966,32 +993,39 @@ export const apply = {
|
|
|
966
993
|
const reported = solutionImport ? tenantWideReport(preview.tenant_wide) : undefined;
|
|
967
994
|
const sections = reported?.sections ?? shared;
|
|
968
995
|
const applied = reported ? reported.applied : tenantWide || !takes;
|
|
969
|
-
const sharedImported = applied ? sections : [];
|
|
970
|
-
const sharedLeftOut = applied ? [] : sections;
|
|
996
|
+
const sharedImported = reported ? reported.imports : applied ? sections : [];
|
|
997
|
+
const sharedLeftOut = reported ? reported.left_out : applied ? [] : sections;
|
|
971
998
|
const reaches = reported?.reaches_active_solutions ?? [];
|
|
972
|
-
|
|
999
|
+
const sharedChanging = sharedImported.length ? sectionsChanging(preview, sharedImported) : [];
|
|
1000
|
+
const sharedSame = sharedImported.length > 0 && sharedChanging !== undefined && !sharedChanging.length;
|
|
1001
|
+
if (sharedImported.length && !sharedSame) {
|
|
973
1002
|
const files = sectionFiles(disk, sharedImported).join(", ") || sharedImported.join(", ");
|
|
974
|
-
|
|
1003
|
+
const what = sharedChanging?.length
|
|
1004
|
+
? `this import changes ${sharedChanging.join(", ")} for every solution of the tenant`
|
|
1005
|
+
: `this import sends ${sharedImported.join(", ")}, and what in ${sharedImported.length === 1 ? "it" : "them"} differs from the instance changes for every solution of the tenant`;
|
|
1006
|
+
ctx.warn(`${files} ${sharedImported.length === 1 ? "holds a section" : "hold sections"} the whole tenant shares: ${what}` +
|
|
975
1007
|
(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
1008
|
}
|
|
977
1009
|
if (sections.length || tenantWide) {
|
|
978
1010
|
data.tenant_wide = {
|
|
979
1011
|
sections,
|
|
980
|
-
applied,
|
|
981
|
-
|
|
1012
|
+
applied: false,
|
|
1013
|
+
would_import: sharedImported,
|
|
982
1014
|
left_out: sharedLeftOut,
|
|
1015
|
+
changing: sharedImported.length ? (sharedChanging ?? null) : [],
|
|
983
1016
|
reaches_active_solutions: reaches,
|
|
984
1017
|
reported_by: reported ? "instance" : "kit",
|
|
985
1018
|
};
|
|
986
1019
|
}
|
|
987
1020
|
const reachText = reaches.length ? `the active solution${reaches.length === 1 ? "" : "s"} ${list(reaches, 10)}` : "";
|
|
988
|
-
const sharedLine =
|
|
989
|
-
? `tenant-wide: ${sharedImported.join(", ")}
|
|
990
|
-
:
|
|
991
|
-
? `tenant-wide: ${
|
|
992
|
-
:
|
|
993
|
-
|
|
994
|
-
|
|
1021
|
+
const sharedLine = sharedSame
|
|
1022
|
+
? `tenant-wide: ${sharedImported.join(", ")} sent as the instance holds ${sharedImported.length === 1 ? "it" : "them"}; nothing changes for the tenant's solutions`
|
|
1023
|
+
: sharedImported.length
|
|
1024
|
+
? `tenant-wide: ${sharedChanging?.length ? sharedChanging.join(", ") : sharedImported.join(", ")} change for every solution of the tenant${reachText ? `, reaching ${reachText}` : ""}`
|
|
1025
|
+
: sharedLeftOut.length
|
|
1026
|
+
? `tenant-wide: ${sharedLeftOut.join(", ")} left out (\`${cavelonCommand("apply", "--include-tenant-wide")}\` imports them, for every solution of the tenant${reachText ? `; they would reach ${reachText}` : ""})`
|
|
1027
|
+
: undefined;
|
|
1028
|
+
const commands = setCommands(preview);
|
|
995
1029
|
if (commands.secrets.length || commands.variables.length)
|
|
996
1030
|
data.set_commands = commands;
|
|
997
1031
|
const context = { disk, harness: harness?.slug };
|
|
@@ -1012,12 +1046,12 @@ export const apply = {
|
|
|
1012
1046
|
return {
|
|
1013
1047
|
data,
|
|
1014
1048
|
text: [
|
|
1015
|
-
previewText(preview,
|
|
1049
|
+
previewText(preview, context),
|
|
1016
1050
|
...(sharedLine ? [sharedLine] : []),
|
|
1017
1051
|
"",
|
|
1018
1052
|
...(pair ? [`hint: ${pair.hint}`] : []),
|
|
1019
1053
|
...(sharedHint ? [`hint: ${sharedHint}`] : []),
|
|
1020
|
-
|
|
1054
|
+
`The preview has blockers; fix them and run \`${cavelonCommand("apply")}\` again.`,
|
|
1021
1055
|
].join("\n"),
|
|
1022
1056
|
exitCode: ExitCode.validation,
|
|
1023
1057
|
};
|
|
@@ -1029,7 +1063,8 @@ export const apply = {
|
|
|
1029
1063
|
data,
|
|
1030
1064
|
text: [
|
|
1031
1065
|
`Preview of ${project.layout.package}/ for ${harness ? `solution ${harness.slug}${harness.status ? ` (${harness.status})` : ""}` : "the tenant"}${envFile ? ` [env ${envFile.name}]` : ""}:`,
|
|
1032
|
-
previewText(preview,
|
|
1066
|
+
previewText(preview, context),
|
|
1067
|
+
...(sharedLine ? [sharedLine] : []),
|
|
1033
1068
|
"",
|
|
1034
1069
|
"Nothing to import: the instance already holds what the package files say. No preview was stored.",
|
|
1035
1070
|
].join("\n"),
|
|
@@ -1058,10 +1093,10 @@ export const apply = {
|
|
|
1058
1093
|
}
|
|
1059
1094
|
const reason = personReason(preview, harness, mode, envFile?.name, sharedImported, reaches);
|
|
1060
1095
|
data.show_to_person = Boolean(reason);
|
|
1061
|
-
const confirmLine = preview.preview_id ?
|
|
1096
|
+
const confirmLine = preview.preview_id ? cavelonCommand("apply", "--confirm", preview.preview_id) : undefined;
|
|
1062
1097
|
const text = [
|
|
1063
1098
|
`Preview of ${project.layout.package}/ for ${harness ? `solution ${harness.slug}${harness.status ? ` (${harness.status})` : ""}` : "the tenant"}${envFile ? ` [env ${envFile.name}]` : ""}:`,
|
|
1064
|
-
previewText(preview,
|
|
1099
|
+
previewText(preview, context),
|
|
1065
1100
|
...(sharedLine ? [sharedLine] : []),
|
|
1066
1101
|
"",
|
|
1067
1102
|
...(preview.preview_id ? [`preview id: ${preview.preview_id}`] : []),
|
|
@@ -1097,7 +1132,7 @@ async function caseStatusAnswer(ctx, status) {
|
|
|
1097
1132
|
code: status.status,
|
|
1098
1133
|
kind: "test_case_status",
|
|
1099
1134
|
message: status.meaning,
|
|
1100
|
-
hint: status.next,
|
|
1135
|
+
hint: spoken(status.next),
|
|
1101
1136
|
summary_counts: status.counts,
|
|
1102
1137
|
docs: instance ? `${instance}${page}` : page,
|
|
1103
1138
|
read: [{ page: TESTING_PAGE, command: cavelonCommand("docs", "get", TESTING_PAGE) }],
|
|
@@ -1108,7 +1143,7 @@ async function caseStatusAnswer(ctx, status) {
|
|
|
1108
1143
|
["code", status.status],
|
|
1109
1144
|
["kind", "test-case status (neither pass nor fail)"],
|
|
1110
1145
|
["meaning", status.meaning],
|
|
1111
|
-
["next",
|
|
1146
|
+
["next", data.hint],
|
|
1112
1147
|
["counted as", status.counts.join(", ")],
|
|
1113
1148
|
["docs", data.docs],
|
|
1114
1149
|
["read", data.read[0].command],
|
|
@@ -1122,7 +1157,7 @@ async function knowledgeOutcomeAnswer(ctx, outcome) {
|
|
|
1122
1157
|
code: outcome.value,
|
|
1123
1158
|
kind: "knowledge_outcome",
|
|
1124
1159
|
message: outcome.message,
|
|
1125
|
-
hint: outcome.hint,
|
|
1160
|
+
hint: spoken(outcome.hint),
|
|
1126
1161
|
...(outcome.recorded_as ? { recorded_as: outcome.recorded_as } : {}),
|
|
1127
1162
|
docs: instance ? `${instance}${page}` : page,
|
|
1128
1163
|
read: [{ page: KNOWLEDGE_OUTCOME_PAGE, command: cavelonCommand("docs", "get", KNOWLEDGE_OUTCOME_PAGE) }],
|
|
@@ -1133,7 +1168,7 @@ async function knowledgeOutcomeAnswer(ctx, outcome) {
|
|
|
1133
1168
|
["code", outcome.value],
|
|
1134
1169
|
["kind", OUTCOME_KIND],
|
|
1135
1170
|
["meaning", outcome.message],
|
|
1136
|
-
["next",
|
|
1171
|
+
["next", data.hint],
|
|
1137
1172
|
["recorded as", outcome.recorded_as],
|
|
1138
1173
|
["docs", data.docs],
|
|
1139
1174
|
["read", data.read[0].command],
|
|
@@ -1143,6 +1178,7 @@ async function knowledgeOutcomeAnswer(ctx, outcome) {
|
|
|
1143
1178
|
const OUTCOME_KIND = "knowledge outcome (what a knowledge search found, as its retrieval span's knowledge_outcome says)";
|
|
1144
1179
|
export const explain = {
|
|
1145
1180
|
name: "explain",
|
|
1181
|
+
tenantless: true,
|
|
1146
1182
|
summary: "Look a code up in the instance's error catalog: what it means and how to fix it.",
|
|
1147
1183
|
description: "Rule codes come from the package and graph checks, API error codes from failed requests; cavelon's own codes (validate's\n" +
|
|
1148
1184
|
"findings, and errors the CLI raises itself, such as operation_not_found or uncommitted_changes) are known too. Uses the\n" +
|
|
@@ -1201,17 +1237,20 @@ export const explain = {
|
|
|
1201
1237
|
const capacity = capacityCodeIn(entry.code);
|
|
1202
1238
|
const stepCap = entry.code.toUpperCase() === PROCESSING_STEP_CAP_CODE;
|
|
1203
1239
|
const ceiling = entry.code === LIMIT_ABOVE_CEILING;
|
|
1204
|
-
const
|
|
1240
|
+
const kitText = capacity
|
|
1205
1241
|
? capacityHint(capacity, await readLimits(ctx).catch(() => undefined))
|
|
1206
1242
|
: stepCap
|
|
1207
1243
|
? processingStepCapHint(await readLimits(ctx).catch(() => undefined))
|
|
1208
1244
|
: ceiling
|
|
1209
1245
|
? ceilingHint(await readLimits(ctx).catch(() => undefined))
|
|
1210
1246
|
: pairOrderPointer(entry.code);
|
|
1247
|
+
const kitHint = kitText ? spoken(kitText) : undefined;
|
|
1211
1248
|
const pages = capacity === MODEL_ENDPOINT_BUSY ? [CAPACITY_TUTORIAL_PAGE, CAPACITY_CONCEPT_PAGE] : [CAPACITY_CONCEPT_PAGE, CAPACITY_TUTORIAL_PAGE];
|
|
1212
1249
|
const read = capacity ? (await listedPages(ctx, pages)).map((page) => ({ page, command: cavelonCommand("docs", "get", page) })) : [];
|
|
1213
|
-
const
|
|
1214
|
-
const
|
|
1250
|
+
const fix = cliFix(entry);
|
|
1251
|
+
const cli = entry.kind === "cli" || !fix ? undefined : spoken(fix);
|
|
1252
|
+
const hint = entry.hint ? spoken(entry.hint) : entry.hint;
|
|
1253
|
+
const data = { ...entry, hint, ...(entry.area === KNOWLEDGE_OUTCOME_AREA ? { kind: "knowledge_outcome" } : {}), docs, ...(cli ? { cli_fix: cli } : {}), ...(kitHint ? { kit_hint: kitHint } : {}), ...(read.length ? { read } : {}) };
|
|
1215
1254
|
return {
|
|
1216
1255
|
data,
|
|
1217
1256
|
text: keyValues([
|
|
@@ -1229,7 +1268,7 @@ export const explain = {
|
|
|
1229
1268
|
: `API error code${entry.area ? ` (${entry.area})` : ""}`,
|
|
1230
1269
|
],
|
|
1231
1270
|
["meaning", entry.message],
|
|
1232
|
-
["fix",
|
|
1271
|
+
["fix", hint ?? undefined],
|
|
1233
1272
|
["with the CLI", cli],
|
|
1234
1273
|
[capacity || stepCap || ceiling ? "raise" : "order", kitHint],
|
|
1235
1274
|
["why", entry.explanation ? clip(entry.explanation.replace(/\s+/g, " "), 600) : undefined],
|
|
@@ -1239,6 +1278,32 @@ export const explain = {
|
|
|
1239
1278
|
};
|
|
1240
1279
|
},
|
|
1241
1280
|
};
|
|
1281
|
+
const SATISFIED = /^(set|ok|configured|confirmed|satisfied|complete|ready|bound)$/i;
|
|
1282
|
+
function missingSecrets(blockers) {
|
|
1283
|
+
const names = new Set();
|
|
1284
|
+
for (const check of blockers) {
|
|
1285
|
+
const items = Array.isArray(check.items) ? check.items : [];
|
|
1286
|
+
for (const item of items) {
|
|
1287
|
+
if (!/secret/i.test(item.kind ?? "") || item.confirmed === true || SATISFIED.test(item.status ?? ""))
|
|
1288
|
+
continue;
|
|
1289
|
+
const name = (item.key ?? "").replace(/^secrets?[:./]/i, "") || (item.label ?? "").replace(/^secret\s+/i, "");
|
|
1290
|
+
if (name)
|
|
1291
|
+
names.add(name);
|
|
1292
|
+
}
|
|
1293
|
+
if (items.length)
|
|
1294
|
+
continue;
|
|
1295
|
+
for (const match of `${check.label ?? ""} ${check.detail ?? check.message ?? ""}`.matchAll(/\bSecret ([A-Za-z0-9_.-]+)/g))
|
|
1296
|
+
names.add(match[1]);
|
|
1297
|
+
}
|
|
1298
|
+
return [...names];
|
|
1299
|
+
}
|
|
1300
|
+
function missingSecretsLine(names, may) {
|
|
1301
|
+
const which = `Secret${names.length === 1 ? "" : "s"} ${names.join(", ")} ${names.length === 1 ? "is" : "are"} not set`;
|
|
1302
|
+
const commands = names.map((n) => secretSetCommand(n)).join("; ");
|
|
1303
|
+
if (may === false)
|
|
1304
|
+
return `${which}, and this token's role cannot set secrets. ${SECRET_SETTER}: ${commands}`;
|
|
1305
|
+
return `${which}: a person sets ${names.length === 1 ? "it" : "each"} (never the agent): ${commands}`;
|
|
1306
|
+
}
|
|
1242
1307
|
const count = (value) => (typeof value === "number" ? value : null);
|
|
1243
1308
|
export async function solutionState(ctx, ref) {
|
|
1244
1309
|
let harness;
|
|
@@ -1265,6 +1330,11 @@ export async function solutionState(ctx, ref) {
|
|
|
1265
1330
|
});
|
|
1266
1331
|
state.ready_to_activate = typeof readiness.ready_to_activate === "boolean" ? readiness.ready_to_activate : null;
|
|
1267
1332
|
state.blockers = (readiness.blockers ?? []).map((b) => clip(String(b.label ?? b.key ?? b.detail ?? "?"), 80));
|
|
1333
|
+
const secrets = missingSecrets(readiness.blockers ?? []);
|
|
1334
|
+
if (secrets.length) {
|
|
1335
|
+
const principal = await readPrincipal(await ctx.client()).catch(() => undefined);
|
|
1336
|
+
state.missing_secrets = { names: secrets, may_set: maySetSecrets(principal) };
|
|
1337
|
+
}
|
|
1268
1338
|
if ("latest_test_run" in readiness) {
|
|
1269
1339
|
const run = readiness.latest_test_run;
|
|
1270
1340
|
const summary = run?.summary ?? {};
|
|
@@ -1297,6 +1367,8 @@ export function solutionStateLines(state) {
|
|
|
1297
1367
|
? `not ready to activate${state.blockers?.length ? ` (${list(state.blockers, 3)})` : ""}`
|
|
1298
1368
|
: undefined;
|
|
1299
1369
|
const lines = [["state", [state.harness.status, ready].filter(Boolean).join(", ")]];
|
|
1370
|
+
if (state.missing_secrets)
|
|
1371
|
+
lines.push(["secrets", missingSecretsLine(state.missing_secrets.names, state.missing_secrets.may_set)]);
|
|
1300
1372
|
const route = state.default_route;
|
|
1301
1373
|
if (route)
|
|
1302
1374
|
lines.push(["default route", defaultRouteText(state.harness, route)]);
|
|
@@ -1453,13 +1525,25 @@ export const activate = {
|
|
|
1453
1525
|
if (!readiness.ready_to_activate) {
|
|
1454
1526
|
const blockers = readiness.blockers ?? [];
|
|
1455
1527
|
const pair = pairOrderHint(await catalogFor(ctx, false), blockers.flatMap((b) => [b.message ?? undefined, b.detail ?? undefined]));
|
|
1528
|
+
const secrets = missingSecrets(blockers);
|
|
1529
|
+
const maySet = maySetSecrets(principal);
|
|
1530
|
+
const secretsLine = secrets.length ? missingSecretsLine(secrets, maySet) : undefined;
|
|
1456
1531
|
return {
|
|
1457
|
-
data: {
|
|
1532
|
+
data: {
|
|
1533
|
+
activated: false,
|
|
1534
|
+
harness,
|
|
1535
|
+
checks,
|
|
1536
|
+
warnings,
|
|
1537
|
+
readiness,
|
|
1538
|
+
...(pair ? { hint: pair.hint } : {}),
|
|
1539
|
+
...(secrets.length ? { missing_secrets: { names: secrets, may_set: maySet, next: secretsLine } } : {}),
|
|
1540
|
+
},
|
|
1458
1541
|
text: [
|
|
1459
1542
|
`${harness.name} (${harness.slug}) is not ready to activate:`,
|
|
1460
1543
|
...blockers.map((b) => ` - ${checkLine(b)}`),
|
|
1461
1544
|
...readinessText(checks, warnings),
|
|
1462
1545
|
...(pair ? [`hint: ${pair.hint}`] : []),
|
|
1546
|
+
...(secretsLine ? [secretsLine] : []),
|
|
1463
1547
|
"Resolve these (often: a passing test run), then activate again. Forcing past the gate is a person's decision in the Admin.",
|
|
1464
1548
|
].join("\n"),
|
|
1465
1549
|
exitCode: ExitCode.validation,
|
package/dist/commands/tenants.js
CHANGED
|
@@ -6,11 +6,11 @@ import { callStable } from "../invoke.js";
|
|
|
6
6
|
import { formatQuota, limitError, limitsOrWarn, readQuotas } from "../limits.js";
|
|
7
7
|
import { containing } from "../choose.js";
|
|
8
8
|
import { readPrincipal, readTenantless } from "../principal.js";
|
|
9
|
-
import {
|
|
9
|
+
import { requireInstance } from "../session.js";
|
|
10
10
|
import { listsTenants, searchTenants } from "../tenant-choice.js";
|
|
11
11
|
import { harnessNotFoundError, lookupHarness, resolveHarnessId } from "../harness-ref.js";
|
|
12
12
|
import { defaultChangeLine, defaultCommands, named, readDefaultRoute, setDefaultRoute } from "../default-route.js";
|
|
13
|
-
import { cavelonCommand } from "../
|
|
13
|
+
import { cavelonCommand, fill } from "../printed.js";
|
|
14
14
|
import { rememberTenant } from "./session.js";
|
|
15
15
|
function idempotency(key) {
|
|
16
16
|
return key ? { "Idempotency-Key": key } : undefined;
|
|
@@ -75,6 +75,7 @@ async function entersTenant(client, tenantId) {
|
|
|
75
75
|
}
|
|
76
76
|
export const tenantCreate = {
|
|
77
77
|
name: "tenant create",
|
|
78
|
+
tenantless: true,
|
|
78
79
|
summary: "Create a tenant (personal access token in Platform mode with tenants.manage).",
|
|
79
80
|
description: "A tenant API key never can. Before sending, the token is checked: one that may not enter Platform mode, or enters it\n" +
|
|
80
81
|
"without tenants.manage, is refused with exit 7 and nothing is sent. With --use, the new tenant is chosen only once the\n" +
|
|
@@ -125,6 +126,7 @@ export const tenantCreate = {
|
|
|
125
126
|
};
|
|
126
127
|
export const tenantList = {
|
|
127
128
|
name: "tenant list",
|
|
129
|
+
tenantless: true,
|
|
128
130
|
summary: "List the tenants this token can see, with name, slug and id.",
|
|
129
131
|
description: "A personal access token in Platform mode sees every tenant; any other sees the tenants it reaches. " +
|
|
130
132
|
"An operator's token that reaches every tenant lists the person's own and finds any other with --search.",
|
|
@@ -139,7 +141,7 @@ export const tenantList = {
|
|
|
139
141
|
async run(ctx, input) {
|
|
140
142
|
const session = await ctx.session();
|
|
141
143
|
if (session.tokenKind === "api_key") {
|
|
142
|
-
throw usageError("A tenant API key sees only its own tenant.", "
|
|
144
|
+
throw usageError("A tenant API key sees only its own tenant.", `\`${cavelonCommand("whoami")}\` shows it.`);
|
|
143
145
|
}
|
|
144
146
|
const limit = intOption(input, "limit", { min: 1, max: 200, fallback: 50 });
|
|
145
147
|
const cursor = stringOption(input, "cursor");
|
|
@@ -173,8 +175,8 @@ export const tenantList = {
|
|
|
173
175
|
page.listed = "own_memberships";
|
|
174
176
|
page.note = "This token reaches every tenant; items and total count only your own memberships. Find any tenant with --search <part of the name>.";
|
|
175
177
|
note = all.length
|
|
176
|
-
? `\nThese are your own memberships; this token reaches every tenant on ${client.url}. Find any other:
|
|
177
|
-
: `No memberships of your own; this token reaches every tenant on ${client.url}. Find any tenant with:
|
|
178
|
+
? `\nThese are your own memberships; this token reaches every tenant on ${client.url}. Find any other: ${cavelonCommand("tenant", "list", "--search", fill("part of the name"))}`
|
|
179
|
+
: `No memberships of your own; this token reaches every tenant on ${client.url}. Find any tenant with: ${cavelonCommand("tenant", "list", "--search", fill("part of the name"))}`;
|
|
178
180
|
}
|
|
179
181
|
}
|
|
180
182
|
else {
|
|
@@ -187,10 +189,10 @@ export const tenantList = {
|
|
|
187
189
|
}
|
|
188
190
|
const columns = page.source === "platform" ? ["name", "slug", "status", "id"] : ["name", "slug", "role", "id"];
|
|
189
191
|
const empty = search ? `No tenant's name or slug contains "${search}".` : note ? "" : "No tenants.";
|
|
190
|
-
const next = page.items.length ? `\nChoose one:
|
|
192
|
+
const next = page.items.length ? `\nChoose one: ${cavelonCommand("use", fill("slug"))} (or \`${cavelonCommand("use")}\` to pick from a list)` : "";
|
|
191
193
|
return {
|
|
192
194
|
data: page,
|
|
193
|
-
text: ((table(page.items, columns) || empty) + moreHint(page.next_cursor, "
|
|
195
|
+
text: ((table(page.items, columns) || empty) + moreHint(page.next_cursor, cavelonCommand("tenant", "list")) + note + next).trimStart(),
|
|
194
196
|
};
|
|
195
197
|
},
|
|
196
198
|
};
|
|
@@ -225,7 +227,7 @@ export const harnessList = {
|
|
|
225
227
|
const columns = ["slug", "name", "status", ...(marksDefault ? ["default"] : []), ...(boolOption(input, "readiness") ? ["ready_to_activate"] : []), "id"];
|
|
226
228
|
return {
|
|
227
229
|
data: page,
|
|
228
|
-
text: (table(rows, columns) ||
|
|
230
|
+
text: (table(rows, columns) || `No solutions yet. Create one: ${cavelonCommand("harness", "new", fill("slug"))}`) + moreHint(page.next_cursor, cavelonCommand("harness", "list")),
|
|
229
231
|
};
|
|
230
232
|
},
|
|
231
233
|
};
|
|
@@ -249,14 +251,12 @@ export const harnessDefault = {
|
|
|
249
251
|
const session = await ctx.session();
|
|
250
252
|
const ref = positional(input, "solution") ?? session.envFile?.harness ?? session.project?.harness;
|
|
251
253
|
if (!ref)
|
|
252
|
-
throw usageError("Which solution?",
|
|
254
|
+
throw usageError("Which solution?", `Pass its name or slug (\`${cavelonCommand("harness", "list")}\` shows them), or run it in a folder whose cavelon.yaml names one.`);
|
|
253
255
|
if (ctx.mode === "mcp" && input.options.confirm === true)
|
|
254
256
|
throw confirmTokenRequired("harness_default");
|
|
255
257
|
const { harness, candidates } = await lookupHarness(ctx, ref);
|
|
256
|
-
if (!harness)
|
|
257
|
-
|
|
258
|
-
throw harnessNotFoundError(ref, candidates, undefined, (slug) => cavelonCommand("harness", "default", slug) + flags, flags);
|
|
259
|
-
}
|
|
258
|
+
if (!harness)
|
|
259
|
+
throw harnessNotFoundError(ref, candidates, undefined, (slug) => cavelonCommand("harness", "default", slug));
|
|
260
260
|
const route = await readDefaultRoute(ctx);
|
|
261
261
|
const target = { id: harness.id, slug: harness.slug, name: harness.name, status: harness.status };
|
|
262
262
|
const current = route.current ? { id: route.current.id, slug: route.current.slug, name: route.current.name } : null;
|
|
@@ -318,7 +318,7 @@ async function checkHarnessCapacity(ctx, slug) {
|
|
|
318
318
|
throw new CavelonError(ExitCode.validation, {
|
|
319
319
|
code: "tenant_quota_reached",
|
|
320
320
|
message: `This tenant has used ${formatQuota(quota)} of its solution quota, so nothing was sent.`,
|
|
321
|
-
hint: `A platform administrator raises the tenant's quotas;
|
|
321
|
+
hint: `A platform administrator raises the tenant's quotas; \`${cavelonCommand("limits")}\` shows them${quotas.docs ? ` (docs: ${quotas.docs})` : ""}. Archiving an unused solution frees one.`,
|
|
322
322
|
docs: quotas.docs ?? undefined,
|
|
323
323
|
details: { quota: { key: quota.key, current: quota.current, limit: quota.limit, path: quotas.path }, sent: false },
|
|
324
324
|
});
|