Class: Aidp::Skills::Wizard::TemplateLibrary
- Inherits:
-
Object
- Object
- Aidp::Skills::Wizard::TemplateLibrary
- Defined in:
- lib/aidp/skills/wizard/template_library.rb
Overview
Manages skill templates for the wizard
Loads and provides access to template skills from the gem’s templates/skills/ directory and existing project skills from .aidp/skills/ for cloning.
Instance Attribute Summary collapse
-
#project_dir ⇒ Object
readonly
Returns the value of attribute project_dir.
Instance Method Summary collapse
-
#all ⇒ Array<Skill>
Get all skills (templates + project skills).
-
#exists?(skill_id) ⇒ Boolean
Check if a skill ID exists.
-
#find(skill_id) ⇒ Skill?
Find a template or project skill by ID.
-
#initialize(project_dir:) ⇒ TemplateLibrary
constructor
Initialize template library.
-
#project_skill_list ⇒ Array<Hash>
Get project skill names for display.
-
#project_skills ⇒ Array<Skill>
Get all project skills (for cloning).
-
#skill_list ⇒ Array<Hash>
Get combined list for selection.
-
#template_list ⇒ Array<Hash>
Get template names for display.
-
#templates ⇒ Array<Skill>
Get all available templates.
Constructor Details
#initialize(project_dir:) ⇒ TemplateLibrary
Initialize template library
23 24 25 26 27 |
# File 'lib/aidp/skills/wizard/template_library.rb', line 23 def initialize(project_dir:) @project_dir = project_dir @templates = nil @project_skills = nil end |
Instance Attribute Details
#project_dir ⇒ Object (readonly)
Returns the value of attribute project_dir.
18 19 20 |
# File 'lib/aidp/skills/wizard/template_library.rb', line 18 def project_dir @project_dir end |
Instance Method Details
#all ⇒ Array<Skill>
Get all skills (templates + project skills)
48 49 50 |
# File 'lib/aidp/skills/wizard/template_library.rb', line 48 def all templates + project_skills end |
#exists?(skill_id) ⇒ Boolean
Check if a skill ID exists
64 65 66 |
# File 'lib/aidp/skills/wizard/template_library.rb', line 64 def exists?(skill_id) !find(skill_id).nil? end |
#find(skill_id) ⇒ Skill?
Find a template or project skill by ID
56 57 58 |
# File 'lib/aidp/skills/wizard/template_library.rb', line 56 def find(skill_id) all.find { |skill| skill.id == skill_id.to_s } end |
#project_skill_list ⇒ Array<Hash>
Get project skill names for display
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/aidp/skills/wizard/template_library.rb', line 85 def project_skill_list project_skills.map do |skill| { id: skill.id, name: skill.name, description: skill.description, source: :project } end end |
#project_skills ⇒ Array<Skill>
Get all project skills (for cloning)
40 41 42 43 |
# File 'lib/aidp/skills/wizard/template_library.rb', line 40 def project_skills load_project_skills unless project_skills_loaded? @project_skills end |
#skill_list ⇒ Array<Hash>
Get combined list for selection
99 100 101 |
# File 'lib/aidp/skills/wizard/template_library.rb', line 99 def skill_list template_list + project_skill_list end |
#template_list ⇒ Array<Hash>
Get template names for display
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/aidp/skills/wizard/template_library.rb', line 71 def template_list templates.map do |skill| { id: skill.id, name: skill.name, description: skill.description, source: :template } end end |
#templates ⇒ Array<Skill>
Get all available templates
32 33 34 35 |
# File 'lib/aidp/skills/wizard/template_library.rb', line 32 def templates load_templates unless loaded? @templates end |