@forgent3d/cad-build
v0.1.7
Published
Portable Forgent3D CAD build capability for coding agents: build-check a build123d-dialect model.py and measure its geometry with the same wasm engine the product runs — no monorepo, no python, no OCCT install. Drives the forgent3d skill's rebuild / run-p
Readme
@forgent3d/cad-build
The portable CAD build capability a coding agent (Claude Code / Codex) drives to
author a Forgent3D model.py. It bundles the same engine the product runs —
@forgent3d/build-service's buildOne / probeOne over @forgent3d/cad-engine's
wasm — so rebuild and run-python return byte-for-byte what the in-product CAD
agent sees. No monorepo, no python, no OCCT install: the wasm + cadkit assets
ship inside this package.
This is the engine behind the forgent3d skill; the skill's scripts shell
out to npx @forgent3d/cad-build … (with a local-path fallback for unpublished use).
Commands
cad-build rebuild [model.py] # build-check + dimension report
cad-build run-python [model.py] --code '…' # measure geometry after the build
cad-build run-python --code-stdin < snippet.py # large snippet via stdin
cad-build recipe <assembly|selectors|outline>
cad-build export [model.py] --format step # step | stl | glb | obj | 3mf
cad-build preview [model.py] # → shareable read-only 3D linkmodel.py defaults to ./model.py; its directory is the project root (so relative
refs resolve exactly like the product's per-project workspace).
- rebuild — mirrors the product's
rebuild_model:ok+ overall bbox + per-body world bboxes + cylindrical-face census + diagnostics, or the first actionable build error. - run-python — mirrors
run_python: runs an ephemeral dialect snippet inmodel.py's namespace after it builds and prints what youprint(). Nothing is persisted — real changes go inmodel.py. - recipe — prints a focused CAD recipe (bundled from the production
*.recipe.ts, single source of truth). - export — writes the built model as STEP/STL/GLB/OBJ/3MF next to the source
(
--outto place it elsewhere). Entirely local; talks to no server. - preview — builds the BREP locally, then uploads
model.pyand that geometry to the anonymous preview endpoint and prints a share link. The link opens read-only for anyone, signed in or not — nothing is rebuilt server-side, and it becomes editable only when someone remixes it into their own account. The secret that lets a laterpreviewupdate the same link lives in.forgent3d-preview.json. Override the endpoint withFORGENT3D_PREVIEW_ENDPOINT.
Build
pnpm --filter @forgent3d/cad-build build # esbuild bundle + copy assets + gen recipes.json
pnpm --filter @forgent3d/cad-build smoke # offline smoke: rebuild / run-python / recipe in an os-temp dirscripts/build.mjs bundles src/cli.ts → dist/cli.mjs (keeping web-tree-sitter
external), copies the runtime assets into dist/assets/
(tree-sitter*.wasm, occt-import-js.cjs + .wasm, cadkit-snapshot.json), and
generates recipes.json. bin/cad-build.mjs points the engine at those assets via
CAD_ENGINE_ASSETS_DIR / OCCT_WASM_JS / CAD_BUILD_ASSETS_DIR before loading the
bundle.
Keep in sync
src/format.ts'sformatRebuild/formatProbemirror cf-sandbox'sformatRebuildModel/formatProbeResult(packages/cf-sandbox/src/lib/agent-tools.ts).recipes.jsonregenerates frompackages/cloud/lib/aicad-agent/recipes/*.recipe.ts.
Relationship to the forgent3d skill
The skill (github.com/forgent3d/forgent3d-skills, mounted here as the
forgent3d-skills submodule) is maintained independently — its SKILL.md is
hand-written and evolves on its own, no longer generated from the in-product
agent-boot.ts prompt. The only contract between the two lines is this CLI: the
skill shells out to cad-build <cmd>, so the subcommand names, flags and output
shape above are what must stay stable. Changing them is a breaking change for the
skill.
