@ontology-kit/okb 0.2.0 → 0.3.0-alpha.23

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/commands.js CHANGED
@@ -1,716 +1,15 @@
1
- /**
2
- * The command reference behind docs/CLI.md: what each `okb` command does, an example,
3
- * and its arguments. `tests/misc.test.ts` checks that every command in the dispatch table
4
- * is here and that every flag the help text shows for a command is documented.
5
- */
6
- const NAME_DESC = "The name, in the case your naming convention asks for.";
7
- export const COMMANDS = [
8
- {
9
- name: "init",
10
- group: "Getting started",
11
- description: "Creates a new ontology folder with the starting files and shows the guide for step 1.",
12
- forms: [{
13
- description: "Creates the folder, then tells you what to do first.",
14
- examples: ['okb init wine --name "Wine and Food"'],
15
- args: [["<folder>", "path", "Where to create the ontology."], ["--name", "text", "The ontology's name. Defaults to the folder name."]],
16
- }],
17
- },
18
- {
19
- name: "status",
20
- group: "Getting started",
21
- description: "Shows which step you are on, what is done, and what to do next.",
22
- forms: [{ description: "Prints every step with its checklist, plus a count of validator findings.", examples: ["okb status"], args: [] }],
23
- },
24
- {
25
- name: "step",
26
- group: "Getting started",
27
- description: "Moves between the eight steps and shows the guide for a step.",
28
- forms: [{
29
- description: "With no argument it shows the guide for your current step. With one, it moves you there.",
30
- examples: ["okb step", "okb step next", "okb step 4"],
31
- args: [["[n|next|prev]", "number or word", "The step to move to: 1 to 8, `next`, or `prev`. Moving on with a step unfinished is allowed."]],
32
- }],
33
- },
34
- {
35
- name: "explain",
36
- group: "Getting started",
37
- description: "Explains a concept, rule, step or decision guide in plain language.",
38
- forms: [{
39
- description: "With no argument it lists everything you can ask about.",
40
- examples: ["okb explain class", "okb explain 5", "okb explain --search inverse"],
41
- args: [["[topic]", "text", "A concept, rule key, step number or decision guide."], ["--search", "text", "Find entries that mention these words instead."]],
42
- }],
43
- },
44
- {
45
- name: "validate",
46
- group: "Getting started",
47
- description: "Checks your ontology against the rules. Errors make the command exit with code 1.",
48
- forms: [{
49
- description: "By default it shows errors, plus warnings and hints for the steps you have reached.",
50
- examples: ["okb validate", "okb validate --all --why"],
51
- args: [
52
- ["--all", "flag", "Include warnings and hints from steps you haven't reached."],
53
- ["--why", "flag", "Show why each rule exists."],
54
- ["--rule", "rule key", "Run only this rule. Repeat it for more."],
55
- ["--strict", "flag", "Also exit with code 1 on warnings."],
56
- ["--json", "flag", "Print the findings as JSON."],
57
- ],
58
- }],
59
- },
60
- {
61
- name: "scope",
62
- group: "Planning",
63
- description: "Records the domain, purpose, users and boundaries of the ontology. With no flags it shows what you have.",
64
- forms: [{
65
- description: "Sets any of the fields you pass and prints the result.",
66
- examples: ['okb scope --domain "Wine and food pairing" --purpose "Recommend wines for a meal" --users sommeliers,cooks'],
67
- args: [
68
- ["--domain", "text", "What the ontology covers."],
69
- ["--purpose", "text", "What it is for."],
70
- ["--users", "list", "Who will use it."],
71
- ["--maintainers", "list", "Who keeps it up to date."],
72
- ["--out-of-scope", "list", "What it deliberately leaves out."],
73
- ["--kind", "text", "The kind of ontology, such as a domain ontology."],
74
- ["--name", "text", "Rename the ontology."],
75
- ],
76
- }],
77
- },
78
- {
79
- name: "cq",
80
- group: "Planning",
81
- description: "Manages competency questions: the questions your ontology must be able to answer.",
82
- forms: [
83
- { sub: "add", description: "Adds one or more questions.", examples: ['okb cq add "Which wines go with fish?"'], args: [["<question>", "text", "The question. Quote it."]] },
84
- { sub: "list", description: "Lists the questions and what each one needs. Bare `okb cq` does the same.", examples: ["okb cq list"], args: [] },
85
- {
86
- sub: "link",
87
- description: "Says which classes, slots or instances a question needs. Use `unlink` to undo it.",
88
- examples: ["okb cq link 1 Wine Food goesWellWith"],
89
- args: [["<number>", "number", "The question's number."], ["<name>...", "names", "The classes, slots or instances it needs."]],
90
- },
91
- {
92
- sub: "set",
93
- description: "Changes a question's text or marks it answerable.",
94
- examples: ["okb cq set 1 --status answerable"],
95
- args: [["<number>", "number", "The question's number."], ["--text", "text", "New wording."], ["--status", "draft or answerable", "Whether the ontology can answer it yet."]],
96
- },
97
- { sub: "remove", description: "Deletes a question.", examples: ["okb cq remove 3"], args: [["<number>", "number", "The question's number."]] },
98
- ],
99
- },
100
- {
101
- name: "reuse",
102
- group: "Planning",
103
- description: "Records which existing ontologies you looked at and what you decided about each.",
104
- forms: [
105
- {
106
- sub: "add",
107
- description: "Records one ontology you considered.",
108
- examples: ["okb reuse add --name FOAF --url http://xmlns.com/foaf/spec/ --decision reference"],
109
- args: [
110
- ["--name", "text", "The ontology's name."],
111
- ["--decision", "reuse, adapt, reference or rejected", "What you decided."],
112
- ["--url", "url", "Where it lives."],
113
- ["--notes", "text", "Why."],
114
- ],
115
- },
116
- { sub: "none", description: "Records that you looked and found nothing that fits.", examples: ['okb reuse none --why "Checked schema.org and FOAF; neither covers wine."'], args: [["--why", "text", "What you looked at and why nothing fit."]] },
117
- { sub: "list", description: "Lists what you recorded. Bare `okb reuse` does the same.", examples: ["okb reuse list"], args: [] },
118
- ],
119
- },
120
- {
121
- name: "term",
122
- group: "Planning",
123
- description: "Collects the important words of your domain, then decides what each one becomes.",
124
- forms: [
125
- { sub: "add", description: "Adds terms to the list.", examples: ["okb term add wine grape winery color"], args: [["<term>...", "text", "One or more terms. Quote multi-word terms."], ["--note", "text", "A note to keep with them."]] },
126
- { sub: "list", description: "Lists terms grouped by what you decided. Bare `okb term` does the same.", examples: ["okb term list"], args: [] },
127
- {
128
- sub: "set",
129
- description: "Decides what a term becomes.",
130
- examples: ["okb term set wine --as class", "okb term set vintage --as synonym --node Year"],
131
- args: [
132
- ["<term>", "text", "The term."],
133
- ["--as", "class, slot, instance, value, synonym or out-of-scope", "What it becomes."],
134
- ["--node", "name", "The class, slot or instance it became or points to."],
135
- ["--note", "text", "A note about the decision."],
136
- ],
137
- },
138
- ],
139
- },
140
- {
141
- name: "convention",
142
- group: "Modeling",
143
- description: "Sets how names are written, so the validator can check them. With no flags it shows the current choices.",
144
- forms: [{
145
- description: "Sets any of the options you pass.",
146
- examples: ["okb convention --class-case PascalCase --slot-case camelCase --number singular"],
147
- args: [
148
- ["--class-case", "text", "Case for class names, such as PascalCase."],
149
- ["--slot-case", "text", "Case for slot names, such as camelCase."],
150
- ["--instance-case", "text", "Case for instance names."],
151
- ["--number", "singular or plural", "Whether class names are singular or plural."],
152
- ["--slot-affix", "text", "A prefix or suffix every slot name carries, if any."],
153
- ],
154
- }],
155
- },
156
- {
157
- name: "class",
158
- group: "Modeling",
159
- description: "Creates and changes classes, the kinds of things in your domain.",
160
- forms: [
161
- {
162
- sub: "add",
163
- description: "Adds a class.",
164
- examples: ['okb class add RedWine --parent Wine --desc "Wine made with dark grapes"'],
165
- args: [
166
- ["<Name>", "text", NAME_DESC],
167
- ["--parent", "class", "A parent class. Repeat it for more."],
168
- ["--desc", "text", "A one-line description."],
169
- ["--synonym", "text", "Another name for it. Repeat it for more."],
170
- ["--abstract", "flag", "Mark it as a grouping with no members of its own."],
171
- ["--terminological", "flag", "Mark it as terminological."],
172
- ["--force", "flag", "Add it even if the name breaks your convention."],
173
- ],
174
- },
175
- {
176
- sub: "set",
177
- description: "Changes a class.",
178
- examples: ["okb class set RedWine --add-parent Beverage"],
179
- args: [
180
- ["<Class>", "class", "The class to change."],
181
- ["--desc", "text", "New description."],
182
- ["--add-parent", "class", "Add a parent."],
183
- ["--remove-parent", "class", "Remove a parent."],
184
- ["--synonym", "text", "Add a synonym."],
185
- ["--abstract", "true or false", "Whether it is abstract."],
186
- ["--terminological", "true or false", "Whether it is terminological."],
187
- ],
188
- },
189
- { sub: "disjoint", description: "Says that no one thing can belong to more than one of these classes.", examples: ["okb class disjoint RedWine WhiteWine RoseWine"], args: [["<Class>...", "classes", "Two or more classes."]] },
190
- {
191
- sub: "fix",
192
- description: "Gives every member of a class the same value for a slot.",
193
- examples: ["okb class fix DessertWine sugar=sweet"],
194
- args: [["<Class>", "class", "The class."], ["<slot=value>...", "slot=value", "The values every member has."]],
195
- },
196
- {
197
- sub: "default",
198
- description: "Gives a class a starting value for a slot that individual members can override.",
199
- examples: ["okb class default Wine body=full"],
200
- args: [["<Class>", "class", "The class."], ["<slot=value>...", "slot=value", "The starting values."]],
201
- },
202
- {
203
- sub: "restrict",
204
- description: "Narrows a slot for one class: fewer values, a limit on how many, or a narrower range.",
205
- examples: ["okb class restrict SingleVarietal grape --max 1"],
206
- args: [
207
- ["<Class>", "class", "The class."],
208
- ["<slot>", "slot", "The slot to narrow."],
209
- ["--values", "list", "Allowed values."],
210
- ["--min", "number", "The fewest values allowed."],
211
- ["--max", "number", "The most values allowed."],
212
- ["--range", "class", "Allowed classes, for a relationship."],
213
- ["--clear", "flag", "Remove the restriction."],
214
- ],
215
- },
216
- ],
217
- },
218
- {
219
- name: "tree",
220
- group: "Modeling",
221
- description: "Prints the class hierarchy as an indented tree.",
222
- forms: [{ description: "Shows each class under its parents.", examples: ["okb tree", "okb tree --instances"], args: [["--instances", "flag", "Show instances under their classes."]] }],
223
- },
224
- {
225
- name: "property",
226
- group: "Modeling",
227
- description: "A slot that holds a plain value, such as a number, text or one of a fixed list. It takes the same subcommands as `okb slot`.",
228
- forms: [{
229
- sub: "add",
230
- description: "Adds a property to a class.",
231
- examples: ["okb property add body --on Wine --type Enumerated --values light,medium,full --card single"],
232
- args: [
233
- ["<name>", "text", NAME_DESC],
234
- ["--on", "class", "The class it belongs to."],
235
- ["--type", "String, Integer, Float, Boolean or Enumerated", "What kind of value it holds."],
236
- ["--values", "list", "The allowed values, for Enumerated."],
237
- ["--card", "single or multiple", "Whether it holds one value or several."],
238
- ["--desc", "text", "A one-line description."],
239
- ],
240
- }],
241
- },
242
- {
243
- name: "relationship",
244
- group: "Modeling",
245
- description: "A slot that links one thing to another, such as a wine to its winery. Okb stores it as edges, so `maker` becomes `:MAKER`.",
246
- forms: [
247
- {
248
- sub: "add",
249
- description: "Adds a relationship between two classes.",
250
- examples: ["okb relationship add maker --from Wine --to Winery --card single"],
251
- args: [
252
- ["<name>", "text", NAME_DESC],
253
- ["--from", "class", "The class the relationship starts at."],
254
- ["--to", "class", "The class it points to."],
255
- ["--card", "single or multiple", "Whether it holds one target or several."],
256
- ],
257
- },
258
- {
259
- sub: "inverse",
260
- description: "Declares that two relationships are the same link read from opposite ends.",
261
- examples: ["okb relationship inverse maker produces"],
262
- args: [["<slotA>", "slot", "The relationship that is stored."], ["<slotB>", "slot", "Its inverse."]],
263
- },
264
- {
265
- sub: "property",
266
- description: "Adds a property to a relationship itself, such as the condition under which one thing is preferred over another.",
267
- examples: ["okb relationship property preferredOver condition --type String"],
268
- args: [
269
- ["<relationship>", "slot", "The relationship."],
270
- ["<name>", "text", "The property's name."],
271
- ["--type", "String, Integer, Float, Boolean or Enumerated", "What kind of value it holds."],
272
- ["--values", "list", "The allowed values, for Enumerated."],
273
- ["--required", "flag", "Every link must give it a value."],
274
- ["--desc", "text", "A one-line description."],
275
- ["--remove", "flag", "Remove the property."],
276
- ],
277
- },
278
- ],
279
- },
280
- {
281
- name: "slot",
282
- group: "Modeling",
283
- description: "Creates and changes slots, the properties and relationships of a class. `okb property` and `okb relationship` are friendlier names for the same command.",
284
- forms: [
285
- {
286
- sub: "add",
287
- description: "Adds a slot to a class.",
288
- examples: ["okb slot add body --on Wine --type Enumerated --values light,medium,full"],
289
- args: [
290
- ["<name>", "text", NAME_DESC],
291
- ["--on", "class", "A class it belongs to. Repeat it for more."],
292
- ["--type", "String, Integer, Float, Boolean, Enumerated or Instance", "What it holds. `Instance` makes it a relationship."],
293
- ["--values", "list", "The allowed values, for Enumerated."],
294
- ["--range", "class", "The class a relationship points to."],
295
- ["--card", "single or multiple", "Whether it holds one value or several."],
296
- ["--min", "number", "The fewest values allowed."],
297
- ["--max", "number", "The most values allowed."],
298
- ["--default", "text", "A starting value."],
299
- ["--desc", "text", "A one-line description."],
300
- ["--force", "flag", "Add it even if the name breaks your convention."],
301
- ],
302
- },
303
- {
304
- sub: "set",
305
- description: "Changes a slot. It takes every flag `add` takes, plus the ones below.",
306
- examples: ["okb slot set maker --card single --min 1", "okb slot set body --off Beverage"],
307
- args: [
308
- ["<slot>", "slot", "The slot to change."],
309
- ["--off", "class", "Take the slot off a class."],
310
- ["--add-range", "class", "Add a class a relationship can point to."],
311
- ["--remove-range", "class", "Remove one."],
312
- ["--on-rules", "flag", "Let rules set this slot."],
313
- ["--off-rules", "flag", "Stop rules setting this slot."],
314
- ],
315
- },
316
- { sub: "inverse", description: "Declares that two relationships are the same link read from opposite ends.", examples: ["okb slot inverse maker produces"], args: [["<slotA>", "slot", "The relationship that is stored."], ["<slotB>", "slot", "Its inverse."]] },
317
- ],
318
- },
319
- {
320
- name: "show",
321
- group: "Modeling",
322
- description: "Shows everything about one class, slot or instance: its parents, slots, values and links.",
323
- forms: [{
324
- description: "With no name it shows the ontology itself.",
325
- examples: ["okb show Wine", "okb show class:Genre"],
326
- args: [["[name]", "text", "The thing to show. When a class and a slot share a name, write `class:Genre` or `slot:genre`."]],
327
- }],
328
- },
329
- {
330
- name: "link",
331
- group: "Modeling",
332
- description: "Connects two instances (or an instance and a class) with a relationship.",
333
- forms: [{
334
- description: "Adds one link. Values for the relationship's own properties go at the end.",
335
- examples: ['okb link Radio preferredOver SegmentedControl condition="2 to 7 options"'],
336
- args: [
337
- ["<from>", "name", "Where the link starts."],
338
- ["<relationship>", "slot", "The relationship."],
339
- ["<to>", "name", "Where it ends."],
340
- ["<name=value>...", "name=value", "Values for the relationship's own properties."],
341
- ["--rule", "rule id", "The extracted rule this link comes from."],
342
- ["--clear", "text", "Remove a property value from the link."],
343
- ],
344
- }],
345
- },
346
- {
347
- name: "unlink",
348
- group: "Modeling",
349
- description: "Removes a link.",
350
- forms: [{ description: "Removes one link.", examples: ["okb unlink Radio preferredOver SegmentedControl"], args: [["<from>", "name", "Where the link starts."], ["<relationship>", "slot", "The relationship."], ["<to>", "name", "Where it ends."]] }],
351
- },
352
- {
353
- name: "instance",
354
- group: "Modeling",
355
- description: "Adds and changes instances, the individual things your classes describe.",
356
- forms: [
357
- {
358
- sub: "add",
359
- description: "Adds an instance and sets its values.",
360
- examples: ['okb instance add "Chateau Morgon Beaujolais" --of Beaujolais body=light maker="Chateau Morgon"'],
361
- args: [
362
- ["<Name>", "text", "The instance's name. Quote it if it has spaces."],
363
- ["--of", "class", "A class it belongs to. Repeat it for more."],
364
- ["--desc", "text", "A one-line description."],
365
- ["<slot=value>...", "slot=value", "Values for its slots."],
366
- ],
367
- },
368
- {
369
- sub: "set",
370
- description: "Changes an instance's values. Use `+=` to add a value, `-=` to remove one, and `slot=` to clear it.",
371
- examples: ['okb instance set "Chateau Morgon Beaujolais" grape+=Gamay', 'okb instance set "Chateau Morgon Beaujolais" --of Beaujolais'],
372
- args: [
373
- ["<Name>", "text", "The instance."],
374
- ["<slot=value>...", "slot=value", "The changes."],
375
- ["--of", "class", "Move it to another class."],
376
- ["--desc", "text", "New description."],
377
- ],
378
- },
379
- ],
380
- },
381
- {
382
- name: "review",
383
- group: "Reviewing and sharing",
384
- description: "Turns the rules only a person can judge into questions about your ontology. The ontology-review skill uses it.",
385
- forms: [{ description: "Lists the questions for the steps you have reached.", examples: ["okb review", "okb review --all --json"], args: [["--all", "flag", "Include every rule, not only the visible ones."], ["--json", "flag", "Print everything as JSON."]] }],
386
- },
387
- {
388
- name: "decision",
389
- group: "Reviewing and sharing",
390
- description: "Records a design decision, with the reason, so you and others can see why the ontology is the way it is.",
391
- forms: [
392
- {
393
- sub: "add",
394
- description: "Records a decision. A decision can waive a rule, which turns that rule's warning into a note.",
395
- examples: ['okb decision add --title "Wines are not foods" --decision "Keep them separate" --why "Pairing needs both"'],
396
- args: [
397
- ["--title", "text", "A short title."],
398
- ["--decision", "text", "What you decided."],
399
- ["--why", "text", "The reason."],
400
- ["--question", "text", "The question it answers."],
401
- ["--alt", "text", "An option you rejected. Repeat it for more."],
402
- ["--about", "name", "A class, slot or instance it concerns. Repeat it for more."],
403
- ["--waives", "rule key", "A rule it explains away. Repeat it for more."],
404
- ],
405
- },
406
- { sub: "list", description: "Lists the decisions. Bare `okb decision` does the same.", examples: ["okb decision list"], args: [] },
407
- ],
408
- },
409
- {
410
- name: "diagram",
411
- group: "Reviewing and sharing",
412
- description: "Draws the ontology as a Mermaid diagram you can open in GitHub or VS Code.",
413
- forms: [{ description: "Prints the diagram, or writes it to a file.", examples: ["okb diagram --out diagram.md"], args: [["--out", "path", "Write the diagram here instead of printing it."]] }],
414
- },
415
- {
416
- name: "export",
417
- group: "Reviewing and sharing",
418
- description: "Writes the ontology as JSON or as openCypher, ready for Neo4j, Neptune or Memgraph. Instances become nodes labeled with their classes.",
419
- forms: [{
420
- description: "Prints the export, or writes it to a file.",
421
- examples: ["okb export --format cypher --out wine.cypher"],
422
- args: [
423
- ["--format", "json or cypher", "The output format. Defaults to json."],
424
- ["--out", "path", "Write to this file instead of printing."],
425
- ["--with-schema", "flag", "Include classes and slots, not only instances."],
426
- ["--no-inherited", "flag", "Leave out values an instance inherits from its class."],
427
- ["--no-rules", "flag", "Leave out extracted rules."],
428
- ["--include-unverified", "flag", "Include rules and quotes that haven't been verified."],
429
- ],
430
- }],
431
- },
432
- {
433
- name: "docs",
434
- group: "Reviewing and sharing",
435
- 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.",
436
- forms: [
437
- {
438
- 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.",
439
- examples: ["okb docs --out docs/kb"],
440
- args: [["--out", "folder", "Where to write the pages. Required; it is created if it doesn't exist."]],
441
- },
442
- {
443
- sub: "--changed",
444
- 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.",
445
- examples: ["okb docs --out review --changed main", "okb docs --out review --changed v1.0.0 --hops 1"],
446
- args: [
447
- ["--out", "folder", "Where to write the pages. Required."],
448
- ["--changed", "ref", "The git ref (or folder) to compare the working folder with."],
449
- ["--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."],
450
- ],
451
- },
452
- {
453
- sub: "--context",
454
- 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.",
455
- examples: ["okb docs --out review --context"],
456
- args: [
457
- ["--out", "folder", "Where to write `rules-in-context.md`. Required."],
458
- ["--context", "flag", "Write the rules-in-context page instead of the reference pages. It doesn't combine with `--changed`."],
459
- ],
460
- },
461
- ],
462
- },
463
- {
464
- name: "source",
465
- group: "Working from documents",
466
- description: "Registers documents you are extracting from, so quotes and rules can point back to them.",
467
- forms: [
468
- {
469
- sub: "add",
470
- description: "Registers a Markdown or PDF file.",
471
- examples: ["okb source add docs/button.md --repo-url https://github.com/acme/ds/blob/main/button.md"],
472
- args: [
473
- ["<file>", "path", "A Markdown or PDF file."],
474
- ["--title", "text", "A title."],
475
- ["--repo-url", "url", "The file's address on GitHub."],
476
- ["--url", "url", "The address of the rendered page."],
477
- ["--id", "text", "Your own id for it."],
478
- ],
479
- },
480
- {
481
- sub: "outline",
482
- description: "Lists every block of a Markdown source with its heading path and line numbers, and shows which are already quoted.",
483
- examples: ["okb source outline button --quotable"],
484
- args: [["<source>", "name", "The source."], ["--quotable", "flag", "Show only blocks you can quote."], ["--problems", "flag", "Show only problems in the document."]],
485
- },
486
- {
487
- sub: "refresh",
488
- description: "Checks quotes again after the document changes. With `--all` it checks every source, reports quotes that are gone (with the rules and facts that cite them) or moved, and lists the new, changed and removed blocks as a worklist. With `--all` it exits with code 1 when a quote is gone or a source can't be read (a single source only reports).",
489
- examples: ["okb source refresh button", "okb source refresh --all", "okb source refresh --all --json --dry-run"],
490
- args: [
491
- ["[<source>]", "name", "The source to check (leave it out with --all)."],
492
- ["--all", "flag", "Check every source and list the worklist of new, changed and removed blocks."],
493
- ["--dry-run", "flag", "With --all: write nothing, not even moved quotes."],
494
- ["--record", "flag", "With --all: store the current blocks as the baseline once the worklist is dealt with."],
495
- ["--strict", "flag", "With --all: also exit with code 1 when the worklist isn't empty."],
496
- ],
497
- },
498
- { sub: "list", description: "Lists the sources. Bare `okb source` does the same.", examples: ["okb source list"], args: [] },
499
- ],
500
- },
501
- {
502
- name: "quote",
503
- group: "Working from documents",
504
- description: "Records a verbatim passage from a source. Okb finds it in the document for you.",
505
- forms: [
506
- {
507
- sub: "add",
508
- description: "Records one quote.",
509
- examples: ['okb quote add button "Use a primary button for the main action." --cites Button'],
510
- args: [
511
- ["<source>", "name", "The source it comes from."],
512
- ["<text>", "text", "The passage, word for word."],
513
- ["--cites", "node", "A node the quote supports. Repeat it for more."],
514
- ["--line", "number", "A line to look near, if the text appears more than once."],
515
- ["--allow-code", "flag", "Allow a quote from a code block."],
516
- ],
517
- },
518
- { sub: "list", description: "Lists the quotes. Bare `okb quote` does the same.", examples: ["okb quote list"], args: [] },
519
- ],
520
- },
521
- {
522
- name: "rule",
523
- group: "Working from documents",
524
- description: "Records a rule a document states, tied to the quote that supports it.",
525
- forms: [
526
- {
527
- sub: "add",
528
- description: "Records one rule.",
529
- examples: ['okb rule add --statement "Buttons SHOULD have one primary per page." --modality SHOULD --governs Button --cites quote.1'],
530
- args: [
531
- ["--statement", "text", "The rule, in one sentence."],
532
- ["--modality", "MUST, SHOULD, MAY, MUST_NOT or SHOULD_NOT", "How strong the document makes it."],
533
- ["--cites", "quote id", "The quote that supports it. Repeat it for more."],
534
- ["--governs", "class or slot", "What it applies to. Repeat it for more."],
535
- ["--name", "text", "A short name."],
536
- ["--authored", "flag", "You wrote it; the document doesn't state it."],
537
- ["--value", "slot=value", "A value it sets. Repeat it for more."],
538
- ["--refines", "rule id", "A broader rule this one narrows."],
539
- ["--adds", "text", "What this rule adds to the one it refines."],
540
- ],
541
- },
542
- {
543
- sub: "refines",
544
- description: "Says that one rule narrows another.",
545
- examples: ['okb rule refines rule.2 rule.1 --adds "Only inside dialogs"'],
546
- args: [["<rule>", "rule id", "The narrower rule."], ["<broader rule>", "rule id", "The rule it narrows."], ["--adds", "text", "What it adds."], ["--remove", "flag", "Remove the link."]],
547
- },
548
- { sub: "list", description: "Lists the rules. Bare `okb rule` does the same.", examples: ["okb rule list"], args: [] },
549
- ],
550
- },
551
- {
552
- name: "fulfills",
553
- group: "Working from documents",
554
- description: "Says that an instance follows a rule.",
555
- forms: [{ description: "Links the instance to the rule.", examples: ["okb fulfills SaveButton rule.1"], args: [["<instance>", "name", "The instance."], ["<rule>", "rule id", "The rule."], ["--remove", "flag", "Remove the link."]] }],
556
- },
557
- {
558
- name: "cite",
559
- group: "Working from documents",
560
- description: "Attaches a quote you already recorded to another node.",
561
- forms: [{ description: "Links the quote to the node.", examples: ["okb cite Button quote.4"], args: [["<node>", "name", "The class, slot, instance or rule."], ["<quote id>", "quote id", "The quote. `okb quote list` shows them."]] }],
562
- },
563
- {
564
- name: "verify",
565
- group: "Working from documents",
566
- description: "Records the result of an independent check that a node matches what its quote says, or approves it.",
567
- forms: [{
568
- description: "Sets a verification status, or approves the node.",
569
- examples: ["okb verify rule.1 --status SUPPORTED", "okb verify rule.1 --approve"],
570
- args: [
571
- ["<node>", "name", "The node to verify."],
572
- ["--status", "SUPPORTED, OVERREACH or UNSUPPORTED", "What the check found."],
573
- ["--corrected", "text", "A corrected wording, for OVERREACH."],
574
- ["--confidence", "verbatim or paraphrased", "How closely the node follows the quote."],
575
- ["--note", "text", "One sentence on why: the word or number you changed, or the part of the statement the quote doesn't support. OVERREACH prints a suggestion."],
576
- ["--ref", "url", "An http or https link to the PR comment, issue or review thread where the reasoning happened."],
577
- ["--approve", "flag", "Approve it after review."],
578
- ],
579
- }],
580
- },
581
- {
582
- name: "skills",
583
- group: "Skills",
584
- description: "Puts the skills that come with okb where Claude Code and Cursor load them from, and checks that they match this okb.",
585
- forms: [
586
- {
587
- sub: "install",
588
- 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.",
589
- examples: ["okb skills install", "okb skills install --copy", "okb skills install --dir ~/.cursor/skills"],
590
- args: [
591
- ["--copy", "flag", "Copy the skill folders instead of linking to them. Run it again after you update okb."],
592
- ["--dir", "path", "The skills folder to use instead of `~/.claude/skills/`. The `OKB_SKILLS_DIR` environment variable sets it too."],
593
- ["--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."],
594
- ],
595
- },
596
- {
597
- sub: "status",
598
- 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.",
599
- examples: ["okb skills status", "okb skills status --dir ~/.cursor/skills"],
600
- args: [["--dir", "path", "The skills folder to check instead of `~/.claude/skills/`."]],
601
- },
602
- ],
603
- },
604
- {
605
- name: "rename",
606
- group: "Housekeeping",
607
- description: "Renames a class, slot or instance and updates everything that points to it.",
608
- forms: [{ description: "Renames one thing.", examples: ["okb rename Vino Wine"], args: [["<old name>", "name", "The current name."], ["<new name>", "text", "The new name."], ["--force", "flag", "Rename it even if the name breaks your convention."]] }],
609
- },
610
- {
611
- name: "remove",
612
- group: "Housekeeping",
613
- description: "Deletes a class, slot, instance, term or other node, with the edges that touch it.",
614
- forms: [{ description: "Deletes one thing.", examples: ["okb remove Vino", "okb remove genre --type Slot"], args: [["<name>", "name", "What to delete."], ["--type", "text", "Which kind, when a name is ambiguous: Class, Slot, Instance, Term and so on."]] }],
615
- },
616
- {
617
- name: "drift",
618
- group: "Housekeeping",
619
- description: "Compares quotes with the documents they came from and reports quotes that no longer match.",
620
- forms: [{ description: "Checks one or more ontology folders. With none it checks the current folder.", examples: ["okb drift .", "okb drift ../wine ../food"], args: [["[folder]...", "paths", "The ontology folders to check."]] }],
621
- },
622
- {
623
- name: "check",
624
- group: "Housekeeping",
625
- description: "Says whether a knowledge base is safe to merge: no validation errors, every quote still in its source, and nothing unverified, unsupported or waiting for approval. Exits non-zero when a check fails, so a CI job can gate on it.",
626
- forms: [{
627
- description: "Checks the current folder. It reads the folder and its source files and never changes them or takes the write lock. Warnings from `okb validate` don't block a merge. It also warns when the installed okb is older than the `okbVersion` the KB pins in okb.json.",
628
- examples: ["okb check", "okb check --json", "okb check -C ../wine"],
629
- args: [["--json", "flag", "Print the result as JSON: `ok`, the installed and pinned versions, and each check with its status, summary and problems."]],
630
- }],
631
- },
632
- {
633
- name: "pin",
634
- group: "Housekeeping",
635
- description: "Records the installed okb version in okb.json as `okbVersion`, so `okb check` warns anyone with an older okb and the CI workflow installs that version. Run it again after you upgrade okb.",
636
- forms: [{ description: "Pins the installed version.", examples: ["okb pin"], args: [] }],
637
- },
638
- {
639
- name: "diff",
640
- group: "Housekeeping",
641
- description: "Shows what changed in the knowledge between two versions of an ontology: added, removed, renamed and changed things, rules side by side, moved quotes and changed links, in words rather than JSON lines.",
642
- forms: [{
643
- description: "Each side is an ontology folder or a git ref. With one argument, the other side is the current folder, so `okb diff main` shows what this branch changes. It never modifies the folder or checks anything out. The output is Markdown, ready for a PR comment; createdAt and updatedAt changes are not reported.",
644
- examples: ["okb diff main", "okb diff v1.0 v1.1", "okb diff ../wine-old .", "okb diff main --json"],
645
- args: [
646
- ["<old>", "folder or git ref", "The earlier version. An existing folder is read as it is; anything else is a branch, tag or commit in the repository around the current folder. A name that is both is an error that shows both spellings (`./name` for the folder, `refs/heads/name` for the branch)."],
647
- ["[new]", "folder or git ref", "The later version. Defaults to the current folder."],
648
- ["--json", "flag", "Print the changes as JSON for other tools."],
649
- ],
650
- }],
651
- },
652
- {
653
- name: "release",
654
- group: "Housekeeping",
655
- description: "Cuts a numbered release of the knowledge base that other tools can pin: a manifest with the SHA-256 of every file and source, and a change log of what changed since the last release.",
656
- forms: [
657
- {
658
- description: "Writes `manifest.json` (the pin), `RELEASES.md` (every release's change log, newest first) and `releases/<version>/` (the files as released, plus `CHANGES.md` and `changes.json`), and records the version in `okb.json`. The change log is `okb diff` against the previous release's snapshot, so it lists renames with old and new names and renamed edge types. It stops, and writes nothing, if `okb validate` reports an error, if the version isn't newer than the last release, if a registered source file is missing or if nothing changed. Commit the files it writes.",
659
- examples: ["okb release 1.0.0", "okb release 1.1.0 --json"],
660
- args: [
661
- ["<version>", "semver", "The new version: `1.0.0`, `1.2.3` or `2.0.0-rc.1`. It must be higher than the version in `manifest.json`."],
662
- ["--json", "flag", "Print the version and the manifest as JSON."],
663
- ],
664
- },
665
- {
666
- sub: "verify",
667
- description: "Checks the files against `manifest.json`: every pinned file must exist and match its SHA-256, and `okb.json` must carry the manifest's version. It changes nothing. It exits 1 when something differs, so it can run in CI or before a server starts.",
668
- examples: ["okb release verify", "okb release verify -C ../wine --json"],
669
- args: [["--json", "flag", "Print the result as JSON."]],
670
- },
671
- ],
672
- },
673
- {
674
- name: "help",
675
- group: "Housekeeping",
676
- description: "Prints a one-screen summary of the commands. `okb --help` and `okb -h` do the same.",
677
- forms: [{ description: "Prints the summary.", examples: ["okb help"], args: [] }],
678
- },
679
- {
680
- name: "version",
681
- group: "Housekeeping",
682
- description: "Prints the okb version and the version of the rules it carries. `okb --version` does the same.",
683
- forms: [{ description: "Prints both versions.", examples: ["okb version"], args: [] }],
684
- },
685
- ];
686
- /** The commands you need most, for the cheat sheet. Each example's command must exist above. */
687
- export const CHEAT_SHEET = [
688
- { example: 'okb init wine --name "Wine and Food"', description: "Start a new ontology" },
689
- { example: "okb status", description: "See where you are and what to do next" },
690
- { example: "okb step next", description: "Move on to the next step" },
691
- { example: "okb explain class", description: "Learn what a term or rule means" },
692
- { example: "okb validate", description: "Check your ontology against the rules" },
693
- { example: 'okb scope --domain "..." --purpose "..."', description: "Record what the ontology is for" },
694
- { example: 'okb cq add "Which wines go with fish?"', description: "Add a competency question" },
695
- { example: 'okb reuse none --why "..."', description: "Record that nothing existing fits" },
696
- { example: "okb term add wine grape winery", description: "Collect the words of your domain" },
697
- { example: "okb class add RedWine --parent Wine", description: "Add a class" },
698
- { example: "okb tree", description: "See the class hierarchy" },
699
- { example: "okb property add body --on Wine --type Enumerated --values light,full", description: "Add a plain-value slot" },
700
- { example: "okb relationship add maker --from Wine --to Winery", description: "Add a link between classes" },
701
- { example: "okb slot set maker --card single --min 1", description: "Tighten a slot" },
702
- { example: "okb show Wine", description: "See everything about one class, slot or instance" },
703
- { example: 'okb instance add "Chateau Morgon" --of Beaujolais body=light', description: "Add an instance" },
704
- { example: "okb link Radio preferredOver SegmentedControl", description: "Connect two instances" },
705
- { example: "okb review", description: "Get questions only a person can judge" },
706
- { example: 'okb decision add --title "..." --decision "..." --why "..."', description: "Record a design decision" },
707
- { example: "okb diagram --out diagram.md", description: "Draw the ontology" },
708
- { example: "okb export --format cypher --out wine.cypher", description: "Export for a graph database" },
709
- { example: "okb source add docs/button.md", description: "Register a document to extract from" },
710
- { example: 'okb quote add button "verbatim text" --cites Button', description: "Record a quote" },
711
- { example: 'okb rule add --statement "..." --modality SHOULD --cites quote.1', description: "Record a rule a document states" },
712
- { example: "okb verify rule.1 --status SUPPORTED", description: "Record an independent check" },
713
- { example: "okb skills install", description: "Install the Claude skills that ship with okb" },
714
- { example: "okb rename Vino Wine", description: "Rename something everywhere" },
715
- { example: "okb remove Vino", description: "Delete something" },
716
- ];
1
+ import { documents } from "./commands/documents.js";
2
+ import { gettingStarted } from "./commands/getting-started.js";
3
+ import { housekeeping } from "./commands/housekeeping.js";
4
+ import { modeling } from "./commands/modeling.js";
5
+ import { planning } from "./commands/planning.js";
6
+ import { reviewing } from "./commands/reviewing.js";
7
+ import { skills } from "./commands/skills.js";
8
+ /** In the order the reference shows them: each group's commands stay together. */
9
+ export const COMMANDS = [...gettingStarted, ...planning, ...modeling, ...reviewing, ...documents, ...skills, ...housekeeping];
10
+ /** Commands and forms that appear in the help text and docs/CLI.md. */
11
+ export const documented = (commands = COMMANDS) => commands.filter((c) => !c.hidden);
12
+ /** The cards on docs/CLI-CHEAT-SHEET.md: the forms that have a `cheat`, in record order. */
13
+ export function cheatSheet(commands = COMMANDS) {
14
+ return commands.flatMap((command) => command.forms.flatMap((f) => (f.cheat ? [{ ...f.cheat, command }] : [])));
15
+ }