The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(config): route platform setup values through .env
KoNit-K49bbc738d4b7
diff --git a/hermes_cli/config.py b/hermes_cli/config.pyindex caccbb71b17..5c67f10ae5c 100644--- a/hermes_cli/config.py+++ b/hermes_cli/config.py@@ -945,13 +945,23 @@ _ENV_CONFIG_KEYS = frozenset({'GITHUB_TOKEN', 'HONCHO_API_KEY'})+def _is_platform_env_config_key(key: str) -> bool:+ """Return whether a platform setup value is owned by ``.env``."""+ if "." in key:+ return False+ from hermes_cli.setup_hidden_env import is_setup_hidden_env++ return is_setup_hidden_env(key.upper())++def _is_env_config_key(key: str) -> bool:"""Return whether `hermes config set` routes this key to .env."""if "." in key:return Falsekey_upper = key.upper()return (- key_upper in _ENV_CONFIG_KEYS+ _is_platform_env_config_key(key)+ or key_upper in _ENV_CONFIG_KEYSor key_upper.endswith(('_API_KEY', '_TOKEN', '_SECRET'))or key_upper.startswith('TERMINAL_SSH'))@@ -3517,6 +3527,10 @@ def set_config_value(key: str, value: str, force: bool = False):"(leading, trailing, or doubled '.').")_exit_if_key_managed(key, "set")if _is_env_config_key(key):+ if _is_platform_env_config_key(key):+ save_env_value(key.upper(), value)+ print(f"✓ Set {key} in {get_env_path()}")+ return# Unified lifecycle: also rotates any config.yaml mirror of the old value.from hermes_cli.credential_lifecycle import save_provider_env_credential@@ -3620,6 +3634,11 @@ def unset_config_value(key: str):_exit_if_key_managed(key, "unset")if _is_env_config_key(key):+ if _is_platform_env_config_key(key):+ if not remove_env_value(key.upper()):+ _exit_invalid(f"Config key not set: {key}")+ print(f"✓ Unset {key} from {get_env_path()}")+ return# 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.diff --git a/tests/hermes_cli/test_config_platform_env_routing.py b/tests/hermes_cli/test_config_platform_env_routing.pynew file mode 100644index 00000000000..3b0f361ee5d--- /dev/null+++ b/tests/hermes_cli/test_config_platform_env_routing.py@@ -0,0 +1,31 @@+"""Regression coverage for platform setup values managed through ``.env``."""++import yaml+++def test_platform_env_key_round_trips_without_a_config_yaml_copy(tmp_path, monkeypatch, capsys):+ """``config set/get/unset`` shares the platform setup flow's .env storage."""+ from hermes_cli import config as cfg++ monkeypatch.setenv("HERMES_HOME", str(tmp_path))+ monkeypatch.setenv("HERMES_MANAGED_DIR", str(tmp_path / "managed"))+ config_path = tmp_path / "config.yaml"+ config_path.write_text("model:\n default: test/model\n", encoding="utf-8")++ cfg.set_config_value("FEISHU_HOME_CHANNEL", "oc_ROUTING_TEST")++ assert yaml.safe_load(config_path.read_text(encoding="utf-8")) == {+ "model": {"default": "test/model"}+ }+ assert (tmp_path / ".env").read_text(encoding="utf-8") == (+ "FEISHU_HOME_CHANNEL=oc_ROUTING_TEST\n"+ )++ cfg.get_config_value("FEISHU_HOME_CHANNEL")+ assert capsys.readouterr().out.strip().endswith("oc_ROUTING_TEST")++ cfg.unset_config_value("FEISHU_HOME_CHANNEL")+ assert "FEISHU_HOME_CHANNEL" not in (tmp_path / ".env").read_text(encoding="utf-8")+ assert yaml.safe_load(config_path.read_text(encoding="utf-8")) == {+ "model": {"default": "test/model"}+ }