@cavelon/cli 0.1.3 → 0.1.5

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.
Files changed (43) hide show
  1. package/README.md +43 -17
  2. package/dist/agent-env.js +24 -0
  3. package/dist/choose.js +8 -4
  4. package/dist/code-hints.js +74 -0
  5. package/dist/commands/api.js +174 -33
  6. package/dist/commands/async.js +26 -5
  7. package/dist/commands/docs.js +183 -37
  8. package/dist/commands/fmt.js +117 -0
  9. package/dist/commands/index.js +6 -1
  10. package/dist/commands/init.js +28 -6
  11. package/dist/commands/inventory.js +27 -5
  12. package/dist/commands/models.js +7 -1
  13. package/dist/commands/schema.js +193 -0
  14. package/dist/commands/session.js +69 -13
  15. package/dist/commands/solution.js +275 -36
  16. package/dist/commands/tenants.js +125 -15
  17. package/dist/commands/work.js +245 -24
  18. package/dist/contracts.js +3 -0
  19. package/dist/default-route.js +21 -0
  20. package/dist/errors.js +4 -0
  21. package/dist/git.js +14 -5
  22. package/dist/http.js +27 -4
  23. package/dist/invoke.js +8 -4
  24. package/dist/kit-codes.js +85 -0
  25. package/dist/limits.js +12 -1
  26. package/dist/local-state.js +9 -2
  27. package/dist/main.js +16 -3
  28. package/dist/mcp.js +19 -8
  29. package/dist/openapi.js +91 -21
  30. package/dist/operations.js +4 -3
  31. package/dist/package-check.js +193 -4
  32. package/dist/package-files.js +21 -10
  33. package/dist/package-format.js +149 -0
  34. package/dist/package-references.js +231 -0
  35. package/dist/paths.js +4 -3
  36. package/dist/preview-report.js +152 -0
  37. package/dist/results.js +65 -5
  38. package/dist/skills/cavelon-authoring/SKILL.md +67 -8
  39. package/dist/skills/cavelon-long-running/SKILL.md +3 -1
  40. package/dist/skills/cavelon-loop/SKILL.md +75 -13
  41. package/dist/skills/cavelon-testing/SKILL.md +85 -4
  42. package/dist/tenant-choice.js +12 -5
  43. package/package.json +3 -3
