@ontology-kit/okb 0.2.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 (71) hide show
  1. package/dist/check.js +21 -2
  2. package/dist/checks.js +23 -0
  3. package/dist/cli.js +11 -819
  4. package/dist/clidocs.d.ts +0 -2
  5. package/dist/clidocs.js +5 -27
  6. package/dist/command-table.d.ts +144 -0
  7. package/dist/command-table.js +85 -0
  8. package/dist/commands/documents.d.ts +3 -0
  9. package/dist/commands/documents.js +250 -0
  10. package/dist/commands/getting-started.d.ts +3 -0
  11. package/dist/commands/getting-started.js +135 -0
  12. package/dist/commands/housekeeping.d.ts +3 -0
  13. package/dist/commands/housekeeping.js +203 -0
  14. package/dist/commands/modeling.d.ts +3 -0
  15. package/dist/commands/modeling.js +467 -0
  16. package/dist/commands/planning.d.ts +3 -0
  17. package/dist/commands/planning.js +251 -0
  18. package/dist/commands/reviewing.d.ts +3 -0
  19. package/dist/commands/reviewing.js +234 -0
  20. package/dist/commands/skills.d.ts +3 -0
  21. package/dist/commands/skills.js +53 -0
  22. package/dist/commands.d.ts +10 -22
  23. package/dist/commands.js +15 -716
  24. package/dist/cqanswer.d.ts +51 -0
  25. package/dist/cqanswer.js +76 -0
  26. package/dist/export-changes.d.ts +40 -0
  27. package/dist/export-changes.js +115 -0
  28. package/dist/export-csv.d.ts +17 -0
  29. package/dist/export-csv.js +188 -0
  30. package/dist/export-eval-cases.d.ts +38 -0
  31. package/dist/export-eval-cases.js +40 -0
  32. package/dist/export.d.ts +33 -2
  33. package/dist/export.js +69 -11
  34. package/dist/help.d.ts +11 -2
  35. package/dist/help.js +51 -64
  36. package/dist/ops/admin.d.ts +1 -1
  37. package/dist/ops/admin.js +2 -1
  38. package/dist/ops/classes.js +2 -2
  39. package/dist/ops/common.d.ts +12 -2
  40. package/dist/ops/common.js +3 -0
  41. package/dist/ops/instances.js +2 -2
  42. package/dist/ops/links.d.ts +1 -1
  43. package/dist/ops/links.js +2 -1
  44. package/dist/ops/scope.d.ts +9 -2
  45. package/dist/ops/scope.js +19 -3
  46. package/dist/ops/slots.js +6 -6
  47. package/dist/provenance.d.ts +1 -1
  48. package/dist/provenance.js +3 -2
  49. package/dist/release.d.ts +4 -0
  50. package/dist/release.js +22 -3
  51. package/dist/render.d.ts +85 -1
  52. package/dist/render.js +244 -1
  53. package/dist/runner.d.ts +3 -0
  54. package/dist/runner.js +84 -0
  55. package/dist/skills.d.ts +19 -3
  56. package/dist/skills.js +129 -13
  57. package/dist/verifynote.d.ts +4 -3
  58. package/dist/verifynote.js +3 -2
  59. package/dist/workflows.d.ts +283 -0
  60. package/dist/workflows.js +270 -0
  61. package/meta-kb/data/edges.json +25 -0
  62. package/meta-kb/data/manifest.json +4 -4
  63. package/meta-kb/data/nodes.json +39 -2
  64. package/package.json +4 -3
  65. package/schema/node.schema.json +22 -1
  66. package/skills/build-domain-kb-from-docs/SKILL.md +2 -2
  67. package/skills/ontology-coach/SKILL.md +3 -3
  68. package/skills/ontology-maintainer/SKILL.md +2 -2
  69. package/skills/ontology-review/SKILL.md +2 -2
  70. package/skills/ontology-signoff/SKILL.md +2 -2
  71. package/templates/okb-check.yml +17 -1
package/dist/check.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { loadSourcePages, runChecks } from "./checks.js";
2
+ import { checkQuestions, describeResult } from "./cqanswer.js";
2
3
  import { compareVersions as compareSemver } from "./release.js";
3
4
  const open = (fs) => fs.filter((f) => !f.explainedBy);
4
5
  const plural = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
@@ -8,6 +9,7 @@ export function compareVersions(a, b) {
8
9
  const x = core(a), y = core(b);
9
10
  return x && y ? compareSemver(x, y) : null;
10
11
  }
12
+ const SAVE_LEFTOVERS_RULE = "struct-no-save-leftovers";
11
13
  const QUOTE_RULES = ["prov-quote-current"];
12
14
  const VERIFY_RULES = ["prov-verified", "prov-cites-quote"];
13
15
  /** The checks, in the order they're reported. */
