Class: RubynCode::Skills::AutoSuggest
- Inherits:
-
Object
- Object
- RubynCode::Skills::AutoSuggest
- Defined in:
- lib/rubyn_code/skills/auto_suggest.rb
Overview
Suggests skill packs based on gems detected in the project’s Gemfile.
On session start, parses the Gemfile, queries the registry for matching packs, and shows a one-time suggestion. Tracks shown suggestions in ‘.rubyn-code/suggested.json` to avoid repeating.
Constant Summary collapse
- SUGGESTED_FILE =
'suggested.json'
Instance Method Summary collapse
-
#check ⇒ String?
Check for suggestable packs and return a display message if any.
-
#initialize(project_root:, registry_client: nil) ⇒ AutoSuggest
constructor
A new instance of AutoSuggest.
-
#mark_dismissed(name) ⇒ Object
Mark a suggestion as dismissed.
-
#mark_installed(name) ⇒ Object
Mark a pack as installed so it won’t be suggested again.
Constructor Details
#initialize(project_root:, registry_client: nil) ⇒ AutoSuggest
Returns a new instance of AutoSuggest.
18 19 20 21 |
# File 'lib/rubyn_code/skills/auto_suggest.rb', line 18 def initialize(project_root:, registry_client: nil) @project_root = project_root @client = registry_client || RegistryClient.new end |
Instance Method Details
#check ⇒ String?
Check for suggestable packs and return a display message if any. Returns nil if no suggestions or if all have been shown/dismissed.
This method never raises — registry failures are silently swallowed to avoid blocking session start.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rubyn_code/skills/auto_suggest.rb', line 30 def check gems = parse_gemfile return nil if gems.empty? suggestions = fetch_suggestions(gems) return nil if suggestions.empty? new_suggestions = filter_shown(suggestions) return nil if new_suggestions.empty? record_shown(new_suggestions) (new_suggestions) rescue StandardError nil end |
#mark_dismissed(name) ⇒ Object
Mark a suggestion as dismissed.
59 60 61 62 63 64 |
# File 'lib/rubyn_code/skills/auto_suggest.rb', line 59 def mark_dismissed(name) state = load_state state['dismissed'] ||= [] state['dismissed'] << name unless state['dismissed'].include?(name) save_state(state) end |
#mark_installed(name) ⇒ Object
Mark a pack as installed so it won’t be suggested again.
49 50 51 52 53 54 |
# File 'lib/rubyn_code/skills/auto_suggest.rb', line 49 def mark_installed(name) state = load_state state['installed'] ||= [] state['installed'] << name unless state['installed'].include?(name) save_state(state) end |