Repository navigation
fix(skills): fall back to CDN mirrors when the catalog API is rate limited (0.5.1) - #7
Open
MarkShawn2020 wants to merge 1 commit into
Open
MarkShawn2020 wants to merge 1 commit into
MarkShawn2020 wants to merge 1 commit into
Conversation
…mited (0.5.1) Anonymous GitHub API calls are capped at 60 per hour per IP, so users behind a shared NAT saw `skills add` fail with "catalog request failed: HTTP 403". The catalog now tries the GitHub API (with GITHUB_TOKEN / GH_TOKEN when set, sent only to api.github.com), then raw.githubusercontent.com, then jsDelivr. The API uses the raw media type, avoiding the empty base64 payload GitHub returns for files over 1 MB, and a response without a skills list is treated as a failure rather than an empty catalog. Installs still stop when no source returns the catalog. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
npx lovstudio@0.5.0 skills add wxmp-clifailed with读取 Lovstudio Skills 目录失败:catalog request failed: HTTP 403. The catalog comes from the unauthenticated GitHub contents API, which allows 60 requests per hour per IP. Users behind a shared NAT use that up quickly, and the CLI won't install anything without a catalog.Change
loadCatalogtries the sources in order and uses the first one that returns a valid catalog:api.github.comcontents API. This is unchanged as the first choice so pushes still show up right away. It sendsGITHUB_TOKEN/GH_TOKENwhen one is set, and only toapi.github.com.raw.githubusercontent.com, which can be about 5 minutes behind.cdn.jsdelivr.net, which can be up to about 12 hours behind.application/vnd.github.raw+jsonmedia type. The base64 JSON form comes back empty once a file passes 1 MB, andskills.yamlis already at 499 KB.skillslist now counts as a failure instead of an empty catalog. This covers a mirror that returns an HTML block page with status 200.LOVSTUDIO_SKILLS_CATALOG_URLstill replaces the whole chain.loadCatalogthrows and both callers exit before installing.Verification
npm test: 43 pass, 1 skip (already skipped), 0 fail. Two new tests:GH_TOKEN: the API answered directly and no fallback line was printed.node bin/lovstudio.mjs skills add definitely-not-a-skill-xyz: the fallback line was printed, then "目录中没有找到 Skill", exit 2.🤖 Generated with Claude Code