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

Function skillNameFromSourcePath

pkg/cmd/skills/list/list.go:454–483  ·  view source on GitHub ↗
(sourcePath string)

Source from the content-addressed store, hash-verified

452}
453
454func skillNameFromSourcePath(sourcePath string) string {
455 sourcePath = strings.TrimSuffix(sourcePath, "/SKILL.md")
456 sourcePath = strings.Trim(sourcePath, "/")
457 if sourcePath == "" {
458 return ""
459 }
460
461 parts := strings.Split(sourcePath, "/")
462 for i := len(parts) - 1; i >= 0; i-- {
463 if parts[i] != "skills" {
464 continue
465 }
466
467 if i >= 2 && parts[i-2] == "plugins" && i+1 < len(parts) {
468 return parts[i-1] + "/" + parts[len(parts)-1]
469 }
470
471 afterSkills := len(parts) - i - 1
472 switch afterSkills {
473 case 0:
474 return ""
475 case 1:
476 return parts[i+1]
477 default:
478 return parts[i+1] + "/" + parts[len(parts)-1]
479 }
480 }
481
482 return parts[len(parts)-1]
483}
484
485func sortListedSkills(skills []listedSkill) {
486 sort.Slice(skills, func(i, j int) bool {

Callers 1

parseInstalledSkillFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected