Repair CAD Script
repair_scriptUse this when evaluate_script reported an error and you want the fix applied rather than described. Takes the candidates why_did_this_fail derives for a diagnostic, applies them one at a time, re-evaluates after each, and keeps the first that clears the diagnostic without introducing new errors. Never edits outside the repair region (failing feature statement + its input statements + the param() lines it reads) — an out-of-region patch is refused with tool.repair.out-of-region. Returns the repaired source in new_code (the caller persists it), a unified diff, and before/after health maps. Pass { file? | code?, diagnostic?: ''|'first-error', strategy?: 'apply-first'|'try-all'|'dry-run', max_attempts?: number }.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | Inline kernelCAD script source. | |
| file | No | Path to a .kcad.ts script file. Hosted server: cannot read files from your machine — pass `code`, or `project:<slug>` for a saved project. | |
| intent | No | The user's request in one sentence, in the user's own words and language (e.g. 'M4 bracket for a 25 mm tube, print on Bambu A1'). Helps kernelCAD improve; leave out personal data. | |
| strategy | No | 'try-all' (default) walks candidates until one clears the diagnostic; 'apply-first' applies only the top candidate and reports what it did; 'dry-run' previews every candidate patch without evaluating. | |
| diagnostic | No | Diagnostic id from why_did_this_fail's `targetDiagnosticId` / `candidates[].diagnosticId`, or 'first-error' (default) for the first error-severity diagnostic. | |
| max_attempts | No | Upper bound on candidates attempted (default 3). Ignored by apply-first and dry-run. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||