Skip to content

The agent that grows with you

fix(skills): installing a built-in skill by name makes it available instead of failing

Teknium53a9fa830d1d
diff --git a/hermes_cli/skills_hub.py b/hermes_cli/skills_hub.py
index 26ba2de2d5a..f6e9af6de13 100644
--- a/hermes_cli/skills_hub.py
+++ b/hermes_cli/skills_hub.py
@@ -702,7 +702,26 @@ def _confirm_install(c: Console, bundle, category: str) -> bool:
cancel="[dim]Installation cancelled.[/]\n")
-_SKILL_METRIC_SOURCES = {"official": "catalog", "url": "url"}
+_SKILL_METRIC_SOURCES = {"official": "catalog", "url": "url", "bundled": "bundled"}
+
+
+def _install_bundled(c: Console, name: str, invalidate_cache: bool) -> tuple:
+ """``_install_skill`` for a name Hermes ships: point at the active copy, or restore it from the
+ bundled source. The hub copy of a built-in is either a stranger's same-named skill or this
+ repo's files rescanned as community content and refused, so neither is fetched."""
+ from types import SimpleNamespace
+ from tools.skills_sync_bundled_ops import ensure_bundled_skill
+ result = ensure_bundled_skill(name)
+ if not result["ok"]:
+ _print_error(c, result["message"])
+ return None, "failed", False
+ if result["action"] == "present":
+ where = f" at {result['path']}" if result["path"] else ""
+ c.print(f"[green]'{name}' is a built-in skill and is already available{where}.[/]\n")
+ return None, None, None
+ c.print(f"[bold green]Restored built-in skill:[/] {name} [dim]({result['path']})[/]\n")
+ _finish_change(c, invalidate_cache, "Skill will be available", "activate")
+ return SimpleNamespace(name=name, source="bundled"), "success", True
def _record_skill_install(identifier: str, bundle, outcome: str) -> None:
@@ -755,6 +774,9 @@ def _install_skill(identifier: str, category: str, force: bool, c: Console, skip
from tools.skills_hub_install import install_from_quarantine, quarantine_bundle
from tools.skills_guard import should_allow_install
ensure_hub_dirs()
+ from tools.skills_sync_bundled_ops import bundled_skill_for_install
+ if not source_id and not name_override and (builtin := bundled_skill_for_install(identifier)):
+ return _install_bundled(c, builtin, invalidate_cache)
sources = _pinned_sources(c, _sources(), source_id, identifier)
if sources is None:
return None, "failed", False
diff --git a/tests/hermes_cli/test_skills_hub.py b/tests/hermes_cli/test_skills_hub.py
index e8127a24d37..c5a0a8e729f 100644
--- a/tests/hermes_cli/test_skills_hub.py
+++ b/tests/hermes_cli/test_skills_hub.py
@@ -734,3 +734,25 @@ def test_skills_command_exit_code_follows_install_verdict(monkeypatch, verdict,
# The router returns the code; `hermes` (main()) turns a handler's int into the exit status.
assert cli_hub.skills_command(args) == expected_exit
+
+
[email protected]("identifier", [
+ "computer-use", "NousResearch/hermes-agent/skills/productivity/pdf",
+ "skills-sh/nousresearch/hermes-agent/google-workspace"])
+def test_install_of_a_bundled_name_restores_it_and_never_touches_the_hub(monkeypatch, identifier):
+ """`hermes skills install <bundled skill>` failed every time: the name resolved to a stranger's
+ same-named hub skill or an ambiguity table, and this repo's own copy was rescanned as community
+ content and refused. It now makes the shipped skill active and fetches nothing."""
+ import hermes_cli.skills_hub as cli_hub
+ from tools import skills_sync
+
+ monkeypatch.setattr(cli_hub, "_sources", lambda: pytest.fail("a bundled skill must not hit the hub"))
+ name = identifier.rsplit("/", 1)[-1]
+ console, sink = _sink_console()
+
+ assert cli_hub.do_install(identifier, console=console, skip_confirm=True) is True
+ assert "Restored built-in skill" in sink.getvalue()
+ assert name in skills_sync._read_manifest()
+ assert any(skills_sync._read_skill_name(md, "") == name for md in skills_sync._iter_active_skill_mds())
+ # Already active now: a no-op the user owns, not a failure (exit 0, no reinstall).
+ assert cli_hub.do_install(identifier, console=console, skip_confirm=True) is None
diff --git a/tools/connectors/catalog.py b/tools/connectors/catalog.py
index 8d14fce1067..47c4dcd5c11 100644
--- a/tools/connectors/catalog.py
+++ b/tools/connectors/catalog.py
@@ -117,9 +117,12 @@ class HostInstaller:
if before is not None and not force:
return {"name": str(before["name"]), "already_installed": True}
out = io.StringIO()
- do_install(identifier, force=force, skip_confirm=True,
- console=Console(file=out, width=200, no_color=True, highlight=False))
+ verdict = do_install(identifier, force=force, skip_confirm=True,
+ console=Console(file=out, width=200, no_color=True, highlight=False))
after = entry()
+ from tools.skills_sync_bundled_ops import bundled_skill_for_install
+ if after is None and verdict is not False and (builtin := bundled_skill_for_install(identifier)):
+ return {"name": builtin, "already_installed": verdict is None} # shipped skill, no hub lock entry
if after is None or (before is not None and after.get("updated_at") == before.get("updated_at")):
lines = [line.strip() for line in out.getvalue().splitlines() if line.strip()]
raise RuntimeError(lines[-1] if lines else "the skill was not installed")
diff --git a/tools/skills_sync_bundled_ops.py b/tools/skills_sync_bundled_ops.py
index 5f66e12025d..7c9b57dac34 100644
--- a/tools/skills_sync_bundled_ops.py
+++ b/tools/skills_sync_bundled_ops.py
@@ -58,6 +58,45 @@ def reset_bundled_skill(name: str, restore: bool = False) -> dict:
return {"ok": True, "action": action, "message": message, "synced": synced}
+_OWN_REPO_PREFIXES = ("nousresearch/hermes-agent/skills/", "skills-sh/nousresearch/hermes-agent/")
+
+
+def bundled_skill_for_install(identifier: str) -> Optional[str]:
+ """Bundled skill name an install identifier means, else None: a bare bundled name, or this
+ repo's own copy of one (``NousResearch/hermes-agent/skills/<cat>/<name>``, which the Skills Hub
+ site hands out for built-ins, or its ``skills-sh/nousresearch/hermes-agent/<name>`` mirror).
+ Fetched from GitHub, that copy is scanned as a community skill and refused — every time."""
+ ident = identifier.strip().strip("/")
+ lowered = ident.lower()
+ if "/" in ident and not lowered.startswith(_OWN_REPO_PREFIXES):
+ return None
+ name = ident.rsplit("/", 1)[-1]
+ return name if name in _bundled_state()[3] else None
+
+
+def ensure_bundled_skill(name: str) -> dict:
+ """Make bundled ``name`` active: ``{ok, action, path, message}``, action ``present`` (any active
+ copy, user edits included, is left alone) or ``restored`` (copied from the bundled source and
+ re-tracked, so an opt-out, curator prune or manual delete no longer hides it)."""
+ ss, manifest, bundled_dir, bundled_by_name = _bundled_state()
+ src = bundled_by_name[name]
+ dest = ss._compute_relative_dest(src, bundled_dir)
+ active = next((md.parent for md in ss._iter_active_skill_mds()
+ if ss._read_skill_name(md, md.parent.name) == name), None)
+ if active is not None or name in ss._build_external_skill_index():
+ return {"ok": True, "action": "present", "path": active, "message": ""}
+ try:
+ ss._copy_dir(src, dest)
+ except OSError as e:
+ return {"ok": False, "action": "not_restored", "path": dest,
+ "message": f"Could not copy the built-in skill '{name}' to {dest}: {e}"}
+ manifest[name] = ss._dir_hash(src)
+ ss._write_manifest(manifest)
+ from tools.skill_usage import _toggle_suppressed_name
+ _toggle_suppressed_name(name, add=False)
+ return {"ok": True, "action": "restored", "path": dest, "message": ""}
+
+
def list_user_modified_bundled_skills() -> List[dict]:
"""Bundled skills ``hermes update`` keeps because the user edited them (same test the sync
loop uses). Name-sorted ``{"name", "dest", "bundled_src"}`` dicts."""
diff --git a/tui_gateway/methods_tools.py b/tui_gateway/methods_tools.py
index 8e75cc17f5a..5c5ef24b922 100644
--- a/tui_gateway/methods_tools.py
+++ b/tui_gateway/methods_tools.py
@@ -1472,6 +1472,9 @@ def _skills_install(rid, params, query):
verdict = _tools_mod("hermes_cli.skills_hub").do_install(
query, skip_confirm=True, console=captured)
installed = verdict is True
+ bundled = _tools_mod("tools.skills_sync_bundled_ops").bundled_skill_for_install
+ if verdict is None and bundled(query): # a shipped skill that is already active is no failure
+ return _ok(rid, {"installed": True, "name": query})
if not installed:
# The tail carries the reason the CLI user would have seen: the scan-block message,
# the "Multiple skills named" candidate table, or the fetch failure.