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
@@ -0,0 +1,140 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ 按需读取 symbols.jsonl 的工具。
4
+
5
+ 用途:
6
+ - 避免Agent直接完整读取体积较大的符号表文件;
7
+ - 通过提供符号表路径与符号名称列表,仅返回匹配的符号记录。
8
+
9
+ 参数:
10
+ - symbols_file (str): 符号表文件路径(.jsonl),或项目根目录/包含 .jarvis/c2rust 的目录
11
+ - symbols (List[str]): 需要读取的符号名称列表(支持 name 与 qualified_name 匹配)
12
+
13
+ 返回:
14
+ - success (bool)
15
+ - stdout (str): JSON文本,包含查询结果
16
+ - stderr (str)
17
+ """
18
+ import json
19
+ import os
20
+ from pathlib import Path
21
+ from typing import Any, Dict, List
22
+
23
+
24
+
25
+ class ReadSymbolsTool:
26
+ # 文件名必须与工具名一致,便于注册表自动加载
27
+ name = "read_symbols"
28
+ description = "从symbols.jsonl按需读取指定符号记录"
29
+ parameters = {
30
+ "type": "object",
31
+ "properties": {
32
+ "symbols_file": {
33
+ "type": "string",
34
+ "description": "符号表文件路径(.jsonl)。若为目录,则解析为 <dir>/.jarvis/c2rust/symbols.jsonl",
35
+ },
36
+ "symbols": {
37
+ "type": "array",
38
+ "items": {"type": "string"},
39
+ "description": "要检索的符号名称列表(支持 name 或 qualified_name 完全匹配)",
40
+ },
41
+ },
42
+ "required": ["symbols_file", "symbols"],
43
+ }
44
+
45
+ @staticmethod
46
+ def check() -> bool:
47
+ """
48
+ 检查工具是否可用。
49
+ 仅在 c2rust 环境中启用(通过环境变量 JARVIS_C2RUST_ENABLED 判断)。
50
+ """
51
+ return os.environ.get("JARVIS_C2RUST_ENABLED") == "1"
52
+
53
+ @staticmethod
54
+ def _resolve_symbols_jsonl_path(path_hint: str) -> Path:
55
+ """
56
+ 解析符号表路径:
57
+ - 若为目录,返回 <dir>/.jarvis/c2rust/symbols.jsonl
58
+ - 若为文件,直接返回
59
+ """
60
+ p = Path(os.path.abspath(os.path.expanduser(path_hint)))
61
+ if p.is_dir():
62
+ candidate = p / ".jarvis" / "c2rust" / "symbols.jsonl"
63
+ return candidate
64
+ return p
65
+
66
+ def execute(self, args: Dict[str, Any]) -> Dict[str, Any]:
67
+ try:
68
+ symbols_file_arg = args.get("symbols_file")
69
+ symbols_arg = args.get("symbols")
70
+
71
+ if not isinstance(symbols_file_arg, str) or not symbols_file_arg.strip():
72
+ return {"success": False, "stdout": "", "stderr": "缺少或无效的 symbols_file 参数"}
73
+
74
+ if not isinstance(symbols_arg, list) or not all(isinstance(s, str) for s in symbols_arg):
75
+ return {"success": False, "stdout": "", "stderr": "symbols 参数必须是字符串列表"}
76
+
77
+ symbols_path = self._resolve_symbols_jsonl_path(symbols_file_arg)
78
+ print(f"[read_symbols] Resolved symbols file path: {symbols_path}")
79
+ if not symbols_path.exists():
80
+ return {"success": False, "stdout": "", "stderr": f"符号表文件不存在: {symbols_path}"}
81
+ if not symbols_path.is_file():
82
+ return {"success": False, "stdout": "", "stderr": f"符号表路径不是文件: {symbols_path}"}
83
+
84
+ # 使用集合提升匹配效率;保持原请求顺序以便输出
85
+ requested: List[str] = [s.strip() for s in symbols_arg if s and s.strip()]
86
+ wanted_set = set(requested)
87
+ print(f"[read_symbols] Requested {len(wanted_set)} unique symbols.")
88
+
89
+ results: Dict[str, List[Dict[str, Any]]] = {s: [] for s in requested}
90
+
91
+ # 流式读取,避免载入整个大文件
92
+ with open(symbols_path, "r", encoding="utf-8") as f:
93
+ for line in f:
94
+ line = line.strip()
95
+ if not line:
96
+ continue
97
+ try:
98
+ obj = json.loads(line)
99
+ except Exception:
100
+ continue
101
+
102
+ name = obj.get("name") or ""
103
+ qname = obj.get("qualified_name") or ""
104
+
105
+ # 仅当命中请求的符号时才记录
106
+ if name in wanted_set:
107
+ results[name].append(obj)
108
+ if qname in wanted_set and qname != name:
109
+ results[qname].append(obj)
110
+
111
+ not_found = [s for s in requested if not results.get(s)]
112
+ if not_found:
113
+ print(f"[read_symbols] Symbols not found: {not_found}")
114
+ found_counts = {s: len(results.get(s, [])) for s in requested}
115
+
116
+ out_obj: Dict[str, Any] = {
117
+ "symbols_file": str(symbols_path),
118
+ "requested": requested,
119
+ "found_counts": found_counts,
120
+ "not_found": not_found,
121
+ "items": results,
122
+ }
123
+
124
+ stdout = json.dumps(out_obj, ensure_ascii=False, indent=2)
125
+ # 简要状态打印(不包含具体内容)
126
+ try:
127
+ status_lines = []
128
+ for s in requested:
129
+ cnt = found_counts.get(s, 0)
130
+ status_lines.append(f"[read_symbols] {s}: {cnt} 条匹配")
131
+ if status_lines:
132
+ print("\n".join(status_lines), end="\n")
133
+ except Exception:
134
+ pass
135
+
136
+ return {"success": True, "stdout": stdout, "stderr": ""}
137
+
138
+ except Exception as e:
139
+ print(f"❌ {str(e)}")
140
+ return {"success": False, "stdout": "", "stderr": f"读取符号表失败: {str(e)}"}
@@ -2,14 +2,13 @@
2
2
  from typing import Any, Dict
3
3
 
4
4
  from jarvis.jarvis_platform.registry import PlatformRegistry
5
- from jarvis.jarvis_utils.output import OutputType, PrettyOutput
6
5
  from jarvis.jarvis_utils.config import (
7
6
  get_web_search_platform_name,
8
7
  get_web_search_model_name,
9
8
  )
10
9
  from jarvis.jarvis_utils.http import get as http_get
11
10
  from markdownify import markdownify as md # type: ignore
12
- import requests
11
+ import requests # type: ignore[import-untyped]
13
12
 
14
13
 
15
14
  class WebpageTool:
@@ -58,10 +57,11 @@ class WebpageTool:
58
57
  2. 包含网页标题
59
58
  3. 根据用户需求提供准确、完整的信息"""
