@coloopx/colocad 0.0.0-stage → 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.
Files changed (194) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE.md +5 -0
  3. package/README.md +131 -2
  4. package/README.zh-CN.md +100 -0
  5. package/bin/colocad.mjs +32 -0
  6. package/examples/manifold.json +11 -0
  7. package/examples/sensor-rail.json +9 -0
  8. package/kernel/LICENSE +21 -0
  9. package/kernel/dist/artifacts.d.ts +3 -0
  10. package/kernel/dist/artifacts.js +19 -0
  11. package/kernel/dist/assets.d.ts +3 -0
  12. package/kernel/dist/assets.js +11 -0
  13. package/kernel/dist/binary.d.ts +2 -0
  14. package/kernel/dist/binary.js +14 -0
  15. package/kernel/dist/client.d.ts +22 -0
  16. package/kernel/dist/client.js +99 -0
  17. package/kernel/dist/files.d.ts +19 -0
  18. package/kernel/dist/files.js +103 -0
  19. package/kernel/dist/generated.d.ts +707 -0
  20. package/kernel/dist/generated.js +1 -0
  21. package/kernel/dist/helpers.d.ts +9 -0
  22. package/kernel/dist/helpers.js +23 -0
  23. package/kernel/dist/index.d.ts +8 -0
  24. package/kernel/dist/index.js +6 -0
  25. package/kernel/dist/preview-cache.d.ts +19 -0
  26. package/kernel/dist/preview-cache.js +29 -0
  27. package/kernel/dist/process.d.ts +12 -0
  28. package/kernel/dist/process.js +41 -0
  29. package/kernel/dist/tools.d.ts +67 -0
  30. package/kernel/dist/tools.js +20 -0
  31. package/kernel/dist/types.d.ts +26 -0
  32. package/kernel/dist/types.js +1 -0
  33. package/kernel/licenses/adler2-2.0.1-LICENSE-0BSD +12 -0
  34. package/kernel/licenses/adler2-2.0.1-LICENSE-APACHE +201 -0
  35. package/kernel/licenses/adler2-2.0.1-LICENSE-MIT +23 -0
  36. package/kernel/licenses/allocator-api2-0.2.21-LICENSE-APACHE +176 -0
  37. package/kernel/licenses/allocator-api2-0.2.21-LICENSE-MIT +23 -0
  38. package/kernel/licenses/autocfg-1.5.1-LICENSE-APACHE +201 -0
  39. package/kernel/licenses/autocfg-1.5.1-LICENSE-MIT +25 -0
  40. package/kernel/licenses/bitflags-1.3.2-LICENSE-APACHE +201 -0
  41. package/kernel/licenses/bitflags-1.3.2-LICENSE-MIT +25 -0
  42. package/kernel/licenses/block-buffer-0.10.4-LICENSE-APACHE +201 -0
  43. package/kernel/licenses/block-buffer-0.10.4-LICENSE-MIT +25 -0
  44. package/kernel/licenses/cfg-if-1.0.5-LICENSE-APACHE +201 -0
  45. package/kernel/licenses/cfg-if-1.0.5-LICENSE-MIT +25 -0
  46. package/kernel/licenses/cpufeatures-0.2.17-LICENSE-APACHE +201 -0
  47. package/kernel/licenses/cpufeatures-0.2.17-LICENSE-MIT +25 -0
  48. package/kernel/licenses/crc32fast-1.5.4-LICENSE-APACHE +202 -0
  49. package/kernel/licenses/crc32fast-1.5.4-LICENSE-MIT +21 -0
  50. package/kernel/licenses/crossbeam-deque-0.8.8-LICENSE-APACHE +201 -0
  51. package/kernel/licenses/crossbeam-deque-0.8.8-LICENSE-MIT +27 -0
  52. package/kernel/licenses/crossbeam-epoch-0.9.21-LICENSE-APACHE +201 -0
  53. package/kernel/licenses/crossbeam-epoch-0.9.21-LICENSE-MIT +27 -0
  54. package/kernel/licenses/crossbeam-utils-0.8.23-LICENSE-APACHE +201 -0
  55. package/kernel/licenses/crossbeam-utils-0.8.23-LICENSE-MIT +27 -0
  56. package/kernel/licenses/crypto-common-0.1.7-LICENSE-APACHE +201 -0
  57. package/kernel/licenses/crypto-common-0.1.7-LICENSE-MIT +25 -0
  58. package/kernel/licenses/dependencies.json +618 -0
  59. package/kernel/licenses/digest-0.10.7-LICENSE-APACHE +201 -0
  60. package/kernel/licenses/digest-0.10.7-LICENSE-MIT +25 -0
  61. package/kernel/licenses/dyn-clone-1.0.20-LICENSE-APACHE +176 -0
  62. package/kernel/licenses/dyn-clone-1.0.20-LICENSE-MIT +23 -0
  63. package/kernel/licenses/either-1.19.0-LICENSE-APACHE +201 -0
  64. package/kernel/licenses/either-1.19.0-LICENSE-MIT +25 -0
  65. package/kernel/licenses/equivalent-1.0.3-LICENSE-APACHE +201 -0
  66. package/kernel/licenses/equivalent-1.0.3-LICENSE-MIT +25 -0
  67. package/kernel/licenses/fdeflate-0.3.7-LICENSE-APACHE +177 -0
  68. package/kernel/licenses/fdeflate-0.3.7-LICENSE-MIT +25 -0
  69. package/kernel/licenses/flate2-1.1.10-LICENSE-APACHE +201 -0
  70. package/kernel/licenses/flate2-1.1.10-LICENSE-MIT +25 -0
  71. package/kernel/licenses/foldhash-0.2.0-LICENSE +19 -0
  72. package/kernel/licenses/generic-array-0.14.7-LICENSE +21 -0
  73. package/kernel/licenses/hashbrown-0.16.1-LICENSE-APACHE +201 -0
  74. package/kernel/licenses/hashbrown-0.16.1-LICENSE-MIT +25 -0
  75. package/kernel/licenses/itoa-1.0.18-LICENSE-APACHE +176 -0
  76. package/kernel/licenses/itoa-1.0.18-LICENSE-MIT +23 -0
  77. package/kernel/licenses/libc-0.2.191-LICENSE-APACHE +176 -0
  78. package/kernel/licenses/libc-0.2.191-LICENSE-MIT +25 -0
  79. package/kernel/licenses/memchr-2.8.3-COPYING +3 -0
  80. package/kernel/licenses/memchr-2.8.3-LICENSE-MIT +21 -0
  81. package/kernel/licenses/miniz_oxide-0.8.9-LICENSE +25 -0
  82. package/kernel/licenses/miniz_oxide-0.8.9-LICENSE-APACHE.md +177 -0
  83. package/kernel/licenses/miniz_oxide-0.8.9-LICENSE-MIT.md +24 -0
  84. package/kernel/licenses/miniz_oxide-0.8.9-LICENSE-ZLIB.md +14 -0
  85. package/kernel/licenses/miniz_oxide-0.9.1-LICENSE +25 -0
  86. package/kernel/licenses/miniz_oxide-0.9.1-LICENSE-APACHE.md +177 -0
  87. package/kernel/licenses/miniz_oxide-0.9.1-LICENSE-MIT.md +24 -0
  88. package/kernel/licenses/miniz_oxide-0.9.1-LICENSE-ZLIB.md +14 -0
  89. package/kernel/licenses/num-traits-0.2.19-LICENSE-APACHE +201 -0
  90. package/kernel/licenses/num-traits-0.2.19-LICENSE-MIT +25 -0
  91. package/kernel/licenses/png-0.17.16-LICENSE-APACHE +201 -0
  92. package/kernel/licenses/png-0.17.16-LICENSE-MIT +25 -0
  93. package/kernel/licenses/proc-macro2-1.0.107-LICENSE-APACHE +176 -0
  94. package/kernel/licenses/proc-macro2-1.0.107-LICENSE-MIT +23 -0
  95. package/kernel/licenses/quote-1.0.47-LICENSE-APACHE +176 -0
  96. package/kernel/licenses/quote-1.0.47-LICENSE-MIT +23 -0
  97. package/kernel/licenses/rayon-1.12.0-LICENSE-APACHE +201 -0
  98. package/kernel/licenses/rayon-1.12.0-LICENSE-MIT +25 -0
  99. package/kernel/licenses/rayon-core-1.13.0-LICENSE-APACHE +201 -0
  100. package/kernel/licenses/rayon-core-1.13.0-LICENSE-MIT +25 -0
  101. package/kernel/licenses/ref-cast-1.0.27-LICENSE-APACHE +176 -0
  102. package/kernel/licenses/ref-cast-1.0.27-LICENSE-MIT +23 -0
  103. package/kernel/licenses/ref-cast-impl-1.0.27-LICENSE-APACHE +176 -0
  104. package/kernel/licenses/ref-cast-impl-1.0.27-LICENSE-MIT +23 -0
  105. package/kernel/licenses/robust-1.2.0-LICENSE-APACHE +201 -0
  106. package/kernel/licenses/robust-1.2.0-LICENSE-MIT +26 -0
  107. package/kernel/licenses/schemars-1.2.3-LICENSE +21 -0
  108. package/kernel/licenses/schemars_derive-1.2.3-LICENSE +21 -0
  109. package/kernel/licenses/serde-1.0.229-LICENSE-APACHE +176 -0
  110. package/kernel/licenses/serde-1.0.229-LICENSE-MIT +23 -0
  111. package/kernel/licenses/serde_core-1.0.229-LICENSE-APACHE +176 -0
  112. package/kernel/licenses/serde_core-1.0.229-LICENSE-MIT +23 -0
  113. package/kernel/licenses/serde_derive-1.0.229-LICENSE-APACHE +176 -0
  114. package/kernel/licenses/serde_derive-1.0.229-LICENSE-MIT +23 -0
  115. package/kernel/licenses/serde_derive_internals-0.30.0-LICENSE-APACHE +176 -0
  116. package/kernel/licenses/serde_derive_internals-0.30.0-LICENSE-MIT +23 -0
  117. package/kernel/licenses/serde_json-1.0.154-LICENSE-APACHE +176 -0
  118. package/kernel/licenses/serde_json-1.0.154-LICENSE-MIT +23 -0
  119. package/kernel/licenses/sha2-0.10.9-LICENSE-APACHE +201 -0
  120. package/kernel/licenses/sha2-0.10.9-LICENSE-MIT +27 -0
  121. package/kernel/licenses/simd-adler32-0.3.10-LICENSE.md +21 -0
  122. package/kernel/licenses/smallvec-1.16.4-LICENSE-APACHE +201 -0
  123. package/kernel/licenses/smallvec-1.16.4-LICENSE-MIT +25 -0
  124. package/kernel/licenses/solidcore-1.0.1-LICENSE +203 -0
  125. package/kernel/licenses/solidcore-1.0.1-NOTICE +30 -0
  126. package/kernel/licenses/solidcore-ATTRIBUTION.md +92 -0
  127. package/kernel/licenses/solidcore-LICENSE +203 -0
  128. package/kernel/licenses/solidcore-NOTICE +30 -0
  129. package/kernel/licenses/solidcore-convert-0.1.0-ATTRIBUTION.md +92 -0
  130. package/kernel/licenses/solidcore-convert-0.1.0-LICENSE +203 -0
  131. package/kernel/licenses/solidcore-convert-0.1.0-NOTICE +30 -0
  132. package/kernel/licenses/solidcore-record-0.1.0-ATTRIBUTION.md +92 -0
  133. package/kernel/licenses/solidcore-record-0.1.0-LICENSE +203 -0
  134. package/kernel/licenses/solidcore-record-0.1.0-NOTICE +30 -0
  135. package/kernel/licenses/solidcore-tess-0.1.0-ATTRIBUTION.md +92 -0
  136. package/kernel/licenses/solidcore-tess-0.1.0-LICENSE +203 -0
  137. package/kernel/licenses/solidcore-tess-0.1.0-NOTICE +30 -0
  138. package/kernel/licenses/spade-2.15.1-LICENSE-APACHE +202 -0
  139. package/kernel/licenses/spade-2.15.1-LICENSE-MIT +25 -0
  140. package/kernel/licenses/step-brep-0.1.0-ATTRIBUTION.md +92 -0
  141. package/kernel/licenses/step-brep-0.1.0-LICENSE +203 -0
  142. package/kernel/licenses/step-brep-0.1.0-NOTICE +30 -0
  143. package/kernel/licenses/step-export-0.1.0-ATTRIBUTION.md +92 -0
  144. package/kernel/licenses/step-export-0.1.0-LICENSE +203 -0
  145. package/kernel/licenses/step-export-0.1.0-NOTICE +30 -0
  146. package/kernel/licenses/step-import-0.1.0-ATTRIBUTION.md +92 -0
  147. package/kernel/licenses/step-import-0.1.0-LICENSE +203 -0
  148. package/kernel/licenses/step-import-0.1.0-NOTICE +30 -0
  149. package/kernel/licenses/syn-3.0.9-LICENSE-APACHE +176 -0
  150. package/kernel/licenses/syn-3.0.9-LICENSE-MIT +23 -0
  151. package/kernel/licenses/thiserror-2.0.21-LICENSE-APACHE +176 -0
  152. package/kernel/licenses/thiserror-2.0.21-LICENSE-MIT +23 -0
  153. package/kernel/licenses/thiserror-impl-2.0.21-LICENSE-APACHE +176 -0
  154. package/kernel/licenses/thiserror-impl-2.0.21-LICENSE-MIT +23 -0
  155. package/kernel/licenses/typenum-1.20.1-LICENSE +1 -0
  156. package/kernel/licenses/typenum-1.20.1-LICENSE-APACHE +201 -0
  157. package/kernel/licenses/typenum-1.20.1-LICENSE-MIT +21 -0
  158. package/kernel/licenses/unicode-ident-1.0.27-LICENSE-APACHE +176 -0
  159. package/kernel/licenses/unicode-ident-1.0.27-LICENSE-MIT +23 -0
  160. package/kernel/licenses/unicode-ident-1.0.27-LICENSE-UNICODE +39 -0
  161. package/kernel/licenses/version_check-0.9.5-LICENSE-APACHE +201 -0
  162. package/kernel/licenses/version_check-0.9.5-LICENSE-MIT +19 -0
  163. package/kernel/licenses/zlib-rs-0.6.8-LICENSE +19 -0
  164. package/kernel/licenses/zmij-1.0.23-LICENSE-MIT +23 -0
  165. package/kernel/native/darwin-arm64/agent-cad +4 -0
  166. package/kernel/native/darwin-arm64/manifest.json +6 -0
  167. package/kernel/native/linux-arm64/agent-cad +4 -0
  168. package/kernel/native/linux-arm64/manifest.json +6 -0
  169. package/kernel/native/linux-x64/agent-cad +4 -0
  170. package/kernel/native/linux-x64/manifest.json +6 -0
  171. package/kernel/release.json +8 -0
  172. package/kernel/schemas/model.schema.json +4080 -0
  173. package/package.json +59 -4
  174. package/scripts/check-release.mjs +24 -0
  175. package/skills/colocad/SKILL.md +17 -0
  176. package/skills/colocad/assets/angle-bracket.json +39 -0
  177. package/skills/colocad/assets/ball.json +16 -0
  178. package/skills/colocad/assets/block.json +18 -0
  179. package/skills/colocad/assets/open-housing.json +35 -0
  180. package/skills/colocad/assets/pin.json +18 -0
  181. package/skills/colocad/assets/plate-grid.json +34 -0
  182. package/skills/colocad/assets/sleeve.json +19 -0
  183. package/skills/colocad/assets/taper.json +20 -0
  184. package/skills/colocad/references/quick-build.md +44 -0
  185. package/skills/colocad/scripts/assembly.mjs +3 -0
  186. package/skills/colocad/scripts/build.mjs +54 -0
  187. package/solidworks/managed/Colocad.SolidWorks.deps.json +23 -0
  188. package/solidworks/managed/Colocad.SolidWorks.dll +0 -0
  189. package/solidworks/managed/Colocad.SolidWorks.runtimeconfig.json +13 -0
  190. package/src/build.mjs +69 -0
  191. package/src/index.d.mts +67 -0
  192. package/src/index.mjs +4 -0
  193. package/src/solidworks.mjs +65 -0
  194. package/src/tree.mjs +199 -0
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
2
  "name": "@coloopx/colocad",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0-alpha.3",
