Evaluate CAD Script
evaluate_scriptUse this when you need to run a script and check it compiles. Run a kernelCAD .kcad.ts script and report pass/fail + feature count + diagnostics. When the scene is assembly-built (assembly().part(...) → .model()/.solvedModel()), also returns a parts summary { count, names } AND runs the mechanism-truth gate by default: the mechanism field reports real/broken/unverified and a broken mechanism (self-collision, fastened drift, dof-mismatch) makes ok:false with the failures in diagnostics. Pass { skipMechanismCheck: true } to opt out. Pass either { file: "" } or { code: "" }. Set { dryRun: true } for fast validation while iterating: transpile + capture + capture-light checks WITHOUT OCCT lowering, DFM gates, or meshing — milliseconds instead of seconds (100x+ on boolean/fillet-heavy scripts). A dry run catches script throws, capture-time API misuse, and assembly validity-gate failures, but NOT lowering failures or dfmSpec diagnostics; it leaves the active session untouched, so finish with a full (non-dry) evaluate_script before using session-dependent tools.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | Inline kernelCAD script source. | |
| file | No | Path to a .kcad.ts script file. | |
| dryRun | No | Fast validation only: skip OCCT lowering, DFM gates, and meshing. Does not set or clear the active session. | |
| skipMechanismCheck | No | Opt out of the default mechanism-truth gate. By default a full evaluation of an assembly-built scene runs checkMechanismTruth and returns a `mechanism` verdict (real/broken/unverified); a broken mechanism makes ok:false. Set true to skip the sweep entirely (no `mechanism` field, no cost). Ignored for dryRun and non-assembly scripts. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | Whether the script compiled and lowered cleanly. | |
| parts | No | Assembly parts summary { count, names } when the scene is assembly-built. | |
| dryRun | No | True when the result came from a fast dry run. | |
| mechanism | No | Mechanism-truth verdict for an assembly-built scene (default-on; omitted for dryRun, non-assembly, or skipMechanismCheck:true). 'broken' makes ok:false; 'unverified' keeps ok and surfaces a loud budget diagnostic. | |
| diagnostics | Yes | ||
| featureCount | Yes | Number of features captured by the script. | |
| featureHealth | No | Per-feature health degradations — ONLY features that fell back to a passthrough (warning) or failed to lower (error). Empty when every feature is healthy. Surfaces which feature degraded even when ok is true. |