Skip to content

The agent that grows with you

fix(skills): built-in restore stays in the skills tree, marks the skill active, and names a hub install that shadows it

Tekniumaf4f663ab8b2
diff --git a/hermes_cli/skills_hub.py b/hermes_cli/skills_hub.py
index f6e9af6de13..fdabce982ef 100644
--- a/hermes_cli/skills_hub.py
+++ b/hermes_cli/skills_hub.py
@@ -715,6 +715,9 @@ def _install_bundled(c: Console, name: str, invalidate_cache: bool) -> tuple:
if not result["ok"]:
_print_error(c, result["message"])
return None, "failed", False
+ if result["action"] == "hub_shadowed": # not the built-in, so exit 1; the hub install stays (no install event)
+ _print_error(c, result["message"])
+ return None, None, 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")
diff --git a/tests/hermes_cli/test_skills_hub.py b/tests/hermes_cli/test_skills_hub.py
index a57e803de4c..41aec0d020f 100644
--- a/tests/hermes_cli/test_skills_hub.py
+++ b/tests/hermes_cli/test_skills_hub.py
@@ -694,20 +694,54 @@ def test_resolve_short_name_matches_identifier_slug(monkeypatch):
@pytest.mark.parametrize("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):
+def test_install_of_a_bundled_name_restores_it_and_never_touches_the_hub(monkeypatch, tmp_path, 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
+ import tools.skills_hub as hub
+ from tools import skill_usage
+ from tools.skills_hub import HubLockFile
+
+ # hub_env's undo leaves its resolved paths as real globals; drop them so the hub follows the profile.
+ for stale in [n for n in vars(hub) if n.isupper() and n.endswith(("_DIR", "_FILE", "_LOG"))]:
+ monkeypatch.delitem(vars(hub), stale)
monkeypatch.setattr(cli_hub, "_sources", lambda: pytest.fail("a bundled skill must not hit the hub"))
name = identifier.rsplit("/", 1)[-1]
+ # The curator pruned it (prune_builtins on): suppressed from re-seeding and recorded archived.
+ monkeypatch.setattr(skill_usage, "_prune_builtins_enabled", lambda: True)
+ skill_usage._toggle_suppressed_name(name, add=True)
+ skill_usage.save_usage({name: {"state": skill_usage.STATE_ARCHIVED}})
+ # A symlinked category must not carry the restore out of the skills tree (the hub's guard).
+ category = skill_usage._skills_dir() / dict(skills_sync._discover_bundled_skills(
+ skills_sync._get_bundled_dir()))[name].parent.name
+ (outside := tmp_path / "outside").mkdir()
+ category.parent.mkdir(parents=True, exist_ok=True)
+ category.symlink_to(outside, target_is_directory=True)
console, sink = _sink_console()
+ assert cli_hub.do_install(identifier, console=console, skip_confirm=True) is False
+ assert not any(outside.iterdir())
+ category.unlink()
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())
+ assert name not in skill_usage.read_suppressed_names()
+ assert skill_usage.load_usage()[name]["state"] == skill_usage.STATE_ACTIVE
# 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
+ # A hub skill that took the name is reported as such (with the way back), never as the built-in.
+ stranger = skill_usage._skills_dir() / "hub-installs" / name
+ stranger.mkdir(parents=True)
+ (stranger / "SKILL.md").write_text(f"---\nname: {name}\n---\nstranger\n")
+ HubLockFile().record_install(name=name, source="skills-sh", identifier=f"skills-sh/x/y/{name}",
+ trust_level="community", scan_verdict="safe", skill_hash="h",
+ install_path=f"hub-installs/{name}", files=["SKILL.md"])
+ console, sink = _sink_console()
+ assert cli_hub.do_install(identifier, console=console, skip_confirm=True) is False
+ out = " ".join(sink.getvalue().split())
+ assert "already available" not in out and f"hermes skills uninstall {name}" in out
+ assert (stranger / "SKILL.md").read_text().endswith("stranger\n")
diff --git a/tools/skills_sync_bundled_ops.py b/tools/skills_sync_bundled_ops.py
index 7c9b57dac34..a0380fc3546 100644
--- a/tools/skills_sync_bundled_ops.py
+++ b/tools/skills_sync_bundled_ops.py
@@ -76,24 +76,34 @@ def bundled_skill_for_install(identifier: str) -> Optional[str]:
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)."""
+ copy, user edits included, is left alone), ``restored`` (copied from the bundled source and
+ re-tracked, so an opt-out, curator prune or manual delete no longer hides it), or
+ ``hub_shadowed`` (a hub install owns the name; it is the user's to remove, never overwritten)."""
+ from tools import skill_usage
ss, manifest, bundled_dir, bundled_by_name = _bundled_state()
src = bundled_by_name[name]
dest = ss._compute_relative_dest(src, bundled_dir)
+ if skill_usage.is_hub_installed(name):
+ return {"ok": True, "action": "hub_shadowed", "path": None, "message": (
+ f"'{name}' is a built-in skill, but a skill installed from the hub uses the same name and "
+ f"shadows it. To get the built-in back: `hermes skills uninstall {name}`, then "
+ f"`hermes skills install {name}`.")}
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:
+ try: # the hub's containment check: a symlinked category must not carry the copy out of skills/
+ from tools.skills_hub_install import _resolve_lock_install_path
+ rel = dest.relative_to(ss._skills_dir()).as_posix()
+ _resolve_lock_install_path(rel, dest.name)
ss._copy_dir(src, dest)
- except OSError as e:
+ except (OSError, ValueError) 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)
+ skill_usage._toggle_suppressed_name(name, add=False) # lift a curator prune the way restore_skill does
+ skill_usage.set_state(name, skill_usage.STATE_ACTIVE)
return {"ok": True, "action": "restored", "path": dest, "message": ""}
diff --git a/tui_gateway/methods_tools.py b/tui_gateway/methods_tools.py
index 5c5ef24b922..571f62a6070 100644
--- a/tui_gateway/methods_tools.py
+++ b/tui_gateway/methods_tools.py
@@ -1469,12 +1469,9 @@ def _skills_install(rid, params, query):
self.lines.append(" ".join(str(a) for a in args))
captured = _Capture()
- verdict = _tools_mod("hermes_cli.skills_hub").do_install(
- query, skip_confirm=True, console=captured)
- installed = verdict is True
+ verdict = _tools_mod("hermes_cli.skills_hub").do_install(query, skip_confirm=True, console=captured)
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})
+ installed = verdict is True or (verdict is None and bool(bundled(query))) # an active built-in is no failure
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.