Class: Aidp::Skills::Skill

Inherits:
Object
  • Object
show all
Defined in:
lib/aidp/skills/skill.rb

Overview

Represents a skill/persona with metadata and content

A Skill encapsulates an agent’s persona, expertise, and capabilities. Skills are loaded from SKILL.md files with YAML frontmatter.

Examples:

Creating a skill

skill = Skill.new(
  id: "repository_analyst",
  name: "Repository Analyst",
  description: "Expert in version control analysis",
  version: "1.0.0",
  expertise: ["git analysis", "code metrics"],
  keywords: ["git", "metrics"],
  when_to_use: ["Analyzing repository history"],
  when_not_to_use: ["Writing new code"],
  compatible_providers: ["anthropic", "openai"],
  content: "You are a Repository Analyst...",
  source_path: "/path/to/SKILL.md"
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:, description:, version:, content:, source_path:, expertise: [], keywords: [], when_to_use: [], when_not_to_use: [], compatible_providers: []) ⇒ Skill

Initialize a new Skill



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/aidp/skills/skill.rb', line 44

def initialize(
  id:,
  name:,
  description:,
  version:,
  content:, source_path:, expertise: [],
  keywords: [],
  when_to_use: [],
  when_not_to_use: [],
  compatible_providers: []
)
  @id = id
  @name = name
  @description = description
  @version = version
  @expertise = Array(expertise)
  @keywords = Array(keywords)
  @when_to_use = Array(when_to_use)
  @when_not_to_use = Array(when_not_to_use)
  @compatible_providers = Array(compatible_providers)
  @content = content
  @source_path = source_path

  validate!
end

Instance Attribute Details

#compatible_providersObject (readonly)

Returns the value of attribute compatible_providers.



27
28
29
# File 'lib/aidp/skills/skill.rb', line 27

def compatible_providers
  @compatible_providers
end

#contentObject (readonly)

Returns the value of attribute content.



27
28
29
# File 'lib/aidp/skills/skill.rb', line 27

def content
  @content
end

#descriptionObject (readonly)

Returns the value of attribute description.



27
28
29
# File 'lib/aidp/skills/skill.rb', line 27

def description
  @description
end

#expertiseObject (readonly)

Returns the value of attribute expertise.



27
28
29
# File 'lib/aidp/skills/skill.rb', line 27

def expertise
  @expertise
end

#idObject (readonly)

Returns the value of attribute id.



27
28
29
# File 'lib/aidp/skills/skill.rb', line 27

def id
  @id
end

#keywordsObject (readonly)

Returns the value of attribute keywords.



27
28
29
# File 'lib/aidp/skills/skill.rb', line 27

def keywords
  @keywords
end

#nameObject (readonly)

Returns the value of attribute name.



27
28
29
# File 'lib/aidp/skills/skill.rb', line 27

def name
  @name
end

#source_pathObject (readonly)

Returns the value of attribute source_path.



27
28
29
# File 'lib/aidp/skills/skill.rb', line 27

def source_path
  @source_path
end

#versionObject (readonly)

Returns the value of attribute version.



27
28
29
# File 'lib/aidp/skills/skill.rb', line 27

def version
  @version
end

#when_not_to_useObject (readonly)

Returns the value of attribute when_not_to_use.



27
28
29
# File 'lib/aidp/skills/skill.rb', line 27

def when_not_to_use
  @when_not_to_use
end

#when_to_useObject (readonly)

Returns the value of attribute when_to_use.



27
28
29
# File 'lib/aidp/skills/skill.rb', line 27

def when_to_use
  @when_to_use
end

Instance Method Details

#compatible_with?(provider_name) ⇒ Boolean

Check if this skill is compatible with a given provider



74
75
76
77
# File 'lib/aidp/skills/skill.rb', line 74

def compatible_with?(provider_name)
  return true if compatible_providers.empty?
  compatible_providers.include?(provider_name.to_s.downcase)
end

#detailsHash

Get full details of this skill for display



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/aidp/skills/skill.rb', line 118

def details
  {
    id: id,
    name: name,
    description: description,
    version: version,
    expertise: expertise,
    keywords: keywords,
    when_to_use: when_to_use,
    when_not_to_use: when_not_to_use,
    compatible_providers: compatible_providers,
    source: source_path,
    content_length: content.length
  }
end

#inspectString

Return inspection string



144
145
146
147
# File 'lib/aidp/skills/skill.rb', line 144

def inspect
  "#<Aidp::Skills::Skill id=#{id} name=\"#{name}\" version=#{version} " \
    "source=#{source_path}>"
end

#matches?(query) ⇒ Boolean

Check if this skill matches a search query

Searches across: id, name, description, expertise, keywords



85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/aidp/skills/skill.rb', line 85

def matches?(query)
  return true if query.nil? || query.strip.empty?

  query_lower = query.downcase
  searchable_text = [
    id,
    name,
    description,
    expertise,
    keywords
  ].flatten.join(" ").downcase

  searchable_text.include?(query_lower)
end

#summaryHash

Get a summary of this skill for display



103
104
105
106
107
108
109
110
111
112
113
# File 'lib/aidp/skills/skill.rb', line 103

def summary
  {
    id: id,
    name: name,
    description: description,
    version: version,
    expertise_areas: expertise.size,
    keywords: keywords,
    providers: compatible_providers.empty? ? "all" : compatible_providers.join(", ")
  }
end

#to_sString

Return string representation



137
138
139
# File 'lib/aidp/skills/skill.rb', line 137

def to_s
  "Skill[#{id}](#{name} v#{version})"
end