Add a dispatch on where apm comes from: a repo that pins apm with uv, a repo that wants the pin, or a global install. The new uv-pin reference covers the pyproject.toml dev group, the committed uv.lock, running as uv run --frozen apm, the one-time online sync, upgrading the pin, and why uvx and uv tool are not used. It closes with a worked example of one pinned and one unpinned repo. Raise the pip floor to Python 3.11, which apm requires since 0.36.0, add the package-manager installs, and note the 0.39.2 minimum for v4 locks. Bump metadata.version to 1.0.2. Refs: #273 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
4.3 KiB
source_keys
| source_keys | |||
|---|---|---|---|
|
Pinning apm per repo with uv
Reached from SKILL.md Step 1. apm has no apm.yml field for a minimum apm version, and upstream
advises pinning apm outside the manifest. A uv pin gives every checkout of the repo the same apm
and the same transitive dependencies, whatever is installed globally. apm's docs do not describe
this method. It was tested with uv 0.11.24 and apm-cli 0.39.3.
Set up the pin
-
Add this
pyproject.tomlat the repo root:[project] name = "<repo>-tooling" version = "0.0.0" requires-python = ">=3.11" dependencies = [] [tool.uv] package = false [dependency-groups] dev = ["apm-cli==0.39.3"]- There is no
[build-system], andpackage = falsekeeps uv from ever building the project, so uv installs only thedevgroup.uv syncinstalls that group by default. >=3.11is apm-cli's own floor.- Pin with
==. Choose 0.39.2 or later. Older versions refuse a lockfile that 0.39.2 or later rewrote. - If the repo already has a
pyproject.tomlfor a real Python project, addapm-cli==<version>to a dependency group there. Do not addpackage = falseto a project that builds.
- There is no
-
Run
uv lock. Commitpyproject.tomlanduv.lock, and gitignore.venv/. The lock hashes apm-cli and every transitive dependency. -
On each checkout, run
uv sync --frozenonce. The first sync on a machine needs the network, because a cold uv cache cannot download wheels offline. -
Run
uv run --frozen apm install. The first install with apm 0.39 or later also needs the network once, to record commit verdicts. -
Check the version with
uv run --frozen apm --version.
Run it
- Spell every apm command in the repo as
uv run --frozen apm <args>.--frozenruns fromuv.lockas committed and never re-resolves it. It still syncs the environment to the lock first. After the one-time sync that costs nothing, and when a pull moves the pin it brings the environment up to the new version. - In a script that may run from a subdirectory, add
--project <repo root>. - Offline,
uv run --frozen --offline apm …works once the uv cache is warm, even with no.venv. With a cold cache it fails. - A hook with a short timeout must never sync. Use
--no-sync --offline, and check first that.venvexists, because even--no-synccreates an empty one.
Upgrade the pin
Change the == version, then run uv lock and uv sync --frozen, and commit both files. Then
follow apm's own upgrade notes for the versions crossed. Every machine and CI job that runs
apm install or apm audit --ci on the repo's lockfile needs an apm at least as new as the one
that last wrote it. apm audit --ci fails on lockfile fields it does not know.
Why not uvx or uv tool
uvx apm-cli@<version>pins only apm-cli. Its transitive dependencies float between runs and nothing is locked. A cache warmed byuv addalso did not satisfyuvx --offline.uv tool install apm-cliis machine-global, the same drift as a global pipx install under another name.
uv installs the apm tool and nothing else. Packages, skills and agents still come from
apm install.
Worked example: one pinned repo, one unpinned
Repo A pins apm. The user asks to install the repo's apm dependencies. The root
pyproject.toml has dev = ["apm-cli==0.39.3"], and uv.lock sits beside it.
- Detect the pin:
grep -q '"apm-cli' pyproject.toml && test -f uv.lock. - Run
uv sync --frozen, the first time on this checkout. - Run
uv run --frozen apm --version. It prints 0.39.3. - Run
uv run --frozen apm install.
Wrong moves: a bare apm install, because the PATH apm may be 0.28.0, which refuses the v4 lock.
pipx upgrade apm-cli, because that changes every repo on the machine. uvx [email protected] install, because its dependencies are unlocked.
Repo B does not pin apm. It has no pyproject.toml naming apm-cli, or no uv.lock.
- Run
apm --version. If nothing answers, install apm globally (SKILL.mdStep 2). - If apm is older than the repo's lock needs (0.39.2 or later for a lock 0.39.2 or later wrote), upgrade the global apm, or propose a per-repo pin. Do not add the pin unasked: it is a repo change the user should approve.
- Run
apm install.