The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat: bare /save shows a usage card instead of exporting
Tekniumca5c04818b49
diff --git a/cli.py b/cli.pyindex c174fd8fcb8..51959deeb08 100644--- a/cli.py+++ b/cli.py@@ -9355,20 +9355,28 @@ class HermesCLI(CLIAgentSetupMixin, CLICommandsMixin, CLIBillingMixin):redaction pass before writing."""from hermes_cli.session_export import (+ SAVE_USAGE,normalize_save_format,render_session_for_save,)parts = cmd.split()[1:]+ if not parts:+ print(SAVE_USAGE)+ returnredact = False- if parts and parts[-1].lower() in ("redact", "--redact"):+ if parts[-1].lower() in ("redact", "--redact"):redact = Trueparts = parts[:-1]+ if not parts:+ print(SAVE_USAGE)+ returntry:- fmt = normalize_save_format(parts[0] if parts else None)+ fmt = normalize_save_format(parts[0])except ValueError as e:print(f"(._.) {e}")+ print(SAVE_USAGE)returnfilename = parts[1] if len(parts) > 1 else Nonediff --git a/gateway/slash_commands.py b/gateway/slash_commands.pyindex 0d39589277e..523af310e97 100644--- a/gateway/slash_commands.py+++ b/gateway/slash_commands.py@@ -4537,27 +4537,33 @@ class GatewaySlashCommandsMixin:Usage: ``/save [json|md|html] [filename] [redact]``"""from hermes_cli.session_export import (+ SAVE_USAGE,default_save_filename,normalize_save_format,render_session_for_save,)- source = event.source- session_entry = await self.async_session_store.get_or_create_session(source)- session_id = session_entry.session_id-- if not self._session_db:- return "Session database not available."-parts = event.get_command_args().split()+ if not parts:+ return SAVE_USAGEredact = False- if parts and parts[-1].lower() in ("redact", "--redact"):+ if parts[-1].lower() in ("redact", "--redact"):redact = Trueparts = parts[:-1]+ if not parts:+ return SAVE_USAGE+try:- fmt = normalize_save_format(parts[0] if parts else None)+ fmt = normalize_save_format(parts[0])except ValueError as e:- return str(e)+ return f"{e}\n\n{SAVE_USAGE}"++ source = event.source+ session_entry = await self.async_session_store.get_or_create_session(source)+ session_id = session_entry.session_id++ if not self._session_db:+ return "Session database not available."filename = parts[1] if len(parts) > 1 else default_save_filename(session_id, fmt)# The filename is echoed to the platform only — never trust path# separators from chat input.diff --git a/hermes_cli/commands.py b/hermes_cli/commands.pyindex 8b246f6248a..c1865dfad7f 100644--- a/hermes_cli/commands.py+++ b/hermes_cli/commands.py@@ -154,8 +154,8 @@ COMMAND_REGISTRY: list[CommandDef] = [cli_only=True),CommandDef("history", "Show conversation history", "Session",cli_only=True),- CommandDef("save", "Save/export the current conversation (json, md, or html)", "Session",- args_hint="[json|md|html] [filename] [redact]"),+ CommandDef("save", "Export the current conversation (bare /save shows usage)", "Session",+ args_hint="<json|md|html> [filename] [redact]"),CommandDef("retry", "Retry the last message (resend to agent)", "Session"),CommandDef("prompt", "Compose your next prompt in $EDITOR (markdown), then send it", "Session",cli_only=True, args_hint="[initial text]", aliases=("compose",)),diff --git a/hermes_cli/session_export.py b/hermes_cli/session_export.pyindex 59c52cf44d4..f8695b8d62f 100644--- a/hermes_cli/session_export.py+++ b/hermes_cli/session_export.py@@ -323,6 +323,26 @@ def _finish_markdown(lines: List[str]) -> str:SAVE_FORMATS = ("json", "md", "html")+SAVE_USAGE = """/save — export the current session to a file+Usage: /save <format> [filename] [redact]++Formats:+ json full session snapshot (canonical export shape)+ md readable Markdown transcript+ html standalone single-file HTML page (shareable, no dependencies)++Options:+ filename optional output name/path (default: auto-named;+ CLI saves under ~/.hermes/sessions/saved/)+ redact scrub API keys, tokens, and credentials before writing++Examples:+ /save json+ /save html+ /save md notes.md+ /save html session.html redact"""++def normalize_save_format(fmt: Optional[str]) -> str:"""Map a user-typed /save format token to a canonical format."""diff --git a/tests/cli/test_save_conversation_location.py b/tests/cli/test_save_conversation_location.pyindex 714ddabddb6..cea981e1dee 100644--- a/tests/cli/test_save_conversation_location.py+++ b/tests/cli/test_save_conversation_location.py@@ -61,7 +61,7 @@ def test_save_conversation_writes_under_hermes_home(hermes_home, tmp_path, monke])# Call the unbound method against our stub.- cli.HermesCLI.save_conversation(stub)+ cli.HermesCLI.save_conversation(stub, "/save json")# File must NOT be in CWDcwd_leak = list(work.glob("hermes_conversation_*.json"))@@ -95,9 +95,40 @@ def test_save_conversation_empty_history_does_nothing(hermes_home, capsys):import clistub = _make_stub_cli([])- cli.HermesCLI.save_conversation(stub)+ cli.HermesCLI.save_conversation(stub, "/save json")saved_dir = hermes_home / "sessions" / "saved"assert not saved_dir.exists() or not list(saved_dir.iterdir())out = capsys.readouterr().outassert "No conversation to save" in out+++def test_save_conversation_bare_shows_usage(hermes_home, capsys):+ """Bare /save prints the usage card and writes nothing."""+ for mod in [m for m in sys.modules if m.startswith("cli") or m == "hermes_constants"]:+ sys.modules.pop(mod, None)+ import cli++ stub = _make_stub_cli([{"role": "user", "content": "hi"}])+ cli.HermesCLI.save_conversation(stub, "/save")++ saved_dir = hermes_home / "sessions" / "saved"+ assert not saved_dir.exists() or not list(saved_dir.iterdir())+ out = capsys.readouterr().out+ # Usage card lists every format and the redact option+ for token in ("json", "md", "html", "redact", "Usage:"):+ assert token in out, (token, out)+++def test_save_conversation_bad_format_shows_usage(hermes_home, capsys):+ for mod in [m for m in sys.modules if m.startswith("cli") or m == "hermes_constants"]:+ sys.modules.pop(mod, None)+ import cli++ stub = _make_stub_cli([{"role": "user", "content": "hi"}])+ cli.HermesCLI.save_conversation(stub, "/save pdf")++ saved_dir = hermes_home / "sessions" / "saved"+ assert not saved_dir.exists() or not list(saved_dir.iterdir())+ out = capsys.readouterr().out+ assert "Usage:" in out