Skip to main content
S

dsh-plugin-mermaid-gb-svg

sandyyst/dsh-plugin-mermaid-gb-svg

DSH 插件:Mermaid 流程图 → GB/T 1526-1989(等同 ISO 5807)国标流程图 SVG,符号合规、正交走线、超 A4/A3 自动分页。DeepSeek Harness plugin: Mermaid flowcharts to GB/T 1526-1989 (ISO 5807) compliant flowchart SVG with A4/A3 pagination.

Install

dsh plugin --profile web add github:sandyyst/dsh-plugin-mermaid-gb-svg

README

dsh-plugin-mermaid-gb-svg

npm version license topic: dsh-plugin GB/T 1526-1989

A DeepSeek Harness plugin that turns Mermaid flowcharts into GB/T 1526-1989 compliant SVG (the Chinese national standard, identical to ISO 5807:1985), and exposes it to the model as one tool.

Preview

GB/T 1526-1989 symbol chartGenerated flowchart
GB/T 1526-1989 symbolsGenerated flowchart

Both SVGs are produced by this tool — the source .mmd files are in examples/.

Install

# 1) install into a profile (web shown here)
dsh plugin --profile web add dsh-plugin-mermaid-gb-svg

# 2) make the loader load it — append to $DSH_HOME/profiles/web/cordis.patch.yml
- insert:
    - id: mermaid-gb-svg
      name: dsh-plugin-mermaid-gb-svg
      # config:
      #   fontSize: 14
      #   paper: none

For local development point at the source directory instead: dsh plugin --profile web add /path/to/dsh-plugin-mermaid-gb-svg.

Tool: mermaid_to_gb_svg

ParameterTypeDescription
outstring, requiredOutput path. Ending in .svg = file name (multi-diagram gets -1/-2), otherwise output dir/prefix
sourcestringMermaid source (mutually exclusive with path)
pathstringInput .mmd/.mermaid, or .md containing ```mermaid blocks (all blocks extracted; nearest heading above becomes the caption)
titlestringFigure caption
dirtd|lr|bt|rlForce flow direction
papernone|auto|a4|a4l|a3|a3lSheet size; none (default) emits one large SVG, others paginate when the drawing does not fit
font_sizeintegerBody font size in px (14 ≈ 10.5pt)
font_tubooleanUse technical-drawing font (GB/T 14691 FangSong)
captionbooleanDraw the caption (default true)

Returns files, diagrams, pages, summary, warnings.

GB/T 1526-1989 symbols

SymbolMeaningMermaid syntax
rounded rectangleterminal (start/end)A([x]) A((x)) A(x)
rectangleprocessA[x]
diamonddecisionA{x}
parallelogramdata (input/output)A[/x/] A[\x\]
hexagonpreparationA{{x}}
double-sided rectanglepredefined processA[[x]]
cylinderdirect access storageA[(x)]
trapezoidmanual operationA{/x/}
sloped-top quadmanual inputA{\x\}
square bracketannotationA>x]
circleconnector (on page)A@{ shape: connector, label: "A" }
pentagonoff-page connectorA@{ shape: off-page, label: "B" }
—document / multi-documentA@{ shape: doc, label: "report" } / docs
—display / delayA@{ shape: display, label: "display" } / delay
—internal storageA@{ shape: internal-storage, label: "storage" }

shape accepts both Mermaid v11 names and Chinese names (处理/起止/判断/数据/准备/预定义处理/ 直接存取存储/人工输入/人工操作/文档/多文档/显示/延迟/内部存储/注释/连接符/换页连接符).

Drawing conventions

  • Flow runs left-to-right or top-to-bottom; flowlines are orthogonal with solid arrowheads.
  • Decision branches: 是 leaves the bottom vertex downward, 否 leaves the right vertex (going right first, then turning).
  • Every incoming flowline enters a symbol vertically at its top centre.
  • At most 3 bends per flowline — routes are tried in order 0→1→2→3 bends and the first one that does not cross a symbol wins.
  • Geometry is self-checked after generation (overlaps, flowlines through symbols) and reported in warnings.

Pagination (optional)

With paper: a4 (or a3/auto), a drawing that does not fit is split:

  • cuts fall in the gaps between layers (and between columns of symbols), never through a symbol;
  • each sheet is sized in real millimetres (width="210mm" height="297mm") with a frame, a binding margin and a (page n/N) caption;
  • each broken flowline gets an off-page connector (pentagon) pointing along the flow, and the connector sits at the same place with the same label on both sheets.

Configuration

KeyDefaultMeaning
fontSimSun, '宋体', 'Microsoft YaHei', sans-serifFont family
fontSize14Body font size (px)
stroke1.6Line width
papernoneDefault sheet size

Sandbox

Writes go through the Harness ctx.fs seam with the session's sandbox policy, and support the same one-shot sandbox_permissions + justification escalation retry as the built-in write tool.

Development

npm test        # test/engine.test.mjs + test/plugin.test.mjs

lib/engine.js is generated from the CLI version (tools/mermaid2gb-svg.js) so both stay in sync; edit the CLI and regenerate rather than editing the engine directly.

Feedback

Feedback is what decides what gets built next — especially standard-compliance corrections, since GB/T 1526-1989 has details that are easy to get subtly wrong.

ChannelUse it for
IssuesBugs, symbol corrections (there is a dedicated template — please cite the clause/figure), feature requests
DiscussionsUsage questions, layout/typography opinions, open-ended ideas
sandyyst@hotmail.comAnything you would rather not post publicly

When reporting a problem, attach the Mermaid source. A one-line description plus the .mmd is usually enough to reproduce it — the generated diagram, the tool's warnings array, and your plugin version help too.

If the tool reports geometry warnings, the output already carries the link to the issue tracker — that is the moment the report is most useful.

License

MIT

Related plugins