Class: Aidp::Skills::Wizard::TemplateLibrary

Inherits:
Object
  • Object
show all
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.

Examples:

Loading templates

library = TemplateLibrary.new(project_dir: "/path/to/project")
templates = library.templates
template = library.find("base_developer")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_dir:) ⇒ TemplateLibrary

Initialize template library

Parameters:

  • project_dir (String)

    Root directory of the project



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_dirObject (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

#allArray<Skill>

Get all skills (templates + project skills)

Returns:

  • (Array<Skill>)

    Combined array of all 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

Parameters:

  • skill_id (String)

    Skill identifier

Returns:

  • (Boolean)

    True if skill 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

Parameters:

  • skill_id (String)

    Skill identifier

Returns:

  • (Skill, nil)

    Found skill or nil



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_listArray<Hash>

Get project skill names for display

Returns:

  • (Array<Hash>)

    Array of name, description hashes



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_skillsArray<Skill>

Get all project skills (for cloning)

Returns:

  • (Array<Skill>)

    Array of project-specific skills



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_listArray<Hash>

Get combined list for selection

Returns:

  • (Array<Hash>)

    Array of name, description, source hashes



99
100
101
# File 'lib/aidp/skills/wizard/template_library.rb', line 99

def skill_list
  template_list + project_skill_list
end

#template_listArray<Hash>

Get template names for display

Returns:

  • (Array<Hash>)

    Array of name, description hashes



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

#templatesArray<Skill>

Get all available templates

Returns:

  • (Array<Skill>)

    Array of template skills



32
33
34
35
# File 'lib/aidp/skills/wizard/template_library.rb', line 32

def templates
  load_templates unless loaded?
  @templates
end