The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(pm): pm update and pm lock --bump regenerate the installers' bootstrap pins
ethernet562c9df25126
diff --git a/pm/cli.py b/pm/cli.pyindex 55eb1dc771f..185ea94b9cb 100644--- a/pm/cli.py+++ b/pm/cli.py@@ -143,7 +143,7 @@ def _pin_tool(args) -> int:lockfile.set_pin(args.name, args.version, artifacts)lockfile.save()print(f"pinned {args.name} {args.version} ({len(artifacts)} targets)")- return 0+ return _regenerate_bootstrap_pins(lockfile)def _fmt_bytes(n: int) -> str:@@ -590,6 +590,19 @@ def _sync_venv_step() -> bool:return True+def _regenerate_bootstrap_pins(lockfile) -> int:+ """Splice the new uv and Windows git pins into this checkout's installers.++ curl|sh and irm|iex bootstrap those tools before any checkout exists to read+ the lock, so they carry the pins as generated fragments. A lock outside a+ checkout (a test fixture) feeds no installer.+ """+ script = lockfile.path.parent.parent / "scripts" / "gen-bootstrap-pins.py"+ if not script.is_file():+ return 0+ return subprocess.run([sys.executable, str(script)], timeout=60, check=False).returncode++def _apply_pins(changed: list, lockfile) -> int:if not changed:print("pm update: nothing to update")@@ -616,7 +629,8 @@ def _apply_pins(changed: list, lockfile) -> int:print(f"✓ {d.name} pinned {d.locked or '—'} → {d.version}")if pinned:lockfile.save()- rc = 1 if _install_names(pinned) or not _sync_venv_step() else 0+ fragments = _regenerate_bootstrap_pins(lockfile)+ rc = 1 if _install_names(pinned) or not _sync_venv_step() or fragments else 0else:print("pm update: every pin failed; lockfile untouched")rc = 1diff --git a/tests/pm/test_update_bootstrap_pins.py b/tests/pm/test_update_bootstrap_pins.pynew file mode 100644index 00000000000..0695dcb0d63--- /dev/null+++ b/tests/pm/test_update_bootstrap_pins.py@@ -0,0 +1,55 @@+"""A uv re-pin carries the installers' bootstrap pins with it.++The curl|sh and irm|iex installers bootstrap uv (and Windows git) before any+checkout exists, so they carry those pins as fragments generated from+pm/lock.json. `pm update` and `pm lock --bump` rewrote only the lock: a uv bump+left the installers on the old uv until someone ran scripts/gen-bootstrap-pins.py+by hand, and the bootstrap-installer drift check failed.+"""++import shutil+import subprocess+import sys+from argparse import Namespace+from pathlib import Path++import pytest++from pm import cli+from pm.lock import Lockfile+from pm.store import ALL_TARGETS+from pm.update import Resolved++REPO = Path(__file__).resolve().parents[2]+VERSION = "99.0.0"+++def _update(lock):+ targets = [t for t in ALL_TARGETS if t != "linux-arm64-bionic"]+ decision = Resolved("uv", lock.version("uv"), "semver", version=VERSION,+ per_target=dict.fromkeys(targets, VERSION))+ return cli._apply_pins([decision], lock)+++def _bump(lock):+ return cli.cmd_lock(Namespace(name="uv", version=VERSION))++[email protected]("repin", [_update, _bump], ids=["update", "bump"])+def test_uv_repin_regenerates_installer_pins(repin, tmp_path, monkeypatch):+ for rel in ("scripts/gen-bootstrap-pins.py", "scripts/install.sh", "scripts/install.ps1"):+ (tmp_path / rel).parent.mkdir(exist_ok=True)+ shutil.copy2(REPO / rel, tmp_path / rel)+ shutil.copytree(REPO / "pm", tmp_path / "pm", ignore=shutil.ignore_patterns("__pycache__"))+ lock = Lockfile(tmp_path / "pm" / "lock.json")+ monkeypatch.setattr(cli, "_lockfile", lambda: lock)+ monkeypatch.setattr(cli, "hash_url", lambda url: "0" * 64)+ monkeypatch.setattr(cli, "_install_names", lambda names: 0)+ monkeypatch.setattr(cli, "_sync_venv_step", lambda: True)++ assert repin(lock) == 0+ check = subprocess.run(+ [sys.executable, str(tmp_path / "scripts" / "gen-bootstrap-pins.py"), "--check"],+ capture_output=True, text=True, timeout=60, check=False,+ )+ assert check.returncode == 0, check.stderrdiff --git a/website/docs/reference/package-management.md b/website/docs/reference/package-management.mdindex 14eed929746..38f8f98a0b4 100644--- a/website/docs/reference/package-management.md+++ b/website/docs/reference/package-management.md@@ -548,8 +548,8 @@ not substitutes for an installed application's update mechanism.| Command | Effect ||---|---|| `pm lock` | Relock `uv.lock` from `pyproject.toml`. Changes no environment; writes nothing when the lock is current. |-| `pm lock --bump NAME VERSION` | Resolve and hash supported target artifacts, then write the tool pin to `pm/lock.json`. |-| `pm update [names...]` | Query upstream versions, change tool pins, and install changed tools. |+| `pm lock --bump NAME VERSION` | Resolve and hash supported target artifacts, write the tool pin to `pm/lock.json`, and regenerate the bootstrap pins in `scripts/install.sh` and `scripts/install.ps1`. |+| `pm update [names...]` | Query upstream versions, change tool pins, regenerate the installers' bootstrap pins, and install changed tools. || `pm update --check` | Query without writing. Exit 1 can mean updates exist; inspect output to distinguish an error. || `pm update --target TARGET` | Resolve versions for the specified target. || `pm update --skip-target TARGET` | Leave TARGET's pins unchanged (repeatable), for example `linux-arm64-bionic` while the termux pool lags upstream. Later runs still report the package as current. `pm lock --bump NAME VERSION` re-pins every target at a version, and `pm update --termux` repins a retired `linux-arm64-bionic` row. |