Class: Ask::Skills::Skill

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

Overview

A discovered skill with its metadata, instructions, and sibling files.

Skills live in directories following the SKILL.md convention:

rails_debug/
├── SKILL.md          → name, description, tags, instructions
├── references/       → reference documents (loaded on demand)
├── scripts/          → executable helpers
└── assets/           → images, templates, other resources

The siblings hash maps category names to arrays of file paths, relative to the skill's directory. Categories are inferred from sibling directory names (references, scripts, assets) or files.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, description:, instructions:, source:, metadata: {}, siblings: {}) ⇒ Skill

Returns a new instance of Skill.



19
20
21
22
# File 'lib/ask/skills/skill.rb', line 19

def initialize(name:, description:, instructions:, source:, metadata: {}, siblings: {})
  super(name: name, description: description, instructions: instructions,
        source: source, metadata: , siblings: siblings)
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



18
19
20
# File 'lib/ask/skills/skill.rb', line 18

def description
  @description
end

#instructionsObject (readonly)

Returns the value of attribute instructions

Returns:

  • (Object)

    the current value of instructions



18
19
20
# File 'lib/ask/skills/skill.rb', line 18

def instructions
  @instructions
end

#metadataObject (readonly)

Returns the value of attribute metadata

Returns:

  • (Object)

    the current value of metadata



18
19
20
# File 'lib/ask/skills/skill.rb', line 18

def 
  @metadata
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



18
19
20
# File 'lib/ask/skills/skill.rb', line 18

def name
  @name
end

#siblingsObject (readonly)

Returns the value of attribute siblings

Returns:

  • (Object)

    the current value of siblings



18
19
20
# File 'lib/ask/skills/skill.rb', line 18

def siblings
  @siblings
end

#sourceObject (readonly)

Returns the value of attribute source

Returns:

  • (Object)

    the current value of source



18
19
20
# File 'lib/ask/skills/skill.rb', line 18

def source
  @source
end

Instance Method Details

#assetsArray<String>

Asset files bundled with this skill.

Returns:

  • (Array<String>)

    file paths relative to skill directory



47
48
49
# File 'lib/ask/skills/skill.rb', line 47

def assets
  siblings["assets"] || []
end

#referencesArray<String>

Reference documents bundled with this skill.

Returns:

  • (Array<String>)

    file paths relative to skill directory



35
36
37
# File 'lib/ask/skills/skill.rb', line 35

def references
  siblings["references"] || []
end

#scriptsArray<String>

Executable scripts bundled with this skill.

Returns:

  • (Array<String>)

    file paths relative to skill directory



41
42
43
# File 'lib/ask/skills/skill.rb', line 41

def scripts
  siblings["scripts"] || []
end

#tagsArray<String>

Comma-separated tags from frontmatter.

Returns:

  • (Array<String>)


53
54
55
56
# File 'lib/ask/skills/skill.rb', line 53

def tags
  raw = ["tags"] || [:tags] || ""
  raw.split(",").map(&:strip).reject(&:empty?)
end

#to_prompt_entryObject



28
29
30
31
# File 'lib/ask/skills/skill.rb', line 28

def to_prompt_entry
  line = "- **#{name}**: #{description}"
  line
end

#to_sObject



24
25
26
# File 'lib/ask/skills/skill.rb', line 24

def to_s
  "#{name}: #{description}"
end