The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(pm): `hermes pm lock` checks a stale uv.lock quietly
ethernetb4ad4b2c26ac
diff --git a/pm/build_operations.py b/pm/build_operations.pyindex 52199bef7e8..c468a4d481b 100644--- a/pm/build_operations.py+++ b/pm/build_operations.py@@ -15,8 +15,14 @@ from pm.package import InstallErrordef check_project_lock(source: Path, *, python: Path | None = None, cache: Path | None = None,env: Mapping[str, str] | None = None, offline: bool = False, explicit: bool = False,+ quiet: bool = False,) -> None:- """Reject a missing or stale lock without rewriting source or creating a venv."""+ """Reject a missing or stale lock without rewriting source or creating a venv.++ ``quiet`` captures uv's output instead of reporting it: for a caller that+ expects a stale lock and says so itself, the red failure tail is noise.+ The error still carries uv's message.+ """from pm.environment import managed_environmentfrom pm.operations import _require_install_allowed@@ -28,7 +34,7 @@ def check_project_lock(environment = managed_environment(source / ".venv", python=Path(python) if python is not None else None,cache=Path(cache) if cache is not None else None, env=env,- offline=offline, explicit=explicit, output=sys.stderr,+ offline=offline, explicit=explicit, output=None if quiet else sys.stderr,)environment.check_lock(source)diff --git a/pm/cli.py b/pm/cli.pyindex 9c1b3d3462b..e9e51534b21 100644--- a/pm/cli.py+++ b/pm/cli.py@@ -38,13 +38,14 @@ def _relock_project(root: Path) -> int:"""import pm+ print("→ Checking uv.lock…", flush=True)try:- pm.check_project_lock(root, explicit=True)+ # Quiet: stale is the expected case here, so uv's failure tail would+ # read like an error. An unreachable index fails the relock below too,+ # and that error names the index knobs.+ pm.check_project_lock(root, explicit=True, quiet=True)except InstallError:- # Stale is the expected case, and the check's own "✗ … failed" tail- # reads like an error, so say what happens next. An unreachable index- # fails the relock below too, and that error names the index knobs.- print("uv.lock is out of date with pyproject.toml; relocking")+ print("uv.lock is out of date with pyproject.toml; relocking", flush=True)else:print("✓ uv.lock is already current with pyproject.toml; nothing written")return 0diff --git a/pm/client.py b/pm/client.pyindex fb51e7f6e9a..9bb89d517ca 100644--- a/pm/client.py+++ b/pm/client.py@@ -342,10 +342,11 @@ def venv_is_current(*, extras: list[str] | None = None, plugins: Members | Candidef check_project_lock(source: Path, *, python: Path | None = None, cache: Path | None = None,env: Mapping[str, str] | None = None, offline: bool = False,- explicit: bool = False) -> None:+ explicit: bool = False, quiet: bool = False) -> None:_python_operation("check_project_lock", {"source": Path(source), "python": python, "cache": cache,"env": dict(env) if env is not None else None, "offline": offline, "explicit": explicit,+ "quiet": quiet,})diff --git a/tests/pm/test_project_relock.py b/tests/pm/test_project_relock.pyindex d9a141998de..1335fe3e99a 100644--- a/tests/pm/test_project_relock.py+++ b/tests/pm/test_project_relock.py@@ -39,6 +39,8 @@ def test_relock_writes_nothing_when_current_and_names_new_opt_in_extras(tmp_pathdef check(source, **kw):assert (source, kw.get("explicit")) == (tmp_path, True)+ # A stale lock is this command's expected case: no red failure report.+ assert kw.get("quiet") is Trueif stale:raise InstallError("venv", "The lockfile at `uv.lock` needs to be updated")@@ -57,6 +59,7 @@ def test_relock_writes_nothing_when_current_and_names_new_opt_in_extras(tmp_path# Relocking never syncs an environment; activation owns that.assert relocks == [(tmp_path, {"explicit": True})]out = capsys.readouterr().out+ assert "out of date" in out and "✗" not in outassert "activate" in out# beta is new and outside [all]; alpha was already locked and is in [all].assert "all,beta" in out and "alpha" not in out