The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(skills): match a ClawHub install by source, not through a bare slug alias
Austin Pickett82d7e2dba798
diff --git a/apps/desktop/src/app/capabilities/index.test.tsx b/apps/desktop/src/app/capabilities/index.test.tsxindex cec11a42570..329b3cc872f 100644--- a/apps/desktop/src/app/capabilities/index.test.tsx+++ b/apps/desktop/src/app/capabilities/index.test.tsx@@ -567,7 +567,7 @@ describe('CapabilitiesView toolset management', { timeout: 60_000 }, () => {[['@tmstudio667-commits/agent-git-oracle', 'agent-git-oracle'],['@liujiang817/my-pdf', 'my-pdf']- ].flatMap(([id, name]) => [id, `clawhub/${name}`, name].map(key => [key, record(name)]))+ ].flatMap(([id, name]) => [id, `clawhub/${name}`].map(key => [key, record(name)])))const api = vi.fn(async ({ path }: { path: string }) => {diff --git a/hermes_cli/web_server_profiles.py b/hermes_cli/web_server_profiles.pyindex 6a474887adf..91ab029a062 100644--- a/hermes_cli/web_server_profiles.py+++ b/hermes_cli/web_server_profiles.py@@ -469,25 +469,19 @@ def _installed_hub_identifiers(profile: Optional[str] = None) -> dict:HubLockFile takes an explicit path, sidestepping the import-time LOCK_FILE binding. {} whenunreadable.- A ClawHub row is also listed under ``ClawHubSource.catalog_identifiers``, so a card's- ``clawhub/<slug>`` and a search hit's bare slug match the lock's ``@owner/slug``. Exact- lock ids win."""+ Keyed by ``HubLockFile.by_identifier``, so a ClawHub install also answers to the+ ``clawhub/<slug>`` id a catalog card installs. Search lists a ClawHub skill by its bare+ slug; a client looks such a hit up under that card id, going by the hit's source."""try:from tools.skills_hub import HubLockFile- from tools.skills_hub_clawhub import ClawHubSourceif _is_current_profile(profile):lock = HubLockFile()else:profile_dir = _resolve_profile_dir(profile.strip())lock = HubLockFile(profile_dir / "skills" / ".hub" / "lock.json")keys = ("name", "trust_level", "scan_verdict")- rows = [entry for entry in lock.list_installed() if entry.get("identifier")]- installed = {entry["identifier"]: {k: entry.get(k) for k in keys} for entry in rows}- for entry in rows:- if entry.get("source") == "clawhub":- for alias in ClawHubSource.catalog_identifiers(entry["identifier"]):- installed.setdefault(alias, installed[entry["identifier"]])- return installed+ return {identifier: {k: entry.get(k) for k in keys}+ for identifier, entry in lock.by_identifier().items()}except HTTPException:raise # an unknown profile is the scope's 404, not an unreadable lock fileexcept Exception:diff --git a/tests/hermes_cli/test_installed_hub_identifiers.py b/tests/hermes_cli/test_installed_hub_identifiers.pyindex 39c5a2aeac5..da85b976358 100644--- a/tests/hermes_cli/test_installed_hub_identifiers.py+++ b/tests/hermes_cli/test_installed_hub_identifiers.py@@ -1,9 +1,9 @@"""Installed state for hub skills: the ``installed`` map that ``/api/skills/hub/sources``,-``/search`` and ``/official`` return, which Desktop catalog cards and the dashboard's hub-search check with ``installed[identifier]``.+``/search`` and ``/official`` return. Desktop catalog cards look themselves up by the id+they install; the dashboard looks a hub hit up by its id and, for ClawHub, its card id.-ClawHub records ``@owner/slug`` in the lock, while a catalog card installs-``clawhub/<slug>`` and the hermes-index / hub search list the bare slug."""+ClawHub records ``@owner/slug`` in the lock, a catalog card installs ``clawhub/<slug>``,+and the hermes-index / hub search list the bare slug."""import asyncio@@ -21,7 +21,7 @@ def _lock(*rows):for source, identifier, name in rows}})-def test_clawhub_install_answers_to_the_card_and_search_ids():+def test_clawhub_install_answers_to_the_card_id():_lock(("clawhub", "@tmstudio667-commits/agent-git-oracle", "agent-git-oracle"),("clawhub", "legacy-slug", "legacy-slug"))@@ -30,11 +30,18 @@ def test_clawhub_install_answers_to_the_card_and_search_ids():record = installed["@tmstudio667-commits/agent-git-oracle"]assert record["name"] == "agent-git-oracle"assert installed["clawhub/agent-git-oracle"] == record- assert installed["agent-git-oracle"] == record# A lock row from before owners were recorded keeps its bare id and gains the card id.assert installed["clawhub/legacy-slug"] == installed["legacy-slug"]+def test_a_clawhub_install_never_answers_for_another_sources_bare_id():+ # Only the source-qualified card id is added: a bare `foo` from any other source+ # must not read installed because @alice/foo is.+ _lock(("clawhub", "@alice/foo", "foo-fork"))++ assert set(_installed_hub_identifiers()) == {"@alice/foo", "clawhub/foo"}++def test_other_sources_keep_their_exact_ids_only():_lock(("skills.sh", "skills-sh/browserbase/skills/browser", "browser"),("official", "official/research/arxiv", "arxiv"),@@ -46,16 +53,14 @@ def test_other_sources_keep_their_exact_ids_only():def test_an_exact_lock_id_beats_a_clawhub_alias():- _lock(("hermes-index", "foo", "foo"), ("clawhub", "@alice/foo", "foo-fork"))-- installed = _installed_hub_identifiers()+ _lock(("clawhub", "@alice/foo", "foo-fork"), ("clawhub", "clawhub/foo", "foo"))- assert installed["foo"]["name"] == "foo"- assert installed["clawhub/foo"]["name"] == "foo-fork"+ assert _installed_hub_identifiers()["clawhub/foo"]["name"] == "foo"-def test_hub_search_marks_an_installed_clawhub_result(monkeypatch):- # Index-backed results carry ClawHub's bare slug; the dashboard checks installed[identifier].+def test_hub_search_returns_the_card_id_a_clawhub_hit_is_found_under(monkeypatch):+ # Index-backed results carry ClawHub's bare slug. The map answers to clawhub/<slug>,+ # which the dashboard derives from the hit's source (web/src/lib/skill-hub-installed.ts).hit = SkillMeta(name="Agent Git Oracle", description="", source="clawhub",identifier="agent-git-oracle", trust_level="community")monkeypatch.setattr("tools.skills_hub_search.create_source_router", list)@@ -65,5 +70,6 @@ def test_hub_search_marks_an_installed_clawhub_result(monkeypatch):body = asyncio.run(search_skills_hub(q="agent git oracle"))- assert [r["identifier"] for r in body["results"]] == ["agent-git-oracle"]- assert body["installed"]["agent-git-oracle"]["name"] == "agent-git-oracle"+ assert [(r["source"], r["identifier"]) for r in body["results"]] == [("clawhub", "agent-git-oracle")]+ assert body["installed"]["clawhub/agent-git-oracle"]["name"] == "agent-git-oracle"+ assert "agent-git-oracle" not in body["installed"]diff --git a/tools/skills_hub.py b/tools/skills_hub.pyindex 6f1dff8ad04..f5f20ad61ea 100644--- a/tools/skills_hub.py+++ b/tools/skills_hub.py@@ -382,6 +382,21 @@ class HubLockFile(_JsonStateFile):def list_installed(self) -> list[dict]:return [{"name": name, **entry} for name, entry in self.load()["installed"].items()]+ def by_identifier(self) -> dict[str, dict]:+ """Installed entries keyed by identifier. A ClawHub row is also keyed by the+ ``clawhub/<slug>`` id a catalog card installs, since the lock records ``@owner/slug``.+ That alias names its source, so a ClawHub install never answers for another source's+ id. Exact identifiers win."""+ from tools.skills_hub_clawhub import ClawHubSource++ rows = [entry for entry in self.list_installed() if entry.get("identifier")]+ installed = {entry["identifier"]: entry for entry in rows}+ for entry in rows:+ if entry.get("source") == "clawhub":+ if alias := ClawHubSource.catalog_identifier(entry["identifier"]):+ installed.setdefault(alias, entry)+ return installed+class TapsManager(_JsonStateFile):"""skills/.hub/taps.json — custom GitHub repo sources."""diff --git a/tools/skills_hub_clawhub.py b/tools/skills_hub_clawhub.pyindex 5d6e00e9822..2ac22676f12 100644--- a/tools/skills_hub_clawhub.py+++ b/tools/skills_hub_clawhub.py@@ -235,12 +235,11 @@ class ClawHubSource(GuardedFetchMixin, SkillSource):return slug, owner@classmethod- def catalog_identifiers(cls, identifier: str) -> tuple[str, ...]:- """Owner-less forms of an installed ``identifier``: ``clawhub/<slug>`` (what a catalog- card installs) and ``<slug>`` (what the hermes-index and hub search list). ``fetch``- records ``@owner/slug``. Empty when ``identifier`` is not a ClawHub id."""+ def catalog_identifier(cls, identifier: str) -> Optional[str]:+ """``clawhub/<slug>``, the owner-less id a catalog card installs, for any ClawHub+ ``identifier`` (``fetch`` records ``@owner/slug``). None when it is not a ClawHub id."""parsed = cls._parse_identifier(identifier)- return (f"clawhub/{parsed[0]}", parsed[0]) if parsed else ()+ return f"clawhub/{parsed[0]}" if parsed else Nonedef fetch(self, identifier: str) -> Optional[SkillBundle]:detail = self._skill_detail(identifier)diff --git a/web/src/lib/skill-hub-installed.test.ts b/web/src/lib/skill-hub-installed.test.tsnew file mode 100644index 00000000000..03aa05df04e--- /dev/null+++ b/web/src/lib/skill-hub-installed.test.ts@@ -0,0 +1,49 @@+import { describe, expect, it } from "vitest";++import type { SkillHubInstalledEntry } from "@/lib/api";+import { installedHubEntry } from "@/lib/skill-hub-installed";++const entry = (name: string): SkillHubInstalledEntry => ({+ name,+ trust_level: "community",+ scan_verdict: "safe",+});++// The map the backend returns with one ClawHub install and one official skill:+// each lock id, plus the ClawHub row under the clawhub/<slug> card id.+const installed = {+ "@tmstudio667-commits/agent-git-oracle": entry("agent-git-oracle"),+ "clawhub/agent-git-oracle": entry("agent-git-oracle"),+ "official/research/arxiv": entry("arxiv"),+};++describe("installedHubEntry", () => {+ it("finds a ClawHub hit's bare slug under the card id", () => {+ const hit = { identifier: "agent-git-oracle", name: "Agent Git Oracle", source: "clawhub" };++ expect(installedHubEntry(installed, hit)?.name).toBe("agent-git-oracle");+ });++ it("never lets a ClawHub install answer for another source's bare id", () => {+ const hit = { identifier: "agent-git-oracle", name: "agent-git-oracle", source: "skills-sh" };++ expect(installedHubEntry(installed, hit)).toBeUndefined();+ });++ it("matches an owner-qualified hit and other sources by their exact id", () => {+ expect(+ installedHubEntry(installed, {+ identifier: "@tmstudio667-commits/agent-git-oracle",+ name: "Agent Git Oracle",+ source: "clawhub",+ })?.name,+ ).toBe("agent-git-oracle");+ expect(+ installedHubEntry(installed, { identifier: "official/research/arxiv", name: "arxiv", source: "official" })+ ?.name,+ ).toBe("arxiv");+ expect(+ installedHubEntry(installed, { identifier: "official/research/arxiv-lite", name: "x", source: "official" }),+ ).toBeUndefined();+ });+});diff --git a/web/src/lib/skill-hub-installed.ts b/web/src/lib/skill-hub-installed.tsnew file mode 100644index 00000000000..ca7fc3ef9c4--- /dev/null+++ b/web/src/lib/skill-hub-installed.ts@@ -0,0 +1,20 @@+import { skillCatalogInstallIdentifier } from "@hermes/shared";++import type { SkillHubInstalledEntry, SkillHubResult } from "@/lib/api";++/**+ * The installed lock entry a hub search or featured hit names. The backend keys+ * a ClawHub install by its lock id (`@owner/slug`) and by the `clawhub/<slug>`+ * id a catalog card installs, but a ClawHub hit carries its bare slug. So a hit+ * is looked up under its own id, then under the id a catalog card would install+ * for it, which differs only for ClawHub.+ */+export function installedHubEntry(+ installed: Record<string, SkillHubInstalledEntry>,+ hit: Pick<SkillHubResult, "identifier" | "name" | "source">,+): SkillHubInstalledEntry | undefined {+ return (+ installed[hit.identifier] ??+ installed[skillCatalogInstallIdentifier(hit) ?? hit.identifier]+ );+}diff --git a/web/src/pages/SkillsPage.tsx b/web/src/pages/SkillsPage.tsxindex 65598e90ba9..43fa47e55a6 100644--- a/web/src/pages/SkillsPage.tsx+++ b/web/src/pages/SkillsPage.tsx@@ -65,6 +65,7 @@ import { en } from "@/i18n/en";import { usePageHeader } from "@/contexts/usePageHeader";import { PluginSlot } from "@/plugins";import { errorMessage } from "@/lib/api-error";+import { installedHubEntry } from "@/lib/skill-hub-installed";/* ------------------------------------------------------------------ *//* Types & helpers */@@ -1024,7 +1025,7 @@ function HubBrowser({}, [showToast, profile]);const isInstalled = useCallback(- (identifier: string) => Boolean(installed[identifier]),+ (hit: SkillHubResult) => Boolean(installedHubEntry(installed, hit)),[installed],);@@ -1124,7 +1125,7 @@ function HubBrowser({<HubResultCardkey={r.identifier}result={r}- installed={isInstalled(r.identifier)}+ installed={isInstalled(r)}onOpen={() => setDetail(r)}onInstall={() => void install(r.identifier)}/>@@ -1168,7 +1169,7 @@ function HubBrowser({<HubResultCardkey={r.identifier}result={r}- installed={isInstalled(r.identifier)}+ installed={isInstalled(r)}onOpen={() => setDetail(r)}onInstall={() => void install(r.identifier)}/>@@ -1181,7 +1182,7 @@ function HubBrowser({{detail && (<SkillDetailDialogresult={detail}- installed={isInstalled(detail.identifier)}+ installed={isInstalled(detail)}onClose={() => setDetail(null)}onInstall={() => void install(detail.identifier)}showToast={showToast}