drawio-skills

规格格式

YAML 规格是 Draw.io Skill 2.6.0 的规范表示方式。

Mermaid、CSV 和导入的 .drawio 都只是输入适配层,进入渲染前都应该先归一化成这个结构。

最小示例

meta:
  theme: tech-blue
  layout: horizontal

nodes:
  - id: api
    label: API Gateway
    type: service
  - id: db
    label: PostgreSQL
    type: database

edges:
  - from: api
    to: db
    type: data
    label: Query

顶层结构

meta

图表级设置。

meta:
  theme: tech-blue
  layout: horizontal
  routing: orthogonal
  profile: default
  figureType: architecture
  title: Example Diagram
  source: generated

常见字段:

字体策略:

meta:
  font:
    primary: Times New Roman
    cjk: Times New Roman,SimSun
    formula: Times New Roman

modules

相关节点的逻辑容器。

modules:
  - id: backend
    label: Backend

nodes

必需。每个节点都需要稳定的 id 和 label。

nodes:
  - id: api
    label: API Gateway
    type: service
    module: backend
    position:
      x: 160
      y: 96
    icon: aws.api-gateway

node.image 引用顶层 assets 的 id(仅 PNG/JPEG)。同一节点不能同时设置 icon 与 image。路径相对 asset root(cwd 或 --asset-root),不相对规范文件。完整规则见 skills/drawio/references/docs/local-image-assets.md。

edges

可选,但大多数图都会用到。

edges:
  - from: api
    to: db
    type: data
    label: Query
    labelPosition: center

复刻元数据

复刻图通常会额外记录:

meta:
  source: replicated
  replication:
    colorMode: preserve-original
    background: "#FFF7ED"
    palette:
      - hex: "#FDBA74"
        role: service fill
        appliesTo: nodes
        confidence: high

colorMode 可取值:

文字保真字段

复刻图常常不只需要颜色元数据。只要文字位置有意义,就可以使用这些字段:

当 position 和 bounds 同时存在时,应该把 bounds 视为保真几何。

自动类型检测

当 type 省略时,标签仍可能自动映射到:

公式检测只应依赖:

校验预期

编译器会检查:

如果你希望 warning 直接阻断输出,启用 strict 模式。

从 A-H 格式迁移

A-H 现在是历史格式。规范映射关系如下:

旧概念 YAML 位置
布局 meta.layout
模块 modules[]
节点 nodes[]
边 edges[]
视觉风格 meta.theme 与 style 覆盖
导出意图 本地 CLI 或 Desktop 导出路径

相关