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

Function parseInstalledSkill

pkg/cmd/skills/update/update.go:654–695  ·  view source on GitHub ↗

parseInstalledSkill parses a SKILL.md file and returns an installedSkill.

(data []byte, name, dir string, host *registry.AgentHost, scope registry.Scope)

Source from the content-addressed store, hash-verified

652
653// parseInstalledSkill parses a SKILL.md file and returns an installedSkill.
654func parseInstalledSkill(data []byte, name, dir string, host *registry.AgentHost, scope registry.Scope) (installedSkill, bool) {
655 result, err := frontmatter.Parse(string(data))
656 if err != nil {
657 return installedSkill{
658 name: name,
659 dir: dir,
660 host: host,
661 scope: scope,
662 metadataErr: fmt.Errorf("invalid SKILL.md: %w", err),
663 }, true
664 }
665
666 s := installedSkill{
667 name: name,
668 dir: dir,
669 host: host,
670 scope: scope,
671 }
672
673 if result.Metadata.Meta != nil {
674 repoInfo, ok, repoErr := source.ParseMetadataRepo(result.Metadata.Meta)
675 if repoErr != nil {
676 s.metadataErr = repoErr
677 } else if ok {
678 if err := source.ValidateSupportedHost(repoInfo.RepoHost()); err != nil {
679 s.metadataErr = err
680 } else {
681 s.repoHost = repoInfo.RepoHost()
682 s.owner = repoInfo.RepoOwner()
683 s.repo = repoInfo.RepoName()
684 }
685 }
686 s.treeSHA, _ = result.Metadata.Meta["github-tree-sha"].(string)
687 s.pinned, _ = result.Metadata.Meta["github-pinned"].(string)
688 s.sourcePath, _ = result.Metadata.Meta["github-path"].(string)
689 if s.metadataErr == nil {
690 s.repoID, s.metadataErr = parseRepoID(result.Metadata.Meta["github-repo-id"])
691 }
692 }
693
694 return s, true
695}
696
697// parseRepoID parses the github-repo-id metadata value. A missing value
698// returns 0, as skills installed by earlier versions don't record it.

Callers 1

scanInstalledSkillsFunction · 0.70

Calls 8

ParseFunction · 0.92
ParseMetadataRepoFunction · 0.92
ValidateSupportedHostFunction · 0.92
parseRepoIDFunction · 0.85
ErrorfMethod · 0.65
RepoHostMethod · 0.65
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65

Tested by

no test coverage detected