mobile-mcp-ai 2.1.2__py3-none-any.whl → 2.5.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. mobile_mcp/__init__.py +34 -0
  2. mobile_mcp/config.py +142 -0
  3. mobile_mcp/core/basic_tools_lite.py +3266 -0
  4. {core → mobile_mcp/core}/device_manager.py +2 -2
  5. mobile_mcp/core/dynamic_config.py +272 -0
  6. mobile_mcp/core/ios_client_wda.py +569 -0
  7. mobile_mcp/core/ios_device_manager_wda.py +306 -0
  8. {core → mobile_mcp/core}/mobile_client.py +279 -39
  9. mobile_mcp/core/template_matcher.py +429 -0
  10. mobile_mcp/core/templates/close_buttons/auto_x_0112_151217.png +0 -0
  11. mobile_mcp/core/templates/close_buttons/auto_x_0112_152037.png +0 -0
  12. mobile_mcp/core/templates/close_buttons/auto_x_0112_152840.png +0 -0
  13. mobile_mcp/core/templates/close_buttons/auto_x_0112_153256.png +0 -0
  14. mobile_mcp/core/templates/close_buttons/auto_x_0112_154847.png +0 -0
  15. mobile_mcp/core/templates/close_buttons/gray_x_stock_ad.png +0 -0
  16. {core → mobile_mcp/core}/utils/smart_wait.py +3 -3
  17. mobile_mcp/mcp_tools/__init__.py +10 -0
  18. mobile_mcp/mcp_tools/mcp_server.py +1071 -0
  19. mobile_mcp_ai-2.5.8.dist-info/METADATA +469 -0
  20. mobile_mcp_ai-2.5.8.dist-info/RECORD +32 -0
  21. mobile_mcp_ai-2.5.8.dist-info/entry_points.txt +2 -0
  22. mobile_mcp_ai-2.5.8.dist-info/licenses/LICENSE +201 -0
  23. mobile_mcp_ai-2.5.8.dist-info/top_level.txt +1 -0
  24. core/ai/__init__.py +0 -11
  25. core/ai/ai_analyzer.py +0 -197
  26. core/ai/ai_config.py +0 -116
  27. core/ai/ai_platform_adapter.py +0 -399
  28. core/ai/smart_test_executor.py +0 -520
  29. core/ai/test_generator.py +0 -365
  30. core/ai/test_generator_from_history.py +0 -391
  31. core/ai/test_generator_standalone.py +0 -293
  32. core/assertion/__init__.py +0 -9
  33. core/assertion/smart_assertion.py +0 -341
  34. core/basic_tools.py +0 -377
  35. core/h5/__init__.py +0 -10
  36. core/h5/h5_handler.py +0 -548
  37. core/ios_client.py +0 -219
  38. core/ios_device_manager.py +0 -252
  39. core/locator/__init__.py +0 -10
  40. core/locator/cursor_ai_auto_analyzer.py +0 -119
  41. core/locator/cursor_vision_helper.py +0 -414
  42. core/locator/mobile_smart_locator.py +0 -1640
  43. core/locator/position_analyzer.py +0 -813
  44. core/locator/script_updater.py +0 -157
  45. core/nl_test_runner.py +0 -585
  46. core/smart_app_launcher.py +0 -334
  47. core/smart_tools.py +0 -311
  48. mcp/__init__.py +0 -8
  49. mcp/mcp_server.py +0 -1919
  50. mcp/mcp_server_simple.py +0 -476
  51. mobile_mcp_ai-2.1.2.dist-info/METADATA +0 -567
  52. mobile_mcp_ai-2.1.2.dist-info/RECORD +0 -45
  53. mobile_mcp_ai-2.1.2.dist-info/entry_points.txt +0 -2
  54. mobile_mcp_ai-2.1.2.dist-info/top_level.txt +0 -4
  55. vision/__init__.py +0 -10
  56. vision/vision_locator.py +0 -404
  57. {core → mobile_mcp/core}/__init__.py +0 -0
  58. {core → mobile_mcp/core}/utils/__init__.py +0 -0
  59. {core → mobile_mcp/core}/utils/logger.py +0 -0
  60. {core → mobile_mcp/core}/utils/operation_history_manager.py +0 -0
  61. {utils → mobile_mcp/utils}/__init__.py +0 -0
  62. {utils → mobile_mcp/utils}/logger.py +0 -0
  63. {utils → mobile_mcp/utils}/xml_formatter.py +0 -0
  64. {utils → mobile_mcp/utils}/xml_parser.py +0 -0
  65. {mobile_mcp_ai-2.1.2.dist-info → mobile_mcp_ai-2.5.8.dist-info}/WHEEL +0 -0
