Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
KM_REPO_URL="file://$GITHUB_WORKSPACE" /tmp/wheel/bin/km init /tmp/wheel-brain --team --name W --desc w --initials WW --folder d=D
- run: bash tests/gate_smoke.sh
- run: bash tests/index_smoke.sh
- run: bash tests/ownership_smoke.sh
- run: bash tests/pins_smoke.sh
- run: bash tests/cites_smoke.sh
- run: bash tests/doctor_smoke.sh
Expand Down Expand Up @@ -154,6 +155,10 @@ jobs:
env:
PYTHON: python
run: bash tests/gate_smoke.sh
- name: the ownership table on Windows (gen-index, validate, upgrade; the symlink cases skip without symlinks)
env:
PYTHON: python
run: bash tests/ownership_smoke.sh
- name: km search on Windows (the cases with a stand-in gh run on POSIX only, see GH_STANDIN)
env:
PYTHON: python
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
pass_filenames: true
- id: km-gen-index
name: km gen-index
description: Rewrite every '## Documents' list in _index.md and create a missing one; a commit that changed one fails, stage it and commit again.
description: Rewrite every '## Documents' list in _index.md, create a missing one, and rewrite the mounted-repositories table in CONVENTIONS.md; a commit that changed one fails, stage it and commit again.
entry: km gen-index
language: python
always_run: true # every commit: one that only deletes a doc stages no file pre-commit would pass
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ e2e/ end-to-end test on a sandbox team brain on GitHub (e2e/RE

## Development

The smoke tests need Python 3.11+, PyYAML and git: `bash tests/gate_smoke.sh`, `index_smoke.sh`, `team_smoke.sh`, `doctor_smoke.sh`, `sync_smoke.sh`, `list_smoke.sh`, `ready_smoke.sh` (`km ready` against a stand-in `gh`), `search_smoke.sh` (`km search` over a brain with two mounts, against a stand-in `gh`), `automerge_smoke.sh` (`km automerge`, each merge condition flipped alone, against a stand-in `gh`), `pins_smoke.sh`, `cites_smoke.sh`, `mounted_pins_smoke.sh` (the mounted-pins workflow and script a team brain gets, against a stand-in GitHub API), `action_smoke.sh` (the GitHub Action's install step, with stand-ins for setup-python's interpreter, one that starts only with its `lib` folder on `LD_LIBRARY_PATH`), `skill_smoke.sh` (the skill's core keeps its size limit, no Markdown line under `skills/` is long enough for the Read tool to cut, its reference paths resolve, every `/km` verb has a dispatch row), `hook_smoke.sh` (the plugin's edit guard; the pre-push hook too where pre-commit is installed) and `e2e_smoke.sh` (the e2e driver's seed generator, and its check that `e2e/` names no repository but km's). CI runs them plus the GitHub Action on every pull request (once in GitHub's tool cache, once in another), and `encoding_smoke.sh`, `doctor_smoke.sh`, `sync_smoke.sh`, `hook_smoke.sh`, `signoff_smoke.sh` and `gate_smoke.sh` on Windows (team_smoke runs the encoding test on macOS under non-UTF-8 locales). A release bumps `__version__` in `src/km/__init__.py`, `version` in `.claude-plugin/plugin.json` and the version in this README together; merging that to main is the release, CI tags `vX.Y.Z` once main is green.
The smoke tests need Python 3.11+, PyYAML and git: `bash tests/gate_smoke.sh`, `index_smoke.sh`, `ownership_smoke.sh` (the ownership table in CONVENTIONS.md: gen-index, validate, upgrade), `team_smoke.sh`, `doctor_smoke.sh`, `sync_smoke.sh`, `list_smoke.sh`, `ready_smoke.sh` (`km ready` against a stand-in `gh`), `search_smoke.sh` (`km search` over a brain with two mounts, against a stand-in `gh`), `automerge_smoke.sh` (`km automerge`, each merge condition flipped alone, against a stand-in `gh`), `pins_smoke.sh`, `cites_smoke.sh`, `mounted_pins_smoke.sh` (the mounted-pins workflow and script a team brain gets, against a stand-in GitHub API), `action_smoke.sh` (the GitHub Action's install step, with stand-ins for setup-python's interpreter, one that starts only with its `lib` folder on `LD_LIBRARY_PATH`), `skill_smoke.sh` (the skill's core keeps its size limit, no Markdown line under `skills/` is long enough for the Read tool to cut, its reference paths resolve, every `/km` verb has a dispatch row), `hook_smoke.sh` (the plugin's edit guard; the pre-push hook too where pre-commit is installed) and `e2e_smoke.sh` (the e2e driver's seed generator, and its check that `e2e/` names no repository but km's). CI runs them plus the GitHub Action on every pull request (once in GitHub's tool cache, once in another), and `encoding_smoke.sh`, `doctor_smoke.sh`, `sync_smoke.sh`, `hook_smoke.sh`, `signoff_smoke.sh`, `gate_smoke.sh` and `ownership_smoke.sh` on Windows (team_smoke runs the encoding test on macOS under non-UTF-8 locales). A release bumps `__version__` in `src/km/__init__.py`, `version` in `.claude-plugin/plugin.json` and the version in this README together; merging that to main is the release, CI tags `vX.Y.Z` once main is green.

km started inside [dotclaude](https://github.com/pasrom/dotclaude) and was moved here with its history.

Expand Down
1 change: 1 addition & 0 deletions e2e/seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ def _build(b: Builder, out: Path, date: datetime.date, mount: tuple[str, str] |
f"\turl = {url}\n", encoding="utf-8")
(out / "mounted" / "notes").mkdir(parents=True) # an empty checkout: `git add -A` keeps the gitlink
b.run("git", "update-index", "--add", "--cacheinfo", f"160000,{sha},mounted/notes")
b.km("gen-index") # its row in the ownership table of CONVENTIONS.md
b.commit("chore(mount): mount the notes repository")

b.run("git", "add", "-A")
Expand Down
4 changes: 2 additions & 2 deletions evals/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

One case per row of the dispatch table in `skills/km/SKILL.md`, plus a negative case. Each case scaffolds a brain with `km init` from this checkout (`lib/brain.sh`), so run with `--scaffold`; the write and shell cases need `--allow-tools Bash Write Edit`, and every shell command then runs in Claude Code's sandbox inside the fixture brain. That sandbox has no network and gives the run its own empty home, so `lib/brain.sh` installs a uv-managed Python with `bin/km`'s PyYAML pin into that home before the session (this step needs uv and network): `bin/km` then starts offline on its first call. Without it, a run spends its turns getting km to start. The step stands in for what a user's first run fetches from the network, so a passing eval does not show that `bin/km` starts in a sandbox without network.

Each case whose row names a reference file has a `reads-reference` grader (that file was read); `help` and `save content` name only the core, so they have none. `save-cites` is a second case of the save row: a note that links a SharePoint file with a synced copy at hand, which the save flow cites with `km cite add` before the commit. `save-generated` is a third: a note with an SVG plotted from a local measurement export, which the save flow commits together with the script that draws it and a line on how to regenerate it. Its fixture brain lacks the rule in CONVENTIONS.md, like a brain set up before it, so the case measures the skill alone; the model mostly keeps the script without the plugin too (baseline 0.67 and 1.00 in two runs), so it guards against a regression rather than showing a lift. `save-owner` and `save-owner-named` are two more cases of the save row, in a team brain (`team_brain` in `lib/brain.sh`): a note saved without naming an owner gets `owner:` the author's initials, one where the user names someone else gets theirs and keeps the author, and the reply says who owns it; the graders read the doc the run leaves at the path the prompt names. `promote-owner` and `promote-owner-off-roster` are cases of the `promote` row in a team brain with an `owners:` roster: an author on it becomes the promoted doc's owner (the grader reads the file the run leaves); an author off it makes `km promote` refuse, and the run must then pass an `--owner` from the roster or ask whom to name, never edit the roster or write the doc by hand (an `llm` grader on the trace, and the roster line is checked to be unchanged); `promote-owner` also has a `reads-reference` grader, the off-roster case none, since a run may ask before it reads further. Measured without the plugin (3 runs each): `save-owner` 0.67 and `promote-owner` 0.22 against 1.00 with it; `save-owner-named` and `promote-owner-off-roster` pass either way (the model follows a named owner, and reads the roster and asks), so those two guard against a regression rather than show a lift. `lookup-all-brains` is a second case of the question row: a brain with two mounted brains (`brain_with_two_peers` in `lib/brain.sh`) and a fact only in the second mount's merged doc, asked without `@`; it checks that the run starts with `km search` (a `regex` on the trace for its coverage or result line), answers the fact with a `[gamma@<sha>]` citation, and (an `llm` grader) names the open pull requests as not searched (the fixture's brains have no GitHub remote, so km search reports them NOT SEARCHED) rather than saying nothing is in review. `lookup-question` allows Bash so that it can run `km search` too. `review-restated-value` is a second case of the review row (link, don't restate): a brain whose accepted `docs/pump-controller.md` states two values of the pump controller, and two docs in review that restate them without a link: a note with one value right and the other off by one digit, and a `type: decision` that quotes the rating it was based on, which differs. It checks that the run searches with `km search` (the `regex` on the trace that `lookup-all-brains` uses; it checks the method, since the rule names `km search`, and fails a run that finds the home with grep), that the reply names the home's file and line and tags a finding with its origin (`regex` graders), and (`llm` graders) that the disagreeing figure is blocking, the matching one is a non-blocking request to link, and the decision, which the reply must cover, is not blocked on its figure. `pr-review-comments` is a second case of the `pr` row: an open PR whose unresolved review threads the user saved to a file, which the flow verifies, fixes, folds and answers, with replies and resolves to post after the push. The threads come from a file because a stand-in `gh` cannot be put in front of the real one: the session keeps the operator's PATH, and neither a `gh` in the run's home nor a PATH in the workspace's `.claude/settings.json` got ahead of it. Without the plugin the model works the threads well enough too (two of its three `llm` graders pass in the baseline); `folds-the-fix` is the one the skill decides. It measures neither posting nor the OK-before-posting rule: nothing is posted. Every case has one grader on the flow's key step (the `km` command it runs, the file it writes, the line it answers). Graders are `tool_used` and `regex`, except the `llm` graders in `fix-in-mounted-brain`, `lookup-all-brains`, `review-restated-value`, `save-generated`, `pr-review-comments` and `promote-owner-off-roster` (those of the latter two judge the trace, not the reply).
Each case whose row names a reference file has a `reads-reference` grader (that file was read); `help` and `save content` name only the core, so they have none. `save-cites` is a second case of the save row: a note that links a SharePoint file with a synced copy at hand, which the save flow cites with `km cite add` before the commit. `save-generated` is a third: a note with an SVG plotted from a local measurement export, which the save flow commits together with the script that draws it and a line on how to regenerate it. Its fixture brain lacks the rule in CONVENTIONS.md, like a brain set up before it, so the case measures the skill alone; the model mostly keeps the script without the plugin too (baseline 0.67 and 1.00 in two runs), so it guards against a regression rather than showing a lift. `save-owner` and `save-owner-named` are two more cases of the save row, in a team brain (`team_brain` in `lib/brain.sh`): a note saved without naming an owner gets `owner:` the author's initials, one where the user names someone else gets theirs and keeps the author, and the reply says who owns it; the graders read the doc the run leaves at the path the prompt names. `promote-owner` and `promote-owner-off-roster` are cases of the `promote` row in a team brain with an `owners:` roster: an author on it becomes the promoted doc's owner (the grader reads the file the run leaves); an author off it makes `km promote` refuse, and the run must then pass an `--owner` from the roster or ask whom to name, never edit the roster or write the doc by hand (an `llm` grader on the trace, and the roster line is checked to be unchanged); `promote-owner` also has a `reads-reference` grader, the off-roster case none, since a run may ask before it reads further. Measured without the plugin (3 runs each): `save-owner` 0.67 and `promote-owner` 0.22 against 1.00 with it; `save-owner-named` and `promote-owner-off-roster` pass either way (the model follows a named owner, and reads the roster and asks), so those two guard against a regression rather than show a lift. `lookup-all-brains` is a second case of the question row: a brain with two mounted brains (`brain_with_two_peers` in `lib/brain.sh`, its ownership table generated with the mounts) and a fact only in the second mount's merged doc, asked without `@`; it checks that the run starts with `km search` (a `regex` on the trace for its coverage or result line), answers the fact with a `[gamma@<sha>]` citation, and (an `llm` grader) names the open pull requests as not searched (the fixture's brains have no GitHub remote, so km search reports them NOT SEARCHED) rather than saying nothing is in review. `lookup-question` allows Bash so that it can run `km search` too. `review-restated-value` is a second case of the review row (link, don't restate): a brain whose accepted `docs/pump-controller.md` states two values of the pump controller, and two docs in review that restate them without a link: a note with one value right and the other off by one digit, and a `type: decision` that quotes the rating it was based on, which differs. It checks that the run searches with `km search` (the `regex` on the trace that `lookup-all-brains` uses; it checks the method, since the rule names `km search`, and fails a run that finds the home with grep), that the reply names the home's file and line and tags a finding with its origin (`regex` graders), and (`llm` graders) that the disagreeing figure is blocking, the matching one is a non-blocking request to link, and the decision, which the reply must cover, is not blocked on its figure. `review-ownership-table` is a third case of the review row: the `review-restated-value` brain plus `docs/pump-controller-ratings.md`, which a hand-written row of the `## Ownership` table in CONVENTIONS.md names as the home of the pump controller's ratings, while `docs/pump-controller.md`, which `km search` also finds, states them too; `/km review` of the wiring note must read CONVENTIONS.md, name the table's home with its line (`names-the-table-home`, a `regex`) and the Ownership row it took it from (`names-the-ownership-row`: CONVENTIONS.md with a line, or the words ownership table, row or section), and tag the finding with its origin. `pr-review-comments` is a second case of the `pr` row: an open PR whose unresolved review threads the user saved to a file, which the flow verifies, fixes, folds and answers, with replies and resolves to post after the push. The threads come from a file because a stand-in `gh` cannot be put in front of the real one: the session keeps the operator's PATH, and neither a `gh` in the run's home nor a PATH in the workspace's `.claude/settings.json` got ahead of it. Without the plugin the model works the threads well enough too (two of its three `llm` graders pass in the baseline); `folds-the-fix` is the one the skill decides. It measures neither posting nor the OK-before-posting rule: nothing is posted. Every case has one grader on the flow's key step (the `km` command it runs, the file it writes, the line it answers). Graders are `tool_used` and `regex`, except the `llm` graders in `brains-list-remove`, `fix-in-mounted-brain`, `lookup-all-brains`, `review-restated-value`, `save-generated`, `pr-review-comments` and `promote-owner-off-roster` (those of the latter two and of `brains-list-remove` judge the trace, not the reply).

A grader on a `km` command (`runs-km-*`) checks that km ran, not how the model typed it: it is a `regex` on the `trace` that matches a line km itself prints (`repin: <doc> pins ...`, `km doctor: <root>`, `ERRORS: <n>`, ...) at the start of a line of a tool result. The model calls km as `km`, as the full path to `bin/km` or through a variable it set (`$KM repin`), and the command text also turns up in descriptions, commit messages and `echo`s, so a match on the Bash input passes when km never started and fails when it ran. Where a command prints several lines, the pattern accepts more than one of them (`km doctor:` or its closing line, `ERRORS:` or `WARNINGS:`), so output cut by `| head` or `| tail` usually still passes. A run whose output was thrown away (`>/dev/null`, `km sync --quiet` with nothing to do, a `| tail` that keeps only the findings under `WARNINGS:`) fails the grader, and so does a refused edit, promote or stub that forwards km validate's report: that is not a validate run of its own. A change to what one of these commands prints changes its grader too, and so does a change to how `claude plugin eval` writes a tool result into the trace (`"tool_use_result":` followed by the output as a JSON string, or by an object whose `stdout` comes first).

The git steps are graded by what git did too. `finds-the-branch-docs` (`pr`) matches a line git prints about the branch's doc, `inbox/thermal-derating.md`: its `--stat` line, its `diff --git` header, or its `--name-status`, `--numstat` or `--raw` line; it depends on the trace format like the `runs-km-*` graders. A bare path is not accepted, since `git ls-files`, `ls` and `grep -l` print it too, so a run that only used `git diff --name-only` fails. `removes-the-submodule` (`brains-list-remove`) checks the state the run leaves behind: `.git/index` no longer holds `brains/peer`. A removal passes however its output was handled (`-q`, a redirect, a pipe); a `git rm -n`, a `deinit` alone or a failed `git rm` fails. It relies on the index keeping full paths (index format 2 or 3, as `git init` writes it; format 4 or a split index would let it pass on any run).
The git steps are graded by what git did too. `finds-the-branch-docs` (`pr`) matches a line git prints about the branch's doc, `inbox/thermal-derating.md`: its `--stat` line, its `diff --git` header, or its `--name-status`, `--numstat` or `--raw` line; it depends on the trace format like the `runs-km-*` graders. A bare path is not accepted, since `git ls-files`, `ls` and `grep -l` print it too, so a run that only used `git diff --name-only` fails. `stages-conventions` (`brains-list-remove`, an `llm` grader on the trace) checks that the run regenerates the mounted-repositories table in CONVENTIONS.md after `git rm` and stages it with the removal, for one commit (`brain_with_peer` generates the row in the mount commit, so the table starts fresh). A run whose sandbox refuses to write `.gitmodules` cannot commit the removal; it passes when both are staged and the reply says why it stopped. `removes-the-submodule` (`brains-list-remove`) checks the state the run leaves behind: `.git/index` no longer holds `brains/peer`. A removal passes however its output was handled (`-q`, a redirect, a pipe); a `git rm -n`, a `deinit` alone or a failed `git rm` fails. It relies on the index keeping full paths (index format 2 or 3, as `git init` writes it; format 4 or a split index would let it pass on any run).

Run from the plugin root: `claude plugin eval . --scaffold --no-publish --ablation none --allow-tools Bash Write Edit`; `--tag batch2` selects the nine dispatch cases, and the no-plugin baseline (`--ablation with-without`) is worth its cost only when a grader changes. `results/` is ignored.

Expand Down
Loading