@ontology-kit/okb 0.2.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/dist/cli.js +11 -819
- package/dist/clidocs.d.ts +0 -2
- package/dist/clidocs.js +5 -27
- 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 -716
- package/dist/help.d.ts +11 -2
- package/dist/help.js +51 -64
- package/dist/release.d.ts +4 -0
- package/dist/release.js +22 -3
- package/dist/render.d.ts +61 -1
- package/dist/render.js +219 -1
- package/dist/runner.d.ts +3 -0
- package/dist/runner.js +79 -0
- package/dist/workflows.d.ts +256 -0
- package/dist/workflows.js +223 -0
- package/package.json +4 -3
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/** Reviewing and sharing: review questions, decisions, diagrams, exports and reference pages (step 8). */
|
|
2
|
+
import { opt } from "../command-table.js";
|
|
3
|
+
import {} from "@ontology-kit/reader";
|
|
4
|
+
import * as ops from "../ops.js";
|
|
5
|
+
import { buildReview } from "../review.js";
|
|
6
|
+
import { mermaid, renderDecisions, renderDiagramWritten, renderExportWritten, renderReview, renderWrote } from "../render.js";
|
|
7
|
+
import { docs, exportOntology, reviewData } from "../workflows.js";
|
|
8
|
+
const { str, strs, bool } = opt;
|
|
9
|
+
export const reviewing = [
|
|
10
|
+
{
|
|
11
|
+
name: "review",
|
|
12
|
+
group: "Reviewing and sharing",
|
|
13
|
+
summary: "questions only a person can judge",
|
|
14
|
+
description: "Turns the rules only a person can judge into questions about your ontology. The ontology-review skill uses it.",
|
|
15
|
+
forms: [
|
|
16
|
+
{
|
|
17
|
+
description: "Lists the questions for the steps you have reached.",
|
|
18
|
+
examples: ["okb review", "okb review --all --json"],
|
|
19
|
+
args: [
|
|
20
|
+
["--all", "flag", "Include every rule, not only the visible ones."],
|
|
21
|
+
["--json", "flag", "Print everything as JSON."],
|
|
22
|
+
],
|
|
23
|
+
options: { all: bool },
|
|
24
|
+
cheat: { example: "okb review", description: "Get questions only a person can judge" },
|
|
25
|
+
run: (ctx) => {
|
|
26
|
+
const ont = ctx.load();
|
|
27
|
+
const items = buildReview(ont, ctx.opts.all);
|
|
28
|
+
ctx.emit(() => reviewData(ont, items), () => renderReview(ont, items, ctx.opts.all));
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "decision",
|
|
35
|
+
group: "Reviewing and sharing",
|
|
36
|
+
summary: "record a design decision",
|
|
37
|
+
description: "Records a design decision, with the reason, so you and others can see why the ontology is the way it is.",
|
|
38
|
+
bare: "list",
|
|
39
|
+
forms: [
|
|
40
|
+
{
|
|
41
|
+
sub: "add",
|
|
42
|
+
description: "Records a decision. A decision can waive a rule, which turns that rule's warning into a note.",
|
|
43
|
+
examples: ["okb decision add --title \"Wines are not foods\" --decision \"Keep them separate\" --why \"Pairing needs both\""],
|
|
44
|
+
args: [
|
|
45
|
+
["--title", "text", "A short title."],
|
|
46
|
+
["--decision", "text", "What you decided."],
|
|
47
|
+
["--why", "text", "The reason."],
|
|
48
|
+
["--question", "text", "The question it answers."],
|
|
49
|
+
["--alt", "text", "An option you rejected. Repeat it for more."],
|
|
50
|
+
["--about", "name", "A class, slot or instance it concerns. Repeat it for more."],
|
|
51
|
+
["--waives", "rule key", "A rule it explains away. Repeat it for more."],
|
|
52
|
+
],
|
|
53
|
+
options: { title: str, decision: str, question: str, why: str, alt: strs, about: strs, waives: strs },
|
|
54
|
+
usage: 'Usage: okb decision add --title "..." --decision "..." --why "..." [--about X] [--waives rule-id]',
|
|
55
|
+
require: ["title", "decision"],
|
|
56
|
+
cheat: { example: "okb decision add --title \"...\" --decision \"...\" --why \"...\"", description: "Record a design decision" },
|
|
57
|
+
run: (ctx) => {
|
|
58
|
+
const o = ctx.opts;
|
|
59
|
+
ctx.mutate((ont) => ops.addDecision(ont, { title: o.title, decision: o.decision, question: o.question, rationale: o.why, alternatives: o.alt, about: o.about, waives: o.waives }));
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
sub: "list",
|
|
64
|
+
description: "Lists the decisions. Bare `okb decision` does the same.",
|
|
65
|
+
examples: ["okb decision list"],
|
|
66
|
+
args: [],
|
|
67
|
+
run: (ctx) => {
|
|
68
|
+
const ont = ctx.load();
|
|
69
|
+
const ds = ont.numbered("DesignDecision");
|
|
70
|
+
ctx.emit(() => ds, () => renderDecisions(ont, ds));
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "diagram",
|
|
77
|
+
group: "Reviewing and sharing",
|
|
78
|
+
summary: "draw the ontology as Mermaid",
|
|
79
|
+
description: "Draws the ontology as a Mermaid diagram you can open in GitHub or VS Code.",
|
|
80
|
+
forms: [
|
|
81
|
+
{
|
|
82
|
+
description: "Prints the diagram, or writes it to a file.",
|
|
83
|
+
examples: ["okb diagram --out diagram.md"],
|
|
84
|
+
args: [
|
|
85
|
+
["--out", "path", "Write the diagram here instead of printing it."],
|
|
86
|
+
],
|
|
87
|
+
options: { out: str },
|
|
88
|
+
cheat: { example: "okb diagram --out diagram.md", description: "Draw the ontology" },
|
|
89
|
+
run: (ctx) => {
|
|
90
|
+
const md = mermaid(ctx.load());
|
|
91
|
+
const { out } = ctx.opts;
|
|
92
|
+
if (out) {
|
|
93
|
+
ctx.write(out, md + "\n");
|
|
94
|
+
ctx.print(renderDiagramWritten(out));
|
|
95
|
+
}
|
|
96
|
+
else
|
|
97
|
+
ctx.print(md);
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: "export",
|
|
104
|
+
group: "Reviewing and sharing",
|
|
105
|
+
summary: "write JSON or openCypher",
|
|
106
|
+
description: "Writes the ontology as JSON or as openCypher, ready for Neo4j, Neptune or Memgraph. Instances become nodes labeled with their classes.",
|
|
107
|
+
forms: [
|
|
108
|
+
{
|
|
109
|
+
description: "Prints the export, or writes it to a file.",
|
|
110
|
+
examples: ["okb export --format cypher --out wine.cypher"],
|
|
111
|
+
args: [
|
|
112
|
+
["--format", "json or cypher", "The output format. Defaults to json."],
|
|
113
|
+
["--out", "path", "Write to this file instead of printing."],
|
|
114
|
+
["--with-schema", "flag", "Include classes and slots, not only instances."],
|
|
115
|
+
["--no-inherited", "flag", "Leave out values an instance inherits from its class."],
|
|
116
|
+
["--no-rules", "flag", "Leave out extracted rules."],
|
|
117
|
+
["--include-unverified", "flag", "Include rules and quotes that haven't been verified."],
|
|
118
|
+
],
|
|
119
|
+
options: { format: str, out: str, "with-schema": bool, "no-inherited": bool, "no-rules": bool, "include-unverified": bool },
|
|
120
|
+
cheat: { example: "okb export --format cypher --out wine.cypher", description: "Export for a graph database" },
|
|
121
|
+
run: (ctx) => {
|
|
122
|
+
const o = ctx.opts;
|
|
123
|
+
const { fmt, graph, text } = exportOntology(ctx.load(), { format: o.format, out: o.out, schema: o["with-schema"], noInherited: o["no-inherited"], noRules: o["no-rules"], includeUnverified: o["include-unverified"] });
|
|
124
|
+
if (o.out) {
|
|
125
|
+
ctx.write(o.out, text);
|
|
126
|
+
ctx.print(renderExportWritten(o.out, graph, fmt));
|
|
127
|
+
}
|
|
128
|
+
else
|
|
129
|
+
ctx.printRaw(text);
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "docs",
|
|
136
|
+
group: "Reviewing and sharing",
|
|
137
|
+
summary: "write Markdown reference pages",
|
|
138
|
+
description: "Writes Markdown reference pages for the ontology, so people can read its structure and rules without okb: an index, one page per class, a rules page and a sources page.",
|
|
139
|
+
forms: [
|
|
140
|
+
{
|
|
141
|
+
description: "Writes `index.md` (scope, competency questions, class tree, decisions), `classes/<id>.md` (slots with allowed values, inherited and own rules with their quotes, instances, decisions), `rules.md` and `sources.md`. Every rule links to its quote on the sources page. Items have stable anchors made from their ids (`rule.breve` becomes `#rule-breve`), links are relative, and the output has no dates, so you can commit it and check it for drift. It replaces pages an earlier run wrote and leaves other files alone. It never changes the ontology.",
|
|
142
|
+
examples: ["okb docs --out docs/kb"],
|
|
143
|
+
args: [
|
|
144
|
+
["--out", "folder", "Where to write the pages. Required; it is created if it doesn't exist."],
|
|
145
|
+
],
|
|
146
|
+
options: { out: str, changed: str, hops: str, context: bool },
|
|
147
|
+
usage: "Usage: okb docs --out <folder> · okb docs --out <folder> --changed <ref> [--hops N] · okb docs --out <folder> --context",
|
|
148
|
+
max: 0,
|
|
149
|
+
require: ["out"],
|
|
150
|
+
run: async (ctx) => {
|
|
151
|
+
const o = ctx.opts;
|
|
152
|
+
const r = await docs(ctx.dir, o.out, { changed: o.changed, hops: o.hops, context: o.context });
|
|
153
|
+
ctx.emit(() => ({ out: o.out, files: r.files, ...r.extra }), () => renderWrote(o.out, r.what, r.hint));
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
sub: "--changed",
|
|
158
|
+
description: "A review view of a change: only the pages whose text differs from `<ref>` (a git ref or a folder, the same as `okb diff`). A rule changed on a class changes the page of every subclass that inherits it, so those pages come with it. It also writes `changes.md`, which lists the changed pages and the stale-quote worklist from `okb source refresh --all --dry-run` (quotes that are gone or moved, and blocks that are new or changed, each with the nodes that cite them), because a source edit that hasn't been re-synced yet changes no page. Pages are the same text as the full render, so links to pages that aren't in the folder point into the full output. It only adds and overwrites files, so write it to a scratch folder, not to the committed pages. It never changes the ontology.",
|
|
159
|
+
examples: ["okb docs --out review --changed main", "okb docs --out review --changed v1.0.0 --hops 1"],
|
|
160
|
+
args: [
|
|
161
|
+
["--out", "folder", "Where to write the pages. Required."],
|
|
162
|
+
["--changed", "ref", "The git ref (or folder) to compare the working folder with."],
|
|
163
|
+
["--hops", "number", "Also write the class pages that link to or from a changed class page, this many links away. Default 0. It doesn't go through the index, rules or sources pages, which link to everything."],
|
|
164
|
+
],
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
sub: "--context",
|
|
168
|
+
description: "A review view of every rule beside the source text around its quote: the statement, modality, verification status, the verifier's note (when `okb verify --note` stored one), the original draft of a corrected rule, the quote, and the lines around it with the quoted lines marked. Rules that need a person come first (UNSUPPORTED, OVERREACH not yet approved, not verified, no quote, quote no longer in the source), then the rest by name. It reads the source files, so it needs them on disk. A source that isn't Markdown shows the quote alone. It writes `rules-in-context.md` and never changes the ontology.",
|
|
169
|
+
examples: ["okb docs --out review --context"],
|
|
170
|
+
args: [
|
|
171
|
+
["--out", "folder", "Where to write `rules-in-context.md`. Required."],
|
|
172
|
+
["--context", "flag", "Write the rules-in-context page instead of the reference pages. It doesn't combine with `--changed`."],
|
|
173
|
+
],
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
},
|
|
177
|
+
];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** Skills: install the Claude skills that ship with okb. */
|
|
2
|
+
import { opt } from "../command-table.js";
|
|
3
|
+
import { renderSkillsInstall, renderSkillsStatus } from "../render.js";
|
|
4
|
+
import { skillsInstallReport, skillsStatusReport } from "../workflows.js";
|
|
5
|
+
const { str, bool } = opt;
|
|
6
|
+
const SKILLS_USAGE = "Usage: okb skills install [--copy] [--dir <folder>] [--force] · okb skills status [--dir <folder>]";
|
|
7
|
+
export const skills = [
|
|
8
|
+
{
|
|
9
|
+
name: "skills",
|
|
10
|
+
group: "Skills",
|
|
11
|
+
summary: "install the Claude skills that ship with okb",
|
|
12
|
+
description: "Puts the skills that come with okb where Claude Code and Cursor load them from, and checks that they match this okb.",
|
|
13
|
+
usage: SKILLS_USAGE,
|
|
14
|
+
forms: [
|
|
15
|
+
{
|
|
16
|
+
sub: "install",
|
|
17
|
+
description: "Links the three skills into `~/.claude/skills/` (a link keeps them current when the package updates), or copies them. It replaces a link to an older okb, a broken link or an older copy. It refuses to touch a folder that is not one of okb's, and changes nothing if it refuses.",
|
|
18
|
+
examples: ["okb skills install", "okb skills install --copy", "okb skills install --dir ~/.cursor/skills"],
|
|
19
|
+
args: [
|
|
20
|
+
["--copy", "flag", "Copy the skill folders instead of linking to them. Run it again after you update okb."],
|
|
21
|
+
["--dir", "path", "The skills folder to use instead of `~/.claude/skills/`. The `OKB_SKILLS_DIR` environment variable sets it too."],
|
|
22
|
+
["--force", "flag", "Delete a folder or file that is not one of okb's skills (or a copy you edited) and put the skill in its place."],
|
|
23
|
+
],
|
|
24
|
+
options: { copy: bool, dir: str, force: bool },
|
|
25
|
+
usage: SKILLS_USAGE,
|
|
26
|
+
max: 0,
|
|
27
|
+
cheat: { example: "okb skills install", description: "Install the Claude skills that ship with okb" },
|
|
28
|
+
run: (ctx) => {
|
|
29
|
+
const { dir, lines } = skillsInstallReport({ dir: ctx.opts.dir, copy: ctx.opts.copy, force: ctx.opts.force });
|
|
30
|
+
ctx.emit(() => ({ dir, lines }), () => renderSkillsInstall(dir, lines));
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
sub: "status",
|
|
35
|
+
description: "Lists each skill with where it is installed and whether its version matches this okb. It exits with code 1 when any skill is missing or out of date.",
|
|
36
|
+
examples: ["okb skills status", "okb skills status --dir ~/.cursor/skills"],
|
|
37
|
+
args: [
|
|
38
|
+
["--dir", "path", "The skills folder to check instead of `~/.claude/skills/`."],
|
|
39
|
+
],
|
|
40
|
+
options: { dir: str },
|
|
41
|
+
usage: SKILLS_USAGE,
|
|
42
|
+
max: 0,
|
|
43
|
+
run: (ctx) => {
|
|
44
|
+
const r = skillsStatusReport({ dir: ctx.opts.dir });
|
|
45
|
+
ctx.emit(() => ({ dir: r.dir, metaKbVersion: r.metaVersion, skills: r.skills }), () => renderSkillsStatus(r.dir, r.metaVersion, r.skills));
|
|
46
|
+
if (!r.allCurrent)
|
|
47
|
+
ctx.exit(1);
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
];
|
package/dist/commands.d.ts
CHANGED
|
@@ -1,28 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* and
|
|
4
|
-
*
|
|
2
|
+
* Every `okb` command, as records (see `command-table.ts`): the one place a command is described,
|
|
3
|
+
* routed and run. `help.ts` and `clidocs.ts` render the help text and docs/CLI.md from this list.
|
|
4
|
+
* To add a command or a form, add a record to the file for its group in `src/commands/`.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/** One way to call a command (a subcommand such as `add`, or the bare command). */
|
|
9
|
-
export interface Form {
|
|
10
|
-
/** The subcommand word, if any: `add` for `okb cq add`. */
|
|
11
|
-
sub?: string;
|
|
12
|
-
description: string;
|
|
13
|
-
examples: string[];
|
|
14
|
-
args: Arg[];
|
|
15
|
-
}
|
|
16
|
-
export interface Command {
|
|
17
|
-
name: string;
|
|
18
|
-
/** The heading it appears under, by what you are trying to do. Commands appear in the order listed, so keep a group together. */
|
|
19
|
-
group: string;
|
|
20
|
-
description: string;
|
|
21
|
-
forms: Form[];
|
|
22
|
-
}
|
|
6
|
+
import type { Command } from "./command-table.js";
|
|
7
|
+
/** In the order the reference shows them: each group's commands stay together. */
|
|
23
8
|
export declare const COMMANDS: Command[];
|
|
24
|
-
/**
|
|
25
|
-
export declare const
|
|
9
|
+
/** Commands and forms that appear in the help text and docs/CLI.md. */
|
|
10
|
+
export declare const documented: (commands?: readonly Command[]) => Command[];
|
|
11
|
+
/** The cards on docs/CLI-CHEAT-SHEET.md: the forms that have a `cheat`, in record order. */
|
|
12
|
+
export declare function cheatSheet(commands?: readonly Command[]): {
|
|
26
13
|
example: string;
|
|
27
14
|
description: string;
|
|
15
|
+
command: Command;
|
|
28
16
|
}[];
|