Package com.tnsai.tools.diagram
Class DiagramTools
java.lang.Object
com.tnsai.tools.diagram.DiagramTools
Function-shape diagram tools — Mermaid (rendered via Kroki.io) and
Excalidraw (.excalidraw JSON generator). Replaces the legacy
MermaidTool + ExcalidrawTool.
| Method | Backend | Auth | Idempotent |
|---|---|---|---|
mermaidRender(java.lang.String, java.lang.String, java.lang.String) | Kroki.io public API | none | true |
excalidrawGenerate(java.lang.String, java.lang.String) | pure JDK (offline) | none | true |
The legacy ICraft3DTool (3D architecture diagrams via icraft.design)
is intentionally deferred — its 600+ lines + premium-features split needs
a dedicated batch. Phase 3 will sweep it if not migrated.
- Since:
- 0.5.7 (Phase 2 batch 21a — built-in tool migration to function shape, see #188)
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor — Mermaid + Excalidraw both auth-free.DiagramTools(okhttp3.OkHttpClient http, com.fasterxml.jackson.databind.ObjectMapper mapper) Full constructor for tests / shared HTTP. -
Method Summary
Modifier and TypeMethodDescriptionexcalidrawGenerate(String spec, String outputPath) mermaidRender(String code, String format, String outputPath)
-
Constructor Details
-
DiagramTools
public DiagramTools()Default constructor — Mermaid + Excalidraw both auth-free. -
DiagramTools
public DiagramTools(okhttp3.OkHttpClient http, com.fasterxml.jackson.databind.ObjectMapper mapper) Full constructor for tests / shared HTTP.
-
-
Method Details
-
mermaidRender
@Tool(name="mermaid_render", description="Render a Mermaid diagram (flowchart / sequence / class / state / ER / gantt / pie / mindmap \u2026) to SVG or PNG via Kroki.io\'s public API. {format} is \"svg\" (default) or \"png\". Optional {outputPath} writes the binary to disk and returns the absolute path; otherwise returns the rendered content as base64. No API key required.", keywords={"mermaid","diagram","flowchart","sequence","render"}, idempotent=true) public String mermaidRender(@ToolParam(description="Mermaid source code") String code, @ToolParam(description="Output format: svg (default) or png",required=false,defaultValue="svg") String format, @ToolParam(description="Optional file path to write the rendered diagram",required=false,defaultValue="") String outputPath) throws IOException - Throws:
IOException
-
excalidrawGenerate
@Tool(name="excalidraw_generate", description="Generate an Excalidraw JSON file from a pipe-separated {spec} of shapes + arrows. Each element is \"shape:label\" (shape \u2208 {box, ellipse, diamond}) or \"arrow:From->To\". Example: \"box:Agent|box:Tool|arrow:Agent->Tool\". {outputPath} writes the .excalidraw JSON to disk and returns its absolute path. Pure-JDK; no API key, no network call.", keywords={"excalidraw","diagram","boxes","arrows","json"}, idempotent=true) public String excalidrawGenerate(@ToolParam(description="Pipe-separated diagram spec (e.g. \"box:A|box:B|arrow:A->B\")") String spec, @ToolParam(description="Output file path (.excalidraw JSON)") String outputPath) throws IOException - Throws:
IOException
-