Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7986,6 +7986,20 @@ def _handle_model_picker_selection(self, persist_global: bool = False) -> None:
return
self._close_model_picker()

def _handle_image_model_switch(self, cmd_original: str):
"""Handle /image_model β€” switch image generation provider/model globally."""
from hermes_cli.image_model_switch import apply_image_model_switch

parts = cmd_original.split(None, 1)
raw_args = parts[1].strip() if len(parts) > 1 else ""
result = apply_image_model_switch(raw_args)
prefix = " " if result.success else " βœ— "
for idx, line in enumerate(result.message.splitlines() or [""]):
if result.success:
_cprint(f" {line}")
else:
_cprint(f"{prefix}{line}" if idx == 0 else f" {line}")

def _handle_model_switch(self, cmd_original: str):
"""Handle /model command β€” switch model for this session.

Expand Down Expand Up @@ -8916,6 +8930,8 @@ def process_command(self, command: str) -> bool:
self._handle_sessions_command(cmd_original)
elif canonical == "model":
self._handle_model_switch(cmd_original)
elif canonical == "image_model":
self._handle_image_model_switch(cmd_original)
elif canonical == "codex-runtime":
self._handle_codex_runtime(cmd_original)
elif canonical == "gquota":
Expand Down
11 changes: 11 additions & 0 deletions gateway/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -8199,6 +8199,9 @@ async def _do_reset():
if canonical == "model":
return await self._handle_model_command(event)

if canonical == "image_model":
return await self._handle_image_model_command(event)

if canonical == "codex-runtime":
return await self._handle_codex_runtime_command(event)

Expand Down Expand Up @@ -10967,6 +10970,14 @@ async def _handle_commands_command(self, event: MessageEvent) -> str:
getattr(getattr(event, "source", None), "platform", None),
)

async def _handle_image_model_command(self, event: MessageEvent) -> str:
"""Handle /image_model command β€” switch image generation provider/model."""
from hermes_cli.image_model_switch import apply_image_model_switch

raw_args = event.get_command_args().strip() if event else ""
result = apply_image_model_switch(raw_args)
return result.message

async def _handle_model_command(self, event: MessageEvent) -> Optional[str]:
"""Handle /model command β€” switch model for this session.

Expand Down
21 changes: 19 additions & 2 deletions hermes_cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ class CommandDef:
cli_only=True),
CommandDef("model", "Switch model for this session", "Configuration",
args_hint="[model] [--provider name] [--global] [--refresh]"),
CommandDef("image_model", "Switch image generation provider/model", "Configuration",
aliases=("image-model",), args_hint="[provider|provider/model|model --provider provider]"),
CommandDef("codex-runtime", "Toggle codex app-server runtime for OpenAI/Codex models",
"Configuration", aliases=("codex_runtime",),
args_hint="[auto|codex_app_server]"),
Expand Down Expand Up @@ -341,6 +343,7 @@ def is_gateway_known_command(name: str | None) -> bool:
"commands",
"deny",
"help",
"image_model",
"new",
"profile",
"queue",
Expand Down Expand Up @@ -520,6 +523,7 @@ def telegram_bot_commands() -> list[tuple[str, str]]:
"resume",
"sessions",
"model",
"image_model",
# Maintenance / diagnostics β€” the ones that prompted this priority list.
"debug",
"restart",
Expand Down Expand Up @@ -1017,6 +1021,9 @@ def discord_skill_commands_by_category(
"topic", "mute", "pro", "shortcuts",
})

_SLACK_ALIAS_PRIORITY = ("reset", "bg", "btw", "q")
"""Common aliases that should survive Slack's 50-command cap."""


def _sanitize_slack_name(raw: str) -> str:
"""Convert a command name to a valid Slack slash command name.
Expand Down Expand Up @@ -1077,16 +1084,26 @@ def _add(name: str, desc: str, hint: str) -> None:
continue
_add(cmd.name, cmd.description, cmd.args_hint or "")

# Second pass: aliases.
# Second pass: high-value aliases that should survive the 50-command cap.
priority_aliases = set(_SLACK_ALIAS_PRIORITY)
for alias in _SLACK_ALIAS_PRIORITY:
cmd = resolve_command(alias)
if not cmd or not _is_gateway_available(cmd, overrides):
continue
_add(alias, f"Alias for /{cmd.name} β€” {cmd.description}", cmd.args_hint or "")

# Third pass: remaining aliases.
for cmd in COMMAND_REGISTRY:
if not _is_gateway_available(cmd, overrides):
continue
for alias in cmd.aliases:
if alias in priority_aliases:
continue
# Skip aliases that only differ from canonical by case/punctuation
# normalization (already covered by _add dedup).
_add(alias, f"Alias for /{cmd.name} β€” {cmd.description}", cmd.args_hint or "")

# Third pass: plugin commands.
# Fourth pass: plugin commands.
for name, description, args_hint in _iter_plugin_command_entries():
_add(name, description, args_hint or "")

Expand Down
Loading
Loading