@@ -39,6 +39,7 @@ Use --remote to force remote API search.`,
3939
4040 forceLocal , _ := cmd .Flags ().GetBool ("local" )
4141 forceRemote , _ := cmd .Flags ().GetBool ("remote" )
42+ minStars , _ := cmd .Flags ().GetInt ("min-stars" )
4243
4344 // Load config or use default
4445 cfg , err := config .LoadConfig ()
@@ -80,7 +81,7 @@ Use --remote to force remote API search.`,
8081
8182 if len (allRepos ) > 0 || forceLocal {
8283 // Display results from local cache
83- displaySearchResults (allRepos , installedSkills , searchSource )
84+ displaySearchResults (allRepos , installedSkills , searchSource , minStars )
8485 if forceLocal && len (allRepos ) == 0 {
8586 fmt .Println ("\n Tip: Run 'ask repo sync' to populate local cache." )
8687 }
@@ -117,10 +118,13 @@ Use --remote to force remote API search.`,
117118 repos , err = github .SearchTopic (r .URL , keyword )
118119 case "dir" :
119120 parts := strings .Split (r .URL , "/" )
120- if len (parts ) >= 3 {
121+ if len (parts ) >= 2 {
121122 owner := parts [0 ]
122123 repoName := parts [1 ]
123- path := strings .Join (parts [2 :], "/" )
124+ path := ""
125+ if len (parts ) > 2 {
126+ path = strings .Join (parts [2 :], "/" )
127+ }
124128 repos , err = github .SearchDir (owner , repoName , path )
125129
126130 // Filter client-side by keyword
@@ -166,14 +170,31 @@ Use --remote to force remote API search.`,
166170 fmt .Println ()
167171 }
168172
169- displaySearchResults (allRepos , installedSkills , searchSource )
173+ // Filter by min-stars if specified
174+ if minStars > 0 {
175+ // Filtering is handled in displaySearchResults to ensure consistent counting
176+ }
177+
178+ displaySearchResults (allRepos , installedSkills , searchSource , minStars )
170179 },
171180}
172181
173- func displaySearchResults (repos []github.Repository , installedSkills map [string ]bool , source string ) {
182+ func displaySearchResults (repos []github.Repository , installedSkills map [string ]bool , source string , minStars int ) {
183+ // Filter repos if minStars > 0
184+ var displayRepos []github.Repository
185+ if minStars > 0 {
186+ for _ , repo := range repos {
187+ if repo .StargazersCount >= minStars {
188+ displayRepos = append (displayRepos , repo )
189+ }
190+ }
191+ } else {
192+ displayRepos = repos
193+ }
194+
174195 w := tabwriter .NewWriter (os .Stdout , 0 , 0 , 2 , ' ' , 0 )
175196 _ , _ = fmt .Fprintln (w , "NAME\t SOURCE\t INSTALLED\t STARS\t DESCRIPTION" )
176- for _ , repo := range repos {
197+ for _ , repo := range displayRepos {
177198 // Truncate description if too long
178199 desc := repo .Description
179200 if len (desc ) > 40 {
@@ -186,7 +207,7 @@ func displaySearchResults(repos []github.Repository, installedSkills map[string]
186207 installed = "✓"
187208 }
188209
189- // Format stars (use "-" for local or dir-based)
210+ // Format stars (use "-" for local or dir-based if actually 0, but dir-based now have stars )
190211 stars := fmt .Sprintf ("%d" , repo .StargazersCount )
191212 if repo .StargazersCount == 0 {
192213 stars = "-"
@@ -196,7 +217,12 @@ func displaySearchResults(repos []github.Repository, installedSkills map[string]
196217 }
197218 _ = w .Flush ()
198219
199- fmt .Printf ("\n Found %d skills.\n " , len (repos ))
220+ fmt .Printf ("\n Found %d skills" , len (displayRepos ))
221+ if minStars > 0 {
222+ fmt .Printf (" (filtered from %d results by stars >= %d)" , len (repos ), minStars )
223+ }
224+ fmt .Println ("." )
225+
200226 if source == "local" {
201227 fmt .Println ("(from local cache - run 'ask repo sync' to update)" )
202228 }
@@ -206,4 +232,5 @@ func init() {
206232 skillCmd .AddCommand (searchCmd )
207233 searchCmd .Flags ().Bool ("local" , false , "search only local cache (offline)" )
208234 searchCmd .Flags ().Bool ("remote" , false , "force remote API search" )
235+ searchCmd .Flags ().Int ("min-stars" , 0 , "filter skills by minimum integer number of GitHub stars" )
209236}
0 commit comments