Repository navigation
fix(skills): allow skills.sh package names on install (fixes #499) #548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import assert from "node:assert/strict"; | ||
| import test from "node:test"; | ||
|
|
||
| const { isValidSkillPackageName } = await import("./skill-package-name.ts"); | ||
|
|
||
| test("accepts the skills.sh source grammar the search route returns (#499)", () => { | ||
| assert.equal(isValidSkillPackageName("vercel-labs/agent-skills@vercel-react-best-practices"), true); | ||
| assert.equal(isValidSkillPackageName("owner/repo@skill"), true); | ||
| assert.equal(isValidSkillPackageName("owner/repo"), true); | ||
| }); | ||
|
|
||
| test("still accepts plain npm names", () => { | ||
| assert.equal(isValidSkillPackageName("react"), true); | ||
| assert.equal(isValidSkillPackageName("react@1.2.3"), true); | ||
| assert.equal(isValidSkillPackageName("@scope/pkg"), true); | ||
| assert.equal(isValidSkillPackageName("@scope/pkg@1.2.3"), true); | ||
| assert.equal(isValidSkillPackageName("my-skill"), true); | ||
| assert.equal(isValidSkillPackageName("my.skill_name-1"), true); | ||
| }); | ||
|
|
||
| test("still rejects option-like values and malformed names", () => { | ||
| assert.equal(isValidSkillPackageName("--force"), false); | ||
| assert.equal(isValidSkillPackageName("-x"), false); | ||
| assert.equal(isValidSkillPackageName("foo/bar/baz"), false); | ||
| assert.equal(isValidSkillPackageName("foo//bar"), false); | ||
| assert.equal(isValidSkillPackageName("foo/"), false); | ||
| assert.equal(isValidSkillPackageName("/foo"), false); | ||
| assert.equal(isValidSkillPackageName("foo@"), false); | ||
| assert.equal(isValidSkillPackageName("foo bar"), false); | ||
| assert.equal(isValidSkillPackageName("../etc"), false); | ||
| assert.equal(isValidSkillPackageName("@scope/"), false); | ||
| assert.equal(isValidSkillPackageName("foo@bar@baz"), false); | ||
| assert.equal(isValidSkillPackageName("foo/bar@baz/qux"), false); | ||
| assert.equal(isValidSkillPackageName(""), false); | ||
| }); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // Skills install accepts two package grammars (issue #499): | ||
| // - npm: `name`, `name@version`, `@scope/name`, `@scope/name@version` | ||
| // - skills.sh: `owner/repo@skill` (what the search route returns), and | ||
| // `owner/repo` for a source's default skill. | ||
| // A leading `-` is still rejected so a value like `--force` cannot be | ||
| // interpreted as an npx/CLI option instead of a package name. The value is | ||
| // passed to `npx skills add` as a single argv element, never via a shell. | ||
| export const SKILL_PACKAGE_NAME_PATTERN = | ||
| /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*(?:\/[a-z0-9][a-z0-9._-]*)?(?:@[a-z0-9][a-z0-9._-]*)?$/i; | ||
|
|
||
| export function isValidSkillPackageName(name: string): boolean { | ||
| return !name.startsWith("-") && SKILL_PACKAGE_NAME_PATTERN.test(name); | ||
| } | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow a leading dot in the repository component of skills.sh names.
The search route forwards each result's source into the package value, and GitHub permits repositories named
.github. A result such asacme/.github@reviewtherefore reaches validation. The repository component must start with an alphanumeric character, so the validator rejects the value and the install route returns HTTP 400package_invalid.Allow one optional leading dot in the repository component only. Keep the package name and skill name starting with an alphanumeric character. This keeps
../etcandacme/..rejected, and the leading-dash check still rejects--force.Suggested fix
Committable suggestion