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

Function fetchDescriptions

pkg/cmd/skills/search/search.go:842–877  ·  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

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

Callers 1

enrichSkillsFunction · 0.85

Calls 6

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

Tested by

no test coverage detected