dsh-dwg-preview: Directly Preview DWG/DXF Engineering Drawings in the DSH Sidebar

Introduction

In the DeepSeek Harness (DSH) desktop workspace, when you open a .dwg or .dxf file, the built-in document preview usually only shows “Cannot Preview” — it only covers text and images. When doing CAD-related development, reviewing drawings, or modifying code while comparing against drawings, you often have to switch to AutoCAD, LibreCAD, or an online viewer, which interrupts the context inside the Harness.

The following is the community plugin dsh-dwg-preview (maintainer linanbuan): it displays vector graphics directly in the right-side document preview tab, supporting drag-to-pan, Ctrl/⌘ + scroll-wheel zoom, and fit-to-width. Decoding and rendering are done in the host process; the browser side only displays a single SVG without loading third-party viewer libraries.

What Is This

dsh-dwg-preview is a client-side bundle plugin for DSH (@local/dsh-dwg-preview, current version 1.0.0). It registers a renderer in the registry provided by the official sidebar-documentpreview, claiming .dwg and .dxf by file suffix; the host side uses LibreDWG (WebAssembly) to convert DWG to DXF, then uses the dependency-free in-repo renderer lib/dxf2svg.mjs to generate a self-contained SVG. DXF is plain text, so it can go directly to the renderer without LibreDWG.

The plugin’s runtime id is dwg-preview, the preview slot is sidebar.right.tab.document, and the body key is @local/dsh-dwg-preview/dwg. The code in this repository is licensed under MIT; if bundled and redistributed together with @mlightcad/libredwg-web (GPL-3.0), the combined work is subject to GPL-3.0. Plugin catalog page: skillhub.cn/plugins/linanbuan/dsh-dwg-preview; source code: github.com/linanbuan/dsh-dwg-preview.

Core Features

Preview Entry and Interaction

Open a .dwg or .dxf file in the workspace file tree, and the right-side document preview tab is rendered by this plugin. The toolbar provides zoom in, zoom out, fit-to-width, and the total number of entities in the current drawing; inside the view you can drag to pan and use Ctrl/⌘ + scroll-wheel to zoom, while the normal scroll-wheel still scrolls.

Takeover Mechanism and Data Flow

The renderer declares the suffixes dwg and dxf, with priority: 'extension' and loading: 'bytes-complete' (the entire file’s bytes are required, not streaming). Flow overview:

  1. The document preview passes the raw bytes to the renderer (content.kind === 'bytes').
  2. The browser side POSTs the bytes to /api/dwg-preview/svg with a percent-encoded filename header x-dwg-name (host format detection does not depend on this header).
  3. The host identifies by content: if the first 8 bytes start with AC10xx it is DWG; if both SECTION and HEADER/ENTITIES appear within the first 8 KB it is DXF.
  4. DWG is converted to DXF via LibreDWG WASM, then enters dxfToSvg(); the result is returned as an SVG string, and the browser displays it using a Blob URL.

LibreDWG’s wasm is about 9.5 MB; on the first DWG preview it is lazily loaded and a single instance is reused; render results are cached in host memory by sha1 (up to 6 images, invalidated when the process exits).

Host API

Two routes are mounted on the connection’s shared /api channel:

Method Path Description
GET /api/dwg-preview/ping Health check, returns ok, plugin, cache (number of cached images)
POST /api/dwg-preview/svg Success: 200, containing kind, svg, stats; empty file: 400 EMPTY; over 64 MB: 413 TOO_LARGE; failure: 500 FAILED

Rendering Capability Boundaries

Supported entity types include LINE, LWPOLYLINE (including bulge arcs), POLYLINE/VERTEX, CIRCLE, ARC, ELLIPSE, TEXT, MTEXT, ATTRIB, INSERT (nested blocks and arrays), HATCH, SOLID/3DFACE, POINT, DIMENSION, etc.; entities outside the list are silently ignored. Linetypes and line widths are not drawn (solid lines, non-scaled strokes); text does not embed fonts and does not process SHX; it is read-only, with no picking, layer toggles, dimension editing, or print/export.

