workgraph-visualization

    Runtime-independent workgraph visualization

    graph
    mermaid
    moonbit
    visualization
    Download zip
    Author
    Version
    0.2.0
    License
    MIT
    Last updated
    3 hours ago
    Downloads
    50

    #moonbit: import: - path: moonbitlang/async@0.21.0 alias: async - path: totto2727/workgraph-core@0.1.4 alias: core - path: totto2727/workgraph-visualization@0.1.4 alias: renderer backend: native

    #workgraph-visualization

    workgraph-visualization owns deterministic Mermaid rendering for callback-free workgraph-core compiled graph snapshots. For shared installation and graph construction, see the root Setup and Usage.

    #Usage

    Render a compiled graph and observe a Mermaid flowchart:

    ///|
    test "workgraph-visualization Mermaid usage" {
    let entry = @core.NodeId::NodeId("render")
    let definition = @core.GraphDefinition::GraphDefinition(
    @core.Reducer::Reducer(fn(state : Int, _patch : Unit) { state }),
    )
    definition.add_node(
    @core.Node::Node(
    entry,
    @core.NodeMetadata::NodeMetadata(
    name="Render",
    description=None,
    kind=@core.Function,
    tags=[],
    ),
    async fn(_context, _state) {
    @async.pause()
    @core.NodeOutput::NodeOutput(None, None)
    },
    ),
    )
    definition.set_router(
    entry,
    @core.router([], fn(_state, _completion) { @core.End }),
    )
    definition.set_entry(entry)
    inspect(
    @renderer.to_mermaid(definition.compile()).has_prefix("flowchart TD"),
    content="true",
    )
    }

    The checked visualization example renders a routed multi-step workflow with labeled branches.

    #API

    This README was generated from the share-artifact skill and README template.

    to_mermaid

    fn[S, P] to_mermaid(graph :
    CompiledGraph
    [S, P]) -> String

    Renders a compiled graph as a deterministic Mermaid flowchart.

    Node and router descriptions and declared route labels come from core metadata. Routers with multiple declared destinations or descriptions are rendered as decision diamonds. Runtime-only conditions, End, and Fail outcomes are not inferred.

    Source Files