@areaartez51/dsh-uml-class: Generate interactive UML class diagrams from JSON specifications

Preface

When doing architecture analysis in DSH, the most common task is to clarify a class structure: which classes exist, what dependencies they have, and how inheritance relationships connect. Existing methods usually involve exporting the model to a drawing tool for manual arrangement, or having an agent paste a Mermaid/PlantUML code block. The former detaches from the codebase, while the latter depends on a rendering environment, and results aren’t always stable.

The plugin introduced below takes a different path: it doesn’t parse source code; instead, it accepts a spec.json and outputs a self-contained HTML file with inline SVG, supporting zooming, theme switching, and hover highlighting. The plugin registers the file system skill uml-class; actual work is done by the CLI within the skill. It doesn’t add native tools or initiate network requests.

What is it

The full name of the plugin is @areaartez51/dsh-uml-class, maintained by areaartez51, and categorized as “Client” in the community directory. Its positioning is a skill-only bundle, mounting the UML class diagram rendering capability to DSH’s skill directory, allowing agents to extract, generate, and verify class diagrams themselves.

It solves the “class structure → interactive diagram” step: input a structured description, output a single HTML file, rather than having the agent stitch together an un-reproducible text diagram in the chat.

Core Features

  1. Generate an independent HTML file from a spec.json, with inline SVG and no external resource dependencies.
  2. The diagram page supports zooming, theme switching, node expansion, and highlights connection lines on hover.
  3. Supports six relationship types: inheritance, realization, dependency, association, composition, and aggregation, each with independent endpoint symbols (hollow triangle, dashed line, diamond, etc.).
  4. Supports package grouping; you can use --package-by auto to let the tool group automatically by directory or namespace.
  5. Besides class diagrams, the stylized output can also generate a receipt file <name>.receipt.json, recording the tool version, artifact sha256, counts of classes and relations, and warnings.
  6. The layout is deterministic: running the same spec twice results in byte-identical HTML.

It is necessary to clarify the boundaries: the plugin does not parse source code. The spec.json must be filled out by a human or agent after reading the code.

Installation & Enablement

The official recommendation is to install from GitHub Release, and no npm account is required:

dsh plugin --profile desktop add https://github.com/areaartez51/dsh-uml-class/releases/download/v0.20.3/areaartez51-dsh-uml-class-0.20.3.tgz

If you already have a local archive, you can install directly from the file:

dsh plugin --profile desktop add C:\path\to\areaartez51-dsh-uml-class-0.20.3.tgz

If you wish to build the archive from source yourself, execute npm pack in the repository root directory to get areaartez51-dsh-uml-class-0.20.3.tgz (35 files), then install it using the local archive command above.

After installation, restart DSH once, and the skill uml-class will appear in the desktop profile’s skill directory. The uninstall command is as follows:

dsh plugin --profile desktop remove @areaartez51/dsh-uml-class

A Node.js version satisfying ^22.19.0 || >=24.0.0 is required (see the engines field in package.json). The plugin is MIT licensed.

Typical Usage: Extracting from a C# Project

In C# projects, the extraction step for specifications can be automated. After entering the skill directory, execute the following three commands in order:

cd skills/uml-class
node bin/uml.mjs extract csharp /path/to/Assets/Scripts --out spec.json --stats
node bin/uml.mjs render class spec.json out/classes.html
node bin/uml.mjs check out/classes.html

The first step extract scans the source code directory to generate spec.json, and --stats outputs statistical information. The second step render class renders the specification into HTML. The third step check performs a validation on the artifact.

Common flags:

  • --package-by auto: Groups by folder if the entire project has only one namespace, otherwise groups by namespace.
  • --include / --exclude: Accept glob patterns to narrow the scan scope.
  • --calls: Supplements dependencies generated by internal method calls.
  • --no-fields / --no-deps: Removes lines for field dependencies and parameter dependencies.

Typical Usage: Writing the Specification Manually

For non-C# projects, or when you want to draw a diagram manually, write a spec first, then validate, render, and check:

