Merge pull request #13249 from cli/sammorrowdrums/fix-skill-install-preview-sha

fix(skills): match skills by install name in preview command
This commit is contained in:
Sam Morrow 2026-04-21 11:30:11 +02:00 committed by GitHub
commit 1b236f23c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 52 additions and 0 deletions

View file

@ -395,6 +395,13 @@ func selectSkill(opts *PreviewOptions, skills []discovery.Skill) (discovery.Skil
return s, nil
}
}
// Fall back to InstallName so that namespaced identifiers produced
// by the post-install hint (e.g. "namespace/skill") are accepted.
for _, s := range skills {
if s.InstallName() == opts.SkillName {
return s, nil
}
}
return discovery.Skill{}, fmt.Errorf("skill %q not found in %s", opts.SkillName, ghrepo.FullName(opts.repo))
}

View file

@ -206,6 +206,51 @@ func TestPreviewRun(t *testing.T) {
},
wantStdout: "My Skill",
},
{
name: "preview plugins skill matched by install name",
tty: true,
opts: &PreviewOptions{
repo: ghrepo.New("owner", "repo"),
SkillName: "aws-common/aws-mcp-setup",
},
httpStubs: func(reg *httpmock.Registry) {
reg.Register(
httpmock.REST("GET", "repos/owner/repo/releases/latest"),
httpmock.StringResponse(`{"tag_name": "v1.0.0"}`),
)
reg.Register(
httpmock.REST("GET", "repos/owner/repo/git/ref/tags/v1.0.0"),
httpmock.StringResponse(`{"object": {"sha": "abc123", "type": "commit"}}`),
)
reg.Register(
httpmock.REST("GET", "repos/owner/repo/git/trees/abc123"),
httpmock.StringResponse(`{
"sha": "abc123",
"truncated": false,
"tree": [
{"path": "plugins", "type": "tree", "sha": "tree-plugins"},
{"path": "plugins/aws-common", "type": "tree", "sha": "tree-awscommon"},
{"path": "plugins/aws-common/skills", "type": "tree", "sha": "tree-awsskills"},
{"path": "plugins/aws-common/skills/aws-mcp-setup", "type": "tree", "sha": "treeSHA3"},
{"path": "plugins/aws-common/skills/aws-mcp-setup/SKILL.md", "type": "blob", "sha": "blob789"}
]
}`),
)
reg.Register(
httpmock.REST("GET", "repos/owner/repo/git/trees/treeSHA3"),
httpmock.StringResponse(`{
"tree": [
{"path": "SKILL.md", "type": "blob", "sha": "blob789", "size": 50}
]
}`),
)
reg.Register(
httpmock.REST("GET", "repos/owner/repo/git/blobs/blob789"),
httpmock.StringResponse(`{"sha": "blob789", "content": "`+encodedContent+`", "encoding": "base64"}`),
)
},
wantStdout: "My Skill",
},
{
name: "skill not found",
tty: true,