The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(skills): install skills.sh skills from a lone generic dir under their slug; resolve index paths before the token expires
Tekniumd2c05341fc7f
diff --git a/scripts/build_skills_index.py b/scripts/build_skills_index.pyindex a26aac24a85..f43b6b8abe8 100755--- a/scripts/build_skills_index.py+++ b/scripts/build_skills_index.py@@ -257,8 +257,10 @@ def main():all_skills: list[dict] = []- # Crawl skills.sh+ # Crawl skills.sh, then resolve its repo paths right away: the CI App token lives 1 h and+ # the ClawHub walk below runs longer, so resolving after it 401'd every tree (0/20000).all_skills.extend(crawl_skills_sh(skills_sh_source))+ all_skills = batch_resolve_paths(all_skills, auth)# Crawl other sources in parallel.# Per-source soft caps — sources stop returning when they run out, so these@@ -288,9 +290,6 @@ def main():except Exception as e:print(f" Error: {e}", file=sys.stderr)- # Batch resolve GitHub paths for skills.sh entries- all_skills = batch_resolve_paths(all_skills, auth)-# Enrich ClawHub skills with owner handles. The listing API does not# include owner info, so we fetch each skill's detail page concurrently.# This is needed to build valid "View source" URLs on the Skills Hub page:diff --git a/tests/tools/test_skills_hub.py b/tests/tools/test_skills_hub.pyindex f3bb39ff633..ac04afba21e 100644--- a/tests/tools/test_skills_hub.py+++ b/tests/tools/test_skills_hub.py@@ -1022,6 +1022,7 @@ class TestHermesIndexSearch:assert bundle is not Noneassert bundle.identifier == "skills-sh/tencent/wechatreading/weread-skills"+ assert bundle.name == "weread-skills" # installs under the slug, not as "skills/"github._find_skill_in_repo_tree.assert_called_once_with("tencent/wechatreading", "weread-skills")class TestProviderFilter:diff --git a/tools/skills_hub_github.py b/tools/skills_hub_github.pyindex c9cc0e00c0c..b828f5bc047 100644--- a/tools/skills_hub_github.py+++ b/tools/skills_hub_github.py@@ -98,6 +98,10 @@ class GitHubAuth:def _resolve_token(self) -> Optional[str]:if self._cached_token and (self._cached_method != "github-app" or time.time() < self._app_token_expiry):return self._cached_token+ if self._cached_method == "anonymous":+ # The chain already came up empty: re-running `gh auth token` (5 s timeout when gh has no+ # login / no keyring) before every API call stretched one install past four minutes.+ return Nonefor method, resolve in (("pat", self._try_pat), ("gh-cli", self._try_gh_cli), ("github-app", self._try_github_app),):@@ -521,18 +525,18 @@ class GitHubSource(SkillSource):if (cached := self._get_repo_tree(repo)) is None:return Noneskill_md_suffix = f"/{skill_name}/SKILL.md"- generic_candidates = []+ skill_dirs = []for entry in cached[1]:path = entry.get("path", "")- if entry.get("type") != "blob" or entry.get("mode") == "120000":+ if entry.get("type") != "blob" or entry.get("mode") == "120000" or not f"/{path}".endswith("/SKILL.md"):continueif path.endswith(skill_md_suffix) or path == skill_md_suffix[1:]:return f"{repo}/{path[: -len('/SKILL.md')]}"- # 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+ skill_dirs.append(path[: -len("SKILL.md")].rstrip("/"))+ # A single-skill repo may keep it in a generically named dir (``skills/SKILL.md``) that no+ # slug matches; with only one SKILL.md in the tree there is nothing else it could mean+ # (a lone root SKILL.md is left to ``_find_repo_root_skill``).+ return f"{repo}/{skill_dirs[0]}" if len(skill_dirs) == 1 and skill_dirs[0] else Nonedef _find_repo_root_skill(self, repo: str) -> Optional[str]:"""Identifier for a single-skill repo whose ``SKILL.md`` sits at the repo ROOT (no skilldiff --git a/tools/skills_hub_official.py b/tools/skills_hub_official.pyindex c38b65f0092..dac544f2f05 100644--- a/tools/skills_hub_official.py+++ b/tools/skills_hub_official.py@@ -358,23 +358,21 @@ class HermesIndexSource(SkillSource):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 [])- # 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- return bundle- return None+ for github_id in filter(None, candidates):+ if bundle := github.fetch(github_id):+ break+ else:+ # skills.sh rows carry the slug as ``path``; when no build resolved it, find the skill in+ # the repo tree (a slug-named dir, a lone generic ``skills/``, or the repo root) instead+ # of reporting a live skill as a stale entry (#130129).+ slug = path.rstrip("/").rsplit("/", 1)[-1]+ found = repo and slug and (github._find_skill_in_repo_tree(repo, slug) or github._find_repo_root_skill(repo))+ if not (found and (bundle := github.fetch(found))):+ return None+ bundle.name = slug # not "skills" / the repo name: the slug the user asked for+ bundle.source = entry.get("source", "hermes-index")+ bundle.identifier = identifier+ return bundledef inspect(self, identifier: str) -> Optional[SkillMeta]:"""Return metadata from the index (zero API calls)."""