jarvis-ai-assistant 0.7.0__py3-none-any.whl → 0.7.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 (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.8.dist-info}/METADATA +205 -70
  149. jarvis_ai_assistant-0.7.8.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.8.dist-info}/WHEEL +0 -0
  157. {jarvis_ai_assistant-0.7.0.dist-info → jarvis_ai_assistant-0.7.8.dist-info}/entry_points.txt +0 -0
  158. {jarvis_ai_assistant-0.7.0.dist-info → jarvis_ai_assistant-0.7.8.dist-info}/licenses/LICENSE +0 -0
  159. {jarvis_ai_assistant-0.7.0.dist-info → jarvis_ai_assistant-0.7.8.dist-info}/top_level.txt +0 -0
@@ -1,27 +1,25 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  """
3
- Lightweight function-name collector for header files using libclang.
3
+ 使用libclang收集头文件中函数名的轻量级工具。
4
4
 
5
- Purpose:
6
- - Given one or more C/C++ header files (.h/.hh/.hpp/.hxx), parse each file with libclang
7
- and collect function names.
8
- - Prefer qualified names when available; fall back to unqualified names.
9
- - Write unique names (de-duplicated, preserving first-seen order) to the specified output file (one per line).
5
+ 用途:
6
+ - 给定一个或多个C/C++头文件(.h/.hh/.hpp/.hxx),使用libclang解析每个文件并收集函数名
7
+ - 优先使用限定名称(qualified names),否则回退到非限定名称
8
+ - 将唯一名称(去重并保留首次出现顺序)写入指定输出文件(每行一个)
10
9
 
11
- Design:
12
- - Reuse scanner utilities:
10
+ 设计:
11
+ - 复用扫描工具:
13
12
  - _try_import_libclang()
14
13
  - find_compile_commands()
15
14
  - load_compile_commands()
16
- - scan_file() (note: scan_file collects only definitions; inline headers are often definitions)
17
- - If compile_commands.json exists, use its args; otherwise, fall back to minimal include of file.parent.
18
- - For header parsing, ensure a language flag (-x c-header / -x c++-header) is present if args do not specify one.
15
+ - scan_file() (注意: scan_file只收集定义;内联头文件通常是定义)
16
+ - 如果存在compile_commands.json,使用其参数;否则回退到包含文件父目录的最小参数集
17
+ - 对于头文件解析,确保语言标志(-x c-header / -x c++-header)存在,如果参数中未指定
19
18
 
20
- Notes:
21
- - This module focuses on correctness/robustness over performance.
22
- - It does not attempt to discover transitive includes; it only assists the parser by adding -I <file.parent>.
19
+ 注意事项:
20
+ - 本模块注重正确性/鲁棒性而非性能
21
+ - 不尝试发现传递包含;仅通过添加-I <file.parent>来辅助解析器
23
22
  """
24
-
25
23
  from __future__ import annotations
26
24
 
27
25
  from pathlib import Path
@@ -41,27 +39,26 @@ HEADER_EXTS = {".h", ".hh", ".hpp", ".hxx"}
41
39
 
42
40
  def _guess_lang_header_flag(file: Path) -> List[str]:
43
41
  """
44
- Guess appropriate -x language flag for header if not specified in compile args.
42
+ 如果编译参数中未指定,则猜测头文件合适的-x语言标志
45
43
  """
46
44
  ext = file.suffix.lower()
47
45
  if ext in {".hh", ".hpp", ".hxx"}:
48
46
  return ["-x", "c++-header"]
49
- # Default to C header for .h (conservative)
47
+ # 对于.h文件默认使用C头文件(保守选择)
50
48
  return ["-x", "c-header"]
51
49
 
52
-
53
50
  def _ensure_parse_args_for_header(file: Path, base_args: Optional[List[str]]) -> List[str]:
54
51
  """
55
- Ensure minimal args for header parsing:
56
- - include file.parent via -I
57
- - add a language flag -x c-header/c++-header if none exists
52
+ 确保头文件解析所需的最小参数集:
53
+ - 通过-I包含file.parent目录
54
+ - 如果没有语言标志则添加-x c-header/c++-header
58
55
  """
59
56
  args = list(base_args or [])
60
- # Detect if a language flag already exists (-x <lang>)
57
+ # 检测是否已存在语言标志(-x <lang>)
61
58
  has_lang = False
62
59
  for i, a in enumerate(args):
