@ontology-kit/okb 0.0.0-stage → 0.1.0
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/LICENSE +9 -0
- package/README.md +26 -2
- package/bin/okb.js +8 -0
- package/dist/checks.d.ts +33 -0
- package/dist/checks.js +966 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +718 -0
- package/dist/clidocs.d.ts +6 -0
- package/dist/clidocs.js +90 -0
- package/dist/clock.d.ts +2 -0
- package/dist/clock.js +16 -0
- package/dist/commands.d.ts +28 -0
- package/dist/commands.js +622 -0
- package/dist/export.d.ts +54 -0
- package/dist/export.js +290 -0
- package/dist/families.d.ts +20 -0
- package/dist/families.js +51 -0
- package/dist/help.d.ts +2 -0
- package/dist/help.js +57 -0
- package/dist/markdown.d.ts +60 -0
- package/dist/markdown.js +310 -0
- package/dist/metakb.d.ts +164 -0
- package/dist/metakb.js +130 -0
- package/dist/naming.d.ts +20 -0
- package/dist/naming.js +140 -0
- package/dist/ops/admin.d.ts +16 -0
- package/dist/ops/admin.js +119 -0
- package/dist/ops/classes.d.ts +21 -0
- package/dist/ops/classes.js +105 -0
- package/dist/ops/common.d.ts +6 -0
- package/dist/ops/common.js +4 -0
- package/dist/ops/instances.d.ts +8 -0
- package/dist/ops/instances.js +70 -0
- package/dist/ops/links.d.ts +9 -0
- package/dist/ops/links.js +85 -0
- package/dist/ops/naming.d.ts +4 -0
- package/dist/ops/naming.js +70 -0
- package/dist/ops/scope.d.ts +29 -0
- package/dist/ops/scope.js +124 -0
- package/dist/ops/slots.d.ts +31 -0
- package/dist/ops/slots.js +186 -0
- package/dist/ops/values.d.ts +20 -0
- package/dist/ops/values.js +151 -0
- package/dist/ops.d.ts +14 -0
- package/dist/ops.js +14 -0
- package/dist/provenance.d.ts +53 -0
- package/dist/provenance.js +296 -0
- package/dist/quotes.d.ts +14 -0
- package/dist/quotes.js +104 -0
- package/dist/render.d.ts +30 -0
- package/dist/render.js +413 -0
- package/dist/review.d.ts +10 -0
- package/dist/review.js +145 -0
- package/dist/site.d.ts +6 -0
- package/dist/site.js +6 -0
- package/dist/skills.d.ts +52 -0
- package/dist/skills.js +120 -0
- package/dist/status.d.ts +18 -0
- package/dist/status.js +59 -0
- package/dist/types.d.ts +12 -0
- package/dist/types.js +5 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +7 -0
- package/meta-kb/data/edges.json +3172 -0
- package/meta-kb/data/manifest.json +19 -0
- package/meta-kb/data/nodes.json +3546 -0
- package/package.json +71 -3
- package/skills/build-domain-kb-from-docs/SKILL.md +87 -0
- package/skills/ontology-coach/SKILL.md +100 -0
- package/skills/ontology-review/SKILL.md +66 -0
package/package.json
CHANGED
|
@@ -1,6 +1,74 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ontology-kit/okb",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "A toolkit for building knowledge graphs with guardrails: a checked file format, rules from a meta-KB, provenance down to verbatim quotes, and skills that drive it.",
|
|
6
|
+
"homepage": "https://ontology-kit.dev",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/alanbsmith/ontology-kit.git",
|
|
10
|
+
"directory": "packages/okb"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/alanbsmith/ontology-kit/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"ontology",
|
|
17
|
+
"knowledge-graph",
|
|
18
|
+
"knowledge-base",
|
|
19
|
+
"provenance",
|
|
20
|
+
"validation",
|
|
21
|
+
"ontology-101",
|
|
22
|
+
"claude-skills",
|
|
23
|
+
"cli",
|
|
24
|
+
"okb"
|
|
25
|
+
],
|
|
26
|
+
"type": "module",
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"bin",
|
|
32
|
+
"dist",
|
|
33
|
+
"meta-kb/data",
|
|
34
|
+
"!meta-kb/README.md",
|
|
35
|
+
"skills",
|
|
36
|
+
"README.md",
|
|
37
|
+
"LICENSE"
|
|
38
|
+
],
|
|
39
|
+
"exports": {
|
|
40
|
+
"./bin": "./bin/okb.js",
|
|
41
|
+
"./cli": {
|
|
42
|
+
"development": "./src/cli.ts",
|
|
43
|
+
"default": "./dist/cli.js"
|
|
44
|
+
},
|
|
45
|
+
"./package.json": "./package.json"
|
|
46
|
+
},
|
|
47
|
+
"bin": {
|
|
48
|
+
"okb": "bin/okb.js"
|
|
49
|
+
},
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=24"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/node": "^26.6.6",
|
|
55
|
+
"typescript": "^5.9.0"
|
|
56
|
+
},
|
|
57
|
+
"optionalDependencies": {
|
|
58
|
+
"pdfjs-dist": "^6.3.289"
|
|
59
|
+
},
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"@ontology-kit/format": "0.1.0",
|
|
62
|
+
"yaml": "^2.8.0"
|
|
63
|
+
},
|
|
64
|
+
"scripts": {
|
|
65
|
+
"okb": "node src/cli.ts",
|
|
66
|
+
"build:meta": "node meta-kb/build.ts",
|
|
67
|
+
"verify:quotes": "node meta-kb/build.ts --pdf src.o101=../../sources/ontology101.pdf --pdf src.g93=../../sources/ontolingua-kaj-1993.pdf",
|
|
68
|
+
"docs": "node src/gendocs.ts",
|
|
69
|
+
"example": "node examples/build-wine.ts && node examples/build-espresso.ts",
|
|
70
|
+
"typecheck": "tsc",
|
|
71
|
+
"test": "node --test --test-concurrency=1 \"tests/*.test.ts\"",
|
|
72
|
+
"build": "pnpm --filter @ontology-kit/format run build && rm -rf dist && tsc -p tsconfig.build.json && node ../../scripts/rewrite-dts.ts"
|
|
73
|
+
}
|
|
6
74
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: build-domain-kb-from-docs
|
|
3
|
+
description: Use when extracting design-system (or other) documentation, usually markdown, into an LPG-based domain knowledge base under the meta-KB's governance rules (ontology-kit / okb format, quote-first extraction with an independent verification pass).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Build a domain KB from docs
|
|
7
|
+
|
|
8
|
+
**Version 2.4.2.** It should match the meta-KB version that `okb version` prints.
|
|
9
|
+
|
|
10
|
+
Turns a documentation source (usually a markdown component doc, sometimes a PDF) into an okb ontology: Class, Slot and Instance nodes plus domain Rule nodes, each tied to a verbatim quote with its heading path and line numbers. It follows the meta-KB's rules in `packages/okb/meta-kb/` and the pipeline in `docs/EXTRACTION-PIPELINE.md` (both in the ontology-kit repository, usually `~/Projects/ontology-kit`).
|
|
11
|
+
|
|
12
|
+
The point of this skill is to be deterministic where possible and to stop for human review everywhere else. Never auto-merge a finding this pipeline can't fully verify itself. Everything goes through okb commands; don't hand-edit nodes.json/edges.json.
|
|
13
|
+
|
|
14
|
+
## Step 0: Set up
|
|
15
|
+
|
|
16
|
+
1. Find okb: `okb version` (Node 24+; if it isn't installed, `npm install --global @ontology-kit/okb`, or from a clone of the repo `node <ontology-kit>/packages/okb/src/cli.ts`). Compare the meta-KB version it prints with this skill's version (top of this file). If they differ, tell the user that the skill or okb is out of date and offer to run `okb skills status`, then `okb skills install` to refresh the skills from this okb (the Installation page, <https://ontology-kit.dev/getting-started/installation/>, covers updating okb itself), before going on. The docs are readable as plain markdown: <https://ontology-kit.dev/llms.txt> lists every page with a one-line summary, and each page has a `.md` version.
|
|
17
|
+
2. The target ontology must exist and have a **scope and at least three competency questions** (`okb status`). If it doesn't, stop and do Step 1 of the method first, or hand off to the **ontology-coach** skill. Competency questions decide what's worth extracting; without them, extraction turns into copying the docs.
|
|
18
|
+
3. Load the modeling rules: `okb explain` (list), and `okb explain <rule-id>` for any you're unsure of. Don't invent structural rules beyond the meta-KB. If a modeling question isn't answered by a meta-KB rule or decision guide, raise it as an open question in the output rather than deciding silently.
|
|
19
|
+
4. Register the document, from a local copy (the markdown source, not the rendered website):
|
|
20
|
+
`okb source add <path/to/doc.md> --repo-url <GitHub URL of the file> [--url <rendered page URL>]`
|
|
21
|
+
Report any document problems it prints (for example malformed table rows) in your output. They're documentation bugs worth fixing at the source.
|
|
22
|
+
|
|
23
|
+
## Step 1: Extract (quote first, nothing else)
|
|
24
|
+
|
|
25
|
+
1. `okb source outline <source> --quotable --json` gives the worklist: every quotable block with its heading path, lines, kind (paragraph, list item, callout, table row, frontmatter) and whether it's already quoted. Code examples and HTML comments are excluded on purpose: examples show usage but don't state rules.
|
|
26
|
+
2. Work through the blocks in the sections your competency questions care about. For each candidate class, property, relationship, allowed value or rule, quote the **literal** text: `okb quote add <source> "<verbatim text>" [--line N]`.
|
|
27
|
+
- okb refuses text that isn't in the file (showing the closest real text) and asks for `--line` when the text appears in several places. Pick the occurrence in the section that's actually about the thing you're extracting (for example `DeleteButton > Props`, not `PrimaryButton > Props`).
|
|
28
|
+
- Quote from the prose. For a prop table, quote the row's description (the row's locator is `… > Props > row: <prop>`).
|
|
29
|
+
- Facts that exist only in code or generated output (types, defaults computed by code) must come from the component source, not from a code example in the doc.
|
|
30
|
+
3. If no single passage supports a candidate, create nothing for it. Dropping an unsupported candidate counts as success.
|
|
31
|
+
|
|
32
|
+
## Step 2: Draft (one claim per quote)
|
|
33
|
+
|
|
34
|
+
From each quote draft exactly one node, claiming no more than the quote supports, and link it with `--cites`:
|
|
35
|
+
|
|
36
|
+
- A kind of thing → `okb class add ...`, then `okb quote add ... --cites <Class>` (or add `--cites` when quoting).
|
|
37
|
+
- A property/prop/option → `okb property add` with facets; options become `--values`.
|
|
38
|
+
- A link between things (a component composes another, a token is used by a component) → `okb relationship add <name> --from <Class> --to <Class>`. Its values are stored as edges named after it (`composes` → `:COMPOSES`).
|
|
39
|
+
- A styling-only variant → work through `okb explain decision.class-or-value`. Usually an enumerated value, not a class.
|
|
40
|
+
- A requirement or recommendation → `okb rule add --statement "..." --modality <MUST|SHOULD|MAY|MUST_NOT|SHOULD_NOT> --governs <Class|slot> --cites <quote id>`.
|
|
41
|
+
- Add `--value slot=value` for qualifier slots declared with `okb slot add ... --on-rules` (for example `condition=open`); each rule states its own values, and nothing is inherited through `--refines`, and `--refines <broader rule> --adds "..."` when it narrows a broader rule.
|
|
42
|
+
- A quote shared by several nodes is added once; attach it to the others with `okb cite <node> <quote id>`.
|
|
43
|
+
- A fact about what one component does (not a requirement) is an Instance, not a Rule. Link it to the rule it meets with `okb fulfills <instance> <rule>`.
|
|
44
|
+
- A rule the owner wrote, not extracted, uses `--authored` and cites the owner's file. It's verified like any other rule.
|
|
45
|
+
- A conditional recommendation between two things ("use X instead of Y when …", typically under "When to Use Something Else") → the rule as above, **plus** a qualified link: declare the edge property once (`okb relationship property preferredOver condition --type String --required`), then `okb link X preferredOver Y condition="<the condition, in the quote's words>" --rule <rule id>`. The edge points at the rule rather than citing the quote again, so the fact has one citation chain and is verified through its rule.
|
|
46
|
+
- Permissive language ("consider", "can", "may") → SHOULD or MAY, never MUST / MUST NOT. okb warns when MUST is drafted from a quote without must/required/always/never.
|
|
47
|
+
- Every number, enum value or named entity in the draft must appear in the quote. Don't fill gaps from background knowledge, even when you're confident.
|
|
48
|
+
- One quote → one claim. Don't combine quotes at this step.
|
|
49
|
+
|
|
50
|
+
Note which meta-KB rule or decision guide drove any structural choice (for example in a design decision: `okb decision add ... --about <node>`).
|
|
51
|
+
|
|
52
|
+
## Step 3: Verify (a separate pass, not a self-check)
|
|
53
|
+
|
|
54
|
+
This step must not be skipped or merged into Step 2; `okb validate` blocks every extracted node that hasn't been verified. Use a **fresh context** (a separate subagent) given only the `{quote, statement}` pairs, from `okb rule list` and `okb quote list --json`. Don't give it the document or your Step 2 reasoning. Use exactly this prompt:
|
|
55
|
+
|
|
56
|
+
> You will be shown a QUOTE and a STATEMENT that claims to be derived from it. Do not use any outside knowledge of the subject matter. Judge only whether the STATEMENT follows from the QUOTE. Check specifically: (a) every number, enum value, or named entity in the STATEMENT appears in the QUOTE; (b) the modality (MUST/SHOULD/MAY/MUST NOT/SHOULD NOT) matches the QUOTE's actual strength of language; (c) the STATEMENT doesn't combine this quote with an assumption from elsewhere. Return SUPPORTED, OVERREACH (with a corrected statement), or UNSUPPORTED.
|
|
57
|
+
|
|
58
|
+
For Class and Slot nodes the "statement" is the node's `description` plus its facets (allowed values, cardinality, parent).
|
|
59
|
+
|
|
60
|
+
Record each result:
|
|
61
|
+
|
|
62
|
+
- `okb verify <node> --status SUPPORTED [--confidence verbatim|paraphrased]`
|
|
63
|
+
- `okb verify <node> --status OVERREACH --corrected "<narrower statement>"`: the original is kept in `_originalDraft`, and the node stays blocked until a person runs `okb verify <node> --approve`.
|
|
64
|
+
- `okb verify <node> --status UNSUPPORTED`, then `okb remove <node>`. It never ships.
|
|
65
|
+
|
|
66
|
+
## Step 4: Spot-check sources
|
|
67
|
+
|
|
68
|
+
For a random 10% of quotes (minimum 5), open their `sourceLink` (from `okb quote list --json`) and confirm the quote comes from the section it's about. This catches quotes taken from the wrong component's section, which Step 3 can't see.
|
|
69
|
+
|
|
70
|
+
## Step 5: Validate
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
okb validate --all
|
|
74
|
+
okb drift <this-ontology> <other-ontologies-from-the-same-doc-set> # optional, cross-KB copy-paste check
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Errors block the output, including `prov-verified` (unverified, UNSUPPORTED, or corrections not yet approved), `prov-cites-quote` and `prov-quote-current` (a quote no longer in the file). Warnings and hints aren't blocking, but they must be carried into the review diff, not silently dropped. When the source doc changes later, `okb source refresh <source>` re-locates every quote and reports the ones that are gone.
|
|
78
|
+
|
|
79
|
+
## Output
|
|
80
|
+
|
|
81
|
+
- The updated ontology folder.
|
|
82
|
+
- A review diff showing, for every new or changed node: `{quote, locator + sourceLink, statement/description, extractionConfidence, verification.status}` side by side, plus the validator's findings, document problems from `okb source add`, and any open modeling questions.
|
|
83
|
+
- Corrected items need a person's `okb verify --approve` before this goes into a PR. This pipeline's job is to make that review fast and well-informed, not to replace it. Then run the **ontology-review** skill for the judgment rules.
|
|
84
|
+
|
|
85
|
+
## What this doesn't cover
|
|
86
|
+
|
|
87
|
+
This catches drift between a quote and a statement (Step 3), structural errors the validator knows about (Step 5), and stale citations after a source is edited (`prov-quote-current`, `okb source refresh`). A quote taken from the wrong section is only partly covered: heading paths and `--line` disambiguation make it visible, and the Step 4 spot check samples for it, but neither is exhaustive. Facts that live only in code (types, computed defaults) are out of scope for doc extraction.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ontology-coach
|
|
3
|
+
description: Coach someone who has never built an ontology or knowledge base through building one from scratch, step by step, using the Ontology 101 method and the okb CLI from ontology-kit.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Ontology coach
|
|
7
|
+
|
|
8
|
+
**Version 2.4.2.** It should match the meta-KB version that `okb version` prints.
|
|
9
|
+
|
|
10
|
+
You are coaching a beginner through building an ontology with the **ontology-kit** toolkit. They have probably never built one. Your job is to make each decision small, explain each idea just before it's needed, do the typing for them, and leave behind an ontology that passes `okb validate` plus a record of _why_ it looks the way it does.
|
|
11
|
+
|
|
12
|
+
The toolkit's meta-KB is the authority on method, vocabulary and rules. **Don't teach from memory; teach from `okb`.** `okb explain <topic>` gives a plain-language explanation, a wine example and the exact quote from the paper for every concept, rule, step and decision guide.
|
|
13
|
+
|
|
14
|
+
## 0. Setup (every session)
|
|
15
|
+
|
|
16
|
+
1. **Find the toolkit.** Try `okb version`. If that fails, okb isn't installed: ask the user to run `npm install --global @ontology-kit/okb` (it needs Node 24+, check with `node --version`). Only if they are working from a clone of the repo, look for the `ontology-kit` folder (usually `~/Projects/ontology-kit`) and run okb as `node <kit>/packages/okb/src/cli.ts ...`; if that folder isn't reachable from this session, ask the user to connect it, and don't try to rebuild the toolkit. Compare the meta-KB version it prints with this skill's version (top of this file). If they differ, tell the user that the skill or okb is out of date and offer to run `okb skills status`, then `okb skills install` to refresh the skills from this okb (the Installation page, <https://ontology-kit.dev/getting-started/installation/>, covers updating okb itself), before going on. The docs are readable as plain markdown: <https://ontology-kit.dev/llms.txt> lists every page with a one-line summary, and each page has a `.md` version.
|
|
17
|
+
2. **Find or create their ontology.**
|
|
18
|
+
- Resuming: run `okb status` in their ontology folder and pick up where they are. Briefly recap their scope and the step they're on.
|
|
19
|
+
- New: ask what they want to model and what they'll use it for (one question), then `okb init <folder> --name "<Name>"`.
|
|
20
|
+
3. Run every command yourself and show the user the relevant part of the output. Don't make them type commands unless they ask to.
|
|
21
|
+
|
|
22
|
+
## How to coach
|
|
23
|
+
|
|
24
|
+
- **One step at a time, one decision at a time.** Ask at most two questions per message. Use multiple-choice questions (AskUserQuestion, when it's available) for choices with a small set of answers: naming style, class vs. value, disjoint or not.
|
|
25
|
+
- **Teach just in time.** Before asking a question that uses a new term (slot, facet, range, disjoint...), explain it in one or two sentences, drawing on `okb explain <term>`. Give the paper's wine example, then an example from _their_ domain.
|
|
26
|
+
- **Use their words.** Build names from how they describe things, then convert to the naming convention (okb suggests the conventional form when a name doesn't fit).
|
|
27
|
+
- **Let okb catch mistakes and turn them into lessons.** When a command is refused or `okb validate` reports something, explain the finding in your own words, show the rule (`okb explain <rule-id>`), and fix it together. Mistakes are the best moments to teach.
|
|
28
|
+
- **Record choices as you go.** Whenever the user picks between two reasonable options, or keeps something the validator warns about, run `okb decision add --title ... --decision ... --why ... --about <node> [--waives <rule-id>]`. Warnings can be explained this way; errors can't.
|
|
29
|
+
- **No single right answer.** When they worry about getting it "right", point to `okb explain principle.no-single-correct-model` and bring them back to their competency questions: "Which of these helps answer your questions?"
|
|
30
|
+
- **Engineers:** watch for object-oriented habits (grouping classes by shared behavior or code, "has-a" treated as "is-a"). Point to `okb explain principle.structure-not-behavior`.
|
|
31
|
+
- **Widen each question once it's answered.** A competency question is one example of a family. When one gets answered, offer its family once (see [Widening a question](#widening-a-question)). Never ask for the whole list up front.
|
|
32
|
+
- **Keep momentum.** Aim for a rough version that works end to end before polishing. Iterating is part of the method (`okb explain principle.iterate`).
|
|
33
|
+
|
|
34
|
+
## The steps
|
|
35
|
+
|
|
36
|
+
At the start of each step, run `okb step` and use its goal, questions, tips and wine example as your script. Don't paste the whole guide; turn it into a conversation. At the end of each step, run `okb validate`, resolve errors, discuss warnings, then `okb status` and `okb step next`.
|
|
37
|
+
|
|
38
|
+
### Step 1: Scope
|
|
39
|
+
|
|
40
|
+
Ask, one at a time: what's the domain (one sentence)? What will it be used for? Who will use and maintain it? What's related but out of scope? Then help them write **at least three competency questions**: specific questions the finished ontology must answer. Push for questions that involve relationships ("Which X go with Y?"), not only lookups. Three to five is plenty: tell them each question stands for a family of similar ones, and you'll help find the rest once there's something built to answer them.
|
|
41
|
+
`okb scope --domain ... --purpose ... --users ... --maintainers ... --out-of-scope ...` · `okb cq add "..."`
|
|
42
|
+
|
|
43
|
+
### Step 2: Reuse
|
|
44
|
+
|
|
45
|
+
Ask whether a standard vocabulary, industry taxonomy, internal glossary, spreadsheet or database schema already names these things. If they have one, look at it with them. Record what you find, or `okb reuse none --why "..."`. Keep it short.
|
|
46
|
+
|
|
47
|
+
### Step 3: Terms
|
|
48
|
+
|
|
49
|
+
Brainstorm terms freely: nouns, properties, relationships. Mine their competency questions for them. Tell them explicitly _not_ to worry yet about what's a class and what's a property. Aim for 15–40 terms. `okb term add ...`
|
|
50
|
+
|
|
51
|
+
### Step 4: Classes and hierarchy
|
|
52
|
+
|
|
53
|
+
1. Explain classes and "is a kind of" (`okb explain class`, `okb explain is-a`).
|
|
54
|
+
2. Pick a naming convention (`okb explain decision.naming`). The defaults are fine for most people: `okb convention`.
|
|
55
|
+
3. Ask whether they think top-down, bottom-up or from the middle (`okb explain decision.approach`).
|
|
56
|
+
4. Go through the term list: which terms name things that exist on their own? Add them with `okb class add ... --parent ... --desc "..."`. For **every** parent link, have them say "Every X is a Y" out loud (`decision.is-a`).
|
|
57
|
+
5. After creating siblings, ask whether anything can be both (`decision.disjoint`) → `okb class disjoint`.
|
|
58
|
+
6. Show `okb tree`, then stand back together: siblings at the same level of generality? A parent with only one child? More than a dozen children? `okb review` turns these into concrete questions about their classes.
|
|
59
|
+
7. Sort the terms: `okb term set <term> --as class|slot|instance|value|synonym|out-of-scope`.
|
|
60
|
+
|
|
61
|
+
### Step 5: Slots (properties and relationships)
|
|
62
|
+
|
|
63
|
+
Explain that the paper calls every attribute a _slot_, and that there are two kinds: **properties** hold a value (a name, a year, one of a fixed list) and **relationships** link to another thing (a wine's maker is a Winery). If they know graph databases: properties become node properties and relationships become edge types. Explain inheritance. For each remaining term, ask what kind of thing has it, then use `decision.slot-placement` to attach it to the most general class where _every_ member has it.
|
|
64
|
+
`okb property add <name> --on <Class> --type <Type> --desc "..."` · `okb relationship add <name> --from <Class> --to <Class> --desc "..."` · `okb show <Class>`
|
|
65
|
+
|
|
66
|
+
### Step 6: Facets
|
|
67
|
+
|
|
68
|
+
Go slot by slot, using the Step 6 questions: value type; allowed values or range (`decision.range`); one value or many; required? Then look for class-level facts (`okb class fix`), defaults (`okb class default`), restrictions on subclasses (`okb class restrict`) and inverse pairs (`okb relationship inverse`). Explain that an inverse pair is one relationship read from both ends, stored once. If a link needs information of its own (a condition, a strength), walk `okb explain decision.edge-or-class`, then `okb relationship property ...` and `okb link ...`. Explain clearly: **a default is a suggestion, a fixed value is a fact.**
|
|
69
|
+
|
|
70
|
+
### Step 7: Instances
|
|
71
|
+
|
|
72
|
+
Pick one competency question and add just enough instances to answer it end to end. Use the most specific class. When an instance doesn't fit, treat it as a finding about the model, not the data. Once it's answered, widen it (see below) before moving to the next question.
|
|
73
|
+
`okb instance add "<Name>" --of <Class> slot=value ...` · `okb instance set ...` (also `--of` to move it to another class)
|
|
74
|
+
|
|
75
|
+
### Step 8: Review and iterate
|
|
76
|
+
|
|
77
|
+
1. For each competency question, ask what answers it and link it: `okb cq link <n> <Class|slot>...`. A question with nothing to link means something is missing, so go back and add it. okb then suggests the question's family; widen it with the user (see below).
|
|
78
|
+
2. `okb validate --all`: fix errors; fix or explain warnings.
|
|
79
|
+
3. Run the **ontology-review** skill (or `okb review` yourself) for the judgment rules a script can't check.
|
|
80
|
+
4. Suggest showing the tree (`okb diagram --out diagram.md`) to someone who knows the domain.
|
|
81
|
+
5. If the data is headed for a graph database, show them `okb export --format cypher --out <name>.cypher` (instances become nodes labeled with their class chain).
|
|
82
|
+
6. Summarize what they built, what's deliberately left out, and what a v2 might add.
|
|
83
|
+
|
|
84
|
+
## Widening a question
|
|
85
|
+
|
|
86
|
+
A question like "When should I use a PrimaryButton?" is one example of a type. Answering only that one passes the competency test without being very useful. Once a question is answered (Step 7, or linked in Step 8), take a moment to widen it. Do this once per question, never all at once, and never before the model exists.
|
|
87
|
+
|
|
88
|
+
1. **Read the family from okb.** The `okb cq link` tip (or `okb review`, rule `scope-cq-families`) names what the ontology already has: sibling classes and other instances (the same question about similar things), and the subject's slots no question uses yet (more about the same thing).
|
|
89
|
+
2. **Offer three directions, briefly, in their words:** the same question about similar things ("…and SecondaryButton, TertiaryButton?"), more about the same subject ("its accessibility requirements? what it's preferred over?"), and follow-ups the answer raised. Use a multiple-choice question when AskUserQuestion is available, with "just this question" as a real option.
|
|
90
|
+
3. **Record every answer.** Wanted: `okb cq add "..."`, then build what it needs and `okb cq link`. Not wanted: `okb scope --out-of-scope "..."`. Staying narrow is a fine choice; it just shouldn't be an accident.
|
|
91
|
+
4. **Watch the size.** Adding questions adds work. If the list is growing faster than the model, say so and suggest parking questions for a v2 (out of scope for now) rather than stalling. The paper warns against trying to include everything (`okb explain scope-no-unneeded`).
|
|
92
|
+
|
|
93
|
+
## Don'ts
|
|
94
|
+
|
|
95
|
+
- Don't skip scope or competency questions. Every later decision leans on them.
|
|
96
|
+
- Don't make them list every possible question up front. A few examples are enough; widen each one once it's answered.
|
|
97
|
+
- Don't edit nodes.json/edges.json by hand. Use okb, which enforces naming, stores each relationship once, fills in defaults, and keeps ids stable.
|
|
98
|
+
- Don't add classes, slots or instances the user didn't agree to. Suggest them and let the user decide.
|
|
99
|
+
- Don't dump the glossary. Explain one idea at the moment it's needed.
|
|
100
|
+
- Don't `--force` a name or waive a warning without saying why and recording a decision.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ontology-review
|
|
3
|
+
description: Review an ontology built with ontology-kit (okb) against the Ontology 101 rules, especially the judgment rules a script can't check, and give plain-language, source-cited findings with exact okb fix commands.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Ontology review
|
|
7
|
+
|
|
8
|
+
**Version 2.4.2.** It should match the meta-KB version that `okb version` prints.
|
|
9
|
+
|
|
10
|
+
Give an okb ontology a second opinion. `okb validate` already covers the mechanical rules. The value of this review is in the rules **only a person can judge** (is this really a kind-of? are these siblings equally general? should this class be a slot value?) and in **double-checking heuristic findings**, which can be false positives. The reader may be a beginner, so every finding must be understandable without prior ontology knowledge.
|
|
11
|
+
|
|
12
|
+
## 1. Gather
|
|
13
|
+
|
|
14
|
+
1. Find okb: `okb version` (Node 24+; if it isn't installed, `npm install --global @ontology-kit/okb`, or from a clone of the repo `node <ontology-kit>/packages/okb/src/cli.ts`). Compare the meta-KB version it prints with this skill's version (top of this file). If they differ, tell the user that the skill or okb is out of date and offer to run `okb skills status`, then `okb skills install` to refresh the skills from this okb (the Installation page, <https://ontology-kit.dev/getting-started/installation/>, covers updating okb itself), before going on. The docs are readable as plain markdown: <https://ontology-kit.dev/llms.txt> lists every page with a one-line summary, and each page has a `.md` version.
|
|
15
|
+
2. In the ontology folder, collect:
|
|
16
|
+
- `okb status --json`: the step they're on and what's complete
|
|
17
|
+
- `okb validate --all --json`: mechanical and heuristic findings
|
|
18
|
+
- `okb review --all --json`: the judgment rules with their review questions, plus the class hierarchy, scope and design decisions
|
|
19
|
+
- `okb cq list --json`, `okb tree`, and `okb show <Class>` for any class you need to look at closely
|
|
20
|
+
3. Read the design decisions first. Anything already explained there is a closed question, unless the explanation itself looks wrong.
|
|
21
|
+
|
|
22
|
+
If this review is high-stakes (going into a shared repo or production), do steps 2–3 in a **separate subagent** that hasn't seen how the ontology was built, so the review isn't grading its own work. Pass it the JSON above and this skill's instructions.
|
|
23
|
+
|
|
24
|
+
## 2. Review
|
|
25
|
+
|
|
26
|
+
Work through each judgment rule from `okb review` against the actual ontology. Use the rule's `question`, and for anything non-obvious read the full rule and its source quote with `okb explain <rule-id>`. For each rule, either name specific nodes that violate it, with your reasoning, or say plainly that nothing does.
|
|
27
|
+
|
|
28
|
+
| Rule | What to look at |
|
|
29
|
+
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
30
|
+
| `hier-is-a-means-kind-of` | Every IS_A edge: "Every <child> is, by definition, a <parent>." Watch for part-of, made-by, role, "usually". |
|
|
31
|
+
| `hier-siblings-same-generality` | Each parent with 2+ children: is one child a kind of another? Would an expert put them on the same level? Is the parent mixing classification axes (region vs. grape variety)? |
|
|
32
|
+
| `hier-no-subclass-per-restriction` | Classes that only fix one slot value. Could they just be that value? |
|
|
33
|
+
| `hier-class-or-value` | Walk `okb explain decision.class-or-value` on suspicious classes _and_ on enumerated values that might deserve to be classes. |
|
|
34
|
+
| `hier-stable-membership` | Classes that instances would move in and out of (status, state, location). |
|
|
35
|
+
| `inst-natural-hierarchy-as-classes` | Instances that contain other instances in the domain. |
|
|
36
|
+
| `inst-granularity` | Are instances at the level of the things the competency questions ask about? |
|
|
37
|
+
| `slot-domain-fits-all` | For each slot, every class that inherits it: does each really have this property? |
|
|
38
|
+
| `reuse-considered` | Did they actually look for an existing vocabulary, standard or internal glossary? |
|
|
39
|
+
| `doc-record-decisions` | Multiple inheritance, terminological classes, --force'd names, deliberate omissions: is each recorded? |
|
|
40
|
+
|
|
41
|
+
Then double-check every **heuristic** finding from `okb validate`. Say whether it's a real problem or a false positive (for example "Sauternes" isn't a plural). A false positive should be recorded with `okb decision add ... --waives <rule-id>`.
|
|
42
|
+
|
|
43
|
+
Also check scope: does each competency question have what it needs (`scope-cq-coverage`)? Is there content no question needs (`scope-no-unneeded`)?
|
|
44
|
+
|
|
45
|
+
## 3. Report
|
|
46
|
+
|
|
47
|
+
Lead with a one-paragraph verdict: is it sound enough to use for its stated purpose, and what's the single most important fix?
|
|
48
|
+
|
|
49
|
+
Then group findings:
|
|
50
|
+
|
|
51
|
+
1. **Must fix**: violations of MUST rules (validator errors and judgment MUST rules).
|
|
52
|
+
2. **Should fix or explain**: SHOULD rules. For each, either a fix or a design decision to record.
|
|
53
|
+
3. **Worth considering**: hints and softer observations.
|
|
54
|
+
4. **Looks good**: what's well done, briefly and specifically.
|
|
55
|
+
|
|
56
|
+
Each finding has:
|
|
57
|
+
|
|
58
|
+
- **What** is wrong, naming the classes/slots involved, in plain words;
|
|
59
|
+
- **Why** it matters, in one sentence, with the rule id and source (for example `hier-siblings-same-generality`, Ontology 101 §4.2, p.14);
|
|
60
|
+
- **Fix**: the exact okb commands, or the `okb decision add ...` that records why it's fine as is.
|
|
61
|
+
|
|
62
|
+
Keep the number of findings proportionate: consolidate repeats ("these 6 classes add nothing to their parents") rather than listing each. Where the right answer depends on the user's intent, say so and ask; don't pick for them (`principle.no-single-correct-model`).
|
|
63
|
+
|
|
64
|
+
## 4. Apply (only with consent)
|
|
65
|
+
|
|
66
|
+
Don't change the ontology unless the user asks you to. When they do, run the fix commands one group at a time, re-run `okb validate --all` after each group, and record any decision they make with `okb decision add`.
|