Skip to content

The agent that grows with you

fix(skills): manage_catalog reads a ClawHub install back through its card id

Austin Pickett22b67fd50c0e
diff --git a/tests/tools/test_connectors_catalog.py b/tests/tools/test_connectors_catalog.py
index b45b92655a1..cbc034db118 100644
--- a/tests/tools/test_connectors_catalog.py
+++ b/tests/tools/test_connectors_catalog.py
@@ -6,6 +6,7 @@ Contracts:
- the model sends catalog ids and an action; every other key is refused before anything runs
- an id the catalog does not know, or a plugin this OS cannot run, is drawn failed and never installed
- an approved row installs and reports what went live; the card never witnesses the outcome
+- a ClawHub skill reads as installed through the id its hub source lists, never another source's
"""
import json
@@ -69,7 +70,7 @@ class FakeInstaller:
def skill_meta(self, identifier):
return None
- def install_skill(self, identifier, *, force):
+ def install_skill(self, identifier, *, force, source=None):
raise AssertionError("no skill in these tests")
@@ -276,3 +277,68 @@ def test_a_failed_row_keeps_its_reason_and_try_again_works_while_the_card_is_ope
(row,) = out["targets"]
assert out["settled_by"] == "all_resolved"
assert (row["state"], row["detail"]) == (TargetState.failed.value, "clone failed: network down")
+
+
+class ClawHubSkillInstaller(FakeInstaller):
+ """One skill, resolved the way the hub index resolves a ClawHub hit: its bare slug."""
+
+ def skill_meta(self, identifier):
+ return {"name": "Agent Git Oracle", "description": "Repository analysis.", "source": "clawhub",
+ "identifier": identifier}
+
+ def install_skill(self, identifier, *, force, source=None):
+ self.installs.append({"identifier": identifier, "source": source})
+ return {"name": identifier, "already_installed": False}
+
+
+def test_a_skill_row_installs_with_the_source_that_resolved_it():
+ installer = ClawHubSkillInstaller()
+
+ out = _install([{"kind": "skill", "id": "agent-git-oracle"}], installer, _card(_approve()))
+
+ assert out["targets"][0]["state"] == TargetState.connected.value
+ assert installer.installs == [{"identifier": "agent-git-oracle", "source": "clawhub"}]
+
+
+def test_a_clawhub_install_is_read_back_through_its_card_id(monkeypatch):
+ # The lock records @owner/slug. Matching the bare slug exactly, a finished install raised its
+ # last printed line ("Files: ...") and a second one raised "Use --force to reinstall."
+ from tools.connectors.catalog import HostInstaller
+ from tools.skills_hub import HubLockFile
+
+ installs = []
+
+ def do_install(identifier, **_):
+ installs.append(identifier)
+ HubLockFile().record_install(
+ name="agent-git-oracle", source="clawhub", identifier="@tmstudio667-commits/agent-git-oracle",
+ trust_level="community", scan_verdict="safe", skill_hash="0" * 64,
+ install_path="agent-git-oracle", files=["SKILL.md"])
+ return True
+
+ monkeypatch.setattr("hermes_cli.skills_hub.do_install", do_install)
+ installer = HostInstaller()
+
+ assert installer.install_skill("agent-git-oracle", force=False, source="clawhub") == {
+ "name": "agent-git-oracle", "already_installed": False}
+ assert installer.install_skill("agent-git-oracle", force=False, source="clawhub")["already_installed"]
+ assert installer.install_skill("clawhub/agent-git-oracle", force=False)["already_installed"]
+ assert installs == ["agent-git-oracle"]
+
+
+def test_search_rows_mark_an_installed_clawhub_hit_but_not_another_sources_bare_id(monkeypatch):
+ from tools.connectors.catalog_tool import _skill_rows
+ from tools.skills_hub import HubLockFile
+ from tools.skills_hub_models import SkillMeta
+
+ HubLockFile().save({"version": 1, "installed": {"agent-git-oracle": {
+ "source": "clawhub", "identifier": "@tmstudio667-commits/agent-git-oracle",
+ "install_path": "agent-git-oracle"}}})
+ hits = [SkillMeta(name=name, description="", source=source, identifier="agent-git-oracle",
+ trust_level="community")
+ for name, source in (("Agent Git Oracle", "clawhub"), ("agent-git-oracle", "skills-sh"))]
+ monkeypatch.setattr("tools.skills_hub_github.GitHubAuth", lambda: None)
+ monkeypatch.setattr("tools.skills_hub_search.create_source_router", lambda auth: [])
+ monkeypatch.setattr("tools.skills_hub_search.unified_search", lambda query, sources, limit: hits)
+
+ assert [row["installed"] for row in _skill_rows("agent git oracle")] == [True, False]
diff --git a/tools/connectors/catalog.py b/tools/connectors/catalog.py
index 31beefcfc7d..9323ffcac73 100644
--- a/tools/connectors/catalog.py
+++ b/tools/connectors/catalog.py
@@ -112,17 +112,19 @@ class HostInstaller:
"identifier": meta.identifier or identifier}
return None
- def install_skill(self, identifier: str, *, force: bool) -> dict[str, Any]:
+ def install_skill(self, identifier: str, *, force: bool, source: Optional[str] = None) -> dict[str, Any]:
"""Install headless; ``{name, already_installed}``. ``do_install`` reports only by printing, so
success is read from the hub lock file and failure from its last line. A skill that is already
- installed (force off) is left as it is and reported so."""
+ installed (force off) is left as it is and reported so. ``source`` is the hub source that
+ resolved ``identifier``; the lock records a ClawHub skill as ``@owner/slug``, so a ClawHub
+ hit's bare slug is read back through its ``clawhub/<slug>`` card id."""
from rich.console import Console
from hermes_cli.skills_hub import do_install
- from tools.skills_hub import HubLockFile
+ from tools.skills_hub import HubLockFile, installed_entry
def entry() -> Optional[dict[str, Any]]:
- return next((e for e in HubLockFile().list_installed() if e.get("identifier") == identifier), None)
+ return installed_entry(HubLockFile().by_identifier(), identifier, source)
before = entry()
if before is not None and not force:
@@ -264,9 +266,10 @@ class _Runner:
with target_scope(_named_home(named) if named else self.home):
_save_credentials({k: v for k, v in env.items() if k not in _OPTION_KEYS and v})
if target.kind == "skill":
- identifier = str(self.facts[target.name].get("identifier") or target.name)
+ meta = self.facts[target.name]
+ identifier = str(meta.get("identifier") or target.name)
step(InstallPhase.downloading)
- return self.installer.install_skill(identifier, force=options["force"])
+ return self.installer.install_skill(identifier, force=options["force"], source=meta.get("source"))
result = self.installer.install_plugin(target.name, force=options["force"], enable=options["enable"],
ref=options["ref"], on_step=step)
if not result.get("ok"):
diff --git a/tools/connectors/catalog_tool.py b/tools/connectors/catalog_tool.py
index cc967602eaa..20cecc95a7a 100644
--- a/tools/connectors/catalog_tool.py
+++ b/tools/connectors/catalog_tool.py
@@ -174,12 +174,12 @@ def _plugin_rows(query: str) -> list[dict[str, Any]]:
def _skill_rows(query: str) -> list[dict[str, Any]]:
- from tools.skills_hub import HubLockFile
+ from tools.skills_hub import HubLockFile, installed_entry
from tools.skills_hub_github import GitHubAuth
from tools.skills_hub_search import create_source_router, unified_search
- installed = {str(e.get("identifier")) for e in HubLockFile().list_installed()}
+ installed = HubLockFile().by_identifier()
return [{"id": r.identifier, "kind": "skill", "display": r.name,
"tier": "official" if r.source == "official" else "community", "platforms": [],
- "installed": r.identifier in installed}
+ "installed": installed_entry(installed, r.identifier, r.source) is not None}
for r in unified_search(query, create_source_router(GitHubAuth()), limit=SEARCH_LIMIT)]
diff --git a/tools/skills_hub.py b/tools/skills_hub.py
index f5f20ad61ea..eb7441be119 100644
--- a/tools/skills_hub.py
+++ b/tools/skills_hub.py
@@ -398,6 +398,21 @@ class HubLockFile(_JsonStateFile):
return installed
+def installed_entry(installed: dict[str, dict], identifier: str,
+ source: Optional[str] = None) -> Optional[dict]:
+ """The ``HubLockFile.by_identifier`` entry a hub result names. Search and the index list a
+ ClawHub skill by its bare slug, so a ``source="clawhub"`` result also matches through its
+ ``clawhub/<slug>`` card id. Any other source matches its exact id only."""
+ if identifier in installed:
+ return installed[identifier]
+ if source != "clawhub":
+ return None
+ from tools.skills_hub_clawhub import ClawHubSource
+
+ alias = ClawHubSource.catalog_identifier(identifier)
+ return installed.get(alias) if alias else None
+
+
class TapsManager(_JsonStateFile):
"""skills/.hub/taps.json — custom GitHub repo sources."""