@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
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** A stable anchor for a command or subcommand section: `cmd-class`, `cmd-class-add`. */
|
|
2
|
+
export declare const cmdAnchor: (cmd: string, sub?: string) => string;
|
|
3
|
+
export declare function renderCliDocs(): string;
|
|
4
|
+
export declare function renderCheatSheet(): string;
|
|
5
|
+
/** Flags the help text shows for a command that its reference entry doesn't document. */
|
|
6
|
+
export declare function undocumentedFlags(help: string): string[];
|
package/dist/clidocs.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders docs/CLI.md from the command reference in src/commands.ts. The help text
|
|
3
|
+
* (src/help.ts) stays the terminal summary; `undocumentedFlags` keeps the two from drifting.
|
|
4
|
+
*/
|
|
5
|
+
import { CHEAT_SHEET, COMMANDS } from "./commands.js";
|
|
6
|
+
/** A stable anchor for a command or subcommand section: `cmd-class`, `cmd-class-add`. */
|
|
7
|
+
export const cmdAnchor = (cmd, sub) => `cmd-${cmd}${sub ? `-${sub}` : ""}`;
|
|
8
|
+
const cell = (s) => s.replace(/\|/g, "\\|");
|
|
9
|
+
const GLOBAL_ARGS = [
|
|
10
|
+
["-C", "path", "The ontology folder. Defaults to the current folder."],
|
|
11
|
+
["--json", "flag", "Print machine-readable output, for commands that support it."],
|
|
12
|
+
];
|
|
13
|
+
function table(args) {
|
|
14
|
+
return ["| Argument | Type | Description |", "| --- | --- | --- |", ...args.map(([n, t, d]) => `| \`${cell(n)}\` | ${cell(t)} | ${cell(d)} |`), ""];
|
|
15
|
+
}
|
|
16
|
+
function form(cmd, f, lines) {
|
|
17
|
+
const level = f.sub ? "####" : "###";
|
|
18
|
+
if (f.sub)
|
|
19
|
+
lines.push(`<a id="${cmdAnchor(cmd.name, f.sub)}"></a>`, `#### okb ${cmd.name} ${f.sub}`, "", f.description, "");
|
|
20
|
+
lines.push("```bash", ...f.examples.map((e) => `$ ${e}`), "```", "");
|
|
21
|
+
if (f.args.length)
|
|
22
|
+
lines.push(`${level}# Arguments`, "", ...table(f.args));
|
|
23
|
+
}
|
|
24
|
+
/** Commands in `COMMANDS` order, grouped by their `group`, each group once. */
|
|
25
|
+
function groups() {
|
|
26
|
+
const out = new Map();
|
|
27
|
+
for (const c of COMMANDS)
|
|
28
|
+
out.set(c.group, [...(out.get(c.group) ?? []), c]);
|
|
29
|
+
return [...out];
|
|
30
|
+
}
|
|
31
|
+
export function renderCliDocs() {
|
|
32
|
+
const lines = [
|
|
33
|
+
"# CLI reference",
|
|
34
|
+
"",
|
|
35
|
+
"## Overview",
|
|
36
|
+
"",
|
|
37
|
+
"This page lists every `okb` command, grouped by what you are trying to do. Each entry shows what the command does, an example, and a table of its arguments. For the commands you will use most, see the [cheat sheet](CLI-CHEAT-SHEET.md). In your terminal, `okb help` prints a short summary.",
|
|
38
|
+
"",
|
|
39
|
+
"Angle brackets like `<name>` mark a required argument, and square brackets like `[name]` mark an optional one. Two options work with most commands:",
|
|
40
|
+
"",
|
|
41
|
+
...table(GLOBAL_ARGS),
|
|
42
|
+
"> **Tip:** When a class and a slot share a name, say which one you mean with `class:Genre` or `slot:genre`.",
|
|
43
|
+
"",
|
|
44
|
+
];
|
|
45
|
+
for (const [group, cmds] of groups()) {
|
|
46
|
+
lines.push(`## ${group}`, "");
|
|
47
|
+
for (const cmd of cmds) {
|
|
48
|
+
lines.push(`<a id="${cmdAnchor(cmd.name)}"></a>`, `### okb ${cmd.name}`, "", cmd.description, "");
|
|
49
|
+
for (const f of cmd.forms)
|
|
50
|
+
form(cmd, f, lines);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return lines.join("\n");
|
|
54
|
+
}
|
|
55
|
+
export function renderCheatSheet() {
|
|
56
|
+
const lines = [
|
|
57
|
+
"# CLI cheat sheet",
|
|
58
|
+
"",
|
|
59
|
+
"The `okb` commands you will use most, in the order you usually need them. For every command and argument, see the [full reference](CLI.md).",
|
|
60
|
+
"",
|
|
61
|
+
];
|
|
62
|
+
const rows = CHEAT_SHEET.map((c) => ({ ...c, group: COMMANDS.find((k) => k.name === c.example.split(" ")[1])?.group ?? "" }));
|
|
63
|
+
for (const [group] of groups()) {
|
|
64
|
+
const mine = rows.filter((r) => r.group === group);
|
|
65
|
+
if (!mine.length)
|
|
66
|
+
continue;
|
|
67
|
+
lines.push(`## ${group}`, "");
|
|
68
|
+
for (const r of mine)
|
|
69
|
+
lines.push('<div class="cheat-card">', "", `${r.description}:`, "", "```bash", r.example, "```", "", "</div>", "");
|
|
70
|
+
}
|
|
71
|
+
return lines.join("\n");
|
|
72
|
+
}
|
|
73
|
+
/** Flags the help text shows for a command that its reference entry doesn't document. */
|
|
74
|
+
export function undocumentedFlags(help) {
|
|
75
|
+
const missing = [];
|
|
76
|
+
const known = new Map(COMMANDS.map((c) => [c.name, new Set(c.forms.flatMap((f) => f.args.map((a) => a[0])))]));
|
|
77
|
+
for (const line of help.split("\n")) {
|
|
78
|
+
for (const piece of line.split(/\s+·\s+|\s{3,}(?=okb [a-z])/)) {
|
|
79
|
+
const m = piece.trim().match(/^okb ([a-z]+)/);
|
|
80
|
+
if (!m)
|
|
81
|
+
continue;
|
|
82
|
+
const doc = known.get(m[1]);
|
|
83
|
+
for (const [, flag] of piece.matchAll(/(?<![\w-])(--[a-z][a-z-]*)/g)) {
|
|
84
|
+
if (!doc?.has(flag) && !["--json", "--help"].includes(flag))
|
|
85
|
+
missing.push(`okb ${m[1]} ${flag}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return missing;
|
|
90
|
+
}
|
package/dist/clock.d.ts
ADDED
package/dist/clock.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Today's date for what okb records (an ontology's creation date, a design
|
|
3
|
+
* decision's date). SOURCE_DATE_EPOCH (seconds since 1970, the reproducible-builds
|
|
4
|
+
* convention) pins it, so generated output like examples/wine is the same on any
|
|
5
|
+
* day and in any time zone.
|
|
6
|
+
*/
|
|
7
|
+
import { OkbError } from "@ontology-kit/format";
|
|
8
|
+
/** YYYY-MM-DD, in UTC. */
|
|
9
|
+
export function today() {
|
|
10
|
+
const epoch = process.env.SOURCE_DATE_EPOCH;
|
|
11
|
+
if (epoch === undefined || epoch === "")
|
|
12
|
+
return new Date().toISOString().slice(0, 10);
|
|
13
|
+
if (!/^\d+$/.test(epoch))
|
|
14
|
+
throw new OkbError(`SOURCE_DATE_EPOCH must be whole seconds since 1970; got '${epoch}'.`);
|
|
15
|
+
return new Date(Number(epoch) * 1000).toISOString().slice(0, 10);
|
|
16
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
/** [name, value type, description] */
|
|
7
|
+
export type Arg = readonly [name: string, type: string, description: string];
|
|
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
|
+
}
|
|
23
|
+
export declare const COMMANDS: Command[];
|
|
24
|
+
/** The commands you need most, for the cheat sheet. Each example's command must exist above. */
|
|
25
|
+
export declare const CHEAT_SHEET: {
|
|
26
|
+
example: string;
|
|
27
|
+
description: string;
|
|
28
|
+
}[];
|