The browser-side client only requires react; DWG decoding depends on @mlightcad/libredwg-web (^0.7.14), installed via the profile’s dependencies.

Installation and Activation

First install the DSH desktop app (deepseek.com/download). This plugin is a standard bundle that declares dsh.bundle.patch and dsh.client; choose any one of the following methods.

  1. Sidebar Plugins → Add plugin;
  2. Enter the spec in the input box, e.g. a repository URL https://github.com/linanbuan/dsh-dwg-preview, GitHub’s Source code (zip), an absolute path to a local directory, or a possible npm package name in the future;
  3. After confirming the information, Install, and when finished Enable now.

The Harness writes the package into the current profile’s dsh.profile.bundles and mounts the host side; no manual profile edits are needed.

Method 2: In-Session Agent

Point the in-session Agent to the repository URL or a local directory, and let the Agent call plugin_manager (action: install_bundle) to complete the installation.

Method 3: Command Line

When the dsh CLI is installed:

dsh plugin --profile <profile name> add <spec>

<spec> is the same as in Method 1; refer to dsh plugin --help for specific parameters.

After Installation

  • If a restart prompt appears, you should restart the DeepSeek Harness application (not just refresh the page) so that the host side loads the /api/dwg-preview/* routes.
  • Verify it is running: check on the plugin page whether the component shows “Running”, or request GET /api/dwg-preview/ping.
  • Temporarily disable: set disabled: true for dwg-preview in cordis.patch.yml or via the plugin page toggle; uninstall via Uninstall on the plugin page, which removes it from the profile dependencies and bundles.

The maintainer’s README states it has been tested on Windows desktop + DSH 0.1.7-rc.2; the host requires Node >= 20. The seams used by the plugin, such as connection.fetch.register and documentPreviews, are not stable public APIs; after Harness upgrades, follow-up work may be needed for new versions.

Typical Usage

After installation and activation, no additional configuration is needed:

  1. Open a project containing .dwg or .dxf files in the DSH workspace;
  2. Click the drawing file in the file tree;
  3. The right-side document preview tab loads the SVG; use the toolbar or gestures to adjust the view.

Developers can run offline self-checks inside the repository (not dependent on the Harness):

node test/selfcheck.mjs

Or use pnpm test via the test script in package.json; when all pass it outputs 31/31 checks passed. To regenerate the documentation example images:

node tools/make-example.mjs

Use Cases and Notes

Suitable for: writing code in DSH while comparing against CAD drawings, reviewing DXF/DWG, and scenarios in Agent workflows that need a “click to view” vector preview.

Permissions and privacy: the plugin runs with the current DSH host process privileges; file bytes are decoded and rendered only in local memory, not uploaded and not written to disk (except for the .mount.log mount marker used for plugin directory troubleshooting). Before installation you should review the source code and license yourself; this plugin is not an official DeepSeek plugin, provides no service commitments, and may stop working after Harness upgrades, degrading with an error prompt; it generally does not affect Harness startup.

Limitations: the single-file preview limit is 64 MB; large drawings will consume host memory and synchronously consume CPU. The official plugin manager does not support auto-update; upgrading requires uninstalling and reinstalling; after replacing an installed package, the host side must restart the application to load the new code. If entities outside the list do not display, check against the entity list in the README.

The DSH ecosystem emphasizes “everything is a plugin”; the SkillHub catalog is a community site with no official affiliation with DeepSeek / High-Flyer.

Conclusion

dsh-dwg-preview fills the gap in DSH’s document preview for CAD drawings: host-side decoding, vector SVG display, and lightweight read-only interaction. If your workspace frequently contains DWG/DXF files, install it using the spec above and open one directly in the file tree to verify.

  • Catalog page: https://www.skillhub.cn/plugins/linanbuan/dsh-dwg-preview
  • GitHub: https://github.com/linanbuan/dsh-dwg-preview
羽毛球分组比赛记分
小程序二维码

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

Xiaoye