Class: Agents::Definition
- Inherits:
-
Object
- Object
- Agents::Definition
- Defined in:
- lib/agents/definition.rb
Overview
A named sub-agent parsed from a Markdown definition file. YAML frontmatter holds metadata; the Markdown body is the system prompt.
Instance Attribute Summary collapse
-
#color ⇒ String?
readonly
TUI display color (reserved for future use).
-
#description ⇒ String
readonly
Description shown to the LLM in the tool catalog.
-
#max_turns ⇒ Integer?
readonly
Maximum conversation turns (reserved for future use).
-
#model ⇒ String?
readonly
LLM model override (reserved for future use).
-
#name ⇒ String
readonly
Unique agent identifier used in spawn_specialist(name: “…”).
-
#prompt ⇒ String
readonly
System prompt (Markdown body of the definition file).
-
#source_path ⇒ String
readonly
File path this definition was loaded from.
-
#tools ⇒ Array<String>
readonly
Tool names available to this agent.
Class Method Summary collapse
-
.from_file(path) ⇒ Definition
Parses a Markdown file with YAML frontmatter into a Definition.
Instance Method Summary collapse
-
#initialize(name:, description:, tools:, prompt:, model: nil, color: nil, max_turns: nil, source_path: "") ⇒ Definition
constructor
A new instance of Definition.
Constructor Details
#initialize(name:, description:, tools:, prompt:, model: nil, color: nil, max_turns: nil, source_path: "") ⇒ Definition
Returns a new instance of Definition.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/agents/definition.rb', line 45 def initialize(name:, description:, tools:, prompt:, model: nil, color: nil, max_turns: nil, source_path: "") @name = name @description = description @tools = tools @prompt = prompt @model = model @color = color @max_turns = max_turns @source_path = source_path end |
Instance Attribute Details
#color ⇒ String? (readonly)
Returns TUI display color (reserved for future use).
37 38 39 |
# File 'lib/agents/definition.rb', line 37 def color @color end |
#description ⇒ String (readonly)
Returns description shown to the LLM in the tool catalog.
25 26 27 |
# File 'lib/agents/definition.rb', line 25 def description @description end |
#max_turns ⇒ Integer? (readonly)
Returns maximum conversation turns (reserved for future use).
40 41 42 |
# File 'lib/agents/definition.rb', line 40 def max_turns @max_turns end |
#model ⇒ String? (readonly)
Returns LLM model override (reserved for future use).
34 35 36 |
# File 'lib/agents/definition.rb', line 34 def model @model end |
#name ⇒ String (readonly)
Returns unique agent identifier used in spawn_specialist(name: “…”).
22 23 24 |
# File 'lib/agents/definition.rb', line 22 def name @name end |
#prompt ⇒ String (readonly)
Returns system prompt (Markdown body of the definition file).
31 32 33 |
# File 'lib/agents/definition.rb', line 31 def prompt @prompt end |
#source_path ⇒ String (readonly)
Returns file path this definition was loaded from.
43 44 45 |
# File 'lib/agents/definition.rb', line 43 def source_path @source_path end |
#tools ⇒ Array<String> (readonly)
Returns tool names available to this agent.
28 29 30 |
# File 'lib/agents/definition.rb', line 28 def tools @tools end |
Class Method Details
.from_file(path) ⇒ Definition
Parses a Markdown file with YAML frontmatter into a Definition.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/agents/definition.rb', line 61 def self.from_file(path) content = File.read(path) frontmatter, body = parse_frontmatter(content) validate_required_fields!(frontmatter, path) new( name: frontmatter["name"].to_s.strip, description: frontmatter["description"].to_s.strip, tools: parse_tools(frontmatter["tools"]), prompt: body.strip, model: frontmatter["model"]&.to_s&.strip, color: frontmatter["color"]&.to_s&.strip, max_turns: frontmatter["maxTurns"]&.to_i, source_path: path.to_s ) end |