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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/README.md +1 -1
  2. package/dist/check.d.ts +43 -0
  3. package/dist/check.js +102 -0
  4. package/dist/checks.d.ts +1 -1
  5. package/dist/checks.js +27 -4
  6. package/dist/cli.js +11 -705
  7. package/dist/clidocs.d.ts +0 -2
  8. package/dist/clidocs.js +5 -27
  9. package/dist/clock.js +1 -1
  10. package/dist/command-table.d.ts +144 -0
  11. package/dist/command-table.js +85 -0
  12. package/dist/commands/documents.d.ts +3 -0
  13. package/dist/commands/documents.js +250 -0
  14. package/dist/commands/getting-started.d.ts +3 -0
  15. package/dist/commands/getting-started.js +135 -0
  16. package/dist/commands/housekeeping.d.ts +3 -0
  17. package/dist/commands/housekeeping.js +203 -0
  18. package/dist/commands/modeling.d.ts +3 -0
  19. package/dist/commands/modeling.js +467 -0
  20. package/dist/commands/planning.d.ts +3 -0
  21. package/dist/commands/planning.js +251 -0
  22. package/dist/commands/reviewing.d.ts +3 -0
  23. package/dist/commands/reviewing.js +234 -0
  24. package/dist/commands/skills.d.ts +3 -0
  25. package/dist/commands/skills.js +53 -0
  26. package/dist/commands.d.ts +10 -22
  27. package/dist/commands.js +15 -622
  28. package/dist/cqanswer.d.ts +51 -0
  29. package/dist/cqanswer.js +76 -0
  30. package/dist/diff.d.ts +85 -0
  31. package/dist/diff.js +323 -0
  32. package/dist/export-changes.d.ts +40 -0
  33. package/dist/export-changes.js +115 -0
  34. package/dist/export-csv.d.ts +17 -0
  35. package/dist/export-csv.js +188 -0
  36. package/dist/export-eval-cases.d.ts +38 -0
  37. package/dist/export-eval-cases.js +40 -0
  38. package/dist/export.d.ts +34 -3
  39. package/dist/export.js +70 -12
  40. package/dist/families.d.ts +1 -1
  41. package/dist/families.js +1 -1
  42. package/dist/help.d.ts +11 -2
  43. package/dist/help.js +51 -57
  44. package/dist/kbdocs.d.ts +18 -0
  45. package/dist/kbdocs.js +393 -0
  46. package/dist/metakb.d.ts +1 -1
  47. package/dist/metakb.js +1 -1
  48. package/dist/naming.d.ts +2 -2
  49. package/dist/naming.js +2 -2
  50. package/dist/ontology-ref.d.ts +20 -0
  51. package/dist/ontology-ref.js +108 -0
  52. package/dist/ops/admin.d.ts +2 -2
  53. package/dist/ops/admin.js +26 -8
  54. package/dist/ops/classes.d.ts +1 -1
  55. package/dist/ops/classes.js +15 -7
  56. package/dist/ops/common.d.ts +12 -2
  57. package/dist/ops/common.js +3 -0
  58. package/dist/ops/instances.d.ts +2 -1
  59. package/dist/ops/instances.js +9 -3
  60. package/dist/ops/links.d.ts +2 -2
  61. package/dist/ops/links.js +3 -2
  62. package/dist/ops/naming.d.ts +1 -1
  63. package/dist/ops/naming.js +3 -1
  64. package/dist/ops/scope.d.ts +14 -3
  65. package/dist/ops/scope.js +38 -4
  66. package/dist/ops/slots.d.ts +1 -1
  67. package/dist/ops/slots.js +21 -8
  68. package/dist/ops/values.d.ts +1 -1
  69. package/dist/ops/values.js +5 -1
  70. package/dist/provenance.d.ts +5 -3
  71. package/dist/provenance.js +61 -19
  72. package/dist/release.d.ts +52 -0
  73. package/dist/release.js +337 -0
  74. package/dist/render.d.ts +88 -1
  75. package/dist/render.js +265 -3
  76. package/dist/resync.d.ts +98 -0
  77. package/dist/resync.js +234 -0
  78. package/dist/review.d.ts +1 -1
  79. package/dist/review.js +1 -1
  80. package/dist/reviewdocs.d.ts +42 -0
  81. package/dist/reviewdocs.js +263 -0
  82. package/dist/runner.d.ts +3 -0
  83. package/dist/runner.js +84 -0
  84. package/dist/skills.d.ts +19 -3
  85. package/dist/skills.js +130 -14
  86. package/dist/status.d.ts +1 -1
  87. package/dist/status.js +1 -1
  88. package/dist/types.d.ts +1 -1
  89. package/dist/types.js +1 -1
  90. package/dist/verifynote.d.ts +19 -0
  91. package/dist/verifynote.js +93 -0
  92. package/dist/workflows.d.ts +283 -0
  93. package/dist/workflows.js +270 -0
  94. package/meta-kb/data/edges.json +25 -0
  95. package/meta-kb/data/manifest.json +5 -5
  96. package/meta-kb/data/nodes.json +46 -9
  97. package/package.json +9 -4
  98. package/schema/edge.schema.json +68 -0
  99. package/schema/edges.schema.json +9 -0
  100. package/schema/node.schema.json +914 -0
  101. package/schema/nodes.schema.json +9 -0
  102. package/schema/okb.schema.json +41 -0
  103. package/skills/build-domain-kb-from-docs/SKILL.md +21 -3
  104. package/skills/ontology-coach/SKILL.md +8 -4
  105. package/skills/ontology-maintainer/SKILL.md +152 -0
  106. package/skills/ontology-review/SKILL.md +4 -2
  107. package/skills/ontology-signoff/SKILL.md +182 -0
  108. package/templates/okb-check.yml +148 -0
  109. package/templates/pull_request_template.md +16 -0