@@ -0,0 +1,231 @@
1
+ import { locate } from "./package-files.js";
2
+ export const DUPLICATE_CODE = "package_duplicate_key";
3
+ export const REFERENCE_MISSING_CODE = "package_reference_missing";
4
+ export const REFERENCE_UNKNOWN_CODE = "package_reference_unknown";
5
+ export const FIELD_UNKNOWN_CODE = "package_field_unknown";
6
+ export const MODEL_UNKNOWN_CODE = "package_model_unknown";
7
+ export const SEARCH_TOOL_KEYS = new Set(["search_documents", "search_knowledge_base", "search_kb"]);
8
+ const asObject = (v) => (v && typeof v === "object" && !Array.isArray(v) ? v : undefined);
9
+ const list = (v) => (Array.isArray(v) ? v.map(asObject) : []);
10
+ const text = (v) => (typeof v === "string" && v !== "" ? v : undefined);
11
+ function distance(a, b) {
12
+ let previous = Array.from({ length: b.length + 1 }, (_, j) => j);
13
+ for (let i = 1; i <= a.length; i++) {
14
+ const current = [i];
15
+ for (let j = 1; j <= b.length; j++) {
16
+ current[j] = Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
17
+ }
18
+ previous = current;
19
+ }
20
+ return previous[b.length];
21
+ }
22
+ export function closest(word, candidates, preferred = []) {
23
+ let best;
24
+ const consider = (name, allowance) => {
25
+ const d = distance(word.toLowerCase(), name.toLowerCase());
26
+ if (d <= allowance && (!best || d < best.d))
27
+ best = { name, d };
28
+ };
29
+ for (const name of preferred)
30
+ consider(name, Math.ceil(Math.max(word.length, name.length) / 2));
31
+ for (const name of candidates)
32
+ consider(name, typoAllowance(word));
33
+ return best?.name;
34
+ }
35
+ const typoAllowance = (word) => Math.max(2, Math.floor(word.length / 3));
36
+ const didYouMean = (name) => (name ? ` Did you mean "${name}"?` : "");
37
+ const suggested = (message, suggestion) => ({ message: message + didYouMean(suggestion), ...(suggestion ? { suggestion } : {}) });
38
+ const AGENT = { label: "agent", section: "agents", key: "slug" };
39
+ const SKILL = { label: "skill", section: "skills", key: "slug", inventory: "skills" };
40
+ const TOOL = { label: "tool", section: "tools", key: "slug", inventory: "tools", builtin: SEARCH_TOOL_KEYS };
41
+ const KNOWLEDGE_BASE = { label: "knowledge base", section: "knowledge_bases", key: "name", inventory: "knowledge_bases" };
42
+ const SOLUTION = { label: "solution", section: "harnesses", key: "slug", inventory: "solutions" };
43
+ const KEYED = [AGENT, SKILL, TOOL, KNOWLEDGE_BASE, SOLUTION, { label: "guardrail", section: "guardrails", key: "slug" }];
44
+ const INVENTORY_LABEL = {
45
+ solutions: "solutions",
46
+ knowledge_bases: "knowledge bases",
47
+ tools: "tools",
48
+ skills: "skills",
49
+ models: "models",
50
+ };
51
+ function references(pkg) {
52
+ const found = [];
53
+ const add = (pointer, from, value, target) => {
54
+ const name = text(value);
55
+ if (name)
56
+ found.push({ pointer, from, name, target });
57
+ };
58
+ list(pkg.agents).forEach((agent, i) => {
59
+ if (!agent)
60
+ return;
61
+ const from = `The agent "${text(agent.slug) ?? i}"`;
62
+ add(`/agents/${i}/harness_slug`, from, agent.harness_slug, SOLUTION);
63
+ list(agent.skill_assignments).forEach((a, j) => add(`/agents/${i}/skill_assignments/${j}/skill_slug`, from, a?.skill_slug, SKILL));
64
+ list(agent.tool_assignments).forEach((a, j) => add(`/agents/${i}/tool_assignments/${j}/tool_slug`, from, a?.tool_slug, TOOL));
65
+ list(agent.handoffs).forEach((h, j) => add(`/agents/${i}/handoffs/${j}/to_agent_slug`, from, h?.to_agent_slug, AGENT));
66
+ });
67
+ list(pkg.skills).forEach((skill, i) => {
68
+ if (!skill)
69
+ return;
70
+ const from = `The skill "${text(skill.slug) ?? i}"`;
71
+ list(skill.knowledge_base_assignments).forEach((a, j) => add(`/skills/${i}/knowledge_base_assignments/${j}/knowledge_base_name`, from, a?.knowledge_base_name, KNOWLEDGE_BASE));
72
+ list(skill.tool_assignments).forEach((a, j) => add(`/skills/${i}/tool_assignments/${j}/tool_slug`, from, a?.tool_slug, TOOL));
73
+ });
74
+ return found;
75
+ }
76
+ function keysIn(pkg, target) {
77
+ return list(pkg[target.section]).flatMap((e) => (text(e?.[target.key]) ? [e[target.key]] : []));
78
+ }
79
+ function pulledAt(inventory, kind) {
80
+ return inventory.refreshed_at?.[kind] ?? inventory.written_at;
81
+ }
82
+ export function checkReferences(disk, inventory) {
83
+ const pkg = disk.package;
84
+ const findings = [];
85
+ for (const target of KEYED) {
86
+ const seen = new Map();
87
+ list(pkg[target.section]).forEach((entry, i) => {
88
+ const key = text(entry?.[target.key]);
89
+ if (!key)
90
+ return;
91
+ const first = seen.get(key);
92
+ if (first === undefined) {
93
+ seen.set(key, i);
94
+ return;
95
+ }
96
+ const earlier = locate(disk, `/${target.section}/${first}/${target.key}`);
97
+ findings.push({
98
+ code: DUPLICATE_CODE,
99
+ severity: "error",
100
+ ...locate(disk, `/${target.section}/${i}/${target.key}`),
101
+ message: `Two ${target.section} have the ${target.key} "${key}" (also ${earlier.file ?? earlier.path}${earlier.line ? `:${earlier.line}` : ""}); the import keeps one of them.`,
102
+ });
103
+ });
104
+ }
105
+ for (const ref of references(pkg)) {
106
+ const { target } = ref;
107
+ const inPackage = keysIn(pkg, target);
108
+ if (inPackage.includes(ref.name) || target.builtin?.has(ref.name))
109
+ continue;
110
+ const tenant = target.inventory ? inventory?.names[target.inventory] : undefined;
111
+ if (target === AGENT) {
112
+ findings.push({
113
+ code: REFERENCE_MISSING_CODE,
114
+ severity: "error",
115
+ ...locate(disk, ref.pointer),
116
+ ...suggested(`${ref.from} hands off to the agent "${ref.name}", which is not in the package.`, closest(ref.name, inPackage)),
117
+ });
118
+ continue;
119
+ }
120
+ if (!Array.isArray(tenant) || tenant.includes(ref.name))
121
+ continue;
122
+ const kind = INVENTORY_LABEL[target.inventory];
123
+ findings.push({
124
+ code: REFERENCE_UNKNOWN_CODE,
125
+ severity: "warning",
126
+ ...locate(disk, ref.pointer),
127
+ ...suggested(`${ref.from} names the ${target.label} "${ref.name}", which is neither in the package nor among the tenant's ${kind} ` +
128
+ `at the last pull (${pulledAt(inventory, target.inventory)}).`, closest(ref.name, [...inPackage, ...tenant])),
129
+ });
130
+ }
131
+ return findings;
132
+ }
133
+ function resolve(schema, node) {
134
+ let current = asObject(node);
135
+ for (let i = 0; i < 10 && current && typeof current.$ref === "string"; i++) {
136
+ const ref = current.$ref;
137
+ if (!ref.startsWith("#/$defs/"))
138
+ return undefined;
139
+ current = asObject(schema.$defs?.[ref.slice("#/$defs/".length)]);
140
+ }
141
+ return current;
142
+ }
143
+ function branches(schema, node) {
144
+ const resolved = resolve(schema, node);
145
+ if (!resolved)
146
+ return [];
147
+ const union = [resolved.anyOf, resolved.oneOf, resolved.allOf].find(Array.isArray);
148
+ return union ? union.flatMap((b) => branches(schema, b)) : [resolved];
149
+ }
150
+ export function checkUnknownFields(disk, schema, schemaFindings = []) {
151
+ const findings = [];
152
+ const walk = (value, node, pointer) => {
153
+ if (Array.isArray(value)) {
154
+ const items = branches(schema, node).map((b) => b.items).find((i) => i !== undefined);
155
+ if (items !== undefined)
156
+ value.forEach((item, i) => walk(item, items, `${pointer}/${i}`));
157
+ return;
158
+ }
159
+ const object = asObject(value);
160
+ if (!object)
161
+ return;
162
+ const shapes = branches(schema, node).filter((b) => b.type === "object" || asObject(b.properties));
163
+ if (!shapes.length)
164
+ return;
165
+ const open = shapes.some((b) => !asObject(b.properties) || (b.additionalProperties !== undefined && b.additionalProperties !== false));
166
+ const closed = shapes.every((b) => b.additionalProperties === false);
167
+ const known = new Map();
168
+ const required = new Set();
169
+ for (const shape of shapes) {
170
+ for (const [key, sub] of Object.entries(asObject(shape.properties) ?? {}))
171
+ if (!known.has(key))
172
+ known.set(key, sub);
173
+ if (Array.isArray(shape.required))
174
+ for (const r of shape.required)
175
+ if (typeof r === "string")
176
+ required.add(r);
177
+ }
178
+ const missing = [...required].filter((r) => !(r in object));
179
+ for (const [key, inner] of Object.entries(object)) {
180
+ const at = `${pointer}/${key.replace(/~/g, "~0").replace(/\//g, "~1")}`;
181
+ if (known.has(key)) {
182
+ walk(inner, known.get(key), at);
183
+ continue;
184
+ }
185
+ if (open || closed)
186
+ continue;
187
+ const suggestion = closest(key, known.keys(), missing);
188
+ const parent = locate(disk, pointer).path;
189
+ const required = suggestion && missing.includes(suggestion) ? schemaFindings.find((f) => f.path === parent && f.message === `missing required field "${suggestion}"`) : undefined;
190
+ if (required) {
191
+ required.message += ` ("${key}" is set, which the package schema does not have; did you mean "${suggestion}"?)`;
192
+ required.suggestion = suggestion;
193
+ continue;
194
+ }
195
+ const where = locate(disk, at);
196
+ findings.push({
197
+ code: FIELD_UNKNOWN_CODE,
198
+ severity: "warning",
199
+ ...where,
200
+ message: `"${key}" is not a field of the package schema here; the import ignores it.${didYouMean(suggestion)}`,
201
+ ...(suggestion ? { suggestion } : {}),
202
+ });
203
+ }
204
+ };
205
+ const sections = asObject(schema.properties) ?? {};
206
+ for (const [section, value] of Object.entries(disk.package)) {
207
+ if (section in sections)
208
+ walk(value, sections[section], `/${section}`);
209
+ }
210
+ return findings;
211
+ }
212
+ export function checkModels(disk, inventory) {
213
+ const tenant = inventory?.names.models;
214
+ if (!Array.isArray(tenant) || !tenant.length)
215
+ return [];
216
+ const known = new Set([...tenant, ...list(disk.package.model_registry).flatMap((row) => (text(row?.model_id) ? [row.model_id] : []))]);
217
+ const findings = [];
218
+ list(disk.package.agents).forEach((agent, i) => {
219
+ const model = text(agent?.llm_model);
220
+ if (!model || known.has(model))
221
+ return;
222
+ findings.push({
223
+ code: MODEL_UNKNOWN_CODE,
224
+ severity: "warning",
225
+ ...locate(disk, `/agents/${i}/llm_model`),
226
+ ...suggested(`The agent "${text(agent.slug) ?? i}" uses the model "${model}", which is not in the tenant's model list ` +
227
+ `(${pulledAt(inventory, "models")}).`, closest(model, known)),
228
+ });
229
+ });
230
+ return findings;
231
+ }
package/dist/paths.js CHANGED
@@ -31,16 +31,17 @@ export function instanceKey(url) {
31
31
  const readable = parts.join("_").replace(/[^A-Za-z0-9._-]+/g, "_");
32
32
  return `${readable}-${createHash("sha256").update(url).digest("hex").slice(0, 8)}`;
33
33
  }
