Skip to content

The agent that grows with you

fix(cli): adopt legacy venv hermes wrapper

Gille91986da49641
diff --git a/hermes_cli/_launchers.py b/hermes_cli/_launchers.py
index 2702fef02a2..2ffbad85aff 100644
--- a/hermes_cli/_launchers.py
+++ b/hermes_cli/_launchers.py
@@ -335,6 +335,7 @@ def _owns_launcher(target: Path, root: Path) -> bool:
return False
paths = {str(root / p) for p in (
"hermes", "run_agent.py", "venv/bin/python", "venv/bin/python3",
+ "venv/bin/hermes",
".hermes/bin/hermes", ".hermes/bin/hermes-acp",
)}
# Current store launchers pass this Python bootstrap as one shell argument.
diff --git a/tests/hermes_cli/test_source_launcher_publication.py b/tests/hermes_cli/test_source_launcher_publication.py
index 623b4c9e9b3..40c203a1186 100644
--- a/tests/hermes_cli/test_source_launcher_publication.py
+++ b/tests/hermes_cli/test_source_launcher_publication.py
@@ -238,7 +238,8 @@ def test_materializer_cli_refuses_missing_store_without_publishing(tmp_path, mon
@pytest.mark.platforms("posix")
-def test_boot_migrates_legacy_conveniences_to_selected_runtime(tmp_path, monkeypatch):
[email protected]("legacy_hermes", ["venv-python", "venv-console-script"])
+def test_boot_migrates_legacy_conveniences_to_selected_runtime(tmp_path, monkeypatch, legacy_hermes):
repo, home, interpreter = fixture_tree(tmp_path, monkeypatch)
monkeypatch.setattr(Path, "home", lambda: home)
monkeypatch.setenv("HERMES_INSTALL_ROOT", str(repo))
@@ -246,7 +247,11 @@ def test_boot_migrates_legacy_conveniences_to_selected_runtime(tmp_path, monkeyp
out = home / ".local" / "bin"
out.mkdir(parents=True)
# Old venv and sibling-ACP wrappers, with an unrelated command sharing bin.
- (out / "hermes").write_text(f'#!/bin/sh\nexec "{repo}/venv/bin/python" "{repo}/hermes" "$@"\n', encoding="utf-8")
+ old_wrapper = (f'#!/bin/sh\nexec "{repo}/venv/bin/python" "{repo}/hermes" "$@"\n'
+ if legacy_hermes == "venv-python" else
+ f'#!/usr/bin/env bash\nunset PYTHONPATH\nunset PYTHONHOME\n'
+ f'exec "{repo}/venv/bin/hermes" "$@"\n')
+ (out / "hermes").write_text(old_wrapper, encoding="utf-8")
(out / "hermes-acp").write_text(
'#!/usr/bin/env bash\n# Hermes Agent — ACP launcher (written by `hermes update`).\n'
f'exec "{out}/hermes" acp "$@"\n', encoding="utf-8")
@@ -270,6 +275,24 @@ def test_boot_migrates_legacy_conveniences_to_selected_runtime(tmp_path, monkeyp
assert before == {p: p.stat().st_mtime_ns for p in out.iterdir()}
+def test_legacy_venv_console_wrapper_is_replaced_only_for_its_install(tmp_path):
+ repo = tmp_path / "checkout"
+ out = tmp_path / "bin"
+ out.mkdir()
+ wrapper = out / "hermes"
+ wrapper.write_text(
+ f'#!/usr/bin/env bash\nunset PYTHONPATH\nunset PYTHONHOME\n'
+ f'exec {shlex.quote(str(repo / "venv/bin/hermes"))} "$@"\n', encoding="utf-8")
+
+ assert _launchers._publish_conveniences(repo, out, ("hermes",)) == {wrapper: True}
+ assert str(repo / ".hermes/bin/hermes") in wrapper.read_text(encoding="utf-8")
+
+ foreign = f'#!/bin/sh\nexec {shlex.quote(str(tmp_path / "other/venv/bin/hermes"))} "$@"\n'
+ wrapper.write_text(foreign, encoding="utf-8")
+ assert _launchers._publish_conveniences(repo, out, ("hermes",)) == {}
+ assert wrapper.read_text(encoding="utf-8") == foreign
+
+
def _command_survives_generation_collection(tmp_path, monkeypatch, surface):
from hermes_cli.runtime_state import collect_generations