Class: Aidp::Metadata::ToolMetadata

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

Examples:

Creating tool metadata

 = .new(
  type: "skill",
  id: "ruby_rspec_tdd",
  title: "Ruby RSpec TDD Implementer",
  summary: "Expert in Test-Driven Development",
  version: "1.0.0",
  applies_to: ["ruby", "testing"],
  work_unit_types: ["implementation", "testing"],
  priority: 10,
  content: "You are a TDD expert...",
  source_path: "/path/to/SKILL.md"
)

Constant Summary collapse

VALID_TYPES =

Valid tool types

%w[skill persona template].freeze
DEFAULT_PRIORITY =

Default priority (medium)

5

Instance Attribute Summary collapse

Instance Method Summary collapse

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

Parameters:

  • type (String)

    Tool type: “skill”, “persona”, or “template”

  • id (String)

    Unique identifier (lowercase, alphanumeric, underscores)

  • title (String)

    Human-readable title

  • summary (String)

    Brief one-line summary

  • version (String)

    Semantic version (e.g., “1.0.0”)

  • applies_to (Array<String>) (defaults to: [])

    Tags indicating applicability

  • work_unit_types (Array<String>) (defaults to: [])

    Work unit types this tool supports

  • priority (Integer) (defaults to: DEFAULT_PRIORITY)

    Priority for ranking (1-10, default 5)

  • capabilities (Array<String>) (defaults to: [])

    Capabilities provided by this tool

  • dependencies (Array<String>) (defaults to: [])

    IDs of required tools

  • experimental (Boolean) (defaults to: false)

    Whether this is experimental

  • content (String)

    The tool content (markdown)

  • source_path (String)

    Path to source .md file

  • file_hash (String)

    SHA256 hash of source file for cache invalidation



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

#capabilitiesObject (readonly)

Returns the value of attribute capabilities.



26
27
28
# File 'lib/aidp/metadata/tool_metadata.rb', line 26

def capabilities
  @capabilities
end

#contentObject (readonly)

Returns the value of attribute content.



26
27
28
# File 'lib/aidp/metadata/tool_metadata.rb', line 26

def content
  @content
end

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



26
27
28
# File 'lib/aidp/metadata/tool_metadata.rb', line 26

def dependencies
  @dependencies
end

#experimentalObject (readonly)

Returns the value of attribute experimental.



26
27
28
# File 'lib/aidp/metadata/tool_metadata.rb', line 26

def experimental
  @experimental
end

#file_hashObject (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

#idObject (readonly)

Returns the value of attribute id.



26
27
28
# File 'lib/aidp/metadata/tool_metadata.rb', line 26

def id
  @id
end

#priorityObject (readonly)

Returns the value of attribute priority.



26
27
28
# File 'lib/aidp/metadata/tool_metadata.rb', line 26

def priority
  @priority
end

#source_pathObject (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

#summaryObject (readonly)

Returns the value of attribute summary.



26
27
28
# File 'lib/aidp/metadata/tool_metadata.rb', line 26

def summary
  @summary
end

#titleObject (readonly)

Returns the value of attribute title.



26
27
28
# File 'lib/aidp/metadata/tool_metadata.rb', line 26

def title
  @title
end

#typeObject (readonly)

Returns the value of attribute type.



26
27
28
# File 'lib/aidp/metadata/tool_metadata.rb', line 26

def type
  @type
end

#versionObject (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_typesObject (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

Parameters:

  • tags (Array<String>)

    Tags to check against

Returns:

  • (Boolean)

    True if any tag matches applies_to



91
92
93
94
95
# File 'lib/aidp/metadata/tool_metadata.rb', line 91

def applies_to?(tags)
  return true if applies_to.empty?
  tags = Array(tags).map(&:downcase)
  applies_to.map(&:downcase).any? { |tag| tags.include?(tag) }
end

#detailsHash

Get full details of this tool for display

Returns:

  • (Hash)

    Detailed tool information



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

#inspectString

Return inspection string

Returns:

  • (String)

    Detailed inspection



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_hashHash

Get a summary of this tool for display

Returns:

  • (Hash)

    Summary with key metadata



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

Parameters:

  • type (String)

    Work unit type (e.g., “implementation”, “analysis”)

Returns:

  • (Boolean)

    True if type is supported



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_hHash

Convert to hash for serialization

Returns:

  • (Hash)

    Metadata as hash (for JSON)



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_sString

Return string representation

Returns:

  • (String)

    Tool representation



168
169
170
# File 'lib/aidp/metadata/tool_metadata.rb', line 168

def to_s
  "#{type.capitalize}[#{id}](#{title} v#{version})"
end