The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: enforce -q/--query-file exclusivity at parse time
Teknium4903993cdd97
diff --git a/hermes_cli/_parser.py b/hermes_cli/_parser.pyindex b587ac10e02..c6b4e7cd55b 100644--- a/hermes_cli/_parser.py+++ b/hermes_cli/_parser.py@@ -300,10 +300,11 @@ def build_top_level_parser():help="Interactive chat with the agent",description="Start an interactive chat session with Hermes Agent",)- chat_parser.add_argument(+ _query_group = chat_parser.add_mutually_exclusive_group()+ _query_group.add_argument("-q", "--query", help="Single query (non-interactive mode)")- chat_parser.add_argument(+ _query_group.add_argument("--query-file",metavar="PATH",help=(diff --git a/hermes_cli/main.py b/hermes_cli/main.pyindex 9ca5388c711..7432f1f018c 100644--- a/hermes_cli/main.py+++ b/hermes_cli/main.py@@ -3187,6 +3187,8 @@ def cmd_chat(args):_qfile = getattr(args, "query_file", None)if _qfile:if args.query:+ # argparse's mutually-exclusive group catches the normal CLI path;+ # this guards programmatic callers that fill the namespace directly.print("Error: -q/--query and --query-file are mutually exclusive", file=sys.stderr)sys.exit(2)try:diff --git a/tests/hermes_cli/test_chat_query_file.py b/tests/hermes_cli/test_chat_query_file.pyindex 469bd16e0ee..fa3bb116f95 100644--- a/tests/hermes_cli/test_chat_query_file.py+++ b/tests/hermes_cli/test_chat_query_file.py@@ -7,7 +7,7 @@ The transport is now a file (--query-file) / stdin, and the protocol textmust never regress to inlining the body into -q."""-import subprocess+import sysfrom pathlib import Path@@ -50,17 +50,14 @@ def test_query_file_reads_hostile_text_verbatim(tmp_path, monkeypatch):def test_query_and_query_file_mutually_exclusive(tmp_path):+ """argparse rejects -q + --query-file at parse time (exit 2), no env needed."""+ import pytest+f = tmp_path / "dm.txt"f.write_text("hello", encoding="utf-8")- proc = subprocess.run(- [sys.executable, "-c",- "import sys; sys.path.insert(0, %r); "- "from hermes_cli.main import main; sys.argv=['hermes','chat','-q','x','--query-file',%r]; main()"- % (str(REPO), str(f))],- capture_output=True, text=True, timeout=120,- )- assert proc.returncode == 2- assert "mutually exclusive" in proc.stderr+ with pytest.raises(SystemExit) as exc:+ _parse(["chat", "-q", "x", "--query-file", str(f)])+ assert exc.value.code == 2def test_bot_mode_protocol_never_inlines_message_into_shell():