Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions docs/integrations/hermes.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ Ownership records are project-local, not tied to the global directory:

## Workflow Dispatch

Workflow steps use `hermes chat -Q`. Slash-prefixed prompts select a skill with
`-s`; remaining text is passed with `-q`. Other prompts use `-q` directly.
The adapter forwards a configured model with `-m` and requests `--json` for
structured output.
Workflow steps use `hermes chat -Q`. Slash-prefixed prompts preload the skill
with `-s` and pass the remaining text (or the slash command itself when no
extra arguments are given) with `-q` so `hermes chat` stays in non-interactive
single-query mode. Other prompts use `-q` directly. The adapter forwards a
configured model with `-m` and requests `--format stream-json` for structured
JSONL output.
17 changes: 11 additions & 6 deletions src/specify_cli/integrations/hermes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,16 +306,21 @@ def build_exec_args(
if model:
args.extend(["-m", model])
if output_json:
args.append("--json")

# If prompt starts with a slash command, pass it directly
# so Hermes can dispatch to the appropriate skill.
# ``hermes chat`` has no ``--json`` flag (exits 2 with
# ``unrecognized arguments: --json``); its ``--format`` option
# accepts ``text`` and ``stream-json`` (JSONL events).
args.extend(["--format", "stream-json"])

# If prompt starts with a slash command, preload the skill via ``-s``
# and always pass a non-empty ``-q`` query. ``-s/--skills`` only
# preloads skills into the session; omitting ``-q`` makes
# ``--format stream-json`` exit 2 (``requires -q/--query``) and makes
# text mode enter the interactive REPL instead of single-query mode.
if prompt.startswith("/"):
command, _, remainder = prompt[1:].partition(" ")
if command:
args.extend(["-s", command])
if remainder:
args.extend(["-q", remainder])
args.extend(["-q", remainder if remainder.strip() else f"/{command}"])
else:
args.extend(["-q", prompt])
else:
Expand Down
49 changes: 44 additions & 5 deletions tests/integrations/test_integration_hermes.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,31 +364,70 @@ class TestHermesBuildExecArgs:

def test_build_exec_args_default_shape(self):
i = get_integration("hermes")
assert i is not None
assert i.build_exec_args("/speckit-plan hi", output_json=True) == [
"hermes", "chat", "-Q", "--json", "-s", "speckit-plan", "-q", "hi",
"hermes", "chat", "-Q", "--format", "stream-json",
"-s", "speckit-plan", "-q", "hi",
]

def test_build_exec_args_text_mode_omits_stream_json(self):
"""Streaming dispatch (output_json=False) omits --format stream-json."""
i = get_integration("hermes")
assert i is not None
assert i.build_exec_args("/speckit-plan hi", output_json=False) == [
"hermes", "chat", "-Q", "-s", "speckit-plan", "-q", "hi",
]

def test_build_exec_args_bare_slash_command_keeps_query_flag(self):
"""A bare slash command (e.g. /speckit-analyze) or whitespace-only
remainder must still pass -q so hermes chat runs in single-query mode
instead of exiting 2 under --format stream-json or hanging in REPL."""
i = get_integration("hermes")
assert i is not None
assert i.build_exec_args("/speckit-analyze", output_json=True) == [
"hermes", "chat", "-Q", "--format", "stream-json",
"-s", "speckit-analyze", "-q", "/speckit-analyze",
]
assert i.build_exec_args("/speckit-analyze ", output_json=False) == [
"hermes", "chat", "-Q",
"-s", "speckit-analyze", "-q", "/speckit-analyze",
]

def test_build_exec_args_plain_and_bare_slash_prompts(self):
i = get_integration("hermes")
assert i is not None
assert i.build_exec_args("plain prompt", output_json=False, model="m1") == [
"hermes", "chat", "-Q", "-m", "m1", "-q", "plain prompt",
]
assert i.build_exec_args("/", output_json=False) == [
"hermes", "chat", "-Q", "-q", "/",
]

def test_build_exec_args_honors_extra_args(self, monkeypatch):
"""SPECKIT_INTEGRATION_HERMES_EXTRA_ARGS is injected before the
canonical -m/--json/-s/-q flags (same env hook as codex/opencode/
canonical -m/--format/-s/-q flags (same env hook as codex/opencode/
devin; hermes previously skipped _apply_extra_args_env_var entirely).
"""
monkeypatch.setenv(
"SPECKIT_INTEGRATION_HERMES_EXTRA_ARGS", "--temperature 0.2"
)
i = get_integration("hermes")
assert i is not None
args = i.build_exec_args("/speckit-plan hi", output_json=True)
assert args == [
"hermes", "chat", "-Q", "--temperature", "0.2",
"--json", "-s", "speckit-plan", "-q", "hi",
"--format", "stream-json", "-s", "speckit-plan", "-q", "hi",
]
# Injected before the canonical flags so it can't displace them.
assert args.index("--temperature") < args.index("--json")
assert args.index("--temperature") < args.index("--format")
assert args.index("--temperature") < args.index("-s")

def test_build_exec_args_honors_executable_override(self, monkeypatch):
monkeypatch.setenv(
"SPECKIT_INTEGRATION_HERMES_EXECUTABLE", "/custom/hermes"
)
i = get_integration("hermes")
assert i.build_exec_args("/speckit-plan hi")[0] == "/custom/hermes"
assert i is not None
exec_args = i.build_exec_args("/speckit-plan hi")
assert exec_args is not None
assert exec_args[0] == "/custom/hermes"
Loading