Class: OllamaAgent::Plugins::Loader
- Inherits:
-
Object
- Object
- OllamaAgent::Plugins::Loader
- Defined in:
- lib/ollama_agent/plugins/loader.rb
Overview
Loads plugins from:
1. OLLAMA_AGENT_PLUGINS env var (comma-separated require paths)
2. ~/.config/ollama_agent/plugins.rb (user global plugins)
3. <project_root>/.ollama_agent/plugins.rb (project-local plugins)
4. Gem-installed plugins with name matching "ollama_agent_*"
Each loaded file is expected to call:
OllamaAgent::Plugins::Registry.register(:my_plugin) { |r| ... }
Constant Summary collapse
- GLOBAL_PLUGINS_PATH =
File.join(Dir.home, ".config", "ollama_agent", "plugins.rb")
- GEM_PLUGIN_PREFIX =
"ollama_agent_"
Instance Method Summary collapse
-
#initialize(root: Dir.pwd, registry: nil) ⇒ Loader
constructor
A new instance of Loader.
-
#load_all(skip_gems: false) ⇒ Array<String>
Load all applicable plugins.
-
#load_plugin(path_or_require) ⇒ Object
Load a single plugin from a require path or file.
Constructor Details
Instance Method Details
#load_all(skip_gems: false) ⇒ Array<String>
Load all applicable plugins.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ollama_agent/plugins/loader.rb', line 27 def load_all(skip_gems: false) loaded = [] loaded.concat(load_env_plugins) loaded.concat(load_file_plugin(GLOBAL_PLUGINS_PATH)) loaded.concat(load_file_plugin(project_plugins_path)) loaded.concat(load_gem_plugins) unless skip_gems loaded end |
#load_plugin(path_or_require) ⇒ Object
Load a single plugin from a require path or file.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ollama_agent/plugins/loader.rb', line 39 def load_plugin(path_or_require) if File.exist?(path_or_require) require File.(path_or_require) else require path_or_require end [path_or_require] rescue LoadError => e warn "ollama_agent: plugin load failed (#{path_or_require}): #{e.}" if debug? [] rescue StandardError => e warn "ollama_agent: plugin error (#{path_or_require}): #{e.}" [] end |