説明
以下はプラグイン作者による原文です。
dsh-inline-visualizer

· GitHub · MIT · DSH 0.2.1-rc.5
English · 简体中文
Turns "inline visualization" into two built-in tools for DeepSeek Harness: the model first spells out what it wants to draw (widget_guidelines loads a design contract), then hands the snippet to show_widget — the card renders right in the conversation, and the visual itself never enters the model's context.
- Targets DSH 0.2.1-rc.5 (
engines.dsh: >=0.2.1-rc.5 <0.3.0). - Plain JavaScript, no build step, no third-party runtime dependencies; the host side uses the host-provided
@deepseek-ai/dsh-tools, and the browser side only pullsreactfrom the host module table.
With and without

Without the plugin, diagrams can only appear as code blocks or files. With it, cards render directly in the conversation — interactive, downloadable, and theme-aware.
Why this plugin
- The artifact never enters the model's context. The tool result is a single ack; the visual travels out-of-band into the UI. The SVG source of two or three charts will not flood the conversation, and the model will not start repeating code.
- No third-party runtime dependencies. No echarts, no mermaid, no build scripts — install and go.
- Theme actually follows. It reads only the documented entry points
ctx.themeand--dsw-alias-*, recalculating colors when the user switches light/dark; it never touches host internals such asdata-ds-dark-theme, so host upgrades will not break it. - Two render paths, separated by risk. SVG goes through a
data:URI into an<img>— vector, crisp, and never executes scripts; HTML goes into an opaque-originsandbox="allow-scripts"iframe with adefault-src 'none'CSP, so it can be interactive but cannot read the host. - The model does not have to guess colors. A built-in design contract provides 8 color families × 6 steps, semantic tokens, typography and hard constraints, loaded per module (diagram / chart / mockup / interactive / art).
- Bilingual UI + complete display metadata.
locale/{en,zh}.jsoncarriesmeta.title/meta.description, andicon.svgis hand-drawn, so the store listing never falls back to a default image. - 197 self-tests; 205 when the real
dsh-toolsPart C is enabled, including tool-schema compilation.
What it does not do
- No streaming, character-by-character rendering: the visual appears all at once after the tool call, not token by token.
- No rasterization: output is always vector SVG, never converted to PNG.
- No Mermaid parsing: install a Mermaid plugin separately if you need it.
- No bundled chart library: charts are hand-written native SVG by the model, trading a library for zero dependencies and a controlled size.
The two tools
| Tool | Arguments | Purpose |
|---|---|---|
widget_guidelines | modules: ('diagram'|'chart'|'mockup'|'interactive'|'art')[] | Returns the design contract (tokens, typography, spacing, hard constraints + the selected modules) |
show_widget | title, widget_code, loading_messages | Renders a card in place; returns only a very short ack |
widget_code is a bare <svg …>…</svg> (preferred) or an HTML fragment. The tool result contains no snippet content — that is the red line of the whole approach.
Install
Published on npm (dsh-inline-visualizer@2.0.2).
Install it with the DSH plugin manager (recommended):
plugin_manager { action: "install_bundle", target: "dsh-inline-visualizer" }
This requires danger-full-access approval; target accepts any pnpm-resolvable install spec — a package name (installed from npm) or an absolute path to a local directory.
Manual install (development only): drop the package into $DSH_HOME/profiles/<profile>/node_modules/dsh-inline-visualizer (for example ~/.dsh/profiles/desktop/node_modules/dsh-inline-visualizer) and append to that profile's cordis.patch.yml:
- insert:
- id: visualizer
name: 'dsh-inline-visualizer'
Installing a new package takes effect via HMR; replacing an already-installed package requires a restart to load the new JS generation.
Optional configuration
- id: visualizer
name: 'dsh-inline-visualizer'
config:
maxCodeChars: 200000 # per-card limit, 1000 - 1000000
Security boundaries
| Surface | Approach |
|---|---|
| SVG | Allowlist-sanitized, then turned into a data: URI and placed in an <img> — <script> / <foreignObject> / animation elements / on* are all stripped, href may only be # or data:; <img> itself never executes scripts |
| HTML | sandbox="allow-scripts" (opaque origin, never allow-same-origin) + a default-src 'none' CSP + external links limited to 4 CDNs |
| Height | The child posts postMessage({type:'viz:height'}); the parent validates event.source before resizing |
| Theme | Reads only documented entry points: ctx.theme.getTheme().colorScheme and theme/change; never touches any host internals |
| Copy | All strings go through the plugin's own locale namespace (ctx.locale), bilingual EN/ZH |
Layout
| File | Purpose |
|---|---|
index.js | Host half: registers the two tools via defineTool; assembles guidelines/*.md on demand |
client.js | Browser half: a window.__ModuleLoader__.load() factory that registers the card into tool.call.toolview under key: 'show_widget' |
guidelines/ | The design-contract text (_core.md always included + five modules) |
locale/{en,zh}.json | Display metadata (meta.title / meta.description) and runtime strings |
icon.svg | Plugin icon (64×64, shipped in the package) |
assets/icon-180.png | Store-card icon (180×180 PNG, listing only) |
assets/readme-hero.png | README hero image (shipped in the package) |
assets/readme-compare.png | With/without comparison image (shipped in the package) |
test/smoke.mjs | npm test: 197 assertions (205 with Part C), including real defineTool schema compilation |
CHANGELOG.md | Version history |
Testing
npm test
Four parts: the host half's tool definitions; compiling schemas with the real dsh-tools (enabled when DSH_TOOLS_ENTRY points at its lib/index.js or lib/types/schema.js); the browser half's rendering / XSS / theme; and packaging / publishability requirements.
Visual test cases and screenshots live in docs/test-cases: 5 design modules, both render paths, sanitization and argument validation — 30 cases, 24 screenshots, with a full smoke-test report.
Known limitations
- No real-browser E2E: the
testuses a fake React + fake DOM, so layout, actual CSP enforcement and React reconciliation are not covered. - Sanitization is regex-level: mXSS and entity-encoding bypasses are out of scope; routing SVG through
<img>keeps the risk minimal, but the HTML branch relies on the CSP as its only line of defense. - The spec is a general rewrite: the palette is a first-party 8-family × 6-step system, not an equivalent copy of any product.
- No performance testing near the 1,000,000-character configuration limit.
Releasing
npm publish --access public(package namedsh-inline-visualizer; if taken, switch to a scope and update the name in three places).- Open a single PR to awesome-dsh-plugin adding one file
data/plugins/tonebean__dsh-inline-visualizer.yml, categoryui, icon fromassets/icon-180.png(raster PNG only). - Or host your own index: any format-1 JSON over http(s), added by the user under Settings → Plugins → Marketplace Index.
Full commands, the acceptance checklist, the PR template and the semver pitfall are in PUBLISHING.md (not shipped in the package).
License
MIT, see LICENSE.
バージョン履歴
- 2.0.22026/11/29 · 573 KB