60
59
  response = model.chat_until_success(prompt) # type: ignore
61
- return {"success": True, "stdout": response, "stderr": ""}
60
+ if response and response.strip():
61
+ return {"success": True, "stdout": response, "stderr": ""}
62
62
 
63
- # 2) 然后尝试使用默认平台(normal)的 web 能力
64
- model = PlatformRegistry().get_normal_platform()
63
+ # 2) 然后尝试使用cheap平台的 web 能力(适用于网页读取等简单任务)
64
+ model = PlatformRegistry().get_cheap_platform()
65
65
  if model.support_web():
66
66
 
67
67
  model.set_web(True)
@@ -73,7 +73,8 @@ class WebpageTool:
73
73
  2. 包含网页标题
74
74
  3. 根据用户需求提供准确、完整的信息"""
75
75
  response = model.chat_until_success(prompt) # type: ignore
76
- return {"success": True, "stdout": response, "stderr": ""}
76
+ if response and response.strip():
77
+ return {"success": True, "stdout": response, "stderr": ""}
77
78
 
78
79
  # 3) 回退:使用 requests 抓取网页,再用模型分析
79
80
 
@@ -81,17 +82,14 @@ class WebpageTool:
81
82
  resp = http_get(url, timeout=10.0, allow_redirects=True)
82
83
  content_md = md(resp.text, strip=["script", "style"])
83
84
  except requests.exceptions.HTTPError as e:
84
- PrettyOutput.print(
85
- f"⚠️ HTTP错误 {e.response.status_code} 访问 {url}",
86
- OutputType.WARNING,
87
- )
85
+ print(f"⚠️ HTTP错误 {e.response.status_code} 访问 {url}")
88
86
  return {
89
87
  "success": False,
90
88
  "stdout": "",
91
89
  "stderr": f"HTTP错误:{e.response.status_code}",
92
90
  }
93
91
  except requests.exceptions.RequestException as e:
94
- PrettyOutput.print(f"⚠️ 请求错误: {e}", OutputType.WARNING)
92
+ print(f"⚠️ 请求错误: {e}")
95
93
  return {"success": False, "stdout": "", "stderr": f"请求错误:{e}"}
96
94
 
97
95
  if not content_md or not content_md.strip():
@@ -110,14 +108,15 @@ class WebpageTool:
110
108
  - 包含网页标题(若可推断)
111
109
  - 提供准确、完整的信息"""
112
110
 
113
- model = PlatformRegistry().get_normal_platform()
111
+ # 使用cheap平台进行网页内容总结(简单任务)
112
+ model = PlatformRegistry().get_cheap_platform()
114
113
  model.set_suppress_output(False) # type: ignore
115
114
  summary = model.chat_until_success(summary_prompt) # type: ignore
116
115
 
117
116
  return {"success": True, "stdout": summary, "stderr": ""}
118
117
 
119
118
  except Exception as e:
120
- PrettyOutput.print(f"读取网页失败: {str(e)}", OutputType.ERROR)
119
+ print(f"读取网页失败: {str(e)}")
121
120
  return {
122
121
  "success": False,
123
122
  "stdout": "",