The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(skills): built-in name collisions show a note in /skills, /help skills and the palette
teknium1b7b203cda057
diff --git a/agent/skill_commands.py b/agent/skill_commands.pyindex 1ce7098d4df..ec17a02d9a1 100644--- a/agent/skill_commands.py+++ b/agent/skill_commands.py@@ -336,7 +336,22 @@ def _scaffold_header(_SCAN_SKIP_PARTS = {'.git', '.github', '.hub', '.archive', '.locks'}-def _scan_skill_md(skill_md: Path, disabled: set, seen_names: set, commands: Dict[str, Dict[str, Any]], resolve_command) -> None:+def skill_command_collision_note(name: str) -> Optional[str]:+ """User-facing note when *name*'s slash slug is a core command (name or alias), else None.++ The single source of the collision predicate: ``scan_skill_commands`` uses it to skip+ auto-registration (the shadowing guard from 370ebf2d3 — the skill map is consulted before+ built-in handlers), and the ``/skills`` listing plus the command palette render the note so+ the skipped skill is explained where the user looks, not only in the log.+ """+ from hermes_cli.commands import resolve_command+ cmd_name = slugify_skill_name(name)+ if not cmd_name or resolve_command(cmd_name) is None:+ return None+ return f"slash command /{cmd_name} unavailable — name taken by built-in; use /skill {name}"+++def _scan_skill_md(skill_md: Path, disabled: set, seen_names: set, commands: Dict[str, Dict[str, Any]]) -> None:"""Register one SKILL.md in *commands* (no-op when filtered or colliding)."""from tools.skills_tool import _parse_frontmatter, skill_matches_platform, skill_matches_environmentif any(part in _SCAN_SKIP_PARTS for part in skill_md.parts):@@ -356,9 +371,9 @@ def _scan_skill_md(skill_md: Path, disabled: set, seen_names: set, commands: Diccmd_name = slugify_skill_name(name)if not cmd_name:return- # A collision with a core command (name or alias, via resolve_command) skips- # auto-registration; the skill stays loadable via /skill <name>.- if resolve_command(cmd_name) is not None:+ # A collision with a core command (name or alias) skips auto-registration; the skill stays+ # loadable via /skill <name>. The same predicate feeds the /skills + palette notes.+ if skill_command_collision_note(name) is not None:logger.warning("Skill %r generates slash command '/%s' which collides with a core Hermes command; ""skipping auto-registration. Use '/skill %s' instead.", name, cmd_name, name)return@@ -393,7 +408,6 @@ def scan_skill_commands() -> Dict[str, Dict[str, Any]]:from agent.skill_utils import (get_external_skills_dirs, get_project_skills_dirs, iter_project_skill_files, iter_skill_index_files,)- from hermes_cli.commands import resolve_commanddisabled = _get_disabled_skill_names()seen_names: set = set()# Precedence: project (through the quarantine chokepoint) > local > external.@@ -407,7 +421,7 @@ def scan_skill_commands() -> Dict[str, Dict[str, Any]]:for _iter in iters:for skill_md in _iter:try:- _scan_skill_md(skill_md, disabled, seen_names, commands, resolve_command)+ _scan_skill_md(skill_md, disabled, seen_names, commands)except Exception:continueexcept Exception:diff --git a/hermes_cli/cli_info_mixin.py b/hermes_cli/cli_info_mixin.pyindex 76aa226a702..1c55c38b43b 100644--- a/hermes_cli/cli_info_mixin.py+++ b/hermes_cli/cli_info_mixin.py@@ -258,12 +258,17 @@ class CLIInfoMixin:# /help skills — the full list, kept out of the default view so core commands don't# scroll off screen.if arg.lower() in ("skills", "skill"):- if not skill_commands:- _cprint("\n No skill commands installed.\n")- return- _cprint(f"\n ⚡ {_BOLD}Skill Commands{_RST} ({len(skill_commands)} installed):")- for cmd, info in sorted(skill_commands.items()):- _row(cmd, info['description'], 22)+ from agent.skill_commands import skill_command_collision_note+ from tools.skills_tool import _find_all_skills+ if skill_commands:+ _cprint(f"\n ⚡ {_BOLD}Skill Commands{_RST} ({len(skill_commands)} installed):")+ for cmd, info in sorted(skill_commands.items()):+ _row(cmd, info['description'], 22)+ else:+ _cprint("\n No skill commands installed.")+ # Skills whose name is a built-in command never get a /<name> (agent.skill_commands guard).+ for note in filter(None, (skill_command_collision_note(s["name"]) for s in _find_all_skills())):+ _cprint(f" {_DIM}⚠ {note}{_RST}")_cprint("")returndiff --git a/hermes_cli/skills_hub.py b/hermes_cli/skills_hub.pyindex e46e1725b60..9731b57ce17 100644--- a/hermes_cli/skills_hub.py+++ b/hermes_cli/skills_hub.py@@ -783,6 +783,7 @@ def do_list(source_filter: str = "all", enabled_only: bool = False,from tools.skills_sync import _read_manifestfrom tools.skills_tool import _find_all_skillsfrom agent.skill_utils import get_disabled_skill_names+ from agent.skill_commands import skill_command_collision_notec = console or _consoleensure_hub_dirs()hub_installed = {e["name"]: e for e in HubLockFile().list_installed()}@@ -809,9 +810,12 @@ def do_list(source_filter: str = "all", enabled_only: bool = False,counts[source_type] += 1enabled_count += is_enableddisabled_count += not is_enabled+ status = "[bold green]enabled[/]" if is_enabled else "[dim red]disabled[/]"+ # Name taken by a built-in: the skill loads but has no /<name> (see agent.skill_commands).+ if note := skill_command_collision_note(name):+ status += f"\n[yellow]{note}[/]"table.add_row(name, skill.get("category", ""), source_display,- _trust_cell(trust, source_display),- "[bold green]enabled[/]" if is_enabled else "[dim red]disabled[/]")+ _trust_cell(trust, source_display), status)c.print(table)tail = (f"{enabled_count} enabled shown" if enabled_onlydiff --git a/hermes_cli/slash_exec.py b/hermes_cli/slash_exec.pyindex c590ba66094..876f355747c 100644--- a/hermes_cli/slash_exec.py+++ b/hermes_cli/slash_exec.py@@ -140,6 +140,11 @@ def _exec_commands(ctx: CommandContext) -> CommandReply:for cmd in sorted(skill_cmds):desc = skill_cmds[cmd].get("description", "").strip() or t("gateway.commands.default_desc")entries.append(f"`{cmd}` — {desc}")+ # Skills kept off the menu because a built-in owns the name (agent.skill_commands guard).+ from agent.skill_commands import skill_command_collision_note+ from tools.skills_tool import _find_all_skills+ entries.extend(f"⚠ {note}" for note in filter(None, map(+ skill_command_collision_note, sorted(s["name"] for s in _find_all_skills()))))except Exception:passdiff --git a/tests/hermes_cli/test_skill_collision_visibility.py b/tests/hermes_cli/test_skill_collision_visibility.pynew file mode 100644index 00000000000..0998ef7ed35--- /dev/null+++ b/tests/hermes_cli/test_skill_collision_visibility.py@@ -0,0 +1,59 @@+"""A skill named like a built-in command is kept out of auto-registration (the 370ebf2d3 guard)+and every listing surface says so where the user looks: the ``/skills`` table, ``/help skills``+and the ``commands.catalog`` palette RPC. A non-colliding skill carries no note."""+from __future__ import annotations++import contextlib+import io++from rich.console import Console++from hermes_constants import get_hermes_home++NOTE = "slash command /handoff unavailable — name taken by built-in; use /skill handoff"+++def _write_skill(name: str) -> None:+ skill_dir = get_hermes_home() / "skills" / name+ skill_dir.mkdir(parents=True)+ (skill_dir / "SKILL.md").write_text(f"---\nname: {name}\ndescription: {name} skill.\n---\n# {name}\n", encoding="utf-8")+++def test_built_in_name_collision_is_visible_on_every_listing_surface(monkeypatch):+ import cli+ import tools.skills_tool as skills_tool+ from hermes_cli.cli_info_mixin import CLIInfoMixin+ from hermes_cli.skills_hub import do_list+ from tui_gateway import server++ _write_skill("handoff") # core CommandDef → dropped by scan_skill_commands+ _write_skill("tidy-notes") # control+ monkeypatch.setattr(skills_tool, "_SKILLS_CACHE", {})+ monkeypatch.setattr(cli, "_skill_commands", None)++ sink = io.StringIO()+ do_list(console=Console(file=sink, force_terminal=False, color_system=None, width=200))+ skills_table = sink.getvalue()+ assert NOTE in skills_table+ assert "tidy-notes" in skills_table and skills_table.count("unavailable") == 1++ class _Cli(CLIInfoMixin):+ config: dict = {}++ def _command_available(self, slash_command):+ return True++ help_out = io.StringIO()+ with contextlib.redirect_stdout(help_out):+ _Cli().show_help("skills")+ assert NOTE in help_out.getvalue()+ assert "/tidy-notes" in help_out.getvalue() and "/handoff" not in help_out.getvalue().replace(NOTE, "")++ catalog = server._methods["commands.catalog"](1, {})["result"]+ assert catalog["warning"] == NOTE+ assert "/tidy-notes" in catalog["skills"] and "/handoff" not in catalog["skills"]++ from hermes_cli.slash_exec import CommandContext, _exec_commands++ gateway_commands = _exec_commands(CommandContext(args="", options={"page_size": 500})).text+ assert f"⚠ {NOTE}" in gateway_commands and "`/tidy-notes`" in gateway_commandsdiff --git a/tui_gateway/methods_tools.py b/tui_gateway/methods_tools.pyindex e65800a7f4e..b260bca1e31 100644--- a/tui_gateway/methods_tools.py+++ b/tui_gateway/methods_tools.py@@ -425,21 +425,28 @@ def _catalog_plugin_commands(cat: _Catalog) -> None:cat.commands[key] = {"argument_mode": mode, "desktop": None}-def _catalog_skills(cat: _Catalog, skills: dict[str, dict]) -> None:- """Append skill pairs and fill ``skills`` = ``{key: {usage, origin}}`` (every consumer ranks by them)."""+def _catalog_skills(cat: _Catalog, skills: dict[str, dict]) -> str:+ """Append skill pairs and fill ``skills`` = ``{key: {usage, origin}}`` (every consumer ranks by them).+ Returns the one-line notice for skills whose name is a built-in command (no ``/<name>`` entry;+ ``agent.skill_commands`` guard), ``""`` when none."""usage, origin_of = _skill_usage_lookup()- for k, info in sorted(_tools_mod("agent.skill_commands").scan_skill_commands().items()):+ sc = _tools_mod("agent.skill_commands")+ for k, info in sorted(sc.scan_skill_commands().items()):cat.pairs.append([k, str(info.get("description", "Skill"))])name = str(info.get("name") or k.lstrip("/"))skills[k] = {"usage": usage(name), "origin": origin_of(name)}+ names = sorted(s["name"] for s in _tools_mod("tools.skills_tool")._find_all_skills())+ return "; ".join(filter(None, map(sc.skill_command_collision_note, names)))@_rpc("commands.catalog", 5020)def _(rid, params: dict) -> dict:"""Registry-backed slash metadata, categorized, no aliases. Discovery failures land in ``warning``- (skills' message wins, then quick commands', then plugins'). Skill discovery is bound to the calling- session's profile and workspace (``_completion_cwd``: its record, else the cwd a new session would be- seeded with) so project-local skills register for the repo the session is actually in (#114359)."""+ (skills' message wins, then quick commands', then plugins'); with no failure it carries the+ built-in-name collision notice for skills that have no ``/<name>`` (empty when none). Skill+ discovery is bound to the calling session's profile and workspace (``_completion_cwd``: its record,+ else the cwd a new session would be seeded with) so project-local skills register for the repo the+ session is actually in (#114359)."""cat = _Catalog()_catalog_registry(cat)warning = ""@@ -454,7 +461,7 @@ def _(rid, params: dict) -> dict:skills: dict[str, dict] = {}try:with _session_home_scope(_sessions.get(params.get("session_id", "")), cwd=_completion_cwd(params)):- _catalog_skills(cat, skills)+ warning = _catalog_skills(cat, skills) or warningexcept Exception as e:warning = f"skill discovery unavailable: {e}"return _ok(rid, {diff --git a/website/docs/reference/slash-commands.md b/website/docs/reference/slash-commands.mdindex eb10b324834..527735c827c 100644--- a/website/docs/reference/slash-commands.md+++ b/website/docs/reference/slash-commands.md@@ -11,7 +11,7 @@ Hermes has two slash-command surfaces, both driven by a central `COMMAND_REGISTR- **Interactive CLI slash commands** — dispatched by `cli.py`, with autocomplete from the registry- **Messaging slash commands** — dispatched by `gateway/run.py`, with help text and platform menus generated from the registry-Installed skills are also exposed as dynamic slash commands on both surfaces. (`/plan` used to be one of these; it is now a built-in command — see the Session table below.)+Installed skills are also exposed as dynamic slash commands on both surfaces. (`/plan` used to be one of these; it is now a built-in command — see the Session table below.) A skill whose name matches a built-in command (or one of its aliases) never gets its own `/<name>` — the built-in wins and the skill stays loadable via `/skill <name>`; `/skills list`, `/help skills` and the command palette mark such a skill with `slash command /<name> unavailable — name taken by built-in; use /skill <name>`.## Permissions and admin/user split