← All procedures

program.diagram

Draw a program as a Mermaid flowchart: the order of the calls, the control flow and the names

MCPCLI
Package
@procedures/compiler · README
Path
["program","diagram"]
CLI
mark program diagram --program <any>
MCP tool
program.diagram on the dev-tools server
As data
{"$proc":["program","diagram"],"input":{}}
Tags
compiler, raw-input

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/compiler/register"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["program","diagram"], { program: "<program>" });
console.log(JSON.stringify(result));

From the command line

$ mark program diagram --program <any>

As data, in a program

{ "$proc": ["program", "diagram"], "input": { "program": "<program>" } }

Input

FieldTypeRequiredDefaultDescription
programanyyesThe program: a call ({ $proc, input }). The procedure reads it as data: nothing in it starts.
mode"exec" | "body"noexec (the default): the program runs as client.exec runs it. body: as the body of a defined procedure, with input in scope.
direction"TD" | "LR"noThe direction of the flowchart: TD (from the top down, the default) or LR (from left to right)

Output

FieldTypeRequiredDefaultDescription
mermaidstringyesThe Mermaid flowchart of the program. A node with an error has the class error.
diagnosticsobject[]yesThe problems that the check found, in the order of the program
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "program": {
        "description": "The program: a call ({ $proc, input }). The procedure reads it as data: nothing in it starts."
      },
      "mode": {
        "description": "exec (the default): the program runs as client.exec runs it. body: as the body of a defined procedure, with input in scope.",
        "type": "string",
        "enum": [
          "exec",
          "body"
        ]
      },
      "direction": {
        "description": "The direction of the flowchart: TD (from the top down, the default) or LR (from left to right)",
        "type": "string",
        "enum": [
          "TD",
          "LR"
        ]
      }
    },
    "required": [
      "program"
    ]
  },
  "output": {
    "type": "object",
    "properties": {
      "mermaid": {
        "type": "string",
        "description": "The Mermaid flowchart of the program. A node with an error has the class error."
      },
      "diagnostics": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "severity": {
              "type": "string",
              "enum": [
                "error",
                "warning",
                "info"
              ],
              "description": "An error stops the program"
            },
            "code": {
              "type": "string",
              "description": "The code of the problem, for example unknown-name"
            },
            "message": {
              "type": "string",
              "description": "The text of the problem"
            },
            "pointer": {
              "type": "string",
              "description": "The JSON pointer of the part of the program"
            }
          },
          "required": [
            "severity",
            "code",
            "message",
            "pointer"
          ],
          "additionalProperties": false
        },
        "description": "The problems that the check found, in the order of the program"
      }
    },
    "required": [
      "mermaid",
      "diagnostics"
    ],
    "additionalProperties": false
  }
}