feat: add --search flag to filter models (#128)#157
Conversation
Greptile SummaryAdds a
Confidence Score: 3/5The --search feature works correctly for remote models, but local model search silently ignores descriptions despite the help text promising both — users can get misleading no-results responses. The local search filter only matches on file name while list_remote_models checks name and description. The CLI help text says 'Find models by name or description' for both modes, so any user running --local --search with a description term gets a wrong answer with no indication why. That behavioral gap should be resolved before merging. lib/classifier/cli.rb — specifically the list_local_models search filter and the --search option help text. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[models command] --> B{--local flag?}
B -- yes --> C[list_local_models]
B -- no --> D[list_remote_models]
C --> C1[Glob local JSON files]
C1 --> C2{--search set?}
C2 -- yes --> C3[Filter by name only]
C2 -- no --> C4[All models]
C3 --> C5{empty?}
C4 --> C5
C5 -- yes --> C6[No local models found]
C5 -- no --> C7[Display local models]
D --> D1[Fetch registry index]
D1 --> D2{--search set?}
D2 -- yes --> D3[Filter by name OR description]
D2 -- no --> D4[All models]
D3 --> D5{empty?}
D4 --> D5
D5 -- yes --> D6[No models found in registry]
D5 -- no --> D7[Display remote models]
style C3 fill:#f9c,stroke:#c66
style D3 fill:#9cf,stroke:#69c
Prompt To Fix All With AIFix the following 4 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 4
lib/classifier/cli.rb:385-389
`unless ... nil?` is the verbose form of `if`. Ruby's falsy semantics cover `nil`, so the nil check is redundant and this pattern reads awkwardly. Applies to both occurrences (lines 385 and 428).
```suggestion
if @options[:search]
models = models.filter do |name, info|
[name, info['description']].any?(/#{Regexp.escape(@options[:search])}/i)
end
end
```
In this review, suggest simpl... ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
### Issue 2 of 4
lib/classifier/cli.rb:428-432
Same `unless ... nil?` anti-pattern in the local model filter. Prefer `if @options[:search]`.
```suggestion
if @options[:search]
models = models.filter do |model|
model[:name] =~ /#{Regexp.escape(@options[:search])}/i
end
end
```
In this review, suggest simpl... ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
### Issue 3 of 4
lib/classifier/cli.rb:428-432
**Local search ignores descriptions, but the flag says otherwise.** The `--search` option is advertised as "Find models by name or description," but `list_local_models` only matches on `model[:name]`. A user who runs `--local --search "spam detection"` and expects a description hit will get zero results, while the same query against the remote registry would succeed. Either restrict the help text to "by name" for local mode, or load each model's JSON inside the filter block to also check `info['description']`.
### Issue 4 of 4
test/cli/registry_commands_test.rb:165
Typo in test name: `decription` → `description`.
```suggestion
def test_models_remote_search_by_description
```
Reviews (1): Last reviewed commit: "feat: add `--search` flag to filter mode..." | Re-trigger Greptile |
|
@cardmagic can you take a look, please? |
Closes #128