Files
Holocron/plugins/kyberforge/.apm/skills/apm-install/references/uv-pin.md
T
Defame1297andClaude Opus 5.5 e6d680a4c5 fix(kyberforge): apply the #273 review to the apm 0.39.3 refresh
- apm-workflow and apm-orchestrate always pass --project to uv run,
  because uv run outside the project silently runs the PATH apm. The
  agent now checks that the reported version equals the pin, or is
  0.39.2 or later where nothing pins it, not only that it exits 0.
- A pin is a quoted apm-cli or apm_cli requirement plus a uv.lock,
  matching the SessionStart hook, in apm-install, uv-pin.md and
  apm-workflow.
- uv-pin.md spells the hook's exact invocation and its environment
  check, and says scripts always pass --project.
- instructions-author and its research note: a Claude rule leaves
  .claude/rules/ only when compile actually wrote it into AGENTS.md;
  install-then-compile dedups it.
- prompt-author: Kiro strips every key with a warning, not silently.
- Record the 0.39.3 executables findings in approvals-and-executables.md
  and the output-profile and type-routing facts in cli-reference.md, and
  cite those digests.
- forge's routing table notes that Kiro gets the body only.

Refs: #273

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
2026-12-02 12:35:19 +00:00

4.7 KiB

source_keys
source_keys
apm-cli-0-39-3-uv-experiments
apm-v0-39-3-docs
pypi-apm-cli

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

  1. Add this pyproject.toml at 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], and package = false keeps uv from ever building the project, so uv installs only the dev group. uv sync installs that group by default.
    • >=3.11 is 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.toml for a real Python project, add apm-cli==<version> to a dependency group there. Do not add package = false to a project that builds.
  2. Run uv lock. Commit pyproject.toml and uv.lock, and gitignore .venv/. The lock hashes apm-cli and every transitive dependency.

  3. On each checkout, run uv sync --frozen once. The first sync on a machine needs the network, because a cold uv cache cannot download wheels offline.

  4. Run uv run --project . --frozen apm install from the repo root. The first install with apm 0.39 or later also needs the network once, to record commit verdicts.

  5. Check the version with uv run --project . --frozen apm --version.

Run it

  • Spell every apm command in the repo as uv run --project <repo root> --frozen apm <args>. --frozen runs from uv.lock as 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.
  • Scripts always pass --project <repo root>. Without it, uv run from a directory outside the repo finds no project and silently runs the PATH apm. The same happens under a nested pyproject.toml.
  • Offline, uv run --project <repo root> --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. kyberforge's SessionStart hook runs uv run --project <root> --frozen --no-sync --offline apm, after checking that ${UV_PROJECT_ENVIRONMENT:-<root>/.venv} exists, because even --no-sync creates 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 by uv add also did not satisfy uvx --offline.
  • uv tool install apm-cli is 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.

  1. Detect the pin: a quoted apm-cli or apm_cli requirement in pyproject.toml, and a uv.lock beside it: grep -Eq "[\"']apm[-_]cli" pyproject.toml && test -f uv.lock.
  2. Run uv sync --frozen, the first time on this checkout.
  3. Run uv run --project . --frozen apm --version. It prints 0.39.3.
  4. Run uv run --project . --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.

  1. Run apm --version. If nothing answers, install apm globally (SKILL.md Step 2).
  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.
  3. Run apm install.