surfcad-mcp 0.3.4 → 0.3.6

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/data/helpers.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "generatedFrom": "src/lib/surfcad/runtime.js HELPER_FUNCTIONS",
3
- "count": 80,
3
+ "count": 81,
4
4
  "helpers": [
5
5
  {
6
6
  "name": "shell",
@@ -21,7 +21,7 @@
21
21
  }
22
22
  ],
23
23
  "description": "shell(manifold, thickness, opening) — the CAVITY tool. ",
24
- "doc": "Hollows a solid out to a **uniform wall thickness**, leaving an opening at the\nface you choose. `hollow()` returns the finished walls; `shell()` returns the\ncavity so the older `part.subtract(shell(part, 2, 'z'))` still works.\n\nEvery boundary vertex is placed on the inward offset of each face meeting it, so\nthe wall measures `thickness` perpendicular to every face and corners stay sharp.\n(The pre-2026 version scaled the solid by one ratio, which gave a 60x20 box a\n2.5mm wall on Y and a 7.5mm wall on X.)\n\n\n\n**Parameters:**\n- `manifold` - The input manifold\n- `thickness` - Wall thickness in mm\n- `opening` - which face(s) the cavity breaks through (default `'z'`, the +Z face):\n - a signed axis: `'z'`, `'-z'`, `'x'`, `'-x'`, `'y'`, `'-y'`\n - `'none'` for a fully closed hollow\n - a face object from `facesByNormal()` / `planarFaceAt()`\n - a viewport face pick: `{ center: [...], normal: [...] }`\n - an array mixing any of the above\n\n**Returns:** `hollow()` the shelled solid; `shell()` the cavity to subtract\n\n**Notes:**\n- Picking a face that is no longer on the body throws and tells you to re-pick,\n rather than silently shelling the wrong side.\n- A thickness the body cannot take throws instead of returning a fold.\n- Curved and lofted walls are supported; the offset follows the tessellation.\n\n---",
24
+ "doc": "Hollows a solid out to a **uniform wall thickness**, leaving an opening at the\nface you choose. `hollow()` returns the finished walls; `shell()` returns the\ncavity so the older `part.subtract(shell(part, 2, 'z'))` still works.\n\nEvery boundary vertex is placed on the inward offset of each face meeting it, so\nthe wall measures `thickness` perpendicular to every face and corners stay sharp.\n(The pre-2026 version scaled the solid by one ratio, which gave a 60x20 box a\n2.5mm wall on Y and a 7.5mm wall on X.) A flat met by a fillet keeps its\ntangency line: those vertices move purely along the flat's normal, every\nvertex on a real flat lands exactly on the offset plane (an open rim's\ncorners too, so the rim keeps its corners instead of a fan of collinear\nvertices), and a sliver the warp turns inside out gets its diagonal swapped\nbefore the cavity is built, so a dense fillet (96 steps per quarter) hollows\nwithout fold pairs.\n\n\n\n**Parameters:**\n- `manifold` - The input manifold\n- `thickness` - Wall thickness in mm\n- `opening` - which face(s) the cavity breaks through (default `'z'`, the +Z face):\n - a signed axis: `'z'`, `'-z'`, `'x'`, `'-x'`, `'y'`, `'-y'`\n - `'none'` for a fully closed hollow\n - a face object from `facesByNormal()` / `planarFaceAt()`\n - a viewport face pick: `{ center: [...], normal: [...] }`\n - an array mixing any of the above\n\n**Returns:** `hollow()` the shelled solid; `shell()` the cavity to subtract\n\n**Notes:**\n- Picking a face that is no longer on the body throws and tells you to re-pick,\n rather than silently shelling the wrong side.\n- A thickness the body cannot take throws instead of returning a fold.\n- Curved and lofted walls are supported; the offset follows the tessellation.\n\n---",
25
25
  "examples": [
26
26
  "// Uniform 2mm wall, open at the top\nconst box = Manifold.cube([50, 30, 40], true);\nreturn hollow(box, 2, 'z');\n\n// Opening on a face you picked in the viewport, or queried\nlet part = Manifold.cylinder(40, 20, 20, 64);\npart = hollow(part, 2.5, facesByNormal(part, [0, 0, 1])[0]);\n\n// Closed hollow (a sealed void), and two openings at once\nconst sealed = hollow(Manifold.cube([30, 30, 30], true), 3, 'none');\nconst openBoth = hollow(Manifold.cube([30, 30, 30], true), 3, ['z', '-z']);"
27
27
  ]
@@ -45,7 +45,7 @@
45
45
  }
46
46
  ],
47
47
  "description": "hollow(manifold, thickness, opening) — the shelled SOLID (walls only).",
48
- "doc": "Hollows a solid out to a **uniform wall thickness**, leaving an opening at the\nface you choose. `hollow()` returns the finished walls; `shell()` returns the\ncavity so the older `part.subtract(shell(part, 2, 'z'))` still works.\n\nEvery boundary vertex is placed on the inward offset of each face meeting it, so\nthe wall measures `thickness` perpendicular to every face and corners stay sharp.\n(The pre-2026 version scaled the solid by one ratio, which gave a 60x20 box a\n2.5mm wall on Y and a 7.5mm wall on X.)\n\n\n\n**Parameters:**\n- `manifold` - The input manifold\n- `thickness` - Wall thickness in mm\n- `opening` - which face(s) the cavity breaks through (default `'z'`, the +Z face):\n - a signed axis: `'z'`, `'-z'`, `'x'`, `'-x'`, `'y'`, `'-y'`\n - `'none'` for a fully closed hollow\n - a face object from `facesByNormal()` / `planarFaceAt()`\n - a viewport face pick: `{ center: [...], normal: [...] }`\n - an array mixing any of the above\n\n**Returns:** `hollow()` the shelled solid; `shell()` the cavity to subtract\n\n**Notes:**\n- Picking a face that is no longer on the body throws and tells you to re-pick,\n rather than silently shelling the wrong side.\n- A thickness the body cannot take throws instead of returning a fold.\n- Curved and lofted walls are supported; the offset follows the tessellation.\n\n---",
48
+ "doc": "Hollows a solid out to a **uniform wall thickness**, leaving an opening at the\nface you choose. `hollow()` returns the finished walls; `shell()` returns the\ncavity so the older `part.subtract(shell(part, 2, 'z'))` still works.\n\nEvery boundary vertex is placed on the inward offset of each face meeting it, so\nthe wall measures `thickness` perpendicular to every face and corners stay sharp.\n(The pre-2026 version scaled the solid by one ratio, which gave a 60x20 box a\n2.5mm wall on Y and a 7.5mm wall on X.) A flat met by a fillet keeps its\ntangency line: those vertices move purely along the flat's normal, every\nvertex on a real flat lands exactly on the offset plane (an open rim's\ncorners too, so the rim keeps its corners instead of a fan of collinear\nvertices), and a sliver the warp turns inside out gets its diagonal swapped\nbefore the cavity is built, so a dense fillet (96 steps per quarter) hollows\nwithout fold pairs.\n\n\n\n**Parameters:**\n- `manifold` - The input manifold\n- `thickness` - Wall thickness in mm\n- `opening` - which face(s) the cavity breaks through (default `'z'`, the +Z face):\n - a signed axis: `'z'`, `'-z'`, `'x'`, `'-x'`, `'y'`, `'-y'`\n - `'none'` for a fully closed hollow\n - a face object from `facesByNormal()` / `planarFaceAt()`\n - a viewport face pick: `{ center: [...], normal: [...] }`\n - an array mixing any of the above\n\n**Returns:** `hollow()` the shelled solid; `shell()` the cavity to subtract\n\n**Notes:**\n- Picking a face that is no longer on the body throws and tells you to re-pick,\n rather than silently shelling the wrong side.\n- A thickness the body cannot take throws instead of returning a fold.\n- Curved and lofted walls are supported; the offset follows the tessellation.\n\n---",
49
49
  "examples": [
50
50
  "// Uniform 2mm wall, open at the top\nconst box = Manifold.cube([50, 30, 40], true);\nreturn hollow(box, 2, 'z');\n\n// Opening on a face you picked in the viewport, or queried\nlet part = Manifold.cylinder(40, 20, 20, 64);\npart = hollow(part, 2.5, facesByNormal(part, [0, 0, 1])[0]);\n\n// Closed hollow (a sealed void), and two openings at once\nconst sealed = hollow(Manifold.cube([30, 30, 30], true), 3, 'none');\nconst openBoth = hollow(Manifold.cube([30, 30, 30], true), 3, ['z', '-z']);"
51
51
  ]
@@ -349,7 +349,7 @@
349
349
  }
350
350
  ],
351
351
  "description": "Add draft angle to a manifold — every side wall, true constant angle. ",
352
- "doc": "Tilts the faces you select by a **true constant angle**, pivoting about where\neach face meets a reference plane. Essential for injection moulding and casting,\nwhere parts must release from the mould.\n\n`addDraft` is the whole-part form (every side wall, bottom stays put);\n`draftFaces` lets you name the faces, the pull direction, the reference plane and\nthe sign. The angle now comes out the same on every wall — the pre-2026 taper\nscaled perpendicular coordinates, so only the narrowest wall hit the requested\nangle.\n\n\n\n**Parameters:**\n- `manifold` - The manifold to draft\n- `faces` - which faces tilt: a viewport pick `{center, normal}`, a face from\n `facesByNormal()`, a signed axis like `'-x'`, `'sides'` for every side wall, or\n an array mixing those\n- `angleDeg` - **signed** draft angle in degrees. Positive tapers inward going\n along the pull (the usual mould-release sense); negative flares outward.\n Typical: 1-2° for smooth surfaces, 3-5° for textured.\n- `opts.pull` - pull / draw direction (default `'z'`; accepts `'-z'`, `[x,y,z]`)\n- `opts.reference` - the neutral plane that does not move: `'min'` (default),\n `'mid'`, `'max'` along the pull, a number (coordinate along pull), or a\n face / plane whose center defines it\n- `opts.sense` - `'taper'` makes every selected wall lean the same way round the\n pull axis, so a hollow part keeps its wall thickness; `'face'` honours each\n face's own outward normal, which is the mould-core sense on a cavity wall.\n Defaults to `'taper'` for `'sides'` and `'face'` for named faces.\n\n**Returns:** The drafted manifold\n\n**Notes:**\n- Drafting a face perpendicular to the pull (a cap) throws — it has no direction\n to tilt in. Pick the side walls, or change `opts.pull`.\n- Vertices shared by two selected faces are solved once against both, so drafted\n corners stay sharp instead of doubling up.\n- An angle the body cannot take throws instead of returning a folded solid.\n\n---",
352
+ "doc": "Tilts the faces you select by a **true constant angle**, pivoting about where\neach face meets a reference plane. Essential for injection moulding and casting,\nwhere parts must release from the mould.\n\n`addDraft` is the whole-part form (every side wall, bottom stays put);\n`draftFaces` lets you name the faces, the pull direction, the reference plane and\nthe sign. The angle now comes out the same on every wall — the pre-2026 taper\nscaled perpendicular coordinates, so only the narrowest wall hit the requested\nangle.\n\n\n\n**Parameters:**\n- `manifold` - The manifold to draft\n- `faces` - which faces tilt: a viewport pick `{center, normal}`, a face from\n `facesByNormal()`, a signed axis like `'-x'`, `'sides'` for every side wall, or\n an array mixing those\n- `angleDeg` - **signed** draft angle in degrees. Positive tapers inward going\n along the pull (the usual mould-release sense); negative flares outward.\n Typical: 1-2° for smooth surfaces, 3-5° for textured.\n- `opts.pull` - pull / draw direction (default `'z'`; accepts `'-z'`, `[x,y,z]`)\n- `opts.reference` - the neutral plane that does not move: `'min'` (default),\n `'mid'`, `'max'` along the pull, a number (coordinate along pull), or a\n face / plane whose center defines it\n- `opts.sense` - `'taper'` makes every selected wall lean the same way round the\n pull axis, so a hollow part keeps its wall thickness; `'face'` honours each\n face's own outward normal, which is the mould-core sense on a cavity wall.\n Defaults to `'taper'` for `'sides'` and `'face'` for named faces.\n\n**Returns:** The drafted manifold\n\n**Notes:**\n- Drafting a face perpendicular to the pull (a cap) throws — it has no direction\n to tilt in. Pick the side walls, or change `opts.pull`.\n- Vertices shared by two selected faces are solved once against both, so drafted\n corners stay sharp instead of doubling up.\n- An angle the body cannot take throws instead of returning a folded solid.\n- A fillet or chamfer between the neutral plane and a selected wall is not\n drafted. The wall hinges on the blend tangency, so the fillet endpoint stays\n on that line and the requested angle is the wall's angle from there. This\n holds when the blend was part of the selection (`'sides'` after a fillet):\n those facets are not tilted as their own planes, and the face names from\n before the draft (`cube1.top`, `fillet1.round`) stay.\n\n---",
353
353
  "examples": [
354
354
  "// Whole part: 2° on every side wall, bottom fixed\nconst box = Manifold.cube([60, 20, 30], false);\nreturn addDraft(hollow(box, 2, 'z'), 2, 'z');\n\n// One picked face, pivoting about the top instead of the bottom\nlet part = Manifold.cube([60, 20, 30], false);\npart = draftFaces(part, facesByNormal(part, [1, 0, 0])[0], 3,\n { pull: 'z', reference: 'max' });\n\n// Several faces at once (what a shift-click multi-pick emits), flaring outward\npart = draftFaces(part, [\n { center: [60, 10, 15], normal: [1, 0, 0] },\n { center: [0, 10, 15], normal: [-1, 0, 0] },\n], -3, { pull: 'z', reference: 'min' });"
355
355
  ]
@@ -377,7 +377,7 @@
377
377
  }
378
378
  ],
379
379
  "description": "draftFaces(manifold, faces, angleDeg, opts) — tilt the selected faces by a true constant angle about their intersection with a reference plane. ",
380
- "doc": "Tilts the faces you select by a **true constant angle**, pivoting about where\neach face meets a reference plane. Essential for injection moulding and casting,\nwhere parts must release from the mould.\n\n`addDraft` is the whole-part form (every side wall, bottom stays put);\n`draftFaces` lets you name the faces, the pull direction, the reference plane and\nthe sign. The angle now comes out the same on every wall — the pre-2026 taper\nscaled perpendicular coordinates, so only the narrowest wall hit the requested\nangle.\n\n\n\n**Parameters:**\n- `manifold` - The manifold to draft\n- `faces` - which faces tilt: a viewport pick `{center, normal}`, a face from\n `facesByNormal()`, a signed axis like `'-x'`, `'sides'` for every side wall, or\n an array mixing those\n- `angleDeg` - **signed** draft angle in degrees. Positive tapers inward going\n along the pull (the usual mould-release sense); negative flares outward.\n Typical: 1-2° for smooth surfaces, 3-5° for textured.\n- `opts.pull` - pull / draw direction (default `'z'`; accepts `'-z'`, `[x,y,z]`)\n- `opts.reference` - the neutral plane that does not move: `'min'` (default),\n `'mid'`, `'max'` along the pull, a number (coordinate along pull), or a\n face / plane whose center defines it\n- `opts.sense` - `'taper'` makes every selected wall lean the same way round the\n pull axis, so a hollow part keeps its wall thickness; `'face'` honours each\n face's own outward normal, which is the mould-core sense on a cavity wall.\n Defaults to `'taper'` for `'sides'` and `'face'` for named faces.\n\n**Returns:** The drafted manifold\n\n**Notes:**\n- Drafting a face perpendicular to the pull (a cap) throws — it has no direction\n to tilt in. Pick the side walls, or change `opts.pull`.\n- Vertices shared by two selected faces are solved once against both, so drafted\n corners stay sharp instead of doubling up.\n- An angle the body cannot take throws instead of returning a folded solid.\n\n---",
380
+ "doc": "Tilts the faces you select by a **true constant angle**, pivoting about where\neach face meets a reference plane. Essential for injection moulding and casting,\nwhere parts must release from the mould.\n\n`addDraft` is the whole-part form (every side wall, bottom stays put);\n`draftFaces` lets you name the faces, the pull direction, the reference plane and\nthe sign. The angle now comes out the same on every wall — the pre-2026 taper\nscaled perpendicular coordinates, so only the narrowest wall hit the requested\nangle.\n\n\n\n**Parameters:**\n- `manifold` - The manifold to draft\n- `faces` - which faces tilt: a viewport pick `{center, normal}`, a face from\n `facesByNormal()`, a signed axis like `'-x'`, `'sides'` for every side wall, or\n an array mixing those\n- `angleDeg` - **signed** draft angle in degrees. Positive tapers inward going\n along the pull (the usual mould-release sense); negative flares outward.\n Typical: 1-2° for smooth surfaces, 3-5° for textured.\n- `opts.pull` - pull / draw direction (default `'z'`; accepts `'-z'`, `[x,y,z]`)\n- `opts.reference` - the neutral plane that does not move: `'min'` (default),\n `'mid'`, `'max'` along the pull, a number (coordinate along pull), or a\n face / plane whose center defines it\n- `opts.sense` - `'taper'` makes every selected wall lean the same way round the\n pull axis, so a hollow part keeps its wall thickness; `'face'` honours each\n face's own outward normal, which is the mould-core sense on a cavity wall.\n Defaults to `'taper'` for `'sides'` and `'face'` for named faces.\n\n**Returns:** The drafted manifold\n\n**Notes:**\n- Drafting a face perpendicular to the pull (a cap) throws — it has no direction\n to tilt in. Pick the side walls, or change `opts.pull`.\n- Vertices shared by two selected faces are solved once against both, so drafted\n corners stay sharp instead of doubling up.\n- An angle the body cannot take throws instead of returning a folded solid.\n- A fillet or chamfer between the neutral plane and a selected wall is not\n drafted. The wall hinges on the blend tangency, so the fillet endpoint stays\n on that line and the requested angle is the wall's angle from there. This\n holds when the blend was part of the selection (`'sides'` after a fillet):\n those facets are not tilted as their own planes, and the face names from\n before the draft (`cube1.top`, `fillet1.round`) stay.\n\n---",
381
381
  "examples": [
382
382
  "// Whole part: 2° on every side wall, bottom fixed\nconst box = Manifold.cube([60, 20, 30], false);\nreturn addDraft(hollow(box, 2, 'z'), 2, 'z');\n\n// One picked face, pivoting about the top instead of the bottom\nlet part = Manifold.cube([60, 20, 30], false);\npart = draftFaces(part, facesByNormal(part, [1, 0, 0])[0], 3,\n { pull: 'z', reference: 'max' });\n\n// Several faces at once (what a shift-click multi-pick emits), flaring outward\npart = draftFaces(part, [\n { center: [60, 10, 15], normal: [1, 0, 0] },\n { center: [0, 10, 15], normal: [-1, 0, 0] },\n], -3, { pull: 'z', reference: 'min' });"
383
383
  ]
@@ -1162,8 +1162,8 @@
1162
1162
  "default": "FEATURE_EDGE_MIN_DEG"
1163
1163
  }
1164
1164
  ],
1165
- "description": "Signed feature edges — convex AND concave, by a local winding test. ",
1166
- "doc": "Signed feature edges — convex AND concave, by a local winding test.\n\nSign: `dot(cross(n0, n1), dir) > 0` is convex, `< 0` is concave, where `dir`\nis the edge as wound in the triangle whose normal is n0. Winding is what\ncarries the inside/outside information; a dot product alone cannot tell a 90°\nconvex edge from a 270° concave one (they share the same normal angle).\n\nNormals come from the adjacent TRIANGLES, not the face groups: a face group's\nnormal is an area-weighted average, and on a curved group (a fillet sail) it\npoints nowhere near the local surface, which flips the cross product. Where a\ntriangle is a degenerate sliver — tessellated lofts carry hundreds — its\nnormal is meaningless, so the face-group normal stands in for it instead.\n\n`e.tris[i]` is the triangle belonging to face group `e.faces[i]`, so the\nsubstitution always pairs a triangle with its own group.",
1165
+ "description": "Feature edges tagged convex or concave from the face dihedral, for fillet and chamfer selection.",
1166
+ "doc": "Feature edges tagged convex or concave from the face dihedral, for fillet and chamfer selection.",
1167
1167
  "examples": [
1168
1168
  "const edges = signedFeatureEdges(part);"
1169
1169
  ]
@@ -1265,6 +1265,38 @@
1265
1265
  "const fr = workplaneFromFace(part, facesByNormal(part, [0,0,1])[0]);\npart = tapDrillHole(part, fr, 0, 0, 'M3'); // Ø2.5 for M3 coarse\npart = tapDrillHole(part, fr, 12, 0, '#8-32');"
1266
1266
  ]
1267
1267
  },
1268
+ {
1269
+ "name": "screwBoss",
1270
+ "signature": "screwBoss(part, frame, u, v, opts = {})",
1271
+ "params": [
1272
+ {
1273
+ "name": "part",
1274
+ "text": "part"
1275
+ },
1276
+ {
1277
+ "name": "frame",
1278
+ "text": "frame"
1279
+ },
1280
+ {
1281
+ "name": "u",
1282
+ "text": "u"
1283
+ },
1284
+ {
1285
+ "name": "v",
1286
+ "text": "v"
1287
+ },
1288
+ {
1289
+ "name": "opts",
1290
+ "text": "opts = {}",
1291
+ "default": "{}"
1292
+ }
1293
+ ],
1294
+ "description": "A screw boss standing on a face: a cylinder of `height` on the frame plane at `(u, v)`, unioned into `part`, with a **tap-drill** pilot for fastener `size` (the default, for a self-tapping or tapped screw), a **clearance** hole, or no hole. ",
1295
+ "doc": "A screw boss standing on a face: a cylinder of `height` on the frame plane at\n`(u, v)`, unioned into `part`, with a **tap-drill** pilot for fastener `size`\n(the default, for a self-tapping or tapped screw), a **clearance** hole, or no\nhole. The base sinks 0.1 mm into the part below the frame plane, so the union\nis one body even when the frame carries float noise (a hand-built cylinder a\nhair off the face leaves two). `opts`: `size` (`'M3'`),\n`dia` (outer Ø, default 2.5 × the screw's major Ø: M3 → 7.5), `height` (8),\n`hole` (`'tap'` | `'clearance'` | `'none'`), `holeDepth` (from the boss top,\ndefault the boss height; deeper cuts on into the part), `fit` (clearance:\n`'close'` | `'normal'` | `'loose'`), `segments` (48). Faces are named\n`boss.side`, `boss.top`, `boss.bottom`, and for the hole `boss.bore` and\n`boss.floor`. Throws on a bad frame, a hole as wide as the boss, or an unknown\n`hole`.",
1296
+ "examples": [
1297
+ "const fr = workplaneFromFace(part, facesByNormal(part, [0, 0, 1])[0]);\npart = screwBoss(part, fr, 12, 8, { size: 'M3', height: 8 }); // Ø7.5, Ø2.5 pilot\npart = screwBoss(part, fr, -12, 8, { size: 'M4', height: 6, hole: 'clearance' }); // through Ø4.5\npart = screwBoss(part, fr, 0, -8, { size: 'M3', height: 10, hole: 'none', dia: 9 });"
1298
+ ]
1299
+ },
1268
1300
  {
1269
1301
  "name": "holesOnContour",
1270
1302
  "signature": "holesOnContour(part, section, spec)",
@@ -1386,7 +1418,7 @@
1386
1418
  }
1387
1419
  ],
1388
1420
  "description": "filletEdges(part, edges, radius, opts) — circular fillet of radius r on a SET of straight convex edges. edges = objects from convexEdges() (required: they carry the mesh indices this helper needs; edges from OTHER selections can still be filleted if the edge object has {a, b, ...",
1389
- "doc": "Circular fillet of radius `r` on a **set** of straight convex edges\n(Manifold has no native fillet; this is a geometric construction).\n`edges` must come from `convexEdges()` (it needs the per-edge vertex\nindices to recover the in-face directions — and the in-face geometry, not\njust the normals, is what makes non-90° corners work). `radius` is a\nnumber (same `r` for all edges) or a `number[]` parallel to `edges`\n(per-edge radii). `opts` (optional): `{ sphericalCorners: true }`\n(see below).\n\n\n\n**How it works (per edge).** In the cross-section perpendicular to the\nedge, the two faces meet at interior angle θ. The fillet arc of radius `r`\nis tangent to both faces at distance `t = r/tan(θ/2)` from the corner,\ncentered on the interior angle bisector at `r/sin(θ/2)`. The removed\ncross-section is the sliver `r·t − ½·r²·(π−θ)` (= `r²(1−π/4)` at 90°).\nThe cutter is exactly `parallelepiped(t·f0, t·f1, edge) − cylinder(r)` —\nboth are exact primitives, so the result is geometrically exact for any\nθ. The in-face boundary directions `f0`/`f1` come from the adjacent\ntriangles' third vertices (robust to Manifold's `faceID` grouping, which\ncan merge faces from different planes into one). All cutters for the set\nare unioned and subtracted once, so shared-corner interactions resolve\nthrough the boolean — matching analytic inclusion-exclusion for adjacent\nedges (two cutters at a corner, three at a box corner).\n\n**Closed circular rims (v2, 2026-09-08).** A curved surface (a cylinder\nwall, a hole wall) meeting a planar face tessellates as a LOOP of many\nshort straight mesh edges — e.g. a Ø12 hole rim at 48 segments has\n~0.78mm segments. In v1 this loop was filleted PER SEGMENT, and any\nsegment failing the size guard below was silently skipped — for a real\nfillet radius (r=1 on that Ø12 rim, t=1 > 0.45·0.78mm) EVERY segment\nfailed, so the whole rim's fillet silently vanished with no error. v2\ndetects a maximal chain of input edges that (a) share consecutive mesh\nvertices, (b) turn ≤30° at each shared vertex (a genuine polygon corner\nturns 60-180°; a tessellated circle turns 360/segs°, well under 30° for\nany segs≥12), and (c) keep the same interior angle θ (within 3°) and the\nsame radius. If that chain closes into a loop AND fits an exact circle\n(3-point circumcircle, verified against every other vertex in the run),\nthe WHOLE rim is filleted as one exact revolved cutter — the same 2D\ncorner-sliver cross-section swept a full 360° around the rim's own axis\n— instead of per-segment boxes, so the old per-segment size guard does\nnot apply to it at all. `convexEdges(part)` (unfiltered, or filtered only\nby position/orientation — do NOT filter out short segments) is the\ncorrect input; a \"filter out the tiny seam edges\" workaround is no longer\nnecessary or correct for a genuine curved rim. If a chain doesn't close,\nor doesn't fit a clean circle (mixed/non-circular topology), filletEdges\nfalls back to the v1 per-edge construction for every edge in that chain,\nincluding the size guard below — so isolated straight edges and\nnon-circular chains behave exactly as before.\n\n**Constraints (v1 per-edge path — still the fallback for singleton edges\nand non-circular chains).**\n- **Planar faces only** — each adjacent face must be planar at the edge\n (checked: all same-face neighbor triangles coplanar within 1e-3). A\n fillet touching a curved face **throws** for a SINGLETON edge. (A\n successfully-fit closed circular run skips this check entirely — the\n circle fit plus per-vertex on-circle verification is a strictly more\n specific validity proof for \"this chain is one smooth curved feature\"\n than the singleton check, which was never designed to look past one\n edge.)\n- **Convex edges only** — concave corners (rounding = adding material)\n throw. `convexEdges()` already filters these out; passing them directly\n also throws via the ball probe. (Applies to every edge, run or not.)\n- **Size guard** — for a SINGLETON edge (or an edge in a chain that didn't\n qualify as a closed circular run), `r` must satisfy `t < 0.45·L` where\n `L` is the edge length; individual edges that FAIL this guard are\n **skipped** when other edges still produce cutters. If **every** requested\n edge is skipped / rejected, `filletEdges` **throws** (no silent unchanged\n part). Closed-circular-run members are exempt — their per-segment `L` is a\n tessellation artifact, not a signal that the feature is too small.\n- **Arc tessellation** — a SINGLETON edge's fillet arc is an inscribed\n 384-gon: the result volume sits at most `L·(π−(n/2)·sin(2π/n))·r²` BELOW\n the circle-exact value per edge. A closed run's revolve resolution is\n tied to the rim's own mesh segment count exactly (verified necessary\n for a numerically clean boolean: Manifold's boolean difference between\n the original n-segment part and a cutter revolved at a DIFFERENT\n segment count — even a clean integer multiple of n — silently removes\n LESS than the cutter's own volume), with a separately-tunable, finer\n resolution for the small fillet arc itself.\n- **Known gaps** — an OPEN curved run (a fillet on a less-than-360° arc)\n does not get the closed-run treatment and can still lose short segments\n to the size guard; not exercised by any part in the current corpus\n (every curved surface here comes from a full-revolution primitive). A\n closed-run cutter throws (rather than silently clipping) if `r` is so\n large the fillet would revolve through the rim's own axis.\n\n**Spherical corner caps** (`opts.sphericalCorners: true`). Three fillets\nmeeting at a box corner converge to a sharp cusp point — the plain\nresult is a valid but pointy corner. With this option the cusp is\nreplaced by the sphere of radius `r` centered on the trihedral incenter\n(equidistant `r` from all three faces and lying ON all three fillet\ncylinder axes): a spherical corner patch that is tangent to each\nfillet sail along a circle (C1 junction) and to each face at one point —\ni.e. the true CAD r/r/r rounded corner. An exact right-angle corner is\nbuilt as meshes (each edge cutter stops at the junction plane and one\npocket solid holds the sphere octant) that share their ring vertices, so\nnothing is cut between tangent surfaces: on a 40×30×20 box each sail is\none face, each corner is one face (`<block>.corner[k]`, see\n[architecture.md](architecture.md) → Face graph walls), and the result\nhas no needle triangles. v1 scope: applies only at vertices where exactly\nTHREE filleted edges meet at ~90° with EQUAL radii; other corners keep\nthe cusp, and non-triple corners are unaffected (the option is a no-op\non an edge set whose corners have fewer than three fillets). A corner a\nfraction of a degree off square keeps the older ball cut.\n\n**Verified** against analytic volumes: single edge, 4 top edges, all 12\nbox edges (pair + triple corner overlaps), an obtuse wedge (90°/116°/153°\ncorners), and mixed per-edge radii — see `cadgen-workspace/reports/c6-report.md`.\n\n---\n\n\n---\n\n## Cross-section substrate (Slice 21)\n\nReusable **plane + 2D profile** value for later edge→sweep path,\nfillet-via-sweep, then extrude/revolve/loft siblings. This slice ships the\nsubstrate only — those followers are **not** started here.\n\nPlane comes from `workplaneFromFace` (primary mobile path: selected planar\nface). Profile is a light 2D shape in plane UV. The returned value is a plain\nobject (no class inheritance):",
1421
+ "doc": "Circular fillet of radius `r` on a **set** of straight convex edges\n(Manifold has no native fillet; this is a geometric construction).\n`edges` must come from `convexEdges()` (it needs the per-edge vertex\nindices to recover the in-face directions — and the in-face geometry, not\njust the normals, is what makes non-90° corners work). `radius` is a\nnumber (same `r` for all edges) or a `number[]` parallel to `edges`\n(per-edge radii). `opts` (optional): `{ sphericalCorners: true }`\n(see below).\n\n\n\n**How it works (per edge).** In the cross-section perpendicular to the\nedge, the two faces meet at interior angle θ. The fillet arc of radius `r`\nis tangent to both faces at distance `t = r/tan(θ/2)` from the corner,\ncentered on the interior angle bisector at `r/sin(θ/2)`. The removed\ncross-section is the sliver `r·t − ½·r²·(π−θ)` (= `r²(1−π/4)` at 90°).\nThe cutter is exactly `parallelepiped(t·f0, t·f1, edge) − cylinder(r)` —\nboth are exact primitives, so the result is geometrically exact for any\nθ. The in-face boundary directions `f0`/`f1` come from the adjacent\ntriangles' third vertices (robust to Manifold's `faceID` grouping, which\ncan merge faces from different planes into one). All cutters for the set\nare unioned and subtracted once, so shared-corner interactions resolve\nthrough the boolean — matching analytic inclusion-exclusion for adjacent\nedges (two cutters at a corner, three at a box corner).\n\n**Closed circular rims (v2, 2026-09-08).** A curved surface (a cylinder\nwall, a hole wall) meeting a planar face tessellates as a LOOP of many\nshort straight mesh edges — e.g. a Ø12 hole rim at 48 segments has\n~0.78mm segments. In v1 this loop was filleted PER SEGMENT, and any\nsegment failing the size guard below was silently skipped — for a real\nfillet radius (r=1 on that Ø12 rim, t=1 > 0.45·0.78mm) EVERY segment\nfailed, so the whole rim's fillet silently vanished with no error. v2\ndetects a maximal chain of input edges that (a) share consecutive mesh\nvertices, (b) turn ≤30° at each shared vertex (a genuine polygon corner\nturns 60-180°; a tessellated circle turns 360/segs°, well under 30° for\nany segs≥12), and (c) keep the same interior angle θ (within 3°) and the\nsame radius. If that chain closes into a loop AND fits an exact circle\n(3-point circumcircle, verified against every other vertex in the run),\nthe WHOLE rim is filleted as one exact revolved cutter — the same 2D\ncorner-sliver cross-section swept a full 360° around the rim's own axis\n— instead of per-segment boxes, so the old per-segment size guard does\nnot apply to it at all. `convexEdges(part)` (unfiltered, or filtered only\nby position/orientation — do NOT filter out short segments) is the\ncorrect input; a \"filter out the tiny seam edges\" workaround is no longer\nnecessary or correct for a genuine curved rim. If a chain doesn't close,\nor doesn't fit a clean circle (mixed/non-circular topology), filletEdges\nfalls back to the v1 per-edge construction for every edge in that chain,\nincluding the size guard below — so isolated straight edges and\nnon-circular chains behave exactly as before.\n\n**Constraints (v1 per-edge path — still the fallback for singleton edges\nand non-circular chains).**\n- **Planar faces only** — each adjacent face must be planar at the edge\n (checked: all same-face neighbor triangles coplanar within 1e-3). A\n fillet touching a curved face **throws** for a SINGLETON edge. (A\n successfully-fit closed circular run skips this check entirely — the\n circle fit plus per-vertex on-circle verification is a strictly more\n specific validity proof for \"this chain is one smooth curved feature\"\n than the singleton check, which was never designed to look past one\n edge.)\n- **Convex edges only** — concave corners (rounding = adding material)\n throw. `convexEdges()` already filters these out; passing them directly\n also throws via the ball probe. (Applies to every edge, run or not.)\n- **Size guard** — for a SINGLETON edge (or an edge in a chain that didn't\n qualify as a closed circular run), `r` must satisfy `t < 0.45·L` where\n `L` is the edge length; individual edges that FAIL this guard are\n **skipped** when other edges still produce cutters. If **every** requested\n edge is skipped / rejected, `filletEdges` **throws** (no silent unchanged\n part). Closed-circular-run members are exempt — their per-segment `L` is a\n tessellation artifact, not a signal that the feature is too small.\n- **Arc tessellation** — a SINGLETON edge's fillet arc is an inscribed\n 384-gon: the result volume sits at most `L·(π−(n/2)·sin(2π/n))·r²` BELOW\n the circle-exact value per edge. A closed run's revolve resolution is\n tied to the rim's own mesh segment count exactly (verified necessary\n for a numerically clean boolean: Manifold's boolean difference between\n the original n-segment part and a cutter revolved at a DIFFERENT\n segment count — even a clean integer multiple of n — silently removes\n LESS than the cutter's own volume), with a separately-tunable, finer\n resolution for the small fillet arc itself.\n- **Known gaps** — an OPEN curved run (a fillet on a less-than-360° arc)\n does not get the closed-run treatment and can still lose short segments\n to the size guard; not exercised by any part in the current corpus\n (every curved surface here comes from a full-revolution primitive). A\n closed-run cutter throws (rather than silently clipping) if `r` is so\n large the fillet would revolve through the rim's own axis.\n\n**Spherical corner caps** (`opts.sphericalCorners: true`). Three fillets\nmeeting at a box corner converge to a sharp cusp point — the plain\nresult is a valid but pointy corner. With this option the cusp is\nreplaced by the sphere of radius `r` centered on the trihedral incenter\n(equidistant `r` from all three faces and lying ON all three fillet\ncylinder axes). The center solves those three plane equations. It equals\n`r` times the sum of the inward normals only when the normals are\northogonal, so a drafted corner (faces a degree off square) still gets\na cap. The patch is tangent to each\nfillet sail along a circle (C1 junction) and to each face at one point —\ni.e. the true CAD r/r/r rounded corner. An exact right-angle corner is\nbuilt as meshes (each edge cutter stops at the junction plane and one\npocket solid holds the sphere octant) that share their ring vertices, so\nnothing is cut between tangent surfaces: on a 40×30×20 box each sail is\none face, each corner is one face (`<block>.corner[k]`, see\n[architecture.md](architecture.md) → Face graph walls), and the result\nhas no needle triangles. v1 scope: applies only at vertices where exactly\nTHREE filleted edges meet at ~90° with EQUAL radii; other corners keep\nthe cusp, and non-triple corners are unaffected (the option is a no-op\non an edge set whose corners have fewer than three fillets). A corner a\ndegree off square (a drafted box) uses the same mesh, on the incenter\nabove. The older ball cut remains only when an edge is too short to hold\nthe cap.\n\n**Verified** against analytic volumes: single edge, 4 top edges, all 12\nbox edges (pair + triple corner overlaps), an obtuse wedge (90°/116°/153°\ncorners), and mixed per-edge radii — see `cadgen-workspace/reports/c6-report.md`.\n\n---\n\n\n---\n\n## Cross-section substrate (Slice 21)\n\nReusable **plane + 2D profile** value for later edge→sweep path,\nfillet-via-sweep, then extrude/revolve/loft siblings. This slice ships the\nsubstrate only — those followers are **not** started here.\n\nPlane comes from `workplaneFromFace` (primary mobile path: selected planar\nface). Profile is a light 2D shape in plane UV. The returned value is a plain\nobject (no class inheritance):",
1390
1422
  "examples": [
1391
1423
  "// round all 12 box corners at r=3\npart = filletEdges(part, convexEdges(part), 3);\n\n// fillet only the 4 vertical corners, mixed radii per edge\nconst vert = convexEdges(part).filter(e => Math.abs(e.tangent[2]) > 0.99);\npart = filletEdges(part, vert, [3, 3, 5, 5]);\n\n// fully-rounded box corners: r=5 fillets + spherical corner patches\npart = filletEdges(part, convexEdges(part), 5, { sphericalCorners: true });",
1392
1424
  "{\n kind: 'crossSection',\n plane: { center, normal, x, y }, // workplaneFromFace frame\n profile: { type: 'circle'|'rectangle'|'polygon', ... },\n contours: [ [[u,v], ...] ], // ready for makeExtrude / sweep later\n}"
@@ -1765,7 +1797,7 @@
1765
1797
  }
1766
1798
  ],
1767
1799
  "description": "edgesNamed(part, ...names) → the mesh segments of the edges between two named faces, for makeSweepPath / filletAlongPath. ",
1768
- "doc": "The one edge reference a script should hold. An edge is the pair of stamped faces it lies between, so the name survives every edit that keeps those faces, where `edge(part, 17)` renumbers after any earlier change and a literal `va/vb` wire breaks as soon as the geometry moves.\n\n\n\n- Face order inside a name does not matter (`a~b` is `b~a`). Names come from `faceNames(part)`, `list_feature_edges`, or the Fillet card.\n- A bare pair returns every chain between those faces. `[k]` picks one chain and throws when the pair no longer has that many chains (the pieces changed): re-pick, or use the bare name. `*` globs either side.\n- Returns the same segment rows `edge()` returns (`a`, `b`, `va`, `vb`, `length`, `mid`, plus `n0` / `n1` and `name`), so `makeSweepPath` and `filletAlongPath` are unchanged. `result.names` lists the chains it matched.\n- Throws, listing the edges that exist, when a name matches nothing. It never substitutes a nearby edge.\n- Every face has a name: helper roles (`cube1.top`), fillet and chamfer surfaces (`fillet1.round`, `chamfer2.bevel`, and the spherical corner balls of `filletEdges(..., { sphericalCorners: true })` as `fillet1.corner[k]`; the block id Accept mints, positional like `fillet-16` only on an older block with no `id=`, one piece per contiguous strip), uploads by coplanar group (`import@1.f3`), and freehand `Manifold.*` runs by their block (`snippet2.f7`, else `script.f7`).\n- `filletAlongPath` also refuses a path whose knots are not on an edge of the solid (a stale literal wire), instead of sweeping a cutter through air.",
1800
+ "doc": "The one edge reference a script should hold. An edge is the pair of stamped faces it lies between, so the name survives every edit that keeps those faces, where `edge(part, 17)` renumbers after any earlier change and a literal `va/vb` wire breaks as soon as the geometry moves.\n\n\n\n- Face order inside a name does not matter (`a~b` is `b~a`). Names come from `faceNames(part)`, `list_feature_edges`, or the Fillet card.\n- A bare pair returns every chain between those faces. `[k]` picks one chain and throws when the pair no longer has that many chains (the pieces changed): re-pick, or use the bare name. `*` globs either side.\n- A face role may already end in `[i]` (`extrude1.wall[0]~extrude1.wall[1]`). That index stays on the face. The chain ordinal is a further `[k]` only when that pair meets in more than one chain.\n- Returns the same segment rows `edge()` returns (`a`, `b`, `va`, `vb`, `length`, `mid`, plus `n0` / `n1` and `name`), so `makeSweepPath` and `filletAlongPath` are unchanged. `result.names` lists the chains it matched.\n- Throws, listing the edges that exist, when a name matches nothing. It never substitutes a nearby edge.\n- Every face has a name: helper roles (`cube1.top`), fillet and chamfer surfaces (`fillet1.round`, `chamfer2.bevel`, and the spherical corner balls of `filletEdges(..., { sphericalCorners: true })` as `fillet1.corner[k]`; the block id Accept mints, positional like `fillet-16` only on an older block with no `id=`, one piece per contiguous strip), uploads by coplanar group (`import@1.f3`), and freehand `Manifold.*` runs by their block (`snippet2.f7`, else `script.f7`).\n- `filletAlongPath` also refuses a path whose knots are not on an edge of the solid (a stale literal wire), instead of sweeping a cutter through air.",
1769
1801
  "examples": [
1770
1802
  "const e1 = edgesNamed(part, 'plate.top~boss.side'); // every chain between those faces\nconst e2 = edgesNamed(part, 'plate.top~boss.side[1]'); // one chain of a pair that meets twice\nconst e3 = edgesNamed(part, 'cube1.top~cube1.front', 'cube1.top~cube1.right'); // several edges, one list\nconst e4 = edgesNamed(part, 'boss.top~boss.wall[*]'); // glob: the rim of a hex boss\npart = filletAlongPath(part, makeSweepPath(e1), 2);\npart = filletAlongPath(part, makeSweepPath(edgesNamed(part, 'plate.top~fillet-2.round')), 1, { profile: 'chamfer' });"
1771
1803
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "surfcad-mcp",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "description": "SurfCAD agent bridge MCP server (stdio) — pairs to a browser tab via the local WebSocket relay, or a saved remote login",
5
5
  "license": "Apache-2.0",
6
6
  "author": "artur0x0",
@@ -363,8 +363,11 @@ export function createAgentBridgeRelayHub(opts = {}) {
363
363
 
364
364
  if (msg.type === PAIR_MSG.AGENT_PROMPT || msg.type === PAIR_MSG.AGENT_PROMPT_CANCEL
365
365
  || msg.type === PAIR_MSG.AGENT_PROMPT_ACK || msg.type === PAIR_MSG.AGENT_PROMPT_CANCEL_RESULT
366
- || msg.type === PAIR_MSG.AGENT_REPLY || msg.type === PAIR_MSG.AGENT_STATUS
367
- || msg.type === PAIR_MSG.AGENT_ACTIVITY) {
366
+ || msg.type === PAIR_MSG.AGENT_REPLY || msg.type === PAIR_MSG.AGENT_MESSAGE
367
+ || msg.type === PAIR_MSG.AGENT_STATUS
368
+ || msg.type === PAIR_MSG.AGENT_ACTIVITY
369
+ || msg.type === PAIR_MSG.AGENT_PROGRESS
370
+ || msg.type === PAIR_MSG.AGENT_CLOSE_SESSION) {
368
371
  if (msg.type === PAIR_MSG.AGENT_PROMPT || msg.type === PAIR_MSG.AGENT_PROMPT_CANCEL) {
369
372
  if (meta.role !== 'tab') {
370
373
  sendJson(socket, {
package/src/errors.mjs CHANGED
@@ -55,6 +55,21 @@ export function tabAsleepError() {
55
55
  });
56
56
  }
57
57
 
58
+ /**
59
+ * The tab took the command and ran past its budget (mold_* analyses get
60
+ * 120 s; everything else 30 s). The tab is awake; the command is the problem.
61
+ * @param {string} [message]
62
+ * @param {unknown} [details]
63
+ */
64
+ export function commandTimeoutError(message, details) {
65
+ return Object.assign(new Error(message || 'SurfCAD tab took the command but did not answer in time'), {
66
+ code: 'command_timeout',
67
+ hint: 'The tab is awake but this command ran past its budget. Retry once with the tab in the foreground; for mold_* pass pull to skip the direction search, or simplify the part.',
68
+ retryable: true,
69
+ ...(details && typeof details === 'object' ? { details } : {}),
70
+ });
71
+ }
72
+
58
73
  export function tooManyPendingError() {
59
74
  return Object.assign(new Error('Too many commands are waiting'), {
60
75
  code: 'too_many_pending',
@@ -71,6 +86,28 @@ export function tokenRevokedError() {
71
86
  });
72
87
  }
73
88
 
89
+ export const TOKEN_EXPIRED_MESSAGE = 'Agent pairing expired, get a new join code.';
90
+
91
+ export function tokenExpiredError() {
92
+ return Object.assign(new Error(TOKEN_EXPIRED_MESSAGE), {
93
+ code: 'expired',
94
+ hint: 'The pairing expired, get a new join code in SurfCAD, then run npx surfcad-mcp login again.',
95
+ retryable: false,
96
+ });
97
+ }
98
+
99
+ /**
100
+ * HTTP 401 from the agent relay. `expired` is a dead pairing; anything else
101
+ * is treated as a revoked login.
102
+ * @param {any} json
103
+ */
104
+ export function authErrorFromBody(json) {
105
+ const error = json && typeof json.error === 'string' ? json.error : '';
106
+ const message = json && typeof json.message === 'string' ? json.message : '';
107
+ if (error === 'expired' || message === 'Token expired') return tokenExpiredError();
108
+ return tokenRevokedError();
109
+ }
110
+
74
111
  /**
75
112
  * @param {string} [message]
76
113
  */
@@ -93,8 +130,10 @@ export function asRemoteError(error) {
93
130
  const code = /** @type {Error & { code?: string }} */ (error).code;
94
131
  if (
95
132
  code === 'tab_asleep'
133
+ || code === 'command_timeout'
96
134
  || code === 'too_many_pending'
97
135
  || code === 'token_revoked'
136
+ || code === 'expired'
98
137
  || code === 'client_update_required'
99
138
  ) return error;
100
139
  }
@@ -106,7 +145,11 @@ export function asRemoteError(error) {
106
145
  ? record.message
107
146
  : (typeof error === 'string' ? error : '');
108
147
  if (code === 'tab_asleep' || message === 'SurfCAD tab is asleep') return tabAsleepError();
148
+ if (code === 'command_timeout') {
149
+ return commandTimeoutError(message, /** @type {{ details?: unknown }} */ (record).details);
150
+ }
109
151
  if (code === 'too_many_pending' || message === 'Too many commands are waiting') return tooManyPendingError();
152
+ if (code === 'expired' || message === 'Token expired') return tokenExpiredError();
110
153
  if (code === 'token_revoked' || code === 'unauthorized' || code === '4001') return tokenRevokedError();
111
154
  if (
112
155
  code === 'client_update_required'
package/src/helpers.mjs CHANGED
@@ -22,7 +22,7 @@ export const LIST_HELPERS_TOOL_NAME = 'list_helpers';
22
22
  export const HELPER_GROUPS = Object.freeze({
23
23
  blocks: ['roundedBox', 'tube', 'rectTube', 'hexPrism', 'sheetMetalSolid'],
24
24
  shapes: ['makeCrossSection', 'solveContour', 'profileCircle', 'profileRectangle', 'profilePolygon', 'makeExtrude', 'makeRevolve', 'makeLoft', 'loft', 'sweep', 'sweepPoints', 'makeSweepPath', 'rotateContour', 'offsetPlaneFrame'],
25
- build: ['cut', 'hollow', 'shell', 'hole', 'holeSpan', 'cboreHole', 'cskHole', 'clearanceHole', 'tapDrillHole', 'holePattern', 'holesOnContour', 'booleanBodies', 'externalBody', 'addDraft', 'draftFaces', 'moveFace', 'deleteFace'],
25
+ build: ['cut', 'hollow', 'shell', 'hole', 'holeSpan', 'cboreHole', 'cskHole', 'clearanceHole', 'tapDrillHole', 'screwBoss', 'holePattern', 'holesOnContour', 'booleanBodies', 'externalBody', 'addDraft', 'draftFaces', 'moveFace', 'deleteFace'],
26
26
  polish: ['filletEdges', 'chamferEdges', 'filletAlongPath', 'edgesNamed', 'convexEdges', 'concaveEdges', 'signedFeatureEdges', 'edge', 'edgesBetween', 'boundaryEdges'],
27
27
  place: ['move', 'rotateAbout', 'center', 'align', 'mirror', 'array3D', 'polarArray', 'patternOnPoints', 'getDimensions'],
28
28
  faces: ['faceNames', 'facesNamed', 'edgesOf', 'surfaceOf', 'facesByNormal', 'planarFaceAt', 'edgesByOrientation', 'workplaneFromFace', 'placeInFrame', 'transformByFrame', 'placeOnFace'],
@@ -17,11 +17,12 @@ export const BUILD_FLOW_NOTE = ` Build in ribbon order: block out every part of
17
17
  /** The full guidance, served by the MCP `guide` tool's `start` topic. */
18
18
  export const BUILD_GUIDANCE = [
19
19
  'How to build in SurfCAD. Work in the order of the feature ribbon: Block, Build, Shape, Polish, Move.',
20
- '1. Block out first. Within seconds of the prompt, create every part of the assembly as plain blocks (create_part, then insert_cube, insert_rounded_box, insert_cylinder, insert_sphere, insert_tube, insert_hex_prism) at roughly the right size and position (block-out positions are rough; joints set final positions), and take a screenshot so the user can approve the layout and proportions before any detail goes in. Never plan silently for long before something appears in the viewport.',
21
- '2. Build. Shape each block into its real form with Build and Shape features: insert_hole, insert_cut, insert_boolean, insert_shell, insert_add_draft; insert_cross_section, insert_workplane, insert_make_extrude, insert_make_revolve, insert_make_sweep, insert_make_loft (sketch_* and slot_* for the profiles).',
20
+ '1. Block out first. Within seconds of the prompt, create every part of the assembly as plain blocks (create_assembly gives the first part as partId; rename_part it. create_part for every other part, then insert_cube, insert_rounded_box, insert_cylinder, insert_sphere, insert_tube, insert_hex_prism) at roughly the right size and position (block-out positions are rough; joints set final positions), and take a screenshot so the user can approve the layout and proportions before any detail goes in. Never plan silently for long before something appears in the viewport.',
21
+ '2. Build. Shape each block into its real form with Build and Shape features: insert_hole, insert_boss, insert_cut, insert_boolean, insert_shell, insert_add_draft; insert_cross_section, insert_workplane, insert_make_extrude, insert_make_revolve, insert_make_sweep, insert_make_loft (sketch_* and slot_* for the profiles).',
22
22
  '3. Polish. insert_fillet_edges, insert_chamfer_edges, insert_move_face, insert_delete_face.',
23
23
  `4. Pattern and place. insert_array3_d (grid), insert_polar_array (bolt circle), and insert_pattern_points (one copy at every hole center and axis from list_faces; Array Type=Points) for repeats and hardware, then insert_move, insert_rotate, insert_center, insert_align, insert_mirror for bodies inside one part. insert_polar_array drills the holes when boreRadius is greater than 0 and boltCircleRadius is the circle (it must be greater than 0); boreRadius 0 copies the body and boltCircleRadius 0 (the default) leaves it on the axis. A bolt circle of holes is that tool, not a FEATURE-GAP snippet. ${JOINT_PLACEMENT_GUIDANCE}`,
24
24
  'Finish each stage across the whole assembly before starting the next, and take a screenshot after each stage.',
25
+ 'Modeling rules: guide { topic: "modeling" }; molded parts: guide { topic: "molding" }, and run mold_fit before Polish.',
25
26
  'Features first. Use insert_* or invoke_helper whenever a feature can do the job. When no feature can, add a script snippet feature with insert_code_snippet { gap, why, script }: one operation, not the whole part, kept next to the other features. Its block starts with a gap comment in this exact form so it can be searched: // FEATURE-GAP: <missing feature or option> | <why the existing feature did not work>. Example: // FEATURE-GAP: sweep along 3D path | the frame tube follows a curve and extrude only goes straight. set_script is only for rewriting a whole part.',
26
27
  'Hardware. Give each unique fastener type its own part named by its spec (Bolt M5x12 SHCS, Nut M5 nylock, Star nut 1-1/8"); two fasteners are the same type only when size, length, and head style all match. Model one instance per part and pattern it to every place it goes: list_faces on the part it fastens gives each hole center and axis in the fastened part frame (result.frame is "local"); compose with part_get_transform when the fastener does not share that frame, then pass them to insert_pattern_points { points: [{ at, axis }, …], up } on the fastener part (insert_array3_d for a regular grid). A bolt circle of holes in the part being drilled is insert_polar_array { count, boltCircleRadius, axis, boreRadius, boreHeight }, not a FEATURE-GAP snippet. Run the pattern again when the holes move. Never one part that holds every fastener, never a copy-paste loop. Do hardware in the pattern-and-place stage, after the parts it fastens are finished.',
27
28
  ].join('\n');
@@ -142,13 +142,14 @@ export const ERROR_HINTS = Object.freeze({
142
142
  confirm_required: { hint: 'Nothing changed: ask the user (details lists what the change touches), and only then retry with confirm: true.', guide: CONSENT_GUIDE },
143
143
  pending_save: { hint: 'The write is planned offline: ask the user to Save again when online; nothing more to do now.' },
144
144
  unknown_save: { hint: 'No save with that id is running or recent in this tab: a git_save that finished within its budget answered its result directly; call git_save { message } again if the save is still wanted.' },
145
- upgrade_required: { hint: 'Legacy vault: after the user agrees, git_upgrade_vault { confirm: true }, then git_save again.' },
145
+ unsupported_vault_version: { hint: 'This vault version is not supported. git_upgrade_vault on the current version reports that nothing needs upgrading. An older version runs only when an upgrade step is registered and confirm is true; with no step, nothing is opened or written.' },
146
146
  upgrade_unavailable: { hint: 'The vault cannot be upgraded from here (message says why): tell the user and stop.' },
147
147
  conflict: { hint: 'A remote edit overlaps this save: git_behind_resolve { action: "reload" | "branch", confirm: true } after the user chooses, or git_force_overwrite with confirm: true.' },
148
148
  'repo-moved': { hint: 'The repository moved or was renamed: ask the user; git_behind_resolve { action: "reload", confirm: true } reloads from it.' },
149
149
  git_blocked: { hint: 'Git is unavailable here (local document or no vault): git_move_to_repo first, or keep working locally; nothing was written.' },
150
150
  git_only: { hint: 'This tool needs a vault: git_move_to_repo first, or stay local and use create_part / insert_* instead.' },
151
151
  git_error: { hint: 'The git handler failed (message): retry once; stop and tell the user with the message if it repeats.' },
152
+ save_on_main: { hint: 'git_save does not commit on main. Nothing was written. Create a branch first with git_branch_create { name }, then git_save { message } on that branch.' },
152
153
  working_copy_unpersisted: { hint: 'The working copy has not been written yet: git_save { message } (the user clicks Allow), then retry.' },
153
154
  not_found: { hint: 'The id or path does not exist in the vault: list_assemblies {} / parts {} and use a listed id.' },
154
155
  bind_failed: { hint: 'The part could not be bound to the vault: retry once; tell the user if it repeats.' },
@@ -178,16 +179,18 @@ export const ERROR_HINTS = Object.freeze({
178
179
  pair_failed: { hint: 'Pairing failed (message): check the code (8 characters, from the open tab) and that the tab shows it, then pair again.', guide: PAIRING_GUIDE },
179
180
  pairing_lost: { hint: 'The tab or relay dropped and the server re-pairs on its own: retry in a few seconds; do not ask for a new code.', guide: PAIRING_GUIDE },
180
181
  bad_pairing_code: { hint: 'pair { code: "........" } with the 8-character code from SurfCAD → Local agent → Show pairing code.', guide: PAIRING_GUIDE },
181
- tab_asleep: { hint: 'Open SurfCAD in Chrome and keep that tab open, then retry this call.' },
182
+ tab_asleep: { hint: 'Open SurfCAD in Chrome and keep that tab open, then retry this call. mold_* analyses may take up to 120 s; keep the tab in the foreground.' },
183
+ command_timeout: { hint: 'The tab is awake but this command ran past its budget (120 s for mold_*, 30 s otherwise). Retry once with the tab in the foreground; for mold_* pass pull to skip the direction search.' },
182
184
  too_many_pending: { hint: 'Wait for the SurfCAD tab to finish the commands already in flight, then retry.' },
183
185
  token_revoked: { hint: 'Run npx surfcad-mcp login and approve the new code in SurfCAD.' },
186
+ expired: { hint: 'The pairing expired, get a new join code in SurfCAD, then run npx surfcad-mcp login again.' },
184
187
  client_update_required: { hint: 'This surfcad-mcp is too old for the agent server. Update the package, then run npx surfcad-mcp login again.' },
185
188
  prompts_need_websocket: { hint: 'The agent WebSocket is not open. A paired session still sends status over HTTPS; retry the call. If it keeps failing, reconnect where the agent server allows wss.' },
186
189
  relay_unavailable: { hint: 'The local relay is not running: start surfcad-mcp normally (it owns the relay) or set SURFCAD_AGENT_BRIDGE_WS_URL.', guide: PAIRING_GUIDE },
187
190
  bridge_error: { hint: 'The tab refused the call without a code: status {} and retry once; tell the user if it repeats.' },
188
191
  bad_webhook_url: { hint: 'Webhooks need a public https URL (no credentials, localhost or private hosts): fix it, or poll read_messages { wait_ms: 25000 } instead.', guide: PAIRING_GUIDE },
189
192
  no_request: { hint: 'in_reply_to is not an open prompt id: read_messages {} lists the queued prompts.' },
190
- unknown_prompt: { hint: 'in_reply_to is not a prompt this session received: call read_messages {} and use an id from recent, or the id on the prompt you were given.' },
193
+ unknown_prompt: { hint: 'in_reply_to is not a prompt this session received: call read_messages {} and use an id from recent, or the id on the prompt you were given. Omit in_reply_to to post a plain-text note to this paired session when recent is empty.' },
191
194
  reply_too_long: { hint: 'Shorten the reply (message gives the limit) or send it in several reply_to_user calls with final on the last.' },
192
195
  });
193
196
 
@@ -237,7 +240,7 @@ function hintFromMessage(code, message) {
237
240
  return { hint: 'The part is empty: insert_cube / insert_cylinder / insert_tube (or an extrude from a sketch) first, then this insert again.' };
238
241
  }
239
242
  if (code === 'insert_failed' && /needs a sketch profile|needs two or more sketch profiles/i.test(message)) {
240
- return { hint: 'Sketch the profile first: sketch_begin → sketch_add → sketch_commit (one contour per profile), then insert again.' };
243
+ return { hint: 'Sketch the profile first: sketch_begin → sketch_add → sketch_commit (a second sketch_add adds a loop on that sketch), then insert again.' };
241
244
  }
242
245
  return null;
243
246
  }
@@ -39,9 +39,9 @@ Then select_clear {} → camera_set { view: "iso" } → screenshot { save_to: tr
39
39
 
40
40
  Reading results: every model-changing tool answers { ok, errors, status } with return "status" by default over MCP (no script echo; get_script reads it, get_script { range: { fromFeature, toFeature } } reads one span). status.runState is not_run_yet | ok | failed; errors rows are feature_failed with the viewport's text and a detail reason.
41
41
  Ids are opaque surf ids from parts, list_assemblies, create_part, create_assembly; never a path or a display name.
42
- Topics: guide { topic: "dialect" | "features" | "selection" | "paint" | "limits" | "camera" | "assembly" }; list_helpers { names } documents any script helper.
42
+ Topics: guide { topic: "dialect" | "features" | "selection" | "paint" | "limits" | "camera" | "assembly" | "modeling" | "molding" }; list_helpers { names } documents any script helper.
43
43
 
44
- In-viewer prompt pane. ${CLOSING_REPLY_GUIDANCE} set_status is for progress and does not close the task. ${BUILDING_STATUS_GUIDANCE} state "responding" (alias typing) is the bouncing dots after the user sends. Listing parts, faces, edges, or transforms, status, and read_messages never start building. Building stays until the closing reply. reply_to_user takes an in_reply_to that this session actually received; any other id is unknown_prompt and is not shown in the chat. After read_messages acks a prompt, that id stays in the response's recent list (the last 50 prompts in this session, oldest first, each { id, state }), including on a later empty read_messages {}.`;
44
+ In-viewer prompt pane. ${CLOSING_REPLY_GUIDANCE} set_status is for progress and does not close the task. ${BUILDING_STATUS_GUIDANCE} Be interactive: post_progress while you work, especially during long reasoning. A fresh surfcad-mcp process per tool call is normal and stays present. A long-lived process is optional and nothing depends on it. Call close_session once when you are done. close_session is not sent on process exit. state "responding" (alias typing) is the bouncing dots after the user sends. Listing parts, faces, edges, or transforms, status, and read_messages never start building. Building stays until the closing reply. reply_to_user takes an in_reply_to that this session actually received; any other id is unknown_prompt and is not shown in the chat. Omit in_reply_to to post one plain-text message to this paired session when no prompt is waiting (not a prompt id, one per second). After read_messages acks a prompt, that id stays in the response's recent list (the last 50 prompts in this session, oldest first, each { id, state }), including on a later empty read_messages {} and on a remote session. An idle session that has not received a prompt has recent: [].`;
45
45
 
46
46
  const FEATURES = `Feature blocks. The script of a part is plain JavaScript over the SurfCAD helpers, and the feature strip reads it from marker comments. Every insert_* writes one block:
47
47
 
@@ -64,7 +64,7 @@ What the markers buy you:
64
64
 
65
65
  Script snippet feature. When no insert_* can do an operation, insert_code_snippet { gap, why, script } adds one block (its first line is // FEATURE-GAP: <missing feature or option> | <why the existing feature did not work>); script reads and sets part. Use set_script { part_id, source } only to rewrite a whole part; part_id must be the active part. Never redeclare a reserved helper name (cut, hole, shell, filletEdges, convexEdges, ...; the set_script description lists them): rename your variable.
66
66
 
67
- Sketch sessions. sketch_begin → sketch_add { tool, ... } / pick_points { kind, keys } → sketch_commit saves a contour; sketch_cancel leaves. In-contour entities are p0, e0, a0, ...; a saved contour is @contour id=c1 in the script.`;
67
+ Sketch sessions. sketch_begin → sketch_add { tool, ... } / pick_points { kind, keys } → sketch_commit saves a contour; sketch_cancel leaves. A second closed sketch_add adds a loop on the same sketch. insert_make_extrude { height, contour? } extrudes that contour (omitted: the newest saved contour no feature uses yet). slot_assign_contour on Extrude accepts several contours; loop_role is auto, outer, or hole. In-contour entities are p0, e0, a0, ...; a saved contour is @contour id=c1 in the script.`;
68
68
 
69
69
  const SELECTION = `Selection. Faces and edges are addressed by keys that survive a rerun of the same script and are invalid after a remesh.
70
70
 
@@ -126,7 +126,92 @@ The Joints card is the advanced path for the same write: joint_open {} → joint
126
126
 
127
127
  Hardware. One part per unique fastener type, patterned to every place it goes: list_faces on the fastened part (cylindrical rows, filter by radius) gives each hole's center and axis in that part's frame (frame is "local"); compose with part_get_transform when the fastener does not share it. insert_pattern_points { points: [{ at, axis }, ...], up } on the fastener part places one instance per hole; insert_array3_d covers a grid. A bolt circle of holes is insert_polar_array { count, boltCircleRadius, axis, boreRadius, boreHeight } on the part being drilled (boreRadius greater than 0 subtracts the holes and does not copy the body; boreRadius 0 copies it; boltCircleRadius defaults to 0, on the axis). Do not record a bolt-circle hole pattern as a FEATURE-GAP.
128
128
 
129
- Saving. Working-copy tools never commit. git_save { message } is the one vault write; it answers consent_pending while the Allow dialog is up (retry the same call after the user clicks Allow), clean when nothing changed, and passes through pending_save, upgrade_required, conflict and repo-moved unchanged. A save is many GitHub round trips: when it is still running after about 20 s, git_save answers { status: "running", saveId } and keeps going; poll git_save_status { save_id } until it answers the save result.`;
129
+ Saving. Working-copy tools never commit. git_save { message } is the one vault write; it answers consent_pending while the Allow dialog is up (retry the same call after the user clicks Allow), clean when nothing changed, and passes through pending_save, unsupported_vault_version, conflict and repo-moved unchanged. Checked out on main, git_save and git_add_to_repo answer save_on_main and write nothing: git_branch_create { name }, then git_save { message } on that branch. A save is many GitHub round trips: when it is still running after about 20 s, git_save answers { status: "running", saveId } and keeps going; poll git_save_status { save_id } until it answers the save result.`;
130
+
131
+ const MODELING = `3D modeling guidelines. Follow these on every part; for a part that will be injection molded also read guide { topic: "molding" }.
132
+
133
+ First part. create_assembly already made the first part and made it active; its result partId is that part. rename_part it and build on it. Do not call create_part for the first part; create_part is for the second part onward.
134
+
135
+ Order of operations.
136
+ - Block out with primitives, then Build and Shape, then Polish, then pattern and place (the ribbon order in guide { topic: "start" }).
137
+ - Shell before fillets: insert_shell first, then fillet the concave (inside) edges, then the convex (outside) edges. Filleting every convex edge before the shell can leave the shell as several bodies; shell-first keeps one body and an even wall. Check status.bodyCount is 1 after each step.
138
+ - Draft (insert_add_draft) goes before the shell, so the inside walls inherit it.
139
+ - Keep edges that must stay sharp (a parting line, a rib base on a molded part) out of the fillet selection: select the faces whose edges you want with select_faces, then insert_fillet_edges { use_selection: true }.
140
+
141
+ Reuse instead of rebuilding.
142
+ - Repeated parts: one part, many instances. insert_part { part_id, instance: true } or a pattern, never a second copy rebuilt by hand. Hardware is one part per unique fastener type, patterned to every place it goes.
143
+ - Symmetric geometry: model one half or one side and insert_mirror it.
144
+ - Repeated features: insert_hole_pattern for holes, insert_polar_array for bolt circles, insert_array3_d for grids, insert_pattern_points to put one copy on every hole center. Never place the same hole N times.
145
+ - Prefer boolean operations with primitives (insert_cube, insert_rounded_box, insert_cylinder, insert_tube, insert_sphere with combine add or subtract, or insert_boolean) over hand sketches. Sketch (sketch_begin, then insert_make_extrude or insert_make_revolve) only for a profile no primitive or primitive boolean gives.
146
+ - Features first; insert_code_snippet only for a real feature gap, with its // FEATURE-GAP line.
147
+
148
+ Assemblies and joints.
149
+ - Fix one base part with a fixed joint (joint_create { type: "fixed" }).
150
+ - Place every part that touches or attaches to another with joint_create: one call creates the joint and solves the placement. Block-out positions are rough; joints set the final positions.
151
+ - Use part_set_transform only for a part that touches nothing. An unjointed_part warning means a touching part has no joint yet: joint it.
152
+ - After a part edit, a joint_broken warning means a joint face moved or vanished: list_joints {}, then fix the part or joint_edit to new picks.
153
+ - Pick joint faces by stamped name (list_faces, then face_id) rather than by position, so the joint survives later edits; and add joints as soon as two parts mate, not at the end.
154
+
155
+ Check your work. After each stage: status (runState ok, bodyCount 1 for a one-piece part), screenshot { save_to } from iso plus one useful view, and show the user.`;
156
+
157
+ /**
158
+ * Design guidelines for high pressure injection molding. The numbers that
159
+ * have a code constant are pinned by test/moldingGuide.test.mjs against
160
+ * src/molding (draft threshold, the 0.5° vertical band, the lifter tilts,
161
+ * the wall thin/thick ratios). Rib ratio, wall range and texture draft are
162
+ * design rules with no code constant.
163
+ */
164
+ const MOLDING = `Design guidelines: high pressure injection molding. Follow these whenever the user's part will be injection molded. Check the part with mold_fit and mold_draft before you call it done.
165
+
166
+ Draft.
167
+ - Give every face that slides against the mold at least 1° of draft along the pull. This is also the default mold_draft / mold_dfm threshold.
168
+ - Use 0.5° only as a rare exception, and tell the user where.
169
+ - 0.25° is acceptable only around ejector sleeves.
170
+ - Textured surfaces: use at least 3°, or follow the Mold-Tech recommendation for that specific texture (deeper textures need more draft).
171
+ - The checker treats a wall within 0.5° of vertical as vertical. That wall is below threshold, so it is not a pass.
172
+
173
+ Wall thickness.
174
+ - Keep walls between 1 and 6.35 mm. Prefer 1 to 4 mm.
175
+ - Never go below 0.75 mm.
176
+ - Keep the wall uniform: avoid thin areas under 50% of nominal. mold_fit flags walls thinner than 0.6× nominal as thin and thicker than 1.5× nominal as thick. Fix any flagged region, or explain it to the user.
177
+
178
+ Ribs.
179
+ - Make ribs 0.5 to 0.65× the adjoining wall thickness.
180
+ - When a rib must be thicker because it is tall, add a moat (a local groove in the wall at the rib's base) that is 40% of the wall thickness deep and 40% of the wall thickness wide. This keeps the junction from becoming a thick section that sinks or voids.
181
+
182
+ Ejector side.
183
+ - Put holes and rib patterns on the ejector (cavity) side where possible, so the part releases with the ejector half and does not stick in the other half.
184
+
185
+ Undercuts, slides and lifters.
186
+ - Every undercut adds steel and cost. Aim for none.
187
+ - mold_fit fit bands: good is 0 undercut regions, fixable is 1 to 4, not_a_fit is 5 or more.
188
+ - Slide: withdraws in the parting plane. All trapped features that share one direction on one connected surface are one block, so two holes in one wall are one slide. Group features to share slides.
189
+ - Lifter: used only when no in-plane direction frees the region. The checker tries tilts of 15°, 20°, then 25° into the core and takes the first that leaves the part without entering material. 20° is the nominal lifter angle. A feature that needs more than 25° cannot be made with a lifter.
190
+ - Unresolved undercut: no straight direction frees it (for example, a slot whose ends narrow toward the outer face). Redesign it. Do not leave it for a special mechanism unless the user agrees.
191
+ - A wall within 0.5° of vertical is not a side action. Faces nearly parallel to the motion (under about 3°) do not block it.
192
+
193
+ What mold_fit checks.
194
+ - Pull direction: it searches box axes, large planar normals, and about 80 icosphere directions, and picks the pull with the least occluded undercut area. Pass pull to score your own axis.
195
+ - Wall: local thickness per triangle, with nominal, min, max, mean, and median, plus thin regions (under 0.6× nominal) and thick regions (over 1.5×).
196
+ - Draft: checked against 1°. Triangles within 0.5° of perpendicular to the pull are not undercuts.
197
+ - Parting: core and cavity by visibility, with one outer parting loop.
198
+ - sideActions: slides, lifters, and unresolved undercuts. Their count is what the report prices.
199
+ - Ejector pin candidate spots: place ejectors on flat, thick, cored-out areas, not on cosmetic faces.
200
+ - It is a geometric check, not a supplier DFM. It can run up to 120 s on a real part; keep the tab in the foreground.
201
+
202
+ Edges.
203
+ - Avoid sharp edges. Fillet edges and corners everywhere except along the parting line, which must stay sharp so the mold halves shut off cleanly, and at the base of ribs, where the rib-to-wall junction must stay sharp to reduce sink. Do not fillet a rib base.
204
+ - Avoid sudden thickness jumps, knife edges, and sharp inside corners (rib bases excepted).
205
+
206
+ Shape.
207
+ - Avoid big openings in the middle of a part. Flow has to split around them and meet again, which leaves knit lines (weak, visible seams).
208
+ - Avoid horseshoe or C-shaped parts, because they warp. Add a tie bar or close the shape if the design allows it.
209
+ - Avoid very long aspect ratios (more than about 10:1). They warp and often need hot runners.
210
+
211
+ SurfCAD examples (from the flanged-box side-action playtests).
212
+ - Keep the flange flush with the inside wall at the rim, with no step into the cavity.
213
+ - Make bosses protrude outward, not into the cavity.
214
+ - Keep flange holes clear of the corner fillets.`;
130
215
 
131
216
  /** Topic name → one-line summary and the text. Order is the listing order. */
132
217
  export const GUIDE_TOPICS = Object.freeze({
@@ -138,6 +223,8 @@ export const GUIDE_TOPICS = Object.freeze({
138
223
  limits: { summary: 'The 30 s kernel budget, what is slow, worker restarts and stale status, result sizes, pairing errors', text: LIMITS },
139
224
  camera: { summary: 'Which side each named view looks from, explicit poses, select_clear before a screenshot, screenshot to file', text: CAMERA },
140
225
  assembly: { summary: 'Documents, create_part placement, insert by reference, part instances, joint_create as the default assembly path, hardware, git_save', text: ASSEMBLY },
226
+ modeling: { summary: '3D modeling guidelines: build on the create_assembly seed part, shell before fillets, draft before shell, reuse (instances, mirror, patterns) over rebuilding, joints, check bodyCount', text: MODELING },
227
+ molding: { summary: 'Injection molding design rules: draft 1° (0.5° vertical band), walls 1 to 6.35 mm with 0.6× / 1.5× thin and thick flags, ribs, ejector side, slides and lifters (15/20/25°), parting line and rib bases stay sharp, what mold_fit checks', text: MOLDING },
141
228
  });
142
229
 
143
230
  /** The core topics, in listing order (the error topics are listed on one line after them). */
@@ -217,12 +304,12 @@ export function guideResourceContents(uri, version = loadPackageVersion()) {
217
304
  export const SERVER_INSTRUCTIONS = [
218
305
  PROMPT_SERVER_INSTRUCTIONS,
219
306
  '',
220
- `SurfCAD quick start. Pair, then call guide { topic: "start" } before the first model call; guide {} lists every topic (${GUIDE_TOPIC_NAMES.join(', ')}).`,
221
- 'Flow, in ribbon order, each stage across the whole assembly before the next: 1 Block: create_part, then insert_cube / insert_cylinder / insert_tube at rough size and position, screenshot for the user. 2 Build: insert_hole, insert_cut, insert_shell, insert_make_extrude / revolve / sweep / loft. 3 Polish: insert_fillet_edges, insert_chamfer_edges on small edge sets. 4 Place: fix one base part with a fixed joint, then joint_create for every part that touches or attaches to another (one call creates the joint and solves placement). part_set_transform only for parts that touch nothing.',
307
+ `SurfCAD quick start. Pair, then call guide { topic: "start" } before the first model call; guide {} lists the topics (${GUIDE_TOPIC_NAMES.join(', ')}).`,
308
+ 'Flow: 1 Block create_part then insert_cube / insert_cylinder / insert_tube, screenshot. 2 Build insert_hole, insert_cut, insert_shell, insert_make_extrude / revolve / sweep / loft. 3 Polish insert_fillet_edges, insert_chamfer_edges. 4 Place: fix one base part with a fixed joint, then joint_create. part_set_transform only for parts that touch nothing.',
222
309
  'Rules that bite: helper names (cut, hole, shell, ...) are reserved, never redeclare them; set_script needs the active part\'s id (set_active_part first) and only rewrites a whole part, insert_code_snippet { gap, why, script } is the one-operation fallback; use_selection is single use: pick, insert once, pick again (nothing selected is no_selection).',
223
310
  'Verify: select_clear → camera_set { view } → screenshot { save_to: true }. right puts the camera on +X, front on -Y, top on +Z.',
224
311
  'Save only when the user asks: git_save { message } answers consent_pending until the user clicks Allow; retry the same call.',
225
- 'Keep results small: tools default to return: "status" (no script echo; get_script reads it), list_faces { filter, page }, list_commands { group }.',
312
+ 'Small results: tools default to return: "status" (no script echo; get_script reads it), list_faces { filter, page }, list_commands { group }.',
226
313
  ].join('\n');
227
314
 
228
315
  export function guideToolDefinition() {