Class: Workflows::Definition
- Inherits:
-
Object
- Object
- Workflows::Definition
- Defined in:
- lib/workflows/definition.rb
Overview
A workflow parsed from a Markdown definition file. YAML frontmatter holds metadata; the Markdown body contains free-form instructions that the analytical brain reads and converts into goals.
Workflows are operational recipes — they describe WHAT to do step by step. The analytical brain uses judgment to decompose workflow prose into tracked goals based on the user’s specific context.
Constant Summary collapse
- NAME_FORMAT =
/\A[a-z0-9][a-z0-9_-]*\z/
Instance Attribute Summary collapse
-
#content ⇒ String
readonly
Workflow content (Markdown body) — free-form instructions.
-
#description ⇒ String
readonly
Description shown to the analytical brain for relevance matching.
-
#name ⇒ String
readonly
Unique workflow identifier used in read_workflow(name: “…”).
-
#source_path ⇒ String
readonly
File path this definition was loaded from.
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:, content:, source_path: "") ⇒ Definition
constructor
A new instance of Definition.
Constructor Details
#initialize(name:, description:, content:, source_path: "") ⇒ Definition
Returns a new instance of Definition.
37 38 39 40 41 42 |
# File 'lib/workflows/definition.rb', line 37 def initialize(name:, description:, content:, source_path: "") @name = name @description = description @content = content @source_path = source_path end |
Instance Attribute Details
#content ⇒ String (readonly)
Returns workflow content (Markdown body) — free-form instructions.
32 33 34 |
# File 'lib/workflows/definition.rb', line 32 def content @content end |
#description ⇒ String (readonly)
Returns description shown to the analytical brain for relevance matching.
29 30 31 |
# File 'lib/workflows/definition.rb', line 29 def description @description end |
#name ⇒ String (readonly)
Returns unique workflow identifier used in read_workflow(name: “…”).
26 27 28 |
# File 'lib/workflows/definition.rb', line 26 def name @name end |
#source_path ⇒ String (readonly)
Returns file path this definition was loaded from.
35 36 37 |
# File 'lib/workflows/definition.rb', line 35 def source_path @source_path end |
Class Method Details
.from_file(path) ⇒ Definition
Parses a Markdown file with YAML frontmatter into a Definition.
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/workflows/definition.rb', line 49 def self.from_file(path) raw = File.read(path) frontmatter, body = parse_frontmatter(raw) validate_required_fields!(frontmatter, path) new( name: frontmatter["name"].to_s.strip, description: frontmatter["description"].to_s.strip, content: body.strip, source_path: path.to_s ) end |