@cavelon/cli 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -22
- package/dist/choose.js +8 -4
- package/dist/code-hints.js +74 -0
- package/dist/commands/api.js +83 -44
- package/dist/commands/async.js +26 -5
- package/dist/commands/chat.js +177 -0
- package/dist/commands/docs.js +240 -37
- package/dist/commands/fmt.js +120 -0
- package/dist/commands/index.js +9 -1
- package/dist/commands/init.js +64 -30
- package/dist/commands/inventory.js +48 -5
- package/dist/commands/limits-set.js +9 -6
- package/dist/commands/loops.js +15 -9
- package/dist/commands/models.js +16 -7
- package/dist/commands/sandboxes.js +8 -4
- package/dist/commands/schema.js +361 -0
- package/dist/commands/session.js +148 -24
- package/dist/commands/setup.js +22 -6
- package/dist/commands/solution.js +537 -76
- package/dist/commands/tenants.js +156 -15
- package/dist/commands/values.js +18 -9
- package/dist/commands/work.js +343 -35
- package/dist/confirm-token.js +72 -0
- package/dist/contracts.js +3 -0
- package/dist/default-route.js +21 -0
- package/dist/errors.js +4 -0
- package/dist/git.js +14 -5
- package/dist/harness-ref.js +14 -1
- package/dist/http.js +27 -4
- package/dist/invoke.js +8 -4
- package/dist/kit-codes.js +91 -0
- package/dist/limits.js +12 -1
- package/dist/local-state.js +32 -7
- package/dist/main.js +52 -4
- package/dist/mcp.js +72 -15
- package/dist/openapi.js +77 -21
- package/dist/operations.js +4 -3
- package/dist/package-check.js +361 -12
- package/dist/package-files.js +92 -45
- package/dist/package-format.js +222 -0
- package/dist/package-references.js +298 -0
- package/dist/preview-report.js +152 -0
- package/dist/results.js +21 -1
- package/dist/skills/cavelon-authoring/SKILL.md +98 -13
- package/dist/skills/cavelon-long-running/SKILL.md +3 -1
- package/dist/skills/cavelon-loop/SKILL.md +129 -21
- package/dist/skills/cavelon-testing/SKILL.md +130 -10
- package/dist/tenant-choice.js +31 -5
- package/dist/trace-view.js +172 -0
- package/package.json +1 -1
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import { stringify } from "yaml";
|
|
2
|
+
import { boolOption, positional } from "../command.js";
|
|
3
|
+
import { CavelonError, ExitCode, usageError } from "../errors.js";
|
|
4
|
+
import { clip, keyValues, table } from "../format.js";
|
|
5
|
+
import { deref, schemaTypes } from "../openapi.js";
|
|
6
|
+
import { DEFAULT_LAYOUT } from "../package-files.js";
|
|
7
|
+
import { requireInstance } from "../session.js";
|
|
8
|
+
import { schemaFor } from "./solution.js";
|
|
9
|
+
const EXAMPLE_DEPTH = 4;
|
|
10
|
+
function resolve(schema, node) {
|
|
11
|
+
return (deref(schema, node) ?? {});
|
|
12
|
+
}
|
|
13
|
+
function nonNull(schema, node) {
|
|
14
|
+
const resolved = resolve(schema, node);
|
|
15
|
+
for (const key of ["anyOf", "oneOf"]) {
|
|
16
|
+
const branches = resolved[key]?.map((b) => resolve(schema, b)).filter((b) => b.type !== "null");
|
|
17
|
+
if (branches?.length === 1)
|
|
18
|
+
return { ...resolved, ...branches[0], [key]: undefined };
|
|
19
|
+
}
|
|
20
|
+
return resolved;
|
|
21
|
+
}
|
|
22
|
+
function refName(node) {
|
|
23
|
+
return typeof node.$ref === "string" ? node.$ref.split("/").pop() : undefined;
|
|
24
|
+
}
|
|
25
|
+
function entryOf(schema, section) {
|
|
26
|
+
const resolved = nonNull(schema, section);
|
|
27
|
+
if (schemaTypes(resolved).includes("array") && resolved.items)
|
|
28
|
+
return { list: true, entry: nonNull(schema, resolved.items) };
|
|
29
|
+
return { list: false, entry: resolved };
|
|
30
|
+
}
|
|
31
|
+
function namedType(schema, raw) {
|
|
32
|
+
if (refName(raw))
|
|
33
|
+
return refName(raw);
|
|
34
|
+
const resolved = resolve(schema, raw);
|
|
35
|
+
for (const key of ["anyOf", "oneOf"]) {
|
|
36
|
+
const named = (resolved[key] ?? []).filter((b) => resolve(schema, b).type !== "null").map(refName);
|
|
37
|
+
if (named.length === 1 && named[0])
|
|
38
|
+
return named[0];
|
|
39
|
+
}
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
function typeOf(schema, raw) {
|
|
43
|
+
const node = nonNull(schema, raw);
|
|
44
|
+
const ref = namedType(schema, raw);
|
|
45
|
+
const types = schemaTypes(node).filter((t) => t !== "null");
|
|
46
|
+
if (types.includes("array") && node.items) {
|
|
47
|
+
const item = node.items;
|
|
48
|
+
return `list of ${refName(item) ?? (schemaTypes(resolve(schema, item)).join("|") || "any")}`;
|
|
49
|
+
}
|
|
50
|
+
return ref ?? (types.join("|") || "object");
|
|
51
|
+
}
|
|
52
|
+
function fieldsOf(schema, entry) {
|
|
53
|
+
const props = (entry.properties ?? {});
|
|
54
|
+
const required = new Set(entry.required ?? []);
|
|
55
|
+
return Object.entries(props).map(([name, raw]) => {
|
|
56
|
+
const node = nonNull(schema, raw);
|
|
57
|
+
const description = (raw.description ?? node.description);
|
|
58
|
+
return {
|
|
59
|
+
name,
|
|
60
|
+
type: typeOf(schema, raw),
|
|
61
|
+
required: required.has(name),
|
|
62
|
+
description: description ? clip(description, 160) : null,
|
|
63
|
+
...(Array.isArray(node.enum) ? { enum: node.enum } : {}),
|
|
64
|
+
...(node.const !== undefined ? { const: node.const } : {}),
|
|
65
|
+
...(node.default !== undefined && node.default !== null ? { default: node.default } : {}),
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function sample(schema, raw, name, depth) {
|
|
70
|
+
const node = nonNull(schema, raw);
|
|
71
|
+
if (node.const !== undefined)
|
|
72
|
+
return node.const;
|
|
73
|
+
if (node.default !== undefined && node.default !== null)
|
|
74
|
+
return node.default;
|
|
75
|
+
if (Array.isArray(node.enum) && node.enum.length)
|
|
76
|
+
return node.enum[0];
|
|
77
|
+
const types = schemaTypes(node).filter((t) => t !== "null");
|
|
78
|
+
if (types.includes("array"))
|
|
79
|
+
return [];
|
|
80
|
+
if (types.includes("boolean"))
|
|
81
|
+
return false;
|
|
82
|
+
if (types.includes("integer") || types.includes("number"))
|
|
83
|
+
return typeof node.minimum === "number" ? node.minimum : 0;
|
|
84
|
+
if (node.properties || types.includes("object"))
|
|
85
|
+
return depth < EXAMPLE_DEPTH ? minimal(schema, node, depth + 1) : {};
|
|
86
|
+
return `<${name}>`;
|
|
87
|
+
}
|
|
88
|
+
function minimal(schema, entry, depth = 0) {
|
|
89
|
+
const props = (entry.properties ?? {});
|
|
90
|
+
const out = {};
|
|
91
|
+
for (const name of entry.required ?? []) {
|
|
92
|
+
out[name] = props[name] ? sample(schema, props[name], name, depth) : `<${name}>`;
|
|
93
|
+
}
|
|
94
|
+
return out;
|
|
95
|
+
}
|
|
96
|
+
function variants(schema, raw, depth = 0) {
|
|
97
|
+
const resolved = resolve(schema, raw);
|
|
98
|
+
const list = (resolved.anyOf ?? resolved.oneOf);
|
|
99
|
+
if (Array.isArray(list) && depth < 10)
|
|
100
|
+
return list.flatMap((b) => variants(schema, b, depth + 1));
|
|
101
|
+
return resolved.type === "null" ? [] : [{ name: refName(raw), node: resolved }];
|
|
102
|
+
}
|
|
103
|
+
function objectShapes(schema, raw) {
|
|
104
|
+
const { list } = entryOf(schema, raw);
|
|
105
|
+
const all = variants(schema, list ? nonNull(schema, raw).items : raw);
|
|
106
|
+
const shapes = all.filter((v) => v.node.properties);
|
|
107
|
+
const others = all.filter((v) => !v.node.properties).map((v) => schemaTypes(v.node).join("|") || "any");
|
|
108
|
+
return { list, shapes, others };
|
|
109
|
+
}
|
|
110
|
+
function nestedOf(schema, shape, at) {
|
|
111
|
+
const props = (shape.properties ?? {});
|
|
112
|
+
return Object.entries(props).flatMap(([field, raw]) => objectShapes(schema, raw).shapes.length ? [{ field, type: typeOf(schema, raw), path: `${at}.${field}` }] : []);
|
|
113
|
+
}
|
|
114
|
+
function itemSamples(schema, items, name, depth) {
|
|
115
|
+
const resolved = resolve(schema, items);
|
|
116
|
+
const list = (resolved.anyOf ?? resolved.oneOf);
|
|
117
|
+
const first = (node) => {
|
|
118
|
+
const at = resolve(schema, node);
|
|
119
|
+
const inner = (at.anyOf ?? at.oneOf);
|
|
120
|
+
return Array.isArray(inner) && inner.length ? first(inner[0]) : at;
|
|
121
|
+
};
|
|
122
|
+
const branches = Array.isArray(list) ? list.map(first).filter((b) => b.type !== "null") : [resolved];
|
|
123
|
+
return branches.map((b) => (b.properties ? fuller(schema, b, depth + 1) : sample(schema, b, name, depth)));
|
|
124
|
+
}
|
|
125
|
+
function fuller(schema, entry, depth = 0) {
|
|
126
|
+
const out = minimal(schema, entry, depth);
|
|
127
|
+
if (depth >= EXAMPLE_DEPTH)
|
|
128
|
+
return out;
|
|
129
|
+
for (const [name, raw] of Object.entries((entry.properties ?? {}))) {
|
|
130
|
+
if (name in out)
|
|
131
|
+
continue;
|
|
132
|
+
const node = nonNull(schema, raw);
|
|
133
|
+
if (!schemaTypes(node).includes("array") || !node.items)
|
|
134
|
+
continue;
|
|
135
|
+
if (!objectShapes(schema, raw).shapes.length)
|
|
136
|
+
continue;
|
|
137
|
+
out[name] = itemSamples(schema, node.items, name, depth);
|
|
138
|
+
}
|
|
139
|
+
return out;
|
|
140
|
+
}
|
|
141
|
+
function fileOf(layout, section) {
|
|
142
|
+
const folder = layout.items[section];
|
|
143
|
+
return folder ? `${folder}/<one file per entry>.yaml` : `${layout.package}/${section}.yaml`;
|
|
144
|
+
}
|
|
145
|
+
function sourceLine(used) {
|
|
146
|
+
const from = used.source === "instance" ? "read from the instance now" : `cached at ${used.fetched_at ?? "an unknown time"}`;
|
|
147
|
+
return `package format ${used.package_version ?? "?"}, ${from}${used.instance_version ? ` (instance ${used.instance_version})` : ""}`;
|
|
148
|
+
}
|
|
149
|
+
function descend(schema, section, keys) {
|
|
150
|
+
let node = schema.properties[section];
|
|
151
|
+
let at = section;
|
|
152
|
+
for (const key of keys) {
|
|
153
|
+
const { shapes } = objectShapes(schema, node);
|
|
154
|
+
const field = shapes.map((s) => s.node.properties[key]).find((f) => f !== undefined);
|
|
155
|
+
if (!field)
|
|
156
|
+
return { at, key, options: [...new Set(shapes.flatMap((s) => nestedOf(schema, s.node, at).map((n) => n.field)))] };
|
|
157
|
+
node = field;
|
|
158
|
+
at = `${at}.${key}`;
|
|
159
|
+
}
|
|
160
|
+
return { node };
|
|
161
|
+
}
|
|
162
|
+
function usesOf(schema, type) {
|
|
163
|
+
const found = [];
|
|
164
|
+
const walk = (raw, at, seen) => {
|
|
165
|
+
for (const shape of objectShapes(schema, raw).shapes) {
|
|
166
|
+
if (shape.name === type)
|
|
167
|
+
found.push(at);
|
|
168
|
+
if (shape.name && seen.has(shape.name))
|
|
169
|
+
continue;
|
|
170
|
+
const next = new Set(seen);
|
|
171
|
+
if (shape.name)
|
|
172
|
+
next.add(shape.name);
|
|
173
|
+
for (const [field, sub] of Object.entries((shape.node.properties ?? {})))
|
|
174
|
+
walk(sub, `${at}.${field}`, next);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
for (const [section, node] of Object.entries(schema.properties ?? {}))
|
|
178
|
+
walk(node, section, new Set());
|
|
179
|
+
return [...new Set(found)];
|
|
180
|
+
}
|
|
181
|
+
function fieldRows(fields) {
|
|
182
|
+
return fields.map((f) => ({
|
|
183
|
+
field: f.name,
|
|
184
|
+
type: f.type,
|
|
185
|
+
required: f.required ? "yes" : "",
|
|
186
|
+
notes: [f.enum ? `one of ${f.enum.map(String).join(", ")}` : "", f.const !== undefined ? `always ${JSON.stringify(f.const)}` : "", f.default !== undefined ? `default ${JSON.stringify(f.default)}` : "", f.description ?? ""]
|
|
187
|
+
.filter(Boolean)
|
|
188
|
+
.join("; "),
|
|
189
|
+
}));
|
|
190
|
+
}
|
|
191
|
+
const yamlOf = (value) => stringify(value, { lineWidth: 0 }).trimEnd();
|
|
192
|
+
function unknownField(found) {
|
|
193
|
+
const near = found.options.filter((o) => o.includes(found.key) || found.key.includes(o)).slice(0, 5);
|
|
194
|
+
const guess = near.length ? `Did you mean: ${near.map((o) => `${found.at}.${o}`).join(", ")}? ` : "";
|
|
195
|
+
return usageError(`The package schema has no nested field "${found.key}" under ${found.at}.`, found.options.length
|
|
196
|
+
? `${guess}Nested under ${found.at}: ${found.options.join(", ")}.`
|
|
197
|
+
: `Nothing under ${found.at} has fields of its own; \`cavelon schema ${found.at}\` shows its fields.`);
|
|
198
|
+
}
|
|
199
|
+
function findTarget(schema, name) {
|
|
200
|
+
const defs = (schema.$defs ?? {});
|
|
201
|
+
const [section, ...keys] = name.split(".");
|
|
202
|
+
if (section && schema.properties[section]) {
|
|
203
|
+
const found = descend(schema, section, keys);
|
|
204
|
+
if ("options" in found)
|
|
205
|
+
throw unknownField(found);
|
|
206
|
+
return { name, node: found.node, at: name, nested: keys.length > 0 };
|
|
207
|
+
}
|
|
208
|
+
if (!keys.length && Object.hasOwn(defs, name)) {
|
|
209
|
+
const usedIn = usesOf(schema, name);
|
|
210
|
+
return { name, node: { $ref: `#/$defs/${name}` }, at: usedIn[0] ?? name, nested: false, usedIn };
|
|
211
|
+
}
|
|
212
|
+
const lower = name.toLowerCase();
|
|
213
|
+
const near = [...Object.keys(schema.properties), ...Object.keys(defs)].filter((s) => s.toLowerCase().includes(lower) || lower.includes(s.toLowerCase())).slice(0, 5);
|
|
214
|
+
throw usageError(`The package schema has no section or type "${name}".`, near.length ? `Did you mean: ${near.join(", ")}? (\`cavelon schema\` lists them)` : "`cavelon schema` lists the sections.");
|
|
215
|
+
}
|
|
216
|
+
function targetData(schema, target, context) {
|
|
217
|
+
const { node, usedIn } = target;
|
|
218
|
+
const top = (usedIn?.[0] ?? target.name).split(".")[0];
|
|
219
|
+
const { list, shapes, others } = objectShapes(schema, node);
|
|
220
|
+
const one = shapes.length === 1 ? shapes[0] : undefined;
|
|
221
|
+
const wrap = (value) => (list ? [value] : value);
|
|
222
|
+
const minimalOne = one ? minimal(schema, one.node) : undefined;
|
|
223
|
+
const fullOne = one ? fuller(schema, one.node) : undefined;
|
|
224
|
+
const fullDiffers = fullOne !== undefined && JSON.stringify(fullOne) !== JSON.stringify(minimalOne);
|
|
225
|
+
const entry = one?.name ?? (list ? namedType(schema, nonNull(schema, node).items) : namedType(schema, node));
|
|
226
|
+
const unused = usedIn !== undefined && usedIn.length === 0;
|
|
227
|
+
return {
|
|
228
|
+
schema: context.used,
|
|
229
|
+
section: unused ? null : top,
|
|
230
|
+
path: usedIn ? (usedIn[0] ?? null) : target.name,
|
|
231
|
+
...(usedIn ? { used_in: usedIn } : {}),
|
|
232
|
+
kind: list ? "list" : "object",
|
|
233
|
+
required: !usedIn && !target.nested ? context.required.has(target.name) : false,
|
|
234
|
+
file: unused ? null : fileOf(context.layout, top),
|
|
235
|
+
entry: entry ?? null,
|
|
236
|
+
fields: one ? fieldsOf(schema, one.node) : [],
|
|
237
|
+
example: minimalOne === undefined ? null : wrap(minimalOne),
|
|
238
|
+
...(fullDiffers ? { nested_example: wrap(fullOne) } : {}),
|
|
239
|
+
nested: one ? nestedOf(schema, one.node, target.at) : [],
|
|
240
|
+
...(shapes.length > 1
|
|
241
|
+
? { shapes: shapes.map((s) => ({ type: s.name ?? null, fields: fieldsOf(schema, s.node), example: minimal(schema, s.node) })), other_shapes: others }
|
|
242
|
+
: {}),
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function headLines(target, data, used) {
|
|
246
|
+
if (target.usedIn) {
|
|
247
|
+
const where = target.usedIn.length ? target.usedIn.join(", ") : "not used by any section";
|
|
248
|
+
return keyValues([
|
|
249
|
+
["type", `${target.name} (an object)`],
|
|
250
|
+
["used at", where],
|
|
251
|
+
["file", data.file ?? "(none)"],
|
|
252
|
+
["schema", sourceLine(used)],
|
|
253
|
+
]);
|
|
254
|
+
}
|
|
255
|
+
const what = data.kind === "list" ? "a list of entries" : "one object";
|
|
256
|
+
const each = data.entry ? `, each a ${data.entry}` : "";
|
|
257
|
+
return keyValues([
|
|
258
|
+
[target.nested ? "field" : "section", `${target.name} (${what}${each})`],
|
|
259
|
+
["file", data.file ?? "(none)"],
|
|
260
|
+
["schema", sourceLine(used)],
|
|
261
|
+
]);
|
|
262
|
+
}
|
|
263
|
+
const FIELD_COLUMNS = ["field", "type", "required", "notes"];
|
|
264
|
+
function shapeLines(data) {
|
|
265
|
+
const shapes = data.shapes ?? [];
|
|
266
|
+
const others = data.other_shapes ?? [];
|
|
267
|
+
const besides = others.length ? ` (${others.map((o) => `a ${o}`).join(", ")}, or an object below)` : "";
|
|
268
|
+
const lines = [`Each entry takes one of ${shapes.length + others.length} shapes${besides}:`, ""];
|
|
269
|
+
for (const shape of shapes) {
|
|
270
|
+
const example = data.kind === "list" ? [shape.example] : shape.example;
|
|
271
|
+
lines.push(`${shape.type ?? "object"}:`, table(fieldRows(shape.fields), FIELD_COLUMNS), yamlOf(example), "");
|
|
272
|
+
}
|
|
273
|
+
return lines;
|
|
274
|
+
}
|
|
275
|
+
function fieldLines(data) {
|
|
276
|
+
const empty = data.example === null || Object.keys((Array.isArray(data.example) ? data.example[0] : data.example)).length === 0;
|
|
277
|
+
const lines = [
|
|
278
|
+
data.fields.length ? table(fieldRows(data.fields), FIELD_COLUMNS) : "No fields are published here.",
|
|
279
|
+
"",
|
|
280
|
+
empty ? "No field is required; the smallest entry is empty:" : "Minimal example (required fields only):",
|
|
281
|
+
yamlOf(data.example),
|
|
282
|
+
];
|
|
283
|
+
if (data.nested_example)
|
|
284
|
+
lines.push("", "With one entry of each nested list:", yamlOf(data.nested_example));
|
|
285
|
+
if (data.nested.length) {
|
|
286
|
+
const rows = data.nested.map((n) => ({ command: `cavelon schema ${n.path}`, type: n.type }));
|
|
287
|
+
lines.push("", "Fields with fields of their own:", table(rows, ["command", "type"]));
|
|
288
|
+
}
|
|
289
|
+
return lines;
|
|
290
|
+
}
|
|
291
|
+
function targetLines(schema, target, data, used) {
|
|
292
|
+
const head = [headLines(target, data, used), ""];
|
|
293
|
+
if (data.shapes)
|
|
294
|
+
return [...head, ...shapeLines(data)];
|
|
295
|
+
if (data.example !== null)
|
|
296
|
+
return [...head, ...fieldLines(data)];
|
|
297
|
+
const others = objectShapes(schema, target.node).others;
|
|
298
|
+
return [...head, `Each entry is a ${others.join(" or ") || typeOf(schema, entryOf(schema, target.node).entry)}; there are no fields to list.`];
|
|
299
|
+
}
|
|
300
|
+
export const schema = {
|
|
301
|
+
name: "schema",
|
|
302
|
+
summary: "Show the package schema the instance publishes: its sections, or the fields of a section or a nested type, with a minimal example.",
|
|
303
|
+
description: "Without an argument, lists the sections with the file each is kept in. With a section, lists its fields (type, required,\n" +
|
|
304
|
+
"allowed values, default) and prints the smallest entry that has every required field, ready to copy into the file, and an\n" +
|
|
305
|
+
"example with one entry of each nested list. A field whose entries have fields of their own is reached by its path\n" +
|
|
306
|
+
"(`agents.handoffs`, `test_suites.test_cases.steps`) or by its type's name (`PackageAgentHandoff`); the section's\n" +
|
|
307
|
+
"output names them. Where entries take one of several shapes (a step's evaluation_criteria: a text, a judge criterion, an\n" +
|
|
308
|
+
"assertion by type), each shape is listed with its fields. Placeholders are written <field>. Reads the schema as `validate`\n" +
|
|
309
|
+
"does: the cached copy first, the instance otherwise.",
|
|
310
|
+
readOnly: true,
|
|
311
|
+
idempotent: true,
|
|
312
|
+
mcpTool: "package_schema",
|
|
313
|
+
positionals: [
|
|
314
|
+
{
|
|
315
|
+
name: "section",
|
|
316
|
+
description: "A section of the package (agents), a path to a nested field (agents.handoffs, test_suites.test_cases.steps), or a type name (PackageAgentHandoff).",
|
|
317
|
+
},
|
|
318
|
+
],
|
|
319
|
+
options: { offline: { type: "boolean", description: "Use only the cached schema; never contact the instance." } },
|
|
320
|
+
examples: ["cavelon schema", "cavelon schema agents", "cavelon schema agents.handoffs", "cavelon schema test_suites.test_cases.steps.evaluation_criteria --json"],
|
|
321
|
+
async run(ctx, input) {
|
|
322
|
+
const session = await ctx.session();
|
|
323
|
+
requireInstance(session);
|
|
324
|
+
const offline = boolOption(input, "offline");
|
|
325
|
+
const { schema: published, used } = await schemaFor(ctx, session.project?.packageVersion, offline);
|
|
326
|
+
if (!published?.properties) {
|
|
327
|
+
throw new CavelonError(ExitCode.failure, {
|
|
328
|
+
code: "package_schema_unavailable",
|
|
329
|
+
message: "No package schema is cached for this instance, and it was not read.",
|
|
330
|
+
hint: offline
|
|
331
|
+
? "Run `cavelon schema` once without --offline while the instance is reachable."
|
|
332
|
+
: "The instance does not publish its package schema (/api/v1/meta/package-schema).",
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
const layout = session.project?.layout ?? DEFAULT_LAYOUT;
|
|
336
|
+
const required = new Set(published.required ?? []);
|
|
337
|
+
const sections = Object.keys(published.properties);
|
|
338
|
+
const name = positional(input, "section");
|
|
339
|
+
if (!name) {
|
|
340
|
+
const items = sections.map((section) => {
|
|
341
|
+
const node = published.properties[section];
|
|
342
|
+
const { list } = entryOf(published, node);
|
|
343
|
+
const description = (node.description ?? node.title ?? resolve(published, node).title);
|
|
344
|
+
return { section, kind: list ? "list" : "object", required: required.has(section), file: fileOf(layout, section), title: description ? clip(description, 80) : null };
|
|
345
|
+
});
|
|
346
|
+
return {
|
|
347
|
+
data: { schema: used, sections: items },
|
|
348
|
+
text: [
|
|
349
|
+
`Package schema: ${sourceLine(used)}.`,
|
|
350
|
+
"",
|
|
351
|
+
table(items, ["section", "kind", "required", "file"]),
|
|
352
|
+
"",
|
|
353
|
+
"One section's fields and a minimal example: cavelon schema <section>; a nested field's: cavelon schema <section>.<field>",
|
|
354
|
+
].join("\n"),
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
const target = findTarget(published, name);
|
|
358
|
+
const data = targetData(published, target, { used, layout, required });
|
|
359
|
+
return { data, text: targetLines(published, target, data, used).join("\n").trimEnd() };
|
|
360
|
+
},
|
|
361
|
+
};
|