@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.
- package/README.md +1 -1
- package/dist/check.d.ts +43 -0
- package/dist/check.js +83 -0
- package/dist/checks.d.ts +1 -1
- package/dist/checks.js +4 -4
- package/dist/cli.js +11 -705
- package/dist/clidocs.d.ts +0 -2
- package/dist/clidocs.js +5 -27
- package/dist/clock.js +1 -1
- package/dist/command-table.d.ts +134 -0
- package/dist/command-table.js +82 -0
- package/dist/commands/documents.d.ts +3 -0
- package/dist/commands/documents.js +250 -0
- package/dist/commands/getting-started.d.ts +3 -0
- package/dist/commands/getting-started.js +135 -0
- package/dist/commands/housekeeping.d.ts +3 -0
- package/dist/commands/housekeeping.js +203 -0
- package/dist/commands/modeling.d.ts +3 -0
- package/dist/commands/modeling.js +433 -0
- package/dist/commands/planning.d.ts +3 -0
- package/dist/commands/planning.js +212 -0
- package/dist/commands/reviewing.d.ts +3 -0
- package/dist/commands/reviewing.js +177 -0
- package/dist/commands/skills.d.ts +3 -0
- package/dist/commands/skills.js +52 -0
- package/dist/commands.d.ts +10 -22
- package/dist/commands.js +15 -622
- package/dist/diff.d.ts +85 -0
- package/dist/diff.js +323 -0
- package/dist/export.d.ts +1 -1
- package/dist/export.js +1 -1
- package/dist/families.d.ts +1 -1
- package/dist/families.js +1 -1
- package/dist/help.d.ts +11 -2
- package/dist/help.js +51 -57
- package/dist/kbdocs.d.ts +18 -0
- package/dist/kbdocs.js +393 -0
- package/dist/metakb.d.ts +1 -1
- package/dist/metakb.js +1 -1
- package/dist/naming.d.ts +2 -2
- package/dist/naming.js +2 -2
- package/dist/ontology-ref.d.ts +20 -0
- package/dist/ontology-ref.js +108 -0
- package/dist/ops/admin.d.ts +1 -1
- package/dist/ops/admin.js +24 -7
- package/dist/ops/classes.d.ts +1 -1
- package/dist/ops/classes.js +13 -5
- package/dist/ops/instances.d.ts +2 -1
- package/dist/ops/instances.js +7 -1
- package/dist/ops/links.d.ts +1 -1
- package/dist/ops/links.js +1 -1
- package/dist/ops/naming.d.ts +1 -1
- package/dist/ops/naming.js +3 -1
- package/dist/ops/scope.d.ts +5 -1
- package/dist/ops/scope.js +19 -1
- package/dist/ops/slots.d.ts +1 -1
- package/dist/ops/slots.js +15 -2
- package/dist/ops/values.d.ts +1 -1
- package/dist/ops/values.js +5 -1
- package/dist/provenance.d.ts +4 -2
- package/dist/provenance.js +58 -17
- package/dist/release.d.ts +52 -0
- package/dist/release.js +337 -0
- package/dist/render.d.ts +64 -1
- package/dist/render.js +240 -3
- package/dist/resync.d.ts +98 -0
- package/dist/resync.js +234 -0
- package/dist/review.d.ts +1 -1
- package/dist/review.js +1 -1
- package/dist/reviewdocs.d.ts +42 -0
- package/dist/reviewdocs.js +263 -0
- package/dist/runner.d.ts +3 -0
- package/dist/runner.js +79 -0
- package/dist/skills.js +1 -1
- package/dist/status.d.ts +1 -1
- package/dist/status.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/verifynote.d.ts +18 -0
- package/dist/verifynote.js +92 -0
- package/dist/workflows.d.ts +256 -0
- package/dist/workflows.js +223 -0
- package/meta-kb/data/manifest.json +2 -2
- package/meta-kb/data/nodes.json +8 -8
- package/package.json +9 -4
- package/schema/edge.schema.json +68 -0
- package/schema/edges.schema.json +9 -0
- package/schema/node.schema.json +893 -0
- package/schema/nodes.schema.json +9 -0
- package/schema/okb.schema.json +41 -0
- package/skills/build-domain-kb-from-docs/SKILL.md +20 -2
- package/skills/ontology-coach/SKILL.md +6 -2
- package/skills/ontology-maintainer/SKILL.md +152 -0
- package/skills/ontology-review/SKILL.md +3 -1
- package/skills/ontology-signoff/SKILL.md +182 -0
- package/templates/okb-check.yml +132 -0
- package/templates/pull_request_template.md +16 -0
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ The `okb` command-line tool from [Ontology Kit](https://ontology-kit.dev), a too
|
|
|
4
4
|
|
|
5
5
|
It's for a team that keeps a knowledge base and wants every fact to point back to its source. It's also for someone building their first: the Ontology 101 method (Noy & McGuinness, 2001), the Learn course and the tutorials walk you through it step by step.
|
|
6
6
|
|
|
7
|
-
The package ships the `okb` command, the meta-KB (a knowledge base about building knowledge bases, which holds the method and its rules), and skills that let Claude coach you, review your work, and extract a knowledge base from documents. Other tools can read the file format with the small [`@ontology-kit/
|
|
7
|
+
The package ships the `okb` command, the meta-KB (a knowledge base about building knowledge bases, which holds the method and its rules), and skills that let Claude coach you, review your work, and extract a knowledge base from documents. Other tools can read the file format with the small [`@ontology-kit/reader`](https://www.npmjs.com/package/@ontology-kit/reader) package, which okb itself builds on.
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
package/dist/check.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `okb check`: the one answer to "is this KB safe to merge?". It reads the folder and never writes it
|
|
3
|
+
* or takes the lock. Each check is one entry in CHECK_STEPS; to add a check (the ledger check, `okb cq check`),
|
|
4
|
+
* add an entry and, if it handles a rule that `validate` also reports, list the rule in its `rules`.
|
|
5
|
+
*/
|
|
6
|
+
import type { Ontology } from "@ontology-kit/reader";
|
|
7
|
+
import type { Finding } from "./types.js";
|
|
8
|
+
export type StepStatus = "pass" | "warn" | "fail";
|
|
9
|
+
export interface StepResult {
|
|
10
|
+
id: string;
|
|
11
|
+
title: string;
|
|
12
|
+
status: StepStatus;
|
|
13
|
+
/** One line saying what was found, for the summary. */
|
|
14
|
+
summary: string;
|
|
15
|
+
/** What a reviewer should look at, one entry per problem. */
|
|
16
|
+
problems: string[];
|
|
17
|
+
}
|
|
18
|
+
export interface CheckInput {
|
|
19
|
+
ont: Ontology;
|
|
20
|
+
/** The report of `validate --all` (nothing hidden). */
|
|
21
|
+
findings: Finding[];
|
|
22
|
+
/** The okb version running this check. */
|
|
23
|
+
installed: string;
|
|
24
|
+
}
|
|
25
|
+
export interface CheckStep {
|
|
26
|
+
id: string;
|
|
27
|
+
title: string;
|
|
28
|
+
/** Rules this step reports. `validation` leaves them out so a problem shows once. */
|
|
29
|
+
rules?: string[];
|
|
30
|
+
run(input: CheckInput): Omit<StepResult, "id" | "title">;
|
|
31
|
+
}
|
|
32
|
+
/** Compare `a.b.c[-pre]` versions (a leading `v` and `+build` are ignored): negative when `a` is older than `b`. Null for text that isn't a version. */
|
|
33
|
+
export declare function compareVersions(a: string, b: string): number | null;
|
|
34
|
+
/** The checks, in the order they're reported. */
|
|
35
|
+
export declare const CHECK_STEPS: CheckStep[];
|
|
36
|
+
export interface CheckReport {
|
|
37
|
+
ok: boolean;
|
|
38
|
+
installed: string;
|
|
39
|
+
pinned: string | null;
|
|
40
|
+
steps: StepResult[];
|
|
41
|
+
}
|
|
42
|
+
/** Run every check. Reads the folder and its source files; writes nothing. */
|
|
43
|
+
export declare function runCheck(ont: Ontology, installed: string): Promise<CheckReport>;
|
package/dist/check.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { loadSourcePages, runChecks } from "./checks.js";
|
|
2
|
+
import { compareVersions as compareSemver } from "./release.js";
|
|
3
|
+
const open = (fs) => fs.filter((f) => !f.explainedBy);
|
|
4
|
+
const plural = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
|
|
5
|
+
/** Compare `a.b.c[-pre]` versions (a leading `v` and `+build` are ignored): negative when `a` is older than `b`. Null for text that isn't a version. */
|
|
6
|
+
export function compareVersions(a, b) {
|
|
7
|
+
const core = (v) => /^v?(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)(?:\+.*)?$/.exec(v.trim())?.[1];
|
|
8
|
+
const x = core(a), y = core(b);
|
|
9
|
+
return x && y ? compareSemver(x, y) : null;
|
|
10
|
+
}
|
|
11
|
+
const QUOTE_RULES = ["prov-quote-current"];
|
|
12
|
+
const VERIFY_RULES = ["prov-verified", "prov-cites-quote"];
|
|
13
|
+
/** The checks, in the order they're reported. */
|
|
14
|
+
export const CHECK_STEPS = [
|
|
15
|
+
{
|
|
16
|
+
id: "validate",
|
|
17
|
+
title: "Validation (okb validate --all)",
|
|
18
|
+
run({ findings }) {
|
|
19
|
+
const claimed = new Set(CHECK_STEPS.flatMap((s) => s.rules ?? []));
|
|
20
|
+
const mine = open(findings).filter((f) => !claimed.has(f.rule));
|
|
21
|
+
const errors = mine.filter((f) => f.severity === "error");
|
|
22
|
+
const warnings = mine.filter((f) => f.severity === "warning").length;
|
|
23
|
+
const tail = warnings ? ` (${plural(warnings, "warning")} ${warnings === 1 ? "doesn't" : "don't"} block a merge; okb validate --all lists them)` : "";
|
|
24
|
+
return errors.length
|
|
25
|
+
? { status: "fail", summary: `${plural(errors.length, "error")}${tail}`, problems: errors.map((f) => `${f.rule}: ${f.message}`) }
|
|
26
|
+
: { status: "pass", summary: `no errors${tail}`, problems: [] };
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "quotes",
|
|
31
|
+
title: "Quotes are still in their sources",
|
|
32
|
+
rules: QUOTE_RULES,
|
|
33
|
+
run({ ont, findings }) {
|
|
34
|
+
// A quote that can't be checked fails too: in CI a missing source file means the check proved nothing.
|
|
35
|
+
// A quote that only moved is still in its source (the validator reports it at info level), so it doesn't fail.
|
|
36
|
+
const found = open(findings).filter((f) => QUOTE_RULES.includes(f.rule));
|
|
37
|
+
const bad = found.filter((f) => f.severity !== "info");
|
|
38
|
+
const moved = found.length - bad.length;
|
|
39
|
+
const unchecked = ont.ofType("Source").filter((s) => !s.localPath && ont.sources(s.id, "PART_OF").some((i) => ont.get(i)?.type === "SourceLocation")).length;
|
|
40
|
+
const notes = [
|
|
41
|
+
unchecked ? `${plural(unchecked, "source")} with quotes has no localPath, so its quotes weren't checked` : "",
|
|
42
|
+
moved ? `${plural(moved, "quote")} moved; okb source refresh --all updates them` : "",
|
|
43
|
+
].filter(Boolean);
|
|
44
|
+
const note = notes.length ? ` (${notes.join("; ")})` : "";
|
|
45
|
+
return bad.length
|
|
46
|
+
? { status: "fail", summary: `${plural(bad.length, "quote")} can't be matched${note}`, problems: bad.map((f) => f.message) }
|
|
47
|
+
: { status: unchecked ? "warn" : "pass", summary: `every checked quote is still in its source${note}`, problems: [] };
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: "verification",
|
|
52
|
+
title: "Rules and extracted facts are verified",
|
|
53
|
+
rules: VERIFY_RULES,
|
|
54
|
+
run({ findings }) {
|
|
55
|
+
const bad = open(findings).filter((f) => VERIFY_RULES.includes(f.rule));
|
|
56
|
+
return bad.length
|
|
57
|
+
? { status: "fail", summary: `${plural(bad.length, "problem")}: something unverified, not supported by its quote, or without a quote`, problems: bad.map((f) => f.message) }
|
|
58
|
+
: { status: "pass", summary: "nothing is unverified, unsupported or waiting for approval", problems: [] };
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: "okb-version",
|
|
63
|
+
title: "okb version",
|
|
64
|
+
run({ ont, installed }) {
|
|
65
|
+
const pinned = ont.manifest.okbVersion;
|
|
66
|
+
if (!pinned)
|
|
67
|
+
return { status: "pass", summary: `installed ${installed}; the KB pins no version (okbVersion in okb.json)`, problems: [] };
|
|
68
|
+
const cmp = compareVersions(installed, pinned);
|
|
69
|
+
if (cmp === null)
|
|
70
|
+
return { status: "warn", summary: `okbVersion '${pinned}' in okb.json isn't a version like 1.2.3`, problems: [] };
|
|
71
|
+
return cmp < 0
|
|
72
|
+
? { status: "warn", summary: `installed ${installed} is older than the ${pinned} this KB pins; install ${pinned} or newer (npm i -g @ontology-kit/okb@${pinned})`, problems: [] }
|
|
73
|
+
: { status: "pass", summary: `installed ${installed}, pinned ${pinned}`, problems: [] };
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
/** Run every check. Reads the folder and its source files; writes nothing. */
|
|
78
|
+
export async function runCheck(ont, installed) {
|
|
79
|
+
const ctx = { pages: await loadSourcePages(ont) };
|
|
80
|
+
const { findings } = runChecks(ont, { all: true }, ctx);
|
|
81
|
+
const steps = CHECK_STEPS.map((s) => ({ id: s.id, title: s.title, ...s.run({ ont, findings, installed }) }));
|
|
82
|
+
return { ok: steps.every((s) => s.status !== "fail"), installed, pinned: ont.manifest.okbVersion ?? null, steps };
|
|
83
|
+
}
|
package/dist/checks.d.ts
CHANGED
package/dist/checks.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { existsSync } from "node:fs";
|
|
11
11
|
import { isAbsolute, join } from "node:path";
|
|
12
12
|
import { MetaKB } from "./metakb.js";
|
|
13
|
-
import { Ontology, VALUE_TYPES, DISPOSITIONS } from "@ontology-kit/
|
|
13
|
+
import { Ontology, VALUE_TYPES, DISPOSITIONS } from "@ontology-kit/reader";
|
|
14
14
|
import { isOneOf } from "./types.js";
|
|
15
15
|
import * as naming from "./naming.js";
|
|
16
16
|
import { findQuote, loadPages, normalize } from "./quotes.js";
|
|
@@ -80,7 +80,7 @@ export const CHECKS = {
|
|
|
80
80
|
continue;
|
|
81
81
|
}
|
|
82
82
|
if (seen.has(n.id))
|
|
83
|
-
hits.push({ message: `Two nodes share the id '${n.id}'.`, nodes: [n.id] });
|
|
83
|
+
hits.push({ message: `Two nodes share the id '${n.id}'. A git merge that kept both sides' version of a node is the likely cause; keep one and delete the other.`, nodes: [n.id] });
|
|
84
84
|
seen.add(n.id);
|
|
85
85
|
const nt = nodeTypes.get(n.type);
|
|
86
86
|
if (!nt) {
|
|
@@ -113,7 +113,7 @@ export const CHECKS = {
|
|
|
113
113
|
const a = ont.get(e.from);
|
|
114
114
|
const b = ont.get(e.to);
|
|
115
115
|
if (!a || !b)
|
|
116
|
-
hits.push({ message: `Edge ${tag} points at a node that doesn't exist (${!a ? e.from : e.to}).`, nodes: [a ? e.from : e.to] });
|
|
116
|
+
hits.push({ message: `Edge ${tag} points at a node that doesn't exist (${!a ? e.from : e.to}). A git merge where one branch deleted the node and another added this edge is the likely cause; remove the edge or restore the node.`, nodes: [a ? e.from : e.to] });
|
|
117
117
|
else if (!["Instance", "Class"].includes(a.type) || !["Instance", "Class"].includes(b.type) || (a.type === "Instance" && b.type === "Class")) {
|
|
118
118
|
hits.push({ message: `Relationship ${tag} connects ${a.type} → ${b.type}; relationships link instances (or state a fixed value on a class).`, nodes: [e.from, e.to] });
|
|
119
119
|
}
|
|
@@ -125,7 +125,7 @@ export const CHECKS = {
|
|
|
125
125
|
const a = ont.get(e.from);
|
|
126
126
|
const b = ont.get(e.to);
|
|
127
127
|
if (!a || !b) {
|
|
128
|
-
hits.push({ message: `Edge ${tag} points at a node that doesn't exist (${!a ? e.from : e.to}).`, nodes: [a ? e.from : e.to] });
|
|
128
|
+
hits.push({ message: `Edge ${tag} points at a node that doesn't exist (${!a ? e.from : e.to}). A git merge where one branch deleted the node and another added this edge is the likely cause; remove the edge or restore the node.`, nodes: [a ? e.from : e.to] });
|
|
129
129
|
continue;
|
|
130
130
|
}
|
|
131
131
|
// Instance misuse in the hierarchy gets its own friendlier rule (inst-are-leaves).
|