The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(install): don't ask the gateway install questions twice
ethernet746d861504ea
diff --git a/hermes_cli/gateway.py b/hermes_cli/gateway.pyindex 74c9f9017ae..6410d392e07 100644--- a/hermes_cli/gateway.py+++ b/hermes_cli/gateway.py@@ -5091,6 +5091,9 @@ def _cmd_install(args):if is_managed():managed_error("install gateway service")return+ if getattr(args, "if_missing", False) and _is_service_installed():+ print("✓ Gateway service already installed")+ returnforce = getattr(args, "force", False)# `--force` doubles as the reinstall flag here; a served profile's unit would only ever exit 78._guard_named_profile_under_multiplexer(force=force)diff --git a/hermes_cli/subcommands/gateway.py b/hermes_cli/subcommands/gateway.pyindex 471ac4389cf..569e6fbe438 100644--- a/hermes_cli/subcommands/gateway.py+++ b/hermes_cli/subcommands/gateway.py@@ -131,6 +131,8 @@ def build_gateway_parser(help="Enable the service to start automatically on login/boot")gateway_install.add_argument("--no-start-on-login", dest="start_on_login", action="store_false",help="Do not enable the service to start on login/boot")+ _flag(gateway_install, "--if-missing", dest="if_missing",+ help="Do nothing when a gateway service is already installed")_flag(gateway_install, "--elevated-handoff", dest="elevated_handoff", help=argparse.SUPPRESS)gateway_uninstall = gateway_subparsers.add_parser("uninstall", help="Uninstall gateway service")diff --git a/scripts/install.ps1 b/scripts/install.ps1index 056286f14b4..637cb22a2ea 100644--- a/scripts/install.ps1+++ b/scripts/install.ps1@@ -1056,7 +1056,8 @@ function Stage-Setup {function Stage-Gateway {if ($NonInteractive) { return }- Invoke-InstalledHermes @('gateway', 'install')+ # Setup installs the service when it handles the gateway; ask only if it did not.+ Invoke-InstalledHermes @('gateway', 'install', '--if-missing')}function Stage-Desktop {diff --git a/scripts/install.sh b/scripts/install.shindex ecbd33e53a1..1911f63e16d 100755--- a/scripts/install.sh+++ b/scripts/install.sh@@ -714,7 +714,8 @@ stage_gateway() {log "gateway setup skipped (no terminal); run 'hermes gateway install' after install"return 0fi- "$INSTALL_DIR/.hermes/bin/hermes" gateway install </dev/tty || fail "gateway installation failed"+ # Setup installs the service when it handles the gateway; ask only if it did not.+ "$INSTALL_DIR/.hermes/bin/hermes" gateway install --if-missing </dev/tty || fail "gateway installation failed"}stage_complete() {diff --git a/tests/hermes_cli/test_gateway.py b/tests/hermes_cli/test_gateway.pyindex 8663aeccdcf..1bb66caa4ca 100644--- a/tests/hermes_cli/test_gateway.py+++ b/tests/hermes_cli/test_gateway.py@@ -1057,3 +1057,20 @@ def test_service_commands_refuse_on_sealed_apt_termux(assert exc.value.code == 1out = capsys.readouterr().outassert "Termux" in out++[email protected]("installed", [True, False])+def test_install_if_missing_only_installs_when_no_service_exists(monkeypatch, installed):+ """The installer's gateway stage runs after setup, which may have installed+ the service already. --if-missing must not ask the install questions again."""+ installs = []+ monkeypatch.setattr(gateway, "is_managed", lambda: False)+ monkeypatch.setattr(gateway, "_is_service_installed", lambda: installed)+ monkeypatch.setattr(gateway, "_guard_named_profile_under_multiplexer", lambda force: None)+ monkeypatch.setattr(gateway, "_service_mgmt_blocked", lambda: False)+ monkeypatch.setattr(gateway, "_service_backend", lambda: "launchd")+ monkeypatch.setattr(gateway, "launchd_install", lambda force, start_now: installs.append(force))++ gateway._cmd_install(SimpleNamespace(if_missing=True, force=False, system=False, run_as_user=None))++ assert installs == ([] if installed else [False])diff --git a/tests/scripts/test_install_sh_launch_handoff.py b/tests/scripts/test_install_sh_launch_handoff.pyindex db7ca3300b2..5faca3fe69c 100644--- a/tests/scripts/test_install_sh_launch_handoff.py+++ b/tests/scripts/test_install_sh_launch_handoff.py@@ -31,7 +31,7 @@ def _with_controlling_terminal(tty_path: str):@pytest.mark.platforms('posix')[email protected]('stage, expected', [('setup', ['setup']), ('gateway', ['gateway', 'install'])])[email protected]('stage, expected', [('setup', ['setup']), ('gateway', ['gateway', 'install', '--if-missing'])])def test_installer_post_pm_stages(tmp_path: Path, stage: str, expected: list[str]) -> None:install = tmp_path / 'source tree'calls = tmp_path / 'calls.json'