34
- export async function confinedPath(ctx, raw, what) {
34
+ export async function confinedPath(ctx, raw, what, confine = ctx.mode === "mcp") {
35
35
  const resolved = path.resolve(ctx.io.cwd, raw);
36
- if (ctx.mode !== "mcp")
36
+ if (!confine)
37
37
  return resolved;
38
38
  const root = (await findProject(ctx.io.cwd))?.root ?? ctx.io.cwd;
39
39
  const real = await realPath(resolved);
40
40
  if (!within(await realPath(root), real)) {
41
+ const who = ctx.mode === "mcp" ? "over MCP a tool" : "run by a coding agent, cavelon";
41
42
  throw new CavelonError(ExitCode.usage, {
42
43
  code: "path_outside_solution",
43
- message: `${what} ${raw} is outside the solution folder ${root}; over MCP a tool reads and writes only there.`,
44
+ message: `${what} ${raw} is outside the solution folder ${root}; ${who} reads and writes only there.`,
44
45
  hint: "Name a file inside the solution folder, or ask the person to run the command in their terminal.",
45
46
  });
46
47
  }
@@ -0,0 +1,152 @@
1
+ import { clip } from "./format.js";
2
+ import { locate } from "./package-files.js";
3
+ import { cavelonCommand } from "./shell.js";
4
+ const isObject = (v) => Boolean(v) && typeof v === "object" && !Array.isArray(v);
5
+ const text = (v) => (typeof v === "string" && v.trim() ? v : null);
6
+ const first = (o, keys) => keys.map((k) => o[k]).find((v) => v !== undefined);
7
+ export function pointerOf(path) {
8
+ if (path.startsWith("/"))
9
+ return path;
10
+ const keys = path
11
+ .replace(/\[(\d+)\]/g, ".$1")
12
+ .split(".")
13
+ .filter(Boolean);
14
+ return `/${keys.map((k) => k.replace(/~/g, "~0").replace(/\//g, "~1")).join("/")}`;
15
+ }
16
+ export function blockerDetails(raw, disk) {
17
+ if (!Array.isArray(raw))
18
+ return [];
19
+ const details = raw.filter(isObject).map((b) => ({
20
+ code: text(b.code),
21
+ message: text(b.message) ?? text(b.detail) ?? JSON.stringify(b),
22
+ path: text(b.path) ?? text(b.pointer) ?? text(b.location),
23
+ hint: text(b.hint),
24
+ }));
25
+ return locateBlockers(details, disk);
26
+ }
27
+ export function locateBlockers(details, disk) {
28
+ if (!disk)
29
+ return details;
30
+ return details.map((b) => {
31
+ if (!b.path)
32
+ return b;
33
+ const at = locate(disk, pointerOf(b.path));
34
+ return { ...b, ...(at.file ? { file: at.file } : {}), ...(at.line ? { line: at.line } : {}) };
35
+ });
36
+ }
37
+ export function blockerLines(details) {
38
+ return details
39
+ .map((b) => {
40
+ const where = [b.file ? `${b.file}${b.line ? `:${b.line}` : ""}` : "", b.path ?? ""].filter(Boolean).join(" ");
41
+ const head = `\n - ${b.code ? `${b.code} ` : ""}${where ? `${where}: ` : ""}${clip(b.message, 300)}`;
42
+ const hint = b.hint ? `\n hint: ${clip(b.hint, 300)}` : "";
43
+ const explain = b.code ? `\n more: ${cavelonCommand("explain", b.code)}` : "";
44
+ return head + hint + explain;
45
+ })
46
+ .join("");
47
+ }
48
+ function change(object, field, raw) {
49
+ if (Array.isArray(raw) && raw.length === 2)
50
+ return { object, field, old: raw[0], new: raw[1] };
51
+ if (!isObject(raw))
52
+ return undefined;
53
+ const before = first(raw, ["old", "before", "from", "old_value", "current"]);
54
+ const after = first(raw, ["new", "after", "to", "new_value", "proposed"]);
55
+ if (before === undefined && after === undefined)
56
+ return undefined;
57
+ return { object, field, old: before ?? null, new: after ?? null };
58
+ }
59
+ function objectOf(entry) {
60
+ const named = text(entry.object) ?? text(entry.target);
61
+ if (named)
62
+ return named;
63
+ const kind = text(entry.kind) ?? text(entry.entity) ?? text(entry.section) ?? text(entry.type);
64
+ const id = text(entry.slug) ?? text(entry.name) ?? text(entry.key) ?? text(entry.id);
65
+ return [kind, id].filter(Boolean).join(":") || "?";
66
+ }
67
+ export function fieldChanges(raw) {
68
+ const out = [];
69
+ const fromFields = (object, fields) => {
70
+ if (Array.isArray(fields)) {
71
+ for (const f of fields.filter(isObject)) {
72
+ const c = change(object, text(f.field) ?? text(f.path) ?? text(f.name) ?? "?", f);
73
+ if (c)
74
+ out.push(c);
75
+ }
76
+ }
77
+ else if (isObject(fields)) {
78
+ for (const [field, value] of Object.entries(fields)) {
79
+ const c = change(object, field, value);
80
+ if (c)
81
+ out.push(c);
82
+ }
83
+ }
84
+ };
85
+ if (Array.isArray(raw)) {
86
+ for (const entry of raw.filter(isObject)) {
87
+ const object = objectOf(entry);
88
+ const nested = first(entry, ["fields", "changes", "diff"]);
89
+ if (nested !== undefined)
90
+ fromFields(object, nested);
91
+ else {
92
+ const c = change(object, text(entry.field) ?? text(entry.path) ?? "?", entry);
93
+ if (c)
94
+ out.push(c);
95
+ }
96
+ }
97
+ }
98
+ else if (isObject(raw)) {
99
+ for (const [object, fields] of Object.entries(raw))
100
+ fromFields(object, fields);
101
+ }
102
+ return out;
103
+ }
104
+ function shown(value) {
105
+ if (value === undefined || value === null)
106
+ return "null";
107
+ return clip(JSON.stringify(value), 80);
108
+ }
109
+ export function changeLines(changes, max = 20) {
110
+ const lines = changes.slice(0, max).map((c) => `\n - ${c.object}.${c.field}: ${shown(c.old)} → ${shown(c.new)}`);
111
+ return lines.join("") + (changes.length > max ? `\n … ${changes.length - max} more (--json)` : "");
112
+ }
113
+ function harnessSlugAt(path, pkg, fallback) {
114
+ const index = /^\/?harnesses[[/.](\d+)/.exec(path)?.[1];
115
+ const list = Array.isArray(pkg?.harnesses) ? pkg.harnesses : [];
116
+ const entry = index !== undefined ? list[Number(index)] : undefined;
117
+ return (isObject(entry) && text(entry.slug)) || fallback;
118
+ }
119
+ export function notApplied(raw, pkg, harness) {
120
+ if (!Array.isArray(raw))
121
+ return [];
122
+ return raw
123
+ .map((entry) => {
124
+ if (typeof entry === "string")
125
+ return { path: entry, how: null };
126
+ if (!isObject(entry))
127
+ return undefined;
128
+ const path = text(entry.path) ?? text(entry.field) ?? text(entry.pointer);
129
+ if (!path)
130
+ return undefined;
131
+ return { path, how: text(entry.how) ?? text(entry.hint) ?? text(entry.set_with) ?? text(entry.reason) ?? text(entry.message) };
132
+ })
133
+ .filter((n) => n !== undefined)
134
+ .map((n) => {
135
+ const field = n.path.split(/[./]/).pop();
136
+ const slug = harnessSlugAt(n.path, pkg, harness);
137
+ if (field === "is_default")
138
+ return { ...n, command: cavelonCommand("harness", "default", slug ?? "<solution>") };
139
+ if (field === "status")
140
+ return { ...n, command: slug ? cavelonCommand("activate", "--harness", slug) : cavelonCommand("activate") };
141
+ return n;
142
+ });
143
+ }
144
+ export function notAppliedLines(list) {
145
+ return list
146
+ .slice(0, 20)
147
+ .map((n) => {
148
+ const how = n.command ? `set with ${n.command}` : n.how ? clip(n.how, 200) : "";
149
+ return `\n - ${n.path}${how ? ` (${how})` : ""}`;
150
+ })
151
+ .join("") + (list.length > 20 ? `\n … ${list.length - 20} more (--json)` : "");
152
+ }
package/dist/results.js CHANGED
@@ -10,8 +10,55 @@ function summaryCount(summary, key) {
10
10
  const value = Number(summary?.[key] ?? 0);
11
11
  return Number.isFinite(value) && value > 0 ? value : 0;
12
12
  }
13
- const NOT_PASSED_COUNTS = ["failed", "errors", "technical_errors", "not_run", "cases_not_run", "missing_results", "unmeasurable_cases", "skipped"];
14
- const WAITING_COUNTS = ["pending_review", "calibration_required"];
13
+ export const NOT_PASSED_COUNTS = ["failed", "errors", "technical_errors", "not_run", "cases_not_run", "missing_results", "unmeasurable_cases", "skipped"];
14
+ export const WAITING_COUNTS = ["pending_review", "calibration_required"];
15
+ export const TESTING_PAGE = "concepts/regression-testing";
16
+ export const CASE_STATUSES = [
17
+ {
18
+ status: "calibration_required",
19
+ counts: ["calibration_required"],
20
+ short: "a knowledge base or value the case needs was not ready",
21
+ meaning: "The instance did not run the case. When it accepted the run (its preflight), a knowledge base the case needs had no ready documents (knowledge_base_not_ready), or a {{var:…}} value the case refers to was not set (tenant_value_missing); the result's reason names which. The run keeps that verdict even if the documents become ready while it runs.",
22
+ next: "Wait until the knowledge base's documents are processed (`cavelon wait` on the upload's operation), or set the value (`cavelon variables set`), then start a new run.",
23
+ section: "preflight-is-decided-when-the-run-is-accepted",
24
+ },
25
+ {
26
+ status: "pending_review",
27
+ counts: ["pending_review"],
28
+ short: "the answer waits for a person's verdict",
29
+ meaning: "The case ran, and its answer waits for a manual verdict: Auto-Evaluate is off for the suite, so no judge scored it.",
30
+ next: "Tell the person: they set Pass, Fail or Skip on the result in the instance. To have the judge score it, turn Auto-Evaluate on for the suite and run it again.",
31
+ section: "reviewing-results",
32
+ },
33
+ {
34
+ status: "not_run",
35
+ counts: ["not_run", "cases_not_run", "missing_results"],
36
+ short: "the step produced no result",
37
+ meaning: "The step produced no result: the run was cancelled or stopped before it (after repeated provider refusals, for example), or the case was held back before any step ran. The run is not comparable and has no pass rate.",
38
+ next: "`cavelon trace <test-run-id>` shows which steps ran and the reasons recorded; fix the cause and start a new run.",
39
+ section: "reviewing-results",
40
+ },
41
+ {
42
+ status: "not_evaluated",
43
+ counts: ["unevaluated_steps"],
44
+ short: "a preparation step, not scored",
45
+ meaning: "A preparation step (`evaluate: false`, or a fixed response): it sets up the dialog for a later step and is not scored, so it counts toward neither side of the pass rate. It does not fail a run.",
46
+ next: "Nothing, unless the step should be judged: then give it `evaluate: true` and a reference answer or criteria.",
47
+ section: "reviewing-results",
48
+ },
49
+ {
50
+ status: "skip",
51
+ counts: ["skipped"],
52
+ short: "the step was skipped",
53
+ meaning: "The step was skipped: a person set a Skip verdict to park the case, or the run was cancelled before the step. The run is not comparable and has no pass rate.",
54
+ next: "When the case applies again, a person replaces the Skip verdict in the instance; after a cancelled run, start a new one.",
55
+ section: "reviewing-results",
56
+ },
57
+ ];
58
+ export function caseStatus(name) {
59
+ const wanted = name.trim().toLowerCase().replaceAll(" ", "_").replaceAll("-", "_");
60
+ return CASE_STATUSES.find((s) => s.status === wanted || s.counts.includes(wanted));
61
+ }
15
62
  export function runVerdict(summary) {
16
63
  const counts = {};
17
64
  for (const key of [...NOT_PASSED_COUNTS, ...WAITING_COUNTS]) {
@@ -33,9 +80,16 @@ export function runVerdict(summary) {
33
80
  }
34
81
  export function countsText(counts) {
35
82
  return Object.entries(counts)
36
- .map(([key, value]) => `${value} ${key === "errors" ? "errored" : key.replaceAll("_", " ")}`)
83
+ .map(([key, value]) => {
84
+ const why = WAITING_COUNTS.includes(key) ? caseStatus(key)?.short : undefined;
85
+ return `${value} ${key === "errors" ? "errored" : key.replaceAll("_", " ")}${why ? ` (${why})` : ""}`;
86
+ })
37
87
  .join(", ");
38
88
  }
89
+ function explainedStatuses(counts) {
90
+ const statuses = Object.keys(counts).map((key) => caseStatus(key)?.status);
91
+ return [...new Set(statuses.filter((s) => Boolean(s)))];
92
+ }
39
93
  const MAX_CASES = 5;
40
94
  const REASON_CHARS = 500;
41
95
  export function failedCase(r, max = REASON_CHARS) {
@@ -69,7 +123,10 @@ export async function resultFailure(ctx, op) {
69
123
  comparable: verdict.comparable,
70
124
  non_comparable_reasons: verdict.non_comparable_reasons,
71
125
  exit_code: verdict.exit_code,
72
- cases: results.filter((r) => NOT_PASSED.has(r.status)).slice(0, MAX_CASES).map((r) => failedCase(r)),
126
+ cases: results
127
+ .filter((r) => NOT_PASSED.has(r.status) || WAITING_COUNTS.includes(r.status))
128
+ .slice(0, MAX_CASES)
129
+ .map((r) => failedCase(r)),
73
130
  trace: cavelonCommand("trace", id),
74
131
  };
75
132
  }
@@ -96,9 +153,12 @@ export function failureLines(failure) {
96
153
  for (const c of failure.cases)
97
154
  lines.push(` ${caseLabel(c)} ${c.status}${c.reason ? ": " + c.reason : ""}`);
98
155
  const shown = failure.cases.length;
99
- const total = failure.failed_cases + failure.errored_cases;
156
+ const total = failure.failed_cases + failure.errored_cases + WAITING_COUNTS.reduce((sum, key) => sum + (failure.counts[key] ?? 0), 0);
100
157
  if (total > shown)
101
158
  lines.push(` … ${total - shown} more`);
159
+ const statuses = explainedStatuses(failure.counts);
160
+ if (statuses.length)
161
+ lines.push(` What to do: ${statuses.map((s) => cavelonCommand("explain", s)).join("; ")}`);
102
162
  lines.push(` Look closer: ${failure.trace}`);
103
163
  return lines.join("\n");
104
164
  }
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: cavelon-authoring
3
- description: Writing and changing a Cavelon solution package in a repository - the package/ files split by schema section, the package schema, environments in env/, declaring the variables and secrets a solution needs, and fixing validation codes with cavelon explain. Use when editing files under package/, tests/ or env/ of a folder with cavelon.yaml, when cavelon validate or apply reports an error code, when the user asks to add or change agents, tools, skills, knowledge bases or triggers of a Cavelon solution, or when a limit of the tenant needs changing (cavelon limits set) or they set up a self-hosted model endpoint or its concurrency limit (max_concurrent_requests).
3
+ description: Writing and changing a Cavelon solution package in a repository - the package/ files split by schema section, the package schema, the persona (who the assistant is, its greeting and fallback), environments in env/, declaring the variables and secrets a solution needs, and fixing validation codes with cavelon explain. Use when editing files under package/, tests/ or env/ of a folder with cavelon.yaml, when cavelon validate or apply reports an error code, when the user asks to add or change agents, tools, skills, knowledge bases or triggers of a Cavelon solution, or when a limit of the tenant needs changing (cavelon limits set) or they set up a self-hosted model endpoint or its concurrency limit (max_concurrent_requests).
4
4
  license: Apache-2.0
5
5
  ---
6
6
 
@@ -131,7 +131,10 @@ it and where, as the output says.
131
131
 
132
132
  A file of a section the instance does not know is kept as it is; the preview
133
133
  lists it under "ignored". `package/manifest.yaml` names the package format
134
- version; leave it as `pull` wrote it.
134
+ version; leave it as `pull` wrote it. Some fields are not applied by an
135
+ import: the preview lists them under "not applied", each with the command
136
+ that sets it (a solution's `status` with `cavelon activate`, its `is_default`
137
+ with `cavelon harness default`).
135
138
 
136
139
  ## Finding out what a section takes
137
140
 
@@ -141,13 +144,62 @@ version; leave it as `pull` wrote it.
141
144
  (JSON or YAML): it writes the same files as `pull`, refuses to change files
142
145
  that hold something else unless `--force`, and names the sections this
143
146
  instance ignores.
144
- 2. The schema: `cavelon validate` checks the files against the instance's
145
- package schema, and each error names the file, line and field.
147
+ 2. The schema: `cavelon schema` lists the sections and the file each is kept
148
+ in; `cavelon schema <section>` (the `package_schema` tool) lists a section's
149
+ fields with type, required, allowed values and default, and prints the
150
+ smallest entry with every required field, to copy into the file. A pulled
151
+ file that is `[]` shows no shape; this does. `cavelon validate` checks the
152
+ files against the same schema, and each error names the file, line and
153
+ field. It also checks the references: a duplicate slug and a handoff to an
154
+ agent the package lacks are errors; a skill, tool, knowledge base or
155
+ solution that is neither in the package nor in the tenant's list from the
156
+ last pull, a field the schema does not have (`package_field_unknown`, "did
157
+ you mean temperature?") and an `llm_model` outside the tenant's model list
158
+ are warnings. A finding's `suggestion` (with `--json`) is the closest name.
146
159
  3. Concepts and fields: `cavelon docs search <topic>` (for example "agent
147
160
  graph", "tools", "knowledge base", "triggers"), then `cavelon docs get
148
161
  <page>`.
149
- 4. A code from `validate`, `apply` or a failed request: `cavelon explain
150
- <code>`. It gives the meaning, the fix and a docs link.
162
+ 4. A code from `validate`, `apply`, a failed request or `cavelon` itself:
163
+ `cavelon explain <code>`. It gives the meaning, the fix (with the command
164
+ that does it, where the instance's fix names an API route) and a docs link;
165
+ for a code it does not know, the closest known ones. `cavelon api describe
166
+ <operation>` shows a body's fields, and the item fields of a list
167
+ (`updates[]`).
168
+
169
+ ## The persona: who the assistant is
170
+
171
+ Every solution has a persona in `package/persona.yaml`. It is not an agent's
172
+ instructions:
173
+
174
+ - **The persona says who** the assistant is, for every agent of the solution:
175
+ its name (`bot_name`), its voice and its boundaries (`persona_prompt`), the
176
+ greeting a conversation opens with and the fallback it gives when it has no
177
+ answer, its language (`language_hint`), response style, disclaimer and the
178
+ widget's copy.
179
+ - **An agent's `system_prompt` says what** that one agent does: its task, its
180
+ tools, when it hands off. Put a rule about tone or identity into the
181
+ persona, and a rule about a task into the agent; `cavelon docs get
182
+ concepts/personas` explains the split.
183
+
184
+ `pull` and `init` write every field the instance's schema lists; a field that
185
+ is not set is a comment with its default (`# bot_name: null`). Remove the `#`
186
+ and fill the field in to set it. A file of comments only sets nothing.
187
+
188
+ - Set at least `bot_name` and `persona_prompt` for a solution people talk to.
189
+ - Write `greeting_message` and `fallback_message` in the content language,
190
+ the language the assistant answers in (the knowledge base's, the
191
+ customer's), not the language of this conversation. `language_hint` names
192
+ it.
193
+ - A greeting or fallback that is on (`greeting_enabled`,
194
+ `fallback_message_enabled`, both on by default) with an empty text shows
195
+ nothing of the solution's own; `cavelon validate` warns
196
+ (`persona_message_empty`). Write the text, or turn it off.
197
+ - Leave the persona out (all fields commented) only for a solution nobody
198
+ talks to directly: a pipeline, a loop, a solution another solution calls.
199
+ - Without `harness_id`, the persona operations of `cavelon api`
200
+ (`get_bot_persona`, `upsert_bot_persona`) reach the tenant's default route;
201
+ in a solution folder, `cavelon api` sends the folder's solution, and says
202
+ so. Prefer the package file and `apply` over those operations.
151
203
 
152
204
  ## Rules that keep a package portable
153
205
 
@@ -155,7 +207,10 @@ version; leave it as `pull` wrote it.
155
207
  a slug creates a new entry and, with `--mode replace`, deletes the old one.
156
208
  - **Secrets and variables are references only:** write `{{secret:<name>}}` or
157
209
  `{{var:<name>}}` where a value is needed, and declare the name (below). Never
158
- write a secret value into any file, an argument or a message.
210
+ write a secret value into any file, an argument or a message. `cavelon api`
211
+ refuses a body that sets a field the instance marks as a secret value
212
+ (`x-cavelon-secret`: provider keys, passwords and the like): leave the field
213
+ out and let the person enter the value in the Admin.
159
214
  - **Environment specifics go into `env/`, not `package/`.** Runtime
160
215
  requirements (Sandboxes, other solutions) are bound per environment in
161
216
  `runtime_bindings`, keyed by the requirement's key, to the target tenant's
@@ -217,7 +272,11 @@ schema has them: `cavelon validate` reports an unknown section):
217
272
 
218
273
  ## After each edit
219
274
 
220
- 1. `cavelon validate` until it reports no errors.
275
+ 1. `cavelon validate` until it reports no errors. After writing files by
276
+ hand, `cavelon fmt` brings them into the form the instance's export gives
277
+ them (field order, the schema's defaults filled in), so the first `pull`
278
+ after `apply` shows only what changed on the instance; `cavelon fmt
279
+ --check` changes nothing and exits 3 when a file would change.
221
280
  2. `cavelon apply --env test` to see what the instance makes of it; the
222
281
  preview re-checks everything on the server, including rules that only the
223
282
  instance can check (graph rules, references between sections).
@@ -68,7 +68,9 @@ connection), the run may have started: retry only with the
68
68
  starts and spends the budget again. `cavelon trace <operation-id>` reads the
69
69
  run's traces. Keep each `watch` or `wait` under your shell's time
70
70
  limit and run it again to resume (exit 6 means still running). Over MCP, use the
71
- `loop_iterations` and `operation_status` tools; they never block.
71
+ `loop_iterations` and `operation_status` tools; `loop_iterations` never
72
+ blocks, and `operation_status` waits only when given a `timeout` (at most 50
73
+ seconds).
72
74
 
73
75
  - **Pause** at the next safe point: `cavelon loop pause <run>`. Resume with
74
76
  `cavelon loop resume <run>`. A paused loop makes `wait` and `loop watch` exit