selectRichestRemote picks the most useful remote-meta entry from a slice of candidates. Preference order: 1. any skills.sh-sourced entry (canonical registry — wins outright), 2. the entry with the highest install count, 3. an entry with a non-empty description when the current pick has none. Retur
(candidates []*registry.SkillMeta)
| 665 | // |
| 666 | // Returns nil when the slice is empty. |
| 667 | func selectRichestRemote(candidates []*registry.SkillMeta) *registry.SkillMeta { |
| 668 | if len(candidates) == 0 { |
| 669 | return nil |
| 670 | } |
| 671 | best := candidates[0] |
| 672 | for _, m := range candidates { |
| 673 | if registry.IsSkillsShSource(m.RegistryName) { |
| 674 | return m |
| 675 | } |
| 676 | if m.Downloads > best.Downloads { |
| 677 | best = m |
| 678 | continue |
| 679 | } |
| 680 | if best.Description == "" && m.Description != "" { |
| 681 | best = m |
| 682 | } |
| 683 | } |
| 684 | return best |
| 685 | } |
| 686 | |
| 687 | // printSkillInfoHeader prints the always-present Name line, preferring the |
| 688 | // remote-meta name when both sides know it. |