Class: Aidp::Skills::Skill
- Inherits:
-
Object
- Object
- Aidp::Skills::Skill
- 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.
Instance Attribute Summary collapse
-
#compatible_providers ⇒ Object
readonly
Returns the value of attribute compatible_providers.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#expertise ⇒ Object
readonly
Returns the value of attribute expertise.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#keywords ⇒ Object
readonly
Returns the value of attribute keywords.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#source_path ⇒ Object
readonly
Returns the value of attribute source_path.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
-
#when_not_to_use ⇒ Object
readonly
Returns the value of attribute when_not_to_use.
-
#when_to_use ⇒ Object
readonly
Returns the value of attribute when_to_use.
Instance Method Summary collapse
-
#compatible_with?(provider_name) ⇒ Boolean
Check if this skill is compatible with a given provider.
-
#details ⇒ Hash
Get full details of this skill for display.
-
#initialize(id:, name:, description:, version:, content:, source_path:, expertise: [], keywords: [], when_to_use: [], when_not_to_use: [], compatible_providers: []) ⇒ Skill
constructor
Initialize a new Skill.
-
#inspect ⇒ String
Return inspection string.
-
#matches?(query) ⇒ Boolean
Check if this skill matches a search query.
-
#summary ⇒ Hash
Get a summary of this skill for display.
-
#to_s ⇒ String
Return string representation.
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_providers ⇒ Object (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 |
#content ⇒ Object (readonly)
Returns the value of attribute content.
27 28 29 |
# File 'lib/aidp/skills/skill.rb', line 27 def content @content end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
27 28 29 |
# File 'lib/aidp/skills/skill.rb', line 27 def description @description end |
#expertise ⇒ Object (readonly)
Returns the value of attribute expertise.
27 28 29 |
# File 'lib/aidp/skills/skill.rb', line 27 def expertise @expertise end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
27 28 29 |
# File 'lib/aidp/skills/skill.rb', line 27 def id @id end |
#keywords ⇒ Object (readonly)
Returns the value of attribute keywords.
27 28 29 |
# File 'lib/aidp/skills/skill.rb', line 27 def keywords @keywords end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
27 28 29 |
# File 'lib/aidp/skills/skill.rb', line 27 def name @name end |
#source_path ⇒ Object (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 |
#version ⇒ Object (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_use ⇒ Object (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_use ⇒ Object (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 |
#details ⇒ Hash
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 |
#inspect ⇒ String
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 |
#summary ⇒ Hash
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_s ⇒ String
Return string representation
137 138 139 |
# File 'lib/aidp/skills/skill.rb', line 137 def to_s "Skill[#{id}](#{name} v#{version})" end |