fix(skills): prioritize DisplayName/Name over InstallName match

Use a two-pass search so exact DisplayName and Name matches are
preferred over InstallName. This avoids incorrectly selecting a
plugins-convention skill via InstallName when a standard namespaced
skill with a matching DisplayName exists later in the sorted slice.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Sam Morrow 2026-04-21 10:09:20 +02:00
parent 1160943af3
commit 6fcc9c24df
No known key found for this signature in database

View file

@ -391,7 +391,14 @@ func isMarkdownFile(filePath string) bool {
func selectSkill(opts *PreviewOptions, skills []discovery.Skill) (discovery.Skill, error) {
if opts.SkillName != "" {
for _, s := range skills {
if s.DisplayName() == opts.SkillName || s.Name == opts.SkillName || s.InstallName() == opts.SkillName {
if s.DisplayName() == opts.SkillName || s.Name == opts.SkillName {
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
}
}