solidcraft-commands
Installation
SKILL.md
Adding a command
User-visible behaviour is a command. The toolbar, dialogs, sketch tools, palette, scripts, CLI, control channel and MCP all reach the same commands through Session::execute(id, params). The long form is docs/book/src/dev/commands.md.
Steps
- Add a
CommandSpecto the right file incrates/engine/src/cmd/and implementrun(fn(&mut Session, &Value) -> Result<Value>). Fields: id, label, toolbar tab and panel (.at), icon (.icon), shortcut (.key), params doc (.params),enabled(its error string is the disabled-button tooltip). - The id is our own: dotted, lower-case
<area>.<thing>[.<variant>], such assolid.extrudeorsketch.rectangle.two_point. Never another product's id. - Validate inputs first (units, ranges, references) and return
BadParamsrather than building a broken feature. Parameters are hostile: seeskills/solidcraft-crash-safety/SKILL.md. - Give it input and output schemas: a contract and a reply type in
crates/engine/src/schema/, registered withchecked!,.contractand.output. A command should have them and a test warns without them; this will become required.schema/unconverted.txtonly shrinks. How:docs/book/src/dev/schemas.md. - Engine tests measure the result: volume, area, face/edge/vertex counts against values you can derive by hand. Where they go:
skills/solidcraft-tests/SKILL.md. - Add the label as
cmd.<command id>in a pending locale file (cargo xtask i18n --add-missinglists what is missing); a test fails without it. Seeskills/solidcraft-ui-text/SKILL.md. - A command the ribbon shows also needs help:
help.<command id>(what it does, then when to use it) in the pending file, and its id inDOCUMENTEDincrates/ui-egui/src/command_help.rs. A test fails without them. - Run
cargo xtask featuresto see the generateddocs/features.mdchange, but do not commit it:mainregenerates it after each merge. - If the command saves something new in a design, add a format file:
skills/solidcraft-file-formats/SKILL.md. - If it needs a dialog or panel:
skills/solidcraft-ui/SKILL.md.
Programmatic calls never open dialogs
engine.execute runs the JSON form. Only toolbar clicks (ui.start) start interactive tools and dialogs, which then run commands. A dialog is a front-end form that builds the parameters.