|
11 | 11 | from config.perfecto import TOOLS_PREFIX, SUPPORT_MESSAGE |
12 | 12 | from config.token import PerfectoToken, token_verify |
13 | 13 | from formatters.ai_scriptless import format_ai_scriptless_tests, \ |
14 | | - format_ai_scriptless_tests_filter_values, format_command_catalog, \ |
15 | | - format_command_definitions, format_snapshots_list, format_test_structure, \ |
16 | | - format_test_variables |
| 14 | + format_ai_scriptless_tests_filter_values, command_selection_policy_info, \ |
| 15 | + format_command_catalog, format_command_definitions, format_snapshots_list, \ |
| 16 | + format_test_structure, format_test_variables |
17 | 17 | from models.manager import Manager |
18 | 18 | from models.result import BaseResult, PaginationResult |
19 | 19 | from tools.ai_scriptless_script import ( |
|
52 | 52 | "do not reuse step_path values from this response.", |
53 | 53 | ] |
54 | 54 |
|
55 | | - |
56 | 55 | def _append_step_path_refresh_notes(result: BaseResult) -> BaseResult: |
57 | 56 | if result.error or not isinstance(result.result, dict): |
58 | 57 | return result |
@@ -196,8 +195,11 @@ async def list_commands(self, checkpoint: bool = False) -> BaseResult: |
196 | 195 | commands_url = commands_url + "/commands" |
197 | 196 | if checkpoint: |
198 | 197 | commands_url = commands_url + "?checkpoint=true" |
199 | | - return await api_request(self.token, "GET", endpoint=commands_url, |
200 | | - result_formatter=format_command_catalog) |
| 198 | + result = await api_request(self.token, "GET", endpoint=commands_url, |
| 199 | + result_formatter=format_command_catalog) |
| 200 | + if not result.error: |
| 201 | + result.append_info(command_selection_policy_info()) |
| 202 | + return result |
201 | 203 |
|
202 | 204 | @token_verify |
203 | 205 | async def get_command_definitions(self, command_ids: list[str]) -> BaseResult: |
@@ -484,9 +486,8 @@ async def move_test( |
484 | 486 | return BaseResult(error=str(exc)) |
485 | 487 |
|
486 | 488 | target_visibility = visibility or source_visibility |
487 | | - owner = await fetch_current_username(self.token) or "" |
488 | | - move_url = perfecto.get_repository_management_api_url(self.token.cloud_name) + "/directory" |
489 | | - body = build_move_test_body(test_id, folder, target_visibility, owner) |
| 489 | + move_url = perfecto.get_repository_management_api_url(self.token.cloud_name) + "/artifacts" |
| 490 | + body = build_move_test_body(test_id, folder, target_visibility) |
490 | 491 | result = await api_request(self.token, "PATCH", endpoint=move_url, json=body) |
491 | 492 | if result.error: |
492 | 493 | return result |
@@ -647,11 +648,12 @@ def register(mcp, token: Optional[PerfectoToken]): |
647 | 648 | args(dict): Dictionary with the following required parameters: |
648 | 649 | test_id (str): Test itemKey from list_tests (e.g. PRIVATE:My Folder/My Test.xml). |
649 | 650 | - list_commands: List available AI Scriptless commands from the command repository. |
| 651 | + Returns the catalog in result and command selection policy in info (read info before add_command when authoring tests). |
650 | 652 | args(dict): Dictionary with the following optional parameters: |
651 | 653 | checkpoint (bool, default=false): If true, list checkpoint commands only. |
652 | 654 | - get_command_definitions: Get parameter definitions for one or more commands. |
653 | 655 | args(dict): Dictionary with the following required parameters: |
654 | | - command_ids (list[str]): Command IDs from list_commands (e.g. ai_user-action, checkpoint_text). |
| 656 | + command_ids (list[str]): Command IDs from list_commands (typically ai_user-action, ai_validation, ai_visual-comparison). |
655 | 657 | - add_command: Add a command to a test and persist it. |
656 | 658 | args(dict): Dictionary with the following parameters: |
657 | 659 | test_id (str, required): Test itemKey from list_tests. |
@@ -725,8 +727,9 @@ def register(mcp, token: Optional[PerfectoToken]): |
725 | 727 | - move_test: Move a test to another folder (same or different visibility). |
726 | 728 | args(dict): Dictionary with the following required parameters: |
727 | 729 | test_id (str): Source test itemKey from list_tests. |
728 | | - folder (str): Target folder path without visibility prefix (e.g. 'My Folder' or 'Shared/Team'). |
| 730 | + folder (str): Target folder path without visibility prefix (e.g. 'My Folder', 'MCP Archive', or 'My Folder/SubFolder'). The test file keeps its name. If the path does not exist, the API creates the nested folder segments automatically (the new folder may not appear as a CONTAINER in list_tests until it contains tests). |
729 | 731 | visibility (str, optional): Target visibility; defaults to the source test visibility. |
| 732 | + Returns source_item_key and target_item_key; use target_item_key for view_test_structure, execute_test, and other actions after the move. |
730 | 733 | - list_snapshots: List snapshot history for a test (includes '<current>' marker plus UUID historical versions). |
731 | 734 | args(dict): Dictionary with the following required parameters: |
732 | 735 | test_id (str): Test itemKey from list_tests. |
@@ -756,8 +759,8 @@ def register(mcp, token: Optional[PerfectoToken]): |
756 | 759 | test_id (str): Test itemKey from list_tests. |
757 | 760 | name (str): Variable name to delete. |
758 | 761 | Hints: |
| 762 | +- When authoring or editing test steps, call list_commands first and follow the command selection policy in the info field. |
759 | 763 | - step_path is a dot-separated positional path without spaces (0-based indices; b0=Then branch, b1=Else). Example: root step 3 is "3"; first step inside Then of condition at 5 is "5.b0.0". Perfecto does not persist paths; they change when steps are inserted, moved, or deleted. Always call view_test_structure before the next structure edit; do not reuse step_path from a previous mutation response. |
760 | | -- Use list_commands and get_command_definitions before add_command to discover valid command_ids and argument names. |
761 | 764 | - Use parent_path on add_command with the step_path of a LogicalStep, Loop, or Branch from view_test_structure. |
762 | 765 | - Use add_logical_step, add_loop, and add_condition to build control-flow structures matching the UI toolbar Group, Loop, and Condition actions. |
763 | 766 | - Script variables (list_test_variables, add/modify/delete_test_variable) are stored in script.variables[] and are distinct from the DUT parameter in script.parameters[]. |
|
0 commit comments