From e7093216188065beef5af632d5f334f513a30b07 Mon Sep 17 00:00:00 2001 From: "knowledge-sync[bot]" Date: Tue, 1 Dec 2026 22:30:55 +0000 Subject: [PATCH] chore(sidecar): sync copies and skills pin from v0.71.1 --- .../PULL_REQUEST_TEMPLATE/knowledge-sync.md | 2 +- .lokf/pyproject.toml | 2 +- .lokf/scripts/knowledge-sync.sh | 107 +++++++++++++----- .lokf/uv.lock | 10 +- CHANGELOG.md | 4 + website/scripts/build.sh | 10 +- website/scripts/prepare.sh | 4 +- website/scripts/vendor.sh | 2 +- 8 files changed, 98 insertions(+), 43 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE/knowledge-sync.md b/.github/PULL_REQUEST_TEMPLATE/knowledge-sync.md index 19b28ac..8b4d673 100644 --- a/.github/PULL_REQUEST_TEMPLATE/knowledge-sync.md +++ b/.github/PULL_REQUEST_TEMPLATE/knowledge-sync.md @@ -2,5 +2,5 @@ ## Reviewer checklist -- [ ] The diff changes only the sidecar's copies, the site's copies, the `ktl` pin and its lock, and `CHANGELOG.md`. +- [ ] The diff changes only the sidecar's copies, the site's copies, the `ktl` pin and its lock, and the changelog. - [ ] Any workflow changes held above are read and applied on this branch. diff --git a/.lokf/pyproject.toml b/.lokf/pyproject.toml index 6d40e71..da19ee9 100644 --- a/.lokf/pyproject.toml +++ b/.lokf/pyproject.toml @@ -12,7 +12,7 @@ description = "LOKF knowledge-bundle tooling for collections." # Keep in sync with the `lokf` toolkit's own requires-python floor. requires-python = ">=3.11" dependencies = [ - "ktl==0.71.0", + "ktl==0.71.1", "lokf[build]>=0.9.0", # The recipe runner the workflows use, pinned here so uv.lock checks it # by hash; keep the version in step with the workflows' uvx fallback. diff --git a/.lokf/scripts/knowledge-sync.sh b/.lokf/scripts/knowledge-sync.sh index d31227a..4cb51d3 100755 --- a/.lokf/scripts/knowledge-sync.sh +++ b/.lokf/scripts/knowledge-sync.sh @@ -14,7 +14,8 @@ # - copies each template the host carries, adds one an `always` or `needs` # line asks for, and lists the rest for ktl-sidecar's Step 5; # - reports local edits it overwrote, and host files no manifest line names; -# - writes the changelog entry under "## [Unreleased]", "### Changed"; +# - writes the changelog entry under "## [Unreleased]", "### Changed", in +# the changelog the host's site shows; # - runs the sidecar's checks on the result. # It starts from a clean tree, on the current branch or a new one from # origin's default branch. It edits the pin line and runs `uv lock` because @@ -184,25 +185,73 @@ add_entry() { return 3 } -# The paths a sync may touch: the sidecar's and the site's copies, the pin, -# its lock and the changelog, in the plain characters the templates use. -sync_paths='^(\.github/workflows/knowledge-[a-z]+\.yaml|\.github/PULL_REQUEST_TEMPLATE/knowledge-[a-z]+\.md|\.lokf/scripts/knowledge-[a-z]+\.(sh|py)|\.lokf/m365/[A-Za-z0-9._-]+|\.lokf/(schema/)?domain\.yaml|\.lokf/\.gitattributes|\.lokf/\.gitignore|\.lokf/justfile|\.lokf/pyproject\.toml|\.lokf/uv\.lock|(ktl-)?website/.+|CHANGELOG\.md)$' +# The site's folder, the first of ktl-website/ and website/ that holds +# site.toml, as the website workflow picks it: . +site_of() { + local o + for o in ktl-website website; do + if [[ -f "$1/$o/site.toml" ]]; then printf '%s\n' "$o"; return; fi + done +} + +# The changelog the site shows, as a path from the host's root: . It +# is CHANGELOG.md in the folder that site.toml's [params] source names, such +# as a fork's .linkml/, or else at the root. A line inside a multi-line +# string is not a key, as TOML reads it. A source outside the host, or not +# in plain characters, means the root. +changelog_of() { + local site src="" up='(^|/)\.\.?(/|$)' dotgit='(^|/)\.[Gg][Ii][Tt](/|$)' + site="$(site_of "$1")" + if [[ -n "$site" ]]; then + src="$(tr -d '\r' < "$1/$site/site.toml" | awk -v q="'" ' + ml != "" { if (index($0, ml)) ml = ""; next } + /^[ \t]*#/ { next } + /^[ \t]*\[/ { t = $0; sub(/#.*/, "", t); gsub(/[ \t]/, "", t); in_params = (t == "[params]"); next } + !/=/ { next } + { + k = $0; sub(/=.*/, "", k); gsub(/[ \t]/, "", k); k = tolower(k) + v = $0; sub(/^[^=]*=[ \t]*/, "", v); c = substr(v, 1, 3) + } + in_params && (k == "source" || k == "\"source\"" || k == (q "source" q)) { + c = substr(v, 1, 1) + if (c == "\"" || c == q) { + r = substr(v, 2); e = index(r, c) + if (e > 0 && (c == q || index(substr(r, 1, e - 1), "\\") == 0)) print substr(r, 1, e - 1) + } + exit + } + (c == "\"\"\"" || c == (q q q)) && !index(substr(v, 4), c) { ml = c }')" + fi + src="${src#./}"; src="${src%/}" + if [[ -n "$src" && "$src" != "." && "$src" =~ $plain_path && "$src" != /* && ! "$src" =~ $up && ! "$src" =~ $dotgit ]]; then + printf '%s/CHANGELOG.md\n' "$src" + else + printf 'CHANGELOG.md\n' + fi +} + +# The paths a sync may touch: the sidecar's and the site's copies, the pin +# and its lock, in the plain characters the templates use. The changelog is +# the one changelog_of names. +sync_paths='^(\.github/workflows/knowledge-[a-z]+\.yaml|\.github/PULL_REQUEST_TEMPLATE/knowledge-[a-z]+\.md|\.lokf/scripts/knowledge-[a-z]+\.(sh|py)|\.lokf/m365/[A-Za-z0-9._-]+|\.lokf/(schema/)?domain\.yaml|\.lokf/\.gitattributes|\.lokf/\.gitignore|\.lokf/justfile|\.lokf/pyproject\.toml|\.lokf/uv\.lock|(ktl-)?website/.+)$' owned_paths='^(ktl-)?website/(site\.toml|README\.md|assets/css/custom\.css)$' plain_path='^[]A-Za-z0-9._/@+[-]+$' # --apply, for knowledge-sync.yaml's privileged job, which trusts nothing the # patch's maker decided. The patch may edit and add plain files on the paths -# above, and move the pin line to 's version. `uv lock`, run here from -# the checkout's lock, must write the patch's lock, so its hashes are the -# index's (`uv lock --locked` does not compare hashes). A workflow pushed with -# a token runs on that push with the repository's secrets, so every workflow +# above and the changelog this checkout's own site.toml names, and move the +# pin line to 's version. `uv lock`, run here from the checkout's lock, +# must write the patch's lock, so its hashes are the index's +# (`uv lock --locked` does not compare hashes). A workflow pushed with a +# token runs on that push with the repository's secrets, so every workflow # change goes to , a patch a person applies on top. apply_patch() { - local patch="$1" held="$2" tag="$3" paths wrong f full lane lines err + local patch="$1" held="$2" tag="$3" paths wrong f full lane lines err changelog [[ -f "$patch" ]] || die "no such patch: $patch" [[ -z "$(git status --porcelain)" ]] || die "the checkout has changes of its own; --apply takes a clean one" paths="$(git -c core.quotePath=false apply --numstat -- "$patch" | cut -f3-)" || die "$patch is not a patch git can read" - wrong="$(printf '%s\n' "$paths" | grep -Ev "$sync_paths" || true)" + changelog="$(changelog_of .)" + wrong="$(printf '%s\n' "$paths" | grep -Ev "$sync_paths" | grep -vxF -- "$changelog" || true)" wrong+=$'\n'"$(printf '%s\n' "$paths" | grep -E "$owned_paths" || true)" wrong+=$'\n'"$(printf '%s\n' "$paths" | grep -Ev "$plain_path" || true)" wrong+=$'\n'"$(printf '%s\n' "$paths" | grep -iE '(^|/)\.git(/|$)' || true)" @@ -471,7 +520,8 @@ workflow_publish() { local declined="${SYNC_DECLINED_PR:-}" lease="${SYNC_LEASE:-}" local held="$RUNNER_TEMP/workflows.patch" heldmd="$RUNNER_TEMP/held.md" body="$RUNNER_TEMP/body.md" local subject="chore(sidecar): sync copies and skills pin from $tag" - local bt='`' staged=1 link copies added url base + local bt='`' staged=1 link copies added url base changelog + changelog="$(changelog_of .)" ! git diff --cached --quiet || staged=0 : > "$heldmd" if [[ -s "$held" ]]; then @@ -494,7 +544,7 @@ workflow_publish() { link="$repo_url/blob/$tag/CHANGELOG.md" [[ -z "$from" || "$from" == "$tag" ]] || link="$repo_url/compare/$from...$tag" # The copies are the staged files other than the changelog and the pin's. - copies="$(git -c core.quotePath=false diff --cached --name-status | awk -F'\t' -v p="$pyproject" -v l="$lock" '$1 == "M" && $2 != "CHANGELOG.md" && $2 != p && $2 != l { print $2 }')" + copies="$(git -c core.quotePath=false diff --cached --name-status | awk -F'\t' -v p="$pyproject" -v l="$lock" -v c="$changelog" '$1 == "M" && $2 != c && $2 != p && $2 != l { print $2 }')" added="$(git -c core.quotePath=false diff --cached --name-status | awk -F'\t' '$1 == "A" { print $2 }')" { if [[ -n "$from" && "$from" != "$tag" ]]; then @@ -527,10 +577,12 @@ workflow_publish() { echo echo "This repository's own checks run on this pull request, on the synced copies, with a read-only token. A failure there is a bundle to fix in this pull request, or the gate fails on it after the merge." echo - if git diff --cached --quiet -- CHANGELOG.md; then - echo "CHANGELOG.md is unchanged: it has the entry already, or it has no Unreleased heading, in which case add the entry by hand." + if [[ ! -f "$changelog" ]]; then + echo "There is no $changelog here, so no entry was written." + elif git diff --cached --quiet -- "$changelog"; then + echo "$changelog is unchanged: it has the entry already, or it has no Unreleased heading, in which case add the entry by hand." else - echo "CHANGELOG.md has the entry under its Unreleased heading and Changed." + echo "$changelog has the entry under its Unreleased heading and Changed." fi echo if [[ -n "$declined" ]]; then @@ -888,11 +940,9 @@ main() { done # The site: every template is synced, and a missing one added. - local website=0 site="" rel skip o new_w="$new_dir/$website_in" old_w="" + local website=0 site rel skip o new_w="$new_dir/$website_in" old_w="" [[ -z "$old_dir" ]] || old_w="$old_dir/$website_in" - for o in website ktl-website; do - if [[ -z "$site" && -f "$host/$o/site.toml" ]]; then site="$o"; fi - done + site="$(site_of "$host")" if [[ -n "$site" && -d "$new_w/website" ]]; then website=1 while IFS= read -r rel; do @@ -1001,7 +1051,7 @@ main() { # The changelog entry, from what the sync did. The link compares the two # pins. "No plugin change" is added for an Obsidian plugin, whose root # manifest.json names minAppVersion. - local link tail="" entry list=() i changelog_line + local link tail="" entry list=() i changelog_line changelog if [[ -n "$old_pin" && "$old_pin" != "$tag" ]]; then link="$repo_url/compare/$old_pin...$tag" else @@ -1034,15 +1084,16 @@ main() { for f in ${copied[@]+"${copied[@]}"} ${overwrote[@]+"${overwrote[@]}"}; do changed+=("$f"); done for f in ${added[@]+"${added[@]}"}; do changed+=("${f%% (*}"); done for f in ${lock_files[@]+"${lock_files[@]}"}; do changed+=("$f"); done - if [[ ! -f "$host/CHANGELOG.md" ]]; then - changelog_line="There is no CHANGELOG.md here, so no entry was written." - elif grep -qF "[$tag]($link)" "$host/CHANGELOG.md"; then - changelog_line="CHANGELOG.md already has the entry for $tag." - elif add_entry "$host/CHANGELOG.md" "$entry"; then - changelog_line="CHANGELOG.md has the entry, under its Unreleased heading and Changed." - changed+=("CHANGELOG.md") + changelog="$(changelog_of "$host")" + if [[ ! -f "$host/$changelog" ]]; then + changelog_line="There is no $changelog here, so no entry was written." + elif grep -qF "[$tag]($link)" "$host/$changelog"; then + changelog_line="$changelog already has the entry for $tag." + elif add_entry "$host/$changelog" "$entry"; then + changelog_line="$changelog has the entry, under its Unreleased heading and Changed." + changed+=("$changelog") else - changelog_line="CHANGELOG.md has no Unreleased heading, so add the entry by hand:"$'\n'" $entry" + changelog_line="$changelog has no Unreleased heading, so add the entry by hand:"$'\n'" $entry" fi echo " entry $changelog_line" diff --git a/.lokf/uv.lock b/.lokf/uv.lock index de228ab..654d5dd 100644 --- a/.lokf/uv.lock +++ b/.lokf/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 3 +revision = 5 requires-python = ">=3.11" resolution-markers = [ "python_full_version >= '3.14'", @@ -416,7 +416,7 @@ dependencies = [ [package.metadata] requires-dist = [ - { name = "ktl", specifier = "==0.71.0" }, + { name = "ktl", specifier = "==0.71.1" }, { name = "lokf", extras = ["build"], specifier = ">=0.9.0" }, { name = "rust-just", specifier = "==1.59.0" }, ] @@ -813,11 +813,11 @@ wheels = [ [[package]] name = "ktl" -version = "0.71.0" +version = "0.71.1" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/08/ae/fd5b916f34cf3a0f00aca419fb10854ab25c93d430ca238354137d46c5d7/ktl-0.71.0.tar.gz", hash = "sha256:a707ed6d7e0acedf38a4bde8be8c910e3f2fa594376fbb9f3c575edd4b2664eb", size = 866277, upload-time = "2026-11-27T19:47:32.061Z" } +sdist = { url = "https://files.pythonhosted.org/packages/03/e3/b479023422473ac5286c773f52780b5152eff7286ff25a7fb1b147f83438/ktl-0.71.1.tar.gz", hash = "sha256:e9155ef6e4d3318bc930eced29000b95c03617bff24eb8b8393672e0b0758221", size = 868069, upload-time = "2026-12-01T20:55:56.87Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/22/b1/af63bf6f2d087cae51076482c4ad80ced4a60eb47ff5460246ba7d5d2207/ktl-0.71.0-py3-none-any.whl", hash = "sha256:242e2c9b356114bb22de53a2efff55d84efd9338519a20937eb574b67171f47d", size = 981304, upload-time = "2026-11-27T19:47:30.474Z" }, + { url = "https://files.pythonhosted.org/packages/7b/98/a34155040e37af45df6fc823fd8deb77a9682afb66e81747b34ad88c15a6/ktl-0.71.1-py3-none-any.whl", hash = "sha256:51687b46dd3673e2959b42a68a1c965f159308d6138ee0984f33665e2502ee3d", size = 983146, upload-time = "2026-12-01T20:55:55.397Z" }, ] [[package]] diff --git a/CHANGELOG.md b/CHANGELOG.md index dad28e3..46cf8d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ The `v0.0.0` tag is a baseline, not a release: it marks where versioning starts - **The shell lint runs the runner image's shellcheck instead of downloading one.** +### Changed + +- **The sidecar copies and the skills pin are at Knowledge Trust Ladder [v0.71.1](https://github.com/noelmcloughlin/knowledge-trust-ladder/compare/v0.71.0...v0.71.1).** The release changed `.github/PULL_REQUEST_TEMPLATE/knowledge-sync.md`, `.lokf/scripts/knowledge-sync.sh`, `website/scripts/build.sh`, `website/scripts/prepare.sh` and `website/scripts/vendor.sh` here. + ## [0.3.4] - 2026-11-30 ### Fixed diff --git a/website/scripts/build.sh b/website/scripts/build.sh index 9b0947d..a62c231 100755 --- a/website/scripts/build.sh +++ b/website/scripts/build.sh @@ -18,7 +18,7 @@ set -euo pipefail here=$(cd "$(dirname "$0")/.." && pwd) cd "$here" -mode=$(scripts/uv-env.sh "$here") +mode=$(bash scripts/uv-env.sh "$here") tool=(uv run --project "$here" "$mode" --quiet) # hugo.toml is the same on every site, and site.toml holds this repository's # own values, read second so that they win. @@ -30,7 +30,7 @@ if grep -qE '<(REPO|PROJ|SITE)_[A-Z]+>' site.toml; then exit 1 fi -scripts/prepare.sh +bash scripts/prepare.sh config=hugo.toml,site.toml # The mounts of a source folder, which prepare.sh writes when site.toml names one. [ -f generated/source.toml ] && config=$config,generated/source.toml @@ -48,9 +48,9 @@ case "${1:-}" in # The mark, new each build, sets off each page's raw HTML for clean-html.py. mark=$("${tool[@]}" python -c 'import secrets; print(secrets.token_hex(12))') HUGO_PARAMS_RAWMARK=$mark "${hugo[@]}" --gc --minify --cleanDestinationDir - "${tool[@]}" python scripts/clean-html.py dist "$mark" + "${tool[@]}" python -I scripts/clean-html.py dist "$mark" "${tool[@]}" python -m pagefind --site dist - "${tool[@]}" python scripts/check-links.py dist "$("${hugo[@]}" config | sed -n 's/^baseurl = //p' | tr -d "\"'")" + "${tool[@]}" python -I scripts/check-links.py dist "$("${hugo[@]}" config | sed -n 's/^baseurl = //p' | tr -d "\"'")" ;; serve) # Pagefind indexes built pages, so one build gives the server an index. @@ -63,7 +63,7 @@ case "${1:-}" in preview) mark=$("${tool[@]}" python -c 'import secrets; print(secrets.token_hex(12))') HUGO_PARAMS_RAWMARK=$mark "${hugo[@]}" --gc --minify -d .preview --baseURL "http://localhost:$port/" - "${tool[@]}" python scripts/clean-html.py .preview "$mark" + "${tool[@]}" python -I scripts/clean-html.py .preview "$mark" "${tool[@]}" python -m pagefind --site .preview exec "${tool[@]}" python -m http.server "$port" --bind 127.0.0.1 --directory .preview ;; diff --git a/website/scripts/prepare.sh b/website/scripts/prepare.sh index ba3a532..50b5310 100755 --- a/website/scripts/prepare.sh +++ b/website/scripts/prepare.sh @@ -15,7 +15,7 @@ root=$(cd "$here/.." && pwd) out="$here/generated" # The site's own tools, as build.sh runs them, for the two checks below. # uv-env.sh installs them, from a package mirror where uv reads one. -mode=$("$here/scripts/uv-env.sh" "$here") +mode=$(bash "$here/scripts/uv-env.sh" "$here") tool=(uv run --project "$here" "$mode" --quiet) # site.toml's values, read by a TOML parser as Hugo reads them, one # `name=value` line each. A file the parser refuses stops the build here. @@ -55,7 +55,7 @@ fi # The bundle's own tools: lokf, and the LinkML it is built on, installed as # the site's own are. -mode=$("$here/scripts/uv-env.sh" "$root/.lokf") +mode=$(bash "$here/scripts/uv-env.sh" "$root/.lokf") lokf=(uv run --project "$root/.lokf" "$mode" --quiet) # The domain vocabulary the sidecar's justfile names, so the export carries diff --git a/website/scripts/vendor.sh b/website/scripts/vendor.sh index 1e07ee0..ea5862f 100755 --- a/website/scripts/vendor.sh +++ b/website/scripts/vendor.sh @@ -12,7 +12,7 @@ set -euo pipefail here=$(cd "$(dirname "$0")/.." && pwd) command -v npm >/dev/null 2>&1 || { echo "vendor.sh: npm not found; it fetches each package from the registry it reads" >&2; exit 1; } -mode=$("$here/scripts/uv-env.sh" "$here") +mode=$(bash "$here/scripts/uv-env.sh" "$here") # name, package@version, path in the package and SHA-256, one line each. tool=(uv run --project "$here" "$mode" --quiet) wanted=$("${tool[@]}" python -I - "$here/hugo.toml" "$@" <<'PY'