Class: AgentSkills::Loader
- Inherits:
-
Object
- Object
- AgentSkills::Loader
- Defined in:
- lib/agent_skills/loader.rb
Constant Summary collapse
- DEFAULT_PATHS =
[ File.("~/.config/claude/skills"), ".claude/skills", "skills" ].freeze
Instance Attribute Summary collapse
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#skills ⇒ Object
readonly
Returns the value of attribute skills.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #count ⇒ Object
- #discover ⇒ Object
- #each(&block) ⇒ Object
- #find_relevant(query) ⇒ Object
-
#initialize(paths: DEFAULT_PATHS) ⇒ Loader
constructor
A new instance of Loader.
Constructor Details
#initialize(paths: DEFAULT_PATHS) ⇒ Loader
Returns a new instance of Loader.
13 14 15 16 |
# File 'lib/agent_skills/loader.rb', line 13 def initialize(paths: DEFAULT_PATHS) @paths = Array(paths) @skills = {} end |
Instance Attribute Details
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
11 12 13 |
# File 'lib/agent_skills/loader.rb', line 11 def paths @paths end |
#skills ⇒ Object (readonly)
Returns the value of attribute skills.
11 12 13 |
# File 'lib/agent_skills/loader.rb', line 11 def skills @skills end |
Instance Method Details
#[](name) ⇒ Object
31 32 33 |
# File 'lib/agent_skills/loader.rb', line 31 def [](name) @skills[name] end |
#count ⇒ Object
35 36 37 |
# File 'lib/agent_skills/loader.rb', line 35 def count @skills.size end |
#discover ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/agent_skills/loader.rb', line 18 def discover @skills = {} @paths.each do |base_path| = File.(base_path) next unless File.directory?() discover_in_path() end @skills end |
#each(&block) ⇒ Object
39 40 41 |
# File 'lib/agent_skills/loader.rb', line 39 def each(&block) @skills.each(&block) end |
#find_relevant(query) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/agent_skills/loader.rb', line 43 def find_relevant(query) return [] if query.nil? || query.empty? keywords = query.downcase.split(/\s+/) @skills.values.select do |skill| text = "#{skill.name} #{skill.description}".downcase keywords.any? { |keyword| text.include?(keyword) } end end |