Skip to content

Commit 1b236f2

Browse files
Merge pull request cli#13249 from cli/sammorrowdrums/fix-skill-install-preview-sha
fix(skills): match skills by install name in preview command
2 parents a67f4f7 + 6fcc9c2 commit 1b236f2

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

pkg/cmd/skills/preview/preview.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,13 @@ func selectSkill(opts *PreviewOptions, skills []discovery.Skill) (discovery.Skil
395395
return s, nil
396396
}
397397
}
398+
// Fall back to InstallName so that namespaced identifiers produced
399+
// by the post-install hint (e.g. "namespace/skill") are accepted.
400+
for _, s := range skills {
401+
if s.InstallName() == opts.SkillName {
402+
return s, nil
403+
}
404+
}
398405
return discovery.Skill{}, fmt.Errorf("skill %q not found in %s", opts.SkillName, ghrepo.FullName(opts.repo))
399406
}
400407

pkg/cmd/skills/preview/preview_test.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,51 @@ func TestPreviewRun(t *testing.T) {
206206
},
207207
wantStdout: "My Skill",
208208
},
209+
{
210+
name: "preview plugins skill matched by install name",
211+
tty: true,
212+
opts: &PreviewOptions{
213+
repo: ghrepo.New("owner", "repo"),
214+
SkillName: "aws-common/aws-mcp-setup",
215+
},
216+
httpStubs: func(reg *httpmock.Registry) {
217+
reg.Register(
218+
httpmock.REST("GET", "repos/owner/repo/releases/latest"),
219+
httpmock.StringResponse(`{"tag_name": "v1.0.0"}`),
220+
)
221+
reg.Register(
222+
httpmock.REST("GET", "repos/owner/repo/git/ref/tags/v1.0.0"),
223+
httpmock.StringResponse(`{"object": {"sha": "abc123", "type": "commit"}}`),
224+
)
225+
reg.Register(
226+
httpmock.REST("GET", "repos/owner/repo/git/trees/abc123"),
227+
httpmock.StringResponse(`{
228+
"sha": "abc123",
229+
"truncated": false,
230+
"tree": [
231+
{"path": "plugins", "type": "tree", "sha": "tree-plugins"},
232+
{"path": "plugins/aws-common", "type": "tree", "sha": "tree-awscommon"},
233+
{"path": "plugins/aws-common/skills", "type": "tree", "sha": "tree-awsskills"},
234+
{"path": "plugins/aws-common/skills/aws-mcp-setup", "type": "tree", "sha": "treeSHA3"},
235+
{"path": "plugins/aws-common/skills/aws-mcp-setup/SKILL.md", "type": "blob", "sha": "blob789"}
236+
]
237+
}`),
238+
)
239+
reg.Register(
240+
httpmock.REST("GET", "repos/owner/repo/git/trees/treeSHA3"),
241+
httpmock.StringResponse(`{
242+
"tree": [
243+
{"path": "SKILL.md", "type": "blob", "sha": "blob789", "size": 50}
244+
]
245+
}`),
246+
)
247+
reg.Register(
248+
httpmock.REST("GET", "repos/owner/repo/git/blobs/blob789"),
249+
httpmock.StringResponse(`{"sha": "blob789", "content": "`+encodedContent+`", "encoding": "base64"}`),
250+
)
251+
},
252+
wantStdout: "My Skill",
253+
},
209254
{
210255
name: "skill not found",
211256
tty: true,

0 commit comments

Comments
 (0)