feat: add /yolo slash command to toggle dangerous command approvals (#3990)
Adds a /yolo command that toggles HERMES_YOLO_MODE at runtime, skipping all dangerous command approval prompts for the current session. Works in both CLI and gateway (Telegram, Discord, etc.). - /yolo -> ON: all commands auto-approved, no confirmation prompts - /yolo -> OFF: normal approval flow restored The --yolo CLI flag already existed for launch-time opt-in. This adds the ability to toggle mid-session without restarting. Session-scoped — resets when the process ends. Uses the existing HERMES_YOLO_MODE env var that check_all_command_guards() already respects.
This commit is contained in:
13
cli.py
13
cli.py
@@ -3836,6 +3836,8 @@ class HermesCLI:
|
|||||||
self.console.print(f" Status bar {state}")
|
self.console.print(f" Status bar {state}")
|
||||||
elif canonical == "verbose":
|
elif canonical == "verbose":
|
||||||
self._toggle_verbose()
|
self._toggle_verbose()
|
||||||
|
elif canonical == "yolo":
|
||||||
|
self._toggle_yolo()
|
||||||
elif canonical == "reasoning":
|
elif canonical == "reasoning":
|
||||||
self._handle_reasoning_command(cmd_original)
|
self._handle_reasoning_command(cmd_original)
|
||||||
elif canonical == "compress":
|
elif canonical == "compress":
|
||||||
@@ -4434,6 +4436,17 @@ class HermesCLI:
|
|||||||
}
|
}
|
||||||
_cprint(labels.get(self.tool_progress_mode, ""))
|
_cprint(labels.get(self.tool_progress_mode, ""))
|
||||||
|
|
||||||
|
def _toggle_yolo(self):
|
||||||
|
"""Toggle YOLO mode — skip all dangerous command approval prompts."""
|
||||||
|
import os
|
||||||
|
current = bool(os.environ.get("HERMES_YOLO_MODE"))
|
||||||
|
if current:
|
||||||
|
os.environ.pop("HERMES_YOLO_MODE", None)
|
||||||
|
self.console.print(" ⚠ YOLO mode [bold red]OFF[/] — dangerous commands will require approval.")
|
||||||
|
else:
|
||||||
|
os.environ["HERMES_YOLO_MODE"] = "1"
|
||||||
|
self.console.print(" ⚡ YOLO mode [bold green]ON[/] — all commands auto-approved. Use with caution.")
|
||||||
|
|
||||||
def _handle_reasoning_command(self, cmd: str):
|
def _handle_reasoning_command(self, cmd: str):
|
||||||
"""Handle /reasoning — manage effort level and display toggle.
|
"""Handle /reasoning — manage effort level and display toggle.
|
||||||
|
|
||||||
|
|||||||
@@ -1877,6 +1877,9 @@ class GatewayRunner:
|
|||||||
if canonical == "verbose":
|
if canonical == "verbose":
|
||||||
return await self._handle_verbose_command(event)
|
return await self._handle_verbose_command(event)
|
||||||
|
|
||||||
|
if canonical == "yolo":
|
||||||
|
return await self._handle_yolo_command(event)
|
||||||
|
|
||||||
if canonical == "provider":
|
if canonical == "provider":
|
||||||
return await self._handle_provider_command(event)
|
return await self._handle_provider_command(event)
|
||||||
|
|
||||||
@@ -4109,6 +4112,16 @@ class GatewayRunner:
|
|||||||
else:
|
else:
|
||||||
return f"🧠 ✓ Reasoning effort set to `{effort}` (this session only)"
|
return f"🧠 ✓ Reasoning effort set to `{effort}` (this session only)"
|
||||||
|
|
||||||
|
async def _handle_yolo_command(self, event: MessageEvent) -> str:
|
||||||
|
"""Handle /yolo — toggle dangerous command approval bypass."""
|
||||||
|
current = bool(os.environ.get("HERMES_YOLO_MODE"))
|
||||||
|
if current:
|
||||||
|
os.environ.pop("HERMES_YOLO_MODE", None)
|
||||||
|
return "⚠️ YOLO mode **OFF** — dangerous commands will require approval."
|
||||||
|
else:
|
||||||
|
os.environ["HERMES_YOLO_MODE"] = "1"
|
||||||
|
return "⚡ YOLO mode **ON** — all commands auto-approved. Use with caution."
|
||||||
|
|
||||||
async def _handle_verbose_command(self, event: MessageEvent) -> str:
|
async def _handle_verbose_command(self, event: MessageEvent) -> str:
|
||||||
"""Handle /verbose command — cycle tool progress display mode.
|
"""Handle /verbose command — cycle tool progress display mode.
|
||||||
|
|
||||||
|
|||||||
@@ -90,6 +90,8 @@ COMMAND_REGISTRY: list[CommandDef] = [
|
|||||||
CommandDef("verbose", "Cycle tool progress display: off -> new -> all -> verbose",
|
CommandDef("verbose", "Cycle tool progress display: off -> new -> all -> verbose",
|
||||||
"Configuration", cli_only=True,
|
"Configuration", cli_only=True,
|
||||||
gateway_config_gate="display.tool_progress_command"),
|
gateway_config_gate="display.tool_progress_command"),
|
||||||
|
CommandDef("yolo", "Toggle YOLO mode (skip all dangerous command approvals)",
|
||||||
|
"Configuration"),
|
||||||
CommandDef("reasoning", "Manage reasoning effort and display", "Configuration",
|
CommandDef("reasoning", "Manage reasoning effort and display", "Configuration",
|
||||||
args_hint="[level|show|hide]",
|
args_hint="[level|show|hide]",
|
||||||
subcommands=("none", "low", "minimal", "medium", "high", "xhigh", "show", "hide", "on", "off")),
|
subcommands=("none", "low", "minimal", "medium", "high", "xhigh", "show", "hide", "on", "off")),
|
||||||
|
|||||||
Reference in New Issue
Block a user