dsh-visio 1.24.1 → 1.24.10
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/README.en.md +116 -42
- package/README.md +103 -38
- package/client.js +4274 -3210
- package/cordis.patch.yml +12 -1
- package/engine/svg_raster.py +646 -140
- package/engine/text_metrics.py +85 -0
- package/engine/visio_bridge.py +1845 -1633
- package/engine/vsdx_core.py +3600 -2891
- package/index.js +118 -876
- 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/package.json +18 -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/engine/vsdx_png.py +0 -254
package/README.en.md
CHANGED
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
[](https://github.com/SamyiHu/dsh-visio/actions/workflows/ci.yml)
|
|
4
4
|
|
|
5
5
|
A native **Visio (.vsdx) viewer and editor for the DeepSeek Harness (DSH) Web UI**, with a
|
|
6
|
-
live preview, shape editing and
|
|
6
|
+
live preview, shape editing and four agent tools (`visio_view` / `visio_draw` / `visio_connect` / `visio_export`). The core engine is Python standard
|
|
7
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/
|
|
9
|
-
`engine/svg_raster.py`).
|
|
8
|
+
previews additionally need [Pillow](https://pillow.readthedocs.io/) (`engine/svg_raster.py`).
|
|
10
9
|
|
|
11
10
|
English · [简体中文](README.md)
|
|
12
11
|
|
|
@@ -15,42 +14,69 @@ English · [简体中文](README.md)
|
|
|
15
14
|

|
|
16
15
|
|
|
17
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
|
+
|
|
18
30
|
## Screenshots
|
|
19
31
|
|
|
20
|
-
| Panel |
|
|
32
|
+
| Panel: drawing + inspector | Tabs: two drawings side by side |
|
|
21
33
|
|---|---|
|
|
22
|
-
|  |  |
|
|
25
35
|
|
|
26
|
-
|
|
36
|
+
| Floating canvas (right-hand orb) | First run: the four-step guide |
|
|
37
|
+
|---|---|
|
|
38
|
+
|  |  |
|
|
27
39
|
|
|
28
40
|
## Showcase
|
|
29
41
|
|
|
30
|
-
|
|
|
31
|
-
|
|
32
|
-
| [
|
|
33
|
-
| [Platform architecture](examples/showcase/showcase-2-platform-architecture.vsdx) | Edge / service / data layers plus external systems | zh · en · ru |
|
|
34
|
-
|
|
35
|
-

|
|
36
|
-
|
|
37
|
-

|
|
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
|
+
|  |  |
|
|
38
45
|
|
|
39
46
|
## Features
|
|
40
47
|
|
|
41
48
|
- **Live preview** – the panel renders the `.vsdx` page to SVG and repaints after every edit.
|
|
42
49
|
- **Edit in place** – move / resize, text, fill, line, per-run text colour, shape data.
|
|
43
50
|
- **Shape library** – 16 built-in kinds (process, decision, terminator, …) plus
|
|
44
|
-
`.vssx`/`.vstx` stencil import;
|
|
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.
|
|
45
54
|
- **Connectors** – add, label, delete; connectors keep their own line colour, weight and
|
|
46
55
|
arrow heads, and their labels are read from the 1-D shape text.
|
|
47
56
|
- **Relationship audit** – `validate` finds empty links (connectors with no `Connect` rows),
|
|
48
57
|
dangling ids, floating endpoints and zero-size shapes.
|
|
49
58
|
- **Multi-page, zoom, pan, grid, undo/redo**, external-change detection.
|
|
50
|
-
- **Agent
|
|
59
|
+
- **Agent tools** – the same operations are exposed as four domain tools, including
|
|
51
60
|
stencil discovery (`stencil_info`, `stencil_sheet`), whole-drawing snapshots (`snapshot`)
|
|
52
61
|
and a self-describing `capabilities` action.
|
|
53
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
|
+
|
|
54
80
|
## Install
|
|
55
81
|
|
|
56
82
|
**From the plugin market (recommended):** open Settings → Plugins in DSH, search `dsh-visio`, install. Or:
|
|
@@ -59,10 +85,20 @@ Select a connector to change its end directions and line style:
|
|
|
59
85
|
dsh plugin --profile desktop add dsh-visio
|
|
60
86
|
```
|
|
61
87
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
88
|
+
npm package: <https://www.npmjs.com/package/dsh-visio> (see the npm page for `latest`).
|
|
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
|
+
```
|
|
66
102
|
|
|
67
103
|
**Local development:** add `"dsh-visio": "link:/absolute/path/to/dsh-visio"` to the profile
|
|
68
104
|
`package.json`, run `pnpm install`, then reload the app. The bundle patch
|
|
@@ -72,15 +108,28 @@ Requires Python 3.9+ on `PATH` (or set `pythonPath` in the plugin config / `DSH_
|
|
|
72
108
|
|
|
73
109
|
## Usage
|
|
74
110
|
|
|
75
|
-
- Sidebar → **Visio 图纸** opens the panel; the floating
|
|
76
|
-
|
|
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.
|
|
77
117
|
- Pick a folder, click a `.vsdx`; the left tree lists pages and shapes, the right pane edits
|
|
78
118
|
the selection.
|
|
79
|
-
- From the agent side: ask for a drawing
|
|
80
|
-
|
|
81
|
-
`
|
|
82
|
-
`
|
|
83
|
-
`
|
|
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.
|
|
84
133
|
|
|
85
134
|
## Configuration
|
|
86
135
|
|
|
@@ -88,6 +137,7 @@ Requires Python 3.9+ on `PATH` (or set `pythonPath` in the plugin config / `DSH_
|
|
|
88
137
|
|---|---|---|
|
|
89
138
|
| `pythonPath` | `python` | interpreter used for the engine |
|
|
90
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 |
|
|
91
141
|
|
|
92
142
|
## Compatibility
|
|
93
143
|
|
|
@@ -103,34 +153,58 @@ Machine-readable declarations live in `package.json`: `engines.node`, `dsh.engin
|
|
|
103
153
|
## Architecture
|
|
104
154
|
|
|
105
155
|
```
|
|
106
|
-
index.js Host
|
|
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
|
|
107
164
|
client.js Client half: panel, floating window, inspector, i18n
|
|
165
|
+
scripts/check.mjs Dependency-free structural check (syntax, py_compile, action parity, version)
|
|
108
166
|
engine/vsdx_core.py Reader/editor/renderer (OPC + XML, stdlib only; PNG paths use Pillow)
|
|
109
167
|
engine/visio_bridge.py JSON line protocol used by the Host
|
|
110
168
|
engine/blank_doc.py Creates a minimal valid .vsdx from scratch
|
|
111
|
-
engine/kinds.py 16 built-in shape kinds (
|
|
169
|
+
engine/kinds.py 16 built-in shape kinds (ShapeSheet geometry rows + Rounding)
|
|
112
170
|
engine/stencil.py .vssx/.vstx import
|
|
113
|
-
tests/ engine, client-render, client-contract, host-contract
|
|
171
|
+
tests/ engine, tool end-to-end, client-render, client-contract, host-contract
|
|
114
172
|
```
|
|
115
173
|
|
|
116
174
|
The Host keeps one engine child process per interpreter and **restarts it when any
|
|
117
|
-
`engine/*.py` file changes** (mtime + size fingerprint
|
|
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.
|
|
118
177
|
|
|
119
178
|
## Development
|
|
120
179
|
|
|
121
180
|
```bash
|
|
122
|
-
|
|
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
|
|
123
189
|
node tests/test_client_render.mjs # renders panel/inspector/dialog headlessly
|
|
124
|
-
node tests/test_client_contract.mjs # i18n keys + slot contract
|
|
125
|
-
node tests/test_host_contract.mjs # tool schema + routes + bridge round trip
|
|
126
190
|
node tests/make_uicheck.mjs # inspector layout page, measurable in a real browser
|
|
127
191
|
```
|
|
128
192
|
|
|
193
|
+
The published package ships `tests/`, so the suite can run straight from `node_modules`.
|
|
194
|
+
|
|
129
195
|
## Limitations
|
|
130
196
|
|
|
131
|
-
-
|
|
132
|
-
|
|
133
|
-
|
|
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.
|
|
134
208
|
|
|
135
209
|
## Licence
|
|
136
210
|
|
|
@@ -141,9 +215,9 @@ MIT — see [LICENSE](LICENSE). No third-party fixtures are bundled; tests buil
|
|
|
141
215
|
`.github/workflows/ci.yml` runs on every push/PR across Linux and Windows:
|
|
142
216
|
|
|
143
217
|
- `node --check` on both halves, `py_compile` on the engine
|
|
144
|
-
- `tests/test_engine.py` (
|
|
145
|
-
- `tests/test_client_render.mjs` and `tests/test_client_contract.mjs` (slots +
|
|
146
|
-
- `tests/test_host_contract.mjs` (tool schema,
|
|
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)
|
|
147
221
|
|
|
148
222
|
`release.yml` publishes a zip on every `v*` tag, after the same test suite, and refuses a tag
|
|
149
223
|
that does not match `package.json` version.
|
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/SamyiHu/dsh-visio/actions/workflows/ci.yml)
|
|
4
4
|
|
|
5
|
-
**在 DeepSeek Harness(DSH)Web 界面里直接看和改 Visio 图纸(.vsdx
|
|
5
|
+
**在 DeepSeek Harness(DSH)Web 界面里直接看和改 Visio 图纸(.vsdx)的插件**:实时预览、形状编辑,外加四个给 Agent 用的工具(`visio_view` / `visio_draw` / `visio_connect` / `visio_export`)。
|
|
6
6
|
|
|
7
|
-
引擎主体(.vsdx 读写、渲染、编辑)只用 Python 标准库,**不需要装 Visio,也不依赖 Office**;PNG 导出、`snapshot` 快照和模具预览图额外需要 [Pillow](https://pillow.readthedocs.io/)(`engine/
|
|
7
|
+
引擎主体(.vsdx 读写、渲染、编辑)只用 Python 标准库,**不需要装 Visio,也不依赖 Office**;PNG 导出、`snapshot` 快照和模具预览图额外需要 [Pillow](https://pillow.readthedocs.io/)(`engine/svg_raster.py`)。
|
|
8
8
|
|
|
9
9
|
[English](README.en.md) · 简体中文
|
|
10
10
|
|
|
@@ -12,36 +12,64 @@
|
|
|
12
12
|

|
|
13
13
|

|
|
14
14
|
|
|
15
|
+
## ⚠️ 测试版本 · 请先备份
|
|
16
|
+
|
|
17
|
+
> **这个项目还在测试阶段,请在使用前备份你的原始 `.vsdx` 文件。**
|
|
18
|
+
>
|
|
19
|
+
> - 插件会**直接写入**你打开的图纸文件。每次保存前会在旁边自动生成一份 `.bak`(保留最近 20 份),
|
|
20
|
+
> 但备份**不能覆盖所有情况**:同时在 Visio 里编辑同一文件、断电/崩溃、网盘同步冲突、
|
|
21
|
+
> 其它工具写入等,都可能让文件损坏或改动丢失。
|
|
22
|
+
> - **因使用本插件造成的文件损坏、数据丢失或任何其它损失,由使用者自行承担风险**;
|
|
23
|
+
> 作者不提供任何明示或暗示的担保(详见 MIT 许可证)。
|
|
24
|
+
> - 重要图纸请先复制一份再用本插件打开;生产环境请等正式版。
|
|
25
|
+
|
|
15
26
|
## 截图
|
|
16
27
|
|
|
17
|
-
|
|
|
28
|
+
| 面板:图纸 + 属性检查器 | 多标签:两张图并排对比 |
|
|
18
29
|
|---|---|
|
|
19
|
-
|  |  |
|
|
20
31
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
 |  |
|
|
24
35
|
|
|
25
36
|
## 展示案例
|
|
26
37
|
|
|
27
|
-
|
|
|
28
|
-
|
|
29
|
-
| [全球订单履约](examples/showcase/showcase-1-global-fulfilment.
|
|
30
|
-
| [平台逻辑架构](examples/showcase/showcase-2-platform-architecture.vsdx) | 接入/服务/数据三层容器 + 外部系统 | 中 · 英 · 俄 |
|
|
31
|
-
|
|
32
|
-

|
|
33
|
-
|
|
34
|
-

|
|
38
|
+
| [全球订单履约](examples/showcase/showcase-1-global-fulfilment.vsdx)<br>4 泳道 / 15 节点 / 3 决策门 / 3 条退回线 | [平台逻辑架构](examples/showcase/showcase-2-platform-architecture.vsdx)<br>接入 / 服务 / 数据三层容器 + 外部系统 |
|
|
39
|
+
|---|---|
|
|
40
|
+
|  |  |
|
|
35
41
|
|
|
36
42
|
## 功能
|
|
37
43
|
|
|
38
44
|
- **实时预览**:面板把 `.vsdx` 页面渲染成 SVG,每次改动后立即重绘。
|
|
39
45
|
- **就地编辑**:移动/缩放、文字、填充、线条、逐行文字颜色、形状数据。
|
|
40
|
-
- **形状库**:内置 16 种图形(流程、判定、起止……),支持导入 `.vssx` / `.vstx`
|
|
46
|
+
- **形状库**:内置 16 种图形(流程、判定、起止……),支持导入 `.vssx` / `.vstx` 模具;内置图形写成 ShapeSheet 几何行(`RelMoveTo`/`RelLineTo` + `Rounding` 单元格),不是预览层画的线,所以 Visio 里打开也是同一个轮廓。
|
|
41
47
|
- **连接线**:新增、加标签、删除;线自己的颜色/线宽/箭头都保留,标签从 1-D 形状的文字里读。
|
|
42
48
|
- **关系检查**:`validate` 能找出空连接(没有 `Connect` 行的线)、悬空 ID、漂移端点、零尺寸形状。
|
|
43
49
|
- **多页、缩放、平移、网格、撤销/重做**,以及文件被外部修改时的自动检测。
|
|
44
|
-
- **Agent
|
|
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`,工具行订阅同一个事件总线,立刻注册/注销工具。
|
|
45
73
|
|
|
46
74
|
## 安装
|
|
47
75
|
|
|
@@ -51,10 +79,20 @@
|
|
|
51
79
|
dsh plugin --profile desktop add dsh-visio
|
|
52
80
|
```
|
|
53
81
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
82
|
+
npm 包:<https://www.npmjs.com/package/dsh-visio>(`latest` 以 npm 页面为准)。
|
|
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
|
+
```
|
|
58
96
|
|
|
59
97
|
**本地开发**:在 profile 的 `package.json` 里加 `"dsh-visio": "link:/absolute/path/to/dsh-visio"`,执行 `pnpm install`,再重载应用。插件自带 `cordis.patch.yml`,会自动插入。
|
|
60
98
|
|
|
@@ -62,20 +100,29 @@ dsh plugin --profile desktop add dsh-visio
|
|
|
62
100
|
|
|
63
101
|
## 使用
|
|
64
102
|
|
|
65
|
-
- 侧栏 → **Visio 图纸**
|
|
103
|
+
- 侧栏 → **Visio 图纸** 打开面板;右下角的悬浮球(悬停展开成胶囊)把同一块面板放进可拖动的独立窗口。
|
|
104
|
+
- **多开像 VS Code 一样用标签**:点左侧文件列表里的 `.vsdx` 就多开一个标签,标签上可切换、`×` 关闭,状态会记住;侧栏和浮窗各有自己的标签,所以可以「侧栏看一张、浮窗看另一张」做对比。
|
|
66
105
|
- 选目录 → 点一个 `.vsdx`:左边树列页面和形状,右边改选中形状的属性。
|
|
67
|
-
- Agent
|
|
68
|
-
`open`、`text`、`get_shape`、`list`、`create`、`add_shape`、`move`、`
|
|
69
|
-
`set_prop`、`
|
|
70
|
-
`
|
|
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`。
|
|
71
113
|
`examples/basic-shapes.vssx` 是测试用的三母版模具。
|
|
72
114
|
|
|
115
|
+
工具 schema 的 `action` 枚举由实现表自动生成:**广告了就一定有实现,有实现就一定广告**;
|
|
116
|
+
参数表与 handler 读取的参数由测试互相对齐(`tests/test_host_contract.mjs`)。任何失败都以
|
|
117
|
+
**工具报错**返回,不再伪装成成功文本。
|
|
118
|
+
|
|
73
119
|
## 配置
|
|
74
120
|
|
|
75
121
|
| 键 | 默认值 | 含义 |
|
|
76
122
|
|---|---|---|
|
|
77
123
|
| `pythonPath` | `python` | 引擎使用的解释器 |
|
|
78
|
-
| `defaultFolder` | 工作目录 |
|
|
124
|
+
| `defaultFolder` | 工作目录 | 文件浏览器起始目录;不设时面板跟随工作目录(标题栏「✓ 跟随工作目录」可切换为手动) |
|
|
125
|
+
| `agentTool` | `true` | 是否把 `visio` 工具注册给 Agent;面板头部的 Agent 开关可随时运行时切换(记忆在 `~/.dsh/visio-agent.json`),设为 `false` 则默认关闭 |
|
|
79
126
|
|
|
80
127
|
## 兼容性
|
|
81
128
|
|
|
@@ -91,37 +138,55 @@ dsh plugin --profile desktop add dsh-visio
|
|
|
91
138
|
## 结构
|
|
92
139
|
|
|
93
140
|
```
|
|
94
|
-
index.js Host
|
|
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 开关
|
|
95
149
|
client.js Client 侧:面板、浮窗、属性检查器、i18n
|
|
150
|
+
scripts/check.mjs 零依赖结构检查(语法、py_compile、action 对账、版本一致)
|
|
96
151
|
engine/vsdx_core.py 读写渲染核心(OPC + XML,纯标准库)
|
|
97
152
|
engine/visio_bridge.py Host 调用的 JSON 行协议
|
|
98
153
|
engine/blank_doc.py 从零生成最小可用 .vsdx
|
|
99
|
-
engine/kinds.py 16
|
|
154
|
+
engine/kinds.py 16 种内置图形(ShapeSheet 几何行 + Rounding)
|
|
100
155
|
engine/stencil.py .vssx/.vstx 导入
|
|
101
|
-
tests/
|
|
156
|
+
tests/ 引擎、工具端到端、客户端渲染、客户端契约、Host 契约
|
|
102
157
|
```
|
|
103
158
|
|
|
104
|
-
Host 按解释器各留一个引擎子进程,并**在任意 `engine/*.py` 变化时重启**(mtime + size
|
|
159
|
+
Host 按解释器各留一个引擎子进程,并**在任意 `engine/*.py` / `engine/*.json` 变化时重启**(mtime + size 指纹,文件列表用目录扫描得到,不再手工维护),避免改完还跑旧代码。
|
|
105
160
|
|
|
106
161
|
## 开发与测试
|
|
107
162
|
|
|
108
163
|
```bash
|
|
109
|
-
|
|
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 与版本一致
|
|
110
172
|
node tests/test_client_render.mjs # 无头渲染面板/检查器/新建对话框
|
|
111
|
-
node tests/test_client_contract.mjs # 翻译键 + 槽位契约
|
|
112
|
-
node tests/test_host_contract.mjs # 工具 schema + 路由 + 桥往返
|
|
113
173
|
node tests/make_uicheck.mjs # 生成右栏布局页,可在真浏览器里量尺寸
|
|
114
174
|
```
|
|
115
175
|
|
|
176
|
+
发布包包含 `tests/`,装到 `node_modules` 之后也能直接跑。
|
|
177
|
+
|
|
116
178
|
## 已知限制
|
|
117
179
|
|
|
118
|
-
- SVG
|
|
119
|
-
|
|
120
|
-
|
|
180
|
+
- **预览是 SVG 近似,但会明说哪里近似**:嵌入图片、线性渐变、投影、竖排文字、图案填充、项目符号
|
|
181
|
+
都会画;样式继承会沿着 StyleSheet 链一路取到基表。仍然近似的部分(渐变只按两色线性、
|
|
182
|
+
阴影只按轮廓偏移、图案按线纹)会列在 `previewGaps` 里,面板底栏显示 `预览近似` 标签;
|
|
183
|
+
文字换行按真实字体度量算,行距/断词仍和 Visio 排版引擎有差。
|
|
184
|
+
- **保存有协作锁**:写之前会在图纸旁建 `*.dsh-visio.lock`(120 秒超时自动失效),两个 DSH 窗口/Agent 同时写会被拒绝;但 Visio 不认这把锁,别在 Visio 里同时改同一张;`.vsdm` 宏不执行,数字签名会失效。
|
|
185
|
+
- **写入受路径守卫限制**:只能写面板打开过的目录,`export` 必须是 `.svg`/`.png` 且不能指向原图。
|
|
121
186
|
|
|
122
187
|
## CI / CD
|
|
123
188
|
|
|
124
|
-
- `ci.yml`:push/PR 在 **Linux + Windows** 双矩阵跑语法检查、引擎
|
|
189
|
+
- `ci.yml`:push/PR 在 **Linux + Windows** 双矩阵跑语法检查、引擎 40 例、客户端契约、Host 契约,通过后产出整包 zip 附件。
|
|
125
190
|
- `release.yml`:打 `v*` tag 自动发 Release;**tag 与 `package.json` 版本不一致直接失败**。
|
|
126
191
|
|
|
127
192
|
## 许可
|