Class: RubynCode::Skills::RegistryAutoload
- Inherits:
-
Object
- Object
- RubynCode::Skills::RegistryAutoload
- Defined in:
- lib/rubyn_code/skills/registry_autoload.rb
Overview
Web fallback for trigger-based skill autoload.
When the user message matches a skill pack in the registry that the user hasn’t installed locally, fetch the pack, install it under ~/.rubyn-code/skill-packs/, refresh the loader’s catalog, and let the local matcher pick up the freshly-available skills.
Pack-level matching (decided up front): substring-match the user message against each pack’s :name and :tags. Skill-level triggers aren’t in the registry catalog yet, so we pull packs at the coarser grain and let the local matcher take over once files land on disk.
Failure modes are silent: a registry error returns no matches so the turn proceeds as if the web fallback weren’t there.
Instance Method Summary collapse
-
#initialize(loader:, matcher:, registry_client: nil, pack_manager: nil, on_fetching: nil) ⇒ RegistryAutoload
constructor
A new instance of RegistryAutoload.
-
#try(user_input) ⇒ Array<Hash>
Attempt to install and match uninstalled packs whose name or tags appear in the user message.
Constructor Details
#initialize(loader:, matcher:, registry_client: nil, pack_manager: nil, on_fetching: nil) ⇒ RegistryAutoload
Returns a new instance of RegistryAutoload.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rubyn_code/skills/registry_autoload.rb', line 25 def initialize(loader:, matcher:, registry_client: nil, pack_manager: nil, on_fetching: nil) @loader = loader @matcher = matcher @client = registry_client || RegistryClient.new @pack_manager = pack_manager || PackManager.new @on_fetching = on_fetching || ->(_name) {} @attempted = Set.new @catalog_cache = nil @catalog_fetch_failed = false end |
Instance Method Details
#try(user_input) ⇒ Array<Hash>
Attempt to install and match uninstalled packs whose name or tags appear in the user message.
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rubyn_code/skills/registry_autoload.rb', line 43 def try(user_input) text = user_input.to_s.downcase return [] if text.empty? candidates = uninstalled_packs_matching(text) return [] if candidates.empty? installed_any = candidates.any? { |pack| attempt_install(pack) } return [] unless installed_any @loader.catalog.refresh! @matcher.match(user_input) end |