63
60
  if a == "-x":
64
- # If '-x' present and followed by a value, treat as language specified
61
+ # 如果存在'-x'且后面有值,则认为已指定语言
65
62
  if i + 1 < len(args):
66
63
  has_lang = True
67
64
  break
@@ -72,7 +69,7 @@ def _ensure_parse_args_for_header(file: Path, base_args: Optional[List[str]]) ->
72
69
  if not has_lang:
73
70
  args.extend(_guess_lang_header_flag(file))
74
71
 
75
- # Ensure -I <file.parent> is present
72
+ # 确保存在-I <file.parent>
76
73
  inc_dir = str(file.parent)
77
74
  has_inc = False
78
75
  i = 0
@@ -85,7 +82,7 @@ def _ensure_parse_args_for_header(file: Path, base_args: Optional[List[str]]) ->
85
82
  i += 2
86
83
  continue
87
84
  elif a.startswith("-I"):
88
- # Could be like -I/path
85
+ # 可能是-I/path格式
89
86
  if a[2:] == inc_dir:
90
87
  has_inc = True
91
88
  break
@@ -95,11 +92,10 @@ def _ensure_parse_args_for_header(file: Path, base_args: Optional[List[str]]) ->
95
92
 
96
93
  return args
97
94
 
98
-
99
95
  def _collect_decl_function_names(cindex, file: Path, args: List[str]) -> List[str]:
100
96
  """
101
- Fallback for headers without inline definitions:
102
- collect function declarations (prototypes/methods) defined in this header file.
97
+ 对于没有内联定义的头文件的回退方案:
98
+ 收集此头文件中定义的函数声明(原型/方法)
103
99
  """
104
100
  try:
105
101
  index = cindex.Index.create()
