Preface¶
dsh-maestro-diagram is a hybrid plugin in the DeepSeek Harness (DSH) ecosystem, positioned as Maestro Diagram Studio. It runs as a Host-only plugin and works together with the maestro-skills/skills/diagram-studio skill to provide deterministic validation and drift detection capabilities for SA-level diagrams.
The core goal of this plugin is to establish a “Single Source of Truth”: use GitHub-native Mermaid as the source code, combine it with editorial-style HTML+SVG output, and ensure consistency between diagrams and code through tool calls rather than a large language model (LLM).
Core Features¶
- mermaid_verify: Mermaid syntax validation tool. It is based on
mermaid.parse()and can optionally integratemermaid-cli, returning errors as structured objects rather than throwing exceptions, making it easier for Agents to fix them. - mermaid_drift: Code-to-diagram drift detection tool. It scans and compares Mermaid nodes/edges with the code root directories (
packages/*,govard,maestro-skills), identifying elements that exist in the diagram but are missing in the code, or stale edges. - 5 diagram types: Supports standard Mermaid diagram types, including
flowchart(component/architecture),sequenceDiagram(sequence),classDiagram(class diagram),erDiagram(entity relationship), andstateDiagram(state machine). - Editorial-style HTML: Supports generating self-contained HTML files. It includes visual Tokens such as
paper(#f5f5f5),ink(#2d3142), andaccent(#eb6c36), and adjusts content presentation based on the audience (Team or Client), such as folding source code and hiding footers. - GitHub-native integration: The default output preserves GitHub Mermaid rendering, serving as the Single Source of Truth for source code.
Installation and Enablement¶
This plugin runs in Host-only mode. After installation, reload the Host to register the tools.
# 安装插件
dsh plugin add @ddtcorex/dsh-maestro-diagram
Typical Usage¶
In a DSH Agent workflow, using this plugin generally follows these steps:
- Load the skill: Load the
diagram-studioskill. This skill selects the diagram type based on semantic patterns and enforces editorial specifications (such as density and accent color). - Write and validate: Write the Mermaid code into a document (such as
docs/architecture.md) and call themermaid_verifytool. The Agent must fix the code untilok: true. - Audience rendering:
- If the audience is Team/Internal, generate HTML containing inline SVG, collapsible source code, and an editorial-style card.
- If the audience is Client/External, generate clean HTML containing only SVG, with source code and decorative elements hidden.
- Drift detection: Before committing code, call
mermaid_driftto check whether the nodes in the diagram match the code implementation, and fixmissingInCodeorstaleEdges.
Tool Interface¶
mermaid_verify¶
Used to validate Mermaid syntax and ensure that diagrams can be rendered.
// 调用示例
mermaid_verify({
input: "graph TD; A-->B;", // 或文件内容
isPath: false,
strict: true // 开启反模式警告(如 shadow, legacy graph)
})
// 返回结构
{
ok: boolean,
errors: { line, col, msg }[],
warnings: { msg }[]
}
mermaid_drift¶
Used to compare a Mermaid diagram with the source code and identify inconsistencies.
// 调用示例
mermaid_drift({
diagramPath: "docs/architecture.md",
codeRoots: ["packages/*", "govard", "maestro-skills"]
})
// 返回结构
{
missingInCode: string[], // 图中有但代码中未定义的节点
staleEdges: { from, to }[], // 图中存在但代码逻辑已废弃的边
missingInDiagram: string[], // 代码中有但图中未展示的节点
summary: string
}
Technical Details and Build¶
- Dependencies: Depends on
mermaid10.9.0. - Build requirements: A flat
lib/index.jsfile must be generated (rootDir: src/host). Iflib/host/index.jsexists instead oflib/index.js, startingdsh webwill fail withERR_MODULE_NOT_FOUND. - Publishing: Publish using pnpm; the
--access publicparameter must be added.
# 构建插件
pnpm --dir packages/dsh-maestro-diagram run build
# 运行测试
pnpm --dir packages/dsh-maestro-diagram run test
# 验证 TypeScript
pnpm --dir packages/dsh-maestro-diagram run verify
Notes¶
- Host-only: The current version (v1) does not include a client package; tools are registered in the Host process.
- Publishing rules: When dependencies use the
workspace:protocol, publishing must usepnpm publish --access public;npm publishis not allowed, otherwise dependency issues may occur. - Style rules: The plugin includes a set of visual specifications (Tokens), including
focalandmuteddefinitions, to ensure consistent diagram styling. - License: MIT License; some editorial style inspiration is derived from
cathrynlavery/diagram-design.
For more details and design documentation, refer to: GitHub Repository