@ontology-kit/okb 0.1.0 → 0.3.0-alpha.210

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 (97) hide show
  1. package/README.md +1 -1
  2. package/dist/check.d.ts +43 -0
  3. package/dist/check.js +83 -0
  4. package/dist/checks.d.ts +1 -1
  5. package/dist/checks.js +4 -4
  6. package/dist/cli.js +11 -705
  7. package/dist/clidocs.d.ts +0 -2
  8. package/dist/clidocs.js +5 -27
  9. package/dist/clock.js +1 -1
  10. package/dist/command-table.d.ts +134 -0
  11. package/dist/command-table.js +82 -0
  12. package/dist/commands/documents.d.ts +3 -0
  13. package/dist/commands/documents.js +250 -0
  14. package/dist/commands/getting-started.d.ts +3 -0
  15. package/dist/commands/getting-started.js +135 -0
  16. package/dist/commands/housekeeping.d.ts +3 -0
  17. package/dist/commands/housekeeping.js +203 -0
  18. package/dist/commands/modeling.d.ts +3 -0
  19. package/dist/commands/modeling.js +433 -0
  20. package/dist/commands/planning.d.ts +3 -0
  21. package/dist/commands/planning.js +212 -0
  22. package/dist/commands/reviewing.d.ts +3 -0
  23. package/dist/commands/reviewing.js +177 -0
  24. package/dist/commands/skills.d.ts +3 -0
  25. package/dist/commands/skills.js +52 -0
  26. package/dist/commands.d.ts +10 -22
  27. package/dist/commands.js +15 -622
  28. package/dist/diff.d.ts +85 -0
  29. package/dist/diff.js +323 -0
  30. package/dist/export.d.ts +1 -1
  31. package/dist/export.js +1 -1
  32. package/dist/families.d.ts +1 -1
  33. package/dist/families.js +1 -1
  34. package/dist/help.d.ts +11 -2
  35. package/dist/help.js +51 -57
  36. package/dist/kbdocs.d.ts +18 -0
  37. package/dist/kbdocs.js +393 -0
  38. package/dist/metakb.d.ts +1 -1
  39. package/dist/metakb.js +1 -1
  40. package/dist/naming.d.ts +2 -2
  41. package/dist/naming.js +2 -2
  42. package/dist/ontology-ref.d.ts +20 -0
  43. package/dist/ontology-ref.js +108 -0
  44. package/dist/ops/admin.d.ts +1 -1
  45. package/dist/ops/admin.js +24 -7
  46. package/dist/ops/classes.d.ts +1 -1
  47. package/dist/ops/classes.js +13 -5
  48. package/dist/ops/instances.d.ts +2 -1
  49. package/dist/ops/instances.js +7 -1
  50. package/dist/ops/links.d.ts +1 -1
  51. package/dist/ops/links.js +1 -1
  52. package/dist/ops/naming.d.ts +1 -1
  53. package/dist/ops/naming.js +3 -1
  54. package/dist/ops/scope.d.ts +5 -1
  55. package/dist/ops/scope.js +19 -1
  56. package/dist/ops/slots.d.ts +1 -1
  57. package/dist/ops/slots.js +15 -2
  58. package/dist/ops/values.d.ts +1 -1
  59. package/dist/ops/values.js +5 -1
  60. package/dist/provenance.d.ts +4 -2
  61. package/dist/provenance.js +58 -17
  62. package/dist/release.d.ts +52 -0
  63. package/dist/release.js +337 -0
  64. package/dist/render.d.ts +64 -1
  65. package/dist/render.js +240 -3
  66. package/dist/resync.d.ts +98 -0
  67. package/dist/resync.js +234 -0
  68. package/dist/review.d.ts +1 -1
  69. package/dist/review.js +1 -1
  70. package/dist/reviewdocs.d.ts +42 -0
  71. package/dist/reviewdocs.js +263 -0
  72. package/dist/runner.d.ts +3 -0
  73. package/dist/runner.js +79 -0
  74. package/dist/skills.js +1 -1
  75. package/dist/status.d.ts +1 -1
  76. package/dist/status.js +1 -1
  77. package/dist/types.d.ts +1 -1
  78. package/dist/types.js +1 -1
  79. package/dist/verifynote.d.ts +18 -0
  80. package/dist/verifynote.js +92 -0
  81. package/dist/workflows.d.ts +256 -0
  82. package/dist/workflows.js +223 -0
  83. package/meta-kb/data/manifest.json +2 -2
  84. package/meta-kb/data/nodes.json +8 -8
  85. package/package.json +9 -4
  86. package/schema/edge.schema.json +68 -0
  87. package/schema/edges.schema.json +9 -0
  88. package/schema/node.schema.json +893 -0
  89. package/schema/nodes.schema.json +9 -0
  90. package/schema/okb.schema.json +41 -0
  91. package/skills/build-domain-kb-from-docs/SKILL.md +20 -2
  92. package/skills/ontology-coach/SKILL.md +6 -2
  93. package/skills/ontology-maintainer/SKILL.md +152 -0
  94. package/skills/ontology-review/SKILL.md +3 -1
  95. package/skills/ontology-signoff/SKILL.md +182 -0
  96. package/templates/okb-check.yml +132 -0
  97. package/templates/pull_request_template.md +16 -0
@@ -0,0 +1,337 @@
1
+ /**
2
+ * `okb release <version>` and `okb release verify`: versioned releases of a knowledge base that
3
+ * consumers (an MCP server, an eval run) can pin. A release writes, inside the KB folder:
4
+ *
5
+ * manifest.json the pin: id, version, and the SHA-256 of every file (the latest release)
6
+ * RELEASES.md every release's change log, newest first
7
+ * releases/<version>/ manifest.json, okb.json, nodes.jsonl, edges.jsonl as released,
8
+ * CHANGES.md and changes.json: what changed since the release before it
9
+ *
10
+ * The change log is `okb diff` between the previous release's snapshot and the working folder, so a
11
+ * release needs no git. The last release is the `version` in `manifest.json`. Output is a function of
12
+ * the files and `SOURCE_DATE_EPOCH` (the date in a change log heading), so cutting the same release
13
+ * twice gives the same bytes. The manifest's shape is the Canvas KB's; docs/FORMAT.md ("Releases")
14
+ * says where it differs.
15
+ */
16
+ import { createHash } from "node:crypto";
17
+ import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
18
+ import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
19
+ import { OkbError, Ontology, slug } from "@ontology-kit/reader";
20
+ import { today } from "./clock.js";
21
+ import { diffMarkdown, diffOntologies, isEmpty } from "./diff.js";
22
+ import { sourcePath } from "./provenance.js";
23
+ export const MANIFEST_FILE = "manifest.json";
24
+ export const RELEASES_DIR = "releases";
25
+ const ONTOLOGY_FILES = ["okb.json", "nodes.jsonl", "edges.jsonl"];
26
+ const SEMVER = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/;
27
+ /** <0 if a is older than b, 0 if equal, >0 if newer. Semver precedence; a version with a pre-release tag is older than the plain one. */
28
+ export function compareVersions(a, b) {
29
+ const x = SEMVER.exec(a);
30
+ const y = SEMVER.exec(b);
31
+ for (let i = 1; i <= 3; i++)
32
+ if (Number(x[i]) !== Number(y[i]))
33
+ return Number(x[i]) - Number(y[i]);
34
+ if (x[4] === y[4])
35
+ return 0;
36
+ if (x[4] === undefined)
37
+ return 1;
38
+ if (y[4] === undefined)
39
+ return -1;
40
+ const pa = x[4].split(".");
41
+ const pb = y[4].split(".");
42
+ for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
43
+ if (pa[i] === undefined)
44
+ return -1;
45
+ if (pb[i] === undefined)
46
+ return 1;
47
+ if (pa[i] === pb[i])
48
+ continue;
49
+ const na = /^\d+$/.test(pa[i]);
50
+ const nb = /^\d+$/.test(pb[i]);
51
+ if (na && nb)
52
+ return Number(pa[i]) - Number(pb[i]);
53
+ if (na !== nb)
54
+ return na ? -1 : 1;
55
+ return pa[i] < pb[i] ? -1 : 1;
56
+ }
57
+ return 0;
58
+ }
59
+ export const isVersion = (v) => SEMVER.test(v);
60
+ const sha256 = (file) => createHash("sha256").update(readFileSync(file)).digest("hex");
61
+ const posix = (p) => p.split(sep).join("/");
62
+ const sortedRecord = (o) => Object.fromEntries(Object.keys(o).sort().map((k) => [k, o[k]]));
63
+ const json = (v) => JSON.stringify(v, null, 2) + "\n";
64
+ /** Read and check the shape of a manifest.json. Throws OkbError naming the problem. */
65
+ export function readReleaseManifest(file) {
66
+ let raw;
67
+ try {
68
+ raw = JSON.parse(readFileSync(file, "utf8"));
69
+ }
70
+ catch (e) {
71
+ throw new OkbError(`Can't read ${file}: ${e.message}`);
72
+ }
73
+ const bad = (why) => {
74
+ throw new OkbError(`${file} isn't a valid release manifest: ${why}`);
75
+ };
76
+ if (!raw || typeof raw !== "object")
77
+ return bad("it should be a JSON object.");
78
+ if (typeof raw.id !== "string" || !raw.id)
79
+ bad("it has no id.");
80
+ if (typeof raw.version !== "string" || !raw.version)
81
+ bad("it has no version.");
82
+ if (!raw.datasets || typeof raw.datasets !== "object")
83
+ bad("it has no datasets.");
84
+ for (const [name, d] of Object.entries(raw.datasets)) {
85
+ if (!d || typeof d.path !== "string" || !d.files || typeof d.files !== "object")
86
+ bad(`dataset ${name} needs a path and files.`);
87
+ for (const [f, h] of Object.entries(d.files))
88
+ if (typeof h !== "string" || !/^[0-9a-f]{64}$/.test(h))
89
+ bad(`dataset ${name}: ${f} has no SHA-256 (64 lowercase hex digits).`);
90
+ }
91
+ return raw;
92
+ }
93
+ /** The registered sources as a dataset: the folder they share and each file's hash. Throws if a source file is missing. */
94
+ function sourcesDataset(ont) {
95
+ const files = new Map();
96
+ const missing = [];
97
+ for (const s of ont.ofType("Source")) {
98
+ if (!s.localPath)
99
+ continue;
100
+ const abs = resolve(sourcePath(ont, s));
101
+ if (!existsSync(abs) || !statSync(abs).isFile())
102
+ missing.push(`${s.title || s.id} (${s.localPath})`);
103
+ else
104
+ files.set(abs, sha256(abs));
105
+ }
106
+ if (missing.length)
107
+ throw new OkbError(`Can't release: ${missing.length} source file(s) are missing, so their hashes can't be pinned: ${missing.join(", ")}. Restore them or remove the source nodes.`);
108
+ if (!files.size)
109
+ return undefined;
110
+ const segs = [...files.keys()].map((f) => dirname(f).split(sep));
111
+ let common = segs[0];
112
+ for (const s of segs) {
113
+ let i = 0;
114
+ while (i < common.length && i < s.length && common[i] === s[i])
115
+ i++;
116
+ common = common.slice(0, i);
117
+ }
118
+ const base = common.join(sep) || sep;
119
+ const rel = posix(relative(ont.root, base)) || ".";
120
+ return {
121
+ path: rel,
122
+ description: `${files.size} source file${files.size === 1 ? "" : "s"} that quotes in the ontology cite.`,
123
+ files: sortedRecord(Object.fromEntries([...files].map(([abs, h]) => [posix(relative(base, abs)), h]))),
124
+ };
125
+ }
126
+ function sourceChanges(before, after) {
127
+ const a = before?.files ?? {};
128
+ const b = after?.files ?? {};
129
+ const out = { added: [], removed: [], changed: [] };
130
+ for (const f of Object.keys(b).sort()) {
131
+ if (!(f in a))
132
+ out.added.push(f);
133
+ else if (a[f] !== b[f])
134
+ out.changed.push(f);
135
+ }
136
+ for (const f of Object.keys(a).sort())
137
+ if (!(f in b))
138
+ out.removed.push(f);
139
+ return out;
140
+ }
141
+ const noSourceChanges = (s) => !s.added.length && !s.removed.length && !s.changed.length;
142
+ function countsLine(ont) {
143
+ const n = (t) => ont.ofType(t).length;
144
+ return `${n("Class")} classes, ${n("Slot")} slots, ${n("Instance")} instances and ${n("Source")} sources.`;
145
+ }
146
+ /** Whether okb.json differs from the released copy in anything but its version (`okb pin` changes okbVersion alone, and that is pinned too). */
147
+ function manifestChanged(snap, ont) {
148
+ try {
149
+ const was = JSON.parse(readFileSync(join(snap, "okb.json"), "utf8"));
150
+ const strip = (m) => JSON.stringify(Object.entries(m).filter(([k]) => k !== "version").sort(([a], [b]) => (a < b ? -1 : 1)));
151
+ return strip(was) !== strip(ont.manifest);
152
+ }
153
+ catch {
154
+ return false;
155
+ }
156
+ }
157
+ /** One release's section of the change log (also the whole of CHANGES.md). */
158
+ function changesMarkdown(version, previous, date, diff, sources, ont, note) {
159
+ const out = [`## ${version} (${date})`, ""];
160
+ if (!previous)
161
+ out.push(`The first release: ${countsLine(ont)}`, "");
162
+ else
163
+ out.push(`Changes since ${previous}.`, "");
164
+ if (note)
165
+ out.push(note, "");
166
+ if (diff) {
167
+ // the diff's own Markdown, one heading level down
168
+ const body = diffMarkdown(diff).split("\n").slice(2).join("\n").replace(/^## /gm, "### ").trimEnd();
169
+ out.push(body, "");
170
+ }
171
+ if (!noSourceChanges(sources) && previous) {
172
+ out.push("### Source files", "");
173
+ for (const f of sources.added)
174
+ out.push(`- **Added** \`${f}\``);
175
+ for (const f of sources.removed)
176
+ out.push(`- **Removed** \`${f}\``);
177
+ for (const f of sources.changed)
178
+ out.push(`- **Changed** \`${f}\``);
179
+ out.push("");
180
+ }
181
+ return out.join("\n").replace(/\n{3,}/g, "\n\n").trimEnd() + "\n";
182
+ }
183
+ /** The versions that have a releases/<version>/ folder, newest first. */
184
+ function releasedVersions(root) {
185
+ const dir = join(root, RELEASES_DIR);
186
+ if (!existsSync(dir))
187
+ return [];
188
+ return readdirSync(dir, { withFileTypes: true })
189
+ .filter((e) => e.isDirectory() && isVersion(e.name) && existsSync(join(dir, e.name, "CHANGES.md")))
190
+ .map((e) => e.name)
191
+ .sort((a, b) => compareVersions(b, a));
192
+ }
193
+ function writeReleasesMd(root, name) {
194
+ const sections = releasedVersions(root).map((v) => readFileSync(join(root, RELEASES_DIR, v, "CHANGES.md"), "utf8").trimEnd());
195
+ writeFileSync(join(root, "RELEASES.md"), `# Releases of ${name}\n\nEach release's changes, newest first. \`manifest.json\` pins the latest one; \`okb release verify\` checks the files against it.\n\n${sections.join("\n\n")}\n`);
196
+ }
197
+ /** The writer `writeFileAtomic` uses; tests swap `write` to simulate a failed write. */
198
+ export const releaseIo = {
199
+ write: (file, text) => writeFileSync(file, text, "utf8"),
200
+ };
201
+ /**
202
+ * Write `text` to a temp file next to `file`, then rename it into place, so a failed write leaves the
203
+ * previous `file` whole. The temp file is removed if the write or the rename fails.
204
+ */
205
+ function writeFileAtomic(file, text) {
206
+ const tmp = `${file}.tmp`;
207
+ try {
208
+ releaseIo.write(tmp, text);
209
+ renameSync(tmp, file);
210
+ }
211
+ catch (e) {
212
+ rmSync(tmp, { force: true });
213
+ throw e;
214
+ }
215
+ }
216
+ /**
217
+ * Cut release `version` of the folder `ont` was loaded from. Call it inside `Ontology.edit` (it saves
218
+ * and writes files under the lock). `findings` are the validator's results; any open error stops the release.
219
+ * Writes nothing when it refuses.
220
+ */
221
+ export function cutRelease(ont, version, findings) {
222
+ if (!isVersion(version))
223
+ throw new OkbError(`'${version}' isn't a version. Use semver: 1.0.0, 1.2.3 or 2.0.0-rc.1.`);
224
+ const errors = findings.filter((f) => f.severity === "error" && !f.explainedBy);
225
+ if (errors.length) {
226
+ throw new OkbError(`Can't release: okb validate reports ${errors.length} error(s). Fix them first (okb validate shows them). The first: ${errors[0].message}`);
227
+ }
228
+ const root = ont.root;
229
+ const lastFile = join(root, MANIFEST_FILE);
230
+ const last = existsSync(lastFile) ? readReleaseManifest(lastFile) : undefined;
231
+ if (last && isVersion(last.version) && compareVersions(version, last.version) <= 0) {
232
+ throw new OkbError(`Version ${version} isn't newer than the last release, ${last.version}. Pick a higher version.`);
233
+ }
234
+ // The root manifest.json is what makes a release exist, and it is written last. So a releases/<version>/
235
+ // folder for a version newer than the one it pins is what a release that stopped half-way leaves (even when
236
+ // the folder's own manifest.json got written), and it is written over. A finished release is never newer
237
+ // than the pinned one, so the check above already refuses to rewrite it.
238
+ const docs = sourcesDataset(ont);
239
+ let diff;
240
+ let note;
241
+ if (last) {
242
+ const snap = join(root, RELEASES_DIR, last.version);
243
+ if (existsSync(join(snap, "nodes.jsonl")) && existsSync(join(snap, "okb.json"))) {
244
+ diff = diffOntologies(Ontology.load(snap), ont, last.version, version);
245
+ }
246
+ else
247
+ note = `There's no snapshot of ${last.version} in ${RELEASES_DIR}/, so this release can't list what changed in the knowledge.`;
248
+ }
249
+ const sources = sourceChanges(last?.datasets.docs, docs);
250
+ if (diff && isEmpty(diff) && !diff.summary.stampOnly && noSourceChanges(sources) && !manifestChanged(join(root, RELEASES_DIR, last.version), ont)) {
251
+ throw new OkbError(`Nothing has changed since ${last.version}, so there is nothing to release.`);
252
+ }
253
+ const date = today(); // an invalid SOURCE_DATE_EPOCH stops here, before anything is written
254
+ // Everything is checked; from here on it writes.
255
+ ont.manifest.version = version;
256
+ ont.save();
257
+ const ontologyFiles = Object.fromEntries(ONTOLOGY_FILES.map((f) => [f, sha256(join(root, f))]));
258
+ const manifest = {
259
+ id: last?.id ?? (slug(ont.meta.name || ont.manifest.name || "") || "ontology"),
260
+ version,
261
+ title: ont.meta.name || ont.manifest.name || last?.title,
262
+ ...(last?.description ? { description: last.description } : {}),
263
+ datasets: {
264
+ ...(docs ? { docs } : {}),
265
+ ontology: {
266
+ path: ".",
267
+ description: `okb graph (${ont.manifest.format}): ${ont.nodes.length} nodes and ${ont.edges.length} edges. Pinned files only; the folder also holds ${MANIFEST_FILE}, ${RELEASES_DIR}/ and RELEASES.md.`,
268
+ files: sortedRecord(ontologyFiles),
269
+ },
270
+ },
271
+ ...(last?.provenance ? { provenance: last.provenance } : {}),
272
+ };
273
+ const snap = join(root, RELEASES_DIR, version);
274
+ mkdirSync(snap, { recursive: true });
275
+ for (const f of ONTOLOGY_FILES)
276
+ copyFileSync(join(root, f), join(snap, f));
277
+ writeFileSync(join(snap, "changes.json"), json({ version, previous: last?.version ?? null, changes: diff ?? null, sources }));
278
+ writeFileSync(join(snap, "CHANGES.md"), changesMarkdown(version, last?.version, date, diff, sources, ont, note));
279
+ writeReleasesMd(root, manifest.title ?? manifest.id);
280
+ // The manifests go last: they are what makes the release exist, so a failure above leaves nothing pinned.
281
+ // Dataset paths are relative to the manifest, so the snapshot's copy points at the sources from its own folder.
282
+ const snapManifest = { ...manifest, datasets: { ...manifest.datasets, ...(docs ? { docs: { ...docs, path: posix(relative(snap, resolve(root, docs.path))) || "." } } : {}) } };
283
+ writeFileAtomic(join(snap, MANIFEST_FILE), json(snapManifest));
284
+ writeFileAtomic(lastFile, json(manifest));
285
+ const notes = [`Released ${version}${last ? ` (was ${last.version})` : ""}: ${countsLine(ont)}`];
286
+ if (diff) {
287
+ const s = diff.summary;
288
+ notes.push(`Since ${last.version}: ${s.nodesAdded} node(s) added, ${s.nodesRemoved} removed, ${s.nodesChanged} changed; ${diff.relationshipTypeRenames.length} edge type(s) renamed.`);
289
+ }
290
+ if (note)
291
+ notes.push(note);
292
+ notes.push(`Wrote ${MANIFEST_FILE}, RELEASES.md and ${join(RELEASES_DIR, version)}/. Commit them, and tag the commit if you want a git ref for ${version}.`);
293
+ return { version, previous: last?.version, manifest, notes };
294
+ }
295
+ /** Check the files in `root` against its manifest.json. Read-only. */
296
+ export function verifyRelease(root) {
297
+ const file = join(root, MANIFEST_FILE);
298
+ if (!existsSync(file))
299
+ throw new OkbError(`There is no ${MANIFEST_FILE} in ${resolve(root)}. Cut a release first: okb release <version>.`);
300
+ const m = readReleaseManifest(file);
301
+ const problems = [];
302
+ let checked = 0;
303
+ // The knowledge itself must be pinned: a manifest that leaves out the ontology files would verify anything.
304
+ for (const f of ONTOLOGY_FILES)
305
+ if (!m.datasets.ontology?.files[f])
306
+ problems.push(`ontology: ${f} isn't pinned in the manifest`);
307
+ const inside = (base, p) => !relative(base, p).startsWith("..") && !isAbsolute(relative(base, p));
308
+ for (const [name, d] of Object.entries(m.datasets)) {
309
+ const dir = resolve(root, d.path);
310
+ if (!existsSync(dir) || !statSync(dir).isDirectory()) {
311
+ problems.push(`${name}: folder ${d.path} is missing`);
312
+ continue;
313
+ }
314
+ for (const [f, expected] of Object.entries(d.files).sort(([p], [q]) => (p < q ? -1 : 1))) {
315
+ checked++;
316
+ const p = join(dir, f);
317
+ if (!inside(dir, p))
318
+ problems.push(`${name}: ${f} points outside its folder`);
319
+ else if (!existsSync(p) || !statSync(p).isFile())
320
+ problems.push(`${name}: ${f} is missing`);
321
+ else {
322
+ const got = sha256(p);
323
+ if (got !== expected)
324
+ problems.push(`${name}: ${f} differs from the release (SHA-256 ${got.slice(0, 12)}…, the manifest says ${expected.slice(0, 12)}…)`);
325
+ }
326
+ }
327
+ }
328
+ try {
329
+ const v = JSON.parse(readFileSync(join(root, "okb.json"), "utf8")).version;
330
+ if (v !== m.version)
331
+ problems.push(`okb.json says version ${v ?? "(none)"}, the manifest says ${m.version}`);
332
+ }
333
+ catch {
334
+ // an unreadable okb.json shows up above as a hash mismatch or a missing file
335
+ }
336
+ return { id: m.id, version: m.version, ok: problems.length === 0, checked, problems };
337
+ }
package/dist/render.d.ts CHANGED
@@ -1,6 +1,12 @@
1
1
  import { type Explainable, type MetaStep } from "./metakb.js";
2
- import { type Ontology, type OkbNode } from "@ontology-kit/format";
2
+ import { type CompetencyQuestionNode, type DesignDecisionNode, type Ontology, type OkbNode, type SourceLocationNode, type SourceNode } from "@ontology-kit/reader";
3
3
  import { type Finding } from "./types.js";
4
+ import type { CheckReport } from "./check.js";
5
+ import type { MdDoc } from "./markdown.js";
6
+ import type { ReviewItem } from "./review.js";
7
+ import type { SkillState } from "./skills.js";
8
+ import type { computeStatus } from "./status.js";
9
+ type Status = ReturnType<typeof computeStatus>;
4
10
  export declare const c: {
5
11
  bold: (s: string) => string;
6
12
  dim: (s: string) => string;
@@ -28,3 +34,60 @@ export declare function listExplainable(): string;
28
34
  export declare function tree(ont: Ontology, withInstances?: boolean): string;
29
35
  export declare function show(ont: Ontology, n: OkbNode): string;
30
36
  export declare function mermaid(ont: Ontology): string;
37
+ /** The `okb check` summary: one line per check, the problems under the ones that failed, and a verdict. */
38
+ export declare function formatCheck(report: CheckReport, name: string): string;
39
+ export declare function formatNotes(notes: readonly string[]): string[];
40
+ export declare function renderInit(name: string, root: string, folder: string, guide: string): string[];
41
+ export declare function renderScope(m: Ontology["meta"]): string[];
42
+ export declare function renderConvention(ont: Ontology): string;
43
+ export declare function renderQuestions(ont: Ontology, qs: readonly CompetencyQuestionNode[]): string[];
44
+ export declare function renderTerms(ont: Ontology): string[];
45
+ export declare function renderReuse(ont: Ontology): string[];
46
+ export declare function renderDecisions(ont: Ontology, ds: readonly DesignDecisionNode[]): string[];
47
+ export declare function renderFindings(findings: Finding[], hiddenLater: number, ont: Ontology, opts: {
48
+ all?: boolean;
49
+ verbose?: boolean;
50
+ }): string[];
51
+ export declare function renderStatus(ont: Ontology, findings: Finding[], st: Status): string[];
52
+ /** What `okb step <n>` prints after moving: a warning if the step you left isn't finished, then the new step's guide. */
53
+ export declare function renderStepMove(target: number, leaving: {
54
+ order: number;
55
+ complete: boolean;
56
+ items: {
57
+ done: boolean | null;
58
+ text: string;
59
+ }[];
60
+ }): string[];
61
+ export declare function renderExplainHits(hits: readonly Explainable[], q: string): string[];
62
+ export declare function renderSearchHits(hits: readonly Explainable[], query: string): string[];
63
+ export declare function renderReview(ont: Ontology, items: ReviewItem[], all: boolean): string[];
64
+ export declare function renderSources(ont: Ontology): string[];
65
+ export declare function renderOutline(src: SourceNode, doc: MdDoc, blocks: MdDoc["blocks"], quoted: ReadonlyMap<number, unknown>, onlyProblems: boolean): string[];
66
+ export declare function renderQuotes(ont: Ontology, locs: readonly SourceLocationNode[]): string[];
67
+ export declare function renderRules(ont: Ontology): string[];
68
+ export declare function renderDrift(hits: readonly {
69
+ message: string;
70
+ }[]): string[];
71
+ export declare function renderReleaseVerify(r: {
72
+ ok: boolean;
73
+ id: string;
74
+ version: string;
75
+ checked: number;
76
+ problems: string[];
77
+ }): string[];
78
+ export declare function renderPin(version: string): string;
79
+ export declare function renderSkillsInstall(dir: string, lines: readonly string[]): string[];
80
+ export declare function renderSkillsStatus(dir: string, metaVersion: string, skills: readonly {
81
+ name: string;
82
+ state: SkillState;
83
+ detail: string;
84
+ }[]): string[];
85
+ export declare function renderWrote(out: string, what: string, hint: string): string;
86
+ export declare function renderStepGuide(order: number): string;
87
+ export declare function renderDiagramWritten(out: string): string;
88
+ export declare function renderExportWritten(out: string, g: {
89
+ nodes: unknown[];
90
+ relationships: unknown[];
91
+ notes: string[];
92
+ }, fmt: string): string[];
93
+ export {};