MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / entitySearchCommand

Function entitySearchCommand

internal/cli/management.go:70–248  ·  view source on GitHub ↗

============================================================================ search — 3-tier search: GitHub → skill_repos.json → config.yaml remotes ============================================================================

(kind entities.Kind)

Source from the content-addressed store, hash-verified

68// ============================================================================
69
70func 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
81Uses the GitHub Code Search API to find ` + defaultManifestName(kind) + ` files whose
82name or description matches the query term.
83
84Search results are validated to ensure they follow the skill standard
85(valid directory conventions, proper SKILL.md frontmatter with name and
86description).
87
88Results 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
93Also searches the local store and configured repositories for matches.
94
95Use --owner to scope GitHub results to a specific GitHub user or organization.
96Use --local to skip the GitHub search and only search local sources.
97
98Set 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 }

Callers 1

managementCommandMethod · 0.85

Calls 11

AllMethod · 0.95
NewStoreFunction · 0.92
defaultManifestNameFunction · 0.85
searchGitHubFunction · 0.85
filterValidSkillResultsFunction · 0.85
rankGHResultsFunction · 0.85
isInteractiveFunction · 0.85
promptSearchInstallFunction · 0.85
formatStarsFunction · 0.85
matchesQueryFunction · 0.70

Tested by

no test coverage detected