dsh-diagram
Manifest validRenders mermaid code blocks in the chat as diagrams in place (flowchart, sequence, class, state, ER, gantt, pie), with zoom, source toggle, copy PNG and SVG download.
dsh-diagram
DSH 图表插件:让 DSH 在审查代码、分析架构时直接在回复里写 mermaid 代码块,Web 界面将其原位渲染成示意图(流程图 / 时序图 / 类图 / 状态图 / ER 图 / 甘特图 / 饼图),辅助理解。
工作方式
- Agent 侧:宿主半边向每个 agent 的系统提示词注入「画图规范」——审查代码 / 梳理调用链 / 解释数据流与请求时序时,主动用
```mermaid代码块画图,并约束纵向单列布局保证可读性。 - 浏览器侧:client 半边用 MutationObserver 扫描聊天里的
.md-code-block代码块,块首行匹配flowchart/graph/sequenceDiagram/classDiagram/stateDiagram/erDiagram/gantt/pie的,在源码稳定 700ms 后渲染成 SVG 原位替换;工具条支持 放大(拖拽平移、双击复位)⇄ 查看源码切换 / 复制源码 / 复制 PNG(2x,剪贴板失败退化为下载) / 下载 SVG。 - mermaid 运行时:不打包进 client.js(体积 ~3.5MB),由宿主路由
/dsh-diagram/mermaid.min.js从插件依赖树内按需分发,首次遇到 mermaid 块时<script>加载,本地闭环不走 CDN。 - 渲染失败不吞内容:保留源码并显示错误条,模型可自行修正语法;跟随界面明暗主题;flowchart 使用纯 SVG 文本标签(
htmlLabels:false)保证 PNG 导出可靠。
安装
dsh plugin --profile web add github:zhangTELL/dsh-diagram
# 重启 dsh web / DSH Desktop 后生效
从源码构建:
git clone https://github.com/zhangTELL/dsh-diagram.git
cd dsh-diagram
pnpm install
pnpm build
dsh plugin --profile web add link:"$PWD"
结构
src/index.ts 宿主:systemPrompt 公告 + mermaid.min.js 路由
src/client/index.ts 浏览器:代码块扫描 / 渲染 / 工具条 / 主题 / 放大弹层
src/client/SettingsSection.tsx 应用设置「图表」分区(介绍 + 自动渲染开关)
src/client/prefs.ts 浏览器侧偏好(自动渲染开关,localStorage)
lib/ tsdown 产物(index.js 宿主 / client.js 浏览器闭包)
应用「设置 → 图表」栏目提供插件介绍、支持的图型说明和「自动渲染聊天中的 mermaid 代码块」开关(关闭后新消息的 mermaid 块保持源码显示)。
其他 mermaid 图型(mindmap / timeline 等)当前不支持渲染,只显示源码;如需扩展,把图型关键字加进 src/client/index.ts 的 SUBSET_RE 并同步更新宿主公告。
Comments
Loading…
Similar plugins
by shinelon
Render mermaid code blocks in DSH chat as diagrams - 在 DSH 聊天中将 mermaid 代码块渲染为图形
★ 0
MIT
JavaScript
Sep 28, 2026
dsh plugin --profile web add @local/mermaid-chatby baconbao
Preview Mermaid diagrams as images via local rendering in DSH Web when the chat message contains a Mermaid fenced code block, and also allow integration with external rendering servers.
★ 4
MIT
JavaScript
Oct 3, 2026
dsh plugin --profile web add @baconbao/dsh-mermaid-image-previewMermaid diagram renderer for the Web UI conversation: renders mermaid code blocks into interactive cards (zoom, fit-width, fullscreen viewer, preview/code toggle) with official UI primitives, and keep
★ 0
↓ 204/wk
dsh plugin --profile web add dsh-mermaid-renderby XiaoBinGan
Render settled ```mermaid fences in the dsh Web GUI chat as SVG diagrams — hardened output, source toggle, and a code-block fallback that never loses the source.
★ 0
MIT
JavaScript
Sep 23, 2026
dsh plugin --profile web add dsh-mermaid-fenceby AKS1st
在 DSH Web 会话中把 Mermaid 代码围栏渲染为 SVG 图表 | Render Mermaid code fences as SVG diagrams in DSH Web messages
★ 9
↓ 1.1k/wk
MIT
TypeScript
Aug 18, 2026
dsh plugin --profile web add dsh-mermaidby gitByteFree
Renders mermaid fences in dsh web chat as SVG diagrams by default, with cursor-anchored smooth zoom and pan, a per-fence diagram/code toggle persisted in localStorage, dark-mode follow, and a bundled
★ 0
↓ 84/wk
MIT
JavaScript
Aug 31, 2026
dsh plugin --profile web add dsh-mermaid-smooth