@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.
- package/README.md +1 -1
- package/dist/check.d.ts +43 -0
- package/dist/check.js +102 -0
- package/dist/checks.d.ts +1 -1
- package/dist/checks.js +27 -4
- package/dist/cli.js +11 -705
- package/dist/clidocs.d.ts +0 -2
- package/dist/clidocs.js +5 -27
- package/dist/clock.js +1 -1
- package/dist/command-table.d.ts +144 -0
- package/dist/command-table.js +85 -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 +467 -0
- package/dist/commands/planning.d.ts +3 -0
- package/dist/commands/planning.js +251 -0
- package/dist/commands/reviewing.d.ts +3 -0
- package/dist/commands/reviewing.js +234 -0
- package/dist/commands/skills.d.ts +3 -0
- package/dist/commands/skills.js +53 -0
- package/dist/commands.d.ts +10 -22
- package/dist/commands.js +15 -622
- package/dist/cqanswer.d.ts +51 -0
- package/dist/cqanswer.js +76 -0
- package/dist/diff.d.ts +85 -0
- package/dist/diff.js +323 -0
- package/dist/export-changes.d.ts +40 -0
- package/dist/export-changes.js +115 -0
- package/dist/export-csv.d.ts +17 -0
- package/dist/export-csv.js +188 -0
- package/dist/export-eval-cases.d.ts +38 -0
- package/dist/export-eval-cases.js +40 -0
- package/dist/export.d.ts +34 -3
- package/dist/export.js +70 -12
- package/dist/families.d.ts +1 -1
- package/dist/families.js +1 -1
- package/dist/help.d.ts +11 -2
- package/dist/help.js +51 -57
- package/dist/kbdocs.d.ts +18 -0
- package/dist/kbdocs.js +393 -0
- package/dist/metakb.d.ts +1 -1
- package/dist/metakb.js +1 -1
- package/dist/naming.d.ts +2 -2
- package/dist/naming.js +2 -2
- package/dist/ontology-ref.d.ts +20 -0
- package/dist/ontology-ref.js +108 -0
- package/dist/ops/admin.d.ts +2 -2
- package/dist/ops/admin.js +26 -8
- package/dist/ops/classes.d.ts +1 -1
- package/dist/ops/classes.js +15 -7
- package/dist/ops/common.d.ts +12 -2
- package/dist/ops/common.js +3 -0
- package/dist/ops/instances.d.ts +2 -1
- package/dist/ops/instances.js +9 -3
- package/dist/ops/links.d.ts +2 -2
- package/dist/ops/links.js +3 -2
- package/dist/ops/naming.d.ts +1 -1
- package/dist/ops/naming.js +3 -1
- package/dist/ops/scope.d.ts +14 -3
- package/dist/ops/scope.js +38 -4
- package/dist/ops/slots.d.ts +1 -1
- package/dist/ops/slots.js +21 -8
- package/dist/ops/values.d.ts +1 -1
- package/dist/ops/values.js +5 -1
- package/dist/provenance.d.ts +5 -3
- package/dist/provenance.js +61 -19
- package/dist/release.d.ts +52 -0
- package/dist/release.js +337 -0
- package/dist/render.d.ts +88 -1
- package/dist/render.js +265 -3
- package/dist/resync.d.ts +98 -0
- package/dist/resync.js +234 -0
- package/dist/review.d.ts +1 -1
- package/dist/review.js +1 -1
- package/dist/reviewdocs.d.ts +42 -0
- package/dist/reviewdocs.js +263 -0
- package/dist/runner.d.ts +3 -0
- package/dist/runner.js +84 -0
- package/dist/skills.d.ts +19 -3
- package/dist/skills.js +130 -14
- package/dist/status.d.ts +1 -1
- package/dist/status.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/verifynote.d.ts +19 -0
- package/dist/verifynote.js +93 -0
- package/dist/workflows.d.ts +283 -0
- package/dist/workflows.js +270 -0
- package/meta-kb/data/edges.json +25 -0
- package/meta-kb/data/manifest.json +5 -5
- package/meta-kb/data/nodes.json +46 -9
- package/package.json +9 -4
- package/schema/edge.schema.json +68 -0
- package/schema/edges.schema.json +9 -0
- package/schema/node.schema.json +914 -0
- package/schema/nodes.schema.json +9 -0
- package/schema/okb.schema.json +41 -0
- package/skills/build-domain-kb-from-docs/SKILL.md +21 -3
- package/skills/ontology-coach/SKILL.md +8 -4
- package/skills/ontology-maintainer/SKILL.md +152 -0
- package/skills/ontology-review/SKILL.md +4 -2
- package/skills/ontology-signoff/SKILL.md +182 -0
- package/templates/okb-check.yml +148 -0
- package/templates/pull_request_template.md +16 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Copy this file to .github/workflows/okb-check.yml in your knowledge base's repository.
|
|
2
|
+
#
|
|
3
|
+
# On every pull request it installs the okb version your KB pins (okbVersion in okb.json; run
|
|
4
|
+
# `okb pin` to set it), runs `okb check`, and posts what the PR changes (`okb diff`) as one comment
|
|
5
|
+
# that later pushes update. It needs no secrets. Make "Check the knowledge base" a required status
|
|
6
|
+
# check on your main branch so a failing check blocks the merge.
|
|
7
|
+
name: okb check
|
|
8
|
+
|
|
9
|
+
on:
|
|
10
|
+
pull_request:
|
|
11
|
+
|
|
12
|
+
# The comment needs pull-requests: write. Everything else only reads.
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
pull-requests: write
|
|
16
|
+
|
|
17
|
+
# A new push supersedes the run for the old one.
|
|
18
|
+
concurrency:
|
|
19
|
+
group: okb-check-${{ github.ref }}
|
|
20
|
+
cancel-in-progress: true
|
|
21
|
+
|
|
22
|
+
env:
|
|
23
|
+
# The folder that holds okb.json. Change it if the KB isn't at the root of the repository.
|
|
24
|
+
KB_DIR: .
|
|
25
|
+
|
|
26
|
+
jobs:
|
|
27
|
+
check:
|
|
28
|
+
name: Check the knowledge base
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
timeout-minutes: 15
|
|
31
|
+
steps:
|
|
32
|
+
# The full history, so `okb diff` can read the base branch.
|
|
33
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
34
|
+
with:
|
|
35
|
+
fetch-depth: 0
|
|
36
|
+
persist-credentials: false
|
|
37
|
+
|
|
38
|
+
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
|
39
|
+
with:
|
|
40
|
+
node-version: 24 # okb needs Node 24 or newer
|
|
41
|
+
|
|
42
|
+
- name: Install the okb version the KB pins
|
|
43
|
+
shell: bash
|
|
44
|
+
run: |
|
|
45
|
+
version="$(node -p "require('./$KB_DIR/okb.json').okbVersion || ''")"
|
|
46
|
+
if [ -z "$version" ]; then
|
|
47
|
+
echo "::warning::okb.json has no okbVersion, so this installs the latest okb. Run 'okb pin' and commit okb.json to pin one."
|
|
48
|
+
version=latest
|
|
49
|
+
elif ! printf '%s' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$'; then
|
|
50
|
+
echo "::error::okbVersion '$version' in okb.json isn't a version like 1.2.3."
|
|
51
|
+
exit 1
|
|
52
|
+
fi
|
|
53
|
+
npm install --global --no-audit --no-fund "@ontology-kit/okb@$version"
|
|
54
|
+
okb version
|
|
55
|
+
|
|
56
|
+
# Never stops the job: the diff and the comment still run, and the last step fails the job.
|
|
57
|
+
- name: Run okb check
|
|
58
|
+
id: check
|
|
59
|
+
continue-on-error: true
|
|
60
|
+
shell: bash
|
|
61
|
+
run: |
|
|
62
|
+
# No pipe: the step must exit with okb check's status, not tee's.
|
|
63
|
+
status=0
|
|
64
|
+
okb check -C "$KB_DIR" > "$RUNNER_TEMP/check.txt" 2>&1 || status=$?
|
|
65
|
+
cat "$RUNNER_TEMP/check.txt"
|
|
66
|
+
exit "$status"
|
|
67
|
+
|
|
68
|
+
# Optional: ask the competency questions through the MCP server's tools, as an agent would, and not
|
|
69
|
+
# only against the files. Uncomment it if the KB is served with @ontology-kit/mcp. It needs the
|
|
70
|
+
# questions' answers stored (`okb cq answer`) and exits 1 when one fails. Add `continue-on-error: true`
|
|
71
|
+
# to report it without blocking the merge. The comment below reads this step's outcome through its `id`, and
|
|
72
|
+
# says "not safe to merge" when it failed, even if `continue-on-error` lets the job pass.
|
|
73
|
+
# - name: Run the competency questions through the MCP server
|
|
74
|
+
# id: mcp
|
|
75
|
+
# shell: bash
|
|
76
|
+
# run: npx --yes @ontology-kit/mcp check "$KB_DIR"
|
|
77
|
+
|
|
78
|
+
- name: Run okb diff against the base branch
|
|
79
|
+
if: always()
|
|
80
|
+
env:
|
|
81
|
+
BASE_REF: ${{ github.base_ref }}
|
|
82
|
+
shell: bash
|
|
83
|
+
run: |
|
|
84
|
+
# The backticks are Markdown, not command substitution.
|
|
85
|
+
# shellcheck disable=SC2016
|
|
86
|
+
if ! okb diff "origin/$BASE_REF" -C "$KB_DIR" > "$RUNNER_TEMP/diff.md" 2> "$RUNNER_TEMP/diff.err"; then
|
|
87
|
+
printf 'okb diff could not compare with `%s`:\n\n```\n%s\n```\n' "$BASE_REF" "$(cat "$RUNNER_TEMP/diff.err")" > "$RUNNER_TEMP/diff.md"
|
|
88
|
+
fi
|
|
89
|
+
|
|
90
|
+
- name: Write the comment
|
|
91
|
+
if: always()
|
|
92
|
+
env:
|
|
93
|
+
RESULT: ${{ steps.check.outcome }}
|
|
94
|
+
# Empty while the optional MCP step above is commented out, which counts as "not run".
|
|
95
|
+
MCP_RESULT: ${{ steps.mcp.outcome }}
|
|
96
|
+
shell: bash
|
|
97
|
+
run: |
|
|
98
|
+
# The backticks are Markdown, not command substitution.
|
|
99
|
+
# shellcheck disable=SC2016
|
|
100
|
+
{
|
|
101
|
+
echo '<!-- okb-check -->'
|
|
102
|
+
if [ "$RESULT" = success ] && [ "$MCP_RESULT" != failure ]; then echo '## okb check: safe to merge'; else echo '## okb check: not safe to merge'; fi
|
|
103
|
+
if [ "$MCP_RESULT" = failure ]; then
|
|
104
|
+
echo
|
|
105
|
+
echo 'The competency questions asked through the MCP server failed (see the step in the run log).'
|
|
106
|
+
fi
|
|
107
|
+
echo
|
|
108
|
+
echo '~~~~text'
|
|
109
|
+
sed 's/\x1b\[[0-9;]*m//g' "$RUNNER_TEMP/check.txt"
|
|
110
|
+
echo '~~~~'
|
|
111
|
+
echo
|
|
112
|
+
echo '## What this PR changes'
|
|
113
|
+
echo
|
|
114
|
+
cat "$RUNNER_TEMP/diff.md"
|
|
115
|
+
} > "$RUNNER_TEMP/body.md"
|
|
116
|
+
# A comment holds at most 65536 characters.
|
|
117
|
+
if [ "$(wc -c < "$RUNNER_TEMP/body.md")" -gt 60000 ]; then
|
|
118
|
+
head -c 60000 "$RUNNER_TEMP/body.md" > "$RUNNER_TEMP/short.md"
|
|
119
|
+
# shellcheck disable=SC2016
|
|
120
|
+
printf '\n\n_(Cut short. Run `okb diff` locally for the rest.)_\n' >> "$RUNNER_TEMP/short.md"
|
|
121
|
+
mv "$RUNNER_TEMP/short.md" "$RUNNER_TEMP/body.md"
|
|
122
|
+
fi
|
|
123
|
+
cat "$RUNNER_TEMP/body.md" >> "$GITHUB_STEP_SUMMARY"
|
|
124
|
+
|
|
125
|
+
# A pull request from a fork gets a read-only token, so it only gets the job summary.
|
|
126
|
+
- name: Create or update the pull request comment
|
|
127
|
+
if: always() && github.event.pull_request.head.repo.full_name == github.repository
|
|
128
|
+
env:
|
|
129
|
+
GH_TOKEN: ${{ github.token }}
|
|
130
|
+
REPO: ${{ github.repository }}
|
|
131
|
+
PR: ${{ github.event.pull_request.number }}
|
|
132
|
+
shell: bash
|
|
133
|
+
run: |
|
|
134
|
+
# Read the list first: if gh fails, stop here rather than post a duplicate comment.
|
|
135
|
+
ids="$(gh api --paginate "repos/$REPO/issues/$PR/comments" --jq '.[] | select(.body | startswith("<!-- okb-check -->")) | .id')"
|
|
136
|
+
id="${ids%%$'\n'*}"
|
|
137
|
+
if [ -n "$id" ]; then
|
|
138
|
+
gh api --method PATCH "repos/$REPO/issues/comments/$id" -F body=@"$RUNNER_TEMP/body.md" > /dev/null
|
|
139
|
+
else
|
|
140
|
+
gh api --method POST "repos/$REPO/issues/$PR/comments" -F body=@"$RUNNER_TEMP/body.md" > /dev/null
|
|
141
|
+
fi
|
|
142
|
+
|
|
143
|
+
- name: Fail if okb check failed
|
|
144
|
+
if: steps.check.outcome == 'failure'
|
|
145
|
+
shell: bash
|
|
146
|
+
run: |
|
|
147
|
+
echo "::error::okb check found problems. See the summary above or the pull request comment."
|
|
148
|
+
exit 1
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!-- Copy this file to .github/pull_request_template.md in your knowledge base's repository. -->
|
|
2
|
+
|
|
3
|
+
## What changed in the knowledge
|
|
4
|
+
|
|
5
|
+
<!-- One or two sentences. Paste the okb diff comment from CI, or run `okb diff main`. -->
|
|
6
|
+
|
|
7
|
+
## Checklist
|
|
8
|
+
|
|
9
|
+
- [ ] `okb check` says "Safe to merge" (the okb check workflow ran it).
|
|
10
|
+
- [ ] I read `okb diff main` and every change in it is meant.
|
|
11
|
+
- [ ] Each new or changed rule, class or fact cites a quote from a source.
|
|
12
|
+
- [ ] I ran `okb source refresh` for every source document I changed, and no quote is missing.
|
|
13
|
+
- [ ] A person other than the author ran `okb verify <id> --approve` on every corrected item.
|
|
14
|
+
- [ ] I used `okb rename` (not remove and add) for every renamed class, slot or instance.
|
|
15
|
+
- [ ] I ran `okb pin` if I upgraded okb.
|
|
16
|
+
- [ ] I ran `okb release <version>` and committed the result, if this change is part of a release.
|