Skip to content

The agent that grows with you

fix(cli): a refused `-w` names `-w`, not the nonexistent `--w`

Teknium42f07ef77c66
diff --git a/hermes_cli/gateway_chat.py b/hermes_cli/gateway_chat.py
index 17c782544b7..1c14dbe26e0 100644
--- a/hermes_cli/gateway_chat.py
+++ b/hermes_cli/gateway_chat.py
@@ -59,8 +59,10 @@ def validate_options(args):
if getattr(args, "create_if_missing", False) and not continue_title(args):
unsupported.append("create-if-missing without -c <name>")
if unsupported:
- flags = ", ".join("--" + name.replace("_", "-") for name in unsupported)
- where = "".join(f"\n --{name.replace('_', '-')}: use {_RELOCATED[name]}" for name in unsupported)
+ # A one-letter alias (``cli.main(w=True)``) is spelled ``-w``, never the nonexistent ``--w``.
+ spell = {name: ("-" if len(name) == 1 else "--") + name.replace("_", "-") for name in unsupported}
+ flags = ", ".join(spell[name] for name in unsupported)
+ where = "".join(f"\n {spell[name]}: use {_RELOCATED[name]}" for name in unsupported)
raise GatewayClientError(
f"Unsupported gateway CLI options: {flags}. No local fallback or policy changes were made.{where}")
# Creation flags repeated on resume are checked against the frozen route once the snapshot is
diff --git a/tests/hermes_cli/test_gateway_chat.py b/tests/hermes_cli/test_gateway_chat.py
index df729c7569e..6ce13dc3ed6 100644
--- a/tests/hermes_cli/test_gateway_chat.py
+++ b/tests/hermes_cli/test_gateway_chat.py
@@ -183,3 +183,12 @@ def test_every_relocation_hint_names_a_command_that_parses():
for hint in gateway_chat._RELOCATED.values():
for command in re.findall(r"`(hermes [^`]*)`", hint):
parser.parse_args([arg for arg in shlex.split(command)[1:] if not arg.startswith("<")])
+
+
+def test_one_letter_alias_refusal_names_a_flag_the_user_can_type(monkeypatch, capsys):
+ """`cli.main(w=True)` (`python cli.py -w`) is refused as `-w`; `--w` is not an option anywhere."""
+ from hermes_cli import gateway_chat
+ monkeypatch.setattr(gateway_chat, "connect_gateway", lambda: pytest.fail("connected"))
+ assert gateway_chat.launch_from_args(argparse.Namespace(w=True)) == 2
+ err = capsys.readouterr().err
+ assert "options: -w." in err and "\n -w: use `hermes --tui -w`" in err and "--w" not in err