jarvis-ai-assistant 0.7.0__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 (159) hide show
  1. jarvis/__init__.py +1 -1
  2. jarvis/jarvis_agent/__init__.py +243 -139
  3. jarvis/jarvis_agent/agent_manager.py +5 -10
  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 +265 -15
  8. jarvis/jarvis_agent/file_methodology_manager.py +3 -4
  9. jarvis/jarvis_agent/jarvis.py +113 -98
  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 +6 -12
  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 +77 -14
  27. jarvis/jarvis_agent/session_manager.py +2 -3
  28. jarvis/jarvis_agent/share_manager.py +12 -21
  29. jarvis/jarvis_agent/shell_input_handler.py +1 -2
  30. jarvis/jarvis_agent/task_analyzer.py +26 -4
  31. jarvis/jarvis_agent/task_manager.py +11 -27
  32. jarvis/jarvis_agent/tool_executor.py +2 -3
  33. jarvis/jarvis_agent/tool_share_manager.py +12 -24
  34. jarvis/jarvis_agent/web_server.py +55 -20
  35. jarvis/jarvis_c2rust/__init__.py +5 -5
  36. jarvis/jarvis_c2rust/cli.py +461 -499
  37. jarvis/jarvis_c2rust/collector.py +45 -53
  38. jarvis/jarvis_c2rust/constants.py +26 -0
  39. jarvis/jarvis_c2rust/library_replacer.py +264 -132
  40. jarvis/jarvis_c2rust/llm_module_agent.py +162 -190
  41. jarvis/jarvis_c2rust/loaders.py +207 -0
  42. jarvis/jarvis_c2rust/models.py +28 -0
  43. jarvis/jarvis_c2rust/optimizer.py +1592 -395
  44. jarvis/jarvis_c2rust/transpiler.py +1722 -1064
  45. jarvis/jarvis_c2rust/utils.py +385 -0
  46. jarvis/jarvis_code_agent/build_validation_config.py +2 -3
  47. jarvis/jarvis_code_agent/code_agent.py +394 -320
  48. jarvis/jarvis_code_agent/code_analyzer/__init__.py +3 -0
  49. jarvis/jarvis_code_agent/code_analyzer/build_validator/base.py +4 -0
  50. jarvis/jarvis_code_agent/code_analyzer/build_validator/cmake.py +17 -2
  51. jarvis/jarvis_code_agent/code_analyzer/build_validator/fallback.py +3 -0
  52. jarvis/jarvis_code_agent/code_analyzer/build_validator/go.py +36 -4
  53. jarvis/jarvis_code_agent/code_analyzer/build_validator/java_gradle.py +9 -0
  54. jarvis/jarvis_code_agent/code_analyzer/build_validator/java_maven.py +9 -0
  55. jarvis/jarvis_code_agent/code_analyzer/build_validator/makefile.py +12 -1
  56. jarvis/jarvis_code_agent/code_analyzer/build_validator/nodejs.py +22 -5
  57. jarvis/jarvis_code_agent/code_analyzer/build_validator/python.py +57 -32
  58. jarvis/jarvis_code_agent/code_analyzer/build_validator/rust.py +62 -6
  59. jarvis/jarvis_code_agent/code_analyzer/build_validator/validator.py +8 -9
  60. jarvis/jarvis_code_agent/code_analyzer/context_manager.py +290 -5
  61. jarvis/jarvis_code_agent/code_analyzer/language_support.py +21 -0
  62. jarvis/jarvis_code_agent/code_analyzer/languages/__init__.py +21 -3
  63. jarvis/jarvis_code_agent/code_analyzer/languages/c_cpp_language.py +72 -4
  64. jarvis/jarvis_code_agent/code_analyzer/languages/go_language.py +35 -3
  65. jarvis/jarvis_code_agent/code_analyzer/languages/java_language.py +212 -0
  66. jarvis/jarvis_code_agent/code_analyzer/languages/javascript_language.py +254 -0
  67. jarvis/jarvis_code_agent/code_analyzer/languages/python_language.py +52 -2
  68. jarvis/jarvis_code_agent/code_analyzer/languages/rust_language.py +73 -1
  69. jarvis/jarvis_code_agent/code_analyzer/languages/typescript_language.py +280 -0
  70. jarvis/jarvis_code_agent/code_analyzer/llm_context_recommender.py +306 -152
  71. jarvis/jarvis_code_agent/code_analyzer/structured_code.py +556 -0
  72. jarvis/jarvis_code_agent/code_analyzer/symbol_extractor.py +193 -18
  73. jarvis/jarvis_code_agent/code_analyzer/tree_sitter_extractor.py +18 -8
  74. jarvis/jarvis_code_agent/lint.py +258 -27
  75. jarvis/jarvis_code_agent/utils.py +0 -1
  76. jarvis/jarvis_code_analysis/code_review.py +19 -24
  77. jarvis/jarvis_data/config_schema.json +53 -26
  78. jarvis/jarvis_git_squash/main.py +4 -5
  79. jarvis/jarvis_git_utils/git_commiter.py +44 -49
  80. jarvis/jarvis_mcp/sse_mcp_client.py +20 -27
  81. jarvis/jarvis_mcp/stdio_mcp_client.py +11 -12
  82. jarvis/jarvis_mcp/streamable_mcp_client.py +15 -14
  83. jarvis/jarvis_memory_organizer/memory_organizer.py +55 -74
  84. jarvis/jarvis_methodology/main.py +32 -48
  85. jarvis/jarvis_multi_agent/__init__.py +79 -61
  86. jarvis/jarvis_multi_agent/main.py +3 -7
  87. jarvis/jarvis_platform/base.py +469 -199
  88. jarvis/jarvis_platform/human.py +7 -8
  89. jarvis/jarvis_platform/kimi.py +30 -36
  90. jarvis/jarvis_platform/openai.py +65 -27
  91. jarvis/jarvis_platform/registry.py +26 -10
  92. jarvis/jarvis_platform/tongyi.py +24 -25
  93. jarvis/jarvis_platform/yuanbao.py +31 -42
  94. jarvis/jarvis_platform_manager/main.py +66 -77
  95. jarvis/jarvis_platform_manager/service.py +8 -13
  96. jarvis/jarvis_rag/cli.py +49 -51
  97. jarvis/jarvis_rag/embedding_manager.py +13 -18
  98. jarvis/jarvis_rag/llm_interface.py +8 -9
  99. jarvis/jarvis_rag/query_rewriter.py +10 -21
  100. jarvis/jarvis_rag/rag_pipeline.py +24 -27
  101. jarvis/jarvis_rag/reranker.py +4 -5
  102. jarvis/jarvis_rag/retriever.py +28 -30
  103. jarvis/jarvis_sec/__init__.py +220 -3520
  104. jarvis/jarvis_sec/agents.py +143 -0
  105. jarvis/jarvis_sec/analysis.py +276 -0
  106. jarvis/jarvis_sec/cli.py +29 -6
  107. jarvis/jarvis_sec/clustering.py +1439 -0
  108. jarvis/jarvis_sec/file_manager.py +427 -0
  109. jarvis/jarvis_sec/parsers.py +73 -0
  110. jarvis/jarvis_sec/prompts.py +268 -0
  111. jarvis/jarvis_sec/report.py +83 -4
  112. jarvis/jarvis_sec/review.py +453 -0
  113. jarvis/jarvis_sec/utils.py +499 -0
  114. jarvis/jarvis_sec/verification.py +848 -0
  115. jarvis/jarvis_sec/workflow.py +7 -0
  116. jarvis/jarvis_smart_shell/main.py +38 -87
  117. jarvis/jarvis_stats/cli.py +1 -1
  118. jarvis/jarvis_stats/stats.py +7 -7
  119. jarvis/jarvis_stats/storage.py +15 -21
  120. jarvis/jarvis_tools/clear_memory.py +3 -20
  121. jarvis/jarvis_tools/cli/main.py +20 -23
  122. jarvis/jarvis_tools/edit_file.py +1066 -0
  123. jarvis/jarvis_tools/execute_script.py +42 -21
  124. jarvis/jarvis_tools/file_analyzer.py +6 -9
  125. jarvis/jarvis_tools/generate_new_tool.py +11 -20
  126. jarvis/jarvis_tools/lsp_client.py +1552 -0
  127. jarvis/jarvis_tools/methodology.py +2 -3
  128. jarvis/jarvis_tools/read_code.py +1525 -87
  129. jarvis/jarvis_tools/read_symbols.py +2 -3
  130. jarvis/jarvis_tools/read_webpage.py +7 -10
  131. jarvis/jarvis_tools/registry.py +370 -181
  132. jarvis/jarvis_tools/retrieve_memory.py +20 -19
  133. jarvis/jarvis_tools/rewrite_file.py +105 -0
  134. jarvis/jarvis_tools/save_memory.py +3 -15
  135. jarvis/jarvis_tools/search_web.py +3 -7
  136. jarvis/jarvis_tools/sub_agent.py +17 -6
  137. jarvis/jarvis_tools/sub_code_agent.py +14 -16
  138. jarvis/jarvis_tools/virtual_tty.py +54 -32
  139. jarvis/jarvis_utils/clipboard.py +7 -10
  140. jarvis/jarvis_utils/config.py +98 -63
  141. jarvis/jarvis_utils/embedding.py +5 -5
  142. jarvis/jarvis_utils/fzf.py +8 -8
  143. jarvis/jarvis_utils/git_utils.py +81 -67
  144. jarvis/jarvis_utils/input.py +24 -49
  145. jarvis/jarvis_utils/jsonnet_compat.py +465 -0
  146. jarvis/jarvis_utils/methodology.py +33 -35
  147. jarvis/jarvis_utils/utils.py +245 -202
  148. {jarvis_ai_assistant-0.7.0.dist-info → jarvis_ai_assistant-0.7.6.dist-info}/METADATA +205 -70
  149. jarvis_ai_assistant-0.7.6.dist-info/RECORD +218 -0
  150. jarvis/jarvis_agent/edit_file_handler.py +0 -584
  151. jarvis/jarvis_agent/rewrite_file_handler.py +0 -141
  152. jarvis/jarvis_agent/task_planner.py +0 -496
  153. jarvis/jarvis_platform/ai8.py +0 -332
  154. jarvis/jarvis_tools/ask_user.py +0 -54
  155. jarvis_ai_assistant-0.7.0.dist-info/RECORD +0 -192
  156. {jarvis_ai_assistant-0.7.0.dist-info → jarvis_ai_assistant-0.7.6.dist-info}/WHEEL +0 -0
  157. {jarvis_ai_assistant-0.7.0.dist-info → jarvis_ai_assistant-0.7.6.dist-info}/entry_points.txt +0 -0
  158. {jarvis_ai_assistant-0.7.0.dist-info → jarvis_ai_assistant-0.7.6.dist-info}/licenses/LICENSE +0 -0
  159. {jarvis_ai_assistant-0.7.0.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,19 +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
- + "在非交互模式(JARVIS_NON_INTERACTIVE=true)下:脚本执行时间限制为5分钟,超时将被终止并返回超时信息;用户无法与命令交互,请不要执行需要交互的命令。"
23
- )
16
+ description = "执行脚本并返回结果,支持任意解释器。建议使用rg过滤大量输出。"
24
17
  parameters = {
25
18
  "type": "object",
26
19
  "properties": {
27
20
  "interpreter": {
28
21
  "type": "string",
29
- "description": "脚本解释器: 如bash, python3, expect, perl, ruby等任意解释器。如需直接执行shell命令, 可使用bash作为解释器",
22
+ "description": "脚本解释器(如bashpython3perl等)。执行shell命令可使用bash",
30
23
  },
31
24
  "script_content": {"type": "string", "description": "要执行的脚本内容"},
32
25
  },
@@ -122,6 +115,7 @@ class ScriptTool:
122
115
 
123
116
  timed_out = False
124
117
  if is_non_interactive():
118
+ proc = None
125
119
  try:
126
120
  proc = subprocess.Popen(tee_command, shell=True)
127
121
  try:
@@ -129,11 +123,33 @@ class ScriptTool:
129
123
  except subprocess.TimeoutExpired:
130
124
  timed_out = True
131
125
  try:
132
- proc.kill()
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
133
134
  except Exception:
134
- pass
135
+ try:
136
+ proc.kill()
137
+ proc.wait()
138
+ except Exception:
139
+ pass
135
140
  except Exception as e:
136
- PrettyOutput.print(str(e), OutputType.ERROR)
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)}")
137
153
  # Attempt to read any partial output if available
138
154
  try:
139
155
  output = self.get_display_output(output_file)
@@ -144,6 +160,18 @@ class ScriptTool:
144
160
  "stdout": output,
145
161
  "stderr": f"执行脚本失败: {str(e)}",
146
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
147
175
  else:
148
176
  # Execute command and capture return code
149
177
  os.system(tee_command)
@@ -175,7 +203,7 @@ class ScriptTool:
175
203
  Path(output_file).unlink(missing_ok=True)
176
204
 
177
205
  except Exception as e:
178
- PrettyOutput.print(str(e), OutputType.ERROR)
206
+ print(f"❌ {str(e)}")
179
207
  return {"success": False, "stdout": "", "stderr": str(e)}
180
208
 
181
209
  def execute(self, args: Dict) -> Dict[str, Any]:
@@ -203,14 +231,7 @@ class ScriptTool:
203
231
  return self._execute_script_with_interpreter(interpreter, script_content)
204
232
 
205
233
  except Exception as e:
206
- PrettyOutput.print(str(e), OutputType.ERROR)
234
+ print(f"❌ {str(e)}")
207
235
  return {"success": False, "stdout": "", "stderr": str(e)}
208
236
 
209
237
 
210
- if __name__ == "__main__":
211
- script_tool = ScriptTool()
212
- PrettyOutput.print(
213
- script_tool.get_display_output("/path/to/a.txt"),
214
- OutputType.CODE,
215
- lang="text",
216
- )
@@ -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
 
@@ -191,14 +182,14 @@ class generate_new_tool:
191
182
 
192
183
 
193
184
  except Exception as e:
194
- PrettyOutput.print(f"依赖检查/安装失败: {str(e)}", OutputType.WARNING)
185
+ print(f"⚠️ 依赖检查/安装失败: {str(e)}")
195
186
 
196
187
  return {"success": True, "stdout": success_message, "stderr": ""}
197
188
 
198
189
  except Exception as e:
199
190
  # 如果发生异常,删除已创建的文件并返回失败响应
200
191
  error_msg = f"生成工具失败: {str(e)}"
201
- PrettyOutput.print(error_msg, OutputType.ERROR)
192
+ print(f"❌ {error_msg}")
202
193
 
203
194
  # 删除已创建的文件
204
195
  if tool_file_path and tool_file_path.exists():
@@ -207,8 +198,8 @@ class generate_new_tool:
207
198
  tool_file_path.unlink()
208
199
 
209
200
  except Exception as delete_error:
210
- PrettyOutput.print(
211
- f"删除文件失败: {str(delete_error)}", OutputType.ERROR
201
+ print(
202
+ f"删除文件失败: {str(delete_error)}"
212
203
  )
213
204
 
214
205
  return {"success": False, "stdout": "", "stderr": error_msg}