mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
Add confirmation for destructive slash commands
This commit is contained in:
parent
d1d425e9d0
commit
064a2882f8
7 changed files with 289 additions and 16 deletions
17
cli.py
17
cli.py
|
|
@ -5277,10 +5277,16 @@ class HermesCLI:
|
|||
|
||||
# Resolve aliases via central registry so adding an alias is a one-line
|
||||
# change in hermes_cli/commands.py instead of touching every dispatch site.
|
||||
from hermes_cli.commands import resolve_command as _resolve_cmd
|
||||
from hermes_cli.commands import (
|
||||
destructive_command_confirmation_message as _destructive_command_msg,
|
||||
destructive_command_is_confirmed as _destructive_command_is_confirmed,
|
||||
resolve_command as _resolve_cmd,
|
||||
)
|
||||
_base_word = cmd_lower.split()[0].lstrip("/")
|
||||
_cmd_def = _resolve_cmd(_base_word)
|
||||
canonical = _cmd_def.name if _cmd_def else _base_word
|
||||
_typed_command = cmd_original.split()[0].lstrip("/").lower()
|
||||
_args = cmd_original.split(maxsplit=1)[1] if " " in cmd_original else ""
|
||||
|
||||
if canonical in ("quit", "exit", "q"):
|
||||
return False
|
||||
|
|
@ -5295,6 +5301,9 @@ class HermesCLI:
|
|||
elif canonical == "config":
|
||||
self.show_config()
|
||||
elif canonical == "clear":
|
||||
if not _destructive_command_is_confirmed(_args):
|
||||
_cprint(_destructive_command_msg("clear", _typed_command))
|
||||
return True
|
||||
self.new_session(silent=True)
|
||||
# Clear terminal screen. Inside the TUI, Rich's console.clear()
|
||||
# goes through patch_stdout's StdoutProxy which swallows the
|
||||
|
|
@ -5412,6 +5421,9 @@ class HermesCLI:
|
|||
else:
|
||||
_cprint(" Session database not available.")
|
||||
elif canonical == "new":
|
||||
if not _destructive_command_is_confirmed(_args):
|
||||
_cprint(_destructive_command_msg("new", _typed_command))
|
||||
return True
|
||||
self.new_session()
|
||||
elif canonical == "resume":
|
||||
self._handle_resume_command(cmd_original)
|
||||
|
|
@ -5431,6 +5443,9 @@ class HermesCLI:
|
|||
# Re-queue the message so process_loop sends it to the agent
|
||||
self._pending_input.put(retry_msg)
|
||||
elif canonical == "undo":
|
||||
if not _destructive_command_is_confirmed(_args):
|
||||
_cprint(_destructive_command_msg("undo", _typed_command))
|
||||
return True
|
||||
self.undo_last()
|
||||
elif canonical == "branch":
|
||||
self._handle_branch_command(cmd_original)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue