roxorlt/UEmaster / skills/flow-canvas
flow-canvas
Verified把业务图渲染成横平竖直的规范 SVG:流程图(正交规范)、架构图(泳道分层)、ER 图、甘特图、时序图。触发:画流程图、业务流程图、架构图、ER 图、甘特图、时序图、把 mermaid 转规范图、流程图横平竖直、评审用图、render flowchart / orthogonal flowchart / architecture diagram / ER diagram / gantt / sequence diagram / draw a clean diagram from mermaid。不适用:只要 mermaid 源码文本、脑图、表格。
contract/erspec-v2.md
View on GitHub# erspec/2 契约(ER 图)
flow-canvas 多图类型引擎 · ER 图排版契约。破坏性变更时主版本 +1。
本版本相对 erspec/1 的两项破坏性变更:
1. 布局由「死板一排横向实体」改为**网格布局**(向上/下/左/右扩展、行列对齐)。
2. 基数记号由文字 `||--o{` 改为**乌鸦脚(crow's foot)图形记号**。
## 输入:mermaid erDiagram 子集
```
erDiagram
CUSTOMER ||--o{ ORDER : "下单"
ORDER ||--|{ ORDER_ITEM : "包含"
CUSTOMER {
int id PK "主键"
string name "姓名"
}
ORDER_ITEM {
int qty 数量
}
```
- 实体:`NAME { 属性行... }`;属性行 = `类型 属性名 [PK|FK] ["注释"]`(PK 下划线、FK 斜体渲染)。
- 属性行**注释可带引号也可不带**:去掉引号注释后,剩余尾部分号/逗号分隔的 token ——
`PK`/`FK` 计为修饰;由中文/字母数字/下划线组成者合并为注释;含其他字符(如 `!!`、`$`)报「形态超限」。
例:`int id 主键` → 注释「主键」;`int id PK "主键"` → PK + 注释「主键」。
- 关系:`A 基数--基数 B : "标签"`;左右各一个基数记号(`||`、`o|`、`|o`、`o{`、`}o`、`|{`、`}|`)。
- 校验:实体重复、自引用、未定义引用、非法基数记号、**完全重复的关系边(同 from/to/基数)**、
实体数 > 8 → 均报「形态超限」错误降级。
## 布局规则(网格布局)
1. 实体 = 表格块:表头 + 属性行;`w = 最宽文本 + 20`,`h = header_h + n*attr_h + 10`。
2. 网格放置(确定性贪心):实体 0 放 `(0,0)`;按边声明序逐条处理,某边恰一端已放置、另一端未放置时,
把未放置端放到已放置端 4 邻域(先上/下/左/右,再对角)中的第一个空格子;4+对角全占则按离原点
由近及远(环状扩张)扫第一个空格子;扫完边后仍未放置的实体同样环状入格;最后平移使最小行列号为 0。
3. 像素映射:`列宽 = 该列最大实体宽 + 80`、`行高 = 该行最大实体高 + 80`;实体中心在单元格中心
(同列 x 对齐、同行 y 对齐)。
4. 边路由:
- 网格相邻(曼哈顿距离 1):两实体相向侧边中点直连(左↔右 / 上↔下)。
- 非相邻(跳级/对角):正交绕行,只走行间隙与列间隙(间隙带内无实体框,不穿框);按
同行跳级 / 同列跳级 / 异行异列 分别走下方(或第 0 行上方)/ 侧方 / 阶梯走廊。
- 同间隙多条绕行边:每条边分配不同走廊偏移(步长 14px,交替上/下、左/右),避免共线重叠。
- 同一端口多条边:端口错位 ±8px。
- 交叉消除:候选实体放置序 = [声明序, 2 轮 barycenter 序, 逆声明序],逐序完整放置+路由,
用正交交叉检测取最小者;`min > 0` 或 `绕行边数 > 6` → 报「形态超限」降级。
5. 边标签:相邻直连边标签在线中点上方(水平边)/ 右侧(垂直边),anchor middle;绕行边标签在
第一段水平段上方。溢出检查:标签宽 ≤ 对应间隙 + 8,超出计入 textOverflow。关系标签 ≤ 4 个汉字。
6. 质检:`box_overlaps`(实体框)+ `text_overflow_check`(实体内文字)+ 边标签检查 + `ortho_crossings`(所有路由)。
## 输出 SVG 契约
- 根元素:`<svg data-erspec="2" viewBox="0 0 W H">`
- 实体:`<g class="entity" id="er-{id}">`:表头 rect + 属性行 text + 行分隔线
- 边:`<polyline>`(两端按记号跨度缩进)+ 乌鸦脚记号 `<g class="er-card" data-card="o{">` 包裹:
- `tick(d)` 竖线/横线、`circle(d)` 白填充圆(r=5)、`fork` 三叉(apex 朝线、叉腿朝实体);
- 组合(从实体边向外):`||`→tick@6+tick@13;`o|`/`|o`→tick@6+circle@16;
`|{`→fork+tick@34;`o{`→fork+circle@34;左端 `}o`→fork+circle@34 镜像、`}|`→fork+tick@34 镜像;
- 垂直接入(上端口)绕端口旋转 90°,下端口向下镜像。
## 质检
统一 `--check` 报告字段;块重叠 0、边交叉 0、文字溢出 0,任一非 0 拒绝产出并降级。
实体数 > 8、绕行边 > 6、交叉无法消除 → 报「形态超限」错误降级。
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |