Class: Workflows::Definition

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

Examples:

Workflow file format

---
name: feature
description: "Implement a GitHub issue end-to-end."
---

## Context
Create and complete a new feature...

Constant Summary collapse

NAME_FORMAT =
/\A[a-z0-9][a-z0-9_-]*\z/

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#contentString (readonly)

Returns workflow content (Markdown body) — free-form instructions.

Returns:

  • (String)

    workflow content (Markdown body) — free-form instructions



32
33
34
# File 'lib/workflows/definition.rb', line 32

def content
  @content
end

#descriptionString (readonly)

Returns description shown to the analytical brain for relevance matching.

Returns:

  • (String)

    description shown to the analytical brain for relevance matching



29
30
31
# File 'lib/workflows/definition.rb', line 29

def description
  @description
end

#nameString (readonly)

Returns unique workflow identifier used in read_workflow(name: “…”).

Returns:

  • (String)

    unique workflow identifier used in read_workflow(name: “…”)



26
27
28
# File 'lib/workflows/definition.rb', line 26

def name
  @name
end

#source_pathString (readonly)

Returns file path this definition was loaded from.

Returns:

  • (String)

    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.

Parameters:

  • path (String, Pathname)

    path to the .md file

Returns:

Raises:



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