Module: TheLocal::DiskProviders
- Defined in:
- lib/the_local/disk_providers.rb
Overview
Discovers providers by reading their committed agent files straight from each bundled gem’s path on disk — no gem code is loaded and no register block runs. The committed .md (the build-and-commit artifact) is the declarative contract; a provider contributes simply by shipping those files. Populates the same registry the install pipeline already reads, so Installer/TriggerWriter/Sync are unchanged.
Constant Summary collapse
- AGENTS_GLOB =
File.join("lib", "**", "the_local", "agents", "*.md")
Class Method Summary collapse
- .agent_from(gem_name, file) ⇒ Object
- .load(registry:, specs:) ⇒ Object
- .register(registry, spec) ⇒ Object
Class Method Details
.agent_from(gem_name, file) ⇒ Object
26 27 28 29 30 |
# File 'lib/the_local/disk_providers.rb', line 26 def self.agent_from(gem_name, file) prefix, _, name = File.basename(file, ".md").rpartition("-") Agent.new(gem_name: gem_name, prefix: prefix, name: name, description: nil, tools: nil, body: nil, knowledge: nil, source_path: file) end |
.load(registry:, specs:) ⇒ Object
13 14 15 |
# File 'lib/the_local/disk_providers.rb', line 13 def self.load(registry:, specs:) specs.each { |spec| register(registry, spec) } end |
.register(registry, spec) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/the_local/disk_providers.rb', line 17 def self.register(registry, spec) files = Dir.glob(File.join(spec[:path], AGENTS_GLOB)) return if files.empty? agents = files.map { |file| agent_from(spec[:name], file) } registry.add_provider(Provider.new(gem_name: spec[:name], prefix: agents.first.prefix, scope: nil)) agents.each { |agent| registry.add(agent) } end |