Class: Aidp::Metadata::ToolMetadata
- Inherits:
-
Object
- Object
- Aidp::Metadata::ToolMetadata
- Defined in:
- lib/aidp/metadata/tool_metadata.rb
Overview
Base class for tool metadata (skills, personas, templates)
Represents metadata extracted from YAML frontmatter in .md files. Provides validation and query capabilities for the tool directory.
Constant Summary collapse
- VALID_TYPES =
Valid tool types
%w[skill persona template].freeze
- DEFAULT_PRIORITY =
Default priority (medium)
5
Instance Attribute Summary collapse
-
#applies_to ⇒ Object
readonly
Returns the value of attribute applies_to.
-
#capabilities ⇒ Object
readonly
Returns the value of attribute capabilities.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#experimental ⇒ Object
readonly
Returns the value of attribute experimental.
-
#file_hash ⇒ Object
readonly
Returns the value of attribute file_hash.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#source_path ⇒ Object
readonly
Returns the value of attribute source_path.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
-
#work_unit_types ⇒ Object
readonly
Returns the value of attribute work_unit_types.
Instance Method Summary collapse
-
#applies_to?(tags) ⇒ Boolean
Check if this tool applies to given tags.
-
#details ⇒ Hash
Get full details of this tool for display.
-
#initialize(type:, id:, title:, summary:, version:, content:, source_path:, file_hash:, applies_to: [], work_unit_types: [], priority: DEFAULT_PRIORITY, capabilities: [], dependencies: [], experimental: false) ⇒ ToolMetadata
constructor
Initialize new tool metadata.
-
#inspect ⇒ String
Return inspection string.
-
#summary_hash ⇒ Hash
Get a summary of this tool for display.
-
#supports_work_unit?(type) ⇒ Boolean
Check if this tool supports a given work unit type.
-
#to_h ⇒ Hash
Convert to hash for serialization.
-
#to_s ⇒ String
Return string representation.
Constructor Details
#initialize(type:, id:, title:, summary:, version:, content:, source_path:, file_hash:, applies_to: [], work_unit_types: [], priority: DEFAULT_PRIORITY, capabilities: [], dependencies: [], experimental: false) ⇒ ToolMetadata
Initialize new tool metadata
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/aidp/metadata/tool_metadata.rb', line 53 def initialize( type:, id:, title:, summary:, version:, content:, source_path:, file_hash:, applies_to: [], work_unit_types: [], priority: DEFAULT_PRIORITY, capabilities: [], dependencies: [], experimental: false ) @type = type @id = id @title = title @summary = summary @version = version @applies_to = Array(applies_to) @work_unit_types = Array(work_unit_types) @priority = priority @capabilities = Array(capabilities) @dependencies = Array(dependencies) @experimental = experimental @content = content @source_path = source_path @file_hash = file_hash validate! end |
Instance Attribute Details
#applies_to ⇒ Object (readonly)
Returns the value of attribute applies_to.
26 27 28 |
# File 'lib/aidp/metadata/tool_metadata.rb', line 26 def applies_to @applies_to end |
#capabilities ⇒ Object (readonly)
Returns the value of attribute capabilities.
26 27 28 |
# File 'lib/aidp/metadata/tool_metadata.rb', line 26 def capabilities @capabilities end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
26 27 28 |
# File 'lib/aidp/metadata/tool_metadata.rb', line 26 def content @content end |
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
26 27 28 |
# File 'lib/aidp/metadata/tool_metadata.rb', line 26 def dependencies @dependencies end |
#experimental ⇒ Object (readonly)
Returns the value of attribute experimental.
26 27 28 |
# File 'lib/aidp/metadata/tool_metadata.rb', line 26 def experimental @experimental end |
#file_hash ⇒ Object (readonly)
Returns the value of attribute file_hash.
26 27 28 |
# File 'lib/aidp/metadata/tool_metadata.rb', line 26 def file_hash @file_hash end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
26 27 28 |
# File 'lib/aidp/metadata/tool_metadata.rb', line 26 def id @id end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
26 27 28 |
# File 'lib/aidp/metadata/tool_metadata.rb', line 26 def priority @priority end |
#source_path ⇒ Object (readonly)
Returns the value of attribute source_path.
26 27 28 |
# File 'lib/aidp/metadata/tool_metadata.rb', line 26 def source_path @source_path end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
26 27 28 |
# File 'lib/aidp/metadata/tool_metadata.rb', line 26 def summary @summary end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
26 27 28 |
# File 'lib/aidp/metadata/tool_metadata.rb', line 26 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
26 27 28 |
# File 'lib/aidp/metadata/tool_metadata.rb', line 26 def type @type end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
26 27 28 |
# File 'lib/aidp/metadata/tool_metadata.rb', line 26 def version @version end |
#work_unit_types ⇒ Object (readonly)
Returns the value of attribute work_unit_types.
26 27 28 |
# File 'lib/aidp/metadata/tool_metadata.rb', line 26 def work_unit_types @work_unit_types end |
Instance Method Details
#applies_to?(tags) ⇒ Boolean
Check if this tool applies to given tags
91 92 93 94 95 |
# File 'lib/aidp/metadata/tool_metadata.rb', line 91 def applies_to?() return true if applies_to.empty? = Array().map(&:downcase) applies_to.map(&:downcase).any? { |tag| .include?(tag) } end |
#details ⇒ Hash
Get full details of this tool for display
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/aidp/metadata/tool_metadata.rb', line 125 def details { type: type, id: id, title: title, summary: summary, version: version, applies_to: applies_to, work_unit_types: work_unit_types, priority: priority, capabilities: capabilities, dependencies: dependencies, experimental: experimental, source: source_path, file_hash: file_hash, content_length: content.length } end |
#inspect ⇒ String
Return inspection string
175 176 177 178 |
# File 'lib/aidp/metadata/tool_metadata.rb', line 175 def inspect "#<Aidp::Metadata::ToolMetadata type=#{type} id=#{id} title=\"#{title}\" " \ "version=#{version} source=#{source_path}>" end |
#summary_hash ⇒ Hash
Get a summary of this tool for display
109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/aidp/metadata/tool_metadata.rb', line 109 def summary_hash { type: type, id: id, title: title, summary: summary, version: version, priority: priority, tags: applies_to, experimental: experimental } end |
#supports_work_unit?(type) ⇒ Boolean
Check if this tool supports a given work unit type
101 102 103 104 |
# File 'lib/aidp/metadata/tool_metadata.rb', line 101 def supports_work_unit?(type) return true if work_unit_types.empty? work_unit_types.map(&:downcase).include?(type.to_s.downcase) end |
#to_h ⇒ Hash
Convert to hash for serialization
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/aidp/metadata/tool_metadata.rb', line 147 def to_h { type: type, id: id, title: title, summary: summary, version: version, applies_to: applies_to, work_unit_types: work_unit_types, priority: priority, capabilities: capabilities, dependencies: dependencies, experimental: experimental, source_path: source_path, file_hash: file_hash } end |
#to_s ⇒ String
Return string representation
168 169 170 |
# File 'lib/aidp/metadata/tool_metadata.rb', line 168 def to_s "#{type.capitalize}[#{id}](#{title} v#{version})" end |