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

Function DiscoverLocalSkills

internal/skills/discovery/discovery.go:950–970  ·  view source on GitHub ↗

DiscoverLocalSkills finds non-hidden-dir skills in a local directory using the same conventions as remote discovery. Hidden-dir skills are excluded; use DiscoverLocalSkillsWithOptions to retrieve all skills including those in hidden directories.

(dir string)

Source from the content-addressed store, hash-verified

948// DiscoverLocalSkillsWithOptions to retrieve all skills including those in
949// hidden directories.
950func DiscoverLocalSkills(dir string) ([]Skill, error) {
951 all, err := DiscoverLocalSkillsWithOptions(dir, DiscoverOptions{})
952 if err != nil {
953 return nil, err
954 }
955 var skills []Skill
956 for _, s := range all {
957 if !s.IsHiddenDirConvention() {
958 skills = append(skills, s)
959 }
960 }
961 if len(skills) == 0 {
962 return nil, fmt.Errorf(
963 "no skills found in %s\n"+
964 " Expected SKILL.md in the directory, or skills in skills/*/SKILL.md,\n"+
965 " skills/{scope}/*/SKILL.md, */SKILL.md, or plugins/*/skills/*/SKILL.md",
966 dir,
967 )
968 }
969 return skills, nil
970}
971
972// DiscoverLocalSkillsWithOptions finds skills in a local directory using the
973// same conventions as remote discovery, with configurable discovery behavior.

Callers 2

publishRunFunction · 0.92
TestDiscoverLocalSkillsFunction · 0.85

Calls 3

IsHiddenDirConventionMethod · 0.80
ErrorfMethod · 0.65

Tested by 1

TestDiscoverLocalSkillsFunction · 0.68