The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(skills): hub installs download skill files from raw.githubusercontent.com, not one API call per file
Teknium18ee4251d8e7
diff --git a/tests/tools/test_skills_hub_github_fetch.py b/tests/tools/test_skills_hub_github_fetch.pynew file mode 100644index 00000000000..2872fde2008--- /dev/null+++ b/tests/tools/test_skills_hub_github_fetch.py@@ -0,0 +1,30 @@+"""GitHubSource file downloads: which host serves a skill's files."""++from unittest.mock import MagicMock++import httpx+import pytest++from tools.skills_hub_github import GitHubAuth, GitHubSource++[email protected]("raw_status", [200, 404])+def test_pinned_file_comes_from_raw_and_spends_no_api_call(monkeypatch, raw_status):+ """Every file of a skill folder was one Contents API call: an anonymous user (60/h) could+ never install a skill with ~58+ files (remotion-best-practices: 143 calls, rate_limited).+ A pinned file now comes from raw.githubusercontent.com; a raw miss (private repo) still+ falls back to the API."""+ import tools.skills_hub as hub+ hosts = []++ def fake_get(url, **_kw):+ hosts.append(url.split("/")[2])+ ok = "raw.githubusercontent.com" not in url or raw_status == 200+ return httpx.Response(200 if ok else raw_status, content=b"body" if ok else b"")++ monkeypatch.setattr(hub, "_skills_hub_http_get", fake_get)+ auth = MagicMock(spec=GitHubAuth)+ auth.get_headers.return_value = {}+ assert GitHubSource(auth)._fetch_file_bytes("o/r", "s/a b.md", ref="c" * 40) == b"body"+ assert hosts == (["raw.githubusercontent.com"] if raw_status == 200+ else ["raw.githubusercontent.com", "api.github.com"])diff --git a/tools/skills_hub_github.py b/tools/skills_hub_github.pyindex b22da1c5866..55b81e4bc23 100644--- a/tools/skills_hub_github.py+++ b/tools/skills_hub_github.py@@ -1,5 +1,6 @@"""Skills Hub GitHub adapter: API auth, tap providers, and the Contents/Trees source."""+import contextlibimport jsonimport loggingimport subprocess@@ -562,7 +563,18 @@ class GitHubSource(SkillSource):def _fetch_file_bytes(self, repo: str, path: str, ref: Optional[str] = None) -> Optional[bytes]:"""Fetch exact file bytes. ``ref`` pins to a tree SHA (see ``fetch`` on- the TOCTOU); None keeps the legacy unpinned behavior."""+ the TOCTOU); None keeps the legacy unpinned behavior. A pinned file comes from+ raw.githubusercontent.com first: the same bytes at the same commit, outside the REST rate+ limit. Through the Contents API every file in a skill folder cost one call, so an anonymous+ user (60/h) could never install a skill with more than ~58 files. A private repo or a raw+ miss falls back to the API."""+ if ref:+ with contextlib.suppress(httpx.HTTPError):+ raw = hub()._skills_hub_http_get(+ f"https://raw.githubusercontent.com/{repo}/{ref}/{quote(path, safe='/')}",+ timeout=15.0, follow_redirects=False)+ if raw.status_code == 200:+ return raw.contentresp = self._github_get(f"{_API}/{repo}/contents/{quote(path, safe='/')}", params={"ref": ref} if ref else None,headers={**self.auth.get_headers(), "Accept": "application/vnd.github.v3.raw"},diff --git a/website/docs/user-guide/features/skills.md b/website/docs/user-guide/features/skills.mdindex 53cc593f3e1..041e8c2007f 100644--- a/website/docs/user-guide/features/skills.md+++ b/website/docs/user-guide/features/skills.md@@ -934,7 +934,7 @@ Valid installs continue to use their source adapter’s existing synchronous fetSkills you have edited locally (the on-disk content no longer matches the hash recorded at install time) are **skipped** by `hermes skills update` so your changes are never silently overwritten. Pass `--force` to replace them with the upstream version anyway.:::tip GitHub rate limits-Skills hub operations use the GitHub API, which has a rate limit of 60 requests/hour for unauthenticated users. If you see rate-limit errors during install or search, set `GITHUB_TOKEN` in your `.env` file to increase the limit to 5,000 requests/hour. The error message includes an actionable hint when this happens.+Skills hub operations use the GitHub API, which has a rate limit of 60 requests/hour for unauthenticated users. An install costs about two API calls (the repo and its file tree); the skill's files themselves download from `raw.githubusercontent.com`, which the limit does not count. If you see rate-limit errors during install or search, set `GITHUB_TOKEN` in your `.env` file to increase the limit to 5,000 requests/hour. The error message includes an actionable hint when this happens.:::### Publishing a custom skill tap