Diff CAD Scripts
diff_scriptsUse this when you need to see exactly what changed between two script versions. Structured geometric delta between two versions of a kernelCAD script — a baseline ({ baseFile } or { baseCode }) and a revision ({ file } or { code }). Returns agent-readable JSON: per-part added/removed/renamed/changed (volume mm³ + exact bbox deltas, numbers matching inspect({ of: 'part-stats' })), total interference-volume delta with per-pair detail, mate-graph changes (added/removed/changed mates incl. type, connectors, pose, limits), and param changes (value/min/max). Single-shape scripts diff as one "(root)" pseudo-part; a return [a, b] multi-body script diffs per body as "body[0]", "body[1]". An error that still leaves geometry (e.g. a skipped fillet) is listed under base/revised.errors beside the diff. Use after editing a script to verify exactly what changed physically before re-rendering. On a hosted server pass both versions inline: { baseCode: 'return box(10, 10, 10);', code: 'return box(10, 10, 12);' } (base_code/old_code/before and revised_code/new_code/after are accepted as aliases). Read-only — never touches the active session.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | Revised (after) script — inline source. One of file / code is required. | |
| file | No | Revised (after) script — path to a .kcad.ts file. Local servers only. Hosted server: cannot read files from your machine — pass `code`, or `project:<slug>` for a saved project. | |
| baseCode | No | Baseline (before) script — inline source. One of baseFile / baseCode is required. | |
| baseFile | No | Baseline (before) script — path to a .kcad.ts file. Local servers only. Hosted server: cannot read files from your machine — pass `code`, or `project:<slug>` for a saved project. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||