4
+ "description": "Parametric feature instructions, a local Rust B-rep kernel and an experimental SolidWorks author",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "engines": {
8
+ "node": ">=22"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/Coloopx/colocad.git"
13
+ },
14
+ "homepage": "https://github.com/Coloopx/colocad",
15
+ "bugs": {
16
+ "url": "https://github.com/Coloopx/colocad/issues"
17
+ },
18
+ "main": "./src/index.mjs",
19
+ "types": "./src/index.d.mts",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./src/index.d.mts",
23
+ "import": "./src/index.mjs"
24
+ },
25
+ "./kernel": {
26
+ "types": "./kernel/dist/index.d.ts",
27
+ "import": "./kernel/dist/index.js"
28
+ },
29
+ "./schema": "./kernel/schemas/model.schema.json"
30
+ },
31
+ "bin": {
32
+ "colocad": "bin/colocad.mjs"
33
+ },
34
+ "files": [
35
+ "bin/colocad.mjs",
36
+ "src",
37
+ "kernel/dist",
38
+ "kernel/native",
39
+ "kernel/schemas",
40
+ "kernel/licenses",
41
+ "solidworks/managed",
42
+ "examples/manifold.json",
43
+ "examples/sensor-rail.json",
44
+ "README.md",
45
+ "LICENSE",
46
+ "NOTICE.md",
47
+ "skills/colocad",
48
+ "kernel/release.json",
49
+ "scripts/check-release.mjs",
50
+ "README.zh-CN.md"
51
+ ],
52
+ "scripts": {
53
+ "test": "node --test test/*.test.mjs",
54
+ "build:kernel": "node scripts/build-kernel.mjs",
55
+ "prepack": "node scripts/check-release.mjs"
56
+ },
57
+ "publishConfig": {
58
+ "access": "public",
59
+ "registry": "https://registry.npmjs.org"
60
+ }
61
+ }
@@ -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,3 @@
1
+ #!/usr/bin/env node
2
+ // Keep the original entry point for projects that already invoke this skill.
3
+ import './build.mjs';
@@ -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
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "runtimeTarget": {
3
+ "name": ".NETCoreApp,Version=v8.0",
4
+ "signature": ""
5
+ },
6
+ "compilationOptions": {},
7
+ "targets": {
8
+ ".NETCoreApp,Version=v8.0": {
9
+ "Colocad.SolidWorks/1.0.0": {
10
+ "runtime": {
11
+ "Colocad.SolidWorks.dll": {}
12
+ }
13
+ }
14
+ }
15
+ },
16
+ "libraries": {
17
+ "Colocad.SolidWorks/1.0.0": {
18
+ "type": "project",
19
+ "serviceable": false,
20
+ "sha512": ""
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "runtimeOptions": {
3
+ "tfm": "net8.0",
4
+ "framework": {
5
+ "name": "Microsoft.NETCore.App",
6
+ "version": "8.0.0"
7
+ },
8
+ "configProperties": {
9
+ "System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
10
+ "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
11
+ }
12
+ }
13
+ }
package/src/build.mjs ADDED
@@ -0,0 +1,69 @@
1
+ import {
2
+ mkdtemp,
3
+ readFile,
4
+ writeFile,
5
+ mkdir,
6
+ rename,
7
+ rm,
8
+ } from "node:fs/promises";
9
+ import { join, resolve, dirname } from "node:path";
10
+ import { compileTree, kernelModel } from "./tree.mjs";
11
+ import { CadClient } from "../kernel/dist/index.js";
12
+
13
+ // Stage beside the destination. Acquiring an empty output directory with mkdir
14
+ // prevents overwriting someone else's receipt or racing a concurrent build.
15
+ export async function build(
16
+ tree,
17
+ destination,
18
+ { preview = false, binary } = {},
19
+ ) {
20
+ const plan = compileTree(tree);
21
+ const model = kernelModel(tree);
22
+ if (preview) model.preview = {};
23
+ const out = resolve(destination);
24
+ await mkdir(dirname(out), { recursive: true });
25
+ const stage = await mkdtemp(join(dirname(out), ".colocad-"));
26
+ let owned = false;
27
+ try {
28
+ const client = new CadClient({ outputRoot: stage, binary, wallMs: 120000 });
29
+ const result = await client.build(model);
30
+ if (!result.ok)
31
+ throw Error(result.error.code + ": " + result.error.message);
32
+ const folder = result.data.artifact_directory;
33
+ const receipt = JSON.parse(
34
+ await readFile(join(folder, "report.json"), "utf8"),
35
+ );
36
+ if (receipt.geometry.solids !== 1 || !(receipt.geometry.volume_mm3 > 0))
37
+ throw Error("Expected a single positive-volume solid");
38
+ const job = {
39
+ format: "colocad/native-job/1",
40
+ features: plan,
41
+ expected: {
42
+ volumeMM3: receipt.geometry.volume_mm3,
43
+ bboxMM: receipt.geometry.bbox_mm,
44
+ },
45
+ };
46
+ await writeFile(
47
+ join(folder, "feature-tree.json"),
48
+ JSON.stringify(tree, null, 2) + "\n",
49
+ );
50
+ await writeFile(
51
+ join(folder, "native-job.json"),
52
+ JSON.stringify(job, null, 2) + "\n",
53
+ );
54
+ await mkdir(out);
55
+ owned = true;
56
+ await rename(folder, join(out, "part"));
57
+ return {
58
+ directory: join(out, "part"),
59
+ step: join(out, "part", "model.step"),
60
+ nativeJob: join(out, "part", "native-job.json"),
61
+ geometry: receipt.geometry,
62
+ };
63
+ } catch (error) {
64
+ if (owned) await rm(out, { recursive: true, force: true });
65
+ throw error;
66
+ } finally {
67
+ await rm(stage, { recursive: true, force: true });
68
+ }
69
+ }
@@ -0,0 +1,67 @@
1
+ export { CadClient, createCadTools } from "../kernel/dist/index.js";
2
+ export type Dim = number | { param: string };
3
+ export type Point = [Dim, Dim];
4
+ export type Profile =
5
+ | { kind: "rectangle"; center: Point; size: Point }
6
+ | { kind: "circle"; center: Point; radius: Dim }
7
+ | { kind: "polygon"; points: Point[] };
8
+ export type Feature =
9
+ | {
10
+ id: string;
11
+ op: "extrude" | "cut";
12
+ profile: Profile;
13
+ startZ?: Dim;
14
+ depth: Dim;
15
+ }
16
+ | { id: string; op: "fillet"; edges: { z: Dim; count: Dim }; radius: Dim }
17
+ | {
18
+ id: string;
19
+ op: "linearPattern";
20
+ seed: string;
21
+ axis: "x" | "y";
22
+ pitch: Dim;
23
+ count: Dim;
24
+ };
25
+ export interface FeatureTree {
26
+ format: "colocad/1";
27
+ units: "mm";
28
+ parameters: Record<string, number>;
29
+ features: Feature[];
30
+ }
31
+ export interface Geometry {
32
+ solids: number;
33
+ volume_mm3: number;
34
+ bbox_mm: number[][];
35
+ edges: number;
36
+ faces: number;
37
+ }
38
+ export function compileTree(tree: FeatureTree): Feature[];
39
+ export function kernelModel(
40
+ tree: FeatureTree,
41
+ ): import("../kernel/dist/types.js").Model;
42
+ export function build(
43
+ tree: FeatureTree,
44
+ destination: string,
45
+ options?: { preview?: boolean; binary?: string },
46
+ ): Promise<{
47
+ directory: string;
48
+ step: string;
49
+ nativeJob: string;
50
+ geometry: Geometry;
51
+ }>;
52
+ export function writeSolidWorks(
53
+ input:
54
+ | FeatureTree
55
+ | {
56
+ format: "colocad/native-job/1";
57
+ features: Feature[];
58
+ expected: { volumeMM3: number; bboxMM: number[][] };
59
+ },
60
+ destination: string,
61
+ ): Promise<{
62
+ file: string;
63
+ reopened: boolean;
64
+ editRebuildVerified: boolean;
65
+ volumeMM3: number;
66
+ nativeFeatureCount: number;
67
+ }>;
package/src/index.mjs ADDED
@@ -0,0 +1,4 @@
1
+ export { compileTree, kernelModel } from "./tree.mjs";
2
+ export { build } from "./build.mjs";
3
+ export { CadClient, createCadTools } from "../kernel/dist/index.js";
4
+ export { writeSolidWorks } from "./solidworks.mjs";