--- name: cadcraft description: >- CADCraft is an open-source, clean-room AutoCAD-style 2D CAD and drafting app (pure Rust, egui) for macOS, Windows, Linux, FreeBSD and the browser, with DXF/DWG file support, clipped block and xref references (XCLIP), attached raster images (IMAGEATTACH: PNG/JPEG/BMP/TIFF), SHX shape-font reading, proxy-preserving DWG saves, editable MTEXT and multileader text, a user keyboard-shortcut dialog, and first-class agent control over MCP, a JSON control channel, a browser page API and a headless CLI. Trigger this skill whenever the user mentions CADCraft (or "the CAD app"), asks what it can or cannot do, which file formats it opens or writes, its keyboard shortcuts or commands, wants to draw, edit, dimension, hatch, block, xref, clip, attach an image, lay out, plot or export a drawing, convert/inspect/verify/round-trip a DXF or DWG, measure what a save loses, script or automate drafting (AutoLISP, .scr scripts, .pgp aliases, MCP, control channel, window.cadcraft, cadcraft-cli), prepare assets for it, or troubleshoot it — and also when they describe the job without naming the app ("draw a floor plan", "edit this DXF", "convert this DWG to PDF/PNG", "put dimensions on this drawing", "check this drawing opens elsewhere"). --- # CADCraft **Audit basis.** Refreshed 2026-11-12 against tag **v0.20.1**, commit **`7526dc62c14e71b3c8d46e73bbf1fa29ef506af1`** — `git rev-parse HEAD` in the pinned checkout confirms it, and the installed 0.20.1 bundle (id `ai.storyteller.cadcraft`) prints `cadcraft 0.20.1 (7526dc62c14e71b3c8d46e73bbf1fa29ef506af1)`. The previous release this skill described was v0.18.0 (`32238e83c2c8bf643994132883e94bc96961f649`, "Release 0.18.0", 2026-11-06). **v0.18.0 → v0.20.1 delta** (measured with `git diff v0.18.0..HEAD`: **146 files, +8,144/−856**; 14 added, 132 modified, 0 deleted). **No engine command id was added or removed** — the multiline-aware literal set is identical at both tags (439 ids), `gc!`/`dc!` stay at 12/6, so the registry stays **457**; the only new catalog id is UI-only **`ui.shortcuts`** (Tools ▸ Customize ▸ Keyboard Shortcuts...), which gives any command a shortcut, lets the user's choice win over the built-in one, reassigns and reports conflicts, keeps the clipboard keys, Delete and Cmd+Q fixed, and stores at most 1,000 with the preferences (`crates/ui-egui/src/keys.rs`, `crates/ui-egui/src/menus.rs`, `crates/ui-egui/src/lib.rs`). **ALIASEDIT aliases now persist** in the user profile across restarts (desktop and web; CLI runs are session-only), a loaded `.pgp` now *replaces* the user alias set, and the Command Aliases dialog gained **Import...** with a `.pgp` picker (`crates/engine/src/cmd/file/pgp.rs`, `crates/ui-egui/src/aliasdlg.rs`, `crates/ui-egui/src/options.rs`). **Right-Click Customization** (Options ▸ User Preferences) sets the hold time (100–2000 ms, default 250) and Default/Edit/Command modes (`menu`/`repeat`; `menu`/`enter`/`menuWithOptions`) (`crates/ui-egui/src/options.rs`, `crates/ui-egui/src/options/dialog.rs`, `crates/ui-egui/src/context_menu.rs`). **TEXTEDIT and a double-click on an existing MTEXT now open the in-place editor with its contents and formats** (#842), and **multileader text is editable** by double-click, TEXTEDIT and the Properties Contents field (#1081); relative `\H2x;` heights stay relative, and text too long for the editor (over 100,000 characters, 20,000 paragraphs or 1,000 kept codes) is refused and sent to the command line instead of being truncated (`crates/engine/src/mtext_edit.rs`, `crates/engine/src/cmd/modify2/textedit.rs`, `crates/ui-egui/src/mtext_editor.rs`, `crates/ui-egui/src/canvas/pick.rs`). The **Properties palette** shows a type's properties for several selected objects of that type and `*VARIES*` where values differ (`crates/ui-egui/src/palettes.rs`). **DWG saves now keep other applications' registered entities and objects as proxies of their own classes** (class numbers 500+, hard-owned null-owner objects kept, failures named in the read notes) (`crates/dwg/src/proxy_transport.rs`, `crates/dwg/src/lib.rs`, `crates/io/src/dxf_raw.rs`). The browser build installs the **`window.cadcraft` page API** (`request`, `execute`, `commands`, `docInspect`, `uiInspect`, `screenshot`) over the control channel (`apps/cadcraft-web/src/api.rs`, `apps/cadcraft-web/src/main.rs`). The **MCP bridge sends the control token only to the exact peer `127.0.0.1:PORT`** and refuses token files that are symlinks, non-plain or readable by other users, with no shared-temp-dir fallback; the web `ui.screenshot` returns an inline PNG (`crates/mcp/src/backend.rs`, `crates/mcp/src/control_token.rs`, `crates/ui-egui/src/control.rs`). **macOS file dialogs are sheets** shown without a modal loop, one at a time, with the answer applied to the drawing that asked (`apps/cadcraft/src/sheet.rs`, `apps/cadcraft/src/main.rs`, `crates/ui-egui/src/lib.rs`). **Flatpak update checks and self-updates** gained `--talk-name=org.freedesktop.Flatpak` in both manifests, guarded by a test (`packaging/linux/flatpak/ai.storyteller.cadcraft.yml`, `packaging/linux/flatpak/ai.storyteller.cadcraft.bundle.yml`, `crates/ui-egui/tests/flatpak_updates.rs`). The rest is hardening and performance (allocation-free NURBS derivatives, banded spline solves, region pair budgets, MTEXT/LISP/render caps). v0.20.1 itself is the Flatpak patch; the other changes arrived between the tags. **v0.17.0 → v0.18.0 (earlier).** XCLIP/XCLIPFRAME; raster IMAGEATTACH/IMAGE (PNG/JPEG/BMP/TIFF); SHX shape/big/unifont fonts; DVIEW view twist; MINSERT; `cadcraft-cli roundtrip` and `cargo xtask corpus`; DWG read/write in a child process on acadrust 0.6.6; autosave locks/failure/recovery and a UI panic guard; Find and Replace (Cmd+F) and Edit Text windows; PLOT format from the path extension; Georgian; and web page-host mode. Older history (v0.16.0 → v0.17.0 and earlier) is folded into `CHANGES.md`. **Verify against your installed version** — the ArtCraft Launcher auto-updates, so a newer build may differ; every count quoted here was re-measured at this tag, and code paths that moved were re-cited. The measurement method for each count is in `evidence.md`. There is no `references/` directory: all detail is here with repo-relative evidence paths. ## Overview CADCraft is an open-source (MIT OR Apache-2.0) 2D CAD and drafting application written in Rust (egui/eframe 0.37, wgpu) for macOS, Windows, Linux, FreeBSD and the web (WebAssembly); source is GitHub `storytold/cadcraft`. It is a clean-room reimplementation of Autodesk AutoCAD targeting AutoCAD 2027, 2D drafting first (`AGENTS.md` clean-room rules, `docs/target-app-parity.md`). Stage: **pre-alpha** — `ROADMAP.md` (last updated 2026-10-24) still lists four of AutoCAD's five core workflows failing the alpha gate (precise drafting, blocks/xrefs, layouts/plotting, and lossless DWG exchange); dimensioning passes. The roadmap is direction, not a per-release status, so do not quote its row text as current. The differentiator: every user-visible action is a command. The engine registry holds **457 commands** at this tag (unchanged at v0.20.1) — 439 unique literal `CommandSpec::new("")` ids plus the 18 ids the `gc!`/`dc!` constraint macros expand to, with no duplicate ids; the same derivation read 457 at v0.18.0 (and 451 at v0.17.0 in the previous audit). The desktop app's catalog adds **60** UI-only entries (`crates/ui-egui/src/menus.rs`), so the app-level catalog is 517. Re-derive before quoting: `cadcraft-cli commands | jq length` (the app bundle does not install the CLI). The repo's generated checklist (`docs/parity-checklist.md`, dated 2026-11-01 and **not regenerated for v0.20.1**) still says **449 registered commands** and menu breadth 298/491. Treat that as a pre-release snapshot, not this tag: it is eight ids short of 457. Do not "correct" one number to the other — the two `gc!`/`dc!` macro bodies carry no literal id, the 18 invocations expand to ids a literal scan cannot see, and the published checklist counts a *built* registry from the day it ran. ## Capabilities (verified) Everything below is implemented and wired to a command/CLI/MCP/control surface unless marked **partial** or **claimed**; `evidence.md` gives the per-claim tier. ### Drawing, editing and precision - **Draw:** LINE, PLINE (arcs, widths), CIRCLE (center/radius/diameter, 2P, 3P), ARC, RECTANG (fillet/chamfer), POLYGON, ELLIPSE (+arcs), SPLINE, POINT, XLINE, RAY, DONUT, TEXT, MTEXT, plus MLINE, REGION and HELIX (`crates/engine/src/cmd/draw.rs`, `crates/engine/src/cmd/draw2.rs`). - **Modify:** ERASE, MOVE, COPY, ROTATE, SCALE, MIRROR, STRETCH, OFFSET, TRIM, EXTEND, FILLET, CHAMFER, BREAK, JOIN, EXPLODE, rectangular/polar ARRAY (associative, ARRAYEDIT; ARRAYPATH exists but is not associative), draw order, OVERKILL, LENGTHEN, ALIGN, REVERSE, FLATTEN, CHSPACE; Express Tools NCOPY, BREAKLINE, TXT2MTXT, BURST, MOCORO. **BREAK and TRIM keep the object's handle**; **EXPLODE of a reference with different X and Y scales gives ellipses, not circles**; **EXTEND runs a polyline's arc end segment round its circle** (`crates/engine/src/cmd/modify/trim.rs`, `crates/engine/src/cmd/modify/explode.rs`). - **Precision:** 14 object snaps (unchanged at v0.20.1) with deferred tangent/perpendicular (`crates/engine/src/snap.rs` — `ALL` has 14 entries: endpoint, midpoint, center, geometric center, node, quadrant, intersection, extension, insertion, perpendicular, tangent, nearest, apparent intersection, parallel); object snap tracking; polar tracking; ortho; grid snap; direct distance entry; `@dx,dy`, `@d"`** — the server starts with a fresh session token in an owner-only file, `cadcraft-control-.token`, in `$XDG_RUNTIME_DIR` (else `~/.cache`; `%LOCALAPPDATA%` on Windows), and logs its path at startup; the MCP bridge reads it automatically only when the connected peer is exactly `127.0.0.1:` (`crates/mcp/src/control_token.rs`, `crates/mcp/src/backend.rs`). The bridge (Unix) refuses a token file that is a symlink, not a plain file, or readable by other users; if neither a runtime dir nor `HOME` exists it refuses rather than using the shared temp dir. **27 top-level methods** in the app, **12** in headless mode (unchanged at v0.20.1): `cmdline.input/script/key/state`, `engine.execute` (alias `command`), `engine.commands`, `drawing.inspect`, `ui.inspect`, `ui.elements`, `ui.menu.list`/`invoke`, `ui.pointer`, `ui.click`, `ui.move`, `ui.drag`, `ui.key`, `ui.text`, `ui.set`, `ui.resize`, `ui.focus`, `ui.screenshot`, `ui.render` (with `window`, `background`, `plot_style`), `app.open`/`save`/`quit`, `control.methods`, `ping`. Limits: 16 connections, 64 queued requests, 256 MiB per line, 512 MiB buffered across connections, 60 s reply timeout (`state: not-run` = safe to resend, `may-have-run` = inspect first), 10 min idle, 30 s blocked-write timeout; a client that gives up cancels a request the app has not started (`apps/cadcraft/src/control_server.rs`, `crates/ui-egui/src/control.rs`). - **CLI `cadcraft-cli`** (separate zip; arguments parsed with clap following RFC-0012): **8 verbs** (unchanged at v0.20.1) — `info`, `convert`, `run`, `commands`, `mcp`, `perf`, `sample`, `roundtrip` — plus `--version`/`--help`. | Command | What it does | |---|---| | `info FILE` | Print `drawing.inspect` JSON (add `--compact` for one line). | | `convert IN OUT` | Conversion or image export; OUT's extension picks the format (dxf, dwg, dwt, svg, png, pdf); PNG 2400×1600; model space only; `--window x0,y0,x1,y1` or `--view extents\|current`; `--in-place` allows replacing an input. | | `run [FILE…] [--sample] [--metric] [--script TEXT] [--script-file F.scr] [--cmd 'id {json}']… [--save OUT] [--export OUT]` | Headless edit session over one or more drawings (the last is current); staged writes; framing flags need an image export. | | `commands [FILTER]` | JSON command catalog (`--compact` for one line). | | `mcp [--connect HOST:PORT [--lazy] [--launch]]` | MCP server on stdio. | | `perf [N \| FILE]` | Timing table (synthetic N entities, or a drawing). | | `sample (bracket\|floorplan) OUT` | Built-in sample drawing in any writable format. | | `roundtrip [FILE\|FOLDER] [--out DIR] [--keep-saved] [--same-format] [--no-census] [--tolerance T]` | Open → save → reopen and diff; writes a Markdown and a JSON report; FOLDER defaults to `CADCRAFT_CORPUS_DIR`; `CADCRAFT_CORPUS_STRICT=1` makes any open/save/reopen failure or lost record fail the run. | `--cmd` chaining: `"{last}"` becomes the last object handle an earlier `--cmd` returned. - **Browser page API (web build only).** `window.cadcraft` is installed by `apps/cadcraft-web/src/api.rs` over the app's control channel: `request(method, params)`, `execute(command, params)`, `commands()`, `docInspect(params)`, `uiInspect(params)` and `screenshot(params)`, each a promise that resolves with the control method's `result` or rejects with an `Error` carrying `error`; an existing `window.cadcraft` keeps its own functions. A page call that times out drops its pending reply, which cancels a request the app has not started (`apps/cadcraft-web/src/api.rs`, `apps/cadcraft-web/Cargo.toml`). The page API is web-only; the desktop build uses the control channel instead. - **Scripting and import automation:** `.scr` via SCRIPT or `run --script-file`; AutoLISP via `lisp` / `appload`; `.pgp` via `aliasedit`/`reinit`; `.lin`/`.pat` loading; `document.bytes {format, version, binary, portableFonts?}` returns base64 without touching a file. - **Read-back commands for agents:** `drawing.inspect` (+`skipped{count,sections}`, `readNotes`), `entities`, `texts`, `shapes` (with `selfCheck`), `usage`, `loops`, `countlist`/`counttable`/`count`, `properties`, `list`, `dist`, `id`, `area`, and `image` for attached rasters. ### Platform notes - Native macOS universal app (signed, notarized DMG; CLI in a separate signed zip, `cadcraft-cli--macos-universal.zip` by default — `packaging/macos/package.sh`), Windows x64/arm64/x86 MSI (`Scope="perUserOrMachine"` in `packaging/windows/cadcraft.wxs`; a fresh install from the 2026-11 launcher is machine-wide, an existing per-user install stays under the user profile), Linux x86_64/aarch64/riscv64 (AppImage, deb, rpm, tar and Flatpak; both Flatpak manifests now allow `org.freedesktop.Flatpak` for update checks), FreeBSD tar (x86_64; the aarch64 build has no DWG bridge, `crates/dwg/build.rs`). **macOS file dialogs are sheets** shown without blocking the window (the #1527 crash), one at a time, and the answer lands on the drawing that asked (`apps/cadcraft/src/sheet.rs`). - WebAssembly build runs the same UI (`?webgl`, `?cpu`, `?sample`) and a **page-host mode** (`?host=parent` in an iframe, or `data-host="page"` on the canvas) where the host page opens drawings and receives saves as `postMessage`/`DOM CustomEvent`s instead of downloads (`apps/cadcraft-web/src/host.rs`). **No DWG**, no autosave, saves are browser downloads without a host. The web build also exposes `window.cadcraft` (above), and `ui.screenshot` returns an inline PNG because there is no file system. - **19 interface languages** (`LANGUAGES` in `crates/ui-egui/src/i18n.rs`: English plus 18 translations; Georgian joined at v0.18.0 and the set is unchanged at v0.20.1); live switching via `ui.language` and `CADCRAFT_LOCALE`. `docs/localization.md` now lists all 19, including Vietnamese. CJK/Arabic/Hangul need an installed matching font; Georgian needs the craft-fonts Noto Sans Georgian face. - Accessibility: system-cursor restore, animation-effects setting; in-place text editing accepts IME composition and commit. - 3Dconnexion SpaceMouse support is compiled for Windows/Linux only (`hidapi` target dependencies in `apps/cadcraft/Cargo.toml`); `docs/gaps.md` claims 2D pan/zoom through raw HID there, with no 3D navigation and no macOS/web support — claimed, not verified here. ## Known limitations and not-implemented Read `docs/gaps.md` before promising anything; it is the maintained list and it is newer than `ROADMAP.md`. The checklist's menu breadth (**298/491, 61 %**) is the 2026-11-01 snapshot and was not regenerated. The high-impact limits for an agent: - **Saving DWG is still lossy.** The new proxy path keeps other applications' registered entities/objects and hard-owned null-owner objects, but DWG still drops xdata on table records and blocks, entity colour books and reactors, and records whose class is missing/ambiguous or that cannot be split (named in the read notes). Always check `readNotes` after opening and the `notSaved` report on every DWG save. The DWG worker process has no memory limit of its own, so a crafted file can use a lot of memory before that one open or save dies (`SECURITY.md` known limits). - **No shipped real-file corpus and no AutoCAD sign-off.** `cadcraft-cli roundtrip` and `cargo xtask corpus` exist, but the corpus lives in a separate repo; `docs/gaps.md` still lists a black-box AutoCAD check as a gap, and its own note says all 88 in-repo file tests use synthetic data. Do not tell a user their CADCraft file is AutoCAD-clean. - **No 3D at all.** No UCS, 3D views, orbit, solids, surfaces, meshes, sections, visual styles, materials, lights or rendering. `3DORBIT` and `SHARE` are registered only to refuse, and ATTACH refuses PDF/DWF/DGN underlays while attaching PNG/JPEG/BMP/TIFF; DVIEW's 3D options (CAmera, TArget, Distance, POints, CLip, Hide) print "not available yet" — TWist, PAn, Zoom, Off and Undo work on 2D views. README's tagline says "2D and 3D"; the 3D half is not implemented. - **Curve geometry is tessellated.** Ellipse/spline intersections, offsets, trims, closest points and snaps are approximations; polyline offsets recompute arc bulges but have no loop cleanup; tolerances are absolute. - **Xrefs cannot be edited in place** (REFEDIT edits block references only) and there is no dynamic-block authoring (parameters/actions). XCLIP exists, so do not repeat the old "no XCLIP" claim. - **SHX text is only as good as the font files present.** No bundled SHX font; without the file the style falls back to `FONTALT`/the stroke font and widths differ. No Options entry for the search path or font map, no desktop drag-and-drop of `.shx`, the big-font code page is guessed from the file name, vertical text is not justified along its column, and extended big-font box scaling is unverified against real files (`docs/gaps.md` FF8). - **Raster images are display-and-PNG only.** No PDF/SVG image output, no prompts/dialog/menu row, no `-IMAGE` options (detach, reload, unload, path), no IMAGECLIP, IMAGEADJUST or IMAGEFRAME, brightness/contrast not applied, images lie under all other objects on screen whatever their draw order, size is not taken from the file's resolution, and pixels are never stored in the drawing — move the drawing without its image files and the pictures are gone. No PDF import/underlays, no DWF/DGN/WMF/EPS/ACIS/STL exchange, no DWS standards, no system printers. - **Binary plot files are unread.** `.ctb`/`.stb`/`.pc3`/`.pmp` must be recreated in CADCraft's JSON formats. - **MTEXT editing has limits.** The in-place editor opens an existing MTEXT with its formatting and keeps relative heights, but refuses text past 100,000 characters, 20,000 paragraphs or 1,000 kept codes and falls back to the command line; there are no fields, no spell check, and stacked fractions show as placeholders. The shortcut menu's Edit Text window still edits plain text (codes visible), not formatting. - **No autosave in the web build.** Desktop autosave writes DXF `.sv$` files, holds a lock per settings folder, shows a failure notice and offers recovery at the next start; a UI panic autosaves and writes a crash report. The web build has none of this, and a panic aborts there. - **SETVAR covers ~150 of ~1,000 variables**; no Sheet Set Manager, eTransmit, Traces, Markup Import, CUI(x) or workspaces. - **`find`/`textedit`/`xclip`/`imageattach` are engine-level.** The first three have UI entries (Cmd+F window, shortcut-menu Edit Text, Modify ▸ Clip ▸ Xref); IMAGEATTACH is JSON only (ATTACH takes the same JSON for an image path) — there is no attach dialog or menu row. - **macOS Finder file association for `.dxf` is broken (#158)**; open positionally or via File > Open. - **No plug-in API.** ObjectARX/.NET plug-ins cannot load. What an agent can extend today is AutoLISP, `.scr` scripts, `.pgp` aliases, `.lin` linetypes and `.pat` patterns. - **Web PLOT may show raw PDF bytes (#134)**; Windows/Linux get little runtime testing. - **Docs that lag the code (code wins):** `README.md` still says SHX fonts "aren't read yet" and advertises "2D and 3D"; `docs/parity-checklist.md` still says 449 commands; `docs/file-format-parity.md` still calls proxy/custom objects "not measured" and lists several unmodelled kinds as dropped by DWG save, although `crates/dwg/src/proxy_transport.rs` preserves registered proxies; the CLI's `--view current` help still says "extents plus a 10% margin" although `crates/engine/src/session/files.rs` opens on the saved view. The old `docs/localization.md` omission of Vietnamese is fixed. - **Claimed but unverified here (static reading only):** README's interactive-feel claims (AutoComplete, right-click repeat), associative-dimension behaviour, MTEXT bidi/OpenType shaping for Arabic-script text, per-language font availability, SpaceMouse behaviour on Windows/Linux, the browser page API under a real page, proxy preservation on a real third-party DWG, and Flatpak self-update in an installed Flatpak. ## How to operate **Launch (macOS).** The GUI binary is the installed CADCraft.app's `Contents/MacOS/CADCraft`; launch with `open -a "CADCraft"`. Start flags (verified with `--help`): `--control ` (also read from `CADCRAFT_CONTROL_PORT`), `--sample`, `--version`/`-V`/`-h`, and positional drawing paths; an unknown flag is a usage error (exit 2); `--dwg-worker` is internal (a copy of the binary started to read or write one DWG — never call it yourself). CADCraft's own MCP `--launch` runs `open -a CADCraft --args --control PORT`. **The bundle contains no CLI binary** — `Contents/MacOS/` holds only `CADCraft`, so install `cadcraft-cli` from the CLI zip. CADCraft does not have to be running for `cadcraft-cli` or headless MCP. Environment variables that matter: `CADCRAFT_CONTROL_PORT`, `CADCRAFT_CONFIG_DIR` (empty means no settings folder), `CADCRAFT_LOCALE`, `CADCRAFT_SYSTEM_CURSOR=1`, `CADCRAFT_FONTALT`/`CADCRAFT_FONTFALLBACK`, `CADCRAFT_SHXPATH` (SHX search path), `CADCRAFT_MAX_DXF_TAGS` (raise the DXF group-code limit), `CADCRAFT_VSYNC`, `CADCRAFT_NO_NATIVE_MENU`, `CADCRAFT_WAYLAND=1`, `WGPU_BACKEND`, `RUST_LOG`. CLI-only: `CADCRAFT_CORPUS_DIR` and `CADCRAFT_CORPUS_STRICT=1` for `roundtrip`. **Settings/state (macOS).** `~/Library/Application Support/CADCraft/` holds `logs/cadcraft.log` (rotated, 16 MiB cap), `autosave/` (`.sv$` DXF copies plus a per-instance `.lock`), `support/` (AutoLISP startup files), `crash-reports/`, and `workspace.json` (panels, command line). The user profile — profile variables, **ALIASEDIT aliases and the alias file**, right-click settings, colours and interface scale — is the `cadcraft.profile` entry; the interface prefs, including **keyboard shortcuts under `shortcuts`**, are `cadcraft.prefs`. The control token file lives outside it (see the control-channel bullet). **Document model.** One window, many drawings: each open drawing is a document with its own file tab and model/paper spaces; `document.switch {index}` switches, `close {index}`/`closeall` close them. Tool Sets, Layers, Properties and External References dock and float; QuickCalc opens as a floating palette (Cmd+8); layout tabs stay stable when Tool Sets toggle. **Keyboard shortcuts (from source — do not invent others).** Engine `.key()` values and the built-in table (`crates/ui-egui/src/menus.rs` `builtin_shortcuts`): Cmd+N new, Cmd+O open, Cmd+S save, Cmd+Shift+S save as, Cmd+W close, Cmd+P plot, Cmd+Z/Cmd+Shift+Z undo/redo, Cmd+Y redo, Cmd+C/V/X clipboard, Cmd+Shift+C copy with base point, Cmd+Shift+V paste as block, Cmd+A select all, Cmd+Shift+A PICKSTYLE, Delete clear selection, F3 osnap, F5 (or Cmd+E) isoplane, F7 grid, F8 ortho, F9 snap, F10 polar, F11 object snap tracking, F12 dynamic input. UI-only: Cmd+1 Properties, Cmd+3 Tool Sets, Cmd+8 QuickCalc, Cmd+9 command line, Cmd+F Find and Replace, F1 command reference, F2 command history, Cmd+Q quit. **Tools ▸ Customize ▸ Keyboard Shortcuts...** edits the map: any command can take one, a user shortcut wins over the built-in one, conflicts are reassigned and reported, the clipboard keys/Delete/Cmd+Q are fixed, and the JSON form is `engine.execute {"command":"ui.shortcuts","params":{"set":{"line":"Cmd+L"}}}` (in the running app, desktop or web; not a headless session; `reset` clears the user map). **Right-click.** While a command runs, a quick right-click is Enter and holding it (default 250 ms) opens the shortcut menu; Options ▸ User Preferences ▸ **Right-Click Customization** sets the hold time (100–2000 ms) and the Default/Edit/Command modes. Profile keys: `rightClickDuration`, `rightClickDefault`, `rightClickEdit`, `rightClickCommand` (values `menu`, `repeat`, `enter`, `menuWithOptions`). **Open/save/export flow.** The Open dialog filters DWG/DXF/DWT and SVG/SVGZ; the Save dialog offers DXF, DWG, DWT, SVG, PNG, PDF. On macOS these dialogs are **sheets**: the answer arrives in a later frame, one dialog at a time (a second request is refused), and it applies to the drawing that asked (or is refused with a status message if that drawing was closed). QSAVE/SAVE writes the drawing's own format/version; SAVEAS `{path, version?, binary?, portableFonts?}` (`portableFonts` writes a Windows font for Linux families that have one and reports the styles still missing on Windows in `nonPortableFonts`); the macOS save panel cannot pick a version per file. `document.bytes {format, version, binary, portableFonts?}` returns base64 without touching a file. EXPORT writes dxf|dwg|svg|png|pdf; **PLOT takes the format from the path extension** and refuses an unknown one, and PNG/SVG hold a single sheet; EXPORTPDF always writes PDF; PUBLISH one PDF per sheet; PDFBOOK builds ISO A-series books from frame polylines. In the web build, saves are downloads unless a host page is attached. **Headless CLI (what an agent will use most).** ```sh cadcraft-cli info drawing.dxf # JSON summary: counts, extents, layers, styles, skipped, readNotes… cadcraft-cli convert drawing.dxf out.svg # dxf|dwg|dwt|svg|png|pdf; PNG is 2400×1600 cadcraft-cli convert drawing.dwg detail.png --window 0,0,20000,15000 # frame a rectangle cadcraft-cli run --sample --script 'CIRCLE 22,3 1\n' --save out.dxf --export out.png cadcraft-cli run drawing.dxf --script-file setup.scr --save out.dxf cadcraft-cli run drawing.dxf --cmd 'circle {"center":[10,10],"radius":4}' --cmd 'zoom {"mode":"extents"}' --export sel.png cadcraft-cli run drawing.dxf --cmd 'imageattach {"path":"site.png","at":[0,0],"width":120}' cadcraft-cli run drawing.dxf --cmd 'xclip {"handle":"2A","option":"new","rectangle":[[0,0],[100,80]]}' cadcraft-cli commands dim # command catalog (JSON), filtered cadcraft-cli sample floorplan out.dxf # built-in sample drawings cadcraft-cli roundtrip drawings/ --out reports/ # open → save → reopen loss report cadcraft-cli roundtrip drawings/ --same-format --keep-saved --tolerance 1e-6 cadcraft-cli mcp --connect 127.0.0.1:7979 # bridge MCP to the running app ``` Framing rules: `convert` fits model-space extents; `run --export` uses the current view only if a command changed it; `--window x0,y0,x1,y1` shows exactly that rectangle. `--view current` follows the session view, and an opened drawing's view is the one stored in the file (when it has a usable `$VIEWCTR`/`$VIEWSIZE`), not the extents — the CLI's own help text still says "extents plus a 10% margin", which is stale. CLI PNG/SVG/PDF always render **model space**. The CLI installs the same raster decoder as the app, so IMAGEATTACH works headlessly. **Browser page API (web build).** ```js await window.cadcraft.execute("circle", {center: [0, 0], radius: 5}); const catalog = await window.cadcraft.commands(); const drawing = await window.cadcraft.docInspect({}); const png = await window.cadcraft.screenshot({}); // inline pngBase64 on the web await window.cadcraft.request("engine.execute", {command: "zoom", params: {mode: "extents"}}); ``` Each call is a promise; a rejection carries the control channel's `error`. `docInspect` maps to `document.inspect`, `uiInspect` to `ui.inspect`, `screenshot` to `ui.screenshot`. The page API reaches the same app control methods as the desktop control channel, but only from the web page that hosts the drawing. **Command-first workflow.** Anything the UI can do is a command: `engine.execute {command, params}` runs the JSON form with no dialogs; typing (`cmdline.input`) drives the interactive prompt machines exactly like a user. A refused command-line line still replies `ok: true` — check the `error` field. Errors inside a command never take the app down (panic guard); a panic in the interface itself autosaves every unsaved drawing and reports it. UI commands exist only in the app catalog; headless returns "unknown command" for them. ## Working with an AI agent Legitimate and reliable: - **Prefer the headless surfaces**: `cadcraft-cli` for one-shot work and verification, MCP (headless or bridged) for interactive sessions, the control channel when a human is watching the same window, and `window.cadcraft` only in the browser build. Do not drive the GUI blindly; `ui.screenshot` needs a presented frame. - **Talk to the control port correctly.** Read `cadcraft-control-.token` (`$XDG_RUNTIME_DIR`, else `~/.cache`; `%LOCALAPPDATA%` on Windows) and send `"token"` in every request line, or use the MCP bridge which does it for you. Pass the bridge `127.0.0.1:PORT`, not `localhost:PORT`: the bridge now sends the token only when the connected peer is exactly `127.0.0.1:`, because a `localhost` alias may resolve to `::1` where another local account could listen. Never assume a local connection is authorized, and do not fight the token-file checks (symlinks and group/world-readable files are refused by design). - **Measure what a save loses before you promise a round trip.** `cadcraft-cli roundtrip FOLDER` is the strongest tool: it opens, saves as DXF and DWG, reopens and lists every lost/added/changed entity, table record, header variable and opaque record, with `--same-format` for a single format and `--keep-saved` to inspect the files. Compare the report before and after your edits. For a DWG, also read `readNotes`/`warnings`: proxy-conversion failures are named there, not silently dropped. - **Author drawings programmatically**: `engine.execute` per entity, or a `.scr` script / `cadcraft-cli run --script-file`, is far more reliable than pointer simulation. Read back with `drawing.inspect`/`entities`, `texts`, `image`, `shapes`, `usage` before purging, `loops`, and eyeball with `render` (with `background`/`plot_style`, so the PNG can look like the plot). - **Prepare/convert inputs**: `convert` turns DXF/DWG/SVG to DXF/DWG/DWT/SVG/PNG/PDF; SVG imports as paths/groups in millimetres, page top-left at the origin, Y up. Check `info`'s JSON before assuming contents. - **Edit text deliberately**: TEXTEDIT `{handle, text}` works on TEXT, MTEXT, attribute definitions, dimension text and multileader text (a block-content multileader has none); a locked layer is refused. In the desktop app, TEXTEDIT/double-click on MTEXT opens the formatted in-place editor; text past the editor's caps (100,000 chars, 20,000 paragraphs, 1,000 codes) is refused there and falls back to the command line, so long text is not lost. An empty answer in the in-place editor keeps the existing text (the JSON form with an empty `text` writes an empty text). - **Set aliases and shortcuts knowingly.** `aliasedit {"file": "..."}` **replaces** the user alias set (built-ins stay); use `set`/`remove`/`clear` for incremental changes, and `reinit` to re-read the last file. Aliases persist in the user profile on desktop/web but not in a headless run. `ui.shortcuts {"set": {...}}` is app-only (desktop or web, not headless) and stored with the preferences; a command that loses a key is returned in `replaced`. - **Attach images deliberately**: IMAGEATTACH stores a path in the drawing and caches pixels in memory, so the image file must travel with the DXF; a relative path is relative to the drawing's folder. PNG output shows the picture, PDF/SVG do not. - **Keep fonts with the drawing**: SHX text metrics depend on the named `.shx` being beside the drawing or on `CADCRAFT_SHXPATH`; without it the text falls back and widths/extents change. - **Interpret and repair project files**: DXF is a documented text format; CADCraft-specific data travels under the `CADCRAFT` xdata app name and `CADCRAFT_*` dictionary entries. For damaged drawings use AUDIT/RECOVER; crash autosaves are `.sv$` DXF files listed by DRAWINGRECOVERY, and a left-behind `.sv$` plus its `.lock` file is the recovery candidate after a crash. - **Verify exports before reporting success**: re-open the saved file, compare entity counts/extents/layers, check `open`'s `warnings`, `drawing.inspect.skipped.count`, `readNotes`, and the `notSaved` report (CLI prints it on stderr for `.dwg`/`.dwt`). Render to PNG and look at it. CLI writes are staged, so a failed write keeps the previous drawing. - **Report commands with their exact ids** from `engine.commands`/`cadcraft-cli commands`; ids are AutoCAD command names lower-cased. The app catalog's `ui.*` entries are not engine commands. - **Counts to expect at v0.20.1**: 457 engine commands (439 literal ids + 18 `gc!`/`dc!` macro ids; unchanged); 60 UI-only commands (+`ui.shortcuts`; app catalog 517); 15 MCP tools (12 headless + 3 app-only, unchanged at v0.20.1); 27 control methods app / 12 headless (unchanged at v0.20.1); 8 CLI verbs (unchanged at v0.20.1); 19 interface languages (unchanged at v0.20.1); 23 built-in hatch patterns (unchanged at v0.20.1); 14 object snaps (unchanged at v0.20.1); 4 drawing formats read / 6 written plus 4 raster image formats (unchanged at v0.20.1). Re-derive with `cadcraft-cli commands | jq length` rather than trusting any number, including these. What an agent must NOT do: - Assume DWG saves round-trip losslessly, or that AutoCAD will open CADCraft output cleanly — the proxy path is new and no real-file AutoCAD check exists. Keep an untouched copy of every received file; prefer DXF when the user's tooling allows it, and always read `readNotes`/`notSaved`. - Assume 3D/UCS, PDF underlays, dynamic-block authoring, xref in-place editing, Visual LISP/DCL/reactors, fields, spell check, sheet sets, eTransmit, Traces or CUI exist. Check `docs/gaps.md` first. - Assume an attached raster image is inside the drawing, or that SHX text will look the same without its font file. - Invent shortcuts, menu paths, flags or format names: only what is in `CommandSpec`, `UI_COMMANDS` and the CLI usage string exists. IMAGEATTACH has no dialog or menu row; it is a JSON command. A user shortcut is a user setting, not an app default. - Edit `.dwg` bytes or expect a CADCraft-proprietary project format — there is none; the drawing *is* the DXF/DWG. - Send UI-only commands (including `ui.shortcuts`) to a headless MCP/CLI session, or rely on `screenshot` without a presented frame. In the browser, `screenshot` is inline only; do not expect a file path. - Call `app.quit` before saving: it quits without the unsaved-changes prompt. - Assume a macOS file dialog has answered when the command returns; dialogs are sheets now. Use the JSON path forms (`open`, `save`, `convert`, `run`) when an agent needs a definite result. - Trust it for production/concurrent work: pre-alpha, synthetic-only file tests in-repo, and open correctness gaps. ## Verification protocol 1. Work throwaway-first: `cadcraft-cli sample bracket scratch/t.dxf` (or `run --metric`), draw, save to a scratch path, re-open, inspect, delete. Never test on the only copy of a real drawing. 2. After every save, assert on the result: the `notSaved` field / the stderr warning must be absent. After reading, `drawing.inspect.skipped.count` must be 0 for DXF, `open`'s `warnings` must be empty for DWG/SVG, and `readNotes` must not name a proxy-conversion failure unless you accept that loss. A silent export is not a verified export. 3. Round-trip discipline: new → edit → save → close → reopen → compare counts/extents/layers; then export to PNG/SVG/PDF and look at it. For a folder of real files, run `cadcraft-cli roundtrip FOLDER` and read the report before and after your work. When the user has AutoCAD or another viewer, open the file there too — a systematic AutoCAD check is still outstanding (`docs/gaps.md`). 4. For the web build, verify the page API in the page console: `await window.cadcraft.commands()` returns the catalog, `await window.cadcraft.docInspect({})` returns the drawing summary, and `await window.cadcraft.screenshot({})` resolves with `pngBase64`; a rejected promise carries the control error. Remember the web build has no DWG and no autosave. 5. Version and back up: keep each session's output under a new name or in version control; the desktop app has SAVETIME autosave, Drawing Recovery, AUDIT and RECOVER, but the web build has none and DWG saves can still drop unmodelled content. If autosave shows a failure notice, treat unsaved work as unprotected until you save. 6. Update CADCraft only between projects (launcher auto-updates), and re-check this skill's claims when the version moves — this skill describes v0.20.1. ## Sources & evidence - Repo: https://github.com/storytold/cadcraft (clean-room, MIT OR Apache-2.0). - Inspected at tag `v0.20.1`, commit `7526dc62c14e71b3c8d46e73bbf1fa29ef506af1` ("Merge tested main for Flatpak update patch release", 2026-11-11), on 2026-11-12; the v0.18.0 ref (`32238e83c2c8bf643994132883e94bc96961f649`) was used for the delta and the count cross-checks. The installed GUI bundle `/Applications/CADCraft.app` is version 0.20.1, bundle id `ai.storyteller.cadcraft`, and its binary printed `cadcraft 0.20.1 (7526dc62c14e71b3c8d46e73bbf1fa29ef506af1)`; its `--help` output is the start-flag list in How to operate. `Contents/MacOS/` holds no CLI, and no `cadcraft-cli` is installed on this machine, so every count was derived from source. The launcher auto-updates, so **verify against your installed version**. - Key files read: `README.md`, `ROADMAP.md`, `SECURITY.md`, `Cargo.toml`, `docs/{gaps,parity-checklist,target-app-parity,file-format-parity,control-protocol,mcp,cli,customization,localization,plotters,ui-parity}.md`; `apps/cadcraft/src/{main.rs,control_server.rs,env.rs,workspace.rs,sheet.rs}`, `apps/cadcraft-cli/src/{args.rs,lib.rs,roundtrip.rs}`, `apps/cadcraft-web/src/{main.rs,host.rs,api.rs}`; `crates/engine/src/cmd.rs` and `crates/engine/src/cmd/{blocks.rs,blocks/xclip.rs,image.rs,plotters.rs,utility.rs,props.rs,layout.rs,settings.rs,modify/trim.rs,modify/explode.rs,modify2/textedit.rs,view/dview.rs,draw.rs,draw2.rs,file/pgp.rs}`, `crates/engine/src/{snap.rs,pointmod.rs,autosave.rs,render_look.rs,lisp.rs,settings_dir.rs,mtext_edit.rs}`; `crates/io/src/{lib.rs,raster.rs,roundtrip.rs,dxf_clip.rs,dxf_raw.rs,pdf.rs}`, `crates/dwg/src/{lib.rs,worker.rs,proxy_transport.rs}`, `crates/dxf/src/lib.rs`, `crates/doc/src/{format.rs,library.rs,entity/layout.rs,xclip.rs,raster.rs}`, `crates/fonts/src/{shx/mod.rs,shx/table.rs,bidi.rs,mtext.rs}`, `crates/render/src/{raster.rs,linetype_text.rs}`, `crates/mcp/src/{tools.rs,server.rs,backend.rs,control_token.rs}`, `crates/ui-egui/src/{menus.rs,control.rs,i18n.rs,i18n/ka.tsv,finddlg.rs,textdlg.rs,fault.rs,autosave.rs,canvas/images.rs,keys.rs,aliasdlg.rs,options.rs,options/dialog.rs,context_menu.rs,mtext_editor.rs,palettes.rs}`, `xtask/src/{main.rs,parity.rs}`, `packaging/macos/package.sh`, `packaging/windows/cadcraft.wxs`, `packaging/linux/flatpak/ai.storyteller.cadcraft.yml`, `packaging/linux/flatpak/ai.storyteller.cadcraft.bundle.yml`; tests `crates/engine/tests/{panic_hunt.rs,it/mleader_text_edit.rs}`, `crates/io/src/tests.rs`, `crates/dxf/tests/hardening.rs`, `crates/io/tests/{registered_proxy.rs,hard_owned_objects_kept.rs}`, `crates/ui-egui/tests/{alias_persistence.rs,it/options_right_click.rs,it/shortcuts_checked.rs,flatpak_updates.rs}`. - Shared libraries consulted: all `storytold/craft-libs` crates pinned at `92d392cff132eaf53e13afff77f38b5c11b73aa0` (chiefly `craft-docpath`, `craft-pdf`), plus `craft-web-api`/`craft-web-host` at `fd5e2feff6ea25bed371a99cc732b3968d621505` and `craft-update` at `6e03f65bf45181db77ba6229716e6624db9eb25b` (`apps/cadcraft-web/Cargo.toml`, `Cargo.toml`); the DWG bridge is `acadrust` 0.6.6 (MPL-2.0, unmodified). Consulted read-only at those pins, not vendored. - Read-only inspection: no build, no GUI launch, no drawing modified, no test run. The app binary was only run with `--version` and `--help`. Cross-check `evidence.md` for claim-by-claim tiering.