@@ -137,25 +133,24 @@ def _collect_decl_function_names(cindex, file: Path, args: List[str]) -> List[st
137
133
  pass
138
134
  return names
139
135
 
140
-
141
136
  def collect_function_names(
142
137
  files: List[Path],
143
138
  out_path: Path,
144
139
  compile_commands_root: Optional[Path] = None,
145
140
  ) -> Path:
146
141
  """
147
- Collect function names from given header files and write unique names to out_path.
142
+ 从给定的头文件中收集函数名并将唯一名称写入out_path
148
143
 
149
- Parameters:
150
- - files: list of header file paths (.h/.hh/.hpp/.hxx). Non-header files will be skipped.
151
- - out_path: output file path. Will be created (parents too) and overwritten.
152
- - compile_commands_root: optional root directory to search for compile_commands.json.
153
- If not provided, we search upward from each file's directory.
144
+ 参数:
145
+ - files: 头文件路径列表(.h/.hh/.hpp/.hxx)。非头文件将被跳过
146
+ - out_path: 输出文件路径。将被创建(包括父目录)并覆盖
147
+ - compile_commands_root: 可选,搜索compile_commands.json的根目录
148
+ 如果未提供,则从每个文件的目录向上搜索
154
149
 
155
- Returns:
156
- - Path to the written out_path.
150
+ 返回值:
151
+ - 写入的out_path路径
157
152
  """
158
- # Normalize and filter header files
153
+ # 标准化和过滤头文件
159
154
  hdrs: List[Path] = []
160
155
  for p in files or []:
161
156
  try:
@@ -166,30 +161,30 @@ def collect_function_names(
166
161
  hdrs.append(fp)
167
162
 
168
163
  if not hdrs:
169
- raise ValueError("No valid header files (.h/.hh/.hpp/.hxx) were provided.")
164
+ raise ValueError("未提供有效的头文件(.h/.hh/.hpp/.hxx)")
170
165
 
171
- # Prepare libclang
166
+ # 准备libclang
172
167
  cindex = _try_import_libclang()
173
168
  if cindex is None:
174
169
  from clang import cindex as _ci # type: ignore
175
170
  cindex = _ci
176
171
 
177
- # Prepare compile_commands args map (either once for provided root, or per-file if None)
172
+ # 准备compile_commands参数映射(如果提供了根目录则全局一次,否则每个文件单独处理)
178
173
  cc_args_map_global: Optional[Dict[str, List[str]]] = None
179
174
  if compile_commands_root is not None:
180
175
  cc_file = find_compile_commands(Path(compile_commands_root))
181
176
  if cc_file:
182
177
  cc_args_map_global = load_compile_commands(cc_file)
183
178
 
184
- # Collect names (preserving order)
179
+ # 收集名称(保持顺序)
185
180
  seen = set()
186
181
  ordered_names: List[str] = []
187
182
 
188
183
  for hf in hdrs:
189
- # Determine args for this file
184
+ # 确定此文件的参数
190
185
  cc_args_map = cc_args_map_global
191
186
  if cc_args_map is None:
192
- # Try to find compile_commands.json near this file
187
+ # 尝试在此文件附近查找compile_commands.json
193
188
  cc_file_local = find_compile_commands(hf.parent)
194
189
  if cc_file_local:
195
190
  try:
@@ -205,7 +200,7 @@ def collect_function_names(
205
200
 
206
201
  args = _ensure_parse_args_for_header(hf, base_args)
207
202
 
208
- # Attempt to scan. If error, try a fallback with minimal args.
203
+ # 尝试扫描。如果出错,尝试使用最小参数集的回退方案
209
204
  try:
210
205
  funcs = scan_file(cindex, hf, args)
211
206
  except Exception:
@@ -214,7 +209,7 @@ def collect_function_names(
214
209
  except Exception:
215
210
  funcs = []
216
211
 
217
- # Extract preferred name (qualified_name or name) from definitions
212
+ # 从定义中提取首选名称(qualified_namename)
218
213
  added_count = 0
219
214
  for fn in funcs:
220
215
  name = ""
@@ -231,7 +226,7 @@ def collect_function_names(
231
226
  ordered_names.append(name)
232
227
  added_count += 1
233
228
 
234
- # Fallback: if no definitions found in this header, collect declarations
229
+ # 回退: 如果在此头文件中未找到定义,则收集声明
235
230
  if not funcs or added_count == 0:
236
231
  try:
237
232
  decl_names = _collect_decl_function_names(cindex, hf, args)
@@ -244,15 +239,12 @@ def collect_function_names(
244
239
  seen.add(name)
245
240
  ordered_names.append(name)
246
241
 
247
- # Write out file (one per line)
242
+ # 写出文件(每行一个)
248
243
  out_path = Path(out_path)
249
244
  out_path.parent.mkdir(parents=True, exist_ok=True)
250
245
  try:
251
246
  out_path.write_text("\n".join(ordered_names) + ("\n" if ordered_names else ""), encoding="utf-8")
252
247
  except Exception as e:
253
- raise RuntimeError(f"Failed to write output file: {out_path}: {e}")
254
-
255
- return out_path
256
-
248
+ raise RuntimeError(f"写入输出文件失败: {out_path}: {e}")
257
249
 
258
- __all__ = ["collect_function_names"]
250
+ return out_path
@@ -0,0 +1,26 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ C2Rust 转译器常量定义
4
+ """
5
+
6
+ # 数据文件常量
7
+ C2RUST_DIRNAME = ".jarvis/c2rust"
8
+
9
+ SYMBOLS_JSONL = "symbols.jsonl"
10
+ ORDER_JSONL = "translation_order.jsonl"
11
+ PROGRESS_JSON = "progress.json"
12
+ CONFIG_JSON = "config.json"
13
+ SYMBOL_MAP_JSONL = "symbol_map.jsonl"
14
+
15
+ # 配置常量
16
+ ERROR_SUMMARY_MAX_LENGTH = 2000 # 错误信息摘要最大长度
17
+ DEFAULT_PLAN_MAX_RETRIES = 0 # 规划阶段默认最大重试次数(0表示无限重试)
18
+ DEFAULT_REVIEW_MAX_ITERATIONS = 0 # 审查阶段最大迭代次数(0表示无限重试)
19
+ DEFAULT_CHECK_MAX_RETRIES = 0 # cargo check 阶段默认最大重试次数(0表示无限重试)
20
+ DEFAULT_TEST_MAX_RETRIES = 0 # cargo test 阶段默认最大重试次数(0表示无限重试)
21
+
22
+ # 回退与重试常量
23
+ CONSECUTIVE_FIX_FAILURE_THRESHOLD = 10 # 连续修复失败次数阈值,达到此值将触发回退
24
+ MAX_FUNCTION_RETRIES = 10 # 函数重新开始处理的最大次数
25
+ DEFAULT_PLAN_MAX_RETRIES_ENTRY = 5 # run_transpile 入口函数的 plan_max_retries 默认值
26
+