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
@@ -10,7 +10,6 @@ from langchain.text_splitter import RecursiveCharacterTextSplitter
10
10
  from rank_bm25 import BM25Okapi # type: ignore
11
11
 
12
12
  from .embedding_manager import EmbeddingManager
13
- from jarvis.jarvis_utils.output import OutputType, PrettyOutput
14
13
 
15
14
 
16
15
  class ChromaRetriever:
@@ -42,9 +41,8 @@ class ChromaRetriever:
42
41
  self.collection = self.client.get_or_create_collection(
43
42
  name=self.collection_name
44
43
  )
45
- PrettyOutput.print(
46
- f"ChromaDB 客户端已在 '{db_path}' 初始化,集合为 '{collection_name}'。",
47
- OutputType.SUCCESS,
44
+ print(
45
+ f"ChromaDB 客户端已在 '{db_path}' 初始化,集合为 '{collection_name}'。"
48
46
  )
49
47
 
50
48
  # BM25索引设置
@@ -58,15 +56,15 @@ class ChromaRetriever:
58
56
  def _load_or_initialize_bm25(self):
59
57
  """从磁盘加载BM25索引或初始化一个新索引。"""
60
58
  if os.path.exists(self.bm25_index_path):
61
- PrettyOutput.print("正在加载现有的 BM25 索引...", OutputType.INFO)
59
+ print("ℹ️ 正在加载现有的 BM25 索引...")
62
60
  with open(self.bm25_index_path, "rb") as f:
63
61
  data = pickle.load(f)
64
62
  self.bm25_corpus = data["corpus"]
65
63
  self.bm25_index = BM25Okapi(self.bm25_corpus)
66
- PrettyOutput.print("BM25 索引加载成功。", OutputType.SUCCESS)
64
+ print("BM25 索引加载成功。")
67
65
  else:
68
- PrettyOutput.print(
69
- "未找到 BM25 索引,将初始化一个新的。", OutputType.WARNING
66
+ print(
67
+ "⚠️ 未找到 BM25 索引,将初始化一个新的。"
70
68
  )
71
69
  self.bm25_corpus = []
72
70
  self.bm25_index = None
@@ -74,10 +72,10 @@ class ChromaRetriever:
74
72
  def _save_bm25_index(self):
75
73
  """将BM25索引保存到磁盘。"""
76
74
  if self.bm25_index:
77
- PrettyOutput.print("正在保存 BM25 索引...", OutputType.INFO)
75
+ print("ℹ️ 正在保存 BM25 索引...")
78
76
  with open(self.bm25_index_path, "wb") as f:
79
77
  pickle.dump({"corpus": self.bm25_corpus, "index": self.bm25_index}, f)
80
- PrettyOutput.print("BM25 索引保存成功。", OutputType.SUCCESS)
78
+ print("BM25 索引保存成功。")
81
79
 
82
80
  def _load_manifest(self) -> Dict[str, Dict[str, Any]]:
83
81
  """加载已索引文件清单,用于变更检测。"""
@@ -97,7 +95,7 @@ class ChromaRetriever:
97
95
  with open(self.manifest_path, "w", encoding="utf-8") as f:
98
96
  json.dump(manifest, f, ensure_ascii=False, indent=2)
99
97
  except Exception as e:
100
- PrettyOutput.print(f"保存索引清单失败: {e}", OutputType.WARNING)
98
+ print(f"⚠️ 保存索引清单失败: {e}")
101
99
 
102
100
  def _compute_md5(
103
101
  self, file_path: str, chunk_size: int = 1024 * 1024
@@ -136,8 +134,8 @@ class ChromaRetriever:
136
134
  continue
137
135
  if updated > 0:
138
136
  self._save_manifest(manifest)
139
- PrettyOutput.print(
140
- f"已更新索引清单,记录 {updated} 个源文件状态。", OutputType.INFO
137
+ print(
138
+ f"ℹ️ 已更新索引清单,记录 {updated} 个源文件状态。"
141
139
  )
142
140
 
143
141
  def _detect_changed_or_deleted(self) -> Dict[str, List[str]]:
@@ -203,7 +201,8 @@ class ChromaRetriever:
203
201
  lines.append(
204
202
  "提示:请使用 'jarvis-rag add <路径>' 重新索引相关文件,以更新向量库与BM25索引。"
205
203
  )
206
- PrettyOutput.print("\n".join(lines), OutputType.WARNING)
204
+ joined_lines = '\n'.join(lines)
205
+ print(f"⚠️ {joined_lines}")
207
206
 
208
207
  def detect_index_changes(self) -> Dict[str, List[str]]:
209
208
  """
@@ -225,8 +224,8 @@ class ChromaRetriever:
225
224
  removed += 1
226
225
  if removed > 0:
227
226
  self._save_manifest(manifest)
228
- PrettyOutput.print(
229
- f"已从索引清单中移除 {removed} 个已删除的源文件记录。", OutputType.INFO
227
+ print(
228
+ f"ℹ️ 已从索引清单中移除 {removed} 个已删除的源文件记录。"
230
229
  )
231
230
 
232
231
  def update_index_for_changes(self, changed: List[str], deleted: List[str]) -> None:
@@ -254,7 +253,8 @@ class ChromaRetriever:
254
253
  except Exception as e:
255
254
  delete_errors.append(f"删除源 '{src}' 时出错: {e}")
256
255
  if delete_errors:
257
- PrettyOutput.print("\n".join(delete_errors), OutputType.WARNING)
256
+ joined_errors = '\n'.join(delete_errors)
257
+ print(f"⚠️ {joined_errors}")
258
258
 
259
259
  # 再处理变更(重建)
260
260
  docs_to_add: List[Document] = []
@@ -275,14 +275,15 @@ class ChromaRetriever:
275
275
  except Exception as e:
276
276
  rebuild_errors.append(f"重建源 '{src}' 内容时出错: {e}")
277
277
  if rebuild_errors:
278
- PrettyOutput.print("\n".join(rebuild_errors), OutputType.WARNING)
278
+ joined_errors = '\n'.join(rebuild_errors)
279
+ print(f"⚠️ {joined_errors}")
279
280
 
280
281
  if docs_to_add:
281
282
  try:
282
283
  # 复用现有拆分与嵌入逻辑
283
284
  self.add_documents(docs_to_add)
284
285
  except Exception as e:
285
- PrettyOutput.print(f"添加变更文档到索引时出错: {e}", OutputType.ERROR)
286
+ print(f"添加变更文档到索引时出错: {e}")
286
287
 
287
288
  # 重建BM25索引,确保删除后的语料被清理
288
289
  try:
@@ -292,7 +293,7 @@ class ChromaRetriever:
292
293
  self.bm25_index = BM25Okapi(self.bm25_corpus) if self.bm25_corpus else None
293
294
  self._save_bm25_index()
294
295
  except Exception as e:
295
- PrettyOutput.print(f"重建BM25索引失败: {e}", OutputType.WARNING)
296
+ print(f"⚠️ 重建BM25索引失败: {e}")
296
297
 
297
298
  # 更新manifest:变更文件更新状态;删除文件从清单中移除
298
299
  try:
@@ -301,11 +302,10 @@ class ChromaRetriever:
301
302
  if deleted:
302
303
  self._remove_sources_from_manifest(deleted)
303
304
  except Exception as e:
304
- PrettyOutput.print(f"更新索引清单时出错: {e}", OutputType.WARNING)
305
+ print(f"⚠️ 更新索引清单时出错: {e}")
305
306
 
306
- PrettyOutput.print(
307
- f"索引已更新:变更 {len(changed)} 个,删除 {len(deleted)} 个。",
308
- OutputType.SUCCESS,
307
+ print(
308
+ f"索引已更新:变更 {len(changed)} 个,删除 {len(deleted)} 个。"
309
309
  )
310
310
 
311
311
  def add_documents(
@@ -319,9 +319,8 @@ class ChromaRetriever:
319
319
  )
320
320
  chunks = text_splitter.split_documents(documents)
321
321
 
322
- PrettyOutput.print(
323
- f"已将 {len(documents)} 个文档拆分为 {len(chunks)} 个块。",
324
- OutputType.INFO,
322
+ print(
323
+ f"ℹ️ 已将 {len(documents)} 个文档拆分为 {len(chunks)} 个块。"
325
324
  )
326
325
 
327
326
  if not chunks:
@@ -341,9 +340,8 @@ class ChromaRetriever:
341
340
  documents=chunk_texts,
342
341
  metadatas=cast(Any, metadatas),
343
342
  )
344
- PrettyOutput.print(
345
- f"成功将 {len(chunks)} 个块添加到 ChromaDB 集合中。",
346
- OutputType.SUCCESS,
343
+ print(
344
+ f"成功将 {len(chunks)} 个块添加到 ChromaDB 集合中。"
347
345
  )
348
346
 
349
347
  # 更新并保存BM25索引