The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(config): config unset terminal.singularity_image still removes its .env copy
Tekniuma71a76ff65fc
diff --git a/hermes_cli/config.py b/hermes_cli/config.pyindex 7c6158868fd..517f0da4205 100644--- a/hermes_cli/config.py+++ b/hermes_cli/config.py@@ -3602,8 +3602,7 @@ def unset_config_value(key: str):if _is_env_config_key(key):# Unified lifecycle: also prunes env-seeded credential_pool entries and model-cache rows so- # the provider is fully removed instead of left resurrectable.- # See #51071.+ # the provider is fully removed instead of left resurrectable (#51071).from hermes_cli.credential_lifecycle import remove_provider_env_credentialtry:@@ -3639,7 +3638,8 @@ def unset_config_value(key: str):if legacy_key:removed = _unset_nested(user_config, legacy_key) or removed- env_var = terminal_config_env_var_for_key(key)+ from hermes_cli.left_core_migration import RETIRED_TERMINAL_ENV_COPIES+ env_var = terminal_config_env_var_for_key(key) or RETIRED_TERMINAL_ENV_COPIES.get(key)if env_var and key != "terminal.cwd":removed = remove_env_value(env_var) or removeddiff --git a/hermes_cli/left_core_migration.py b/hermes_cli/left_core_migration.pyindex e7344482547..1daf8eb2a22 100644--- a/hermes_cli/left_core_migration.py+++ b/hermes_cli/left_core_migration.py@@ -39,6 +39,11 @@ from hermes_cli.memory_provider_migration import (logger = logging.getLogger(__name__)+# ``terminal.*`` keys ``hermes config set`` also wrote to ``.env`` while core shipped their backend. The+# plugin still reads that copy as a fallback, so ``hermes config unset`` keeps removing it: otherwise the+# old value returns instead of the default.+RETIRED_TERMINAL_ENV_COPIES = {"terminal.singularity_image": "TERMINAL_SINGULARITY_IMAGE"}+def _read_config(home: Path) -> dict:import utilsdiff --git a/tests/hermes_cli/test_left_core_singularity.py b/tests/hermes_cli/test_left_core_singularity.pyindex 2a15b3055a0..c2c8c835e5f 100644--- a/tests/hermes_cli/test_left_core_singularity.py+++ b/tests/hermes_cli/test_left_core_singularity.py@@ -135,3 +135,16 @@ def test_without_the_plugin_the_backend_error_names_the_install_command(tmp_pathwith pytest.raises(ValueError, match="hermes plugins install singularity"):backends._create_environment("singularity", image="", cwd="/root", timeout=10)assert lcm.terminal_backend_install_hint("acmebox") == ""+++def test_config_unset_removes_the_env_copy_core_used_to_write(tmp_path, monkeypatch):+ # While core shipped the backend, `hermes config set terminal.singularity_image` also wrote+ # TERMINAL_SINGULARITY_IMAGE to .env, and the plugin still falls back to it: unset must remove both,+ # or the old image comes back instead of the default.+ home = _home(tmp_path, env="TERMINAL_SINGULARITY_IMAGE=docker://old:1\n",+ config="terminal:\n backend: singularity\n singularity_image: docker://old:1\n")+ monkeypatch.setenv("HERMES_HOME", str(home))+ from hermes_cli.config import unset_config_value+ unset_config_value("terminal.singularity_image")+ assert "singularity_image" not in (home / "config.yaml").read_text(encoding="utf-8")+ assert "TERMINAL_SINGULARITY_IMAGE" not in (home / ".env").read_text(encoding="utf-8")