MCPcopy
hub / github.com/cli/cli / existingSkillPrompt

Function existingSkillPrompt

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

Source from the content-addressed store, hash-verified

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

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