The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): apply /vim salvage to decomposed layout, trim tests, docs
Sam Foreman968fdc474640
diff --git a/tests/cli/test_vim_mode_command.py b/tests/cli/test_vim_mode_command.pyindex 26f8a864d64..7ebca398cfc 100644--- a/tests/cli/test_vim_mode_command.py+++ b/tests/cli/test_vim_mode_command.py@@ -8,15 +8,6 @@ from prompt_toolkit.enums import EditingModedef _import_cli():- import hermes_cli.config as config_mod-- if not hasattr(config_mod, "save_env_value_secure"):- config_mod.save_env_value_secure = lambda key, value: {- "success": True,- "stored_as": key,- "validated": False,- }-import cli as cli_modreturn cli_mod@@ -32,117 +23,58 @@ class TestHandleVimCommand(unittest.TestCase):_console_print=lambda *a, **k: None,)- def test_status_reports_without_saving(self):- cli_mod = _import_cli()- stub = self._make_cli(vim_mode=True)- printed = []- stub._console_print = lambda msg: printed.append(str(msg))-- with patch.object(cli_mod, "save_config_value") as mock_save:- cli_mod.HermesCLI._handle_vim_command(stub, "/vim status")-- mock_save.assert_not_called()- self.assertTrue(stub._vim_mode)- self.assertIn("on", " ".join(printed))-- def test_bare_command_toggles_on_and_persists(self):+ def test_toggle_persists_and_applies_to_running_app(self):cli_mod = _import_cli()- stub = self._make_cli(vim_mode=False)+ app = SimpleNamespace(editing_mode=EditingMode.EMACS)+ stub = self._make_cli(vim_mode=False, app=app)with patch.object(cli_mod, "save_config_value") as mock_save:cli_mod.HermesCLI._handle_vim_command(stub, "/vim")-self.assertTrue(stub._vim_mode)+ self.assertEqual(app.editing_mode, EditingMode.VI)mock_save.assert_called_once_with("display.vim_mode", True)- def test_off_argument_disables_and_persists(self):- cli_mod = _import_cli()- stub = self._make_cli(vim_mode=True)-with patch.object(cli_mod, "save_config_value") as mock_save:cli_mod.HermesCLI._handle_vim_command(stub, "/vim off")-self.assertFalse(stub._vim_mode)- mock_save.assert_called_once_with("display.vim_mode", False)-- def test_applies_editing_mode_to_running_app(self):- cli_mod = _import_cli()- app = SimpleNamespace(editing_mode=EditingMode.EMACS)- stub = self._make_cli(vim_mode=False, app=app)-- with patch.object(cli_mod, "save_config_value"):- cli_mod.HermesCLI._handle_vim_command(stub, "/vim on")- self.assertEqual(app.editing_mode, EditingMode.VI)-- with patch.object(cli_mod, "save_config_value"):- cli_mod.HermesCLI._handle_vim_command(stub, "/vim off")self.assertEqual(app.editing_mode, EditingMode.EMACS)+ mock_save.assert_called_once_with("display.vim_mode", False)- def test_no_running_app_is_not_fatal(self):- cli_mod = _import_cli()- stub = self._make_cli(vim_mode=False, app=None)-- with patch.object(cli_mod, "save_config_value"):- cli_mod.HermesCLI._handle_vim_command(stub, "/vim on")-- self.assertTrue(stub._vim_mode)-- def test_invalid_argument_does_not_change_state(self):+ def test_status_and_invalid_args_change_nothing(self):cli_mod = _import_cli()- stub = self._make_cli(vim_mode=False)printed = []+ stub = self._make_cli(vim_mode=True)stub._console_print = lambda msg: printed.append(str(msg))with patch.object(cli_mod, "save_config_value") as mock_save:+ cli_mod.HermesCLI._handle_vim_command(stub, "/vim status")cli_mod.HermesCLI._handle_vim_command(stub, "/vim sideways")mock_save.assert_not_called()- self.assertFalse(stub._vim_mode)+ self.assertTrue(stub._vim_mode)self.assertIn("Usage", " ".join(printed))class TestVimModeLabel(unittest.TestCase):- """The status-bar label reflects the live vi input mode."""+ """The status-bar label reflects the live vi input mode; off/no-app yields empty."""- def test_empty_when_vim_mode_off(self):- cli_mod = _import_cli()- stub = SimpleNamespace(_vim_mode=False, _app=None)- self.assertEqual(cli_mod.HermesCLI._vim_mode_label(stub), "")-- def test_empty_when_no_app_yet(self):- cli_mod = _import_cli()- stub = SimpleNamespace(_vim_mode=True, _app=None)- self.assertEqual(cli_mod.HermesCLI._vim_mode_label(stub), "")-- def test_reports_insert_and_normal(self):+ def test_label_tracks_input_mode(self):cli_mod = _import_cli()from prompt_toolkit.key_binding.vi_state import InputMode+ self.assertEqual(+ cli_mod.HermesCLI._vim_mode_label(SimpleNamespace(_vim_mode=False, _app=None)), "")+ self.assertEqual(+ cli_mod.HermesCLI._vim_mode_label(SimpleNamespace(_vim_mode=True, _app=None)), "")+app = SimpleNamespace(vi_state=SimpleNamespace(input_mode=InputMode.INSERT))stub = SimpleNamespace(_vim_mode=True, _app=app)self.assertEqual(cli_mod.HermesCLI._vim_mode_label(stub), "INSERT")-app.vi_state.input_mode = InputMode.NAVIGATIONself.assertEqual(cli_mod.HermesCLI._vim_mode_label(stub), "NORMAL")-app.vi_state.input_mode = InputMode.REPLACEself.assertEqual(cli_mod.HermesCLI._vim_mode_label(stub), "REPLACE")-class TestVimModeConfigAndRegistration(unittest.TestCase):- """The feature is opt-in and discoverable."""-- def test_default_is_off(self):- from hermes_cli.config_defaults import DEFAULT_CONFIG-- self.assertIs(DEFAULT_CONFIG["display"]["vim_mode"], False)-- def test_command_is_registered_with_subcommands(self):- from hermes_cli.commands import COMMANDS, SUBCOMMANDS-- self.assertIn("/vim", COMMANDS)- self.assertEqual(SUBCOMMANDS["/vim"], ["on", "off", "status"])--if __name__ == "__main__":unittest.main()diff --git a/website/docs/reference/slash-commands.md b/website/docs/reference/slash-commands.mdindex 61d5c3af2b9..a1e9b186cde 100644--- a/website/docs/reference/slash-commands.md+++ b/website/docs/reference/slash-commands.md@@ -88,6 +88,7 @@ Type `/` in the CLI to open the autocomplete menu. Built-in commands are case-in| `/import <archive.tar.gz> [--name <name>]` | **CLI only.** Install a profile archive as a new profile, inferring the name from the archive unless `--name` is given. Refuses to overwrite an existing profile and cannot import as `default`. Creates a shell wrapper when the name is free. See [Export and import a profile file](../user-guide/profile-distributions.md#export-and-import-a-profile-file). || `/statusbar` (alias: `/sb`) | Toggle the context/model status bar on or off || `/battery [on\|off\|status]` | Toggle a color-coded battery read-out as the first status-bar element (off by default; no-op without a battery). |+| `/vim [on\|off\|status]` | Toggle vi/vim keybindings in the input composer (off by default). The live NORMAL/INSERT/REPLACE mode shows at the right of the status bar; persisted to `display.vim_mode`. || `/voice [on\|off\|tts\|status]` | Toggle CLI voice mode and spoken playback. Recording uses `voice.record_key` (default: `Ctrl+B`). || `/yolo` | Toggle YOLO mode — skip all dangerous command approval prompts. || `/approvals [manual\|smart\|off]` | Show or set the persistent dangerous-command approval mode. |@@ -307,7 +308,7 @@ The messaging gateway supports the following built-in commands inside Telegram,## Notes-- `/skin`, `/snapshot`, `/export`, `/import`, `/reload`, `/tools`, `/toolsets`, `/browser`, `/config`, `/cron`, `/platforms`, `/paste`, `/image`, `/statusbar`, `/battery`, `/focus`, `/plugins`, `/indicator`, `/wake`, `/journey`, `/redraw`, `/clear`, `/history`, `/save`, `/copy`, `/handoff`, `/prompt`, `/pet`, `/hatch`, `/timestamps`, `/subscription`, and `/quit` are **CLI-only** commands.+- `/skin`, `/snapshot`, `/export`, `/import`, `/reload`, `/tools`, `/toolsets`, `/browser`, `/config`, `/cron`, `/platforms`, `/paste`, `/image`, `/statusbar`, `/battery`, `/vim`, `/focus`, `/plugins`, `/indicator`, `/wake`, `/journey`, `/redraw`, `/clear`, `/history`, `/save`, `/copy`, `/handoff`, `/prompt`, `/pet`, `/hatch`, `/timestamps`, `/subscription`, and `/quit` are **CLI-only** commands.- `/skills` is **CLI-only for search/browse/install**; its write-approval review subcommands (`pending`, `approve`, `reject`, `diff`, `approval`) also work on messaging platforms when `skills.write_approval` is on. `/memory` works on **both** surfaces.- `/verbose` is **CLI-only by default**, but can be enabled for messaging platforms by setting `display.tool_progress_command: true` in `config.yaml`. When enabled, it cycles the `display.tool_progress` mode and saves to config.- `/focus` and `/verbose` share one suppression path (`display.tool_progress`), so they can never contradict each other: `/focus on` pins tool progress to `off` and stashes your mode under `display.focus_saved_tool_progress`; `/focus off` restores it; cycling `/verbose` while focus is on takes the mode back and clears the focus badge. Focus view is display-only — it never changes conversation history, the system prompt, or anything sent to the model, so it has zero prompt-cache impact.