docs: document the uv-pinned apm setup and full-identity allow keys
README: uv replaces the global apm as a prerequisite, setup starts with `uv sync --frozen`, and the offline note names both one-time steps. gates.md: the apm hooks run through scripts/lib/apm.sh with plain --frozen (and why the gates, unlike the SessionStart hook, keep the sync), and check-executables-allow-sync expects the full package identity apm 0.39 matches on. Refs: #271 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
This commit is contained in:
1 parent
e87bd67c1f
commit
a48f0fdf5b
2 files changed
+42
-12
No files matched your search
@@ -36,7 +36,7 @@ Install all of these before setting up. Each one is a hard dependency of a git h
|
|||||||
|
|
||||||
| Tool | Why | Install |
|
| Tool | Why | Install |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `apm` CLI | Two pre-push hooks shell out to it (`apm-audit-ci` and `apm-pack-check-clean`) | The `apm-install` skill, or `curl -sSL https://aka.ms/apm-unix \| sh`. Verify with `apm --version` |
|
| `uv` | Runs this repo's pinned apm. The root `pyproject.toml` pins `apm-cli==0.39.3` and `uv.lock` locks it (ADR-0034); the `apm-audit-ci` and `apm-pack-check-clean` pre-push hooks run it as `uv run --frozen apm` through `scripts/lib/apm.sh`, and fail below apm 0.39.2 | https://docs.astral.sh/uv/getting-started/installation/. A global `apm` is not needed and not used: a bare `apm` here may be an older one that refuses the v4 `apm.lock.yaml` |
|
||||||
| `python3` + PyYAML | Required by `scripts/skill-size-check.sh` (the `skill-size-check` pre-commit hook) and `scripts/check-skill-version-bump.sh` (the `check-skill-version-bump` pre-push hook), which both parse YAML frontmatter | `python3` is usually present — pre-commit is itself a Python application. `pip install pyyaml` if the hook reports PyYAML missing |
|
| `python3` + PyYAML | Required by `scripts/skill-size-check.sh` (the `skill-size-check` pre-commit hook) and `scripts/check-skill-version-bump.sh` (the `check-skill-version-bump` pre-push hook), which both parse YAML frontmatter | `python3` is usually present — pre-commit is itself a Python application. `pip install pyyaml` if the hook reports PyYAML missing |
|
||||||
| `vale` | Required by the `vale-audit-prefilter-skill` / `-agent` pre-commit hooks, and by the `test-vale-wrap.sh` suite that `run-tests --strict` runs at pre-push | `brew install vale` (macOS), `snap install vale` (Linux), `choco install vale` (Windows), or https://vale.sh/docs/vale-cli/installation/ |
|
| `vale` | Required by the `vale-audit-prefilter-skill` / `-agent` pre-commit hooks, and by the `test-vale-wrap.sh` suite that `run-tests --strict` runs at pre-push | `brew install vale` (macOS), `snap install vale` (Linux), `choco install vale` (Windows), or https://vale.sh/docs/vale-cli/installation/ |
|
||||||
| `claude` CLI | Required by the `validate-marketplace` pre-push hook | Claude Code |
|
| `claude` CLI | Required by the `validate-marketplace` pre-push hook | Claude Code |
|
||||||
@@ -51,14 +51,19 @@ Two notes worth reading before you skip one:
|
|||||||
Run these in order, from the repo root.
|
Run these in order, from the repo root.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 1. Deploy this repo's own skills and agents
|
# 1. Install the pinned apm into .venv/ (gitignored)
|
||||||
apm install
|
uv sync --frozen
|
||||||
|
|
||||||
# 2. Install the git hooks — all three stages
|
# 2. Deploy this repo's own skills and agents
|
||||||
|
uv run --frozen apm install
|
||||||
|
|
||||||
|
# 3. Install the git hooks — all three stages
|
||||||
pre-commit install -t pre-commit -t commit-msg -t pre-push
|
pre-commit install -t pre-commit -t commit-msg -t pre-push
|
||||||
```
|
```
|
||||||
|
|
||||||
**`apm install`** deploys the plugins root `apm.yml` lists into `.claude/skills/` and `.claude/agents/`. Both are gitignored install output, *not* authoring source — `plugins/<name>/.apm/` remains the only place to edit. It needs the network and materializes `apm_modules/` (which stays gitignored).
|
**`uv sync --frozen`** installs the apm that `uv.lock` pins into `.venv/`. Every apm command in this repo runs as `uv run --frozen apm ...`.
|
||||||
|
|
||||||
|
**`apm install`** deploys the plugins root `apm.yml` lists into `.claude/skills/` and `.claude/agents/`. Both are gitignored install output, *not* authoring source — `plugins/<name>/.apm/` remains the only place to edit. Both steps need the network once, and `apm install` materializes `apm_modules/` (which stays gitignored).
|
||||||
|
|
||||||
**Git hooks** must be wired for **all three stages**. This repo's `.pre-commit-config.yaml` has no `default_install_hook_types`, so a plain `pre-commit install` silently skips `commit-msg` (Conventional Commits) and `pre-push` (the full gate) — the `-t` flags above are not optional. The `pc-run` skill handles this and the troubleshooting around it, if you would rather not remember the flags.
|
**Git hooks** must be wired for **all three stages**. This repo's `.pre-commit-config.yaml` has no `default_install_hook_types`, so a plain `pre-commit install` silently skips `commit-msg` (Conventional Commits) and `pre-push` (the full gate) — the `-t` flags above are not optional. The `pc-run` skill handles this and the troubleshooting around it, if you would rather not remember the flags.
|
||||||
|
|
||||||
@@ -92,7 +97,7 @@ pre-commit run --hook-stage pre-push --all-files
|
|||||||
|
|
||||||
See [`docs/spec/gates.md`](docs/spec/gates.md) for what each hook enforces and why.
|
See [`docs/spec/gates.md`](docs/spec/gates.md) for what each hook enforces and why.
|
||||||
|
|
||||||
**Offline?** No pre-push hook needs the network **once `apm install` has populated `apm_modules/`**. Root `apm.yml`'s marketplace has no remote package entries (the last one, `mattpocock-skills`, was removed), so `apm-pack-check-clean` resolves everything from local sources, and `apm-audit-ci`'s install-replay is cache-only against a populated install. On a **fresh clone** there is no cache: `apm-audit-ci`'s `deployed-files-present` fails outright, and its `drift` and `config-consistency` checks clone from the holocron remote. The offline guarantee is a property of a populated `apm_modules/`, not of the hook set — run `apm install` once on a new checkout and it holds from then on.
|
**Offline?** No pre-push hook needs the network **once `uv sync --frozen` and `apm install` have each run once** (ADR-0034). Root `apm.yml`'s marketplace has no remote package entries (the last one, `mattpocock-skills`, was removed), so `apm-pack-check-clean` resolves everything from local sources, and `apm-audit-ci`'s install-replay is cache-only against a populated install. On a **fresh clone** there is no cache: `apm-audit-ci`'s `deployed-files-present` fails outright, and its `drift` and `config-consistency` checks clone from the holocron remote. The offline guarantee is a property of a populated `apm_modules/`, not of the hook set — run `uv sync --frozen` and `uv run --frozen apm install` once on a new checkout and it holds from then on.
|
||||||
|
|
||||||
## Editing plugin content
|
## Editing plugin content
|
||||||
|
|
||||||
|
|||||||
+31
-6
@@ -1164,8 +1164,18 @@ Verified: a malformed dependency entry passes
|
|||||||
`apm pack --check-versions --check-clean --dry-run` and fails `apm audit --ci` in that package's
|
`apm pack --check-versions --check-clean --dry-run` and fails `apm audit --ci` in that package's
|
||||||
directory. Costs ~0.5s per package.
|
directory. Costs ~0.5s per package.
|
||||||
|
|
||||||
**apm runs with git's repo-locating env scrubbed.** Both apm hooks source
|
**Both apm hooks run the repo-pinned apm.** They source `scripts/lib/apm.sh`, the one place the
|
||||||
`scripts/lib/clean-git-env.sh` before calling `apm`, which unsets `GIT_DIR`, `GIT_WORK_TREE`,
|
invocation is spelled: `uv run --project <repo root> --frozen apm` (ADR-0034). `--project` comes
|
||||||
|
from the helper's own location, so it names the repo root even when apm runs inside
|
||||||
|
`plugins/<name>/`. Each hook first checks the resolved apm's version and fails, naming
|
||||||
|
`uv sync --frozen` as the fix, below 0.39.2. The gates keep plain `--frozen`, without the
|
||||||
|
SessionStart hook's `--no-sync --offline`: once `uv sync --frozen` has run, the sync it implies is a
|
||||||
|
no-op that needs no network, and after a pull that moves the pin it brings `.venv/` to the new pin
|
||||||
|
instead of letting a gate certify the tree with a stale apm. `tests/test-apm-gate-invocation.sh`
|
||||||
|
pins the command, the `--project` root, the scrub and the version floor with a fake `uv`.
|
||||||
|
|
||||||
|
**apm runs with git's repo-locating env scrubbed.** Sourcing `scripts/lib/apm.sh` also sources
|
||||||
|
`scripts/lib/clean-git-env.sh` before anything calls `apm`, which unsets `GIT_DIR`, `GIT_WORK_TREE`,
|
||||||
`GIT_INDEX_FILE`, `GIT_OBJECT_DIRECTORY`, `GIT_COMMON_DIR`, `GIT_PREFIX` and
|
`GIT_INDEX_FILE`, `GIT_OBJECT_DIRECTORY`, `GIT_COMMON_DIR`, `GIT_PREFIX` and
|
||||||
`GIT_IMPLICIT_WORK_TREE`. It deliberately keeps the config-passing vars (`GIT_CONFIG_PARAMETERS`,
|
`GIT_IMPLICIT_WORK_TREE`. It deliberately keeps the config-passing vars (`GIT_CONFIG_PARAMETERS`,
|
||||||
`GIT_CONFIG_COUNT`), because they carry `git -c` overrides apm's remote clones may need. The reason: `git push` from a **linked worktree** exports an
|
`GIT_CONFIG_COUNT`), because they carry `git -c` overrides apm's remote clones may need. The reason: `git push` from a **linked worktree** exports an
|
||||||
@@ -1256,6 +1266,21 @@ among them, which is the state ADR-0026 rules out rather than a second scan wort
|
|||||||
|
|
||||||
### `check-executables-allow-sync`
|
### `check-executables-allow-sync`
|
||||||
|
|
||||||
|
**Keys are full package identities (apm 0.39, #271).** apm 0.39.3 matches a grant on the package
|
||||||
|
identity `<host>/<owner>/<repo>/<path>`, as `apm approve --list` prints it, e.g.
|
||||||
|
`git.rkdr.net/Mortis/Holocron/plugins/kyberforge`. The bare `kyberforge#<version>` key that 0.28.0
|
||||||
|
matched no longer matches: the first 0.39 install parks the hooks, rewrites `.claude/settings.json`
|
||||||
|
without them, and root `apm audit --ci` still passes (spike #269, on #268). So the gate now derives
|
||||||
|
each expected key from root `apm.yml`'s own `git:` + `path:` dependency entry for the plugin (URL
|
||||||
|
without scheme, user or `.git`, then the path), appends `#<version>`, and fails a bare key with a
|
||||||
|
message saying why. A shipping plugin with no such entry fails, since no key can be derived. The
|
||||||
|
`#<version>` suffix is still stripped before apm matches, so the grant stays version-blind and the
|
||||||
|
version half stays a repo-level record. The grants are type-level (`hooks: true`), not
|
||||||
|
content-pinned: `apm approve` would pin content, strip the block's comments, and park the hook on
|
||||||
|
every script edit until someone approves again.
|
||||||
|
|
||||||
|
The rest of this section describes the 0.28.0 matching that the version-blind behaviour comes from.
|
||||||
|
|
||||||
apm gates a package's `hooks/` and `bin/` on root `apm.yml`'s `executables.allow`
|
apm gates a package's `hooks/` and `bin/` on root `apm.yml`'s `executables.allow`
|
||||||
(`apm_cli/security/executables.py`). `is_package_approved` is itself an exact dictionary lookup, but
|
(`apm_cli/security/executables.py`). `is_package_approved` is itself an exact dictionary lookup, but
|
||||||
it is never called with a single key: `install/exec_gate.py` builds a candidate list that includes
|
it is never called with a single key: `install/exec_gate.py` builds a candidate list that includes
|
||||||
@@ -1276,10 +1301,10 @@ It covers every plugin that ships executables, not one named package. The script
|
|||||||
`plugins/*/` and treats a plugin as shipping executables when `plugins/<name>/.apm/hooks/` or
|
`plugins/*/` and treats a plugin as shipping executables when `plugins/<name>/.apm/hooks/` or
|
||||||
`plugins/<name>/bin/` exists — kyberforge ships both, delivery ships a guard hook. For each one it
|
`plugins/<name>/bin/` exists — kyberforge ships both, delivery ships a guard hook. For each one it
|
||||||
reads `name:` and `version:` from `plugins/<name>/apm.yml` and asserts root `apm.yml` carries the
|
reads `name:` and `version:` from `plugins/<name>/apm.yml` and asserts root `apm.yml` carries the
|
||||||
`<name>#<version>` key under `executables.allow`. Keys use the package name, so a `name:` that
|
`<identity>#<version>` key under `executables.allow`. The `name:` must equal the directory name, so
|
||||||
differs from the directory name fails rather than being guessed at. Every failing package is
|
one that differs fails rather than being guessed at. Every failing package is
|
||||||
reported in one run, each with its own Why/Fix block; a stale `<name>#<other-version>` key is quoted
|
reported in one run, each with its own Why/Fix block; a stale `<identity>#<other-version>` key, or a
|
||||||
back as "found instead". It also fails on a shipping plugin with no `apm.yml`, a missing `version:`,
|
bare `<name>#...` key, is quoted back as "found instead". It also fails on a shipping plugin with no `apm.yml`, a missing `version:`,
|
||||||
a missing root `apm.yml`, or no `executables.allow` mapping. A repo with no executable-shipping
|
a missing root `apm.yml`, or no `executables.allow` mapping. A repo with no executable-shipping
|
||||||
plugin at all is the one no-op, and a plugin with neither directory needs no key.
|
plugin at all is the one no-op, and a plugin with neither directory needs no key.
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user