@@ -21,9 +23,13 @@ export const CHECK_STEPS = [
21
23
  const errors = mine.filter((f) => f.severity === "error");
22
24
  const warnings = mine.filter((f) => f.severity === "warning").length;
23
25
  const tail = warnings ? ` (${plural(warnings, "warning")} ${warnings === 1 ? "doesn't" : "don't"} block a merge; okb validate --all lists them)` : "";
26
+ // Leftovers of an interrupted save say the files may not belong together, which the other warnings don't, so show them here.
27
+ const torn = mine.filter((f) => f.rule === SAVE_LEFTOVERS_RULE);
24
28
  return errors.length
25
- ? { status: "fail", summary: `${plural(errors.length, "error")}${tail}`, problems: errors.map((f) => `${f.rule}: ${f.message}`) }
26
- : { status: "pass", summary: `no errors${tail}`, problems: [] };
29
+ ? { status: "fail", summary: `${plural(errors.length, "error")}${tail}`, problems: [...errors, ...torn].map((f) => `${f.rule}: ${f.message}`) }
30
+ : torn.length
31
+ ? { status: "warn", summary: `no errors, but a save was cut short${tail}`, problems: torn.map((f) => `${f.rule}: ${f.message}`) }
32
+ : { status: "pass", summary: `no errors${tail}`, problems: [] };
27
33
  },
28
34
  },
29
35
  {
@@ -58,6 +64,19 @@ export const CHECK_STEPS = [
58
64
  : { status: "pass", summary: "nothing is unverified, unsupported or waiting for approval", problems: [] };
59
65
  },
60
66
  },
67
+ {
68
+ id: "competency-questions",
69
+ title: "Competency questions are still answered (okb cq check)",
70
+ run({ ont }) {
71
+ const results = checkQuestions(ont);
72
+ const failed = results.filter((r) => r.status === "fail");
73
+ const none = results.filter((r) => r.status === "none").length;
74
+ const tail = none ? ` (${plural(none, "question")} with no answer stored)` : "";
75
+ return failed.length
76
+ ? { status: "fail", summary: `${plural(failed.length, "question")} no longer get the expected answer${tail}`, problems: failed.map(describeResult) }
77
+ : { status: "pass", summary: `${results.length - none} of ${plural(results.length, "question")} get the expected answer${tail}`, problems: [] };
78
+ },
79
+ },
61
80
  {
62
81
  id: "okb-version",
63
82
  title: "okb version",
package/dist/checks.js CHANGED
@@ -68,8 +68,27 @@ const pipeline = (n) => n;
68
68
  function isTerminological(ont, c) {
69
69
  return Boolean(c.terminological) || ont.meta.kind === "terminological";
70
70
  }
71
+ /** The files a save leaves behind when it is cut short (see decision 0033). */
72
+ const SAVE_LEFTOVERS = [".okb.saving.tmp", "okb.json.tmp", "nodes.jsonl.tmp", "edges.jsonl.tmp"];
71
73
  export const CHECKS = {
72
74
  // Structure
75
+ // Reads the folder, not the graph. A load finishes a marked save, so this sees a marker only when a save began after
76
+ // the load (a command running now, which finishes it) and temp files with no marker (an older okb's save, or a
77
+ // save killed before its marker). An in-memory ontology has no okb.json on disk, so it has no leftovers.
78
+ "struct-no-save-leftovers": (ont) => {
79
+ if (!existsSync(join(ont.root, "okb.json")))
80
+ return [];
81
+ const found = SAVE_LEFTOVERS.filter((f) => existsSync(join(ont.root, f)));
82
+ if (!found.length)
83
+ return [];
84
+ const marked = found.includes(".okb.saving.tmp");
85
+ return [{
86
+ message: marked
87
+ ? `A save of ${ont.root} didn't finish: ${found.join(", ")} ${found.length > 1 ? "are" : "is"} left over. If no okb command is running, run any okb command that changes this folder; it finishes the save.`
88
+ : `${found.join(", ")} ${found.length > 1 ? "are" : "is"} left over from a save that was cut short, so a file of this ontology may be older than the others. Compare ${found.length > 1 ? "each with the file it names" : "it with the file it names"} (git diff shows the real one), restore the folder from git or a backup if they differ, then delete the leftover${found.length > 1 ? "s" : ""}. If a command is running now, wait for it.`,
89
+ nodes: [],
90
+ }];
91
+ },
73
92
  "struct-well-formed": (ont) => {
74
93
  const hits = [];
75
94
  const { nodeTypes, edgeTypes } = MetaKB.get().formatRegistry();
@@ -730,6 +749,10 @@ export const CHECKS = {
730
749
  const loose = ont.ofType("CompetencyQuestion").filter((q) => ont.targets(q.id, "NEEDS").length === 0);
731
750
  return loose.map((q) => ({ message: `Competency question ${q.id} ("${q.text}") isn't linked to anything that answers it.`, nodes: [q.id] }));
732
751
  },
752
+ "scope-cq-expected-answer": (ont) => {
753
+ const loose = ont.ofType("CompetencyQuestion").filter((q) => !q.answer);
754
+ return loose.map((q) => ({ message: `Competency question ${q.id} ("${q.text}") has no expected answer, so nothing checks that the ontology still answers it.`, nodes: [q.id] }));
755
+ },
733
756
  "scope-no-unneeded": (ont) => {
734
757
  const needs = ont.edgesOf("NEEDS").map((e) => e.to);
735
758
  if (needs.length === 0)