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

Function existingSkillPrompt

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

Source from the content-addressed store, hash-verified

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

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