Skip to content

The agent that grows with you

fix(skills): resolve generic indexed skill directories

Yuan Lif176143406a6
diff --git a/tests/tools/test_skills_hub.py b/tests/tools/test_skills_hub.py
index ba747089bd4..f3bb39ff633 100644
--- a/tests/tools/test_skills_hub.py
+++ b/tests/tools/test_skills_hub.py
@@ -369,6 +369,21 @@ class TestFindSkillInRepoTree:
result = self._source()._find_skill_in_repo_tree("davila7/claude-code-templates", "senior-backend")
assert result == "davila7/claude-code-templates/cli-tool/components/skills/development/senior-backend"
+ @patch("tools.skills_hub.httpx.get")
+ def test_finds_single_generic_skills_directory_when_slug_is_stale(self, mock_get):
+ tree_entries = [
+ {"path": "README.md", "type": "blob"},
+ {"path": "skills/SKILL.md", "type": "blob"},
+ ]
+ mock_get.side_effect = [
+ MagicMock(status_code=200, json=lambda: {"default_branch": "main"}),
+ MagicMock(status_code=200, json=lambda: {"tree": tree_entries}),
+ ]
+
+ result = self._source()._find_skill_in_repo_tree("tencent/wechatreading", "weread-skills")
+
+ assert result == "tencent/wechatreading/skills"
+
@patch("tools.skills_hub.httpx.get")
def test_returns_none_when_repo_api_fails(self, mock_get):
mock_get.return_value = MagicMock(status_code=404)
diff --git a/tools/skills_hub_github.py b/tools/skills_hub_github.py
index 81a735796b0..c9cc0e00c0c 100644
--- a/tools/skills_hub_github.py
+++ b/tools/skills_hub_github.py
@@ -521,11 +521,18 @@ class GitHubSource(SkillSource):
if (cached := self._get_repo_tree(repo)) is None:
return None
skill_md_suffix = f"/{skill_name}/SKILL.md"
+ generic_candidates = []
for entry in cached[1]:
path = entry.get("path", "")
- if entry.get("type") == "blob" and (path.endswith(skill_md_suffix) or path == skill_md_suffix[1:]):
+ if entry.get("type") != "blob" or entry.get("mode") == "120000":
+ continue
+ if path.endswith(skill_md_suffix) or path == skill_md_suffix[1:]:
return f"{repo}/{path[: -len('/SKILL.md')]}"
- return None
+ # Some older index rows use a public slug even though the repo
+ # exposes one skill from a generic directory such as ``skills/``.
+ if path.endswith("/skills/SKILL.md") or path == "skills/SKILL.md":
+ generic_candidates.append(path[: -len('/SKILL.md')])
+ return f"{repo}/{generic_candidates[0]}" if len(generic_candidates) == 1 else None
def _find_repo_root_skill(self, repo: str) -> Optional[str]:
"""Identifier for a single-skill repo whose ``SKILL.md`` sits at the repo ROOT (no skill