Skip to content

The agent that grows with you

fix: share read-only insights reporting with interactive CLI

Teknium9cd5d6dd2108
diff --git a/hermes_cli/cli_info_mixin.py b/hermes_cli/cli_info_mixin.py
index 0d7fbbd6ca5..c8b45a0dd5e 100644
--- a/hermes_cli/cli_info_mixin.py
+++ b/hermes_cli/cli_info_mixin.py
@@ -771,17 +771,10 @@ class CLIInfoMixin:
days = int(parts[i])
i += 1
- try:
- from hermes_state import SessionDB
- from agent.insights import InsightsEngine
- db = SessionDB()
- try:
- engine = InsightsEngine(db)
- print(engine.format_terminal(engine.generate(days=days, source=source)))
- finally:
- db.close()
- except Exception as e:
- print(f" Error generating insights: {e}")
+ from types import SimpleNamespace
+ from hermes_cli.main_agent_cmds import cmd_insights
+
+ cmd_insights(SimpleNamespace(days=days, source=source))
def _check_config_mcp_changes(self) -> None:
"""Detect mcp_servers changes in config.yaml (polled from process_loop every
diff --git a/tests/cli/test_cli_insights_command.py b/tests/cli/test_cli_insights_command.py
index f324e6a5ea7..944076ca556 100644
--- a/tests/cli/test_cli_insights_command.py
+++ b/tests/cli/test_cli_insights_command.py
@@ -3,6 +3,13 @@ from types import SimpleNamespace
from cli import HermesCLI
from hermes_cli.main_agent_cmds import cmd_insights
+import pytest
+
+
[email protected](autouse=True)
+def existing_store(tmp_path, monkeypatch):
+ monkeypatch.setattr("hermes_cli.config.get_hermes_home", lambda: tmp_path)
+ (tmp_path / "state.db").touch()
class _InsightsEngineStub:
@@ -45,9 +52,7 @@ def test_cli_insights_keeps_days_flag_and_source(capsys):
assert "days=14 source=discord" in capsys.readouterr().out
-def test_subcommand_insights_closes_database_when_generation_fails(capsys, tmp_path, monkeypatch):
- monkeypatch.setattr("hermes_cli.config.get_hermes_home", lambda: tmp_path)
- (tmp_path / "state.db").touch()
+def test_subcommand_insights_closes_database_when_generation_fails(capsys):
db = MagicMock()
with patch("hermes_state.SessionDB", return_value=db), \
patch("agent.insights.InsightsEngine", side_effect=RuntimeError("boom")):
diff --git a/tests/hermes_cli/test_launch_readonly.py b/tests/hermes_cli/test_launch_readonly.py
index aa7f644d60a..d821885abb4 100644
--- a/tests/hermes_cli/test_launch_readonly.py
+++ b/tests/hermes_cli/test_launch_readonly.py
@@ -35,6 +35,8 @@ _print_tui_exit_summary('reader-fixture')
from hermes_cli.main_agent_cmds import cmd_insights
from types import SimpleNamespace
cmd_insights(SimpleNamespace(days=30, source='tui'))
+from hermes_cli.cli_info_mixin import CLIInfoMixin
+CLIInfoMixin._show_insights(object(), '/insights --days 30 --source tui')
after = path.read_bytes() if path.exists() else None
assert after == before, 'launch reader created or mutated state.db'
'''.replace('POPULATED', repr(populated))