@@ -0,0 +1,467 @@
1
+ /** Modeling: conventions, classes, slots, links and instances (steps 4 to 7). */
2
+ import { NAME_DESC, opt, tri } from "../command-table.js";
3
+ import * as ops from "../ops.js";
4
+ import { renderConvention, show, tree } from "../render.js";
5
+ import { setInstance, showData } from "../workflows.js";
6
+ const { str, strs, bool } = opt;
7
+ /** The slot options both `slot add` and `slot set` take, as the op wants them. */
8
+ const slotOpts = (ctx) => {
9
+ const o = ctx.opts;
10
+ return {
11
+ on: o.on, off: o.off, type: o.type, values: o.values, range: o.range, addRange: o["add-range"], removeRange: o["remove-range"],
12
+ card: o.card, min: ctx.int("min"), max: ctx.int("max"), default: o.default, description: o.desc, force: o.force, onRules: o["on-rules"], offRules: o["off-rules"],
13
+ };
14
+ };
15
+ /** Every option `slot add`, `slot set` and their friendlier names (`property`, `relationship`) parse. */
16
+ const slotOptions = { on: strs, off: strs, type: str, values: strs, range: strs, "add-range": strs, "remove-range": strs, card: str, min: str, max: str, default: str, desc: str, force: bool, "on-rules": bool, "off-rules": bool };
17
+ /** `relationship` also takes `--from` and `--to`, which are the slot's `--on` and `--range`. */
18
+ const relationshipOptions = { ...slotOptions, from: strs, to: strs };
19
+ /** The values of two options that name the same thing, or undefined when neither was given. */
20
+ const either = (a, b) => (a || b ? [...(a ?? []), ...(b ?? [])] : undefined);
21
+ /** The slot options of a `relationship` form: `--from` is `--on`, `--to` is `--range`, and `add` always makes an Instance slot. */
22
+ const relationshipSlotOpts = (ctx, add) => ({
23
+ ...slotOpts(ctx),
24
+ on: either(ctx.opts.on, ctx.opts.from),
25
+ range: either(ctx.opts.range, ctx.opts.to),
26
+ ...(add ? { type: "Instance" } : {}),
27
+ });
28
+ export const modeling = [
29
+ {
30
+ name: "convention",
31
+ group: "Modeling",
32
+ summary: "set how names are written",
33
+ description: "Sets how names are written, so the validator can check them. With no flags it shows the current choices.",
34
+ forms: [
35
+ {
36
+ description: "Sets any of the options you pass.",
37
+ examples: ["okb convention --class-case PascalCase --slot-case camelCase --number singular"],
38
+ args: [
39
+ ["--class-case", "text", "Case for class names, such as PascalCase."],
40
+ ["--slot-case", "text", "Case for slot names, such as camelCase."],
41
+ ["--instance-case", "text", "Case for instance names."],
42
+ ["--number", "singular or plural", "Whether class names are singular or plural."],
43
+ ["--slot-affix", "text", "A prefix or suffix every slot name carries, if any."],
44
+ ],
45
+ options: { "class-case": str, "slot-case": str, "instance-case": str, number: str, "slot-affix": str },
46
+ run: (ctx) => {
47
+ const o = ctx.opts;
48
+ ctx.mutate((ont) => {
49
+ const notes = ops.setConventions(ont, { classCase: o["class-case"], slotCase: o["slot-case"], instanceCase: o["instance-case"], classNumber: o.number, slotAffix: o["slot-affix"] });
50
+ return [renderConvention(ont), ...notes];
51
+ });
52
+ },
53
+ },
54
+ ],
55
+ },
56
+ {
57
+ name: "class",
58
+ group: "Modeling",
59
+ summary: "create and change classes",
60
+ description: "Creates and changes classes, the kinds of things in your domain.",
61
+ forms: [
62
+ {
63
+ sub: "add",
64
+ description: "Adds a class.",
65
+ examples: ["okb class add RedWine --parent Wine --desc \"Wine made with dark grapes\""],
66
+ args: [
67
+ ["<Name>", "text", NAME_DESC],
68
+ ["--parent", "class", "A parent class. Repeat it for more."],
69
+ ["--desc", "text", "A one-line description."],
70
+ ["--synonym", "text", "Another name for it. Repeat it for more."],
71
+ ["--abstract", "flag", "Mark it as a grouping with no members of its own."],
72
+ ["--terminological", "flag", "Mark it as terminological."],
73
+ ["--force", "flag", "Add it even if the name breaks your convention."],
74
+ ],
75
+ options: { parent: strs, desc: str, synonym: strs, abstract: bool, terminological: bool, force: bool },
76
+ usage: "Usage: okb class add <Name> [--parent P] [--desc ...]",
77
+ min: 1,
78
+ cheat: { example: "okb class add RedWine --parent Wine", description: "Add a class" },
79
+ run: (ctx) => {
80
+ const o = ctx.opts;
81
+ ctx.mutate((ont) => ops.addClass(ont, ctx.args[0], { parents: o.parent, description: o.desc, synonyms: o.synonym, abstract: o.abstract, terminological: o.terminological, force: o.force }));
82
+ },
83
+ },
84
+ {
85
+ sub: "set",
86
+ description: "Changes a class.",
87
+ examples: ["okb class set RedWine --add-parent Beverage"],
88
+ args: [
89
+ ["<Class>", "class", "The class to change."],
90
+ ["--desc", "text", "New description."],
91
+ ["--add-parent", "class", "Add a parent."],
92
+ ["--remove-parent", "class", "Remove a parent."],
93
+ ["--synonym", "text", "Add a synonym."],
94
+ ["--abstract", "true or false", "Whether it is abstract."],
95
+ ["--terminological", "true or false", "Whether it is terminological."],
96
+ ],
97
+ options: { desc: str, "add-parent": strs, "remove-parent": strs, synonym: strs, abstract: str, terminological: str },
98
+ usage: "Usage: okb class set <Class> [--desc ...] [--add-parent P] [--remove-parent P] [--synonym S] [--abstract true|false]",
99
+ min: 1,
100
+ run: (ctx) => {
101
+ const o = ctx.opts;
102
+ ctx.mutate((ont) => ops.setClass(ont, ctx.args[0], { description: o.desc, addParents: o["add-parent"], removeParents: o["remove-parent"], synonyms: o.synonym, abstract: tri(o.abstract), terminological: tri(o.terminological) }));
103
+ },
104
+ },
105
+ {
106
+ sub: "disjoint",
107
+ description: "Says that no one thing can belong to more than one of these classes.",
108
+ examples: ["okb class disjoint RedWine WhiteWine RoseWine"],
109
+ args: [
110
+ ["<Class>...", "classes", "Two or more classes."],
111
+ ],
112
+ run: (ctx) => ctx.mutate((ont) => ops.disjoint(ont, ctx.args)),
113
+ },
114
+ {
115
+ sub: "fix",
116
+ description: "Gives every member of a class the same value for a slot.",
117
+ examples: ["okb class fix DessertWine sugar=sweet"],
118
+ args: [
119
+ ["<Class>", "class", "The class."],
120
+ ["<slot=value>...", "slot=value", "The values every member has."],
121
+ ],
122
+ usage: "Usage: okb class fix <Class> slot=value ...",
123
+ min: 2,
124
+ run: (ctx) => ctx.mutate((ont) => ops.assign(ont, ont.find(ctx.args[0], "Class").id, ctx.args.slice(1), "fixed")),
125
+ },
126
+ {
127
+ sub: "default",
128
+ description: "Gives a class a starting value for a slot that individual members can override.",
129
+ examples: ["okb class default Wine body=full"],
130
+ args: [
131
+ ["<Class>", "class", "The class."],
132
+ ["<slot=value>...", "slot=value", "The starting values."],
133
+ ],
134
+ usage: "Usage: okb class default <Class> slot=value ...",
135
+ min: 2,
136
+ run: (ctx) => ctx.mutate((ont) => ops.classDefault(ont, ctx.args[0], ctx.args.slice(1))),
137
+ },
138
+ {
139
+ sub: "restrict",
140
+ description: "Narrows a slot for one class: fewer values, a limit on how many, or a narrower range.",
141
+ examples: ["okb class restrict SingleVarietal grape --max 1"],
142
+ args: [
143
+ ["<Class>", "class", "The class."],
144
+ ["<slot>", "slot", "The slot to narrow."],
145
+ ["--values", "list", "Allowed values."],
146
+ ["--min", "number", "The fewest values allowed."],
147
+ ["--max", "number", "The most values allowed."],
148
+ ["--range", "class", "Allowed classes, for a relationship."],
149
+ ["--clear", "flag", "Remove the restriction."],
150
+ ],
151
+ options: { values: strs, min: str, max: str, range: strs, clear: bool },
152
+ usage: "Usage: okb class restrict <Class> <slot> [--values a,b] [--min N] [--max N] [--range C] [--clear]",
153
+ min: 2,
154
+ run: (ctx) => {
155
+ const o = ctx.opts;
156
+ ctx.mutate((ont) => ops.restrict(ont, ctx.args[0], ctx.args[1], { values: o.values, min: ctx.int("min"), max: ctx.int("max"), range: o.range, clear: o.clear }));
157
+ },
158
+ },
159
+ ],
160
+ },
161
+ {
162
+ name: "tree",
163
+ group: "Modeling",
164
+ summary: "show the class hierarchy",
165
+ description: "Prints the class hierarchy as an indented tree.",
166
+ forms: [
167
+ {
168
+ description: "Shows each class under its parents.",
169
+ examples: ["okb tree", "okb tree --instances"],
170
+ args: [
171
+ ["--instances", "flag", "Show instances under their classes."],
172
+ ],
173
+ options: { instances: bool },
174
+ cheat: { example: "okb tree", description: "See the class hierarchy" },
175
+ run: (ctx) => ctx.print(tree(ctx.load(), ctx.opts.instances)),
176
+ },
177
+ ],
178
+ },
179
+ {
180
+ name: "property",
181
+ group: "Modeling",
182
+ summary: "add a slot that holds a plain value",
183
+ 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`.",
184
+ usage: "Usage: okb property add|set|inverse ... (okb help)",
185
+ forms: [
186
+ {
187
+ sub: "add",
188
+ description: "Adds a property to a class.",
189
+ examples: ["okb property add body --on Wine --type Enumerated --values light,medium,full --card single"],
190
+ args: [
191
+ ["<name>", "text", NAME_DESC],
192
+ ["--on", "class", "The class it belongs to."],
193
+ ["--type", "String, Integer, Float, Boolean or Enumerated", "What kind of value it holds."],
194
+ ["--values", "list", "The allowed values, for Enumerated."],
195
+ ["--card", "single or multiple", "Whether it holds one value or several."],
196
+ ["--desc", "text", "A one-line description."],
197
+ ],
198
+ options: slotOptions,
199
+ usage: "Usage: okb slot add <name> --on <Class> --type <Type> [--card single|multiple] ...",
200
+ min: 1,
201
+ cheat: { example: "okb property add body --on Wine --type Enumerated --values light,full", description: "Add a plain-value slot" },
202
+ run: (ctx) => ctx.mutate((ont) => ops.addSlot(ont, ctx.args[0], slotOpts(ctx))),
203
+ },
204
+ {
205
+ sub: "set",
206
+ description: "Changes a property. It takes the flags `okb slot set` takes.",
207
+ examples: ["okb property set body --desc \"How heavy the wine feels\""],
208
+ args: [["<property>", "slot", "The property to change."]],
209
+ options: slotOptions,
210
+ usage: "Usage: okb slot set <slot> [--on C] [--type T] [--values a,b] [--range C] [--card single|multiple] ...",
211
+ min: 1,
212
+ run: (ctx) => ctx.mutate((ont) => ops.updateSlot(ont, ctx.args[0], slotOpts(ctx))),
213
+ },
214
+ {
215
+ sub: "inverse",
216
+ description: "Same as `okb slot inverse`: only relationships have inverses.",
217
+ examples: [],
218
+ args: [],
219
+ usage: "Usage: okb slot inverse <slotA> <slotB>",
220
+ min: 2,
221
+ max: 2,
222
+ hidden: true,
223
+ run: (ctx) => ctx.mutate((ont) => ops.inverse(ont, ctx.args[0], ctx.args[1])),
224
+ },
225
+ ],
226
+ },
227
+ {
228
+ name: "relationship",
229
+ group: "Modeling",
230
+ summary: "add a slot that links things",
231
+ 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`.",
232
+ usage: "Usage: okb relationship add|set|inverse|property ... (okb help)",
233
+ forms: [
234
+ {
235
+ sub: "add",
236
+ description: "Adds a relationship between two classes.",
237
+ examples: ["okb relationship add maker --from Wine --to Winery --card single"],
238
+ args: [
239
+ ["<name>", "text", NAME_DESC],
240
+ ["--from", "class", "The class the relationship starts at."],
241
+ ["--to", "class", "The class it points to."],
242
+ ["--card", "single or multiple", "Whether it holds one target or several."],
243
+ ],
244
+ options: relationshipOptions,
245
+ usage: "Usage: okb slot add <name> --on <Class> --type <Type> [--card single|multiple] ...",
246
+ min: 1,
247
+ cheat: { example: "okb relationship add maker --from Wine --to Winery", description: "Add a link between classes" },
248
+ run: (ctx) => ctx.mutate((ont) => ops.addSlot(ont, ctx.args[0], relationshipSlotOpts(ctx, true))),
249
+ },
250
+ {
251
+ sub: "set",
252
+ description: "Changes a relationship. It takes the flags `okb slot set` takes, and `--from` and `--to` name the classes.",
253
+ examples: ["okb relationship set maker --card single --min 1"],
254
+ args: [["<relationship>", "slot", "The relationship to change."]],
255
+ options: relationshipOptions,
256
+ usage: "Usage: okb slot set <slot> [--on C] [--type T] [--values a,b] [--range C] [--card single|multiple] ...",
257
+ min: 1,
258
+ run: (ctx) => ctx.mutate((ont) => ops.updateSlot(ont, ctx.args[0], relationshipSlotOpts(ctx, false))),
259
+ },
260
+ {
261
+ sub: "inverse",
262
+ description: "Declares that two relationships are the same link read from opposite ends.",
263
+ examples: ["okb relationship inverse maker produces"],
264
+ args: [
265
+ ["<slotA>", "slot", "The relationship that is stored."],
266
+ ["<slotB>", "slot", "Its inverse."],
267
+ ],
268
+ usage: "Usage: okb slot inverse <slotA> <slotB>",
269
+ min: 2,
270
+ max: 2,
271
+ run: (ctx) => ctx.mutate((ont) => ops.inverse(ont, ctx.args[0], ctx.args[1])),
272
+ },
273
+ {
274
+ sub: "property",
275
+ description: "Adds a property to a relationship itself, such as the condition under which one thing is preferred over another.",
276
+ examples: ["okb relationship property preferredOver condition --type String"],
277
+ args: [
278
+ ["<relationship>", "slot", "The relationship."],
279
+ ["<name>", "text", "The property's name."],
280
+ ["--type", "String, Integer, Float, Boolean or Enumerated", "What kind of value it holds."],
281
+ ["--values", "list", "The allowed values, for Enumerated."],
282
+ ["--required", "flag", "Every link must give it a value."],
283
+ ["--desc", "text", "A one-line description."],
284
+ ["--remove", "flag", "Remove the property."],
285
+ ],
286
+ options: { type: str, values: strs, required: bool, desc: str, remove: bool },
287
+ usage: "Usage: okb relationship property <relationship> <name> --type String|Integer|Float|Boolean|Enumerated [--values a,b] [--required] [--desc ...] [--remove]",
288
+ min: 2,
289
+ max: 2,
290
+ run: (ctx) => {
291
+ const o = ctx.opts;
292
+ ctx.mutate((ont) => ops.declareEdgeProperty(ont, ctx.args[0], ctx.args[1], { type: o.type, values: o.values, required: o.required, description: o.desc, remove: o.remove }));
293
+ },
294
+ },
295
+ ],
296
+ },
297
+ {
298
+ name: "slot",
299
+ group: "Modeling",
300
+ summary: "create and change slots",
301
+ description: "Creates and changes slots, the properties and relationships of a class. `okb property` and `okb relationship` are friendlier names for the same command.",
302
+ forms: [
303
+ {
304
+ sub: "add",
305
+ description: "Adds a slot to a class.",
306
+ examples: ["okb slot add body --on Wine --type Enumerated --values light,medium,full"],
307
+ args: [
308
+ ["<name>", "text", NAME_DESC],
309
+ ["--on", "class", "A class it belongs to. Repeat it for more."],
310
+ ["--type", "String, Integer, Float, Boolean, Enumerated or Instance", "What it holds. `Instance` makes it a relationship."],
311
+ ["--values", "list", "The allowed values, for Enumerated."],
312
+ ["--range", "class", "The class a relationship points to."],
313
+ ["--card", "single or multiple", "Whether it holds one value or several."],
314
+ ["--min", "number", "The fewest values allowed."],
315
+ ["--max", "number", "The most values allowed."],
316
+ ["--default", "text", "A starting value."],
317
+ ["--desc", "text", "A one-line description."],
318
+ ["--force", "flag", "Add it even if the name breaks your convention."],
319
+ ],
320
+ options: slotOptions,
321
+ usage: "Usage: okb slot add <name> --on <Class> --type <Type> [--card single|multiple] ...",
322
+ min: 1,
323
+ run: (ctx) => ctx.mutate((ont) => ops.addSlot(ont, ctx.args[0], slotOpts(ctx))),
324
+ },
325
+ {
326
+ sub: "set",
327
+ description: "Changes a slot. It takes every flag `add` takes, plus the ones below.",
328
+ examples: ["okb slot set maker --card single --min 1", "okb slot set body --off Beverage"],
329
+ args: [
330
+ ["<slot>", "slot", "The slot to change."],
331
+ ["--off", "class", "Take the slot off a class."],
332
+ ["--add-range", "class", "Add a class a relationship can point to."],
333
+ ["--remove-range", "class", "Remove one."],
334
+ ["--on-rules", "flag", "Let rules set this slot."],
335
+ ["--off-rules", "flag", "Stop rules setting this slot."],
336
+ ],
337
+ options: slotOptions,
338
+ usage: "Usage: okb slot set <slot> [--on C] [--type T] [--values a,b] [--range C] [--card single|multiple] ...",
339
+ min: 1,
340
+ cheat: { example: "okb slot set maker --card single --min 1", description: "Tighten a slot" },
341
+ run: (ctx) => ctx.mutate((ont) => ops.updateSlot(ont, ctx.args[0], slotOpts(ctx))),
342
+ },
343
+ {
344
+ sub: "inverse",
345
+ description: "Declares that two relationships are the same link read from opposite ends.",
346
+ examples: ["okb slot inverse maker produces"],
347
+ args: [
348
+ ["<slotA>", "slot", "The relationship that is stored."],
349
+ ["<slotB>", "slot", "Its inverse."],
350
+ ],
351
+ usage: "Usage: okb slot inverse <slotA> <slotB>",
352
+ min: 2,
353
+ max: 2,
354
+ run: (ctx) => ctx.mutate((ont) => ops.inverse(ont, ctx.args[0], ctx.args[1])),
355
+ },
356
+ ],
357
+ },
358
+ {
359
+ name: "show",
360
+ group: "Modeling",
361
+ summary: "everything about one class, slot or instance",
362
+ description: "Shows everything about one class, slot or instance: its parents, slots, values and links.",
363
+ forms: [
364
+ {
365
+ description: "With no name it shows the ontology itself.",
366
+ examples: ["okb show Wine", "okb show class:Genre"],
367
+ args: [
368
+ ["[name]", "text", "The thing to show. When a class and a slot share a name, write `class:Genre` or `slot:genre`."],
369
+ ],
370
+ cheat: { example: "okb show Wine", description: "See everything about one class, slot or instance" },
371
+ run: (ctx) => {
372
+ const ont = ctx.load();
373
+ const n = ont.find(ctx.args[0] ?? "ontology");
374
+ ctx.emit(() => showData(ont, n), () => show(ont, n));
375
+ },
376
+ },
377
+ ],
378
+ },
379
+ {
380
+ name: "link",
381
+ group: "Modeling",
382
+ summary: "connect two instances",
383
+ description: "Connects two instances (or an instance and a class) with a relationship.",
384
+ forms: [
385
+ {
386
+ description: "Adds one link. Values for the relationship's own properties go at the end.",
387
+ examples: ["okb link Radio preferredOver SegmentedControl condition=\"2 to 7 options\""],
388
+ args: [
389
+ ["<from>", "name", "Where the link starts."],
390
+ ["<relationship>", "slot", "The relationship."],
391
+ ["<to>", "name", "Where it ends."],
392
+ ["<name=value>...", "name=value", "Values for the relationship's own properties."],
393
+ ["--rule", "rule id", "The extracted rule this link comes from."],
394
+ ["--clear", "text", "Remove a property value from the link."],
395
+ ],
396
+ options: { rule: str, clear: strs },
397
+ usage: 'Usage: okb link <from> <relationship> <to> [name=value ...] [--rule <rule id>] [--clear name]',
398
+ min: 3,
399
+ cheat: { example: "okb link Radio preferredOver SegmentedControl", description: "Connect two instances" },
400
+ run: (ctx) => {
401
+ const [from, relationship, to, ...props] = ctx.args;
402
+ ctx.mutate((ont) => ops.link(ont, from, relationship, to, { props, rule: ctx.opts.rule, clear: ctx.opts.clear }));
403
+ },
404
+ },
405
+ ],
406
+ },
407
+ {
408
+ name: "unlink",
409
+ group: "Modeling",
410
+ summary: "remove a link",
411
+ description: "Removes a link.",
412
+ forms: [
413
+ {
414
+ description: "Removes one link.",
415
+ examples: ["okb unlink Radio preferredOver SegmentedControl"],
416
+ args: [
417
+ ["<from>", "name", "Where the link starts."],
418
+ ["<relationship>", "slot", "The relationship."],
419
+ ["<to>", "name", "Where it ends."],
420
+ ],
421
+ usage: "Usage: okb unlink <from> <relationship> <to>",
422
+ min: 3,
423
+ max: 3,
424
+ run: (ctx) => ctx.mutate((ont) => ops.unlink(ont, ctx.args[0], ctx.args[1], ctx.args[2])),
425
+ },
426
+ ],
427
+ },
428
+ {
429
+ name: "instance",
430
+ group: "Modeling",
431
+ summary: "add and change instances",
432
+ description: "Adds and changes instances, the individual things your classes describe.",
433
+ forms: [
434
+ {
435
+ sub: "add",
436
+ description: "Adds an instance and sets its values.",
437
+ examples: ["okb instance add \"Chateau Morgon Beaujolais\" --of Beaujolais body=light maker=\"Chateau Morgon\""],
438
+ args: [
439
+ ["<Name>", "text", "The instance's name. Quote it if it has spaces."],
440
+ ["--of", "class", "A class it belongs to. Repeat it for more."],
441
+ ["--desc", "text", "A one-line description."],
442
+ ["<slot=value>...", "slot=value", "Values for its slots."],
443
+ ],
444
+ options: { of: strs, desc: str },
445
+ usage: 'Usage: okb instance add "Name" --of <Class> [slot=value ...]',
446
+ min: 1,
447
+ cheat: { example: "okb instance add \"Chateau Morgon\" --of Beaujolais body=light", description: "Add an instance" },
448
+ run: (ctx) => ctx.mutate((ont) => ops.addInstance(ont, ctx.args[0], { of: ctx.opts.of, description: ctx.opts.desc, assignments: ctx.args.slice(1) })),
449
+ },
450
+ {
451
+ sub: "set",
452
+ description: "Changes an instance's values. Use `+=` to add a value, `-=` to remove one, and `slot=` to clear it.",
453
+ examples: ["okb instance set \"Chateau Morgon Beaujolais\" grape+=Gamay", "okb instance set \"Chateau Morgon Beaujolais\" --of Beaujolais"],
454
+ args: [
455
+ ["<Name>", "text", "The instance."],
456
+ ["<slot=value>...", "slot=value", "The changes."],
457
+ ["--of", "class", "Move it to another class."],
458
+ ["--desc", "text", "New description."],
459
+ ],
460
+ options: { of: strs, desc: str },
461
+ usage: 'Usage: okb instance set "Name" slot=value ... [--of <Class>]',
462
+ min: 1,
463
+ run: (ctx) => ctx.mutate((ont) => setInstance(ont, ctx.args[0], { of: ctx.opts.of, desc: ctx.opts.desc, assignments: ctx.args.slice(1) })),
464
+ },
465
+ ],
466
+ },
467
+ ];
@@ -0,0 +1,3 @@
1
+ /** Planning: scope, competency questions, reuse and terms (steps 1 to 3). */
2
+ import { type Command } from "../command-table.js";
3
+ export declare const planning: Command[];