diagram

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderASCII

func RenderASCII(model *DiagramModel) string

RenderASCII renders a DiagramModel as a text-based ASCII diagram. It uses a level-based layout with box-drawing characters.

func RenderASCIIAuto

func RenderASCIIAuto(model *DiagramModel, binDir string) string

RenderASCIIAuto tries to render using the mermaid-ascii CLI binary if available, falling back to the hand-rolled RenderASCII renderer.

func RenderASCIIViaCLI

func RenderASCIIViaCLI(model *DiagramModel, binPath string) (string, error)

RenderASCIIViaCLI pipes simplified Mermaid syntax through the mermaid-ascii binary.

func RenderImage

func RenderImage(model *DiagramModel) ([]byte, error)

RenderImage renders a DiagramModel as a PNG image using graphviz. Returns the PNG bytes.

func RenderMermaid

func RenderMermaid(model *DiagramModel) string

RenderMermaid renders a DiagramModel as a Mermaid flowchart string.

func RenderMermaidForCLI

func RenderMermaidForCLI(model *DiagramModel) string

RenderMermaidForCLI generates simplified Mermaid syntax compatible with the mermaid-ascii CLI tool. Unlike RenderMermaid, this avoids node declarations with ["label"] syntax (which mermaid-ascii cannot parse) and instead embeds status information directly in edge-referenced node IDs. Subgraphs (condition branches, parallel branches, loop bodies) are flattened into top-level edges since mermaid-ascii silently ignores subgraph blocks.

Types

type DiagramModel

type DiagramModel struct {
	Title  string
	Nodes  []*Node
	Edges  []Edge
	Levels [][]string
}

DiagramModel is the intermediate representation used by all renderers.

func Build

func Build(def *schema.WorkflowDefinition, states []*store.StepState) (*DiagramModel, error)

Build constructs a DiagramModel from a WorkflowDefinition and optional step states. It uses engine.ParseDAG for topology and maps each step to a Node with the appropriate kind. Flow control steps get SubGraph children.

type Edge

type Edge struct {
	From  string
	To    string
	Label string
}

Edge represents a dependency between two nodes.

type Node

type Node struct {
	ID       string
	Label    string
	Kind     NodeKind
	Status   *StatusOverlay
	Children []*SubGraph // condition branches, parallel branches, loop body
}

Node represents a single step in the diagram.

type NodeKind

type NodeKind string

NodeKind classifies a diagram node by its workflow step type.

const (
	NodeKindAction    NodeKind = "action"
	NodeKindCondition NodeKind = "condition"
	NodeKindReasoning NodeKind = "reasoning"
	NodeKindParallel  NodeKind = "parallel"
	NodeKindLoop      NodeKind = "loop"
	NodeKindWait      NodeKind = "wait"
	NodeKindStart     NodeKind = "start"
	NodeKindEnd       NodeKind = "end"
)

type StatusOverlay

type StatusOverlay struct {
	Status     string // from schema.StepStatus
	DurationMs int64
	RetryCount int
	Error      string
}

StatusOverlay carries runtime state for a node.

type SubGraph

type SubGraph struct {
	Label string
	Nodes []*Node
	Edges []Edge
}

SubGraph holds nested steps for flow control nodes (condition, parallel, loop).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL