The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(sessions): Ctrl-D at a terminal is a no; an over-cap export exits 1
Teknium2dfe39361d19
diff --git a/hermes_cli/sessions_cmd.py b/hermes_cli/sessions_cmd.pyindex 23a78065470..37681e9267e 100644--- a/hermes_cli/sessions_cmd.py+++ b/hermes_cli/sessions_cmd.py@@ -39,14 +39,14 @@ def _size_delta_label(saved_mb: float) -> str:def _confirm_prompt(prompt: str) -> bool | None:- """Prompt for y/N confirmation. ``None`` when no answer can be read (stdin is /dev/null or closed:- cron, a wrapper, a backgrounded shell), which is not the same as the user saying no. Ctrl-C- propagates: an interrupt is neither a no nor a success."""+ """Prompt for y/N confirmation. ``None`` when stdin is not a terminal and hits EOF (/dev/null, an empty+ pipe: cron, a wrapper), which is not the same as the user saying no; Ctrl-D at a terminal is a no.+ Ctrl-C propagates: an interrupt is neither a no nor a success."""try:return input(prompt).strip().lower() in {"y", "yes"}except EOFError:print()- return None+ return False if sys.stdin.isatty() else Nonedef _confirm_or_exit_code(prompt: str, *, declined: str = "Cancelled.", unattended: str | None = "--yes") -> int | None:@@ -417,7 +417,7 @@ def _cmd_export(db, args):if args.session_id:resolved = db.resolve_session_id(args.session_id)if resolved and _too_large([resolved]):- return None+ return 1data = _one(resolved) if resolved else Noneif not data:return _not_found(args.session_id)@@ -427,13 +427,13 @@ def _cmd_export(db, args):if args.dry_run:return _print_dry_run_preview(candidates, filters)if _too_large([row["id"] for row in candidates]):- return None+ return 1return [s for s in (_one(row["id"]) for row in candidates) if s]if args.dry_run:print("--dry-run requires at least one filter.")return 1if _too_large():- return None+ return 1return [_redact(s) for s in db.export_all(source=None, **projection)]if getattr(args, "only", None):return _export_flat("only", args, _collect_sessions)diff --git a/tests/hermes_cli/test_sessions_export_backup_round_trip.py b/tests/hermes_cli/test_sessions_export_backup_round_trip.pyindex 76edb83008a..2935a28d084 100644--- a/tests/hermes_cli/test_sessions_export_backup_round_trip.py+++ b/tests/hermes_cli/test_sessions_export_backup_round_trip.py@@ -82,11 +82,13 @@ def test_jsonl_backup_refuses_a_session_over_max_export_messages(tmp_path, monkelambda self, *a, **kw: scans.append(1) or real_search(self, *a, **kw))backup = tmp_path / "backup.jsonl"- _export(monkeypatch, backup, *selection)-if disabled:+ _export(monkeypatch, backup, *selection)assert backup.exists() and len(scans) == 1return+ with pytest.raises(SystemExit) as refused:+ _export(monkeypatch, backup, *selection)+ assert refused.value.code == 1assert not backup.exists()out = capsys.readouterr().outassert SID in out and "max_export_messages" in out