cd skills/uml-class
node bin/uml.mjs validate examples/payments.json
node bin/uml.mjs render class examples/payments.json out/payments.html
node bin/uml.mjs check out/payments.html

The schema for the specification is in skills/uml-class/schemas/class.schema.json, and the attached sample is skills/uml-class/examples/payments.json. The structure is roughly as follows:

{
  "schemaVersion": 1,
  "title": "Модуль оплаты",
  "classes": [
    { "id": "order-service", "name": "OrderService", "fields": ["- repo: OrderRepository"],
      "constructors": ["+ OrderService(repo: OrderRepository)"],
      "methods": ["+ place(order: Order): Receipt"] }
  ],
  "relations": [
    { "from": "order-service", "to": "payment-provider", "kind": "dependency",
      "label": "charge(card, amount)" }
  ],
  "packages": [
    { "id": "commerce", "label": "module: commerce", "classes": ["order-service"] }
  ]
}

Key points for fields: use - for private and + for public in classes; the kind of relation determines the endpoint style; packages are for grouping. During rendering, a payments.receipt.json will be generated next to the HTML for easier verification of whether the artifact has been tampered with.

How it Works

The rendering chain is split into several modules with clear responsibilities:

  1. renderers/model.mjs: Parses JSON and performs validation; error paths look like relations[0].to.
  2. renderers/layout.mjs: Calculates levels; inheritance is arranged downward, same-level items are sorted by the center of gravity method; coordinates are deterministic.
  3. renderers/routing.mjs: Draws orthogonal lines; skips rows for neighbors at the same level, uses gaps for close levels, and seeks vertical channels for far levels.
  4. renderers/svg.mjs + html.mjs: Produces SVG and the self-contained page.

Because coordinates are entirely determined by the algorithm rather than random, results are byte-identical across two renders. When expanding a node, other nodes do not move; only the expanded node grows, and lines are redrawn.

Exit Codes

The CLI exit codes are fixed, making it easy for agents to determine if the last call was successful:

  • 0: Success.
  • 1: Spec error, input/output error, or validation failure.
  • 2: More than 800 classes.
  • 3: Parameter error.

Testing

npm test        # node --test --test-isolation=none "skills/uml-class/tests/*.test.mjs"

--test-isolation=none is mandatory: DSH’s sandbox forbids spawning subprocesses, so tests must run within the same process. The test does not launch a browser and covers layout, neighbor node symmetry, determinism, and missing external resources.

Use Cases & Notes

Suitable scenarios: you have already clarified the class structure in the codebase and need to solidify this structure into an interactive artifact; or you are doing technical debt review or module dependency audits and want to quickly obtain a zoomable, highlightable diagram.

Points to note:

  1. The plugin runs with the permissions of the current DSH process. Before installing, you should check the source code and license to ensure the command, parameters, and file write paths meet expectations.
  2. It does not parse source code; spec.json must be generated by a human or agent after reading the code. The default extract only covers C#.
  3. PNG/SVG file export is not supported; only HTML is produced.
  4. Relationships of a class to itself are not supported.
  5. Full UML (templates, {...} constraints, object graphs) is out of scope.
  6. The class count limit is 800; exceeding this will fail with exit code 2.

Additionally, an ecosystem background note: DSH’s philosophy is “Everything is a plugin”. The community directory mentioned above is an independent site and has no official affiliation with DeepSeek or Fangfang; do not treat it as an official app store.

Conclusion

The value of this plugin lies in a narrow niche: turning “JSON spec → interactive class diagram” into a deterministic, offline output that doesn’t depend on a browser or network. If you are already using DSH to organize architecture, install one command and the uml-class skill is ready to use; if the diagram you need to draw exceeds its declared boundaries, you will need to evaluate for yourself whether it is sufficient.

Directory: https://www.skillhub.cn/plugins/areaartez51/dsh-uml-class
GitHub: https://github.com/areaartez51/dsh-uml-class

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye