jarvis-ai-assistant 0.3.30__py3-none-any.whl → 0.7.6__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 (181) hide show
  1. jarvis/__init__.py +1 -1
  2. jarvis/jarvis_agent/__init__.py +458 -152
  3. jarvis/jarvis_agent/agent_manager.py +17 -13
  4. jarvis/jarvis_agent/builtin_input_handler.py +2 -6
  5. jarvis/jarvis_agent/config_editor.py +2 -7
  6. jarvis/jarvis_agent/event_bus.py +82 -12
  7. jarvis/jarvis_agent/file_context_handler.py +329 -0
  8. jarvis/jarvis_agent/file_methodology_manager.py +3 -4
  9. jarvis/jarvis_agent/jarvis.py +628 -55
  10. jarvis/jarvis_agent/language_extractors/__init__.py +57 -0
  11. jarvis/jarvis_agent/language_extractors/c_extractor.py +21 -0
  12. jarvis/jarvis_agent/language_extractors/cpp_extractor.py +21 -0
  13. jarvis/jarvis_agent/language_extractors/go_extractor.py +21 -0
  14. jarvis/jarvis_agent/language_extractors/java_extractor.py +84 -0
  15. jarvis/jarvis_agent/language_extractors/javascript_extractor.py +79 -0
  16. jarvis/jarvis_agent/language_extractors/python_extractor.py +21 -0
  17. jarvis/jarvis_agent/language_extractors/rust_extractor.py +21 -0
  18. jarvis/jarvis_agent/language_extractors/typescript_extractor.py +84 -0
  19. jarvis/jarvis_agent/language_support_info.py +486 -0
  20. jarvis/jarvis_agent/main.py +34 -10
  21. jarvis/jarvis_agent/memory_manager.py +7 -16
  22. jarvis/jarvis_agent/methodology_share_manager.py +10 -16
  23. jarvis/jarvis_agent/prompt_manager.py +1 -1
  24. jarvis/jarvis_agent/prompts.py +193 -171
  25. jarvis/jarvis_agent/protocols.py +8 -12
  26. jarvis/jarvis_agent/run_loop.py +105 -9
  27. jarvis/jarvis_agent/session_manager.py +2 -3
  28. jarvis/jarvis_agent/share_manager.py +20 -22
  29. jarvis/jarvis_agent/shell_input_handler.py +1 -2
  30. jarvis/jarvis_agent/stdio_redirect.py +295 -0
  31. jarvis/jarvis_agent/task_analyzer.py +31 -6
  32. jarvis/jarvis_agent/task_manager.py +11 -27
  33. jarvis/jarvis_agent/tool_executor.py +2 -3
  34. jarvis/jarvis_agent/tool_share_manager.py +12 -24
  35. jarvis/jarvis_agent/utils.py +5 -1
  36. jarvis/jarvis_agent/web_bridge.py +189 -0
  37. jarvis/jarvis_agent/web_output_sink.py +53 -0
  38. jarvis/jarvis_agent/web_server.py +786 -0
  39. jarvis/jarvis_c2rust/__init__.py +26 -0
  40. jarvis/jarvis_c2rust/cli.py +575 -0
  41. jarvis/jarvis_c2rust/collector.py +250 -0
  42. jarvis/jarvis_c2rust/constants.py +26 -0
  43. jarvis/jarvis_c2rust/library_replacer.py +1254 -0
  44. jarvis/jarvis_c2rust/llm_module_agent.py +1272 -0
  45. jarvis/jarvis_c2rust/loaders.py +207 -0
  46. jarvis/jarvis_c2rust/models.py +28 -0
  47. jarvis/jarvis_c2rust/optimizer.py +2157 -0
  48. jarvis/jarvis_c2rust/scanner.py +1681 -0
  49. jarvis/jarvis_c2rust/transpiler.py +2983 -0
  50. jarvis/jarvis_c2rust/utils.py +385 -0
  51. jarvis/jarvis_code_agent/build_validation_config.py +132 -0
  52. jarvis/jarvis_code_agent/code_agent.py +1371 -220
  53. jarvis/jarvis_code_agent/code_analyzer/__init__.py +65 -0
  54. jarvis/jarvis_code_agent/code_analyzer/base_language.py +74 -0
  55. jarvis/jarvis_code_agent/code_analyzer/build_validator/__init__.py +44 -0
  56. jarvis/jarvis_code_agent/code_analyzer/build_validator/base.py +106 -0
  57. jarvis/jarvis_code_agent/code_analyzer/build_validator/cmake.py +74 -0
  58. jarvis/jarvis_code_agent/code_analyzer/build_validator/detector.py +125 -0
  59. jarvis/jarvis_code_agent/code_analyzer/build_validator/fallback.py +72 -0
  60. jarvis/jarvis_code_agent/code_analyzer/build_validator/go.py +70 -0
  61. jarvis/jarvis_code_agent/code_analyzer/build_validator/java_gradle.py +53 -0
  62. jarvis/jarvis_code_agent/code_analyzer/build_validator/java_maven.py +47 -0
  63. jarvis/jarvis_code_agent/code_analyzer/build_validator/makefile.py +61 -0
  64. jarvis/jarvis_code_agent/code_analyzer/build_validator/nodejs.py +110 -0
  65. jarvis/jarvis_code_agent/code_analyzer/build_validator/python.py +154 -0
  66. jarvis/jarvis_code_agent/code_analyzer/build_validator/rust.py +110 -0
  67. jarvis/jarvis_code_agent/code_analyzer/build_validator/validator.py +153 -0
  68. jarvis/jarvis_code_agent/code_analyzer/build_validator.py +43 -0
  69. jarvis/jarvis_code_agent/code_analyzer/context_manager.py +648 -0
  70. jarvis/jarvis_code_agent/code_analyzer/context_recommender.py +18 -0
  71. jarvis/jarvis_code_agent/code_analyzer/dependency_analyzer.py +132 -0
  72. jarvis/jarvis_code_agent/code_analyzer/file_ignore.py +330 -0
  73. jarvis/jarvis_code_agent/code_analyzer/impact_analyzer.py +781 -0
  74. jarvis/jarvis_code_agent/code_analyzer/language_registry.py +185 -0
  75. jarvis/jarvis_code_agent/code_analyzer/language_support.py +110 -0
  76. jarvis/jarvis_code_agent/code_analyzer/languages/__init__.py +49 -0
  77. jarvis/jarvis_code_agent/code_analyzer/languages/c_cpp_language.py +299 -0
  78. jarvis/jarvis_code_agent/code_analyzer/languages/go_language.py +215 -0
  79. jarvis/jarvis_code_agent/code_analyzer/languages/java_language.py +212 -0
  80. jarvis/jarvis_code_agent/code_analyzer/languages/javascript_language.py +254 -0
  81. jarvis/jarvis_code_agent/code_analyzer/languages/python_language.py +269 -0
  82. jarvis/jarvis_code_agent/code_analyzer/languages/rust_language.py +281 -0
  83. jarvis/jarvis_code_agent/code_analyzer/languages/typescript_language.py +280 -0
  84. jarvis/jarvis_code_agent/code_analyzer/llm_context_recommender.py +605 -0
  85. jarvis/jarvis_code_agent/code_analyzer/structured_code.py +556 -0
  86. jarvis/jarvis_code_agent/code_analyzer/symbol_extractor.py +252 -0
  87. jarvis/jarvis_code_agent/code_analyzer/tree_sitter_extractor.py +58 -0
  88. jarvis/jarvis_code_agent/lint.py +501 -8
  89. jarvis/jarvis_code_agent/utils.py +141 -0
  90. jarvis/jarvis_code_analysis/code_review.py +493 -584
  91. jarvis/jarvis_data/config_schema.json +128 -12
  92. jarvis/jarvis_git_squash/main.py +4 -5
  93. jarvis/jarvis_git_utils/git_commiter.py +82 -75
  94. jarvis/jarvis_mcp/sse_mcp_client.py +22 -29
  95. jarvis/jarvis_mcp/stdio_mcp_client.py +12 -13
  96. jarvis/jarvis_mcp/streamable_mcp_client.py +15 -14
  97. jarvis/jarvis_memory_organizer/memory_organizer.py +55 -74
  98. jarvis/jarvis_methodology/main.py +32 -48
  99. jarvis/jarvis_multi_agent/__init__.py +287 -55
  100. jarvis/jarvis_multi_agent/main.py +36 -4
  101. jarvis/jarvis_platform/base.py +524 -202
  102. jarvis/jarvis_platform/human.py +7 -8
  103. jarvis/jarvis_platform/kimi.py +30 -36
  104. jarvis/jarvis_platform/openai.py +88 -25
  105. jarvis/jarvis_platform/registry.py +26 -10
  106. jarvis/jarvis_platform/tongyi.py +24 -25
  107. jarvis/jarvis_platform/yuanbao.py +32 -43
  108. jarvis/jarvis_platform_manager/main.py +66 -77
  109. jarvis/jarvis_platform_manager/service.py +8 -13
  110. jarvis/jarvis_rag/cli.py +53 -55
  111. jarvis/jarvis_rag/embedding_manager.py +13 -18
  112. jarvis/jarvis_rag/llm_interface.py +8 -9
  113. jarvis/jarvis_rag/query_rewriter.py +10 -21
  114. jarvis/jarvis_rag/rag_pipeline.py +24 -27
  115. jarvis/jarvis_rag/reranker.py +4 -5
  116. jarvis/jarvis_rag/retriever.py +28 -30
  117. jarvis/jarvis_sec/__init__.py +305 -0
  118. jarvis/jarvis_sec/agents.py +143 -0
  119. jarvis/jarvis_sec/analysis.py +276 -0
  120. jarvis/jarvis_sec/checkers/__init__.py +32 -0
  121. jarvis/jarvis_sec/checkers/c_checker.py +2680 -0
  122. jarvis/jarvis_sec/checkers/rust_checker.py +1108 -0
  123. jarvis/jarvis_sec/cli.py +139 -0
  124. jarvis/jarvis_sec/clustering.py +1439 -0
  125. jarvis/jarvis_sec/file_manager.py +427 -0
  126. jarvis/jarvis_sec/parsers.py +73 -0
  127. jarvis/jarvis_sec/prompts.py +268 -0
  128. jarvis/jarvis_sec/report.py +336 -0
  129. jarvis/jarvis_sec/review.py +453 -0
  130. jarvis/jarvis_sec/status.py +264 -0
  131. jarvis/jarvis_sec/types.py +20 -0
  132. jarvis/jarvis_sec/utils.py +499 -0
  133. jarvis/jarvis_sec/verification.py +848 -0
  134. jarvis/jarvis_sec/workflow.py +226 -0
  135. jarvis/jarvis_smart_shell/main.py +38 -87
  136. jarvis/jarvis_stats/cli.py +2 -2
  137. jarvis/jarvis_stats/stats.py +8 -8
  138. jarvis/jarvis_stats/storage.py +15 -21
  139. jarvis/jarvis_stats/visualizer.py +1 -1
  140. jarvis/jarvis_tools/clear_memory.py +3 -20
  141. jarvis/jarvis_tools/cli/main.py +21 -23
  142. jarvis/jarvis_tools/edit_file.py +1019 -132
  143. jarvis/jarvis_tools/execute_script.py +83 -25
  144. jarvis/jarvis_tools/file_analyzer.py +6 -9
  145. jarvis/jarvis_tools/generate_new_tool.py +14 -21
  146. jarvis/jarvis_tools/lsp_client.py +1552 -0
  147. jarvis/jarvis_tools/methodology.py +2 -3
  148. jarvis/jarvis_tools/read_code.py +1736 -35
  149. jarvis/jarvis_tools/read_symbols.py +140 -0
  150. jarvis/jarvis_tools/read_webpage.py +12 -13
  151. jarvis/jarvis_tools/registry.py +427 -200
  152. jarvis/jarvis_tools/retrieve_memory.py +20 -19
  153. jarvis/jarvis_tools/rewrite_file.py +72 -158
  154. jarvis/jarvis_tools/save_memory.py +3 -15
  155. jarvis/jarvis_tools/search_web.py +18 -18
  156. jarvis/jarvis_tools/sub_agent.py +36 -43
  157. jarvis/jarvis_tools/sub_code_agent.py +25 -26
  158. jarvis/jarvis_tools/virtual_tty.py +55 -33
  159. jarvis/jarvis_utils/clipboard.py +7 -10
  160. jarvis/jarvis_utils/config.py +232 -45
  161. jarvis/jarvis_utils/embedding.py +8 -5
  162. jarvis/jarvis_utils/fzf.py +8 -8
  163. jarvis/jarvis_utils/git_utils.py +225 -36
  164. jarvis/jarvis_utils/globals.py +3 -3
  165. jarvis/jarvis_utils/http.py +1 -1
  166. jarvis/jarvis_utils/input.py +99 -48
  167. jarvis/jarvis_utils/jsonnet_compat.py +465 -0
  168. jarvis/jarvis_utils/methodology.py +52 -48
  169. jarvis/jarvis_utils/utils.py +819 -491
  170. jarvis_ai_assistant-0.7.6.dist-info/METADATA +600 -0
  171. jarvis_ai_assistant-0.7.6.dist-info/RECORD +218 -0
  172. {jarvis_ai_assistant-0.3.30.dist-info → jarvis_ai_assistant-0.7.6.dist-info}/entry_points.txt +4 -0
  173. jarvis/jarvis_agent/config.py +0 -92
  174. jarvis/jarvis_agent/edit_file_handler.py +0 -296
  175. jarvis/jarvis_platform/ai8.py +0 -332
  176. jarvis/jarvis_tools/ask_user.py +0 -54
  177. jarvis_ai_assistant-0.3.30.dist-info/METADATA +0 -381
  178. jarvis_ai_assistant-0.3.30.dist-info/RECORD +0 -137
  179. {jarvis_ai_assistant-0.3.30.dist-info → jarvis_ai_assistant-0.7.6.dist-info}/WHEEL +0 -0
  180. {jarvis_ai_assistant-0.3.30.dist-info → jarvis_ai_assistant-0.7.6.dist-info}/licenses/LICENSE +0 -0
  181. {jarvis_ai_assistant-0.3.30.dist-info → jarvis_ai_assistant-0.7.6.dist-info}/top_level.txt +0 -0
@@ -4,7 +4,6 @@ import tempfile
4
4
  from pathlib import Path
5
5
  from typing import Any, Dict, List
6
6
 
7
- from jarvis.jarvis_utils.output import OutputType, PrettyOutput
8
7
 
9
8
 
10
9
  class ScriptTool:
@@ -14,18 +13,13 @@ class ScriptTool:
14
13
  """
15
14
 
16
15
  name = "execute_script"
17
- description = (
18
- "执行脚本并返回结果,支持任意解释器。"
19
- + "注意:由于模型上下文长度限制,请避免在脚本中输出大量信息,应该使用rg过滤输出。"
20
- + "与virtual_tty不同,此工具会创建一个临时的脚本文件,并使用脚本命令执行脚本,不具备交互式操作的能力,"
21
- + "适用于需要执行脚本并获取结果的场景。不适合需要交互式操作的场景(如:ssh连接、sftp传输、gdb/dlv调试等)。"
22
- )
16
+ description = "执行脚本并返回结果,支持任意解释器。建议使用rg过滤大量输出。"
23
17
  parameters = {
24
18
  "type": "object",
25
19
  "properties": {
26
20
  "interpreter": {
27
21
  "type": "string",
28
- "description": "脚本解释器: 如bash, python3, expect, perl, ruby等任意解释器。如需直接执行shell命令, 可使用bash作为解释器",
22
+ "description": "脚本解释器(如bashpython3perl等)。执行shell命令可使用bash",
29
23
  },
30
24
  "script_content": {"type": "string", "description": "要执行的脚本内容"},
31
25
  },
@@ -115,8 +109,72 @@ class ScriptTool:
115
109
  f"script -q -c '{interpreter} {script_path}' {output_file}"
116
110
  )
117
111
 
118
- # Execute command and capture return code
119
- os.system(tee_command)
112
+ # Execute command with optional timeout in non-interactive mode
113
+ from jarvis.jarvis_utils.config import get_script_execution_timeout, is_non_interactive
114
+ import subprocess
115
+
116
+ timed_out = False
117
+ if is_non_interactive():
118
+ proc = None
119
+ try:
120
+ proc = subprocess.Popen(tee_command, shell=True)
121
+ try:
122
+ proc.wait(timeout=get_script_execution_timeout())
123
+ except subprocess.TimeoutExpired:
124
+ timed_out = True
125
+ try:
126
+ proc.terminate()
127
+ proc.wait(timeout=2)
128
+ except subprocess.TimeoutExpired:
129
+ try:
130
+ proc.kill()
131
+ proc.wait()
132
+ except Exception:
133
+ pass
134
+ except Exception:
135
+ try:
136
+ proc.kill()
137
+ proc.wait()
138
+ except Exception:
139
+ pass
140
+ except Exception as e:
141
+ # 确保进程被关闭
142
+ if proc is not None:
143
+ try:
144
+ proc.terminate()
145
+ proc.wait(timeout=1)
146
+ except Exception:
147
+ try:
148
+ proc.kill()
149
+ proc.wait()
150
+ except Exception:
151
+ pass
152
+ print(f"❌ {str(e)}")
153
+ # Attempt to read any partial output if available
154
+ try:
155
+ output = self.get_display_output(output_file)
156
+ except Exception as ee:
157
+ output = f"读取输出文件失败: {str(ee)}"
158
+ return {
159
+ "success": False,
160
+ "stdout": output,
161
+ "stderr": f"执行脚本失败: {str(e)}",
162
+ }
163
+ finally:
164
+ # 确保进程和文件描述符被关闭
165
+ if proc is not None:
166
+ try:
167
+ if proc.stdin:
168
+ proc.stdin.close()
169
+ if proc.stdout:
170
+ proc.stdout.close()
171
+ if proc.stderr:
172
+ proc.stderr.close()
173
+ except Exception:
174
+ pass
175
+ else:
176
+ # Execute command and capture return code
177
+ os.system(tee_command)
120
178
 
121
179
  # Read and process output file
122
180
  try:
@@ -125,12 +183,19 @@ class ScriptTool:
125
183
  except Exception as e:
126
184
  output = f"读取输出文件失败: {str(e)}"
127
185
 
128
- # Return successful result
129
- return {
130
- "success": True,
131
- "stdout": output,
132
- "stderr": "",
133
- }
186
+ # Return result (handle timeout in non-interactive mode)
187
+ if is_non_interactive() and timed_out:
188
+ return {
189
+ "success": False,
190
+ "stdout": output,
191
+ "stderr": f"执行超时(超过{get_script_execution_timeout()}秒),进程已被终止(非交互模式)。",
192
+ }
193
+ else:
194
+ return {
195
+ "success": True,
196
+ "stdout": output,
197
+ "stderr": "",
198
+ }
134
199
 
135
200
  finally:
136
201
  # Clean up temporary files
@@ -138,7 +203,7 @@ class ScriptTool:
138
203
  Path(output_file).unlink(missing_ok=True)
139
204
 
140
205
  except Exception as e:
141
- PrettyOutput.print(str(e), OutputType.ERROR)
206
+ print(f"❌ {str(e)}")
142
207
  return {"success": False, "stdout": "", "stderr": str(e)}
143
208
 
144
209
  def execute(self, args: Dict) -> Dict[str, Any]:
@@ -166,14 +231,7 @@ class ScriptTool:
166
231
  return self._execute_script_with_interpreter(interpreter, script_content)
167
232
 
168
233
  except Exception as e:
169
- PrettyOutput.print(str(e), OutputType.ERROR)
234
+ print(f"❌ {str(e)}")
170
235
  return {"success": False, "stdout": "", "stderr": str(e)}
171
236
 
172
237
 
173
- if __name__ == "__main__":
174
- script_tool = ScriptTool()
175
- PrettyOutput.print(
176
- script_tool.get_display_output("/home/wangmaobin/code/Jarvis/a.txt"),
177
- OutputType.CODE,
178
- lang="text",
179
- )
@@ -4,14 +4,11 @@ from typing import Any, Dict
4
4
 
5
5
 
6
6
  from jarvis.jarvis_platform.registry import PlatformRegistry
7
- from jarvis.jarvis_utils.output import OutputType, PrettyOutput
8
7
 
9
8
 
10
9
  class FileAnalyzerTool:
11
10
  name = "file_analyzer"
12
- description = (
13
- """分析文件内容并提取关键信息。支持的文件:文本文件、word文档、pdf文件、图片"""
14
- )
11
+ description = "分析文件内容并提取关键信息。支持文本、word、pdf、图片等格式。"
15
12
  parameters = {
16
13
  "type": "object",
17
14
  "properties": {
@@ -54,9 +51,9 @@ class FileAnalyzerTool:
54
51
  else:
55
52
  missing_files.append(file_path)
56
53
  if missing_files:
57
- PrettyOutput.print(
58
- "以下文件不存在:\n" + "\n".join(f" - {p}" for p in missing_files),
59
- OutputType.WARNING,
54
+ missing_list = '\n'.join(f' - {p}' for p in missing_files)
55
+ print(
56
+ f"⚠️ 以下文件不存在:\n{missing_list}"
60
57
  )
61
58
 
62
59
  if not valid_files:
@@ -83,7 +80,7 @@ class FileAnalyzerTool:
83
80
  try:
84
81
  upload_result = platform.upload_files(valid_files)
85
82
  if not upload_result:
86
- PrettyOutput.print("文件上传失败", OutputType.ERROR)
83
+ print("文件上传失败")
87
84
  return {
88
85
  "success": False,
89
86
  "stdout": "",
@@ -91,7 +88,7 @@ class FileAnalyzerTool:
91
88
  }
92
89
 
93
90
  except Exception as e:
94
- PrettyOutput.print(f"文件上传失败: {str(e)}", OutputType.ERROR)
91
+ print(f"文件上传失败: {str(e)}")
95
92
  return {
96
93
  "success": False,
97
94
  "stdout": "",
@@ -3,19 +3,11 @@ from pathlib import Path
3
3
  from typing import Any, Dict
4
4
 
5
5
  from jarvis.jarvis_utils.config import get_data_dir
6
- from jarvis.jarvis_utils.output import OutputType, PrettyOutput
7
6
 
8
7
 
9
8
  class generate_new_tool:
10
9
  name = "generate_new_tool"
11
- description = """
12
- 生成并注册新的Jarvis工具。该工具会在用户数据目录下创建新的工具文件,
13
- 并自动注册到当前的工具注册表中。适用场景:1. 需要创建新的自定义工具;
14
- 2. 扩展Jarvis功能;3. 自动化重复性操作;4. 封装特定领域的功能。
15
- 重要提示:
16
- 1. `tool_name` 参数必须与 `tool_code` 中定义的 `name` 属性完全一致。
17
- 2. 在编写工具代码时,应尽量将工具执行的过程和结果打印出来,方便追踪工具的执行状态。
18
- """
10
+ description = "生成并注册新的Jarvis工具。在用户数据目录下创建工具文件并自动注册。注意:tool_name必须与tool_code中的name属性完全一致。"
19
11
 
20
12
  parameters = {
21
13
  "type": "object",
@@ -45,8 +37,8 @@ class generate_new_tool:
45
37
  tools_dir.mkdir(parents=True, exist_ok=True)
46
38
  return True
47
39
  except Exception as e:
48
- PrettyOutput.print(
49
- f"无法创建工具目录 {tools_dir}: {e}", OutputType.ERROR
40
+ print(
41
+ f"无法创建工具目录 {tools_dir}: {e}"
50
42
  )
51
43
  return False
52
44
 
@@ -129,9 +121,8 @@ class generate_new_tool:
129
121
  success_message += "\n已成功注册到当前会话的工具注册表中"
130
122
  else:
131
123
  # 注册失败,删除已创建的文件
132
- PrettyOutput.print(
133
- f"注册工具 '{tool_name}' 失败,正在删除文件...",
134
- OutputType.WARNING,
124
+ print(
125
+ f"⚠️ 注册工具 '{tool_name}' 失败,正在删除文件..."
135
126
  )
136
127
  if tool_file_path.exists():
137
128
  tool_file_path.unlink()
@@ -141,8 +132,8 @@ class generate_new_tool:
141
132
  "stderr": "工具文件已生成,但注册失败。文件已被删除。",
142
133
  }
143
134
  else:
144
- PrettyOutput.print(
145
- "未找到工具注册表,无法自动注册工具", OutputType.WARNING
135
+ print(
136
+ "⚠️ 未找到工具注册表,无法自动注册工具"
146
137
  )
147
138
  success_message += "\n注册到当前会话失败,可能需要重新启动Jarvis"
148
139
 
@@ -173,7 +164,9 @@ class generate_new_tool:
173
164
  __import__(pkg)
174
165
  except ImportError:
175
166
 
176
- import subprocess, sys, os
167
+ import subprocess
168
+ import sys
169
+ import os
177
170
  from shutil import which as _which
178
171
  # 优先使用 uv 安装(先查 venv 内 uv,再查 PATH 中 uv),否则回退到 python -m pip
179
172
  if sys.platform == "win32":
@@ -189,14 +182,14 @@ class generate_new_tool:
189
182
 
190
183
 
191
184
  except Exception as e:
192
- PrettyOutput.print(f"依赖检查/安装失败: {str(e)}", OutputType.WARNING)
185
+ print(f"⚠️ 依赖检查/安装失败: {str(e)}")
193
186
 
194
187
  return {"success": True, "stdout": success_message, "stderr": ""}
195
188
 
196
189
  except Exception as e:
197
190
  # 如果发生异常,删除已创建的文件并返回失败响应
198
191
  error_msg = f"生成工具失败: {str(e)}"
199
- PrettyOutput.print(error_msg, OutputType.ERROR)
192
+ print(f"❌ {error_msg}")
200
193
 
201
194
  # 删除已创建的文件
202
195
  if tool_file_path and tool_file_path.exists():
@@ -205,8 +198,8 @@ class generate_new_tool:
205
198
  tool_file_path.unlink()
206
199
 
207
200
  except Exception as delete_error:
208
- PrettyOutput.print(
209
- f"删除文件失败: {str(delete_error)}", OutputType.ERROR
201
+ print(
202
+ f"删除文件失败: {str(delete_error)}"
210
203
  )
211
204
 
212
205
  return {"success": False, "stdout": "", "stderr": error_msg}