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)
| 834 | // fetchDescriptions fetches SKILL.md frontmatter descriptions concurrently |
| 835 | // for all search results. Each result may come from a different repo. |
| 836 | func 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 |