The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(skills): keep inspect/install from mixing same-named hub skills
xxxigm696fef621431
diff --git a/hermes_cli/skills_hub.py b/hermes_cli/skills_hub.pyindex 08e77495fa0..295248f6fde 100644--- a/hermes_cli/skills_hub.py+++ b/hermes_cli/skills_hub.py@@ -159,33 +159,39 @@ def _format_extra_metadata_lines(extra: Dict[str, Any]) -> list[str]:def _resolve_source_meta_and_bundle(identifier: str, sources):- """Resolve metadata and bundle for a specific identifier."""- meta = None- bundle = None- matched_source = None+ """Resolve metadata and bundle from a single source adapter.++ Meta and bundle must come from the same adapter. Keeping catalog+ metadata from skills.sh while taking a ClawHub zip of a same-named+ skill is how ``hermes skills inspect owner/repo/skills/foo`` showed+ the requested identifier and the wrong SKILL.md.+ """+ first_meta = None+ first_meta_source = Nonefor src in sources:- if meta is None:- try:- meta = src.inspect(identifier)- if meta:- matched_source = src- except Exception:- meta = None+ meta = None+ bundle = None+ try:+ meta = src.inspect(identifier)+ except Exception:+ meta = Nonetry:bundle = src.fetch(identifier)except Exception:bundle = Noneif bundle:- matched_source = srcif meta is None:try:meta = src.inspect(identifier)except Exception:meta = None- break+ return meta, bundle, src+ if first_meta is None and meta:+ first_meta = meta+ first_meta_source = src- return meta, bundle, matched_source+ return first_meta, None, first_meta_sourcedef _derive_category_from_install_path(install_path: str) -> str:diff --git a/tools/skills_hub.py b/tools/skills_hub.pyindex ebd00d73344..59912c2ce64 100644--- a/tools/skills_hub.py+++ b/tools/skills_hub.py@@ -2302,12 +2302,15 @@ class ClawHubSource(SkillSource):return dedupeddef _exact_slug_meta(self, query: str) -> Optional[SkillMeta]:- slug = query.strip().split("/")[-1]+ query = query.strip()+ parsed = self._parse_identifier(query)query_terms = self._query_terms(query)candidates: List[str] = []- if slug and re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9._-]*", slug):- candidates.append(slug)+ if parsed:+ candidates.append(parsed[0])+ elif "/" not in query and self._SLUG_RE.fullmatch(query):+ candidates.append(query)if query_terms:base_slug = "-".join(query_terms)@@ -2443,12 +2446,74 @@ class ClawHubSource(SkillSource):_write_index_cache(cache_key, [_skill_meta_to_dict(s) for s in final_results])return final_results+ _SLUG_RE = re.compile(r"[A-Za-z0-9][A-Za-z0-9._-]*$")++ @classmethod+ def _parse_identifier(cls, identifier: str) -> Optional[Tuple[str, Optional[str]]]:+ """Return ``(slug, expected_owner)`` for a ClawHub identifier.++ Accepts a bare slug, ``clawhub/<slug>``, ``@owner/slug``, and the+ clawhub.ai URL path ``owner/skills/slug``. GitHub-style+ ``owner/repo/skill`` and ``owner/repo/skills/skill`` identifiers+ are not ClawHub's — claiming them by last path segment installs+ a same-named skill from a different author.+ """+ raw = (identifier or "").strip()+ if not raw:+ return None+ had_at = raw.startswith("@")+ ident = raw[1:] if had_at else raw+ if ident.startswith("clawhub/"):+ ident = ident[len("clawhub/"):]+ parts = [part for part in ident.split("/") if part]+ if len(parts) == 1:+ slug = parts[0]+ return (slug, None) if cls._SLUG_RE.fullmatch(slug) else None+ if len(parts) == 2 and had_at:+ owner, slug = parts+ if cls._SLUG_RE.fullmatch(owner) and cls._SLUG_RE.fullmatch(slug):+ return slug, owner+ return None+ if len(parts) == 3 and parts[1].lower() == "skills":+ owner, _, slug = parts+ if cls._SLUG_RE.fullmatch(owner) and cls._SLUG_RE.fullmatch(slug):+ return slug, owner+ return None+ return None++ @staticmethod+ def _owner_from_payload(data: Optional[Dict[str, Any]]) -> Optional[str]:+ if not isinstance(data, dict):+ return None+ owner = data.get("owner")+ if isinstance(owner, dict):+ handle = owner.get("handle")+ if isinstance(handle, str) and handle.strip():+ return handle.strip()+ if isinstance(owner, str) and owner.strip():+ return owner.strip()+ return None++ @classmethod+ def _owner_matches(cls, expected_owner: Optional[str], data: Optional[Dict[str, Any]]) -> bool:+ if not expected_owner:+ return True+ actual = cls._owner_from_payload(data)+ if not actual:+ return True+ return actual.lower() == expected_owner.lower()+def fetch(self, identifier: str) -> Optional[SkillBundle]:- slug = identifier.split("/")[-1]+ parsed = self._parse_identifier(identifier)+ if parsed is None:+ return None+ slug, expected_owner = parsed- skill_data = self._get_json(f"{self.BASE_URL}/skills/{slug}")+ skill_data = self._coerce_skill_payload(self._get_json(f"{self.BASE_URL}/skills/{slug}"))if not isinstance(skill_data, dict):return None+ if not self._owner_matches(expected_owner, skill_data):+ return Nonelatest_version = self._resolve_latest_version(slug, skill_data)if not latest_version:@@ -2486,21 +2551,22 @@ class ClawHubSource(SkillSource):)def inspect(self, identifier: str) -> Optional[SkillMeta]:- slug = identifier.split("/")[-1]+ parsed = self._parse_identifier(identifier)+ if parsed is None:+ return None+ slug, expected_owner = parseddata = self._coerce_skill_payload(self._get_json(f"{self.BASE_URL}/skills/{slug}"))if not isinstance(data, dict):return None+ if not self._owner_matches(expected_owner, data):+ return Nonetags = self._normalize_tags(data.get("tags", []))extra: Dict[str, Any] = {}# The detail API returns owner info — capture it so callers can build# valid ClawHub URLs (https://clawhub.ai/{owner}/skills/{slug}).- owner = data.get("owner")- if isinstance(owner, dict):- handle = owner.get("handle")- if isinstance(handle, str) and handle:- extra["owner"] = handle- elif isinstance(owner, str) and owner:+ owner = self._owner_from_payload(data)+ if owner:extra["owner"] = ownerreturn SkillMeta(