@cavelon/cli 0.1.4 → 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.
@@ -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
+ }
@@ -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
+ }
@@ -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
 
@@ -220,7 +272,11 @@ schema has them: `cavelon validate` reports an unknown section):
220
272
 
221
273
  ## After each edit
222
274
 
223
- 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.
224
280
  2. `cavelon apply --env test` to see what the instance makes of it; the
225
281
  preview re-checks everything on the server, including rules that only the
226
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
@@ -14,8 +14,10 @@ use it when you parse the result.
14
14
  ## Before anything
15
15
 
16
16
  - `cavelon status` says which instance, tenant and solution this folder is
17
- bound to, the last pull and the open previews. `cavelon whoami` says who the
18
- token acts as and when it expires.
17
+ bound to, the solution's state (draft or active, whether it is ready to
18
+ activate, its latest test run), the last pull and the open previews.
19
+ `cavelon whoami` says who the token acts as, when it expires, whether it may
20
+ enter Platform mode and which tenants it reaches.
19
21
  - **Never handle a token.** If a command exits 7 (not authorised) or says no
20
22
  token, ask the person to run `cavelon login --instance <url>` themselves (in a
21
23
  terminal, or with a `!` prefix where your client offers one). Never ask them
@@ -54,17 +56,29 @@ use it when you parse the result.
54
56
 
55
57
  1. **Pull** what is live: `cavelon pull`. It refuses when `package/` has
56
58
  uncommitted changes (outside git: files changed since the last pull);
57
- commit or apply them first. `git diff` then shows what someone changed
58
- in the Admin.
59
+ commit or apply them first. A file as the last pull or confirmed apply left
60
+ it counts as unchanged, so a pull right after an apply goes ahead without a
61
+ commit. `git diff` then shows what someone changed in the Admin.
59
62
  2. **Edit** the files in `package/` (one file per schema section) and `tests/`
60
63
  (one file per test suite). See the cavelon-authoring skill.
61
64
  3. **Validate** offline: `cavelon validate`. Fix every error; `cavelon explain
62
- <code>` says what a code means and how to fix it.
65
+ <code>` says what a code means and how to fix it. Besides the schema it
66
+ finds duplicate slugs, handoffs to an agent the package lacks, fields the
67
+ schema does not have (with "did you mean"), and skills, tools, knowledge
68
+ bases, solutions and models the tenant did not hold at the last pull
69
+ (warnings: `cavelon pull` or `cavelon models list` refreshes that list).
70
+ After writing files by hand, run `cavelon fmt`: it fills in the defaults
71
+ the export writes, so the first `pull` after the apply rewrites only what
72
+ changed on the instance.
63
73
  4. **Preview**: `cavelon apply --env test` (or `--harness <name or slug>`). Nothing is
64
74
  imported yet. Read the preview: what is created, updated or deleted, which
65
75
  active solutions it reaches, what the target still needs (variables and
66
76
  secrets with the command that sets each, OAuth grants, runtime bindings,
67
- trigger identities), loop budgets, and what the instance ignores.
77
+ trigger identities), loop budgets, and what the instance ignores. A recent
78
+ instance also lists each field it changes (`field changes`, `object.field:
79
+ old → new`) and the fields it does not apply ("not applied", with the
80
+ command that sets each). A blocked preview names each blocker with its
81
+ code, package file and path, and hint; `cavelon explain <code>` says more.
68
82
  5. **Confirm** exactly that preview: `cavelon apply --confirm <preview-id>`
69
83
  (the line `apply` printed, with the same `--env` and `--tenant`). Exit 4 means the target changed since the preview:
70
84
  preview again and confirm the new id. When the error lists `blockers`, the
@@ -75,7 +89,15 @@ use it when you parse the result.
75
89
  a type it does not accept, and a `.zip` unless the tenant has archive
76
90
  uploads on (`kb_upload_archive_enabled`) and it stays within their file
77
91
  count, unpacked size and compression ratio (exit 3, naming the limit and who
78
- changes it). A test
92
+ changes it).
93
+ **Updating a document**: upload the new version under the same file name
94
+ with `--replace` (try it with `--dry-run` first). Without it the old version
95
+ may stay active next to the new one, and both answer: `kb upload` names each
96
+ file that matches an active document ("bergbahn-faq.md exists (094e95e9…)
97
+ and stays active"). An instance that replaces same-named documents itself
98
+ does so on every upload (`--keep-both` keeps both); where the instance's
99
+ upload cannot replace, `--replace` shows the documents it would deactivate
100
+ after the upload and needs `--confirm`: show the person that first. A test
79
101
  Sandbox gets its files with `cavelon sandbox seed <sandbox> <folder>`
80
102
  (isolated container) or `cavelon sandbox refresh <sandbox>` after the files
81
103
  were put on the VM (customer VM).
@@ -86,6 +108,22 @@ use it when you parse the result.
86
108
  8. **Fix** what the results and traces show, and go back to step 2. Commit
87
109
  when a step works.
88
110
 
111
+ ## The default route
112
+
113
+ A tenant answers its chat and widget, where a conversation names no solution,
114
+ with one solution: its **default route**. A fresh tenant's default is an empty
115
+ `default` solution, so a new solution built beside it answers nobody there.
116
+ `cavelon harness list` marks the default (DEFAULT), and `cavelon activate`
117
+ says when the solution it activated is not the default.
118
+
119
+ - **Ask the person** whether the new solution should become the default. It
120
+ changes live traffic; never decide it yourself.
121
+ - With their yes: `cavelon activate --make-default` (or `cavelon harness
122
+ default <solution>`) shows the change, naming the current default; show it,
123
+ then run the same command with `--confirm`.
124
+ - `is_default` in `harnesses.yaml` is not applied by `apply`; the preview
125
+ lists it under "not applied".
126
+
89
127
  ## Show the person before confirming
90
128
 
91
129
  Confirm on your own only for a draft solution in a test environment. Stop and
@@ -100,7 +138,9 @@ show the preview to the person, and confirm only after they agree, when:
100
138
 
101
139
  The same holds for the other commands that take `--confirm`: without it they
102
140
  only show what would happen. Show it to the person before `cavelon trigger
103
- identity <trigger> <key> --confirm` (it gives a trigger standing authority), and
141
+ identity <trigger> <key> --confirm` (it gives a trigger standing authority),
142
+ before `cavelon harness default … --confirm` or `cavelon activate
143
+ --make-default --confirm` (it moves live traffic), and
104
144
  before `cavelon sandbox seed … --confirm` or `cavelon loop cancel … --confirm` on
105
145
  anything but a test Sandbox or a run you started yourself.
106
146
 
@@ -155,8 +195,10 @@ return operation ids at once. `cavelon wait <ids> --timeout 90s` returns the
155
195
  state when the time is up (exit 6 means still running; the same `wait` again
156
196
  resumes). Keep each wait under your shell's command time limit, and run longer
157
197
  waits in the background if your client can. Over MCP, the `operation_status`
158
- tool reads an operation without blocking. Exit 5 means a person must act (an
159
- approval, a paused loop): tell them, with the link `wait` prints.
198
+ tool returns the state at once, or, given a `timeout`, waits up to it (at most
199
+ 50 seconds) and reports `waited_ms`; `timed_out` is true only when it waited
200
+ the whole timeout. Exit 5 means a person must act (an approval, a paused
201
+ loop): tell them, with the link `wait` prints.
160
202
 
161
203
  **Never approve anything.** An approval is decided by a person, or by an API
162
204
  key an owner granted the explicit scope `approvals.decide`; never by you, and
@@ -174,9 +216,11 @@ preview · 5 needs a person · 6 timed out (still running) · 7 not authorised
174
216
  ## Where to read more
175
217
 
176
218
  - `cavelon docs search <query>` and `cavelon docs get <page>`: the instance's
177
- own docs, for its version.
178
- - `.cavelon/inventory.md`: the tenant's solutions, knowledge bases, tools, test
179
- suites and sandboxes from the last pull; `cavelon sandbox list` for their
219
+ own docs, for its version. They are in English; a German question works for
220
+ the core concepts, English words for the rest. `cavelon docs get index`
221
+ lists every page.
222
+ - `.cavelon/inventory.md`: the tenant's solutions, knowledge bases, tools,
223
+ skills, models, test suites and sandboxes from the last pull; `cavelon sandbox list` for their
180
224
  current state and mode.
181
225
  - `cavelon api list --search <word>` and `cavelon api <operation>`: any API
182
226
  operation the workflow commands do not cover.