(params map[string]interface{})
| 278 | } |
| 279 | |
| 280 | func (g *githubTools) searchRepos(params map[string]interface{}) (string, error) { |
| 281 | query, _ := params["query"].(string) |
| 282 | if query == "" { |
| 283 | return "", fmt.Errorf("github_search_repos: 'query' param required (e.g. {\"query\": \"python web framework\"})") |
| 284 | } |
| 285 | |
| 286 | // this if PHASE 1: Query Intelligence |
| 287 | // Extract language + strip noise + add ecosystem anchors |
| 288 | |
| 289 | lang, _ := params["language"].(string) |
| 290 | if lang == "" { |
| 291 | lang = detectLanguage(query) |
| 292 | } |
| 293 | |
| 294 | // this is to Strip noise words — keep only domain keywords |
| 295 | cleanQuery := stripNoiseWords(query) |
| 296 | |
| 297 | // this is the Ecosystem that hints to disambiguate (javascript→nodejs, go→golang) |
| 298 | ecosystemHints := map[string]string{ |
| 299 | "javascript": "nodejs", |
| 300 | "typescript": "nodejs", |
| 301 | "go": "golang", |
| 302 | "c#": "dotnet", |
| 303 | "csharp": "dotnet", |
| 304 | } |
| 305 | |
| 306 | // this is PHASE 2: basically this is Retrieval whihch means it: |
| 307 | // Keep language in the query for signal strength. |
| 308 | // The noise word stripper already removed "backend", "frontend", "server" |
| 309 | // which were causing strict AND failures on GitHub. |
| 310 | |
| 311 | var allRepos []map[string]interface{} |
| 312 | |
| 313 | searchQ := strings.ReplaceAll(cleanQuery, " ", "+") |
| 314 | if hint, ok := ecosystemHints[strings.ToLower(lang)]; ok { |
| 315 | searchQ += "+" + hint |
| 316 | } |
| 317 | |
| 318 | // This is For languages with ecosystem overlap (JS includes TS, and vice versa), |
| 319 | // This don't add language: filter to the API — it would exclude valid repos. |
| 320 | // My local filterByLanguage handles the cross-language matching. |
| 321 | langOverlap := map[string]bool{ |
| 322 | "javascript": true, |
| 323 | "typescript": true, |
| 324 | } |
| 325 | if lang != "" && !langOverlap[strings.ToLower(lang)] { |
| 326 | searchQ += "+language:" + strings.ToLower(lang) |
| 327 | } |
| 328 | |
| 329 | url := fmt.Sprintf("%s/search/repositories?q=%s&sort=stars&order=desc&per_page=30", |
| 330 | githubAPI, searchQ) |
| 331 | |
| 332 | result, err := g.exec.Execute(HTTPToolConfig{ |
| 333 | Method: "GET", |
| 334 | URL: url, |
| 335 | Headers: g.headers(), |
| 336 | }, nil) |
| 337 | if err != nil { |
nothing calls this directly
no test coverage detected