Introduction¶
The DeepSeek Harness (DSH) plugin ecosystem is designed to extend the capabilities of the main program. dsh-drawai addresses the problem of fragmented diagramming and conversation: it integrates an editable canvas into the right sidebar of DSH and provides two tools, diagram_read and diagram_apply, allowing the model to directly read and modify the same .drawio file.
This achieves “surgical” editing — the human and the model read and write the same file, changes are persisted directly, and cumbersome import/export is unnecessary.
Plugin Overview¶
- Plugin name:
dsh-drawai - Core focus: Editable canvas in the DSH right sidebar + two tools that let the model modify diagrams directly
- Maintainer:
fourzkw - Category: Model inference
- License: MIT
Installation and Enablement¶
After installing the plugin, the host must restart dsh web for the changes to take effect.
dsh plugin --profile web add dsh-drawai
After the restart is complete, a “DrawAI canvas” panel appears in the right sidebar, and diagram_read and diagram_apply appear in the model tool list.
Core Capabilities¶
1. Editable canvas in the right sidebar¶
The canvas supports basic operations such as drawing nodes, connecting lines, layering, sorting, and alignment. Double-click to modify labels. It directly reads and writes native .drawio files, and units that the canvas cannot recognize are preserved byte-for-byte.
2. Diagram modification via natural language¶
The model uses diagram_read to perceive the current canvas’s structure, styles, layers, and selection, then uses diagram_apply to perform additions, deletions, modifications, layout adjustments, or export operations.
3. Selection awareness and rollback¶
The model can perceive what you have selected on the canvas. Multi-step undo is supported, with rollback up to 8 steps.
4. Diagram support¶
- SVG nodes: Supports direct insertion of SVG markup, or specifying the
svgattribute viaaddNode. - Bitmap vectorization: Provides the
traceImagetool, which can generate SVG nodes from bitmaps in the workspace.
5. Data consistency¶
- Optimistic locking: Uses the
revisionfield to prevent concurrent conflicts. If therevisionpassed todiagram_applydoes not match the current file, the operation errors out and does not write back to the file. - Preserve unknown content: When writing back to the file, units unknown to the model are retained as-is and are not removed.
Usage Examples¶
1. Vectorizing a bitmap¶
Convert an image in the workspace into a vector node:
diagram_apply({ op:'traceImage', image:'refs/角色.png', x:40, y:40 })
2. Exporting SVG¶
Export the current canvas to SVG format:
diagram_apply(export, format:'svg')
3. Optimistic locking write-back¶
Before making modifications, first read the file’s revision, and include that version number when writing:
// 模型先读取
const state = await diagram_read();
// 后续修改操作带上 expectRevision
diagram_apply({ op:'setStyle', ids:['node-1'], style:'fill:#f00' }, { expectRevision: state.revision });
Notes¶
- Restart to take effect: You must restart
dsh webafter installation. - SVG requirements: SVG markup must include the
viewBoxattribute; otherwise, graphics may distort when scaling. - Dependencies: The
traceImagefeature requires the host to have thesharplibrary installed when processing JPEG, GIF, or WebP formats. - File format: The canvas is based on the native
.drawio(mxfile) format and is compatible with drawio / diagrams.net.
Summary¶
dsh-drawai provides a closed-loop diagramming solution within the DSH environment. Through the native file format and structured tool interface, it enables the model to “speak about what it sees” like a human and precisely modify local content in a diagram.