首页龙虾技能列表 › mermaid-canvas — 技能工具

mermaid-canvas — 技能工具

v1.0.0

[自动翻译] Render Mermaid code into PNG images supporting all 27 Mermaid 11 chart types, with optional upload to Feishu docs, requiring no API keys.

0· 31·0 当前·0 累计
by @xx235300·MIT-0
下载技能包
License
MIT-0
最后更新
2026/4/10
安全扫描
VirusTotal
可疑
查看报告
OpenClaw
可疑
medium confidence
The skill mostly does what it says (render Mermaid to PNG) but has some mismatches and risky runtime choices — notably a claimed Feishu upload with no declared credentials and HTML rendering using remote CDN + 'securityLevel: "loose"' which can execute remote content.
评估建议
This skill appears to be what it claims — it generates PNGs from Mermaid — but proceed with caution. Things to check before installing or using it: - Feishu upload: The skill advertises optional Feishu integration but declares no Feishu credentials. Confirm how upload is implemented in your OpenClaw environment (does it call a platform feishu_doc_media tool that already has credentials?). Do not supply unrelated secrets to this skill; instead verify the platform-level Feishu integration. - Rem...
详细分析 ▾
用途与能力
The skill's code and instructions align with the stated purpose (generate PNGs from Mermaid). However the SKILL.md advertises '飞书集成' (Feishu upload) and 'zero API keys' while the package declares no Feishu credentials; the code mentions feishu_doc_media only in docstrings and the upload functions are unimplemented stubs, so the Feishu integration is not fully specified. Relying on platform-provided Feishu tools (which may carry credentials) is plausible but not declared explicitly, creating a transparency gap.
指令范围
Runtime instructions generate a local HTML that loads mermaid from jsdelivr CDN and ask the agent to use a browser tool to navigate and snapshot that HTML. The HTML sets mermaid.initialize({securityLevel: 'loose'}), which weakens sanitization and can allow embedded HTML/script in diagrams. The fallback uses mermaid.ink (an external API) by base64-encoding the diagram and fetching a PNG. Both behaviors involve sending user diagram content to external endpoints and executing remote JS in the browser context — reasonable for rendering but raises exfiltration/XSS risks if diagrams contain malicious payloads or sensitive data.
安装机制
No install spec — instruction-only plus a helper script. No archives or downloads beyond the runtime loading of external CDN resources (jsdelivr and mermaid.ink) at render time. Low install-time risk.
凭证需求
Skill declares no required environment variables or primary credential. That is coherent for standalone rendering. The claimed Feishu upload is not backed by declared Feishu credentials; it likely expects the agent/platform to provide an existing feishu_doc_media tool or credentials. If the platform does not provide those, Feishu upload won't work; if it does, the skill will gain access to whatever credentials that platform tool exposes. The skill itself does not request unrelated secrets.
持久化与权限
Skill does not request persistent 'always' inclusion or write system-wide config. It writes temporary HTML files to the OS temp directory for rendering, which is expected and proportionate.
安全有层次,运行前请审查代码。

License

MIT-0

可自由使用、修改和再分发,无需署名。

运行时依赖

无特殊依赖

版本

latestv1.0.02026/4/10

Mermaid-canvas v1.0.0 — initial release: - New skill to render Mermaid diagrams as PNG images directly in-browser. - No API key required; works fully client-side. - Supports 27 official diagram types from Mermaid 11 (flowchart, sequence, ER, Gantt, mindmap, etc.). - Integrated with Feishu for direct image uploads to documents. - Auto-detects diagram type based on user prompt for ease of use. - Includes usage examples, supported types table, safe syntax rules, and troubleshooting tips.

● 可疑

安装命令 点击复制

官方npx clawhub@latest install mermaid-canvas
镜像加速npx clawhub@latest install mermaid-canvas --registry https://cn.clawhub-mirror.com

技能文档

Mermaid Canvas:将 Mermaid 代码渲染为图片,用浏览器当画布。
>
版本:v1.0.0
技能名称:mermaid-canvas
触发词:/mermaidmermaid图表画图生成图表

一、什么时候用这个技能

当用户请求以下内容时,使用此技能:

  • "画一个流程图"
  • "生成时序图"
  • "帮我画个架构图"
  • "/mermaid"
  • "mermaid图表"
  • "用 Mermaid 画"
  • 以及任何涉及创建图表(流程图、时序图、甘特图等)的请求

二、核心能力

能力说明
图表渲染将 Mermaid 代码渲染为 PNG 图片
飞书集成直接上传图片到飞书文档
零依赖不需要任何 API Key
27 种图表支持 Mermaid 11 全部图表类型

三、技术方案

渲染流程

1. 接收 Mermaid 代码
  • 生成临时 HTML(含 Mermaid CDN)
  • Browser navigate 到本地 HTML
  • 等待 Mermaid 渲染完成
  • snapshot 截图
  • 保存为 PNG
  • 可选:feishu_doc_media 上传到飞书

HTML 模板




  
  
  


  
    %% Mermaid 代码在这里
    flowchart LR
    A --> B
  

四、支持的图表类型(Mermaid 11 全部 27 种)

