npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dsh-web-mermaid

v0.1.1

Published

DeepSeek Harness (DSH) Web 插件:把聊天 Markdown 中的 ```mermaid 围栏代码块离线渲染为 Mermaid 图表(SVG)。mermaid 运行时随插件内置,不依赖任何在线 CDN。

Downloads

259

Readme

dsh-web-mermaid

npm version License GitHub

DeepSeek Harness(DSH)Web 插件:把聊天 Markdown 中的 ```mermaid 围栏代码块自动渲染为 Mermaid 图表(SVG)。

  • npm:[email protected](https://www.npmjs.com/package/dsh-web-mermaid)
  • GitHub:https://github.com/vtxf/dsh-web-mermaid

完全离线:mermaid 运行时(vendor/mermaid.min.js,v11.16.1)随插件内置,由插件 Host 半通过同源路由提供,不依赖任何在线 CDN。

特性

  • 助手回复中的 mermaid 围栏块在消息结束后自动渲染为可交互 SVG 图表(流式期间不渲染半截图);
  • 渲染失败(语法错误 / 资源缺失)时保留原始代码块,显示错误信息与「重试」按钮,复制按钮不受影响;语法错误不会被渲染成无法关闭的错误 SVG;
  • 深浅色主题切换时已渲染图表跟随新主题自动重渲染;
  • 零改动 DSH 核心源码,纯插件方式运行;
  • 若在页面加载前执行 window.__DSH_MERMAID_ASSET__ = '…',可覆盖 mermaid 资源地址(默认同源路由)。

工作原理

DSH 的 MarkdownText 把围栏代码块渲染为 <div class="md-code-block">(banner 里显示语言名,代码体为 <pre><code>;shiki 语言表不含 mermaid,因此 mermaid 块恒为纯文本代码体)。本插件在浏览器端用 MutationObserver 扫描 .md-code-block,判定语言名为 mermaid 后,用 mermaid.render 把代码体替换为 SVG 容器(保留 banner 与复制按钮),并对主题切换做重渲染。

维护提示:.md-code-block 结构来自 @deepseek-ai/dsh-client-ui-primitives 的 CodeBlock 组件;若 DSH 大版本升级改变该 DOM,本插件有文本回退判定(banner 文本 = mermaid),一般仍可工作,但建议升级后顺手验证。

安装(一条命令)

插件按 DSH 官方 bundle 机制打包(manifest 声明 dsh.bundle.patch,包内自带 cordis.patch.yml),用 DSH 自带的插件命令一键安装:

# 从 npm 安装(推荐):
dsh plugin --profile web add dsh-web-mermaid

# 备选:从 GitHub 或本地目录安装:
dsh plugin --profile web add "github:vtxf/dsh-web-mermaid"
dsh plugin --profile web add "file:/path/to/dsh-web-mermaid"

# 卸载:
dsh plugin --profile web remove dsh-web-mermaid

安装或卸载后重启 dsh web 即可。

原理:dsh plugin 转发 pnpm 安装依赖,并自动把声明了 dsh.bundle.patch 的包加入 profile 的 dsh.profile.bundles 层;包内 cordis.patch.yml 即该层的 patch,随包自动注册插件行(- insert: [{ id: dsh-web-mermaid, name: dsh-web-mermaid }])。无需 junction、无需手改任何配置文件。

手动兜底(不使用 dsh plugin 时):把插件装进 profile 的 node_modules,并在 $DSH_HOME/profiles/web/cordis.patch.yml 追加 - insert: [{ id: dsh-web-mermaid, name: dsh-web-mermaid }](见 cordis.patch.example.yml)。

使用

无需任何操作:在对话中让助手输出 ```mermaid 围栏块,消息结束后自动变成图表。例如:

```mermaid
graph TD
  A[开始] --> B{判断}
  B -->|是| C[继续]
  B -->|否| D[结束]
```

目录结构

dsh-web-mermaid/
├── package.json                  # npm 包声明(dsh.bundle + dsh.client + exports["./client"])
├── index.js                      # Host 半:注册 /plugin-assets/dsh-web-mermaid/mermaid.min.js 路由
├── client.js                     # 浏览器半:渲染核心 + __ModuleLoader__.load 包装
├── cordis.patch.yml              # bundle patch:随 dsh plugin add 自动注册插件行
├── cordis.patch.example.yml      # 手动安装兜底示例
├── vendor/
│   ├── mermaid.min.js            # [email protected] UMD(离线内置)
│   ├── LICENSE                   # mermaid MIT 许可
│   └── SOURCE.md                 # 来源与升级记录
├── CHANGELOG.md                  # 版本历史
└── prototype/                    # 本地开发存档(.gitignore 排除,不随包发布)

已知限制

  • 用户消息不渲染:DSH 用户消息是纯文本(非 Markdown),mermaid 只在助手消息中生效(DSH 现状,非本插件缺陷);
  • 流式期间不渲染:mermaid 块在消息结束后才出现图表(避免半截图);
  • 离线指 mermaid 运行时:图表内容若引用外部图片/链接仍由内容本身决定;
  • 首图渲染需先加载内置的 mermaid.min.js(约 3.4MB,之后浏览器缓存)。

开发与发布

  • 修改核心逻辑后:同步更新 client.js 与 prototype/dynamic-client-half.js(两者同源;prototype 仅本地存档,不发布);
  • 升级 mermaid:见 vendor/SOURCE.md;
  • 变更记录:更新 CHANGELOG.md;
  • 发布 npm:npm publish --registry https://registry.npmjs.org(无 TOTP 账号走浏览器 Passkey 认证,需在交互终端执行);
  • 保持 package.json 的 name: dsh-web-mermaid 不变(client 模块系统按包名关联 bundle id)。

版本历史

见 CHANGELOG.md。

许可

插件本体 MIT(见 LICENSE);内置 mermaid 为 MIT(见 vendor/LICENSE)。