============================================================================ search — 3-tier search: GitHub → skill_repos.json → config.yaml remotes ============================================================================
(kind entities.Kind)
| 68 | // ============================================================================ |
| 69 | |
| 70 | func entitySearchCommand(kind entities.Kind) *cobra.Command { |
| 71 | var ( |
| 72 | owner string |
| 73 | limit int |
| 74 | local bool |
| 75 | ) |
| 76 | cmd := &cobra.Command{ |
| 77 | Use: "search <query>", |
| 78 | Short: "Search for " + string(kind) + "s across GitHub", |
| 79 | Long: "Search across all public GitHub repositories for " + string(kind) + `s matching a keyword. |
| 80 | |
| 81 | Uses the GitHub Code Search API to find ` + defaultManifestName(kind) + ` files whose |
| 82 | name or description matches the query term. |
| 83 | |
| 84 | Search results are validated to ensure they follow the skill standard |
| 85 | (valid directory conventions, proper SKILL.md frontmatter with name and |
| 86 | description). |
| 87 | |
| 88 | Results are presented in three tiers: |
| 89 | 1. GitHub Code Search (primary discovery) |
| 90 | 2. Configured skill repositories (skill_repos.json) |
| 91 | 3. Remote sources (config.yaml) |
| 92 | |
| 93 | Also searches the local store and configured repositories for matches. |
| 94 | |
| 95 | Use --owner to scope GitHub results to a specific GitHub user or organization. |
| 96 | Use --local to skip the GitHub search and only search local sources. |
| 97 | |
| 98 | Set GITHUB_TOKEN or GH_TOKEN for higher API rate limits.`, |
| 99 | Example: " cam " + string(kind) + " search terraform\n" + |
| 100 | " cam " + string(kind) + " search code-review\n" + |
| 101 | " cam " + string(kind) + " search terraform --owner hashicorp\n" + |
| 102 | " cam " + string(kind) + " search terraform --limit 5\n" + |
| 103 | " cam " + string(kind) + " search terraform --local", |
| 104 | Args: cobra.MinimumNArgs(1), |
| 105 | RunE: func(cmd *cobra.Command, args []string) error { |
| 106 | query := strings.ToLower(strings.Join(args, " ")) |
| 107 | out := cmd.OutOrStdout() |
| 108 | |
| 109 | // ----------------------------------------------------------- |
| 110 | // Tier 1: GitHub Code Search (skip with --local). |
| 111 | // ----------------------------------------------------------- |
| 112 | var ghResults []ghSearchResult |
| 113 | if !local { |
| 114 | var err error |
| 115 | ghResults, err = searchGitHub(kind, strings.Join(args, " "), owner, limit) |
| 116 | if err != nil { |
| 117 | fmt.Fprintf(out, "GitHub search: %v\n\n", err) |
| 118 | } |
| 119 | |
| 120 | // Validate: filter to only valid skills. |
| 121 | if kind == entities.KindSkill { |
| 122 | ghResults = filterValidSkillResults(ghResults) |
| 123 | } |
| 124 | |
| 125 | // Rank by relevance. |
| 126 | rankGHResults(ghResults, strings.Join(args, " ")) |
| 127 | } |
no test coverage detected