task icon Task

Generate Mermaid Diagram

Requirements
Description of what to visualize OR raw Mermaid syntax. Optional: diagram type preference (flowchart, sequence, class, etc.), title for the diagram.
2

Help the user create their diagram. If they provided a description, choose the most appropriate diagram type and craft the Mermaid syntax. If they provided raw Mermaid code, validate it looks correct. Common choices: flowchart for processes, sequence for interactions, class for OOP design, state for lifecycles, erDiagram for databases, gantt for timelines, pie for proportions, mindmap for brainstorming.

3

Review the Mermaid syntax before rendering. Check for common issues: no spaces in node IDs, special characters in labels are quoted, no reserved words as IDs. Show the user the diagram code and confirm before rendering.

5

Tell the user where the diagram was saved. Offer to make adjustments (add nodes, change layout direction, apply different styling) or create a different type of diagram for the same concept.

                    To run this task you must have the following required information:

> Description of what to visualize OR raw Mermaid syntax. Optional: diagram type preference (flowchart, sequence, class, etc.), title for the diagram.

If you don't have all of this information, exit here and respond asking for any extra information you require, and instructions to run this task again with ALL required information.

---

You MUST use a todo list to complete these steps in order. Never move on to one step if you haven't completed the previous step. If you have multiple read steps in a row, read them all at once (in parallel).

Add all steps to your todo list now and begin executing.

## Steps

1. [Read Mermaid Diagram Syntax Guide]: Read the documentation in: `./skills/sauna/[skill_id]/references/media.mermaid.guide.md` (Reference for Mermaid syntax across all diagram types)

2. Help the user create their diagram. If they provided a description, choose the most appropriate diagram type and craft the Mermaid syntax. If they provided raw Mermaid code, validate it looks correct. Common choices: flowchart for processes, sequence for interactions, class for OOP design, state for lifecycles, erDiagram for databases, gantt for timelines, pie for proportions, mindmap for brainstorming.

3. Review the Mermaid syntax before rendering. Check for common issues: no spaces in node IDs, special characters in labels are quoted, no reserved words as IDs. Show the user the diagram code and confirm before rendering.

4. [Gather Arguments: Render Mermaid Diagram] The next step has the following requirements for arguments, do not proceed until you have all the required information:
- `mermaidCode`: the complete Mermaid diagram syntax
- `title`: descriptive title for the diagram (used in filename)
- `outputDir`: ./documents/diagrams/**/*

5. [Run Code: Render Mermaid Diagram]: Call `run_script` with:

```json
{
  "file": {
    "path": https://sk.ills.app/code/media.mermaid.render/preview,
    "args": [
      "mermaidCode",
      "title",
      "outputDir"
    ]
  },
  "packages": null
}
```

6. Tell the user where the diagram was saved. Offer to make adjustments (add nodes, change layout direction, apply different styling) or create a different type of diagram for the same concept.