mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-11-25 23:01:09 -05:00
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.
This commit is contained in:
1 parent
74c98e197c
commit
d64e10f4dd
287 files changed
+40484
-16770
No files matched your search
@@ -654,7 +654,7 @@ TEST_CASE("a script reads the catalog", "[PluginHost][Python]")
|
||||
py::exec(R"PY(
|
||||
import orca
|
||||
tools = orca.host.tools
|
||||
state = tools.describe("get_app_state")
|
||||
state = tools.describe("app_state")
|
||||
commands = tools.list()
|
||||
names = [entry["name"] for entry in commands]
|
||||
fields = sorted(commands[0])
|
||||
@@ -666,7 +666,7 @@ try:
|
||||
except tools.ToolError as error:
|
||||
unknown = (str(error), error.details)
|
||||
try:
|
||||
tools.describe("get_app_stat")
|
||||
tools.describe("app_stat")
|
||||
mistyped = None
|
||||
except tools.ToolError as error:
|
||||
mistyped = error.details
|
||||
@@ -679,18 +679,18 @@ except tools.ToolError as error:
|
||||
Slic3r::PluginOperations::instance().remove_plugin("catalog_reader");
|
||||
|
||||
CHECK(scope["state"]["read_only"].cast<bool>());
|
||||
CHECK(scope["state"]["key"].cast<std::string>() == "get_app_state");
|
||||
CHECK(scope["state"]["key"].cast<std::string>() == "app_state");
|
||||
CHECK(scope["state"].contains("input_schema"));
|
||||
CHECK(py::len(scope["commands"]) >= 53);
|
||||
const std::vector<std::string> list_fields{"description", "group", "listed", "name", "read_only", "title"};
|
||||
CHECK(scope["fields"].cast<std::vector<std::string>>() == list_fields);
|
||||
CHECK(scope["plugin_fields"].cast<std::vector<std::string>>() == list_fields);
|
||||
const auto names = scope["names"].cast<std::vector<std::string>>();
|
||||
for (const char* name : {"get_app_state", "obj_arrange", "plugin.catalog_reader.measure"}) {
|
||||
for (const char* name : {"app_state", "object_mirror", "plugin.catalog_reader.measure"}) {
|
||||
CAPTURE(name);
|
||||
CHECK(std::count(names.begin(), names.end(), name) == 1);
|
||||
}
|
||||
CHECK(scope["operation"]["group"].cast<std::string>() == "api");
|
||||
CHECK(scope["operation"]["group"].cast<std::string>() == "Plugins");
|
||||
CHECK(scope["operation"]["read_only"].cast<bool>());
|
||||
REQUIRE_FALSE(scope["unknown"].is_none());
|
||||
CHECK(scope["unknown"].cast<py::tuple>()[0].cast<std::string>() == "Unknown tool: nope");
|
||||
@@ -700,9 +700,9 @@ except tools.ToolError as error:
|
||||
REQUIRE_FALSE(scope["mistyped"].is_none());
|
||||
const auto close = scope["mistyped"]["did_you_mean"].cast<std::vector<std::string>>();
|
||||
REQUIRE_FALSE(close.empty());
|
||||
CHECK(close.front() == "get_app_state");
|
||||
CHECK(close.front() == "app_state");
|
||||
|
||||
// search_python_api documents both, as it does every function of the package.
|
||||
// script_search_api documents both, as it does every function of the package.
|
||||
std::set<std::string> documented;
|
||||
for (const nlohmann::json& entry : Slic3r::GUI::Mcp::python_api_reference())
|
||||
if (entry["kind"] == "function" && !entry["doc"].get<std::string>().empty())
|
||||
@@ -713,7 +713,7 @@ except tools.ToolError as error:
|
||||
|
||||
TEST_CASE("every public member of the orca package has documentation and named parameters", "[PluginHost][Python]")
|
||||
{
|
||||
// search_python_api serves this documentation to agents writing scripts and plugins: a member without it, or
|
||||
// script_search_api serves this documentation to agents writing scripts and plugins: a member without it, or
|
||||
// with a parameter pybind11 names argN, is one they can only guess at. A constant's documentation is
|
||||
// the documentation that names it, and a class's goes on with what its constructors say; an enum's
|
||||
// constructor takes one of the values its documentation lists.
|
||||
|
||||
Reference in new issue
Block a user