dsh-diagram: Rendering Diagrams and Screenshots Directly in DSH Responses

Introduction

The output of DeepSeek Harness (DSH) is text, but some explanations are better conveyed through flowcharts, structural comparisons, or page screenshots. Letting the model draw ASCII art on its own often yields unclear results, while taking screenshots requires manual browser interaction and risks missing details. The dsh-diagram plugin, through four tools, renders HTML fragments, web pages, or existing images directly into PNGs and inlines them into the conversation. Rendering uses the Chrome or Edge already installed on the machine, with no dependency on additional services.

Plugin Overview

dsh-diagram is a DSH plugin maintained by LuosuQWQ, categorized as a “web tool.” It provides four tools to DSH: diagram_render, page_screenshot, image_annotate, and diagram_guide, for generating diagrams, screenshots, and annotated images within responses.

Core Features

diagram_render: Render Diagrams from HTML

diagram_render accepts an HTML fragment or document, wraps it in a container with a CJK font stack, a dark or light theme, and utility classes such as .card, .grid, .arrow, .pill, and table, crops to the content height, and outputs a PNG at 2× resolution by default.

page_screenshot: Web Page Screenshots

page_screenshot can capture http(s) URLs, local HTML files, or inline HTML. It supports capturing the entire page or a specific element via a CSS selector, with configurable wait time, viewport size, and scale factor.

image_annotate: Image Annotation

image_annotate overlays annotations on existing images, including rectangles, ellipses, arrows, lines, text labels, highlights, and blur masks. Annotations can use pixel or percentage-based coordinates, and the image can be cropped before annotation.

diagram_guide: Built-in Style Guide

diagram_guide returns theme variables, available class names, and three preset layouts, so that agents can call the tool without guessing the style structure.

Installation & Activation

There are two ways to install dsh-diagram. Method 1: Use the plugin manager to install from a local checkout directory.

plugin_manager: { action: "install_bundle", target: "<path-to-checkout>" }

Method 2: Add via the command line to a specified profile.

dsh plugin --profile <profile> add @luosuqwq/dsh-diagram

After installation, restart DSH. The tools will be registered when the service starts. To uninstall, use plugin_manager: { action: "remove_bundle", target: "dsh-diagram" } and remove the plugin from the configuration.

Usage Examples

diagram_render Example

{
  "title": "Request path",
  "subtitle": "client → cache → origin",
  "theme": "dark",
  "html": "<div class=\"grid\"><div class=\"card\"><h3>Client</h3><p>sends a request</p></div><div class=\"arrow\">→</div><div class=\"card\"><h3>Cache</h3><p>answers on a hit</p></div><div class=\"arrow\">→</div><div class=\"card\"><h3>Origin</h3><p>handles a miss</p></div></div>"
}

The markdown returned by diagram_render is ![alt](<percent-encoded absolute path>), which can be pasted directly to display the image in the response. The rendered result is also saved as a file, located by default under .dsh/diagram/ in the session working directory.

image_annotate Example

Annotation operations are specified via the ops array, where each shape includes its coordinates, style, and an optional label. For example:

{
  "image": "path/to/image.png",
  "ops": [
    {
      "type": "box",
      "x": 100,
      "y": 200,
      "width": 150,
      "height": 100,
      "label": "Focus"
    },
    {
      "type": "arrow",
      "x": 250,
      "y": 250,
      "x2": 300,
      "y2": 200,
      "label": "Gaze guide"
    }
  ],
  "scale": 2
}

Setting unit to "percent" makes coordinates relative to the image’s width and height.

Configuration & Dependencies

The plugin requires DeepSeek Harness 0.2.x (tested version 0.2.2-rc.5) and Node.js 21 or later. Rendering requires Chrome, Edge, or Chromium; the plugin automatically probes common installation paths. If not found, set the environment variable DSH_DIAGRAM_BROWSER to specify the browser executable path. CJK labels require CJK fonts available on the system (e.g., Microsoft YaHei on Windows, PingFang on macOS, Noto Sans CJK on Linux).

The plugin uses only built-in Node.js modules and the DSH tool API, requires no additional npm packages, and runs within the DSH service process.

Use Cases & Considerations

Suitable for developers and agent workers who need to embed flowcharts, structural diagrams, page screenshots, or annotated images directly into responses. The plugin runs with the permissions of the current DSH process; review the source code and license before installing. All rendered results are saved to disk as PNG files and are also accessible via the plugin’s own route.

Conclusion

dsh-diagram enables DSH to include high-quality diagrams and screenshots directly in its text output, reducing reliance on ASCII art and manual screenshots. See the links below for the plugin directory and GitHub repository.

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

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

Xiaoye