类型关键字触发关键词
流程图flowchart流程图、flowchart、流程
时序图sequenceDiagram时序图、sequence、API图
类图classDiagram类图、classDiagram、类
状态图stateDiagram状态图、stateDiagram、状态机
实体关系图erDiagramER图、erDiagram、实体关系
甘特图gantt甘特图、gantt、项目进度
饼图pie饼图、pie、比例
思维导图mindmap思维导图、mindmap、脑图
时间线timeline时间线、timeline
用户旅程journey用户旅程、journey
架构图architecture架构图、architecture、系统架构
Git 图gitGraphgitGraph、Git图
象限图quadrantChart象限图、quadrantChart
XY 图表xyChartxyChart、XY图
需求图requirementDiagram需求图、requirementDiagram
C4 图c4DiagramC4图、C4Diagram
雷达图radar雷达图、radar
桑基图sankey桑基图、sankey、流量图
块图block块图、block
石川图ishikawa石川图、鱼骨图
维恩图venn维恩图、venn
树状图treemap树状图、treemap
Wardley 图wardleywardley图、Wardley
事件建模图eventmodeling事件建模、eventmodeling
看板图kanban看板、kanban
数据包图packet数据包、packet
树视图treeView树视图、treeView

五、图表类型自动判断规则

当用户描述不明确时,按以下规则判断:

用户描述判断类型默认关键字
"画个流程"流程图flowchart TD
"API调用"时序图sequenceDiagram
"项目进度"甘特图gantt
"占比分布"饼图pie
"思路整理"思维导图mindmap
"决策流程"流程图flowchart TD
"系统结构"架构图architecture
"数据库设计"实体关系图erDiagram

六、使用示例

示例 1:流程图

用户请求

画一个用户登录的流程图

生成的 Mermaid 代码

mermaid flowchart TD A["用户打开APP"] --> B{是否已登录} B -->|是| C[进入主页] B -->|否| D[显示登录页] D --> E[输入账号密码] E --> F{验证成功?} F -->|是| C F -->|否| G[提示错误] G --> D

渲染结果:PNG 图片


示例 2:时序图

用户请求

生成一个API调用的时序图

生成的 Mermaid 代码

mermaid sequenceDiagram participant 用户 participant 前端 participant 后端 participant 数据库 用户->>前端: 点击按钮 前端->>后端: POST /api/login 后端->>数据库: 查询用户 数据库-->>后端: 用户数据 后端-->>前端: JWT Token 前端-->>用户: 登录成功


示例 3:甘特图

用户请求

画一个项目甘特图

生成的 Mermaid 代码

mermaid gantt title 项目进度 dateFormat YYYY-MM-DD section 设计 需求分析 :a1, 2024-01-01, 7d 架构设计 :a2, after a1, 5d section 开发 前端开发 :a3, after a2, 14d 后端开发 :a4, after a2, 14d section 测试 集成测试 :a5, after a3 a4, 7d 上线部署 :a6, after a5, 3d


七、安全语法规范

7.1 节点 ID 安全规则

禁用词汇(作为节点 ID):

  • endsubgraphgraphflowchart
  • sequenceDiagramclassDiagramstateDiagram

正确做法

%% 错误 ❌
flowchart
    end --> start

%% 正确 ✅ flowchart EndState --> StartState

7.2 标签引号规则

何时使用引号

  • 含空格的标签
  • 含特殊字符:(, ), [, ], {, }, :, ;
  • 含中文的标签

语法

flowchart LR
    A["带空格的标签"] --> B["带(括号)的标签"]
    C["中文标签"] --> D["多字:标签"]

八、执行脚本

8.1 渲染函数

# scripts/mermaid_render.py

def render_mermaid_to_png( mermaid_code: str, output_path: str = "/tmp/mermaid_output.png", theme: str = "default" ) -> str: """ 将 Mermaid 代码渲染为 PNG Args: mermaid_code: Mermaid 图表代码 output_path: 输出图片路径 theme: Mermaid 主题 (default/dark/base/wind) Returns: 渲染后的图片路径 """ pass

8.2 渲染+飞书上传

def render_and_upload_feishu(
    mermaid_code: str,
    doc_id: str
) -> str:
    """
    渲染 Mermaid 并上传到飞书
    
    Args:
        mermaid_code: Mermaid 图表代码
        doc_id: 飞书文档 ID
    
    Returns:
        飞书图片 token
    """
    pass

九、常见问题

Q1: 图表不渲染怎么办?

可能原因

  • Mermaid 代码语法错误
  • 浏览器未启动
  • CDN 访问超时

解决方案

  • 在 https://mermaid.live 验证代码语法
  • 检查 OpenClaw browser 状态
  • 等待更长时间让 Mermaid 渲染完成

Q2: 中文显示乱码?

原因:HTML 编码问题

解决:确保 HTML 使用 meta charset="utf-8"

Q3: 图片显示不完整?

原因:图表节点太多太复杂

解决:简化图表,或使用 subgraph 分组

Q4: 支持哪些 Mermaid 版本?

答案:Mermaid 11(最新稳定版)


十、文件结构

mermaid-canvas/
├── SKILL.md                          # 本文件
├── scripts/
│   └── mermaid_render.py              # 核心渲染脚本
└── references/
    ├── diagram-patterns.md            # 常用图表模板
    └── syntax-guide.md               # 安全语法规范

十一、参考文件

文件说明
references/diagram-patterns.md常用图表类型的代码模板
references/syntax-guide.md安全语法规范和最佳实践

十二、相关链接

数据来源:ClawHub ↗ · 中文优化:龙虾技能库
OpenClaw 技能定制 / 插件定制 / 私有工作流定制

免费技能或插件可能存在安全风险,如需更匹配、更安全的方案,建议联系付费定制

了解定制服务