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)
| 819 | // fetchDescriptions fetches SKILL.md frontmatter descriptions concurrently |
| 820 | // for all search results. Each result may come from a different repo. |
| 821 | func fetchDescriptions(client *api.Client, host string, skills []skillResult) map[int]string { |
| 822 | const maxWorkers = 10 |
| 823 | sem := make(chan struct{}, maxWorkers) |
| 824 | var wg sync.WaitGroup |
| 825 | var mu sync.Mutex |
| 826 | |
| 827 | descs := make(map[int]string) |
| 828 | |
| 829 | for i := range skills { |
| 830 | if skills[i].BlobSHA == "" { |
| 831 | continue |
| 832 | } |
| 833 | wg.Add(1) |
| 834 | go func(idx int) { |
| 835 | defer wg.Done() |
| 836 | sem <- struct{}{} |
| 837 | defer func() { <-sem }() |
| 838 | |
| 839 | content, err := discovery.FetchBlob(client, host, skills[idx].Owner, skills[idx].RepoName, skills[idx].BlobSHA) |
| 840 | if err != nil { |
| 841 | return |
| 842 | } |
| 843 | result, err := frontmatter.Parse(content.Raw()) |
| 844 | if err != nil { |
| 845 | return |
| 846 | } |
| 847 | |
| 848 | mu.Lock() |
| 849 | descs[idx] = result.Metadata.Description |
| 850 | mu.Unlock() |
| 851 | }(i) |
| 852 | } |
| 853 | wg.Wait() |
| 854 | |
| 855 | return descs |
| 856 | } |
| 857 | |
| 858 | // extractSkillInfo derives the skill name and namespace from a SKILL.md path, |
| 859 | // but only if the path matches a known skill convention. Returns empty strings |