@coloopx/colocad 0.1.0-alpha.2 → 0.1.0-alpha.3
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 +80 -2
- package/README.zh-CN.md +100 -0
- package/kernel/native/darwin-arm64/agent-cad +2 -2
- package/kernel/native/darwin-arm64/manifest.json +2 -2
- package/kernel/native/linux-arm64/agent-cad +1 -1
- package/kernel/native/linux-arm64/manifest.json +2 -2
- package/kernel/native/linux-x64/agent-cad +2 -2
- package/kernel/native/linux-x64/manifest.json +2 -2
- package/kernel/release.json +8 -0
- package/package.json +8 -3
- package/scripts/check-release.mjs +24 -0
- package/skills/colocad/SKILL.md +17 -0
- package/skills/colocad/assets/angle-bracket.json +39 -0
- package/skills/colocad/assets/ball.json +16 -0
- package/skills/colocad/assets/block.json +18 -0
- package/skills/colocad/assets/open-housing.json +35 -0
- package/skills/colocad/assets/pin.json +18 -0
- package/skills/colocad/assets/plate-grid.json +34 -0
- package/skills/colocad/assets/sleeve.json +19 -0
- package/skills/colocad/assets/taper.json +20 -0
- package/skills/colocad/references/quick-build.md +44 -0
- package/skills/colocad/scripts/assembly.mjs +3 -0
- package/skills/colocad/scripts/build.mjs +54 -0
package/README.md
CHANGED
|
@@ -1,8 +1,86 @@
|
|
|
1
1
|
# colocad
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[中文说明](README.zh-CN.md) · [npm package](https://www.npmjs.com/package/@coloopx/colocad) · [Download the offline comparison](https://github.com/Coloopx/colocad/raw/refs/heads/main/docs/benchmarks/comparison.html)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Generate a mechanical part from a JSON feature tree, export an exact STEP solid, and give an agent a PNG or 3D preview to inspect. **The npm package ships the compiled Rust CAD kernel.** The agent and harness call it locally in the same sandbox through the Node CLI or TypeScript API. No Python, Rust toolchain, network or separate service is required to build a part after installation.
|
|
6
|
+
|
|
7
|
+
## How many tendon hands can an agent deliver in 100 seconds?
|
|
8
|
+
|
|
9
|
+
**colocad delivered 44 complete revisions to build123d’s 33 (+33.3%), with 57.1% lower peak sampled sandbox memory.** Both tools rebuilt and assembled the same 43-solid hand at each revision. Each tick marks a complete STEP handed off to storage.
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
The GIF shows the **highest memory sampled so far** for each tool on the same 0–512 MiB scale. For actual usage between builds, see the [instantaneous-memory replay (MP4)](https://github.com/Coloopx/colocad/raw/refs/heads/main/showcase/tendon-hand/window/hand-window-en.mp4) or the [timestamped samples](showcase/tendon-hand/evidence/window-optimized.json).
|
|
14
|
+
|
|
15
|
+
| Same revision queue, 1 vCPU / 512 MiB | Optimized colocad | build123d |
|
|
16
|
+
|---|---:|---:|
|
|
17
|
+
| Complete hands delivered in 100 s | **44** | 33 |
|
|
18
|
+
| First STEP | **2.223 s** | 3.010 s |
|
|
19
|
+
| Median job time on the same first 33 inputs | **2.234 s** | 2.855 s |
|
|
20
|
+
| Highest sampled cgroup memory over the 100 s window | **130.9 MiB** | 304.9 MiB |
|
|
21
|
+
|
|
22
|
+
One measured window per backend, with a new CAD process for each revision. The original run used the alpha.2 SDK and the optimized Linux arm64 kernel now bundled in alpha.3. Memory samples taken about every 25 ms include subprocesses, tmpfs and charged file cache. Every counted STEP reopened successfully. [Measurement method](showcase/tendon-hand/window/README.md) · [Detailed build and single-call replay](showcase/tendon-hand/assembly-performance.md)
|
|
23
|
+
|
|
24
|
+
The static scorecard below uses the **published alpha.2 binary**. With fresh tool processes the sensor rail and manifold reached STEP 22.0× and 12.9× faster than build123d, using 7.7% and 8.0% of its peak memory.
|
|
25
|
+
|
|
26
|
+
<details>
|
|
27
|
+
<summary>See the static comparison across four workloads</summary>
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
</details>
|
|
32
|
+
|
|
33
|
+
| Deliverable | Time to STEP: colocad / build123d | Speedup¹ | Peak memory: colocad / build123d | Share of build123d peak |
|
|
34
|
+
| :--- | ---: | ---: | ---: | ---: |
|
|
35
|
+
| Sensor rail | 113 / 2,485 ms | **22.0×** | 20.0 / 259.3 MiB | **7.7%** |
|
|
36
|
+
| Port manifold | 230 / 2,963 ms | **12.9×** | 20.7 / 258.7 MiB | **8.0%** |
|
|
37
|
+
| Tendon-hand proximal link | 259 / 2,244 ms | **8.6×** | 21.4 / 260.1 MiB | **8.2%** |
|
|
38
|
+
| Complete 43-solid hand | 3,952 / 3,293 ms | **0.83×** | 52.7 / 271.3 MiB | **19.4%** |
|
|
39
|
+
|
|
40
|
+
¹ build123d time divided by colocad time from unrounded observations. Same Linux arm64 image, 1 vCPU, 512 MiB. Five fresh processes and cgroups per part and backend after warm-up. Time is the median wall clock including startup, imports, modeling, backend checks and STEP export. Memory is the maximum measured cgroup peak; charged pages, temporary outputs and tool descendants count. Installation, container startup, previews, inference and a resident agent are excluded.
|
|
41
|
+
|
|
42
|
+
[Rail/manifold samples](docs/benchmarks/runs.json) · [Finger/hand samples](showcase/tendon-hand/evidence/scope.json) · [Four-view hand study and CAD downloads](showcase/tendon-hand/README.md) · [Offline scorecard](https://github.com/Coloopx/colocad/raw/refs/heads/main/docs/benchmarks/time-to-step.html)
|
|
43
|
+
|
|
44
|
+
**Historical alpha.2 result.** in a separate 100-second sweep of complete hand revisions, colocad delivered 24 STEPs to build123d’s 30. Every counted file reopened as a valid 43-solid assembly. [Timestamped outputs and paired geometry checks](showcase/tendon-hand/evidence/window.json)
|
|
45
|
+
|
|
46
|
+
## SDK, CLI or skill?
|
|
47
|
+
|
|
48
|
+
Install with `npm install @coloopx/colocad@0.1.0-alpha.3`. This version bundles the optimized assembly kernel and the complete agent skill. The skill lives at `node_modules/@coloopx/colocad/skills/colocad/`. Point your harness at its `SKILL.md` or copy the whole directory into your agent’s skill collection.
|
|
49
|
+
|
|
50
|
+
For a dimensioned part, try “Make a 100 × 50 × 6 mm plate with a centered 3 × 2 grid of Ø6 through-holes on 32 × 30 mm pitches.” The skill includes editable stock, hole grids, sleeves, brackets and open housings. [Quick-build commands and examples](skills/colocad/references/quick-build.md)
|
|
51
|
+
|
|
52
|
+
- **In an application or harness:** call `build(tree, newDir, { preview: true })` in the SDK. Use `CadClient.build(model)` for named multi-solid assemblies.
|
|
53
|
+
- **In a shell or agent tool call:** install `npm install @coloopx/colocad@0.1.0-alpha.3`. Run `./node_modules/.bin/colocad plan tree.json`, then `./node_modules/.bin/colocad build tree.json ./new-part --preview`. Open `new-part/part/model.step`.
|
|
54
|
+
- **From drawings with an agent:** install the [colocad skill](skills/colocad/SKILL.md). Start the next turn with “Use `$colocad` to reconstruct these four views, export STEP, and flag any internal details you inferred.” [Installation and assembly replay](showcase/tendon-hand/README.md#try-it-with-your-agent).
|
|
55
|
+
|
|
56
|
+
## What the two STEP writers produced
|
|
57
|
+
|
|
58
|
+

|
|
59
|
+
|
|
60
|
+
Each backend modeled the part from the same parameters. The images use the exported STEPs, the same mesher and camera. OCCT reopened each file as **one valid solid**. Both rail exports had 22 faces and 56 edges; both manifold exports had 27 faces and 54 edges. The two directional boolean differences measured **0 mm³** in both cases (boolean tolerance: 0.000001 mm). [Geometry checks](docs/benchmarks/step-checks.json)
|
|
61
|
+
|
|
62
|
+
On the manifold, build123d’s modeling phase alone was **43.8 ms** to colocad’s **53.7 ms**, while build123d import alone took **2.45 s**. The table measures a fresh tool call, not the speed of an isolated boolean operation. [Stage timings and reproduction](benchmarks/readme/README.md)
|
|
63
|
+
|
|
64
|
+
### When the agent only changes the camera
|
|
65
|
+
|
|
66
|
+
The first preview saves a display mesh. For a second view of unchanged geometry, the kernel SDK can load that mesh instead of rebuilding the solid or triangulating it again. Here are five-run medians for the same **top view**, comparing two paths inside colocad:
|
|
67
|
+
|
|
68
|
+
| Part | Rebuild part + render | Render from saved mesh | Speedup |
|
|
69
|
+
| :--- | ---: | ---: | ---: |
|
|
70
|
+
| Sensor rail | 108.8 ms | 19.4 ms | **5.6×** |
|
|
71
|
+
| Port manifold | 223.8 ms | 13.3 ms | **16.8×** |
|
|
72
|
+
|
|
73
|
+
The PNG, GLB and STL from both paths matched byte for byte on every pair. This test starts with the SDK already loaded and includes native process startup and display output. A geometry edit needs a new revision. [Preview measurements and hashes](docs/benchmarks/preview-runs.json)
|
|
74
|
+
|
|
75
|
+
## What ships
|
|
76
|
+
|
|
77
|
+
| In the [npm tarball](https://www.npmjs.com/package/@coloopx/colocad) | In the [source repository](https://github.com/Coloopx/colocad) |
|
|
78
|
+
| :--- | :--- |
|
|
79
|
+
| Agent skill, CLI, JavaScript API, TypeScript declarations and precompiled Rust executables for **Linux x64, Linux arm64 and macOS arm64**. Node.js 22+. | [Rust CAD source](crates/agent-cad/src), [TypeScript kernel SDK](kernel/src), [feature compiler](src/tree.mjs), tests and [pinned SolidCore dependency](third_party/solidcore.lock.json). |
|
|
80
|
+
|
|
81
|
+
For example, on Linux arm64 the CLI launches `node_modules/@coloopx/colocad/kernel/native/linux-arm64/agent-cad`. The tarball contains the executable; the Rust `.rs` files are in the repository.
|
|
82
|
+
|
|
83
|
+
**Alpha status.** Linux supports parametric edits, STEP and PNG/GLB/STL export. Direct generation of a complex, editable SOLIDWORKS part on Linux is still experimental. The optional Windows author compiles against the SOLIDWORKS 2024 interop API; a licensed native rebuild has not been verified. See the [native author](#native-solidworks-author-experimental) and [validation notes](docs/validation.md).
|
|
6
84
|
|
|
7
85
|
## Run the examples
|
|
8
86
|
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# colocad
|
|
2
|
+
|
|
3
|
+
[English](README.md) · [npm 包](https://www.npmjs.com/package/@coloopx/colocad) · [下载单文件对比报告:含四份 STEP](https://github.com/Coloopx/colocad/raw/refs/heads/main/docs/benchmarks/comparison.html)
|
|
4
|
+
|
|
5
|
+
让沙箱内的 agent 用 JSON 描述可改参的机械零件,输出 STEP 实体、PNG 预览和 GLB/STL 网格。**npm 包自带编译好的 Rust CAD 内核**:Linux x64、Linux arm64 和 macOS arm64 各一份。agent 和 harness 在同一沙箱里调用 Node CLI 或 TypeScript API,CLI 直接启动本地 Rust 程序。安装后建模不需要网络、Python、Rust 工具链或额外服务。[Rust 源码](crates/agent-cad/src)和[内核依赖版本](third_party/solidcore.lock.json)在本仓库。
|
|
6
|
+
|
|
7
|
+
## 100 秒能交付多少版绳驱灵巧手?
|
|
8
|
+
|
|
9
|
+
**colocad 交付 44 版,build123d 交付 33 版:交付量多 33.3%,采样峰值内存低 57.1%。** 两边按同一组参数逐版建模、装配。每条刻线代表一份含 43 个实体的整手 STEP 已写入持久存储。
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
动图底部显示两边**从开始到当前时刻采到的最高内存**,共用 0–512 MiB 刻度。要看每次建模之间内存如何回落,可打开[瞬时内存回放(MP4)](https://github.com/Coloopx/colocad/raw/refs/heads/main/showcase/tendon-hand/window/hand-window-zh-CN.mp4)或[原始采样](showcase/tendon-hand/evidence/window-optimized.json)。
|
|
14
|
+
|
|
15
|
+
| 同一改参队列,1 vCPU / 512 MiB | colocad 优化内核 | build123d |
|
|
16
|
+
|---|---:|---:|
|
|
17
|
+
| 100 秒内交付的完整整手 | **44 份** | 33 份 |
|
|
18
|
+
| 首份 STEP | **2.223 s** | 3.010 s |
|
|
19
|
+
| 共同前 33 份交付耗时中位数 | **2.234 s** | 2.855 s |
|
|
20
|
+
| 连续 100 秒内的最高采样内存 | **130.9 MiB** | 304.9 MiB |
|
|
21
|
+
|
|
22
|
+
各运行一个真实窗口,每版新起 CAD 进程。这次原始记录使用 alpha.2 SDK 和优化后的 Linux arm64 内核。alpha.3 已内置同一份二进制。内存约每 25 ms 采样,包含子进程、临时文件和计入本容器的文件缓存。两边计入的 STEP 都已独立回读。[单文件回放与 STEP 下载](https://github.com/Coloopx/colocad/raw/refs/heads/main/showcase/tendon-hand/window/hand-window.html) · [建模细节与单次原速回放](showcase/tendon-hand/assembly-performance.md)
|
|
23
|
+
|
|
24
|
+
以下静态表记录 npm **0.1.0-alpha.2 自带内核**的历史基线。新进程交付导轨和歧管分别快 22.0× 和 12.9×,峰值内存分别为 build123d 的 7.7% 和 8.0%。
|
|
25
|
+
|
|
26
|
+
<details>
|
|
27
|
+
<summary>查看四种任务的静态对照图</summary>
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
</details>
|
|
32
|
+
|
|
33
|
+
| 独立交付物 | 首份 STEP:colocad / build123d | 交付速度比¹ | 沙箱峰值:colocad / build123d | 内存占对方 |
|
|
34
|
+
|---|---:|---:|---:|---:|
|
|
35
|
+
| 三槽导轨 | 113 / 2,485 ms | **22.0×** | 20.0 / 259.3 MiB | **7.7%** |
|
|
36
|
+
| 四盲孔歧管 | 230 / 2,963 ms | **12.9×** | 20.7 / 258.7 MiB | **8.0%** |
|
|
37
|
+
| 绳驱手近节指骨 | 259 / 2,244 ms | **8.6×** | 21.4 / 260.1 MiB | **8.2%** |
|
|
38
|
+
| 43 实体整手 | 3,952 / 3,293 ms | **0.83×** | 52.7 / 271.3 MiB | **19.4%** |
|
|
39
|
+
|
|
40
|
+
¹ 速度比为 build123d 用时 ÷ colocad 用时,按未取整的读数计算。Linux arm64、1 vCPU、512 MiB。每组预热后交替运行五轮,**耗时取中位数,内存取五轮容器 cgroup 峰值最大值**。计入启动、导入、建模、后端自身的检查及 STEP 导出;不含安装、容器启动、预览、模型推理或常驻 agent。单件和整手使用各自对应的公开接口。
|
|
41
|
+
|
|
42
|
+
[原始读数:导轨与歧管](docs/benchmarks/runs.json) · [原始读数:指骨与整手](showcase/tendon-hand/evidence/scope.json) · [四视图、可编辑整手和 STEP](showcase/tendon-hand/README.md) · [离线数据卡](https://github.com/Coloopx/colocad/raw/refs/heads/main/docs/benchmarks/time-to-step.html)
|
|
43
|
+
|
|
44
|
+
**旧版整手基线。** 另一项 100 秒、按顺序改参的实测中,colocad 交付 24 份整手 STEP,build123d 交付 30 份;每份都是完整的 43 个实体,已逐件回读。[两端交付时间戳与几何核对](showcase/tendon-hand/evidence/window.json)
|
|
45
|
+
|
|
46
|
+
## SDK、CLI、skill 怎么选?
|
|
47
|
+
|
|
48
|
+
运行 `npm install @coloopx/colocad@0.1.0-alpha.3` 即可安装优化后的装配内核和完整 skill。沙箱内的 harness 可加载 `node_modules/@coloopx/colocad/skills/colocad/SKILL.md`,也可以把整个 `colocad` skill 目录复制到 agent 的技能目录。
|
|
49
|
+
|
|
50
|
+
常见机械件可以让 agent 直接按尺寸搭建。例如「做一块 100 × 50 × 6 mm 的安装板,钻 3 × 2 个 Ø6 通孔,两向孔距 32 和 30 mm」。skill 自带可改参的孔阵列、轴套、角码、开口壳和四种基础实体。参见[基础形状与结构的命令示例](skills/colocad/references/quick-build.md)。
|
|
51
|
+
|
|
52
|
+
- **应用或 harness 集成:** 进程里直接调用 SDK 的 `build(tree, newDir, { preview: true })`;多实体装配用 `CadClient.build(model)`。
|
|
53
|
+
- **终端或沙箱 agent:** 安装 `npm install @coloopx/colocad@0.1.0-alpha.3`;用 `./node_modules/.bin/colocad plan tree.json` 检查特征,再用 `./node_modules/.bin/colocad build tree.json ./new-part --preview`。成品在 `new-part/part/model.step`。全程在同一沙箱内。
|
|
54
|
+
- **从多视图交给 agent:** 从 [skills/colocad](skills/colocad/SKILL.md) 安装 skill;下个回合输入「用 `$colocad` 读这四张图,生成可编辑模型和 STEP,并标出推断的内部结构」。[完整安装命令、SDK 装配示例和重放步骤](showcase/tendon-hand/README.md#try-it-with-your-agent)。
|
|
55
|
+
|
|
56
|
+
以 Linux arm64 为例,安装后可执行文件就在 `node_modules/@coloopx/colocad/kernel/native/linux-arm64/agent-cad`。npm 分发编译产物;要读或修改 `.rs` 源文件,请用上面的 GitHub 源码链接。
|
|
57
|
+
|
|
58
|
+
## 两个建模后端做出来的东西一样吗?
|
|
59
|
+
|
|
60
|
+

|
|
61
|
+
|
|
62
|
+
左右两列分别从相同参数独立建模、导出 STEP,再用同一套 OCCT 三角化参数、相机和光照出图。四份 STEP 回读都是有效的单实体。导轨各有 22 个面、56 条边;歧管各有 27 个面、54 条边。两个零件分别做 A−B、B−A,测得差集体积均为 **0 mm³**(布尔容差 0.000001 mm)。[逐件几何核对](docs/benchmarks/step-checks.json)
|
|
63
|
+
|
|
64
|
+
只看歧管几何阶段,build123d 是 43.8 ms,colocad 是 53.7 ms;build123d 导入则用了 2.45 s。端到端提速不能当作纯几何运算提速。[分阶段数据与复现方法](benchmarks/readme/README.md)
|
|
65
|
+
|
|
66
|
+
## 如果 agent 只是转动视角呢?
|
|
67
|
+
|
|
68
|
+
首次预览会保存网格。同一个零件从等轴视图切到俯视图,SDK 可以用 `observeArtifact` 重新出图,跳过精确建模和三角化。同一版 colocad 在同样沙箱预算下得到以下五轮中位数:
|
|
69
|
+
|
|
70
|
+
| 切到俯视图 | 完整重建并出图 | 复用网格出图 | 加速比 |
|
|
71
|
+
| :--- | ---: | ---: | ---: |
|
|
72
|
+
| 导轨 | 108.8 ms | 19.4 ms | **5.6×** |
|
|
73
|
+
| 歧管 | 223.8 ms | 13.3 ms | **16.8×** |
|
|
74
|
+
|
|
75
|
+
每对输出的 PNG、GLB、STL 三个文件均逐字节相同。这一组只比较 colocad 的两条路径;SDK 已加载,计时包括启动本地 Rust 进程和写出显示文件。改几何参数需要生成新版本。[预览耗时和文件哈希](docs/benchmarks/preview-runs.json)
|
|
76
|
+
|
|
77
|
+
## 试跑并改参
|
|
78
|
+
|
|
79
|
+
需要 Node.js 22+。输出目录必须是新目录。
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
npm install @coloopx/colocad@0.1.0-alpha.3
|
|
83
|
+
npx colocad build node_modules/@coloopx/colocad/examples/manifold.json ./manifold --preview
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
打开 `manifold/part/model.step` 检查实体;`preview.png`、`model.glb` 和 `model.stl` 用于查看。歧管由六边形拉伸、盲孔切除、上缘圆角、引用种子孔的线性阵列和矩形浅槽构成。将 `instances` 从 4 改到 3,少切一个 Ø6 × 8 mm 的盲孔,实测恢复材料 **226.195 mm³**,与圆柱体积一致。[验证记录](docs/evidence/scoped-runner.json)
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
import { readFile } from 'node:fs/promises';
|
|
90
|
+
import { build } from '@coloopx/colocad';
|
|
91
|
+
|
|
92
|
+
const tree = JSON.parse(await readFile('./node_modules/@coloopx/colocad/examples/manifold.json', 'utf8'));
|
|
93
|
+
tree.parameters.instances = 3;
|
|
94
|
+
const result = await build(tree, './three-port-manifold', { preview: true });
|
|
95
|
+
console.log(result.step);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
公开特征接口支持矩形、圆和多边形草图拉伸、切除、按 Z 平面选边的定半径圆角,以及沿 X/Y 的拉伸或切除阵列。[类型定义](src/index.d.mts) · [更底层的内核 API](kernel/src/client.ts)
|
|
99
|
+
|
|
100
|
+
**交付边界:** Linux 已验证 STEP、网格和改参。Linux 直接生成复杂、可在 SOLIDWORKS 里编辑和重建的原生 `.SLDPRT` 尚未完成。仓库中的 Windows 作者程序已针对 SOLIDWORKS 2024 接口编译,尚未在有授权的 SOLIDWORKS 上完成回读重建。[验证说明](docs/validation.md) · [从源码构建](README.md#build-and-verify-from-source)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/kernel/native/darwin-arm64/agent-cad
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 35996736 bytes
|
|
4
|
+
sha256: fa439185a647a66e65fba6d61d816dacb1e2ab3ba89665c5e89d4821123fcf65
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/kernel/native/linux-arm64/agent-cad
|
|
3
3
|
size: 35525448 bytes
|
|
4
|
-
sha256:
|
|
4
|
+
sha256: 332bc7b75ad66816617b12ed2a11823bd5061105a8df9da2c884ad6824825c4f
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/kernel/native/linux-x64/agent-cad
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 46383568 bytes
|
|
4
|
+
sha256: 0a5d2ab6b8a5fc9ae36d61affc97a33ffab734842762ece73d73980dd9069a32
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.1.0-alpha.3",
|
|
3
|
+
"sha256": {
|
|
4
|
+
"linux-arm64": "332bc7b75ad66816617b12ed2a11823bd5061105a8df9da2c884ad6824825c4f",
|
|
5
|
+
"linux-x64": "0a5d2ab6b8a5fc9ae36d61affc97a33ffab734842762ece73d73980dd9069a32",
|
|
6
|
+
"darwin-arm64": "fa439185a647a66e65fba6d61d816dacb1e2ab3ba89665c5e89d4821123fcf65"
|
|
7
|
+
}
|
|
8
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coloopx/colocad",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.3",
|
|
4
4
|
"description": "Parametric feature instructions, a local Rust B-rep kernel and an experimental SolidWorks author",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -43,11 +43,16 @@
|
|
|
43
43
|
"examples/sensor-rail.json",
|
|
44
44
|
"README.md",
|
|
45
45
|
"LICENSE",
|
|
46
|
-
"NOTICE.md"
|
|
46
|
+
"NOTICE.md",
|
|
47
|
+
"skills/colocad",
|
|
48
|
+
"kernel/release.json",
|
|
49
|
+
"scripts/check-release.mjs",
|
|
50
|
+
"README.zh-CN.md"
|
|
47
51
|
],
|
|
48
52
|
"scripts": {
|
|
49
53
|
"test": "node --test test/*.test.mjs",
|
|
50
|
-
"build:kernel": "node scripts/build-kernel.mjs"
|
|
54
|
+
"build:kernel": "node scripts/build-kernel.mjs",
|
|
55
|
+
"prepack": "node scripts/check-release.mjs"
|
|
51
56
|
},
|
|
52
57
|
"publishConfig": {
|
|
53
58
|
"access": "public",
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { readFile, stat } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
|
|
6
|
+
const root = fileURLToPath(new URL('../', import.meta.url));
|
|
7
|
+
const readJson = async (name) => JSON.parse(await readFile(join(root, name), 'utf8'));
|
|
8
|
+
const pkg = await readJson('package.json');
|
|
9
|
+
const release = await readJson('kernel/release.json');
|
|
10
|
+
if (release.version !== pkg.version) throw Error('Update the tested kernel hashes for ' + pkg.version);
|
|
11
|
+
|
|
12
|
+
for (const platform of ['darwin-arm64', 'linux-arm64', 'linux-x64']) {
|
|
13
|
+
const dir = join('kernel', 'native', platform);
|
|
14
|
+
const manifest = await readJson(join(dir, 'manifest.json'));
|
|
15
|
+
const binary = join(root, dir, 'agent-cad');
|
|
16
|
+
const bytes = await readFile(binary);
|
|
17
|
+
const hash = createHash('sha256').update(bytes).digest('hex');
|
|
18
|
+
if (manifest.platform !== platform || manifest.bytes !== bytes.length ||
|
|
19
|
+
manifest.sha256 !== hash || release.sha256[platform] !== hash ||
|
|
20
|
+
!((await stat(binary)).mode & 0o111)) {
|
|
21
|
+
throw Error('Missing or incorrect tested kernel for ' + platform);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
await readFile(join(root, 'skills/colocad/SKILL.md'));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: colocad
|
|
3
|
+
description: Build and verify editable mechanical parts and assemblies from dimensions, engineering drawings or multiple views with @coloopx/colocad. Use for quick parametric construction, fit checks, STEP and previews.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Use the project's installed `@coloopx/colocad` on Node 22+. The agent and harness use the SDK and native executable inside the same sandbox.
|
|
7
|
+
|
|
8
|
+
For a dimensioned part, start with the cross-section or stock that controls its shape. Use the [quick-build guide](references/quick-build.md) for single-feature stock (block, pin, ball, taper) and common structures (hole grid, sleeve, L-section, open housing). Each model has editable dimensions. The guide gives their datums, measurements to check, and an example of reusing a definition in an assembly. Pick only the features the drawing calls for. Guide dimensions are examples.
|
|
9
|
+
|
|
10
|
+
For drawings, identify the views, units, scale and common datum. Separate measured dimensions from hidden or assumed details. Compare projections from the final STEP against the supplied views at the same scale. Flag dimensions that prevent a critical fit from being checked.
|
|
11
|
+
|
|
12
|
+
Choose the entry point that matches the model:
|
|
13
|
+
|
|
14
|
+
- A kernel model (`version: 1`, units `mm`, `parameters`, `features`, and either `output` or named `assembly`) supports arbitrary sketch planes, single solids and placements. Run `node <skill-dir>/scripts/build.mjs MODEL.json NEW_DIR [--set name=value] [--preview]` in the project. Use the returned `directory` to find the effective `model.json`, exact `model.step` and `report.json`. The installed package exports the full schema as `@coloopx/colocad/schema`.
|
|
15
|
+
- For a `colocad/1` XY feature tree use the project's `node_modules/.bin/colocad plan TREE.json` and `node_modules/.bin/colocad build TREE.json NEW_DIR --preview`. Cuts start at `startZ` and travel along +Z. Linear pattern counts include their seed. This entry point also produces the feature tree and native job in `NEW_DIR/part/`.
|
|
16
|
+
|
|
17
|
+
Return the editable model and STEP. Reopen the STEP and check the dimensions that distinguish success for this task, such as a bore's diameter and axis or a cut reaching the cavity. For a long construction, keep inspectable milestones and a fixed camera. An assembly preview establishes appearance. A fit or motion claim needs the corresponding measurement.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"units": "mm",
|
|
4
|
+
"parameters": {
|
|
5
|
+
"foot": 40,
|
|
6
|
+
"upright": 32,
|
|
7
|
+
"span": 24,
|
|
8
|
+
"wall": 4,
|
|
9
|
+
"holeDiameter": 5
|
|
10
|
+
},
|
|
11
|
+
"features": [
|
|
12
|
+
{
|
|
13
|
+
"id": "angle",
|
|
14
|
+
"op": "extrude",
|
|
15
|
+
"frame": {"origin": [0, 0, 0], "x_axis": [1, 0, 0], "y_axis": [0, 0, 1]},
|
|
16
|
+
"profile": {"kind": "polygon", "points": [[0, 0], [{"param": "foot"}, 0], [{"param": "foot"}, {"param": "wall"}], [{"param": "wall"}, {"param": "wall"}], [{"param": "wall"}, {"param": "upright"}], [0, {"param": "upright"}]]},
|
|
17
|
+
"height": {"param": "span"}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"id": "footHole",
|
|
21
|
+
"op": "face_holes",
|
|
22
|
+
"input": "angle",
|
|
23
|
+
"face": "neg_z",
|
|
24
|
+
"positions": [[{"op": "div", "a": {"param": "foot"}, "b": 2}, {"op": "div", "a": {"param": "span"}, "b": -2}]],
|
|
25
|
+
"radius": {"op": "div", "a": {"param": "holeDiameter"}, "b": 2},
|
|
26
|
+
"depth": {"param": "wall"}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"id": "uprightHole",
|
|
30
|
+
"op": "face_holes",
|
|
31
|
+
"input": "footHole",
|
|
32
|
+
"face": "neg_x",
|
|
33
|
+
"positions": [[{"op": "div", "a": {"param": "span"}, "b": -2}, {"op": "div", "a": {"param": "upright"}, "b": 2}]],
|
|
34
|
+
"radius": {"op": "div", "a": {"param": "holeDiameter"}, "b": 2},
|
|
35
|
+
"depth": {"param": "wall"}
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"output": "uprightHole"
|
|
39
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"units": "mm",
|
|
4
|
+
"parameters": {
|
|
5
|
+
"diameter": 16
|
|
6
|
+
},
|
|
7
|
+
"features": [
|
|
8
|
+
{
|
|
9
|
+
"id": "stock",
|
|
10
|
+
"op": "sphere",
|
|
11
|
+
"center": [0, 0, 0],
|
|
12
|
+
"radius": {"op": "div", "a": {"param": "diameter"}, "b": 2}
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"output": "stock"
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"units": "mm",
|
|
4
|
+
"parameters": {
|
|
5
|
+
"length": 40,
|
|
6
|
+
"width": 25,
|
|
7
|
+
"height": 8
|
|
8
|
+
},
|
|
9
|
+
"features": [
|
|
10
|
+
{
|
|
11
|
+
"id": "stock",
|
|
12
|
+
"op": "box",
|
|
13
|
+
"origin": [0, 0, 0],
|
|
14
|
+
"size": [{"param": "length"}, {"param": "width"}, {"param": "height"}]
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"output": "stock"
|
|
18
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"units": "mm",
|
|
4
|
+
"parameters": {
|
|
5
|
+
"width": 60,
|
|
6
|
+
"depth": 40,
|
|
7
|
+
"height": 22,
|
|
8
|
+
"wall": 2,
|
|
9
|
+
"floor": 3,
|
|
10
|
+
"portWidth": 12,
|
|
11
|
+
"portHeight": 6,
|
|
12
|
+
"portCenterZ": 12
|
|
13
|
+
},
|
|
14
|
+
"features": [
|
|
15
|
+
{
|
|
16
|
+
"id": "shell",
|
|
17
|
+
"op": "shell_body",
|
|
18
|
+
"profile": {"kind": "rectangle", "width": {"param": "width"}, "depth": {"param": "depth"}},
|
|
19
|
+
"height": {"param": "height"},
|
|
20
|
+
"wall": {"param": "wall"},
|
|
21
|
+
"floor": {"param": "floor"},
|
|
22
|
+
"open_face": "top"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"id": "port",
|
|
26
|
+
"op": "face_cutout",
|
|
27
|
+
"input": "shell",
|
|
28
|
+
"face": "pos_y",
|
|
29
|
+
"center": [0, {"param": "portCenterZ"}],
|
|
30
|
+
"profile": {"kind": "rectangle", "width": {"param": "portWidth"}, "depth": {"param": "portHeight"}},
|
|
31
|
+
"depth": {"param": "wall"}
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"output": "port"
|
|
35
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"units": "mm",
|
|
4
|
+
"parameters": {
|
|
5
|
+
"diameter": 8,
|
|
6
|
+
"length": 20
|
|
7
|
+
},
|
|
8
|
+
"features": [
|
|
9
|
+
{
|
|
10
|
+
"id": "stock",
|
|
11
|
+
"op": "cylinder",
|
|
12
|
+
"origin": [0, 0, 0],
|
|
13
|
+
"radius": {"op": "div", "a": {"param": "diameter"}, "b": 2},
|
|
14
|
+
"height": {"param": "length"}
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"output": "stock"
|
|
18
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"units": "mm",
|
|
4
|
+
"parameters": {
|
|
5
|
+
"length": 80,
|
|
6
|
+
"width": 50,
|
|
7
|
+
"thickness": 6,
|
|
8
|
+
"holeDiameter": 6,
|
|
9
|
+
"xCount": 2,
|
|
10
|
+
"yCount": 2,
|
|
11
|
+
"xPitch": 50,
|
|
12
|
+
"yPitch": 30
|
|
13
|
+
},
|
|
14
|
+
"features": [
|
|
15
|
+
{
|
|
16
|
+
"id": "plate",
|
|
17
|
+
"op": "box",
|
|
18
|
+
"origin": [0, 0, 0],
|
|
19
|
+
"size": [{"param": "length"}, {"param": "width"}, {"param": "thickness"}]
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id": "mounts",
|
|
23
|
+
"op": "face_hole_grid",
|
|
24
|
+
"input": "plate",
|
|
25
|
+
"face": "pos_z",
|
|
26
|
+
"center": [{"op": "div", "a": {"param": "length"}, "b": 2}, {"op": "div", "a": {"param": "width"}, "b": 2}],
|
|
27
|
+
"count": [{"param": "xCount"}, {"param": "yCount"}],
|
|
28
|
+
"spacing": [{"param": "xPitch"}, {"param": "yPitch"}],
|
|
29
|
+
"radius": {"op": "div", "a": {"param": "holeDiameter"}, "b": 2},
|
|
30
|
+
"depth": {"param": "thickness"}
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"output": "mounts"
|
|
34
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"units": "mm",
|
|
4
|
+
"parameters": {
|
|
5
|
+
"outerDiameter": 12,
|
|
6
|
+
"boreDiameter": 6,
|
|
7
|
+
"length": 16
|
|
8
|
+
},
|
|
9
|
+
"features": [
|
|
10
|
+
{
|
|
11
|
+
"id": "sleeve",
|
|
12
|
+
"op": "extrude",
|
|
13
|
+
"profile": {"kind": "circle", "radius": {"op": "div", "a": {"param": "outerDiameter"}, "b": 2}},
|
|
14
|
+
"holes": [{"kind": "circle", "radius": {"op": "div", "a": {"param": "boreDiameter"}, "b": 2}}],
|
|
15
|
+
"height": {"param": "length"}
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"output": "sleeve"
|
|
19
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"units": "mm",
|
|
4
|
+
"parameters": {
|
|
5
|
+
"baseDiameter": 16,
|
|
6
|
+
"topDiameter": 8,
|
|
7
|
+
"height": 20
|
|
8
|
+
},
|
|
9
|
+
"features": [
|
|
10
|
+
{
|
|
11
|
+
"id": "stock",
|
|
12
|
+
"op": "cone",
|
|
13
|
+
"origin": [0, 0, 0],
|
|
14
|
+
"base_radius": {"op": "div", "a": {"param": "baseDiameter"}, "b": 2},
|
|
15
|
+
"top_radius": {"op": "div", "a": {"param": "topDiameter"}, "b": 2},
|
|
16
|
+
"height": {"param": "height"}
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"output": "stock"
|
|
20
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Quick construction in millimetres
|
|
2
|
+
|
|
3
|
+
Run from the project containing the installed npm dependency. Set `skill` to the directory containing this skill's `SKILL.md`. For a 100 × 50 × 6 mm plate with a centered 3 × 2 pattern of Ø6 mm through-holes, use the following command. The pitches are center-to-center, 32 mm along X and 30 mm along Y.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
skill="${CODEX_HOME:-$HOME/.codex}/skills/colocad"
|
|
7
|
+
node "$skill/scripts/build.mjs" "$skill/assets/plate-grid.json" ./plate-v1 \
|
|
8
|
+
--set length=100 --set xCount=3 --set xPitch=32 --preview
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Each invocation takes a new output directory. Edit the saved `model.json` to add features or pass it back to the helper with another `--set` to change an existing dimension. Overrides are saved in the built model. Only request a preview when you need to inspect it.
|
|
12
|
+
|
|
13
|
+
| Shape or structure | Shortest construction in this skill | Datum and acceptance check |
|
|
14
|
+
|---|---|---|
|
|
15
|
+
| Block, pin, ball or taper | Use one feature from [block](../assets/block.json), [pin](../assets/pin.json), [ball](../assets/ball.json) or [taper](../assets/taper.json). For example, pass `pin.json` with `--set diameter=8 --set length=40` for a Ø8 × 40 mm pin. | Box origin is the lower corner. A cylinder or cone starts at its base center and grows along +Z. Check the outer envelope. |
|
|
16
|
+
| Mounting plate or perforated rail | [Plate with centered hole grid](../assets/plate-grid.json) uses a box and one `face_hole_grid`. Use `yCount=1` for one row. Keep both pitches positive. | XY starts at the lower corner. Confirm count, hole centers and minimum edge material. For centered columns the end margin is `(length − (xCount−1) × xPitch − holeDiameter) / 2`. Check Y likewise. |
|
|
17
|
+
| Ring, spacer or plain sleeve | [Sleeve](../assets/sleeve.json) extrudes an annular profile in one feature. Use positive diameters with the bore smaller than the outside diameter. | Axis is +Z, bottom at Z=0. Check that the bore goes through and the radial wall is `(outerDiameter−boreDiameter)/2`. |
|
|
18
|
+
| Right-angle mounting bracket | [L-section with perpendicular holes](../assets/angle-bracket.json) extrudes one L profile, then drills each leg from its outside face. Shorten the feature list and select `angle` as output for a plain angle. | Section lies in XZ and extrudes toward −Y. The foot and upright dimensions include the shared corner. Check one connected solid and both bore axes. |
|
|
19
|
+
| Open housing with a side window | [Housing](../assets/open-housing.json) uses `shell_body` followed by `face_cutout`. Set the output to `shell` and remove the last feature for an uncut tray. | XY centered, floor starts at Z=0, opening is +Z. Port center is on +Y at world (X,Z). Check wall, floor and air through the side port, including material above and below it. |
|
|
20
|
+
|
|
21
|
+
For a custom single solid, append a native feature referencing the previous feature's ID and set `output` to the new ID. A `face_*` operation starts on the selected outer bounding plane and cuts inward. Centers on ±X use world (Y,Z), on ±Y use (X,Z), and on ±Z use (X,Y). For a recessed or inclined face use a local sketch `frame` and `holes` or `cutout`. A diameter from the drawing becomes a radius in the native operation. Keep the conversion as a parameter expression so edits rebuild correctly.
|
|
22
|
+
|
|
23
|
+
## Place the same part twice
|
|
24
|
+
|
|
25
|
+
Given two identical 16 mm sleeves separated by a 4 mm axial gap, start from the sleeve model. This uses the same definition for both occurrences and ties the upper position to the edited length. Run in the same shell as above.
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
node --input-type=module - "$skill/assets/sleeve.json" > pair.json <<'JS'
|
|
29
|
+
import { readFileSync } from 'node:fs';
|
|
30
|
+
const model = JSON.parse(readFileSync(process.argv[2], 'utf8'));
|
|
31
|
+
const sleeve = model.output;
|
|
32
|
+
delete model.output;
|
|
33
|
+
model.parameters.gap = 4;
|
|
34
|
+
model.assembly = [
|
|
35
|
+
{ id: 'lower', input: sleeve, translation: [0, 0, 0] },
|
|
36
|
+
{ id: 'upper', input: sleeve, translation: [0, 0,
|
|
37
|
+
{ op: 'add', a: { param: 'length' }, b: { param: 'gap' } }] }
|
|
38
|
+
];
|
|
39
|
+
console.log(JSON.stringify(model, null, 2));
|
|
40
|
+
JS
|
|
41
|
+
node "$skill/scripts/build.mjs" pair.json ./pair-v1 --set length=20
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Check two solids on the same axis. In the edited model the lower sleeve spans Z=0…20 and the upper spans Z=24…44 mm. For one fused part, combine the stock and additions with native features and select one `output`. For an assembly, name each physical occurrence and preserve independent solids.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { mkdir, readFile, rmdir } from 'node:fs/promises';
|
|
3
|
+
import { resolve, join } from 'node:path';
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
5
|
+
import { createRequire } from 'node:module';
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
const [input, output, ...flags] = process.argv.slice(2);
|
|
9
|
+
if (!input || !output)
|
|
10
|
+
throw Error('usage: node build.mjs MODEL.json NEW_DIRECTORY [--set name=value]... [--preview]');
|
|
11
|
+
// The skill lives outside node_modules. Use the consumer project’s pinned SDK.
|
|
12
|
+
const project = createRequire(join(process.cwd(), 'package.json'));
|
|
13
|
+
const name = '@coloopx/colocad';
|
|
14
|
+
let entry;
|
|
15
|
+
for (const root of project.resolve.paths(name)) {
|
|
16
|
+
const pkg = join(root, name);
|
|
17
|
+
try {
|
|
18
|
+
const manifest = JSON.parse(await readFile(join(pkg, 'package.json'), 'utf8'));
|
|
19
|
+
entry = join(pkg, manifest.exports['./kernel'].import);
|
|
20
|
+
break;
|
|
21
|
+
} catch (e) { if (e.code !== 'ENOENT') throw e; }
|
|
22
|
+
}
|
|
23
|
+
if (!entry) throw Error('Install @coloopx/colocad in the current project first.');
|
|
24
|
+
const { CadClient } = await import(pathToFileURL(entry).href);
|
|
25
|
+
const model = JSON.parse(await readFile(input, 'utf8'));
|
|
26
|
+
if (model.version !== 1 || (!model.output && !model.assembly?.length))
|
|
27
|
+
throw Error('Expected a kernel model with output or assembly. For colocad/1 feature trees use colocad build.');
|
|
28
|
+
for (let i = 0; i < flags.length; i++) {
|
|
29
|
+
if (flags[i] === '--preview') {
|
|
30
|
+
model.preview ??= {};
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (flags[i] !== '--set') throw Error('Unknown option: ' + flags[i]);
|
|
34
|
+
const assignment = flags[++i] ?? '';
|
|
35
|
+
const [key, value, extra] = assignment.split('=');
|
|
36
|
+
if (extra !== undefined || !value?.trim() || !Number.isFinite(Number(value)))
|
|
37
|
+
throw Error('Expected --set name=number, got: ' + assignment);
|
|
38
|
+
if (!Object.hasOwn(model.parameters ?? {}, key)) throw Error('Unknown model parameter: ' + key);
|
|
39
|
+
model.parameters[key] = Number(value);
|
|
40
|
+
}
|
|
41
|
+
const dest = resolve(output);
|
|
42
|
+
await mkdir(dest, { recursive: false });
|
|
43
|
+
try {
|
|
44
|
+
const result = await new CadClient({ outputRoot: dest, wallMs: 120000 }).build(model);
|
|
45
|
+
if (!result.ok) throw Error(JSON.stringify(result.error));
|
|
46
|
+
console.log(JSON.stringify({ directory: result.data.artifact_directory, geometry: result.data.geometry }));
|
|
47
|
+
} catch (error) {
|
|
48
|
+
// Remove only the empty directory reserved by this invocation.
|
|
49
|
+
await rmdir(dest).catch(() => {});
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error(error.message); process.exitCode = 1;
|
|
54
|
+
}
|