Skip to content

The agent that grows with you

fix(skills): resolve indexed skills in generic directories

Yuan Lib6058d755be6
diff --git a/tests/tools/test_skills_hub.py b/tests/tools/test_skills_hub.py
index f1bfa6d221d..ba747089bd4 100644
--- a/tests/tools/test_skills_hub.py
+++ b/tests/tools/test_skills_hub.py
@@ -984,6 +984,31 @@ class TestHermesIndexSearch:
assert "NVIDIA/skills/skills/accelerated-computing-cudf" in ids
assert "clawhub/unrelated" not in ids
+ def test_fetch_resolves_generic_skill_directory_from_index_slug(self, monkeypatch):
+ """Index rows with a slug path still fetch skills stored under ``skills/``."""
+ src = _make_index_source([{
+ "name": "weread-skills",
+ "description": "WeChat Reading skills",
+ "source": "skills.sh",
+ "identifier": "skills-sh/tencent/wechatreading/weread-skills",
+ "repo": "tencent/wechatreading",
+ "path": "weread-skills",
+ }])
+ github = MagicMock()
+ github._find_skill_in_repo_tree.return_value = "tencent/wechatreading/skills"
+ github._find_repo_root_skill.return_value = None
+ github.fetch.side_effect = [None, SkillBundle(
+ name="skills", files={"SKILL.md": "---\nname: weread-skills\n---\n"},
+ source="github", identifier="tencent/wechatreading/skills", trust_level="community",
+ )]
+ monkeypatch.setattr(src, "_get_github", lambda: github)
+
+ bundle = src.fetch("skills-sh/tencent/wechatreading/weread-skills")
+
+ assert bundle is not None
+ assert bundle.identifier == "skills-sh/tencent/wechatreading/weread-skills"
+ github._find_skill_in_repo_tree.assert_called_once_with("tencent/wechatreading", "weread-skills")
+
class TestProviderFilter:
def test_filter_results_by_provider_narrows_exactly(self):
from tools.skills_hub_github import _filter_results_by_provider
diff --git a/tools/skills_hub_official.py b/tools/skills_hub_official.py
index a896d89d6d1..c38b65f0092 100644
--- a/tools/skills_hub_official.py
+++ b/tools/skills_hub_official.py
@@ -356,9 +356,20 @@ class HermesIndexSource(SkillSource):
if not entry:
return None
repo, path = entry.get("repo", ""), entry.get("path", "")
+ github = self._get_github()
candidates = [entry.get("resolved_github_id")] + ([f"{repo}/{path}"] if repo and path else [])
- for github_id in filter(None, candidates):
- bundle = self._get_github().fetch(github_id)
+ # Older index rows used the skill slug as ``path`` even when the
+ # repository stores the skill directly under a generic directory such
+ # as ``skills/``. Resolve that slug against the repository tree before
+ # declaring the catalog entry stale.
+ if repo and path:
+ skill_token = path.rstrip("/").rsplit("/", 1)[-1]
+ candidates.extend([
+ github._find_skill_in_repo_tree(repo, skill_token),
+ github._find_repo_root_skill(repo),
+ ])
+ for github_id in filter(None, dict.fromkeys(candidates)):
+ bundle = github.fetch(github_id)
if bundle:
bundle.source = entry.get("source", "hermes-index")
bundle.identifier = identifier