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

Function existingSkillPrompt

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

Source from the content-addressed store, hash-verified

1067}
1068
1069func existingSkillPrompt(targetDir string, incoming discovery.Skill) string {
1070 skillFile := filepath.Join(targetDir, incoming.Name, "SKILL.md")
1071 data, err := os.ReadFile(skillFile)
1072 if err != nil {
1073 return fmt.Sprintf("Skill %q already exists. Overwrite?", incoming.DisplayName())
1074 }
1075
1076 result, err := frontmatter.Parse(string(data))
1077 if err != nil || result.Metadata.Meta == nil {
1078 return fmt.Sprintf("Skill %q already exists. Overwrite?", incoming.DisplayName())
1079 }
1080
1081 repoInfo, _, err := source.ParseMetadataRepo(result.Metadata.Meta)
1082 ref, _ := result.Metadata.Meta["github-ref"].(string)
1083 if err != nil {
1084 return fmt.Sprintf("Skill %q already exists. Overwrite?", incoming.DisplayName())
1085 }
1086
1087 if repoInfo != nil {
1088 sourceName := ghrepo.FullName(repoInfo)
1089 if ref != "" {
1090 sourceName += "@" + ref
1091 }
1092 return fmt.Sprintf("Skill %q already installed from %s. Overwrite?", incoming.DisplayName(), sourceName)
1093 }
1094
1095 return fmt.Sprintf("Skill %q already exists. Overwrite?", incoming.DisplayName())
1096}
1097
1098const installProgressLabel = "Downloading skill files"
1099

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