dsh-visio 0.0.0-stage → 1.24.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.en.md +223 -0
- package/README.md +193 -2
- package/client.js +4295 -0
- package/cordis.patch.yml +15 -0
- package/engine/blank_doc.py +172 -0
- package/engine/fix_units.py +50 -0
- package/engine/kinds.py +65 -0
- package/engine/route_grammar.py +321 -0
- package/engine/shape_library.json +111 -0
- package/engine/stencil.py +338 -0
- package/engine/svg_raster.py +666 -0
- package/engine/text_metrics.py +85 -0
- package/engine/visio_bridge.py +1854 -0
- package/engine/vsdx_core.py +3603 -0
- package/icon.svg +16 -0
- package/index.js +124 -0
- package/lib/actions.js +392 -0
- package/lib/agent-tool.js +145 -0
- package/lib/bridge.js +325 -0
- package/lib/format.js +40 -0
- package/lib/http.js +89 -0
- package/lib/paths.js +135 -0
- package/lib/schema.js +169 -0
- package/lib/util.js +17 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +75 -4
- package/tests/e2e-panel.mjs +226 -0
- package/tests/make_live_panel.mjs +100 -0
- package/tests/make_uicheck.mjs +52 -0
- package/tests/test_client_contract.mjs +127 -0
- package/tests/test_client_render.mjs +257 -0
- package/tests/test_engine.py +1261 -0
- package/tests/test_host_contract.mjs +351 -0
- package/tests/test_tool_integration.mjs +119 -0
- package/tools/index.js +41 -0
- package/tools/locale/en.json +6 -0
- package/tools/locale/zh.json +6 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SamyiHu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.en.md
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# dsh-visio
|
|
2
|
+
|
|
3
|
+
[](https://github.com/SamyiHu/dsh-visio/actions/workflows/ci.yml)
|
|
4
|
+
|
|
5
|
+
A native **Visio (.vsdx) viewer and editor for the DeepSeek Harness (DSH) Web UI**, with a
|
|
6
|
+
live preview, shape editing and four agent tools (`visio_view` / `visio_draw` / `visio_connect` / `visio_export`). The core engine is Python standard
|
|
7
|
+
library, with no Visio install and no Office dependency; PNG export, `snapshot` and stencil
|
|
8
|
+
previews additionally need [Pillow](https://pillow.readthedocs.io/) (`engine/svg_raster.py`).
|
|
9
|
+
|
|
10
|
+
English · [简体中文](README.md)
|
|
11
|
+
|
|
12
|
+

|
|
13
|
+

|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## ⚠️ Beta · back up your files first
|
|
18
|
+
|
|
19
|
+
> **This project is still in beta — back up the original `.vsdx` before you open it here.**
|
|
20
|
+
>
|
|
21
|
+
> - The plugin **writes to the drawing file** you open. Every save drops a `.bak` next to it
|
|
22
|
+
> (the last 20 are kept), but that copy **cannot cover every case**: editing the same file in
|
|
23
|
+
> Visio at the same time, a crash or power loss, a cloud-sync conflict, or another tool writing
|
|
24
|
+
> to it can still corrupt the file or lose edits.
|
|
25
|
+
> - **Any file damage, data loss or other harm caused by using this plugin is at your own risk**;
|
|
26
|
+
> the authors provide no warranty, express or implied (see the MIT licence).
|
|
27
|
+
> - Copy important drawings before opening them here, and wait for a stable release for
|
|
28
|
+
> production work.
|
|
29
|
+
|
|
30
|
+
## Screenshots
|
|
31
|
+
|
|
32
|
+
| Panel: drawing + inspector | Tabs: two drawings side by side |
|
|
33
|
+
|---|---|
|
|
34
|
+
|  |  |
|
|
35
|
+
|
|
36
|
+
| Floating canvas (right-hand orb) | First run: the four-step guide |
|
|
37
|
+
|---|---|
|
|
38
|
+
|  |  |
|
|
39
|
+
|
|
40
|
+
## Showcase
|
|
41
|
+
|
|
42
|
+
| [Global order fulfilment](examples/showcase/showcase-1-global-fulfilment.vsdx)<br>4 swimlanes / 15 nodes / 3 gates / 3 rework loops | [Platform architecture](examples/showcase/showcase-2-platform-architecture.vsdx)<br>Edge / service / data layers plus external systems |
|
|
43
|
+
|---|---|
|
|
44
|
+
|  |  |
|
|
45
|
+
|
|
46
|
+
## Features
|
|
47
|
+
|
|
48
|
+
- **Live preview** – the panel renders the `.vsdx` page to SVG and repaints after every edit.
|
|
49
|
+
- **Edit in place** – move / resize, text, fill, line, per-run text colour, shape data.
|
|
50
|
+
- **Shape library** – 16 built-in kinds (process, decision, terminator, …) plus
|
|
51
|
+
`.vssx`/`.vstx` stencil import; built-ins are written as real ShapeSheet geometry rows
|
|
52
|
+
(`RelMoveTo`/`RelLineTo` + `Rounding` cells), not lines painted on a preview layer, so the
|
|
53
|
+
outline is identical when the file is opened in Visio.
|
|
54
|
+
- **Connectors** – add, label, delete; connectors keep their own line colour, weight and
|
|
55
|
+
arrow heads, and their labels are read from the 1-D shape text.
|
|
56
|
+
- **Relationship audit** – `validate` finds empty links (connectors with no `Connect` rows),
|
|
57
|
+
dangling ids, floating endpoints and zero-size shapes.
|
|
58
|
+
- **Multi-page, zoom, pan, grid, undo/redo**, external-change detection.
|
|
59
|
+
- **Agent tools** – the same operations are exposed as four domain tools, including
|
|
60
|
+
stencil discovery (`stencil_info`, `stencil_sheet`), whole-drawing snapshots (`snapshot`)
|
|
61
|
+
and a self-describing `capabilities` action.
|
|
62
|
+
|
|
63
|
+
## Five-minute tour
|
|
64
|
+
|
|
65
|
+
> Illustrated walkthrough (Chinese): [docs/GETTING-STARTED.md](docs/GETTING-STARTED.md).
|
|
66
|
+
|
|
67
|
+
The first time you open the panel, the empty canvas carries a four-step card; the **?**
|
|
68
|
+
button in the header reopens it at any time ("Don't show again" only hides the card).
|
|
69
|
+
|
|
70
|
+
1. **Pick a folder** — the panel follows the workspace by default, so those `.vsdx` files are already listed (use … to switch). It may only write inside folders you opened — that is the path guard's edge.
|
|
71
|
+
2. **Open or create** — open a file, or create a blank drawing. Saves write back in place and
|
|
72
|
+
leave a `<name>.bak-<timestamp>` beside it.
|
|
73
|
+
3. **Edit on the canvas** — select a shape to change text, position and fill; drag the dots on
|
|
74
|
+
a shape edge to draw a connector; Space + drag pans, the wheel zooms, Ctrl+Z / Ctrl+D /
|
|
75
|
+
Delete behave as usual.
|
|
76
|
+
4. **Let the agent draw** — ask for "a login flow diagram"; the model calls the same `visio`
|
|
77
|
+
tool. The **Agent** switch in the header takes that permission away at any time (panel
|
|
78
|
+
editing is unaffected).
|
|
79
|
+
|
|
80
|
+
## Install
|
|
81
|
+
|
|
82
|
+
**From the plugin market (recommended):** open Settings → Plugins in DSH, search `dsh-visio`, install. Or:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
dsh plugin --profile desktop add dsh-visio
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
npm package: <https://www.npmjs.com/package/dsh-visio> (`latest` = 1.24.1).
|
|
89
|
+
|
|
90
|
+
To see it under **Plugins → Discover**, add the community index source:
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
Settings → Plugins → Discover → Index sources
|
|
94
|
+
https://cdn.jsdelivr.net/npm/dsh-plugin-catalog/index.json
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
GitHub source still works as a fallback:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
dsh plugin --profile desktop add github:SamyiHu/dsh-visio
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Local development:** add `"dsh-visio": "link:/absolute/path/to/dsh-visio"` to the profile
|
|
104
|
+
`package.json`, run `pnpm install`, then reload the app. The bundle patch
|
|
105
|
+
`cordis.patch.yml` inserts the plugin automatically.
|
|
106
|
+
|
|
107
|
+
Requires Python 3.9+ on `PATH` (or set `pythonPath` in the plugin config / `DSH_VISIO_PYTHON`). For PNG export / snapshots / stencil previews, install Pillow for that interpreter: `python -m pip install Pillow`.
|
|
108
|
+
|
|
109
|
+
## Usage
|
|
110
|
+
|
|
111
|
+
- Sidebar → **Visio 图纸** opens the panel; the floating orb (bottom right, expands into a
|
|
112
|
+
capsule on hover) puts the same panel in a draggable window.
|
|
113
|
+
- **Multiple drawings open like VS Code tabs**: clicking a `.vsdx` in the file list adds a tab
|
|
114
|
+
that can be switched and closed (`×`), remembered across restarts. The sidebar and the
|
|
115
|
+
floating window keep their own tabs, so one can show the agent's drawing while the other
|
|
116
|
+
shows a reference drawing.
|
|
117
|
+
- Pick a folder, click a `.vsdx`; the left tree lists pages and shapes, the right pane edits
|
|
118
|
+
the selection.
|
|
119
|
+
- From the agent side: ask for a drawing. The 42 actions are split into **four tools**, like the UART plugin's `uart_serial` / `uart_view`: `visio_view` (inspect), `visio_draw` (edit), `visio_connect` (connectors), `visio_export` (rendering). Actions:
|
|
120
|
+
`open`, `text`, `get_shape`, `list`, `create`, `add_shape`, `add_freeform`, `move`, `align`, `swimlane`,
|
|
121
|
+
`set_text`, `set_cell`, `set_prop`, `delete`, `duplicate`, `validate`, `audit_full`,
|
|
122
|
+
`connect`, `connect_styled`, `probe`, `route_style`, `set_route`, `bend`, `clear_route`,
|
|
123
|
+
`move_endpoint`, `set_end_direction`, `add_anchor`, `kinds`, `guide`, `shape_list`, `shape_save`,
|
|
124
|
+
`stencils`, `stencil_info`, `stencil_sheet`, `stencil_add`, `snapshot`, `capabilities`,
|
|
125
|
+
`undo`, `redo`, `normalize`, `export`.
|
|
126
|
+
`examples/basic-shapes.vssx` is a three-master stencil used by the tests.
|
|
127
|
+
|
|
128
|
+
The tool schema's `action` enum is generated from the implementation table:
|
|
129
|
+
**an advertised action always has an implementation, and an implemented action is always
|
|
130
|
+
advertised**; the parameter table and the arguments each handler reads are kept aligned by
|
|
131
|
+
the tests (`tests/test_host_contract.mjs`). Any failure is returned as a **tool error**
|
|
132
|
+
instead of success-looking text.
|
|
133
|
+
|
|
134
|
+
## Configuration
|
|
135
|
+
|
|
136
|
+
| key | default | meaning |
|
|
137
|
+
|---|---|---|
|
|
138
|
+
| `pythonPath` | `python` | interpreter used for the engine |
|
|
139
|
+
| `defaultFolder` | workspace dir | where the file browser starts |
|
|
140
|
+
| `agentTool` | `true` | whether the `visio` tool is registered for the agent; the Agent switch in the panel header toggles it at runtime (remembered in `~/.dsh/visio-agent.json`), `false` starts disabled |
|
|
141
|
+
|
|
142
|
+
## Compatibility
|
|
143
|
+
|
|
144
|
+
| component | requirement | notes |
|
|
145
|
+
|---|---|---|
|
|
146
|
+
| Node.js | **>= 18** | Host half `index.js` uses ESM, `node:` imports and `import.meta.url`; CI runs on Node 20 |
|
|
147
|
+
| Python | **>= 3.9** | Engine interpreter: `python` on Windows, `python3` elsewhere; override with `pythonPath` / `DSH_VISIO_PYTHON`. CI runs on 3.12 |
|
|
148
|
+
| Pillow | optional | Only PNG export, `snapshot` and stencil previews need it; core read/write and SVG rendering are stdlib |
|
|
149
|
+
| DSH host | `>=0.1.7-rc.2` (`dsh.engines.dsh`); **guaranteed on `0.2.2-rc.1`** | desktop profile / Web UI plugin. The build it was first developed against (2026-10-28 first commit) works, but its exact version was not recorded; some earlier builds may work and are not guaranteed. `peerDependencies["@deepseek-ai/dsh"]` lists each prerelease branch explicitly so semver does not silently exclude prereleases |
|
|
150
|
+
|
|
151
|
+
Machine-readable declarations live in `package.json`: `engines.node`, `dsh.engines.dsh` (informational; pnpm only WARNs by default) and `peerDependencies["@deepseek-ai/dsh"]` (the range npm/pnpm actually validates). Python / Pillow are runtime prerequisites of the plugin itself, see above.
|
|
152
|
+
|
|
153
|
+
## Architecture
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
index.js Host entry point: wires routes and the tool (~150 lines)
|
|
157
|
+
lib/bridge.js Python child pool, engine fingerprint, timeouts
|
|
158
|
+
lib/paths.js Write guard: only folders opened in the panel
|
|
159
|
+
lib/http.js route() / JSON / same-origin helpers
|
|
160
|
+
lib/schema.js Tool parameter table + action help text
|
|
161
|
+
lib/actions.js 41 action handlers (the schema enum is generated from these)
|
|
162
|
+
lib/format.js bridge state -> the text the model reads
|
|
163
|
+
lib/agent-tool.js `visio` tool registration + the ~/.dsh switch
|
|
164
|
+
client.js Client half: panel, floating window, inspector, i18n
|
|
165
|
+
scripts/check.mjs Dependency-free structural check (syntax, py_compile, action parity, version)
|
|
166
|
+
engine/vsdx_core.py Reader/editor/renderer (OPC + XML, stdlib only; PNG paths use Pillow)
|
|
167
|
+
engine/visio_bridge.py JSON line protocol used by the Host
|
|
168
|
+
engine/blank_doc.py Creates a minimal valid .vsdx from scratch
|
|
169
|
+
engine/kinds.py 16 built-in shape kinds (ShapeSheet geometry rows + Rounding)
|
|
170
|
+
engine/stencil.py .vssx/.vstx import
|
|
171
|
+
tests/ engine, tool end-to-end, client-render, client-contract, host-contract
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
The Host keeps one engine child process per interpreter and **restarts it when any
|
|
175
|
+
`engine/*.py` / `engine/*.json` file changes** (mtime + size fingerprint, file list from a
|
|
176
|
+
directory scan instead of a hand-kept list), so edits never run on stale code.
|
|
177
|
+
|
|
178
|
+
## Development
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
npm run check # 1s: JS syntax, py_compile, handler<->engine parity, CLIENT_BUILD==version, files[] coverage
|
|
182
|
+
npm test # everything: 40 engine cases + tool end-to-end + host contract + render + client contract
|
|
183
|
+
|
|
184
|
+
python tests/test_engine.py # engine: edits, connectors, undo, export, snapshots, style-injection guards
|
|
185
|
+
python tests/test_svg_raster.py # PNG paints the panel's SVG: element coverage, rotation, dashes, arrows, CJK fonts
|
|
186
|
+
node tests/test_tool_integration.mjs # end-to-end: real engine drives build→connect→audit→export→undo
|
|
187
|
+
node tests/test_host_contract.mjs # tool schema ↔ handler table ↔ bridge actions, path guard, fingerprint, real round trip
|
|
188
|
+
node tests/test_client_contract.mjs # zh/en key parity, no hard-coded Chinese, no debug leftovers, CLIENT_BUILD == package version
|
|
189
|
+
node tests/test_client_render.mjs # renders panel/inspector/dialog headlessly
|
|
190
|
+
node tests/make_uicheck.mjs # inspector layout page, measurable in a real browser
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
The published package ships `tests/`, so the suite can run straight from `node_modules`.
|
|
194
|
+
|
|
195
|
+
## Limitations
|
|
196
|
+
|
|
197
|
+
- **The preview is an SVG approximation, and it says where**: embedded pictures, linear gradients,
|
|
198
|
+
drop shadows, vertical text, hatch patterns and paragraph bullets all render; style resolution
|
|
199
|
+
follows StyleSheet inheritance chains down to the base sheet. What stays approximate (two-stop
|
|
200
|
+
gradients, offset-only shadows, line hatches) is listed in `previewGaps` and surfaced as an
|
|
201
|
+
amber chip in the panel; text metrics are real, line spacing and word-breaking are not Visio's.
|
|
202
|
+
- **Saves take an advisory lock**: a `*.dsh-visio.lock` file appears beside the drawing while it
|
|
203
|
+
is written and expires after 120s, so two DSH windows or agents cannot clobber each other -
|
|
204
|
+
Visio does not honour it, so do not edit the same file there. `.vsdm` macros never run but a
|
|
205
|
+
digital signature is invalidated.
|
|
206
|
+
- **Writes go through the path guard**: only folders opened in the panel, and `export` must be
|
|
207
|
+
`.svg`/`.png` and must not point at the drawing itself.
|
|
208
|
+
|
|
209
|
+
## Licence
|
|
210
|
+
|
|
211
|
+
MIT — see [LICENSE](LICENSE). No third-party fixtures are bundled; tests build their own documents.
|
|
212
|
+
|
|
213
|
+
## CI
|
|
214
|
+
|
|
215
|
+
`.github/workflows/ci.yml` runs on every push/PR across Linux and Windows:
|
|
216
|
+
|
|
217
|
+
- `node --check` on both halves, `py_compile` on the engine
|
|
218
|
+
- `tests/test_engine.py` (40 cases: edits, connectors, undo, exports, snapshots)
|
|
219
|
+
- `tests/test_client_render.mjs` and `tests/test_client_contract.mjs` (slots + translations)
|
|
220
|
+
- `tests/test_host_contract.mjs` (tool schema, handler table, path guard, real bridge round trip)
|
|
221
|
+
|
|
222
|
+
`release.yml` publishes a zip on every `v*` tag, after the same test suite, and refuses a tag
|
|
223
|
+
that does not match `package.json` version.
|
package/README.md
CHANGED
|
@@ -1,3 +1,194 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-visio
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/SamyiHu/dsh-visio/actions/workflows/ci.yml)
|
|
4
|
+
|
|
5
|
+
**在 DeepSeek Harness(DSH)Web 界面里直接看和改 Visio 图纸(.vsdx)的插件**:实时预览、形状编辑,外加四个给 Agent 用的工具(`visio_view` / `visio_draw` / `visio_connect` / `visio_export`)。
|
|
6
|
+
|
|
7
|
+
引擎主体(.vsdx 读写、渲染、编辑)只用 Python 标准库,**不需要装 Visio,也不依赖 Office**;PNG 导出、`snapshot` 快照和模具预览图额外需要 [Pillow](https://pillow.readthedocs.io/)(`engine/svg_raster.py`)。
|
|
8
|
+
|
|
9
|
+
[English](README.en.md) · 简体中文
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+

|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
## ⚠️ 测试版本 · 请先备份
|
|
16
|
+
|
|
17
|
+
> **这个项目还在测试阶段,请在使用前备份你的原始 `.vsdx` 文件。**
|
|
18
|
+
>
|
|
19
|
+
> - 插件会**直接写入**你打开的图纸文件。每次保存前会在旁边自动生成一份 `.bak`(保留最近 20 份),
|
|
20
|
+
> 但备份**不能覆盖所有情况**:同时在 Visio 里编辑同一文件、断电/崩溃、网盘同步冲突、
|
|
21
|
+
> 其它工具写入等,都可能让文件损坏或改动丢失。
|
|
22
|
+
> - **因使用本插件造成的文件损坏、数据丢失或任何其它损失,由使用者自行承担风险**;
|
|
23
|
+
> 作者不提供任何明示或暗示的担保(详见 MIT 许可证)。
|
|
24
|
+
> - 重要图纸请先复制一份再用本插件打开;生产环境请等正式版。
|
|
25
|
+
|
|
26
|
+
## 截图
|
|
27
|
+
|
|
28
|
+
| 面板:图纸 + 属性检查器 | 多标签:两张图并排对比 |
|
|
29
|
+
|---|---|
|
|
30
|
+
|  |  |
|
|
31
|
+
|
|
32
|
+
| 浮动画布(右下悬浮球打开) | 首次打开:四步引导 |
|
|
33
|
+
|---|---|
|
|
34
|
+
|  |  |
|
|
35
|
+
|
|
36
|
+
## 展示案例
|
|
37
|
+
|
|
38
|
+
| [全球订单履约](examples/showcase/showcase-1-global-fulfilment.vsdx)<br>4 泳道 / 15 节点 / 3 决策门 / 3 条退回线 | [平台逻辑架构](examples/showcase/showcase-2-platform-architecture.vsdx)<br>接入 / 服务 / 数据三层容器 + 外部系统 |
|
|
39
|
+
|---|---|
|
|
40
|
+
|  |  |
|
|
41
|
+
|
|
42
|
+
## 功能
|
|
43
|
+
|
|
44
|
+
- **实时预览**:面板把 `.vsdx` 页面渲染成 SVG,每次改动后立即重绘。
|
|
45
|
+
- **就地编辑**:移动/缩放、文字、填充、线条、逐行文字颜色、形状数据。
|
|
46
|
+
- **形状库**:内置 16 种图形(流程、判定、起止……),支持导入 `.vssx` / `.vstx` 模具;内置图形写成 ShapeSheet 几何行(`RelMoveTo`/`RelLineTo` + `Rounding` 单元格),不是预览层画的线,所以 Visio 里打开也是同一个轮廓。
|
|
47
|
+
- **连接线**:新增、加标签、删除;线自己的颜色/线宽/箭头都保留,标签从 1-D 形状的文字里读。
|
|
48
|
+
- **关系检查**:`validate` 能找出空连接(没有 `Connect` 行的线)、悬空 ID、漂移端点、零尺寸形状。
|
|
49
|
+
- **多页、缩放、平移、网格、撤销/重做**,以及文件被外部修改时的自动检测。
|
|
50
|
+
- **Agent 工具**:同一套能力按域拆成四个工具暴露给模型,含模具发现(`stencil_info`、`stencil_sheet`)、整图快照(`snapshot`)和自描述的 `capabilities`。
|
|
51
|
+
|
|
52
|
+
## 五分钟上手
|
|
53
|
+
|
|
54
|
+
> 图文版新手教程:[docs/GETTING-STARTED.md](docs/GETTING-STARTED.md)(10 分钟,含真实面板截图与常见问题)。
|
|
55
|
+
|
|
56
|
+
第一次打开面板,空画布上会有一张四步指引卡;点标题栏的 **?** 可以随时重新打开(「不再显示」只关掉这张卡,不影响功能)。
|
|
57
|
+
|
|
58
|
+
1. **选文件夹** — 面板默认**跟随工作目录**(Agent 正在用的那个),左侧直接列出里面的 `.vsdx`(换目录点「…」)。面板只允许写入你打开过 / 跟随过的目录,这是路径守卫的边界。
|
|
59
|
+
2. **打开或新建** — 点一个文件打开,或「新建」一张空白图纸;保存直接写回原文件,并在旁边留 `<文件名>.bak-<时间戳>`。
|
|
60
|
+
3. **直接改图** — 点选形状改文字、位置、填充;拖图形边上的圆点拉出连线;空格 + 拖动平移,滚轮缩放,Ctrl+Z / Ctrl+D / Delete 照常。
|
|
61
|
+
4. **让 Agent 画** — 直接说「画一张登录流程图」,模型调用的是同一个 `visio` 工具;标题栏的 **Agent** 开关可以随时收回这个权限(面板编辑不受影响)。
|
|
62
|
+
|
|
63
|
+
## 插件页里的两个组件
|
|
64
|
+
|
|
65
|
+
设置 → 插件 → dsh-visio 会列出**两个组件**(和串口插件一样):
|
|
66
|
+
|
|
67
|
+
| 组件 | 内容 |
|
|
68
|
+
|---|---|
|
|
69
|
+
| `Visio 图纸`(local-visio) | 面板:画布、属性检查器、标签、悬浮球、`/dsh-visio/*` 路由 |
|
|
70
|
+
| **Visio 工具**(`dsh-visio/tools`) | 四个分组工具 `visio_view` / `visio_draw` / `visio_connect` / `visio_export` |
|
|
71
|
+
|
|
72
|
+
两行共享同一个开关:面板头部的 Agent 开关写 `~/.dsh/visio-agent.json`,工具行订阅同一个事件总线,立刻注册/注销工具。
|
|
73
|
+
|
|
74
|
+
## 安装
|
|
75
|
+
|
|
76
|
+
**从插件市场安装(推荐)**:DSH 里打开 Settings → Plugins,搜 `dsh-visio` 点安装;或命令行:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
dsh plugin --profile desktop add dsh-visio
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
npm 包:<https://www.npmjs.com/package/dsh-visio>(`latest` = 1.24.1)。
|
|
83
|
+
|
|
84
|
+
想在 **Plugins → Discover / 插件市场** 里看到它,需要先给 DSH 加一个索引源:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
Settings → Plugins → Discover → Index sources
|
|
88
|
+
https://cdn.jsdelivr.net/npm/dsh-plugin-catalog/index.json
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
GitHub 源仍可直装(备用):
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
dsh plugin --profile desktop add github:SamyiHu/dsh-visio
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**本地开发**:在 profile 的 `package.json` 里加 `"dsh-visio": "link:/absolute/path/to/dsh-visio"`,执行 `pnpm install`,再重载应用。插件自带 `cordis.patch.yml`,会自动插入。
|
|
98
|
+
|
|
99
|
+
需要 `PATH` 里有 Python 3.9+(或在插件配置里设 `pythonPath`,或设环境变量 `DSH_VISIO_PYTHON`);若要用 PNG 导出 / 快照 / 模具预览,还需为该解释器安装 Pillow:`python -m pip install Pillow`。
|
|
100
|
+
|
|
101
|
+
## 使用
|
|
102
|
+
|
|
103
|
+
- 侧栏 → **Visio 图纸** 打开面板;右下角的悬浮球(悬停展开成胶囊)把同一块面板放进可拖动的独立窗口。
|
|
104
|
+
- **多开像 VS Code 一样用标签**:点左侧文件列表里的 `.vsdx` 就多开一个标签,标签上可切换、`×` 关闭,状态会记住;侧栏和浮窗各有自己的标签,所以可以「侧栏看一张、浮窗看另一张」做对比。
|
|
105
|
+
- 选目录 → 点一个 `.vsdx`:左边树列页面和形状,右边改选中形状的属性。
|
|
106
|
+
- Agent 侧直接说需求即可。42 个动作按域拆成 **4 个工具**(和串口插件的 `uart_serial` / `uart_view` 一样分开显示):`visio_view`(看/查/审)、`visio_draw`(画/改)、`visio_connect`(连线)、`visio_export`(导出)。每个动作:
|
|
107
|
+
`open`、`text`、`get_shape`、`list`、`create`、`add_shape`、`add_freeform`、`move`、`align`、`swimlane`、
|
|
108
|
+
`set_text`、`set_cell`、`set_prop`、`delete`、`duplicate`、`validate`、`audit_full`、
|
|
109
|
+
`connect`、`connect_styled`、`probe`、`route_style`、`set_route`、`bend`、`clear_route`、
|
|
110
|
+
`move_endpoint`、`set_end_direction`、`add_anchor`、`kinds`、`guide`、`shape_list`、`shape_save`、
|
|
111
|
+
`stencils`、`stencil_info`、`stencil_sheet`、`stencil_add`、`snapshot`、`capabilities`、
|
|
112
|
+
`undo`、`redo`、`normalize`、`export`。
|
|
113
|
+
`examples/basic-shapes.vssx` 是测试用的三母版模具。
|
|
114
|
+
|
|
115
|
+
工具 schema 的 `action` 枚举由实现表自动生成:**广告了就一定有实现,有实现就一定广告**;
|
|
116
|
+
参数表与 handler 读取的参数由测试互相对齐(`tests/test_host_contract.mjs`)。任何失败都以
|
|
117
|
+
**工具报错**返回,不再伪装成成功文本。
|
|
118
|
+
|
|
119
|
+
## 配置
|
|
120
|
+
|
|
121
|
+
| 键 | 默认值 | 含义 |
|
|
122
|
+
|---|---|---|
|
|
123
|
+
| `pythonPath` | `python` | 引擎使用的解释器 |
|
|
124
|
+
| `defaultFolder` | 工作目录 | 文件浏览器起始目录;不设时面板跟随工作目录(标题栏「✓ 跟随工作目录」可切换为手动) |
|
|
125
|
+
| `agentTool` | `true` | 是否把 `visio` 工具注册给 Agent;面板头部的 Agent 开关可随时运行时切换(记忆在 `~/.dsh/visio-agent.json`),设为 `false` 则默认关闭 |
|
|
126
|
+
|
|
127
|
+
## 兼容性
|
|
128
|
+
|
|
129
|
+
| 组件 | 要求 | 说明 |
|
|
130
|
+
|---|---|---|
|
|
131
|
+
| Node.js | **≥ 18** | 宿主半 `index.js` 用 ESM + `node:` 前缀导入 + `import.meta.url`;CI 在 Node 20 上跑 |
|
|
132
|
+
| Python | **≥ 3.9** | 引擎解释器,默认 Windows 用 `python`、其他系统用 `python3`;可用 `pythonPath` / `DSH_VISIO_PYTHON` 指定。CI 在 3.12 上跑 |
|
|
133
|
+
| Pillow | 可选 | 仅 PNG 导出、`snapshot`、模具预览需要;核心读写与 SVG 渲染是标准库 |
|
|
134
|
+
| DSH 宿主 | `>=0.1.7-rc.2`(`dsh.engines.dsh`);**保证 `0.2.2-rc.1`** | desktop profile / Web UI 插件。初制作期(2026-10-28 首版)的版本可用但仓库未记录确切号;更早的部分 0.2.x 之前版本可能可用、不保证。`peerDependencies["@deepseek-ai/dsh"]` 显式列出各预发布分支,避免 semver 静默排除 prerelease |
|
|
135
|
+
|
|
136
|
+
机器可读声明在 `package.json`:`engines.node`、`dsh.engines.dsh`(声明性,pnpm 默认只 WARN)与 `peerDependencies["@deepseek-ai/dsh"]`(npm/pnpm 真正校验的范围)。Python / Pillow 为插件自身运行前置,见上表。
|
|
137
|
+
|
|
138
|
+
## 结构
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
index.js Host 侧入口:装配路由与工具(约 150 行)
|
|
142
|
+
lib/bridge.js Python 子进程池、引擎指纹、请求超时
|
|
143
|
+
lib/paths.js 写入守卫:只允许面板打开过的目录
|
|
144
|
+
lib/http.js route() / JSON / 同源校验
|
|
145
|
+
lib/schema.js 工具参数表 + action 帮助文本
|
|
146
|
+
lib/actions.js 42 个 action 的 handler(schema 枚举由此生成)
|
|
147
|
+
lib/format.js bridge state → 给模型读的文本
|
|
148
|
+
lib/agent-tool.js `visio` 工具注册 + ~/.dsh 开关
|
|
149
|
+
client.js Client 侧:面板、浮窗、属性检查器、i18n
|
|
150
|
+
scripts/check.mjs 零依赖结构检查(语法、py_compile、action 对账、版本一致)
|
|
151
|
+
engine/vsdx_core.py 读写渲染核心(OPC + XML,纯标准库)
|
|
152
|
+
engine/visio_bridge.py Host 调用的 JSON 行协议
|
|
153
|
+
engine/blank_doc.py 从零生成最小可用 .vsdx
|
|
154
|
+
engine/kinds.py 16 种内置图形(ShapeSheet 几何行 + Rounding)
|
|
155
|
+
engine/stencil.py .vssx/.vstx 导入
|
|
156
|
+
tests/ 引擎、工具端到端、客户端渲染、客户端契约、Host 契约
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Host 按解释器各留一个引擎子进程,并**在任意 `engine/*.py` / `engine/*.json` 变化时重启**(mtime + size 指纹,文件列表用目录扫描得到,不再手工维护),避免改完还跑旧代码。
|
|
160
|
+
|
|
161
|
+
## 开发与测试
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
npm run check # 1 秒:JS 语法、py_compile、handler↔引擎对账、CLIENT_BUILD==版本、files[] 覆盖
|
|
165
|
+
npm test # 全量:引擎 40 例 + 工具端到端 + Host 契约 + 面板渲染 + 客户端契约
|
|
166
|
+
|
|
167
|
+
python tests/test_engine.py # 引擎:编辑、连线、撤销、导出、快照、颜色注入防护
|
|
168
|
+
python tests/test_svg_raster.py # PNG 与面板同源:元素覆盖、旋转、虚线、箭头、中文字体
|
|
169
|
+
node tests/test_tool_integration.mjs # 端到端:用真实引擎跑 visio 工具的建图→连线→检查→导出→撤销
|
|
170
|
+
node tests/test_host_contract.mjs # 工具 schema ↔ 实现表 ↔ 桥动作、路径守卫、指纹覆盖、真实桥往返
|
|
171
|
+
node tests/test_client_contract.mjs # 中英词条对齐、无硬编码中文、无调试残留、CLIENT_BUILD 与版本一致
|
|
172
|
+
node tests/test_client_render.mjs # 无头渲染面板/检查器/新建对话框
|
|
173
|
+
node tests/make_uicheck.mjs # 生成右栏布局页,可在真浏览器里量尺寸
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
发布包包含 `tests/`,装到 `node_modules` 之后也能直接跑。
|
|
177
|
+
|
|
178
|
+
## 已知限制
|
|
179
|
+
|
|
180
|
+
- **预览是 SVG 近似,但会明说哪里近似**:嵌入图片、线性渐变、投影、竖排文字、图案填充、项目符号
|
|
181
|
+
都会画;样式继承会沿着 StyleSheet 链一路取到基表。仍然近似的部分(渐变只按两色线性、
|
|
182
|
+
阴影只按轮廓偏移、图案按线纹)会列在 `previewGaps` 里,面板底栏显示 `预览近似` 标签;
|
|
183
|
+
文字换行按真实字体度量算,行距/断词仍和 Visio 排版引擎有差。
|
|
184
|
+
- **保存有协作锁**:写之前会在图纸旁建 `*.dsh-visio.lock`(120 秒超时自动失效),两个 DSH 窗口/Agent 同时写会被拒绝;但 Visio 不认这把锁,别在 Visio 里同时改同一张;`.vsdm` 宏不执行,数字签名会失效。
|
|
185
|
+
- **写入受路径守卫限制**:只能写面板打开过的目录,`export` 必须是 `.svg`/`.png` 且不能指向原图。
|
|
186
|
+
|
|
187
|
+
## CI / CD
|
|
188
|
+
|
|
189
|
+
- `ci.yml`:push/PR 在 **Linux + Windows** 双矩阵跑语法检查、引擎 40 例、客户端契约、Host 契约,通过后产出整包 zip 附件。
|
|
190
|
+
- `release.yml`:打 `v*` tag 自动发 Release;**tag 与 `package.json` 版本不一致直接失败**。
|
|
191
|
+
|
|
192
|
+
## 许可
|
|
193
|
+
|
|
194
|
+
MIT,见 [LICENSE](LICENSE)。仓库不含第三方样例文件,测试自己生成文档。
|