Files
OrcaSlicer/tools/mcp/tests/ops_open_project.json
T
SoftFever 1ef24b7d34 Hold Speed Dial commands, MCP tools and Design tools in one command catalog
Every command takes JSON arguments and has one function for a person and for
automation: with no arguments it does what a person's pick does, and with
arguments it runs silently. The Design tab's CAD tools are commands that
call_tool runs, and they show as Speed Dial tiles on the Design tab.
2026-11-13 20:59:31 +08:00

147 lines
11 KiB
JSON

// Records what opening a project does through its two routes, the load_project command run with run_action and a
// path, and the open_files tool given a .3mf (as auto): on a clean project, on one with unsaved changes
// (the tool with and without discard_changes) and with unsaved preset changes (top_shell_layers 7). The project
// it opens is saved here first: a cube with wall_loops 5. Each call that may ask runs with "await": false;
// get_app_state lists the question, which the replay answers, by its title, as a person who does not save: No to
// saving the project, Discard for the presets. After each it reads the objects, the project's name and file, the
// presets and their unsaved keys, the recent projects and the tab, and the undo snapshots taken since the last
// read (fixtures/ops_undo.py). Every call it records is optional. Run it with
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/ops_open_project.json --out <dir>
{
"orca_replay": 1,
"name": "ops open_project",
"vars": {"undo": "${replay_dir}/fixtures/ops_undo.py"},
"steps": [
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "set_view", "args": {"tab": "prepare"}},
// ---- The project to open: a cube with wall_loops 5 ----
{"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca", "args": {"size": [20, 20, 20]}}},
{"tool": "set_settings", "args": {"values": {"wall_loops": 5}}},
{"tool": "save_project", "args": {"path": "${out_dir}/open_src.3mf", "overwrite": true}},
// ---- A clean project: the command ----
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "set_view", "args": {"tab": "home"}},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "run_action", "args": {"id": "orca_command:load_project:orca", "args": {"path": "${out_dir}/open_src.3mf"}}, "await": false, "save_as": "clean_cmd", "optional": true},
{"tool": "get_app_state"},
{"tool": "answer_dialog", "args": {"dialog": {"title": "- Save"}, "button": "no"}, "optional": true},
{"tool": "answer_dialog", "args": {"dialog": {"title": "unsaved changes"}, "button": "Discard"}, "optional": true},
{"tool": "wait", "args": {"for": "job", "job": "${jobs.clean_cmd}"}, "optional": true},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "list_objects"},
{"tool": "get_settings", "args": {"scope": "process", "compare": ":saved"}},
{"tool": "search_actions", "args": {"group": "Recent Projects"}},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- the tool ----
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "set_view", "args": {"tab": "home"}},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "open_files", "args": {"paths": ["${out_dir}/open_src.3mf"]}, "await": false, "save_as": "clean_tool", "optional": true},
{"tool": "get_app_state"},
{"tool": "answer_dialog", "args": {"dialog": {"title": "- Save"}, "button": "no"}, "optional": true},
{"tool": "answer_dialog", "args": {"dialog": {"title": "unsaved changes"}, "button": "Discard"}, "optional": true},
{"tool": "wait", "args": {"for": "job", "job": "${jobs.clean_tool}"}, "optional": true},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "list_objects"},
{"tool": "get_settings", "args": {"scope": "process", "compare": ":saved"}},
{"tool": "search_actions", "args": {"group": "Recent Projects"}},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- Unsaved project changes (a cylinder), presets clean: the command asks ----
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "run_action", "args": {"id": "orca_command:add_primitive_cylinder:orca", "args": {"size": [20, 10]}}},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "run_action", "args": {"id": "orca_command:load_project:orca", "args": {"path": "${out_dir}/open_src.3mf"}}, "await": false, "save_as": "dirty_cmd", "optional": true},
{"tool": "get_app_state"},
{"tool": "answer_dialog", "args": {"dialog": {"title": "- Save"}, "button": "no"}, "optional": true},
{"tool": "get_app_state"},
{"tool": "answer_dialog", "args": {"dialog": {"title": "unsaved changes"}, "button": "Discard"}, "optional": true},
{"tool": "wait", "args": {"for": "job", "job": "${jobs.dirty_cmd}"}, "optional": true},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "list_objects"},
{"tool": "get_settings", "args": {"scope": "process", "compare": ":saved"}},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- the tool, without discard_changes, then with it ----
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "run_action", "args": {"id": "orca_command:add_primitive_cylinder:orca", "args": {"size": [20, 10]}}},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "open_files", "args": {"paths": ["${out_dir}/open_src.3mf"]}, "optional": true},
{"tool": "get_app_state"},
{"tool": "list_objects"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "open_files", "args": {"paths": ["${out_dir}/open_src.3mf"], "discard_changes": true}, "await": false, "save_as": "dirty_tool", "optional": true},
{"tool": "get_app_state"},
{"tool": "answer_dialog", "args": {"dialog": {"title": "- Save"}, "button": "no"}, "optional": true},
{"tool": "answer_dialog", "args": {"dialog": {"title": "unsaved changes"}, "button": "Discard"}, "optional": true},
{"tool": "wait", "args": {"for": "job", "job": "${jobs.dirty_tool}"}, "optional": true},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "list_objects"},
{"tool": "get_settings", "args": {"scope": "process", "compare": ":saved"}},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- Unsaved preset changes (top_shell_layers 7) on an empty project: the command ----
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "set_settings", "args": {"values": {"top_shell_layers": 7}}},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "run_action", "args": {"id": "orca_command:load_project:orca", "args": {"path": "${out_dir}/open_src.3mf"}}, "await": false, "save_as": "presets_cmd", "optional": true},
{"tool": "get_app_state"},
{"tool": "answer_dialog", "args": {"dialog": {"title": "- Save"}, "button": "no"}, "optional": true},
{"tool": "get_app_state"},
{"tool": "answer_dialog", "args": {"dialog": {"title": "unsaved changes"}, "button": "Discard"}, "optional": true},
{"tool": "wait", "args": {"for": "job", "job": "${jobs.presets_cmd}"}, "optional": true},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "list_objects"},
{"tool": "get_settings", "args": {"scope": "process", "compare": ":saved"}},
{"tool": "get_settings", "args": {"keys": ["wall_loops", "top_shell_layers"]}},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- the tool, without discard_changes, then with it ----
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "set_settings", "args": {"values": {"top_shell_layers": 7}}},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "open_files", "args": {"paths": ["${out_dir}/open_src.3mf"]}, "await": false, "save_as": "presets_tool", "optional": true},
{"tool": "get_app_state"},
{"tool": "answer_dialog", "args": {"dialog": {"title": "- Save"}, "button": "no"}, "optional": true},
{"tool": "get_app_state"},
{"tool": "answer_dialog", "args": {"dialog": {"title": "unsaved changes"}, "button": "Discard"}, "optional": true},
{"tool": "wait", "args": {"for": "job", "job": "${jobs.presets_tool}"}, "optional": true},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "get_settings", "args": {"keys": ["wall_loops", "top_shell_layers"]}},
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "set_settings", "args": {"values": {"top_shell_layers": 7}}},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "open_files", "args": {"paths": ["${out_dir}/open_src.3mf"], "discard_changes": true}, "await": false, "save_as": "presets_tool2", "optional": true},
{"tool": "get_app_state"},
{"tool": "answer_dialog", "args": {"dialog": {"title": "- Save"}, "button": "no"}, "optional": true},
{"tool": "get_app_state"},
{"tool": "answer_dialog", "args": {"dialog": {"title": "unsaved changes"}, "button": "Discard"}, "optional": true},
{"tool": "wait", "args": {"for": "job", "job": "${jobs.presets_tool2}"}, "optional": true},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "list_objects"},
{"tool": "get_settings", "args": {"scope": "process", "compare": ":saved"}},
{"tool": "get_settings", "args": {"keys": ["wall_loops", "top_shell_layers"]}},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}}
]
}