MCPcopy Create free account
hub / github.com/cli/cli / existingSkillPrompt

Function existingSkillPrompt

pkg/cmd/skills/install/install.go:1082–1109  ·  view source on GitHub ↗
(targetDir string, incoming discovery.Skill)

Source from the content-addressed store, hash-verified

1080}
1081
1082func existingSkillPrompt(targetDir string, incoming discovery.Skill) string {
1083 skillFile := filepath.Join(targetDir, incoming.Name, "SKILL.md")
1084 data, err := os.ReadFile(skillFile)
1085 if err != nil {
1086 return fmt.Sprintf("Skill %q already exists. Overwrite?", incoming.DisplayName())
1087 }
1088
1089 result, err := frontmatter.Parse(string(data))
1090 if err != nil || result.Metadata.Meta == nil {
1091 return fmt.Sprintf("Skill %q already exists. Overwrite?", incoming.DisplayName())
1092 }
1093
1094 repoInfo, _, err := source.ParseMetadataRepo(result.Metadata.Meta)
1095 ref, _ := result.Metadata.Meta["github-ref"].(string)
1096 if err != nil {
1097 return fmt.Sprintf("Skill %q already exists. Overwrite?", incoming.DisplayName())
1098 }
1099
1100 if repoInfo != nil {
1101 sourceName := ghrepo.FullName(repoInfo)
1102 if ref != "" {
1103 sourceName += "@" + ref
1104 }
1105 return fmt.Sprintf("Skill %q already installed from %s. Overwrite?", incoming.DisplayName(), sourceName)
1106 }
1107
1108 return fmt.Sprintf("Skill %q already exists. Overwrite?", incoming.DisplayName())
1109}
1110
1111const installProgressLabel = "Downloading skill files"
1112

Callers 1

checkOverwriteFunction · 0.85

Calls 5

ParseFunction · 0.92
ParseMetadataRepoFunction · 0.92
FullNameFunction · 0.92
JoinMethod · 0.80
DisplayNameMethod · 0.65

Tested by

no test coverage detected