From d2176ef1054a52fb31eab645bc4f96b9278e17ff Mon Sep 17 00:00:00 2001 From: Roman PASSLER Date: Fri, 6 Nov 2026 21:58:41 +0100 Subject: [PATCH] test(cli): the commands that never hand over to the pinned km run the km that was started upgrade, init, doctor, list and sync are in NO_PIN_CHECK. The smoke test now checks each of them in a brain pinned to an older km: exit 0, the runner is not called, no 'running that one' notice. The cli docstring and the skill name these commands, so nobody adds KM_LOCAL=1 to km upgrade again. --- skills/km/SKILL.md | 3 ++- src/km/cli.py | 3 ++- tests/team_smoke.sh | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/skills/km/SKILL.md b/skills/km/SKILL.md index dc04f76..489a4db 100644 --- a/skills/km/SKILL.md +++ b/skills/km/SKILL.md @@ -29,7 +29,8 @@ Read `CONVENTIONS.md` in the repo root. If missing, offer to initialize (`/km in below; `km --help` lists the commands, and all take `--root DIR`. Brains carry no km code: CI and the pre-commit hook install the km release the brain pins, by its commit (`pasrom/km@ # vX.Y.Z`, so a moved tag cannot change what runs), and so does `km` here: in a brain that pins another version -it runs that commit through `uvx`, so results match CI (`KM_LOCAL=1` keeps the plugin's). Without uv, +it runs that commit through `uvx`, so results match CI (`KM_LOCAL=1` keeps the plugin's; `init`, +`upgrade`, `doctor`, `list` and `sync` always run the plugin's km, so `km upgrade` needs no `KM_LOCAL`). Without uv, offline, for a pin to a movable tag, or when the workflows disagree, it runs the plugin's km and warns; `/km upgrade` the brain then. diff --git a/src/km/cli.py b/src/km/cli.py index 459c8ae..930c7d9 100644 --- a/src/km/cli.py +++ b/src/km/cli.py @@ -7,7 +7,8 @@ When this km is another version, a brain command runs the commit CI runs instead (through uvx), so local results match CI; `KM_LOCAL=1` keeps this km. When that is not possible (no uv, offline, a movable tag instead of a commit, workflows that disagree) it runs this km and says so. A hook pinned -apart from CI gets a note. +apart from CI gets a note. `init`, `upgrade`, `doctor`, `list` and `sync` (NO_PIN_CHECK) always run +this km: they write the pins, check the km that runs, only read, or act on the clone. """ from __future__ import annotations diff --git a/tests/team_smoke.sh b/tests/team_smoke.sh index 774eb30..eafb402 100644 --- a/tests/team_smoke.sh +++ b/tests/team_smoke.sh @@ -279,6 +279,12 @@ rm -f "$F/runner-args"; out="$(KM_PINNED_RUNNER="$F/fake-uvx" km repin --root "$ rm -f "$F/runner-args"; out="$(KM_PINNED_RUNNER="$F/fake-uvx" km repin --root "$O" --cites any.md --dir . 2>&1)"; rc=$? { [ "$rc" = 2 ] && echo "$out" | grep -q "needs km v1.8.0, the brain pins v0.9.0" && [ ! -e "$F/runner-args" ]; } \ && ok "an option the pinned km lacks says to upgrade" || no "option newer than the pin ($rc: $out)" +for c in init upgrade doctor list sync; do # NO_PIN_CHECK in cli.py: they run the km that was started + rm -f "$F/runner-args"; out="$(KM_PINNED_RUNNER="$F/fake-uvx" km "$c" --root "$O" --help 2>&1)"; rc=$? + { [ "$rc" = 0 ] && [ ! -e "$F/runner-args" ] && ! echo "$out" | grep -q "running that one"; } \ + && ok "km $c runs this km, not the older one the brain pins" \ + || no "km $c with an older pin ($rc: $(cat "$F/runner-args" 2>/dev/null) $out)" +done repin "$V09_SHA" v0.9.0 "$S99" v99.0.0 "$O"/.github/workflows/*.yml "$O/.pre-commit-config.yaml" rm -f "$F/runner-args"; KM_LOCAL=1 KM_PINNED_RUNNER="$F/fake-uvx" km validate --root "$O" >/dev/null 2>&1 [ ! -e "$F/runner-args" ] && ok "KM_LOCAL=1 keeps this km" || no "KM_LOCAL=1 keeps this km"