Class: Silas::Skill

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

Overview

A flat markdown playbook with a description: frontmatter key — the description is advertised to the model; the body loads on demand via the load_skill tool (eve's progressive-disclosure mechanism).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



5
6
7
# File 'lib/silas/skill.rb', line 5

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



5
6
7
# File 'lib/silas/skill.rb', line 5

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



5
6
7
# File 'lib/silas/skill.rb', line 5

def path
  @path
end

Class Method Details

.parse(path) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/silas/skill.rb', line 6

def self.parse(path)
  content = File.read(path)
  description =
    if content =~ /\A---\s*\n(.*?)\n---\s*\n/m
      Regexp.last_match(1)[/^description:\s*(.+)$/, 1].to_s.strip
    else
      ""
    end
  new(name: File.basename(path, ".md"), description: description, path: path.to_s)
end

Instance Method Details

#bodyObject



17
18
19
# File 'lib/silas/skill.rb', line 17

def body
  File.read(path).sub(/\A---\s*\n.*?\n---\s*\n/m, "")
end