Introduction¶
DeepSeek Harness (DSH) adopts an “everything is a plugin” architecture. In the default DSH environment, the model can only output Mermaid source code, and users cannot directly see rendered diagrams. The sijidoubi/dsh-plugin-mermaid plugin resolves this issue by providing the built-in mermaid_render tool. It can directly render Mermaid source code to SVG within the process, without relying on a browser or external network access.
Features¶
This plugin provides the mermaid_render tool, which completes rendering in-process based on mermaid 11 and jsdom.
- Output formats: Supports returning SVG text, a DataUri, and an absolute URL hosted by a Web server.
- Diagram types: Supports multiple types, including flowchart, sequenceDiagram, classDiagram, pie, stateDiagram, erDiagram, and more.
- Error handling: When rendering fails, the tool returns with
isError, including parsing error information.
Installation¶
After installing the plugin, the model can invoke the rendering tool.
dsh plugin --profile web add github:sijidoubi/dsh-plugin-mermaid
dsh web
Configuration¶
The following configuration is enabled by default and can be overridden via cordis.patch.yml:
- insert:
- id: tool-mermaid
name: dsh-tool-mermaid
config:
theme: default # default | dark | neutral | forest
securityLevel: strict # strict(默认,消毒标签内 HTML) | loose(原样渲染)
Usage¶
The tool name is mermaid_render, and the parameters are as follows:
code(string, required): Mermaid diagram source code.title(string, optional): The title of the diagram.
Return value:
{
"format": "svg",
"title": "可选标题",
"svg": "<svg ...>...</svg>",
"width": 127,
"height": 77,
"url": "http://127.0.0.1:3080/dsh-mermaid/m1.svg",
"dataUri": "data:image/svg+xml;base64,..."
}
url: The address hosted by the Web server (the Web chat interface preferentially displays this address).dataUri: The fallback when no Web server is available.width/height: The pixel values from the final viewBox.
Limitations and Notes¶
- Some diagrams are not supported: Diagram types that rely on browser interaction or Canvas are not supported (such as some mindmap/gantt diagrams).
- URL lifetime: The
urlis a temporary address based on an in-memory cache. After DSH restarts, old URLs return 404 and require re-rendering. - Process side effects: On the first render, the plugin installs jsdom global objects (such as window/document) in the host Node process.
- Width estimation: Width is estimated using a per-character width model and may differ slightly from actual browser rendering under extreme fonts.
Conclusion¶
This plugin provides native Mermaid rendering capabilities for the DSH environment, allowing the model to directly generate SVG images that can be embedded in responses. Source code and catalog links are listed below.
- Repository: https://github.com/sijidoubi/dsh-plugin-mermaid
- Catalog: https://www.skillhub.cn/plugins/sijidoubi/dsh-plugin-mermaid