Files
OrcaSlicer/tools/mcp/tests/cad_doc.json
T
SoftFever d64e10f4dd Regroup the slicer's MCP commands and let each run from its arguments
Outside the Design tab an agent had 175 commands, 50 of them in the tool
list. There are now 118, named by what they act on (`object_`, `plate_`,
`preset_`, `filament_`, `plugin_` and so on), and 115 are listed. Each takes
its target and values in the call, acts on the selection when it names no
target and says what it acted on; an old name is refused. Printers and
system filaments install and uninstall, preferences read and write, plugins
enable, reload, uninstall and refresh, and objects reorder, with no dialog
to drive.

The Speed Dial keeps its 129 tiles under the same ids. Eight defects in the
rows these commands share with the menus are fixed. For a person: an object
row that cannot run says why instead of "Select an object first.", rows
that failed no longer claim success, Duplicate Plate can be undone, and
Refresh Plugins picked while a refresh runs now runs after it instead of
beside it.
2026-11-18 16:50:32 +08:00

157 lines
14 KiB
JSON

// Reads and edits a Design-tab feature as its card does: a variable bound to an extrude, the
// binding and the variable removed, then literal edits through feature_edit, checked by volume, also
// under the names agents often give its params (index, params, values).
// Then hands the design off: Commit to Plate, a recommit that replaces the first object (one
// Prepare undo step), a STEP export read back into a new design, and two bodies committed both ways.
// Last, the Design history and the tree: undo / redo of an edit and of a rename (its own step),
// suppressing, moving and deleting features, naming, hiding and colouring bodies (a hidden body stays
// off the plate, a named one names its object), and a save and reopen that keeps the colour.
// Needs the CAD feature on:
// tools/mcp/orca_mcp.py launch --cad
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/cad_doc.json --out /tmp/out
{
"orca_replay_version": "0.2.0",
"name": "cad document",
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "window_set", "args": {"size": [1600, 900]}},
{"tool": "tool_call", "args": {"tool": "new_design"}, "expect": {"/result/ok": {"eq": true}, "/result/cleared/features": {"eq": 0}}},
{"tool": "tool_search", "args": {"tool": "feature_describe"}, "expect": {"/group": {"eq": "Design"}, "/read_only": {"eq": true}}},
{"tool": "tool_search", "args": {"tool": "feature_edit"}, "expect": {"/group": {"eq": "Design"}, "/read_only": {"eq": false}}},
{"tool": "tool_call", "args": {"tool": "extrude", "args": {"width": 20, "height": 20, "distance": 10}},
"expect": {"/result/ok": {"eq": true}, "/result/extrude_index": {"eq": 1}}},
{"tool": "tool_call", "args": {"tool": "set_variable", "args": {"name": "h", "expr": "12"}},
"expect": {"/result/ok": {"eq": true}}},
{"tool": "tool_call", "args": {"tool": "feature_set_expression", "args": {"feature": 1, "field": "distance", "expr": "h"}},
"expect": {"/result/ok": {"eq": true}}},
{"tool": "tool_call", "args": {"tool": "describe_design"},
"expect": {"/result/variables/0/name": {"eq": "h"}, "/result/variables/0/value": {"eq": 12.0},
"/result/features/1/bound/0": {"eq": "distance"}, "/result/bodies/0/source_feature": {"eq": 1},
"/result/bodies/0/visible": {"eq": true}, "/result/bodies/0/moved": {"eq": false},
"/result/bodies/0/color": {"regex": "^#[0-9A-F]{6}$"}, "/result/undo_depth": {"eq": 3}}},
{"tool": "tool_call", "args": {"tool": "feature_describe", "args": {"feature": 1}},
"expect": {"/result/type": {"eq": "Extrude"}, "/result/params/distance": {"eq": 12.0}, "/result/expr/distance": {"eq": "h"},
"/result/refs/sketch_ref": {"eq": 0}, "/result/bodies_made/0": {"eq": 0}, "/result/editable": {"contains": "distance"}}},
{"tool": "tool_call", "args": {"tool": "feature_describe", "args": {"feature": 0}},
"expect": {"/result/type": {"eq": "Sketch"}, "/result/params/width": {"eq": 20.0}, "/result/plane/base": {"eq": "XY"},
"/result/used_by/0": {"eq": 1}}},
{"tool": "tool_call", "args": {"tool": "feature_set_expression", "args": {"feature": 1, "field": "distance", "expr": ""}},
"expect": {"/result/ok": {"eq": true}}},
{"tool": "tool_call", "args": {"tool": "set_variable", "args": {"name": "h", "expr": ""}},
"expect": {"/result/ok": {"eq": true}, "/result/removed": {"eq": true}}},
{"tool": "tool_call", "args": {"tool": "describe_design"},
"expect": {"/result/variables": {"empty": true}, "/result/features/1/bound": {"exists": false}}},
{"tool": "tool_call", "args": {"tool": "feature_edit", "args": {"feature": 1, "fields": {"distance": 15}}},
"expect": {"/result/ok": {"eq": true}, "/result/changed/distance/0": {"eq": 12.0}, "/result/changed/distance/1": {"eq": 15.0}}},
{"tool": "tool_call", "args": {"tool": "body_mass_properties", "args": {"body": 0}},
"expect": {"/result/volume": {"ge": 5999.99, "le": 6000.01}}},
{"tool": "tool_call", "args": {"tool": "feature_edit", "args": {"feature": 0, "fields": {"width": 30}}},
"expect": {"/result/changed/width/1": {"eq": 30.0}}},
// The names agents often use: index for feature, params or values for fields.
{"tool": "tool_call", "args": {"tool": "feature_edit", "args": {"index": 0, "params": {"width": 20}}},
"expect": {"/result/changed/width/1": {"eq": 20.0}}},
{"tool": "tool_call", "args": {"tool": "feature_edit", "args": {"feature": 0, "values": {"width": 30}}},
"expect": {"/result/changed/width/1": {"eq": 30.0}}},
{"tool": "tool_call", "args": {"tool": "feature_describe", "args": {"index": 1}}, "expect": {"/result/params/distance": {"eq": 15.0}}},
{"tool": "tool_call", "args": {"tool": "body_mass_properties", "args": {"body": 0}},
"expect": {"/result/volume": {"ge": 8999.99, "le": 9000.01}}},
{"tool": "tool_call", "args": {"tool": "sketch_create", "args": {"plane": "XY"}}},
{"tool": "tool_call", "args": {"tool": "sketch_draw", "args": {"type": "rectangle_2_point", "p0": [40, 0], "p1": [60, 10]}}},
{"tool": "tool_call", "args": {"tool": "sketch_repair"}},
{"tool": "tool_call", "args": {"tool": "sketch_finish"}, "expect": {"/result/features": {"eq": 3}}},
{"tool": "tool_call", "args": {"tool": "feature_describe", "args": {"feature": 2}},
"expect": {"/result/entities/0/type": {"eq": "line"}, "/result/entities/3/type": {"eq": "line"},
"/result/editable": {"empty": true}}},
{"tool": "tool_call", "args": {"tool": "commit_to_plate"},
"expect": {"/result/objects/0/index": {"eq": 0}, "/result/objects/0/name": {"eq": "Design Body"},
"/result/objects/0/parts": {"eq": 1}, "/result/bodies_sent/0": {"eq": 0}, "/result/tab": {"eq": "prepare"}}},
{"tool": "object_list", "expect": {"/total": {"eq": 1}, "/plates/0/objects/0/name": {"eq": "Design Body"},
"/plates/0/objects/0/bbox/size/2": {"ge": 14.99, "le": 15.01}}},
{"tool": "tool_call", "args": {"tool": "feature_edit", "args": {"feature": 1, "fields": {"distance": 20}}}},
{"tool": "tool_call", "args": {"tool": "commit_to_plate", "args": {"replace": [0]}},
"expect": {"/result/objects/0/index": {"eq": 0}, "/result/replaced/0/index": {"eq": 0}, "/result/replaced/0/name": {"eq": "Design Body"}}},
{"tool": "object_list", "expect": {"/total": {"eq": 1}, "/plates/0/objects/0/bbox/size/2": {"ge": 19.99, "le": 20.01}}},
{"tool": "action_run", "args": {"id": "orca_command:undo:orca"}},
{"tool": "object_list", "expect": {"/total": {"eq": 1}, "/plates/0/objects/0/bbox/size/2": {"ge": 14.99, "le": 15.01}}},
{"tool": "tool_call", "args": {"tool": "export_step", "args": {"path": "${out_dir}/design.step", "overwrite": true}},
"expect": {"/result/bytes": {"gt": 0}, "/result/bodies": {"eq": 1}, "/result/moved_bodies": {"empty": true}}},
{"tool": "tool_call", "args": {"tool": "new_design", "args": {"discard_changes": true}},
"expect": {"/result/cleared/features": {"eq": 3}, "/result/cleared/bodies": {"eq": 1}}},
{"tool": "tool_call", "args": {"tool": "import_step", "args": {"path": "${out_dir}/design.step"}},
"expect": {"/result/ok": {"eq": true}, "/result/bodies": {"eq": 1}}},
{"tool": "tool_call", "args": {"tool": "body_mass_properties", "args": {"body": 0}},
"expect": {"/result/volume": {"ge": 11998.8, "le": 12001.2}}},
{"tool": "tool_call", "args": {"tool": "extrude", "args": {"profile": [[40, 0], [50, 0], [50, 10], [40, 10]], "distance": 5}},
"expect": {"/result/bodies": {"eq": 2}}},
{"tool": "tool_call", "args": {"tool": "commit_to_plate", "args": {"mode": "bodies"}},
"expect": {"/result/mode": {"eq": "bodies"}, "/result/objects/0/index": {"eq": 1}, "/result/objects/1/index": {"eq": 2},
"/result/objects/1/name": {"eq": "Design Body 2"}, "/result/bodies_sent/1": {"eq": 1}, "/result/bodies_hidden": {"empty": true}}},
{"tool": "tool_call", "args": {"tool": "commit_to_plate", "args": {"mode": "assembly"}},
"expect": {"/result/objects/0/index": {"eq": 3}, "/result/objects/0/name": {"eq": "Design Assembly"}, "/result/objects/0/parts": {"eq": 2}}},
{"tool": "object_list", "expect": {"/total": {"eq": 4}}},
{"tool": "tool_call", "args": {"tool": "new_design", "args": {"discard_changes": true}}},
{"tool": "tool_call", "args": {"tool": "extrude", "args": {"width": 20, "height": 20, "distance": 10}},
"expect": {"/result/extrude_index": {"eq": 1}}},
{"tool": "tool_call", "args": {"tool": "feature_edit", "args": {"feature": 1, "fields": {"distance": 15}}}},
{"tool": "tool_call", "args": {"tool": "undo", "args": {"history": "design"}},
"expect": {"/result/scope": {"eq": "design"}, "/result/undo_depth": {"eq": 1}, "/result/redo_depth": {"eq": 1}}},
{"tool": "tool_call", "args": {"tool": "feature_describe", "args": {"feature": 1}}, "expect": {"/result/params/distance": {"eq": 10.0}}},
{"tool": "tool_call", "args": {"tool": "redo", "args": {"history": "design"}}, "expect": {"/result/redo_depth": {"eq": 0}}},
{"tool": "tool_call", "args": {"tool": "feature_describe", "args": {"feature": 1}}, "expect": {"/result/params/distance": {"eq": 15.0}}},
{"tool": "tool_call", "args": {"tool": "extrude", "args": {"profile": [[40, 0], [50, 0], [50, 10], [40, 10]], "distance": 5}},
"expect": {"/result/extrude_index": {"eq": 3}, "/result/bodies": {"eq": 2}}},
{"tool": "tool_call", "args": {"tool": "feature_rename", "args": {"feature": 1, "name": " Base "}},
"expect": {"/result/name": {"eq": "Base"}, "/result/changed": {"eq": true}, "/result/undo_depth": {"eq": 4}}},
{"tool": "tool_call", "args": {"tool": "undo", "args": {"history": "design"}}, "expect": {"/result/undo_depth": {"eq": 3}}},
{"tool": "tool_call", "args": {"tool": "describe_design"},
"expect": {"/result/features/1/name": {"regex": "^Extrude \\d+$"}, "/result/features/3": {"exists": true}, "/result/features/4": {"exists": false}}},
{"tool": "tool_call", "args": {"tool": "feature_describe", "args": {"feature": 1}}, "expect": {"/result/params/distance": {"eq": 15.0}}},
{"tool": "tool_call", "args": {"tool": "redo", "args": {"history": "design"}}},
{"tool": "tool_call", "args": {"tool": "describe_design"}, "expect": {"/result/features/1/name": {"eq": "Base"}}},
{"tool": "tool_call", "args": {"tool": "feature_suppress", "args": {"feature": 3, "suppressed": true}},
"expect": {"/result/changed": {"eq": true}, "/result/bodies": {"eq": 1}}},
{"tool": "tool_call", "args": {"tool": "feature_suppress", "args": {"feature": 3, "suppressed": true}},
"expect": {"/result/changed": {"eq": false}, "/result/bodies": {"eq": 1}}},
{"tool": "tool_call", "args": {"tool": "feature_suppress", "args": {"feature": 3, "suppressed": false}},
"expect": {"/result/bodies": {"eq": 2}}},
{"tool": "tool_call", "args": {"tool": "feature_move", "args": {"feature": 2, "delta": -1}},
"expect": {"/result/feature": {"eq": 1}, "/result/from": {"eq": 2}, "/result/bodies": {"eq": 2}}},
{"tool": "tool_call", "args": {"tool": "describe_design"},
"expect": {"/result/features/1/type": {"eq": "Sketch"}, "/result/features/2/name": {"eq": "Base"}}},
{"tool": "tool_call", "args": {"tool": "undo", "args": {"history": "design"}}},
{"tool": "tool_call", "args": {"tool": "describe_design"}, "expect": {"/result/features/1/name": {"eq": "Base"}}},
{"tool": "tool_call", "args": {"tool": "body_set", "args": {"body": 1, "name": "Lid", "visible": false}},
"expect": {"/result/name": {"eq": "Lid"}, "/result/visible": {"eq": false}}},
{"tool": "tool_call", "args": {"tool": "describe_design"},
"expect": {"/result/bodies/1/name": {"eq": "Lid"}, "/result/bodies/1/user_name": {"eq": true}, "/result/bodies/1/visible": {"eq": false}}},
{"tool": "tool_call", "args": {"tool": "commit_to_plate"},
"expect": {"/result/bodies_sent/1": {"exists": false}, "/result/bodies_sent/0": {"eq": 0}, "/result/bodies_hidden/0": {"eq": 1}}},
{"tool": "tool_call", "args": {"tool": "body_set", "args": {"body": 1, "visible": true}}, "expect": {"/result/visible": {"eq": true}}},
{"tool": "tool_call", "args": {"tool": "body_set", "args": {"body": 0, "visible": false}}},
{"tool": "tool_call", "args": {"tool": "commit_to_plate", "args": {"mode": "bodies"}},
"expect": {"/result/objects/0/name": {"eq": "Lid"}, "/result/bodies_sent/0": {"eq": 1}, "/result/bodies_hidden/0": {"eq": 0}}},
{"tool": "tool_call", "args": {"tool": "body_set", "args": {"body": 0, "visible": true}}},
{"tool": "tool_call", "args": {"tool": "body_delete", "args": {"body": 1}},
"expect": {"/result/deleted_feature/index": {"eq": 3}, "/result/deleted_feature/type": {"eq": "Extrude"},
"/result/removed": {"eq": 1}, "/result/features": {"eq": 3}, "/result/bodies": {"eq": 1}}},
{"tool": "tool_call", "args": {"tool": "undo", "args": {"history": "design"}}, "expect": {"/result/bodies": {"eq": 2}}},
{"tool": "tool_call", "args": {"tool": "describe_design"}, "expect": {"/result/bodies/1/source_feature": {"eq": 3}}},
{"tool": "tool_call", "args": {"tool": "feature_delete", "args": {"feature": 0}},
"expect": {"/result/removed": {"eq": 2}, "/result/features": {"eq": 2}, "/result/bodies": {"eq": 1}}},
{"tool": "tool_call", "args": {"tool": "undo", "args": {"history": "design"}}, "expect": {"/result/features": {"eq": 4}, "/result/bodies": {"eq": 2}}},
{"tool": "tool_call", "args": {"tool": "body_set", "args": {"body": 1, "name": "Lid"}}},
{"tool": "tool_call", "args": {"tool": "body_set", "args": {"body": 1, "color": "#3080ff"}},
"expect": {"/result/color": {"eq": "#3080FF"}}},
{"tool": "project_save", "args": {"path": "${out_dir}/design.3mf", "overwrite": true}},
{"tool": "project_new", "args": {"discard_changes": true}},
// Presets an earlier session modified make loading a project ask about them; the rule ends with the replay.
{"tool": "dialog_auto_answer", "args": {"rules": [{"match": "Load project: unsaved changes", "button": "Discard"}]}},
{"tool": "project_open", "args": {"path": "${out_dir}/design.3mf"}},
{"tool": "tool_call", "args": {"tool": "describe_design"},
"expect": {"/result/features/3": {"exists": true}, "/result/features/4": {"exists": false}, "/result/bodies/1/name": {"eq": "Lid"},
"/result/bodies/1/has_color": {"eq": true}, "/result/bodies/1/color": {"eq": "#3080FF"}}}
]
}