Class: Aidp::Skills::Registry
- Inherits:
-
Object
- Object
- Aidp::Skills::Registry
- Defined in:
- lib/aidp/skills/registry.rb
Overview
Registry for managing available skills
The Registry loads skills from multiple search paths and provides lookup, filtering, and management capabilities.
Skills are loaded from:
-
Template skills directory (gem templates/skills/) - built-in templates
-
Project skills directory (.aidp/skills/) - project-specific skills
Project skills with matching IDs override template skills.
Instance Attribute Summary collapse
-
#project_dir ⇒ Object
readonly
Returns the value of attribute project_dir.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
Instance Method Summary collapse
-
#all ⇒ Array<Skill>
Get all registered skills.
-
#by_keyword(keyword) ⇒ Array<Skill>
Get skills by keyword.
-
#by_source ⇒ Hash
Get skill IDs grouped by source.
-
#compatible_with(provider_name) ⇒ Array<Skill>
Get skills compatible with a specific provider.
-
#count ⇒ Integer
Get count of registered skills.
-
#exists?(skill_id) ⇒ Boolean
Check if a skill exists.
-
#find(skill_id) ⇒ Skill?
Find a skill by ID.
-
#initialize(project_dir:, provider: nil) ⇒ Registry
constructor
Initialize a new skills registry.
-
#load_skills ⇒ Integer
Load skills from all search paths.
-
#loaded? ⇒ Boolean
Check if skills have been loaded.
-
#reload ⇒ Integer
Reload skills from disk.
-
#search(query) ⇒ Array<Skill>
Get skills matching a search query.
Constructor Details
#initialize(project_dir:, provider: nil) ⇒ Registry
Initialize a new skills registry
32 33 34 35 36 37 |
# File 'lib/aidp/skills/registry.rb', line 32 def initialize(project_dir:, provider: nil) @project_dir = project_dir @provider = provider @skills = {} @loaded = false end |
Instance Attribute Details
#project_dir ⇒ Object (readonly)
Returns the value of attribute project_dir.
26 27 28 |
# File 'lib/aidp/skills/registry.rb', line 26 def project_dir @project_dir end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
26 27 28 |
# File 'lib/aidp/skills/registry.rb', line 26 def provider @provider end |
Instance Method Details
#all ⇒ Array<Skill>
Get all registered skills
77 78 79 80 |
# File 'lib/aidp/skills/registry.rb', line 77 def all load_skills unless loaded? @skills.values end |
#by_keyword(keyword) ⇒ Array<Skill>
Get skills by keyword
95 96 97 98 |
# File 'lib/aidp/skills/registry.rb', line 95 def by_keyword(keyword) load_skills unless loaded? all.select { |skill| skill.keywords.include?(keyword) } end |
#by_source ⇒ Hash
Get skill IDs grouped by source
143 144 145 146 147 148 149 150 |
# File 'lib/aidp/skills/registry.rb', line 143 def by_source load_skills unless loaded? { template: @skills.values.select { |s| template_skill?(s) }.map(&:id), project: @skills.values.select { |s| project_skill?(s) }.map(&:id) } end |
#compatible_with(provider_name) ⇒ Array<Skill>
Get skills compatible with a specific provider
104 105 106 107 |
# File 'lib/aidp/skills/registry.rb', line 104 def compatible_with(provider_name) load_skills unless loaded? all.select { |skill| skill.compatible_with?(provider_name) } end |
#count ⇒ Integer
Get count of registered skills
127 128 129 130 |
# File 'lib/aidp/skills/registry.rb', line 127 def count load_skills unless loaded? @skills.size end |
#exists?(skill_id) ⇒ Boolean
Check if a skill exists
113 114 115 |
# File 'lib/aidp/skills/registry.rb', line 113 def exists?(skill_id) find(skill_id) != nil end |
#find(skill_id) ⇒ Skill?
Find a skill by ID
69 70 71 72 |
# File 'lib/aidp/skills/registry.rb', line 69 def find(skill_id) load_skills unless loaded? @skills[skill_id.to_s] end |
#load_skills ⇒ Integer
Load skills from all search paths
Skills are loaded in order:
-
Template skills (gem templates/skills/) - built-in templates
-
Project skills (.aidp/skills/) - override templates
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/aidp/skills/registry.rb', line 46 def load_skills Aidp.log_debug("skills", "Loading skills", project_dir: project_dir, provider: provider) @skills = {} # Load template skills first template_skills = load_from_path(template_skills_path) template_skills.each { |skill| register_skill(skill, source: :template) } # Load project skills (override templates if IDs match) project_skills = load_from_path(project_skills_path) project_skills.each { |skill| register_skill(skill, source: :project) } @loaded = true Aidp.log_info("skills", "Loaded skills", count: @skills.size, provider: provider) @skills.size end |
#loaded? ⇒ Boolean
Check if skills have been loaded
120 121 122 |
# File 'lib/aidp/skills/registry.rb', line 120 def loaded? @loaded end |
#reload ⇒ Integer
Reload skills from disk
135 136 137 138 |
# File 'lib/aidp/skills/registry.rb', line 135 def reload @loaded = false load_skills end |
#search(query) ⇒ Array<Skill>
Get skills matching a search query
86 87 88 89 |
# File 'lib/aidp/skills/registry.rb', line 86 def search(query) load_skills unless loaded? all.select { |skill| skill.matches?(query) } end |