dsh-cad 0.9.0 → 0.11.0
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.md +264 -248
- package/README.zh-CN.md +236 -222
- package/lib/cad_connector/executor.js +2 -0
- package/lib/cad_connector/onshape-executor.js +758 -0
- package/lib/cad_connector/onshape.js +2 -2
- package/lib/client.js +176 -176
- package/lib/client.js.map +4 -4
- package/lib/index.js +5 -1
- package/lib/modeling/assembly.js +131 -10
- package/lib/modeling/modeling-worker.cjs +27 -4
- package/lib/modeling/occtts-adapter.cjs +562 -0
- package/lib/routes.js +46 -0
- package/lib/tools/cad-model.js +14 -1
- package/lib/tools/cad-onshape.js +171 -0
- package/lib/types/cad_connector/executor.d.ts +15 -0
- package/lib/types/cad_connector/onshape-executor.d.ts +103 -0
- package/lib/types/cad_connector/onshape.d.ts +1 -1
- package/lib/types/modeling/assembly.d.ts +62 -5
- package/lib/types/modeling/client.d.ts +2 -0
- package/lib/types/routes.d.ts +10 -0
- package/lib/types/tools/cad-onshape.d.ts +8 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,248 +1,264 @@
|
|
|
1
|
-
# dsh-cad — CAD Plugin for DeepSeek Harness
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-
|
|
5
|
-
[](https://lau-mars.github.io/dsh-cad/)
|
|
6
|
-
[](https://www.npmjs.com/package/dsh-cad)
|
|
7
|
-
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
8
|
-
[](https://nodejs.org/)
|
|
9
|
-
[](https://github.com/donalffons/opencascade.js)
|
|
10
|
-
[](./LICENSE)
|
|
11
|
-
|
|
12
|
-
English | [简体中文](./README.zh-CN.md)
|
|
13
|
-
|
|
14
|
-
A CAD plugin for [DeepSeek Harness (dsh)](https://github.com/deepseek-ai/deepseek-harness):
|
|
15
|
-
an **embedded 3D/2D CAD viewer** plus a **native parametric modeling tool family**
|
|
16
|
-
(OCCT kernel) in the Web UI, letting the agent build and inspect CAD geometry
|
|
17
|
-
step by step — "model while you watch".
|
|
18
|
-
|
|
19
|
-
## Preview
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
dsh
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
dsh web
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
- “
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
|
100
|
-
|
|
|
101
|
-
| `
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
106
|
-
| `
|
|
107
|
-
| `
|
|
108
|
-
| `
|
|
109
|
-
| `
|
|
110
|
-
| `
|
|
111
|
-
| `
|
|
112
|
-
| `
|
|
113
|
-
| `
|
|
114
|
-
| `
|
|
115
|
-
| `
|
|
116
|
-
| `
|
|
117
|
-
| `
|
|
118
|
-
| `
|
|
119
|
-
| `
|
|
120
|
-
| `
|
|
121
|
-
| `
|
|
122
|
-
| `
|
|
123
|
-
| `
|
|
124
|
-
| `
|
|
125
|
-
| `
|
|
126
|
-
| `
|
|
127
|
-
| `
|
|
128
|
-
| `
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
|
145
|
-
|
|
|
146
|
-
|
|
|
147
|
-
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
- **
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
1
|
+
# dsh-cad — CAD Plugin for DeepSeek Harness
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
[](https://lau-mars.github.io/dsh-cad/)
|
|
6
|
+
[](https://www.npmjs.com/package/dsh-cad)
|
|
7
|
+
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
8
|
+
[](https://nodejs.org/)
|
|
9
|
+
[](https://github.com/donalffons/opencascade.js)
|
|
10
|
+
[](./LICENSE)
|
|
11
|
+
|
|
12
|
+
English | [简体中文](./README.zh-CN.md)
|
|
13
|
+
|
|
14
|
+
A CAD plugin for [DeepSeek Harness (dsh)](https://github.com/deepseek-ai/deepseek-harness):
|
|
15
|
+
an **embedded 3D/2D CAD viewer** plus a **native parametric modeling tool family**
|
|
16
|
+
(OCCT kernel) in the Web UI, letting the agent build and inspect CAD geometry
|
|
17
|
+
step by step — "model while you watch".
|
|
18
|
+
|
|
19
|
+
## Preview
|
|
20
|
+
|
|
21
|
+
A full modeling session, end to end: the agent builds a parametric assembly
|
|
22
|
+
from plain chat — a 120×80×8 base plate with R5 rounded corners, then four
|
|
23
|
+
bolt instances placed at the corners — while the resident CAD panel tracks
|
|
24
|
+
every step live (parts tree with per-instance colors, ViewCube, "装配体"
|
|
25
|
+
assembly tab, 5 instances · 1,740 triangles). The finished assembly exports
|
|
26
|
+
as a structured STEP document and the agent verifies it by reading the file
|
|
27
|
+
back — 2 solids, 3 products, 2 assembly usages, 1,125.00 mm³:
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
## Feature Overview
|
|
32
|
+
|
|
33
|
+
| Capability | Description |
|
|
34
|
+
| --- | --- |
|
|
35
|
+
| ⚙️ Single-kernel architecture | **occt.ts as the primary modeling kernel** (true B-splines, native shell/draft, centroid); opencascade.js stays only as the fallback backend; the v0.8 "no editing after shell" seam is gone — fillet/chamfer/boolean keep working after shelling |
|
|
36
|
+
| 🔍 CAD viewing | STL / OBJ / STEP / IGES / BREP / DCPRT (3D), DXF / SVG (2D); interactive in-chat card (orbit / zoom / wireframe / pan) |
|
|
37
|
+
| 🧭 CAD editor interactions | Onshape-style ViewCube (26-zone click-to-orient), hover/click face & edge picking with live measurement (area mm² / length mm), Faces+Edges / Faces / Wireframe render modes, switchable BRep demo parts (bracket / flange / shaft) |
|
|
38
|
+
| 🏗️ Parametric modeling | Primitives, profile extrusion, **loft**, **sweep**, **revolve**, booleans, all-edge fillet/chamfer, **shell**, **draft**, **patterns** (linear/circular), transforms; profiles take **curve segments** (arcs/circles exact BRep; B-splines sampled approximation) — exact OCCT BRep, not a mesh approximation |
|
|
39
|
+
| 🗂️ Codex-style document tabs | The resident display panel gets a tab strip with a "+" menu: **Part** (Part Studio, the default) / **Assembly** (instance insert/move/remove) / **Drawing** (true hidden-line sheets); tabs are closable and keep their state |
|
|
40
|
+
| 📁 Multi-document file space | Named documents per workspace (`.dsh-cad/docs/`), each session bound to its own active document — new sessions start empty instead of inheriting leftovers; a folder button in the panel lists every document (preview / delete), and `cad_doc_new` / `cad_doc_open` manage the modeling target from chat |
|
|
41
|
+
| 📐 Engineering drawings | GB first-angle layout: front / top / left views + isometric, true OCCT hidden-line removal via the **occt.ts** kernel (an npm dependency, dashed); sheet frame, title block, overall dimensions, standard scale series; exports SVG / DXF |
|
|
42
|
+
| 🔗 Constraint solving & motion | **Ansatz** geometric constraint solver (**one command: `npm install ansatz-wasm`** — a wasm dependency, no Rust toolchain, no native binary): entity/constraint modeling (assembly instances ↔ rigid3 poses mapped automatically), solve-with-writeback, full DOF/residual/redundancy/suggestion diagnostics (LLM-oriented), and parametric kinematic sweeps (`cad_constraint` / `cad_solve` / `cad_motion`) |
|
|
43
|
+
| 📐 Geometry measurement | Exact volume (mm³), bounding box, triangle counts, DXF layers |
|
|
44
|
+
| 📤 On-demand export | STEP (parametric) / STL (mesh); files are written only when the user asks |
|
|
45
|
+
| 🖥️ Resident CAD panel | A permanent panel right of the conversation: Codex-style tabs (Part / Assembly / Drawing), tracking the latest model in real time while modeling |
|
|
46
|
+
| ⚡ Zero-copy render pipeline | worker mesh → in-memory binary → three.js typed arrays; zero base64 / zero intermediate files / zero per-step disk writes |
|
|
47
|
+
| 💾 Modeling document persistence | Operation log (JSON) + debounced disk mirror; automatically replayed to restore state after a process restart |
|
|
48
|
+
| 🖼️ Image → profile | PNG sketch/screenshot → Otsu binarization → contour tracing → extrusion-ready polygon (`cad_image_profile`) |
|
|
49
|
+
| 🔌 FreeCAD executor | Run the same op family on an external FreeCAD console (STEP in/out); requires a local FreeCAD install |
|
|
50
|
+
| ☁️ Onshape executor | Run the same op family on **Onshape** over its signed REST API — zero local install; every op compiles to a **standard Onshape feature** pushed into the target Part Studio (no Feature Studio setup). Readback is three-tier: cheap per-part STL by default, `readback: "step"` for exact-BRep-derived named meshes via a server-side STEP translation, or `readback: "none"` — build only and return the document link (~3 calls, quota-friendliest). Exports `.stl` / `.step` / `.x_t` (Parasolid). Quota-aware errors distinguish credential problems from free-plan cooldowns; the Onshape document URL is always surfaced |
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
The plugin is published to npm — one line:
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
dsh plugin --profile web add dsh-cad
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The installer applies the bundled `cordis.patch.yml` (declared in the `dsh.bundle` manifest) automatically, so there is nothing to configure by hand.
|
|
61
|
+
|
|
62
|
+
### Version requirements
|
|
63
|
+
|
|
64
|
+
- **Node.js** ≥ 22
|
|
65
|
+
- **dsh CLI** (`@deepseek-ai/dsh`): this plugin is developed against **0.1.0-rc.7**
|
|
66
|
+
(minimum supported version, declared in the `engines` field of `package.json`);
|
|
67
|
+
recommended **≥ 0.1.1-rc.2** (verified 2026-08-31)
|
|
68
|
+
|
|
69
|
+
### Install from source (dev mode)
|
|
70
|
+
|
|
71
|
+
```sh
|
|
72
|
+
git clone https://github.com/LAU-MARS/dsh-cad.git
|
|
73
|
+
cd dsh-cad
|
|
74
|
+
npm install && npm run build && npm test # deps include occt.ts (true-HLR drawing kernel, ~20MB wasm)
|
|
75
|
+
|
|
76
|
+
npm install -g @deepseek-ai/dsh@^0.1.1-rc.2 pnpm # requires Node ≥ 22
|
|
77
|
+
dsh web # let the first launch init the profile, then Ctrl-C
|
|
78
|
+
|
|
79
|
+
dsh plugin --profile web add /path/to/dsh-cad
|
|
80
|
+
|
|
81
|
+
dsh web
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The patch insert ships as `cordis.patch.yml` in the package root and is applied by the installer via the same `dsh.bundle` manifest.
|
|
85
|
+
|
|
86
|
+
Set `DEEPSEEK_API_KEY` and you are ready — for example:
|
|
87
|
+
|
|
88
|
+
- “open bracket.stl” → `cad_view`
|
|
89
|
+
- “model a 100×60×5 plate, punch a ⌀20 hole in the middle, R2 fillets on the four
|
|
90
|
+
corners, add a ⌀16 boss 20 tall, export plate.step”
|
|
91
|
+
→ `cad_create_prim` + `cad_boolean` + `cad_fillet` + `cad_export`, with the 3D tab
|
|
92
|
+
updating live at every step
|
|
93
|
+
- “build a snowman” → spheres + a cone nose + a cylinder hat (precise `at`/`axis` placement)
|
|
94
|
+
- “add two more b1, one rotated 90 degrees” → `cad_assembly_insert` + `cad_assembly_move`, the Assembly tab updates live
|
|
95
|
+
- “make an A3 drawing of b1 and export dxf” → `cad_drawing` (three views + iso + dashed hidden lines + dimensions) → `cad_export` `.dxf`
|
|
96
|
+
|
|
97
|
+
## Modeling Tool Family
|
|
98
|
+
|
|
99
|
+
| Tool | Description |
|
|
100
|
+
| --- | --- |
|
|
101
|
+
| `cad_view` | Open a CAD file and render an interactive viewer card |
|
|
102
|
+
| `cad_info` | Read-only geometry metadata (format / counts / bounding box / units / layers) |
|
|
103
|
+
| `cad_create_prim` | Primitives (mm, Z-up); `at` for placement, `axis` for orientation (exact axis-angle rotation) |
|
|
104
|
+
| `cad_extrude_profile` | Extrude a closed XY-plane polygon along +Z into a solid |
|
|
105
|
+
| `cad_loft` | Loft: skin a solid through successive closed sections (each a [x,y,z,…] loop in its own plane); sections may differ in shape and point count; `ruled` for straight sides |
|
|
106
|
+
| `cad_revolve` | Solid of revolution: revolve a closed profile around an axis (profile coords = (radius, height); curve segments supported — rounded rims exact); optional `angle` |
|
|
107
|
+
| `cad_chamfer` | Chamfer: bevel every sharp edge with one equal distance (mm) |
|
|
108
|
+
| `cad_pattern` | Pattern: linear (`delta` spacing) or circular (principal axis + `at` point + sweep angle); creates copy bodies, fuse afterwards for one body |
|
|
109
|
+
| `cad_shell` | Shell: hollow to a wall thickness (inward, outer skin preserved); `open` lists outward normals of the faces to open (empty = sealed). Runs on the occt.ts kernel; the result is a HOSTED body |
|
|
110
|
+
| `cad_draft` | Draft: tilt the walls `angle` degrees about a neutral plane (mold release); `direction` is the pull direction, walls auto-selected by default. Runs on the occt.ts kernel; the result is a HOSTED body |
|
|
111
|
+
| `cad_sweep` | Sweep: pipe a closed 2D profile along a 3D [x,y,z,…] path; the profile is auto-placed on the start plane, so no manual orientation |
|
|
112
|
+
| `cad_boolean` | fuse / cut / common (classic hole punching: plate cut cylinder) |
|
|
113
|
+
| `cad_fillet` | Constant-radius fillet on all sharp edges |
|
|
114
|
+
| `cad_transform` | Translate / Euler rotate / mirror |
|
|
115
|
+
| `cad_volume` | Exact BRep volume (mm³) |
|
|
116
|
+
| `cad_drawing` | Engineering drawing: front/top/left + isometric views, dashed hidden lines, frame, title block, overall dimensions, standard scale, A4/A3 |
|
|
117
|
+
| `cad_assembly_insert` | Insert a body into the assembly as a placed instance (`at` position, `rotate` orientation) |
|
|
118
|
+
| `cad_assembly_move` | Set an instance's absolute placement |
|
|
119
|
+
| `cad_assembly_remove` | Remove an instance from the assembly (the body stays) |
|
|
120
|
+
| `cad_constraint` | Declare the constraint model: entities (assembly-instance bindings) + constraints (distance/angle/mate/coaxial…), persisted in the op log |
|
|
121
|
+
| `cad_solve` | Solve with Ansatz and write poses back; returns DOF/residual/redundancy/suggestion diagnostics |
|
|
122
|
+
| `cad_motion` | Kinematic sweep: drive one constraint value from `from` to `to`, solve frame by frame, apply the last pose, return the motion table |
|
|
123
|
+
| `cad_export` | Export STEP / STL / DCPRT (the native replayable part document) to a workspace path; `target: "assembly"` writes the assembly STEP, `target: "drawing"` writes the sheet as SVG / DXF |
|
|
124
|
+
| `cad_delete` | Delete a body |
|
|
125
|
+
| `cad_docs` | List the workspace's modeling documents (id / name / bodies / updated, active marked) |
|
|
126
|
+
| `cad_doc_new` | Create a named document and make it the session's modeling target (start multi-part projects here) |
|
|
127
|
+
| `cad_doc_open` | Open an existing document (by id or name) as the session's modeling target — bodies replay exactly |
|
|
128
|
+
| `cad_doc_rename` | Rename a document |
|
|
129
|
+
| `cad_doc_delete` | Permanently delete a document (requires `confirm: true`) |
|
|
130
|
+
| `cad_freecad` | Run an op program on an external FreeCAD executor (optional STEP input / export) |
|
|
131
|
+
| `cad_fusion` | Run an op program on an external Fusion 360 executor (GUI bridge; optional export) |
|
|
132
|
+
| `cad_onshape` | Run an op program on the Onshape cloud (signed REST API): creates or drives a document, returns its URL; `readback: "step"` for exact BRep meshes; exports `.stl` / `.step` / `.x_t` (Parasolid) |
|
|
133
|
+
| `cad_image_profile` | PNG → contours → extrusion-ready polygon points |
|
|
134
|
+
|
|
135
|
+
After every modeling step: **the same viewer card refreshes in place** (stable viewId +
|
|
136
|
+
versioned URL), and the "3D" tab tracks the latest model in real time.
|
|
137
|
+
|
|
138
|
+
## Connectors (roadmap)
|
|
139
|
+
|
|
140
|
+
Modeling primarily runs on the **occt.ts kernel** (opencascade.js as the fallback backend) (OCCT in the browser —
|
|
141
|
+
zero install). The connectors below refer to **external CAD engines** acting as
|
|
142
|
+
executors for the same tool family, planned for future support:
|
|
143
|
+
|
|
144
|
+
| Connector | Suite | Platform | Status |
|
|
145
|
+
| --- | --- | --- | --- |
|
|
146
|
+
| **Built-in kernel** | CAD modeling kernel based on OCCT + WebGL, runs in the browser — zero install | All platforms (WebGL rendering) | ✅ Built-in |
|
|
147
|
+
| FreeCAD | open-source parametric suite — natural local executor via its Python API (console + GUI window modes) | Windows / macOS / Linux | ✅ Available (needs local install) |
|
|
148
|
+
| Fusion 360 | Autodesk CAD/CAM — resident add-in + spool bridge (no headless; the Fusion window doubles as a viewer) | Windows / macOS | 🧪 Experimental (`cad_fusion`) |
|
|
149
|
+
| SolidWorks | Dassault Systèmes industry-standard 3D CAD, COM/.NET automation | Windows only | 🚧 Windows demo scaffold (`scripts/solidworks-bridge/`) |
|
|
150
|
+
| Onshape | PTC cloud-native SaaS CAD, fully in the browser — signed REST API (cad.onshape.com or chamber hosts); every op compiles to a standard Onshape feature pushed into the Part Studio, results read back as per-part STL + mass properties, the cloud is the viewer | All platforms (browser) | ✅ Available (`cad_onshape`; set `DSH_ONSHAPE_ACCESS_KEY` / `DSH_ONSHAPE_SECRET_KEY`) |
|
|
151
|
+
| ZW3D(中望3D) | ZWSOFT all-in-one CAD/CAM | Windows / Linux | 🚧 Planned |
|
|
152
|
+
| GstarCAD 3D(浩辰3D) | Gstarsoft 3D CAD | Windows | 🚧 Planned |
|
|
153
|
+
|
|
154
|
+
All external engines implement the same **GeometryExecutor contract** (`available()` /
|
|
155
|
+
`run(opProgram) → meshes`), so the WebGL display layer never changes — swapping a
|
|
156
|
+
backend changes only the quality of the produced geometry.
|
|
157
|
+
|
|
158
|
+
## Architecture
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
cad_view(path) modeling tools (cad_create_prim, …)
|
|
162
|
+
→ import worker (occt-import-js) → modeling worker (opencascade.js WASM)
|
|
163
|
+
→ CadScene JSON (base64-f32) → exact BRep geometry + meshing
|
|
164
|
+
→ GET /dsh-cad/scene/<id> → in-memory binary scene (f32/u32 packed)
|
|
165
|
+
→ GET /dsh-cad/bin/<docId>
|
|
166
|
+
↓ session presentationMeta (viewId + versioned URL) ↓
|
|
167
|
+
browser card + persistent "3D" tab (three.js / SVG, Z-up, XYZ axes)
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
- **Two workers**: import (occt-import-js, read-only STEP/IGES/BREP) and modeling
|
|
171
|
+
(opencascade.js 1.1.1, full OCCT) are separate, both lazily started; the `_N`
|
|
172
|
+
suffix convention of embind overloaded constructors is wrapped in
|
|
173
|
+
`src/modeling/occt-adapter.cjs` (all verified at runtime)
|
|
174
|
+
- **Zero-copy pipeline**: modeling scenes use zero base64 / zero large JSON arrays /
|
|
175
|
+
zero per-step disk writes (disk mirror debounced 1.5s, replayed only on service
|
|
176
|
+
restart); `cad_export` is the only explicit file export
|
|
177
|
+
- **Modeling document**: `<workspace>/.dsh-cad/model.json` operation log; all bodies
|
|
178
|
+
are restored by replay after a restart
|
|
179
|
+
- **Drawing HLR kernel**: hidden lines run on **occt.ts** (npm dependency,
|
|
180
|
+
`npm i occt.ts`) — true OCCT removal, no fallback engine, a missing kernel is
|
|
181
|
+
a hard error. New APIs over opencascade.js: `hiddenLines()` true hidden-line
|
|
182
|
+
removal, byte-level STEP/BRep `readStep`/`readBrep`/`writeStep`/`writeBrep`
|
|
183
|
+
without MEMFS, tessellation with built-in feature-edge extraction, and a
|
|
184
|
+
`hasError()`/`lastError()` error contract. Geometry crosses kernels as STEP
|
|
185
|
+
bytes and the projected segments are remapped into the sheet frame. Kernel
|
|
186
|
+
dist resolution: `DSH_OCCTJS_DIST` env var → `node_modules/occt.ts/dist`
|
|
187
|
+
(npm, default) → `<repo>/../opencascade-ts/dist` (sibling checkout) → `vendor/`
|
|
188
|
+
→ `node_modules/opencascade-ts`
|
|
189
|
+
- **Constraint solving (Ansatz)**: the solver is the npm dependency
|
|
190
|
+
**`ansatz-wasm`** (a wasm-bindgen build, single package ~538KB, zero deps) —
|
|
191
|
+
installing dsh-cad pulls it automatically, and `npm install ansatz-wasm` alone
|
|
192
|
+
upgrades it. **No Rust toolchain, no native binary, platform independent.**
|
|
193
|
+
Resolution: the npm package (node_modules) → a `DSH_ANSATZ_WASM` directory → a
|
|
194
|
+
sibling Ansatz checkout's pkg-node. The solver speaks one JSON envelope
|
|
195
|
+
contract, with tool-layer errors (e.g. `unsupported_constraint`) surfaced
|
|
196
|
+
verbatim for the LLM. Assembly placements (translate + XYZ Euler
|
|
197
|
+
degrees) map bidirectionally to the solver's rigid3 poses (translate +
|
|
198
|
+
exponential-map rotation, radians). Solver capability is staged
|
|
199
|
+
(point-distance-to-origin today) — the plumbing contract is finished and needs
|
|
200
|
+
no changes as it grows
|
|
201
|
+
- **Single-kernel architecture (v0.9)**: the primary modeling kernel is now
|
|
202
|
+
**occt.ts >= 0.5.0** — primitives, curve-segment profiles (TRUE B-spline
|
|
203
|
+
interpolation), loft/sweep/revolve, booleans, fillet/chamfer, shell/draft,
|
|
204
|
+
mirror (composed as scale(-1) + a π rotation) and centroid all live in one
|
|
205
|
+
session; engineering-drawing HLR takes the shape directly (zero STEP hops);
|
|
206
|
+
editing after shelling is seamless (the v0.8 hosted-body seam is deleted).
|
|
207
|
+
opencascade.js remains as the FALLBACK backend (auto-selected when occt.ts
|
|
208
|
+
cannot load). Assembly STEP export writes a **structured document** (occt.ts
|
|
209
|
+
≥ 0.7.0 `writeStepDocument`): one root product plus one named, placed child
|
|
210
|
+
per instance — instance separation survives the file (STL stays a single
|
|
211
|
+
fused mesh; the fallback backend also fuses). Instance separation stays in
|
|
212
|
+
the assembly scene/document for the fuse paths.
|
|
213
|
+
Face selection matches `describe()` plane normals (outermost along ±normal)
|
|
214
|
+
- **Client**: esbuild single-file CJS factory (three.js inlined ~560KB, react provided
|
|
215
|
+
by the host module table), Z-up CAD convention, empty scene with XYZ axis labels
|
|
216
|
+
and a ground grid always displayed
|
|
217
|
+
|
|
218
|
+
## Tests
|
|
219
|
+
|
|
220
|
+
```sh
|
|
221
|
+
npm test # 41 tests: converters / modeling worker (exact volume assertions) / DCPRT round-trip / FreeCAD executor / image profiles / binary pipeline
|
|
222
|
+
node test/m0-kernel-check.cjs # OCCT kernel API smoke test
|
|
223
|
+
node test/route-check.mjs # JSON scene routing layer
|
|
224
|
+
node test/visual/serve.mjs # browser card/tab visual verification page (http://127.0.0.1:3987)
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Representative assertions covered: the boolean-punched volume exactly equals the
|
|
228
|
+
analytic value (28429.20 mm³), L-shaped profile extrusion 3000 mm³, volumes and
|
|
229
|
+
bounding-box flips of sphere/cone/torus placed with `at`/`axis`, 8-byte alignment
|
|
230
|
+
of the binary packing, an STL export round-trip (export → read back by the
|
|
231
|
+
phase-1 parser), and a DCPRT document round-trip (serialize → replay on the
|
|
232
|
+
OCCT worker → exact bounds).
|
|
233
|
+
|
|
234
|
+
## Known Limitations
|
|
235
|
+
|
|
236
|
+
- DWG (closed-source) is unsupported; DXF bulge arcs are approximated by chords;
|
|
237
|
+
glTF/3MF viewing is not implemented (the structure is reserved)
|
|
238
|
+
- `cad_fillet` is all-edge constant-radius (per-edge selection is unstable under
|
|
239
|
+
embind); chamfer is not implemented
|
|
240
|
+
- Sketch extrusion supports polygon profiles only (arc profiles are constructed by
|
|
241
|
+
boolean combinations of cylinders/tori)
|
|
242
|
+
- dsh framework limitation: an already-mounted single slot (the right-side details
|
|
243
|
+
panel itself) does not respond to components registered later, so the persistent
|
|
244
|
+
view is provided as the "3D" view tab (a list slot, the official composition)
|
|
245
|
+
- The host reads CAD files via node:fs (the platform fs service supports UTF-8 text
|
|
246
|
+
only and cannot carry binary data)
|
|
247
|
+
|
|
248
|
+
## Community
|
|
249
|
+
|
|
250
|
+
| QQ Group (🇨🇳 China) | Feishu (🇨🇳 China) | X / Twitter (🌍 International) | Discord (🌍 International) |
|
|
251
|
+
| --- | --- | --- | --- |
|
|
252
|
+
| `485038246` (join note: dsh-cad) | 🚧 Coming soon | 🚧 Coming soon | 🚧 Coming soon |
|
|
253
|
+
|
|
254
|
+
<!-- TODO: fill in the X handle / Discord invite link before publishing -->
|
|
255
|
+
|
|
256
|
+
## Contributors
|
|
257
|
+
|
|
258
|
+
Auto-generated from the commit history — thanks to everyone who has contributed!
|
|
259
|
+
|
|
260
|
+
[](https://github.com/LAU-MARS/dsh-cad/graphs/contributors)
|
|
261
|
+
|
|
262
|
+
## License
|
|
263
|
+
|
|
264
|
+
MIT
|