dsh-mermaid-diagram: Mermaid Diagram Rendering Plugin for DeepSeek Harness

Introduction

The core design philosophy of DeepSeek Harness (DSH) is “everything is a plugin.” When developing model-based agents or workflows, it is a common requirement to have the model directly generate diagrams (such as flowcharts, sequence diagrams). Traditional approaches typically rely on the model outputting Markdown code blocks, which then need to be manually parsed and rendered by the user or scripts, increasing interaction overhead and lacking immediacy.

butterhost69/dsh-mermaid-diagram is a DSH plugin that provides the model with a tool named mermaid and is responsible for rendering the diagrams generated by the model as interactive cards in the Web UI. This plugin solves the problem of models outputting text-based diagram code that is difficult to preview in real-time by directly displaying diagrams in the conversation flow.

Core Features

The plugin primarily provides the following capabilities:

  1. Model Tool Integration: Provides the mermaid tool to the model. This tool accepts a source parameter (diagram source code) and an optional title parameter.
  2. All Diagram Type Support: Supports rendering various diagram types supported by Mermaid, including flowcharts, sequence diagrams, class diagrams, state diagrams, ER diagrams, Gantt charts, pie charts, etc.
  3. Theme Awareness and Adaptation: Diagram rendering automatically adapts to the host Web UI’s light/dark theme. When the theme switches, cards automatically re-render to match the new theme.
  4. Streaming Processing: Displays progress during streaming output and renders once the parameters are fully received.
  5. Session Replay: Diagram cards are part of session events, can be derived from logs, and support replay after page refresh or pagination.
  6. Error Handling: If rendering fails, the card automatically degrades to show the source code view with an error prompt, instead of displaying a broken card.
  7. Localization Support: Card text supports English and Simplified Chinese, following the host language settings.
  8. Local Execution: The plugin has a built-in Mermaid runtime, does not depend on external CDNs, and serves resources from the plugin’s own routes.
  9. On-Demand Loading: The Mermaid runtime is approximately 3.5 MB and is only loaded when a diagram first appears, without affecting startup speed.

Installation and Activation

Please ensure the environment meets the following requirements before installation:
* DSH Version: 0.2.1-alpha.1 or compatible.
* Node.js: ^22.19 or >=24.
* Runtime Environment: Must use Web configuration (i.e., dsh web), as diagram cards depend on Web interface rendering.

Run the following command to install the plugin:

dsh plugin --profile web add -w github:ButterHost69/dsh-mermaid-diagram

After installation, restart the dsh web service or refresh the browser page.

Typical Usage

Ask the model in the conversation to generate diagrams. The model will call the mermaid tool upon detecting the requirement.

For example, you can input:

Draw a flowchart of a release process.

The model will call this tool, and the result will appear as a card in the conversation flow. This card contains the following interactive features:
* Diagram / Code Toggle: View the rendered SVG diagram or the original source code.
* Copy: Copy the diagram source code to the clipboard in one click.
* Error Fallback: If the source code has errors, it opens the Code view by default and displays an error prompt at the top.

Use Cases and Notes

  • Use Cases: Suitable for developers who need the model to directly generate architecture diagrams, algorithm flowcharts, data models, and similar scenarios.
  • Character Limit: Diagram source code exceeding 50,000 characters will be blocked by the tool and not sent to the browser (to prevent performance issues caused by synchronous parsing).
  • Rendering Security: Cards are rendered using Mermaid’s strict security level, and labels are automatically sanitized.
  • Interaction Limit: Very tall diagrams will scroll within the card instead of expanding the entire conversation history.

Summary

dsh-mermaid-diagram provides the model with direct drawing capabilities by standardizing the integration of the mermaid tool into the DSH ecosystem. It solves the problem of instant conversion from text code to visualization and enhances the interaction experience with streaming output and theme adaptation features.

View Catalog Page
View Source Code

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye