diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 1be5d49..51d779e 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -12,7 +12,7 @@ { "name": "shapeitup", "description": "CAD scripting toolkit: create/modify .shape.ts files, validate geometry, check collisions, export STEP/STL/3MF via Replicad + OpenCascade. Runs headless; live 3D preview available if the ShapeItUp VS Code extension is installed.", - "version": "1.29.4", + "version": "1.29.5", "author": { "name": "Asbjorn Rorvik", "email": "rorvik.asbjorn@gmail.com" diff --git a/CHANGELOG.md b/CHANGELOG.md index eb973a4..a95c997 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,29 @@ Releases 1.17.0–1.24.0 are described only in their Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); the project follows semantic versioning at the extension level. +## [1.29.5] - 2026-09-23 + +Extension `1.29.5` / mcp-server `1.29.5`. + +### Fixed +- **Stdlib helpers no longer warn about their own internals.** + `holes.counterbore` used through `patterns.cutAt` printed + "fuse #N: fuse produced no new material" once per placement, and `placeOn` + raised the extrude-plane hint whose recommended fix is `placeOn` itself. + The hint told user code from stdlib code by looking for `/stdlib/` in the + call stack, which is only true when core runs from source. Once bundled + (the worker, the MCP server, the website), every helper looked like user + code. Stdlib construction now runs inside an explicit internal scope that + the no-op fuse guard, the extrude-plane hint and the pen-axis advisory + respect. It covers `placeOn`, `extrudeCentered`, `holes.counterbore`, + `holes.teardrop`, `bearings.seat` and the motor mount plates. Internal fuses + no longer use up the user's `fuse #N` numbers. +- **`holes.counterbore` on a plate too thin for the head.** When the head + pocket is as deep as the plate (M4 in 4 mm: the pocket is 4.2 mm deep), the + pocket cuts straight through and the screw head has nothing to seat on. It + now says that once, instead of emitting a no-op fuse warning per hole. The + cut geometry is unchanged. + ## [1.29.4] - 2026-09-23 Extension `1.29.4` / mcp-server `1.29.4` — a face op no longer writes a line diff --git a/packages/core/src/executor.test.ts b/packages/core/src/executor.test.ts index c5cfc75..4693695 100644 --- a/packages/core/src/executor.test.ts +++ b/packages/core/src/executor.test.ts @@ -13,7 +13,7 @@ import { __resetCutPatchedForTests, __resetFusePatchedForTests, } from "./index"; -import { drainRuntimeWarnings, resetRuntimeWarnings } from "./stdlib/warnings"; +import { asStdlibInternal, drainRuntimeWarnings, resetRuntimeWarnings } from "./stdlib/warnings"; // --------------------------------------------------------------------------- // Mocks @@ -1169,6 +1169,27 @@ describe("patchShapeFuseNoOpGuard — warns when fuse adds zero material", () => expect(warnings[0]).toMatch(/fully contained in the target/); }); + it("ignores a no-op fuse a stdlib helper performs on its own behalf, and doesn't number it", () => { + // holes.counterbore fusing a shaft that lies inside its pocket is not the + // user's fuse. Reporting it read as "you made a mistake" once per cutAt + // placement, and spending an ordinal on it made "fuse #N" point at the + // wrong line of the user's script. + const { replicad, volumeMap, _3DShape } = makeFakeReplicad(); + patchShapeFuseNoOpGuard(replicad); + + const cutter: any = new _3DShape(); + volumeMap.set(cutter, 175.79); + asStdlibInternal(() => cutter.fuse(new _3DShape())); + expect(drainRuntimeWarnings()).toEqual([]); + + const target: any = new _3DShape(); + volumeMap.set(target, 2500); + target.fuse(new _3DShape()); + const warnings = drainRuntimeWarnings(); + expect(warnings).toHaveLength(1); + expect(warnings[0]).toMatch(/^fuse #1:/); + }); + it("names the disjoint axis and suggests a translate when the operands' AABBs don't touch", () => { // P2-3 from knitting-printer v8: the cut guard's axis-disjoint hint // (`Cutter is RIGHT-OF target, translate by N mm on X`) saved real diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index f0ad916..d66b82c 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -58,6 +58,7 @@ import { drainCutAtOutcomes, drainExtrudeHints, drainRuntimeWarnings, + inStdlibInternal, nextCutCallIndex, nextFuseCallIndex, pushRuntimeWarning, @@ -692,10 +693,15 @@ export function patchShapeFuseNoOpGuard(replicad: any): boolean { } const originalFuse = proto.fuse; proto.fuse = function patchedFuse(this: any, other: any, options?: any) { - // Consume a call ordinal on every .fuse(), mirroring the cut guard — + // Consume a call ordinal on every user .fuse(), mirroring the cut guard — // when a user has several .fuse() calls in one script and one silently // produces no new material, identical warnings make the offender // impossible to locate. + // A stdlib helper fusing its own cutter pieces is not the user's fuse: + // don't measure it, and don't spend one of the user's "fuse #N" ordinals + // on it either, or the numbers in their warnings stop matching the + // .fuse() calls they can see. + if (inStdlibInternal()) return originalFuse.call(this, other, options); const callIdx = nextFuseCallIndex(); const inputVolume = readVolumeSafe(this, replicad); // Snapshot AABBs before the fuse so the axis-disjoint hint can describe diff --git a/packages/core/src/instrumentation.ts b/packages/core/src/instrumentation.ts index 370f3cd..deac9d7 100644 --- a/packages/core/src/instrumentation.ts +++ b/packages/core/src/instrumentation.ts @@ -2,6 +2,7 @@ import { assertPositiveFinite } from "./stdlib/standards"; import { claimNonXYPlaneHint, enqueueExtrudeHint, + inStdlibInternal, shiftPendingExtrudeHint, pushRuntimeWarning, type PendingExtrudeHint, @@ -1058,9 +1059,11 @@ function validateSketchOnPlane(self: any, planeName: unknown): void { // axis-mapping warning would just be noise. If the blueprint or its bbox // can't be read (e.g. a unit-test stub without `.blueprint`), we fall back // to firing the hint — preserving the prior behaviour for non-replicad - // receivers. + // receivers. A stdlib helper sketching its own profile is skipped too: the + // user never drew with that pen. if ( planeName !== "XY" && + !inStdlibInternal() && typeof self === "object" && self !== null && PEN_AXIS_DRAWINGS.has(self) && diff --git a/packages/core/src/stdlib/bearings.ts b/packages/core/src/stdlib/bearings.ts index 12cd996..a232588 100644 --- a/packages/core/src/stdlib/bearings.ts +++ b/packages/core/src/stdlib/bearings.ts @@ -13,6 +13,7 @@ import { makeCylinder, type Shape3D } from "replicad"; import { BALL_BEARING, LINEAR_BEARING, CUT_EPSILON } from "./standards"; import { applyAxis, resolveHoleAxis, type HoleAxis } from "./holes"; +import { asStdlibInternal } from "./warnings"; /** Clearance behind the bearing back so the cut-tool doesn't coplanar-fail. */ const POCKET_BACK_CLEARANCE = 0.2; @@ -173,7 +174,7 @@ export function seat( [0, 0, 1] ); - const tool = pocket.fuse(relief); + const tool = asStdlibInternal(() => pocket.fuse(relief)); return applyAxis(tool, axis); } diff --git a/packages/core/src/stdlib/holes.test.ts b/packages/core/src/stdlib/holes.test.ts index 06c799c..e678a1d 100644 --- a/packages/core/src/stdlib/holes.test.ts +++ b/packages/core/src/stdlib/holes.test.ts @@ -1,6 +1,8 @@ -import { describe, it, expect } from "vitest"; +import { describe, it, expect, beforeAll } from "vitest"; import * as holes from "./holes"; import { applyAxis, type HoleAxis } from "./holes"; +import { initCore } from "../index.js"; +import { loadOCCTForTest } from "../testing/occt.js"; // --------------------------------------------------------------------------- // Pin the public API surface of `holes`. OCCT is not required for these @@ -326,3 +328,67 @@ describe("holes.slot — length vs travel input forms", () => { ).toThrow(/travel.*width.*avoid the inequality/); }); }); + +// --------------------------------------------------------------------------- +// counterbore must not report its own construction as the user's mistake. +// +// The cutter is a pocket fused to a shaft. On a plate no thicker than the +// pocket is deep (M4 in 4 mm: pocket 4.2 mm) the shaft sits wholly inside the +// pocket, the fuse adds nothing, and the no-op fuse guard used to print +// "fuse #N: fuse produced no new material" once per patterns.cutAt placement — +// about a fuse the user never wrote. What IS wrong is that the pocket goes +// straight through, so that is what should be said, once. +// --------------------------------------------------------------------------- + +describe("holes.counterbore warnings (real OCCT)", () => { + let core: Awaited>; + + beforeAll(async () => { + core = await initCore(loadOCCTForTest); + }, 120_000); + + async function plateWithCounterbores(thickness: number, extra = "") { + const r = await core.execute(` + const { drawRoundedRectangle } = __replicad__; + const { holes, patterns, shape3d } = __shapeitup__; + function main() { + let plate = shape3d(drawRoundedRectangle(100, 80, 6).sketchOnPlane("XY").extrude(${thickness})); + ${extra} + return patterns.cutAt( + plate, + () => holes.counterbore("M4", { plateThickness: ${thickness} }).translate(0, 0, ${thickness}), + patterns.grid(2, 2, 86, 66), + ); + } + `, undefined, { partStats: "full" }); + return r; + } + + it("says once that the pocket leaves no seat, and nothing about a fuse, when the plate is too thin", async () => { + const { warnings } = await plateWithCounterbores(4); + expect(warnings.filter((w) => /fuse/.test(w))).toEqual([]); + const seat = warnings.filter((w) => /no seat for the screw head/.test(w)); + expect(seat).toHaveLength(1); + expect(seat[0]).toMatch(/holes\.counterbore\("M4", \{ plateThickness: 4 \}\)/); + }); + + it("is silent on a plate thick enough to seat the head, and still cuts pocket + shaft", async () => { + const { warnings, parts } = await plateWithCounterbores(6); + expect(warnings).toEqual([]); + const pocket = Math.PI * 3.65 ** 2 * 4.2; // Ø7.3 x 4.2 + const shaft = Math.PI * 2.2 ** 2 * (6 - 4.2); // Ø4.4 (M4 + clearance fit) below the pocket + const plate = (parts[0] as any).volume; + const solid = 100 * 80 * 6 - (4 - Math.PI) * 6 * 6 * 6; // rounded corners r=6 + expect(solid - plate).toBeCloseTo(4 * (pocket + shaft), 0); + }); + + it("keeps the user's own fuse numbering: a no-op fuse they wrote is still #1", async () => { + const { warnings } = await plateWithCounterbores( + 6, + `plate = plate.fuse(drawRoundedRectangle(10, 10, 1).sketchOnPlane("XY").extrude(2));`, + ); + const fuse = warnings.filter((w) => /fuse produced no new material/.test(w)); + expect(fuse).toHaveLength(1); + expect(fuse[0]).toMatch(/^fuse #1:/); + }); +}); diff --git a/packages/core/src/stdlib/holes.ts b/packages/core/src/stdlib/holes.ts index 387e37b..d64f4c2 100644 --- a/packages/core/src/stdlib/holes.ts +++ b/packages/core/src/stdlib/holes.ts @@ -45,7 +45,12 @@ import { assertPositiveFinite, assertSupportedSize, } from "./standards"; -import { pushRuntimeWarning, claimAmbiguousRawWarning } from "./warnings"; +import { + asStdlibInternal, + claimAmbiguousRawWarning, + pushRuntimeWarning, + pushRuntimeWarningOnce, +} from "./warnings"; /** * Raw diameters that equal a nominal metric size (M3, M4, M5, M6, M8, M10, M12). @@ -390,13 +395,29 @@ export function counterbore( // CUT_EPSILON so coincident faces don't produce non-manifold geometry. The // original overlap into the pocket is preserved by starting at -plateThickness. const eps = opts.strict ? 0 : CUT_EPSILON; + const shaftLength = plateThickness + eps; + // When the pocket is at least as deep as the shaft is long, the shaft lies + // wholly inside it: fusing would add nothing, and would trip the no-op + // fuse guard with a warning about an operation the user never wrote. The + // real problem is the one worth saying — the pocket reaches through the + // plate, so there is nothing left for the screw head to seat on. + if (shaftLength <= pocketH) { + pushRuntimeWarningOnce( + `holes.counterbore("${spec}", { plateThickness: ${plateThickness} }): the ` + + `${size} head pocket (Ø${pocketD.toFixed(1)} × ${pocketH.toFixed(1)} mm) is as deep as ` + + `the plate, so it cuts straight through and leaves no seat for the screw head. ` + + `Use a plate thicker than ${pocketH.toFixed(1)} mm, or holes.countersink / ` + + `holes.through for a plate this thin.`, + ); + return applyAxis(pocket, axis); + } const shaft = makeCylinder( shaftD / 2, - plateThickness + eps, - [0, 0, -plateThickness - eps], + shaftLength, + [0, 0, -shaftLength], [0, 0, 1] ); - const tool = pocket.fuse(shaft); + const tool = asStdlibInternal(() => pocket.fuse(shaft)); return applyAxis(tool, axis); } @@ -642,31 +663,35 @@ export function teardrop( // axis = "+X" → sketch on YZ, extrude along +X. Local X → world Y, local Y → world Z. const plane = axis === "+Y" ? "XZ" : "YZ"; - const circleSolid = drawCircle(r) - .sketchOnPlane(plane) - .extrude(totalDepth) - .asShape3D(); + // Internal: these non-XY extrudes and the fuse are the cutter's own + // construction, not the user's, so neither may raise a hint against them. + return asStdlibInternal(() => { + const circleSolid = drawCircle(r) + .sketchOnPlane(plane) + .extrude(totalDepth) + .asShape3D(); - // Triangle: apex at (0, 2r), base corners DELIBERATELY below the circle's - // equator at (±r, -r). The lower half of this triangle is hidden inside - // the circle, so the visible silhouette is still a clean teardrop — but - // the 3D fuse now has a volumetric overlap instead of two shared boundary - // points. OCCT's boolean robustness drops sharply on shapes that only - // touch at points, which is why the earlier shared-equator variants - // produced shapes the downstream cut couldn't process. - const triangleSolid = draw([r, -r]) - .lineTo([0, 2 * r]) - .lineTo([-r, -r]) - .close() - .sketchOnPlane(plane) - .extrude(totalDepth) - .asShape3D(); + // Triangle: apex at (0, 2r), base corners DELIBERATELY below the circle's + // equator at (±r, -r). The lower half of this triangle is hidden inside + // the circle, so the visible silhouette is still a clean teardrop — but + // the 3D fuse now has a volumetric overlap instead of two shared boundary + // points. OCCT's boolean robustness drops sharply on shapes that only + // touch at points, which is why the earlier shared-equator variants + // produced shapes the downstream cut couldn't process. + const triangleSolid = draw([r, -r]) + .lineTo([0, 2 * r]) + .lineTo([-r, -r]) + .close() + .sketchOnPlane(plane) + .extrude(totalDepth) + .asShape3D(); - const fused = circleSolid.fuse(triangleSolid); - // Translate by -eps along the extrude axis so the cutter spans - // [-eps, depth+eps] — overshooting both the near and far faces. - if (eps === 0) return fused; - return axis === "+Y" ? fused.translate(0, -eps, 0) : fused.translate(-eps, 0, 0); + const fused = circleSolid.fuse(triangleSolid); + // Translate by -eps along the extrude axis so the cutter spans + // [-eps, depth+eps] — overshooting both the near and far faces. + if (eps === 0) return fused; + return axis === "+Y" ? fused.translate(0, -eps, 0) : fused.translate(-eps, 0, 0); + }); } /** diff --git a/packages/core/src/stdlib/motors.ts b/packages/core/src/stdlib/motors.ts index 92d46b0..d3505a5 100644 --- a/packages/core/src/stdlib/motors.ts +++ b/packages/core/src/stdlib/motors.ts @@ -34,6 +34,7 @@ import { drawRectangle } from "replicad"; import { Part, type Axis, normalizeAxis } from "./parts"; import { shape3d } from "./placement"; import { cylinder } from "./cylinder"; +import { asStdlibInternal } from "./warnings"; import { NEMA17, NEMA23, @@ -306,7 +307,7 @@ function buildNemaMountPlate( length: holeLength, diameter: boltClearanceDia, }); - tool = tool.fuse(bolt); + tool = asStdlibInternal(() => tool.fuse(bolt)); } if (opts.boss === true) { const bossDepth = opts.bossDepth ?? 2; @@ -324,7 +325,10 @@ function buildNemaMountPlate( length: bossDepth + overcut, diameter: spec.pilotDia, }); - tool = tool.fuse(boss); + // The boss is the pilot bore's own diameter and lies inside it, so this + // fuse adds nothing today; scoped internal so it never reads as the + // user's no-op fuse. + tool = asStdlibInternal(() => tool.fuse(boss)); } // Axis routing — same rotation table as holes.applyAxis. Inlined here to diff --git a/packages/core/src/stdlib/placement.test.ts b/packages/core/src/stdlib/placement.test.ts index 15e5331..d5ec30e 100644 --- a/packages/core/src/stdlib/placement.test.ts +++ b/packages/core/src/stdlib/placement.test.ts @@ -1,5 +1,7 @@ -import { describe, it, expect } from "vitest"; +import { describe, it, expect, beforeAll, afterEach } from "vitest"; import { extrudeCentered } from "./placement"; +import { initCore } from "../index.js"; +import { loadOCCTForTest } from "../testing/occt.js"; // Minimal Sketch stub: records the translate arguments the returned "solid" // receives so we can verify extrudeCentered's shift math without touching @@ -67,3 +69,63 @@ describe("extrudeCentered (plane passed explicitly)", () => { ).toThrow(/Sketch/); }); }); + +// --------------------------------------------------------------------------- +// The extrude-plane hint recommends placeOn — so placeOn must never raise it. +// +// It used to, but only in shipped builds. The hint decided "is this the user's +// extrude?" by looking for a `/stdlib/` frame in the call stack, which is there +// when core runs from source (as here) and gone once it is bundled into the +// worker, the MCP server, or the website. The stub below gives every stack the +// single-file shape a bundle has, so these tests fail the way users saw it. +// --------------------------------------------------------------------------- + +describe("extrude-plane hint vs. the stdlib helpers it recommends (real OCCT)", () => { + let core: Awaited>; + const realPrepare = Error.prepareStackTrace; + + beforeAll(async () => { + core = await initCore(loadOCCTForTest); + }, 120_000); + + afterEach(() => { + Error.prepareStackTrace = realPrepare; + }); + + function asBundled() { + Error.prepareStackTrace = (err) => `${err}\n at main (bundle.js:1:1)`; + } + + const HINT = /bounding box will be/; + + async function warningsFor(body: string) { + asBundled(); + const r = await core.execute(` + const { draw, drawRectangle } = __replicad__; + const { placeOn, extrudeCentered } = __shapeitup__; + function main() { ${body} } + `); + return r.warnings; + } + + it("still fires for the user's own sketchOnPlane('YZ').extrude (the stub keeps the hint live)", async () => { + const warnings = await warningsFor( + `return draw([0, 0]).lineTo([-24, 0]).lineTo([0, 24]).close().sketchOnPlane("YZ").extrude(5);`, + ); + expect(warnings.some((w) => HINT.test(w))).toBe(true); + }); + + it("does not fire for placeOn — the bracket example's gusset rib", async () => { + const warnings = await warningsFor( + `return placeOn(draw([0, 0]).lineTo([-24, 0]).lineTo([0, 24]).close(), "YZ", { into: "+X", distance: 5 });`, + ); + expect(warnings.filter((w) => HINT.test(w))).toEqual([]); + }); + + it("does not fire for extrudeCentered", async () => { + const warnings = await warningsFor( + `return extrudeCentered(drawRectangle(40, 20).sketchOnPlane("XZ"), 10);`, + ); + expect(warnings.filter((w) => HINT.test(w))).toEqual([]); + }); +}); diff --git a/packages/core/src/stdlib/placement.ts b/packages/core/src/stdlib/placement.ts index 25d1f29..7e42fc0 100644 --- a/packages/core/src/stdlib/placement.ts +++ b/packages/core/src/stdlib/placement.ts @@ -7,6 +7,7 @@ import type { DrawingInterface, Shape3D } from "replicad"; import { getSketchPlane } from "../instrumentation"; +import { asStdlibInternal } from "./warnings"; /** * Flip a cut-tool shape so it opens upward from Z=0 instead of downward — the @@ -248,8 +249,14 @@ export function placeOn( // Replicad's `.extrude()` return union is wider than Shape3D (Shell | Solid // | CompSolid | Compound | Vertex | Edge | Wire | Face). At runtime a // Drawing-on-plane extrude always produces a Solid, so the cast is safe. - const extruded = (sketch as unknown as { extrude: (d: number) => unknown }) - .extrude(distance) as Shape3D; + // + // Internal, so the extrude-plane hint stays quiet: that hint's preferred + // fix IS placeOn, and this extrude is placeOn doing the fix. The + // sketchOnPlane above stays outside — the drawing is the user's, and the + // pen-axis advisory about it still applies. + const extruded = asStdlibInternal( + () => (sketch as unknown as { extrude: (d: number) => unknown }).extrude(distance) as Shape3D, + ); // --- Translate the native bbox into the requested half-space -------------- // Native bbox along entry.axis: @@ -294,11 +301,11 @@ export function placeOn( // `Shape3D` so `.cut()` / `.fuse()` chains don't need an `as Shape3D` cast // (Fix #10). // -// Origin tagging: because this function lives in `/stdlib/`, the -// call-stack-based check in `warnings.ts#enqueueExtrudeHint` automatically -// tags the hint as `origin: "stdlib"` and `drainExtrudeHints` drops it. No -// explicit wrap needed — verified against the regex `/[\\/]stdlib[\\/]/` the -// enqueue helper uses. The separate pen-axis hint emitted by +// Origin tagging: the extrude runs inside `asStdlibInternal`, so +// `warnings.ts#enqueueExtrudeHint` tags its hint `origin: "stdlib"` and +// `drainExtrudeHints` drops it. The call-stack check there can't be relied on +// for this: once core is bundled no frame names `/stdlib/`, and the hint used +// to fire from the helper it recommends. The separate pen-axis hint emitted by // `sketchOnPlane` fires before this helper runs (the user already called // `.sketchOnPlane(plane)` to build the Sketch), so extrudeCentered cannot // suppress it. @@ -381,7 +388,9 @@ export function extrudeCentered( const entry = PLANE_AXIS[plane]; // --- Extrude (narrow replicad's Solid | Compound union to Shape3D) ------- - const extruded = sketch.extrude(distance) as Shape3D; + // Internal for the same reason as placeOn's extrude: centring is the fix + // the extrude-plane hint would suggest. + const extruded = asStdlibInternal(() => sketch.extrude(distance) as Shape3D); // --- Translate to center on the plane's normal axis ---------------------- // Native bbox on entry.axis: [0, +distance] when nativeSign=+1, else diff --git a/packages/core/src/stdlib/warnings.ts b/packages/core/src/stdlib/warnings.ts index 5267e94..e51586f 100644 --- a/packages/core/src/stdlib/warnings.ts +++ b/packages/core/src/stdlib/warnings.ts @@ -18,6 +18,44 @@ export function pushRuntimeWarning(msg: string): void { buf.push(msg); } +// Messages already pushed through pushRuntimeWarningOnce this run. For +// advisories raised from inside a tool factory: `patterns.cutAt` calls the +// factory once per placement, and four copies of one warning is noise. +const onceSeen = new Set(); + +/** Push `msg` unless an identical message was already pushed this run. */ +export function pushRuntimeWarningOnce(msg: string): void { + if (onceSeen.has(msg)) return; + onceSeen.add(msg); + buf.push(msg); +} + +// Depth of stdlib-internal construction currently on the stack. The no-op +// fuse guard and the extrude-plane hint describe the USER's operations; a +// helper building its own cutter (counterbore's pocket + shaft, placeOn's +// sketch + extrude) must not be reported as though the user wrote it. +// +// This is an explicit scope rather than a call-stack inspection because the +// stack only names stdlib files when core runs from source. Bundled — the +// worker, the MCP server's dist, the website — every frame points at one +// file, and the helper's own internals read as user code. +let internalDepth = 0; + +/** Run `fn` as stdlib-internal construction; see {@link inStdlibInternal}. */ +export function asStdlibInternal(fn: () => T): T { + internalDepth++; + try { + return fn(); + } finally { + internalDepth--; + } +} + +/** True while a stdlib helper is building geometry on its own behalf. */ +export function inStdlibInternal(): boolean { + return internalDepth > 0; +} + export function drainRuntimeWarnings(): string[] { const out = buf.slice(); buf.length = 0; @@ -26,6 +64,7 @@ export function drainRuntimeWarnings(): string[] { export function resetRuntimeWarnings(): void { buf.length = 0; + onceSeen.clear(); resetCutAtCounter(); resetCutCallCounter(); resetFuseCallCounter(); @@ -324,7 +363,8 @@ export function enqueueExtrudeHint( .split("\n") .filter((line) => !/[\\/]stdlib[\\/]warnings\.(ts|js)/.test(line)) .join("\n"); - const origin = /[\\/]stdlib[\\/]/.test(stackWithoutSelf) ? "stdlib" : "user"; + const origin = + inStdlibInternal() || /[\\/]stdlib[\\/]/.test(stackWithoutSelf) ? "stdlib" : "user"; const hint: PendingExtrudeHint = { plane, length, diff --git a/packages/extension/package.json b/packages/extension/package.json index 5b02751..f866e44 100644 --- a/packages/extension/package.json +++ b/packages/extension/package.json @@ -2,7 +2,7 @@ "name": "shapeitup-vscode", "displayName": "ShapeItUp", "description": "Scripted CAD for VS Code — write TypeScript, see 3D, export STEP/STL/3MF (Bambu Studio & OrcaSlicer ready). AI-powered with Claude Code MCP integration.", - "version": "1.29.4", + "version": "1.29.5", "publisher": "shapeitup", "license": "MIT", "icon": "icon.png", diff --git a/packages/mcp-server/package.json b/packages/mcp-server/package.json index 87b33ad..da50b8d 100644 --- a/packages/mcp-server/package.json +++ b/packages/mcp-server/package.json @@ -1,6 +1,6 @@ { "name": "@shapeitup/mcp-server", - "version": "1.29.4", + "version": "1.29.5", "description": "ShapeItUp MCP server — scripted CAD tools (Replicad/OpenCascade) for Claude Code, Cursor, Claude Desktop, and other MCP clients.", "type": "module", "bin": {