Files
hermes-agent/tests/hermes_cli/test_slash_command_metrics.py
teknium1 73edfc9353 feat(telemetry): count classic CLI slash commands in shared metrics
HermesCLI.process_command records each user-typed slash command once
(canonical registry name, surface cli) through the lazy
shared_metrics_events API. Internal re-entries (quick-command alias,
unique-prefix expansion) pass redispatch=True so one typed command is
one count. Gives hermes.slash_command.count its classic-CLI producer.
2026-09-28 12:43:03 -07:00

20 lines
805 B
Python

"""Classic-CLI slash commands reach shared metrics once each: canonical name, surface ``cli``."""
from cli import HermesCLI
def test_cli_counts_each_typed_slash_command_once(monkeypatch):
calls = []
monkeypatch.setattr(
"hermes_cli.observability.shared_metrics_events.record_slash_command", lambda **kw: calls.append(kw))
ran = []
monkeypatch.setattr(HermesCLI, "_cmd_new", lambda self, cmd: ran.append(cmd))
cli = object.__new__(HermesCLI)
cli.config = {"quick_commands": {"rs": {"type": "alias", "target": "/reset"}}}
cli.process_command("/reset")
cli.process_command("/rs") # a user alias re-dispatches /reset internally
assert ran == ["/reset", "/reset"]
assert calls == [{"command": "new", "surface": "cli"}, {"command": "rs", "surface": "cli"}]