MCPcopy
hub / github.com/cli/cli / fetchDescriptions

Function fetchDescriptions

pkg/cmd/skills/search/search.go:836–871  ·  view source on GitHub ↗

fetchDescriptions fetches SKILL.md frontmatter descriptions concurrently for all search results. Each result may come from a different repo.

(client *api.Client, host string, skills []skillResult)

Source from the content-addressed store, hash-verified

834// fetchDescriptions fetches SKILL.md frontmatter descriptions concurrently
835// for all search results. Each result may come from a different repo.
836func fetchDescriptions(client *api.Client, host string, skills []skillResult) map[int]string {
837 const maxWorkers = 10
838 sem := make(chan struct{}, maxWorkers)
839 var wg sync.WaitGroup
840 var mu sync.Mutex
841
842 descs := make(map[int]string)
843
844 for i := range skills {
845 if skills[i].BlobSHA == "" {
846 continue
847 }
848 wg.Add(1)
849 go func(idx int) {
850 defer wg.Done()
851 sem <- struct{}{}
852 defer func() { <-sem }()
853
854 content, err := discovery.FetchBlob(client, host, skills[idx].Owner, skills[idx].RepoName, skills[idx].BlobSHA)
855 if err != nil {
856 return
857 }
858 result, err := frontmatter.Parse(content)
859 if err != nil {
860 return
861 }
862
863 mu.Lock()
864 descs[idx] = result.Metadata.Description
865 mu.Unlock()
866 }(i)
867 }
868 wg.Wait()
869
870 return descs
871}
872
873// extractSkillInfo derives the skill name and namespace from a SKILL.md path,
874// but only if the path matches a known skill convention. Returns empty strings

Callers 1

enrichSkillsFunction · 0.85

Calls 5

FetchBlobFunction · 0.92
ParseFunction · 0.92
AddMethod · 0.65
DoneMethod · 0.65
WaitMethod · 0.65

Tested by

no test coverage detected