@@ -1,157 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- """
4
- 脚本更新工具 - 将坐标保存到测试脚本中
5
-
6
- 功能:
7
- 1. 解析测试脚本
8
- 2. 找到对应的步骤
9
- 3. 更新坐标(添加注释或替换为坐标格式)
10
- 4. 保存文件
11
- """
12
- import re
13
- import ast
14
- from pathlib import Path
15
- from typing import Dict, Optional, List, Tuple
16
-
17
-
18
- class ScriptUpdater:
19
- """脚本更新工具"""
20
-
21
- def __init__(self, script_path: str):
22
- """
23
- 初始化脚本更新工具
24
-
25
- Args:
26
- script_path: 测试脚本路径
27
- """
28
- self.script_path = Path(script_path)
29
- self.script_content = None
30
- self.script_lines = []
31
-
32
- def load_script(self) -> bool:
33
- """加载脚本文件"""
34
- try:
35
- with open(self.script_path, 'r', encoding='utf-8') as f:
36
- self.script_content = f.read()
37
- self.script_lines = self.script_content.split('\n')
38
- return True
39
- except Exception as e:
40
- print(f" ❌ 加载脚本失败: {e}")
41
- return False
42
-
43
- def find_step(self, element_desc: str) -> Optional[Tuple[int, Dict]]:
44
- """
45
- 查找包含指定元素描述的步骤
46
-
47
- Args:
48
- element_desc: 元素描述
49
-
50
- Returns:
51
- (行号, 步骤信息) 或 None
52
- """
53
- for i, line in enumerate(self.script_lines):
54
- # 查找STEPS列表中的步骤
55
- if '("点击"' in line or '("输入"' in line:
56
- # 提取步骤内容
57
- step_match = re.search(r'\(["\']([^"\']+)["\']\s*,\s*["\']([^"\']+)["\']', line)
58
- if step_match:
59
- action = step_match.group(1)
60
- desc = step_match.group(2)
61
-
62
- if desc == element_desc or element_desc in desc:
63
- return (i, {
64
- 'action': action,
65
- 'element_desc': desc,
66
- 'line': line,
67
- 'line_number': i + 1
68
- })
69
- return None
70
-
71
- def update_step_with_coordinate(self, element_desc: str, coordinate: Dict, method: str = 'comment') -> bool:
72
- """
73
- 更新步骤,添加坐标信息
74
-
75
- Args:
76
- element_desc: 元素描述
77
- coordinate: 坐标信息 {"x": int, "y": int, "confidence": int}
78
- method: 更新方式
79
- - 'comment': 添加注释(推荐,不破坏原有逻辑)
80
- - 'replace': 替换为坐标格式
81
-
82
- Returns:
83
- 是否成功
84
- """
85
- if not self.load_script():
86
- return False
87
-
88
- step_info = self.find_step(element_desc)
89
- if not step_info:
90
- print(f" ⚠️ 未找到步骤: {element_desc}")
91
- return False
92
-
93
- line_num, step = step_info
94
- x = coordinate.get('x')
95
- y = coordinate.get('y')
96
- confidence = coordinate.get('confidence', 80)
97
-
98
- if method == 'comment':
99
- # 方法1:添加注释(推荐)
100
- # 格式:("点击", "设置"), # Cursor AI坐标: [976,159] (置信度:95%)
101
- comment = f" # Cursor AI坐标: [{x},{y}] (置信度:{confidence}%)"
102
-
103
- # 检查是否已有注释
104
- if '#' in self.script_lines[line_num]:
105
- # 已有注释,更新注释
106
- line = self.script_lines[line_num]
107
- if 'Cursor AI坐标' in line:
108
- # 替换现有坐标注释
109
- self.script_lines[line_num] = re.sub(
110
- r'# Cursor AI坐标:.*',
111
- comment.strip(),
112
- line
113
- )
114
- else:
115
- # 追加坐标注释
116
- self.script_lines[line_num] = line.rstrip() + comment
117
- else:
118
- # 没有注释,添加注释
119
- self.script_lines[line_num] = self.script_lines[line_num].rstrip() + comment
120
-
121
- elif method == 'replace':
122
- # 方法2:替换为坐标格式
123
- # 格式:("点击", "[976,159][976,159]"), # 设置 (Cursor AI坐标)
124
- coord_format = f'"[{x},{y}][{x},{y}]"'
125
- new_line = f' ("点击", {coord_format}), # {element_desc} (Cursor AI坐标, 置信度:{confidence}%)'
126
- self.script_lines[line_num] = new_line
127
-
128
- return True
129
-
130
- def save_script(self) -> bool:
131
- """保存脚本文件"""
132
- try:
133
- new_content = '\n'.join(self.script_lines)
134
- with open(self.script_path, 'w', encoding='utf-8') as f:
135
- f.write(new_content)
136
- print(f" ✅ 脚本已更新: {self.script_path}")
137
- return True
138
- except Exception as e:
139
- print(f" ❌ 保存脚本失败: {e}")
140
- return False
141
-
142
- def update_with_coordinate(self, element_desc: str, coordinate: Dict, method: str = 'comment') -> bool:
143
- """
144
- 更新脚本(完整流程)
145
-
146
- Args:
147
- element_desc: 元素描述
148
- coordinate: 坐标信息
149
- method: 更新方式
150
-
151
- Returns:
152
- 是否成功
153
- """
154
- if self.update_step_with_coordinate(element_desc, coordinate, method):
155
- return self.save_script()
156
- return False
157
-