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.
- jarvis/__init__.py +1 -1
- jarvis/jarvis_agent/__init__.py +458 -152
- jarvis/jarvis_agent/agent_manager.py +17 -13
- jarvis/jarvis_agent/builtin_input_handler.py +2 -6
- jarvis/jarvis_agent/config_editor.py +2 -7
- jarvis/jarvis_agent/event_bus.py +82 -12
- jarvis/jarvis_agent/file_context_handler.py +329 -0
- jarvis/jarvis_agent/file_methodology_manager.py +3 -4
- jarvis/jarvis_agent/jarvis.py +628 -55
- jarvis/jarvis_agent/language_extractors/__init__.py +57 -0
- jarvis/jarvis_agent/language_extractors/c_extractor.py +21 -0
- jarvis/jarvis_agent/language_extractors/cpp_extractor.py +21 -0
- jarvis/jarvis_agent/language_extractors/go_extractor.py +21 -0
- jarvis/jarvis_agent/language_extractors/java_extractor.py +84 -0
- jarvis/jarvis_agent/language_extractors/javascript_extractor.py +79 -0
- jarvis/jarvis_agent/language_extractors/python_extractor.py +21 -0
- jarvis/jarvis_agent/language_extractors/rust_extractor.py +21 -0
- jarvis/jarvis_agent/language_extractors/typescript_extractor.py +84 -0
- jarvis/jarvis_agent/language_support_info.py +486 -0
- jarvis/jarvis_agent/main.py +34 -10
- jarvis/jarvis_agent/memory_manager.py +7 -16
- jarvis/jarvis_agent/methodology_share_manager.py +10 -16
- jarvis/jarvis_agent/prompt_manager.py +1 -1
- jarvis/jarvis_agent/prompts.py +193 -171
- jarvis/jarvis_agent/protocols.py +8 -12
- jarvis/jarvis_agent/run_loop.py +105 -9
- jarvis/jarvis_agent/session_manager.py +2 -3
- jarvis/jarvis_agent/share_manager.py +20 -22
- jarvis/jarvis_agent/shell_input_handler.py +1 -2
- jarvis/jarvis_agent/stdio_redirect.py +295 -0
- jarvis/jarvis_agent/task_analyzer.py +31 -6
- jarvis/jarvis_agent/task_manager.py +11 -27
- jarvis/jarvis_agent/tool_executor.py +2 -3
- jarvis/jarvis_agent/tool_share_manager.py +12 -24
- jarvis/jarvis_agent/utils.py +5 -1
- jarvis/jarvis_agent/web_bridge.py +189 -0
- jarvis/jarvis_agent/web_output_sink.py +53 -0
- jarvis/jarvis_agent/web_server.py +786 -0
- jarvis/jarvis_c2rust/__init__.py +26 -0
- jarvis/jarvis_c2rust/cli.py +575 -0
- jarvis/jarvis_c2rust/collector.py +250 -0
- jarvis/jarvis_c2rust/constants.py +26 -0
- jarvis/jarvis_c2rust/library_replacer.py +1254 -0
- jarvis/jarvis_c2rust/llm_module_agent.py +1272 -0
- jarvis/jarvis_c2rust/loaders.py +207 -0
- jarvis/jarvis_c2rust/models.py +28 -0
- jarvis/jarvis_c2rust/optimizer.py +2157 -0
- jarvis/jarvis_c2rust/scanner.py +1681 -0
- jarvis/jarvis_c2rust/transpiler.py +2983 -0
- jarvis/jarvis_c2rust/utils.py +385 -0
- jarvis/jarvis_code_agent/build_validation_config.py +132 -0
- jarvis/jarvis_code_agent/code_agent.py +1371 -220
- jarvis/jarvis_code_agent/code_analyzer/__init__.py +65 -0
- jarvis/jarvis_code_agent/code_analyzer/base_language.py +74 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/__init__.py +44 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/base.py +106 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/cmake.py +74 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/detector.py +125 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/fallback.py +72 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/go.py +70 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/java_gradle.py +53 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/java_maven.py +47 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/makefile.py +61 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/nodejs.py +110 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/python.py +154 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/rust.py +110 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/validator.py +153 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator.py +43 -0
- jarvis/jarvis_code_agent/code_analyzer/context_manager.py +648 -0
- jarvis/jarvis_code_agent/code_analyzer/context_recommender.py +18 -0
- jarvis/jarvis_code_agent/code_analyzer/dependency_analyzer.py +132 -0
- jarvis/jarvis_code_agent/code_analyzer/file_ignore.py +330 -0
- jarvis/jarvis_code_agent/code_analyzer/impact_analyzer.py +781 -0
- jarvis/jarvis_code_agent/code_analyzer/language_registry.py +185 -0
- jarvis/jarvis_code_agent/code_analyzer/language_support.py +110 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/__init__.py +49 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/c_cpp_language.py +299 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/go_language.py +215 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/java_language.py +212 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/javascript_language.py +254 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/python_language.py +269 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/rust_language.py +281 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/typescript_language.py +280 -0
- jarvis/jarvis_code_agent/code_analyzer/llm_context_recommender.py +605 -0
- jarvis/jarvis_code_agent/code_analyzer/structured_code.py +556 -0
- jarvis/jarvis_code_agent/code_analyzer/symbol_extractor.py +252 -0
- jarvis/jarvis_code_agent/code_analyzer/tree_sitter_extractor.py +58 -0
- jarvis/jarvis_code_agent/lint.py +501 -8
- jarvis/jarvis_code_agent/utils.py +141 -0
- jarvis/jarvis_code_analysis/code_review.py +493 -584
- jarvis/jarvis_data/config_schema.json +128 -12
- jarvis/jarvis_git_squash/main.py +4 -5
- jarvis/jarvis_git_utils/git_commiter.py +82 -75
- jarvis/jarvis_mcp/sse_mcp_client.py +22 -29
- jarvis/jarvis_mcp/stdio_mcp_client.py +12 -13
- jarvis/jarvis_mcp/streamable_mcp_client.py +15 -14
- jarvis/jarvis_memory_organizer/memory_organizer.py +55 -74
- jarvis/jarvis_methodology/main.py +32 -48
- jarvis/jarvis_multi_agent/__init__.py +287 -55
- jarvis/jarvis_multi_agent/main.py +36 -4
- jarvis/jarvis_platform/base.py +524 -202
- jarvis/jarvis_platform/human.py +7 -8
- jarvis/jarvis_platform/kimi.py +30 -36
- jarvis/jarvis_platform/openai.py +88 -25
- jarvis/jarvis_platform/registry.py +26 -10
- jarvis/jarvis_platform/tongyi.py +24 -25
- jarvis/jarvis_platform/yuanbao.py +32 -43
- jarvis/jarvis_platform_manager/main.py +66 -77
- jarvis/jarvis_platform_manager/service.py +8 -13
- jarvis/jarvis_rag/cli.py +53 -55
- jarvis/jarvis_rag/embedding_manager.py +13 -18
- jarvis/jarvis_rag/llm_interface.py +8 -9
- jarvis/jarvis_rag/query_rewriter.py +10 -21
- jarvis/jarvis_rag/rag_pipeline.py +24 -27
- jarvis/jarvis_rag/reranker.py +4 -5
- jarvis/jarvis_rag/retriever.py +28 -30
- jarvis/jarvis_sec/__init__.py +305 -0
- jarvis/jarvis_sec/agents.py +143 -0
- jarvis/jarvis_sec/analysis.py +276 -0
- jarvis/jarvis_sec/checkers/__init__.py +32 -0
- jarvis/jarvis_sec/checkers/c_checker.py +2680 -0
- jarvis/jarvis_sec/checkers/rust_checker.py +1108 -0
- jarvis/jarvis_sec/cli.py +139 -0
- jarvis/jarvis_sec/clustering.py +1439 -0
- jarvis/jarvis_sec/file_manager.py +427 -0
- jarvis/jarvis_sec/parsers.py +73 -0
- jarvis/jarvis_sec/prompts.py +268 -0
- jarvis/jarvis_sec/report.py +336 -0
- jarvis/jarvis_sec/review.py +453 -0
- jarvis/jarvis_sec/status.py +264 -0
- jarvis/jarvis_sec/types.py +20 -0
- jarvis/jarvis_sec/utils.py +499 -0
- jarvis/jarvis_sec/verification.py +848 -0
- jarvis/jarvis_sec/workflow.py +226 -0
- jarvis/jarvis_smart_shell/main.py +38 -87
- jarvis/jarvis_stats/cli.py +2 -2
- jarvis/jarvis_stats/stats.py +8 -8
- jarvis/jarvis_stats/storage.py +15 -21
- jarvis/jarvis_stats/visualizer.py +1 -1
- jarvis/jarvis_tools/clear_memory.py +3 -20
- jarvis/jarvis_tools/cli/main.py +21 -23
- jarvis/jarvis_tools/edit_file.py +1019 -132
- jarvis/jarvis_tools/execute_script.py +83 -25
- jarvis/jarvis_tools/file_analyzer.py +6 -9
- jarvis/jarvis_tools/generate_new_tool.py +14 -21
- jarvis/jarvis_tools/lsp_client.py +1552 -0
- jarvis/jarvis_tools/methodology.py +2 -3
- jarvis/jarvis_tools/read_code.py +1736 -35
- jarvis/jarvis_tools/read_symbols.py +140 -0
- jarvis/jarvis_tools/read_webpage.py +12 -13
- jarvis/jarvis_tools/registry.py +427 -200
- jarvis/jarvis_tools/retrieve_memory.py +20 -19
- jarvis/jarvis_tools/rewrite_file.py +72 -158
- jarvis/jarvis_tools/save_memory.py +3 -15
- jarvis/jarvis_tools/search_web.py +18 -18
- jarvis/jarvis_tools/sub_agent.py +36 -43
- jarvis/jarvis_tools/sub_code_agent.py +25 -26
- jarvis/jarvis_tools/virtual_tty.py +55 -33
- jarvis/jarvis_utils/clipboard.py +7 -10
- jarvis/jarvis_utils/config.py +232 -45
- jarvis/jarvis_utils/embedding.py +8 -5
- jarvis/jarvis_utils/fzf.py +8 -8
- jarvis/jarvis_utils/git_utils.py +225 -36
- jarvis/jarvis_utils/globals.py +3 -3
- jarvis/jarvis_utils/http.py +1 -1
- jarvis/jarvis_utils/input.py +99 -48
- jarvis/jarvis_utils/jsonnet_compat.py +465 -0
- jarvis/jarvis_utils/methodology.py +52 -48
- jarvis/jarvis_utils/utils.py +819 -491
- jarvis_ai_assistant-0.7.6.dist-info/METADATA +600 -0
- jarvis_ai_assistant-0.7.6.dist-info/RECORD +218 -0
- {jarvis_ai_assistant-0.3.30.dist-info → jarvis_ai_assistant-0.7.6.dist-info}/entry_points.txt +4 -0
- jarvis/jarvis_agent/config.py +0 -92
- jarvis/jarvis_agent/edit_file_handler.py +0 -296
- jarvis/jarvis_platform/ai8.py +0 -332
- jarvis/jarvis_tools/ask_user.py +0 -54
- jarvis_ai_assistant-0.3.30.dist-info/METADATA +0 -381
- jarvis_ai_assistant-0.3.30.dist-info/RECORD +0 -137
- {jarvis_ai_assistant-0.3.30.dist-info → jarvis_ai_assistant-0.7.6.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.3.30.dist-info → jarvis_ai_assistant-0.7.6.dist-info}/licenses/LICENSE +0 -0
- {jarvis_ai_assistant-0.3.30.dist-info → jarvis_ai_assistant-0.7.6.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
使用libclang收集头文件中函数名的轻量级工具。
|
|
4
|
+
|
|
5
|
+
用途:
|
|
6
|
+
- 给定一个或多个C/C++头文件(.h/.hh/.hpp/.hxx),使用libclang解析每个文件并收集函数名
|
|
7
|
+
- 优先使用限定名称(qualified names),否则回退到非限定名称
|
|
8
|
+
- 将唯一名称(去重并保留首次出现顺序)写入指定输出文件(每行一个)
|
|
9
|
+
|
|
10
|
+
设计:
|
|
11
|
+
- 复用扫描工具:
|
|
12
|
+
- _try_import_libclang()
|
|
13
|
+
- find_compile_commands()
|
|
14
|
+
- load_compile_commands()
|
|
15
|
+
- scan_file() (注意: scan_file只收集定义;内联头文件通常是定义)
|
|
16
|
+
- 如果存在compile_commands.json,使用其参数;否则回退到包含文件父目录的最小参数集
|
|
17
|
+
- 对于头文件解析,确保语言标志(-x c-header / -x c++-header)存在,如果参数中未指定
|
|
18
|
+
|
|
19
|
+
注意事项:
|
|
20
|
+
- 本模块注重正确性/鲁棒性而非性能
|
|
21
|
+
- 不尝试发现传递包含;仅通过添加-I <file.parent>来辅助解析器
|
|
22
|
+
"""
|
|
23
|
+
from __future__ import annotations
|
|
24
|
+
|
|
25
|
+
from pathlib import Path
|
|
26
|
+
from typing import List, Optional, Dict
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
from jarvis.jarvis_c2rust.scanner import (
|
|
30
|
+
_try_import_libclang,
|
|
31
|
+
find_compile_commands,
|
|
32
|
+
load_compile_commands,
|
|
33
|
+
scan_file,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
HEADER_EXTS = {".h", ".hh", ".hpp", ".hxx"}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _guess_lang_header_flag(file: Path) -> List[str]:
|
|
41
|
+
"""
|
|
42
|
+
如果编译参数中未指定,则猜测头文件合适的-x语言标志
|
|
43
|
+
"""
|
|
44
|
+
ext = file.suffix.lower()
|
|
45
|
+
if ext in {".hh", ".hpp", ".hxx"}:
|
|
46
|
+
return ["-x", "c++-header"]
|
|
47
|
+
# 对于.h文件默认使用C头文件(保守选择)
|
|
48
|
+
return ["-x", "c-header"]
|
|
49
|
+
|
|
50
|
+
def _ensure_parse_args_for_header(file: Path, base_args: Optional[List[str]]) -> List[str]:
|
|
51
|
+
"""
|
|
52
|
+
确保头文件解析所需的最小参数集:
|
|
53
|
+
- 通过-I包含file.parent目录
|
|
54
|
+
- 如果没有语言标志则添加-x c-header/c++-header
|
|
55
|
+
"""
|
|
56
|
+
args = list(base_args or [])
|
|
57
|
+
# 检测是否已存在语言标志(-x <lang>)
|
|
58
|
+
has_lang = False
|
|
59
|
+
for i, a in enumerate(args):
|
|
60
|
+
if a == "-x":
|
|
61
|
+
# 如果存在'-x'且后面有值,则认为已指定语言
|
|
62
|
+
if i + 1 < len(args):
|
|
63
|
+
has_lang = True
|
|
64
|
+
break
|
|
65
|
+
elif a.startswith("-x"):
|
|
66
|
+
has_lang = True
|
|
67
|
+
break
|
|
68
|
+
|
|
69
|
+
if not has_lang:
|
|
70
|
+
args.extend(_guess_lang_header_flag(file))
|
|
71
|
+
|
|
72
|
+
# 确保存在-I <file.parent>
|
|
73
|
+
inc_dir = str(file.parent)
|
|
74
|
+
has_inc = False
|
|
75
|
+
i = 0
|
|
76
|
+
while i < len(args):
|
|
77
|
+
a = args[i]
|
|
78
|
+
if a == "-I":
|
|
79
|
+
if i + 1 < len(args) and args[i + 1] == inc_dir:
|
|
80
|
+
has_inc = True
|
|
81
|
+
break
|
|
82
|
+
i += 2
|
|
83
|
+
continue
|
|
84
|
+
elif a.startswith("-I"):
|
|
85
|
+
# 可能是-I/path格式
|
|
86
|
+
if a[2:] == inc_dir:
|
|
87
|
+
has_inc = True
|
|
88
|
+
break
|
|
89
|
+
i += 1
|
|
90
|
+
if not has_inc:
|
|
91
|
+
args.extend(["-I", inc_dir])
|
|
92
|
+
|
|
93
|
+
return args
|
|
94
|
+
|
|
95
|
+
def _collect_decl_function_names(cindex, file: Path, args: List[str]) -> List[str]:
|
|
96
|
+
"""
|
|
97
|
+
对于没有内联定义的头文件的回退方案:
|
|
98
|
+
收集此头文件中定义的函数声明(原型/方法)
|
|
99
|
+
"""
|
|
100
|
+
try:
|
|
101
|
+
index = cindex.Index.create()
|
|
102
|
+
tu = index.parse(str(file), args=args, options=0)
|
|
103
|
+
except Exception:
|
|
104
|
+
return []
|
|
105
|
+
names: List[str] = []
|
|
106
|
+
seen = set()
|
|
107
|
+
|
|
108
|
+
def visit(node):
|
|
109
|
+
try:
|
|
110
|
+
kind = node.kind.name
|
|
111
|
+
except Exception:
|
|
112
|
+
kind = ""
|
|
113
|
+
if kind in {"FUNCTION_DECL", "CXX_METHOD", "FUNCTION_TEMPLATE", "CONSTRUCTOR", "DESTRUCTOR"}:
|
|
114
|
+
loc_file = getattr(getattr(node, "location", None), "file", None)
|
|
115
|
+
try:
|
|
116
|
+
same_file = loc_file is not None and Path(loc_file.name).resolve() == file.resolve()
|
|
117
|
+
except Exception:
|
|
118
|
+
same_file = False
|
|
119
|
+
if same_file:
|
|
120
|
+
try:
|
|
121
|
+
nm = str(node.spelling or "").strip()
|
|
122
|
+
except Exception:
|
|
123
|
+
nm = ""
|
|
124
|
+
if nm and nm not in seen:
|
|
125
|
+
seen.add(nm)
|
|
126
|
+
names.append(nm)
|
|
127
|
+
for ch in node.get_children():
|
|
128
|
+
visit(ch)
|
|
129
|
+
|
|
130
|
+
try:
|
|
131
|
+
visit(tu.cursor)
|
|
132
|
+
except Exception:
|
|
133
|
+
pass
|
|
134
|
+
return names
|
|
135
|
+
|
|
136
|
+
def collect_function_names(
|
|
137
|
+
files: List[Path],
|
|
138
|
+
out_path: Path,
|
|
139
|
+
compile_commands_root: Optional[Path] = None,
|
|
140
|
+
) -> Path:
|
|
141
|
+
"""
|
|
142
|
+
从给定的头文件中收集函数名并将唯一名称写入out_path
|
|
143
|
+
|
|
144
|
+
参数:
|
|
145
|
+
- files: 头文件路径列表(.h/.hh/.hpp/.hxx)。非头文件将被跳过
|
|
146
|
+
- out_path: 输出文件路径。将被创建(包括父目录)并覆盖
|
|
147
|
+
- compile_commands_root: 可选,搜索compile_commands.json的根目录
|
|
148
|
+
如果未提供,则从每个文件的目录向上搜索
|
|
149
|
+
|
|
150
|
+
返回值:
|
|
151
|
+
- 写入的out_path路径
|
|
152
|
+
"""
|
|
153
|
+
# 标准化和过滤头文件
|
|
154
|
+
hdrs: List[Path] = []
|
|
155
|
+
for p in files or []:
|
|
156
|
+
try:
|
|
157
|
+
fp = Path(p).resolve()
|
|
158
|
+
except Exception:
|
|
159
|
+
continue
|
|
160
|
+
if fp.is_file() and fp.suffix.lower() in HEADER_EXTS:
|
|
161
|
+
hdrs.append(fp)
|
|
162
|
+
|
|
163
|
+
if not hdrs:
|
|
164
|
+
raise ValueError("未提供有效的头文件(.h/.hh/.hpp/.hxx)")
|
|
165
|
+
|
|
166
|
+
# 准备libclang
|
|
167
|
+
cindex = _try_import_libclang()
|
|
168
|
+
if cindex is None:
|
|
169
|
+
from clang import cindex as _ci # type: ignore
|
|
170
|
+
cindex = _ci
|
|
171
|
+
|
|
172
|
+
# 准备compile_commands参数映射(如果提供了根目录则全局一次,否则每个文件单独处理)
|
|
173
|
+
cc_args_map_global: Optional[Dict[str, List[str]]] = None
|
|
174
|
+
if compile_commands_root is not None:
|
|
175
|
+
cc_file = find_compile_commands(Path(compile_commands_root))
|
|
176
|
+
if cc_file:
|
|
177
|
+
cc_args_map_global = load_compile_commands(cc_file)
|
|
178
|
+
|
|
179
|
+
# 收集名称(保持顺序)
|
|
180
|
+
seen = set()
|
|
181
|
+
ordered_names: List[str] = []
|
|
182
|
+
|
|
183
|
+
for hf in hdrs:
|
|
184
|
+
# 确定此文件的参数
|
|
185
|
+
cc_args_map = cc_args_map_global
|
|
186
|
+
if cc_args_map is None:
|
|
187
|
+
# 尝试在此文件附近查找compile_commands.json
|
|
188
|
+
cc_file_local = find_compile_commands(hf.parent)
|
|
189
|
+
if cc_file_local:
|
|
190
|
+
try:
|
|
191
|
+
cc_args_map = load_compile_commands(cc_file_local)
|
|
192
|
+
except Exception:
|
|
193
|
+
cc_args_map = None
|
|
194
|
+
|
|
195
|
+
base_args = None
|
|
196
|
+
if cc_args_map:
|
|
197
|
+
base_args = cc_args_map.get(str(hf))
|
|
198
|
+
if base_args is None:
|
|
199
|
+
base_args = ["-I", str(hf.parent)]
|
|
200
|
+
|
|
201
|
+
args = _ensure_parse_args_for_header(hf, base_args)
|
|
202
|
+
|
|
203
|
+
# 尝试扫描。如果出错,尝试使用最小参数集的回退方案
|
|
204
|
+
try:
|
|
205
|
+
funcs = scan_file(cindex, hf, args)
|
|
206
|
+
except Exception:
|
|
207
|
+
try:
|
|
208
|
+
funcs = scan_file(cindex, hf, _ensure_parse_args_for_header(hf, ["-I", str(hf.parent)]))
|
|
209
|
+
except Exception:
|
|
210
|
+
funcs = []
|
|
211
|
+
|
|
212
|
+
# 从定义中提取首选名称(qualified_name或name)
|
|
213
|
+
added_count = 0
|
|
214
|
+
for fn in funcs:
|
|
215
|
+
name = ""
|
|
216
|
+
try:
|
|
217
|
+
qn = getattr(fn, "qualified_name", "") or ""
|
|
218
|
+
nm = getattr(fn, "name", "") or ""
|
|
219
|
+
name = qn or nm
|
|
220
|
+
name = str(name).strip()
|
|
221
|
+
except Exception:
|
|
222
|
+
name = ""
|
|
223
|
+
if not name or name in seen:
|
|
224
|
+
continue
|
|
225
|
+
seen.add(name)
|
|
226
|
+
ordered_names.append(name)
|
|
227
|
+
added_count += 1
|
|
228
|
+
|
|
229
|
+
# 回退: 如果在此头文件中未找到定义,则收集声明
|
|
230
|
+
if not funcs or added_count == 0:
|
|
231
|
+
try:
|
|
232
|
+
decl_names = _collect_decl_function_names(cindex, hf, args)
|
|
233
|
+
except Exception:
|
|
234
|
+
decl_names = []
|
|
235
|
+
for nm in decl_names:
|
|
236
|
+
name = str(nm).strip()
|
|
237
|
+
if not name or name in seen:
|
|
238
|
+
continue
|
|
239
|
+
seen.add(name)
|
|
240
|
+
ordered_names.append(name)
|
|
241
|
+
|
|
242
|
+
# 写出文件(每行一个)
|
|
243
|
+
out_path = Path(out_path)
|
|
244
|
+
out_path.parent.mkdir(parents=True, exist_ok=True)
|
|
245
|
+
try:
|
|
246
|
+
out_path.write_text("\n".join(ordered_names) + ("\n" if ordered_names else ""), encoding="utf-8")
|
|
247
|
+
except Exception as e:
|
|
248
|
+
raise RuntimeError(f"写入输出文件失败: {out_path}: {e}")
|
|
249
|
+
|
|
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
|
+
|