feat(memory): improve OpenViking setup UX

This commit is contained in:
Hao Zhe
2026-06-17 01:04:26 +08:00
parent 3c76dac4fd
commit 2c2ca0443b
8 changed files with 1930 additions and 756 deletions
+70
View File
@@ -45,6 +45,22 @@ def test_curses_select_accepts_explicit_cancel_value(monkeypatch):
assert captured["cancel_returns"] == _CANCELLED
def test_curses_select_clears_after_picker_returns(monkeypatch):
events = []
def fake_radiolist(title, items, selected=0, *, cancel_returns=None):
events.append("picker")
return selected
monkeypatch.setattr("hermes_cli.curses_ui.curses_radiolist", fake_radiolist)
monkeypatch.setattr(memory_setup, "_clear_interactive_transition", lambda: events.append("clear"))
result = _curses_select("Pick one", [("first", "")], default=0)
assert result == 0
assert events == ["picker", "clear"]
def test_cmd_setup_top_level_cancel_writes_nothing(monkeypatch):
save_config = MagicMock()
load_config = MagicMock(side_effect=AssertionError("cancel should not load config"))
@@ -95,6 +111,60 @@ def test_cmd_setup_clears_interactive_picker_before_provider_post_setup(monkeypa
assert events == ["select", "clear", "install", "post_setup"]
def test_cmd_setup_provider_clears_before_provider_post_setup(monkeypatch):
events = []
class PostSetupProvider:
def post_setup(self, hermes_home, config):
events.append("post_setup")
monkeypatch.setattr(memory_setup, "_get_available_providers", lambda: [("openviking", "local", PostSetupProvider())])
monkeypatch.setattr(memory_setup, "_clear_interactive_transition", lambda: events.append("clear"), raising=False)
monkeypatch.setattr(memory_setup, "_install_dependencies", lambda name: events.append("install"))
monkeypatch.setattr(memory_setup, "get_hermes_home", lambda: "/tmp/hermes-test")
monkeypatch.setattr("hermes_cli.config.load_config", lambda: {"memory": {}})
memory_setup.cmd_setup_provider("openviking")
assert events == ["clear", "install", "post_setup"]
def test_cmd_status_prefers_provider_status_config(monkeypatch, capsys):
class StatusProvider:
def get_status_config(self, provider_config):
assert provider_config["endpoint"] == "http://stale.local"
return {
"use_ovcli_config": True,
"ovcli_config_path": "/tmp/ovcli.conf.VPS_ROOT",
"endpoint": "https://vps.example",
"account": "acct",
"user": "alice",
"agent": "hermes",
}
def is_available(self):
return True
config = {
"memory": {
"provider": "openviking",
"openviking": {
"use_ovcli_config": True,
"ovcli_config_path": "/tmp/ovcli.conf.VPS_ROOT",
"endpoint": "http://stale.local",
},
}
}
monkeypatch.setattr("hermes_cli.config.load_config", lambda: config)
monkeypatch.setattr(memory_setup, "_get_available_providers", lambda: [("openviking", "API key / local", StatusProvider())])
memory_setup.cmd_status(SimpleNamespace())
output = capsys.readouterr().out
assert "endpoint: https://vps.example" in output
assert "http://stale.local" not in output
def test_cmd_setup_generic_choice_cancel_writes_nothing(tmp_path, monkeypatch):
class ChoiceProvider:
def __init__(self):