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.
- jarvis/__init__.py +1 -1
- jarvis/jarvis_agent/__init__.py +243 -139
- jarvis/jarvis_agent/agent_manager.py +5 -10
- 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 +265 -15
- jarvis/jarvis_agent/file_methodology_manager.py +3 -4
- jarvis/jarvis_agent/jarvis.py +113 -98
- 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 +6 -12
- 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 +77 -14
- jarvis/jarvis_agent/session_manager.py +2 -3
- jarvis/jarvis_agent/share_manager.py +12 -21
- jarvis/jarvis_agent/shell_input_handler.py +1 -2
- jarvis/jarvis_agent/task_analyzer.py +26 -4
- 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/web_server.py +55 -20
- jarvis/jarvis_c2rust/__init__.py +5 -5
- jarvis/jarvis_c2rust/cli.py +461 -499
- jarvis/jarvis_c2rust/collector.py +45 -53
- jarvis/jarvis_c2rust/constants.py +26 -0
- jarvis/jarvis_c2rust/library_replacer.py +264 -132
- jarvis/jarvis_c2rust/llm_module_agent.py +162 -190
- jarvis/jarvis_c2rust/loaders.py +207 -0
- jarvis/jarvis_c2rust/models.py +28 -0
- jarvis/jarvis_c2rust/optimizer.py +1592 -395
- jarvis/jarvis_c2rust/transpiler.py +1722 -1064
- jarvis/jarvis_c2rust/utils.py +385 -0
- jarvis/jarvis_code_agent/build_validation_config.py +2 -3
- jarvis/jarvis_code_agent/code_agent.py +394 -320
- jarvis/jarvis_code_agent/code_analyzer/__init__.py +3 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/base.py +4 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/cmake.py +17 -2
- jarvis/jarvis_code_agent/code_analyzer/build_validator/fallback.py +3 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/go.py +36 -4
- jarvis/jarvis_code_agent/code_analyzer/build_validator/java_gradle.py +9 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/java_maven.py +9 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/makefile.py +12 -1
- jarvis/jarvis_code_agent/code_analyzer/build_validator/nodejs.py +22 -5
- jarvis/jarvis_code_agent/code_analyzer/build_validator/python.py +57 -32
- jarvis/jarvis_code_agent/code_analyzer/build_validator/rust.py +62 -6
- jarvis/jarvis_code_agent/code_analyzer/build_validator/validator.py +8 -9
- jarvis/jarvis_code_agent/code_analyzer/context_manager.py +290 -5
- jarvis/jarvis_code_agent/code_analyzer/language_support.py +21 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/__init__.py +21 -3
- jarvis/jarvis_code_agent/code_analyzer/languages/c_cpp_language.py +72 -4
- jarvis/jarvis_code_agent/code_analyzer/languages/go_language.py +35 -3
- 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 +52 -2
- jarvis/jarvis_code_agent/code_analyzer/languages/rust_language.py +73 -1
- jarvis/jarvis_code_agent/code_analyzer/languages/typescript_language.py +280 -0
- jarvis/jarvis_code_agent/code_analyzer/llm_context_recommender.py +306 -152
- jarvis/jarvis_code_agent/code_analyzer/structured_code.py +556 -0
- jarvis/jarvis_code_agent/code_analyzer/symbol_extractor.py +193 -18
- jarvis/jarvis_code_agent/code_analyzer/tree_sitter_extractor.py +18 -8
- jarvis/jarvis_code_agent/lint.py +258 -27
- jarvis/jarvis_code_agent/utils.py +0 -1
- jarvis/jarvis_code_analysis/code_review.py +19 -24
- jarvis/jarvis_data/config_schema.json +53 -26
- jarvis/jarvis_git_squash/main.py +4 -5
- jarvis/jarvis_git_utils/git_commiter.py +44 -49
- jarvis/jarvis_mcp/sse_mcp_client.py +20 -27
- jarvis/jarvis_mcp/stdio_mcp_client.py +11 -12
- 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 +79 -61
- jarvis/jarvis_multi_agent/main.py +3 -7
- jarvis/jarvis_platform/base.py +469 -199
- jarvis/jarvis_platform/human.py +7 -8
- jarvis/jarvis_platform/kimi.py +30 -36
- jarvis/jarvis_platform/openai.py +65 -27
- jarvis/jarvis_platform/registry.py +26 -10
- jarvis/jarvis_platform/tongyi.py +24 -25
- jarvis/jarvis_platform/yuanbao.py +31 -42
- jarvis/jarvis_platform_manager/main.py +66 -77
- jarvis/jarvis_platform_manager/service.py +8 -13
- jarvis/jarvis_rag/cli.py +49 -51
- 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 +220 -3520
- jarvis/jarvis_sec/agents.py +143 -0
- jarvis/jarvis_sec/analysis.py +276 -0
- jarvis/jarvis_sec/cli.py +29 -6
- 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 +83 -4
- jarvis/jarvis_sec/review.py +453 -0
- jarvis/jarvis_sec/utils.py +499 -0
- jarvis/jarvis_sec/verification.py +848 -0
- jarvis/jarvis_sec/workflow.py +7 -0
- jarvis/jarvis_smart_shell/main.py +38 -87
- jarvis/jarvis_stats/cli.py +1 -1
- jarvis/jarvis_stats/stats.py +7 -7
- jarvis/jarvis_stats/storage.py +15 -21
- jarvis/jarvis_tools/clear_memory.py +3 -20
- jarvis/jarvis_tools/cli/main.py +20 -23
- jarvis/jarvis_tools/edit_file.py +1066 -0
- jarvis/jarvis_tools/execute_script.py +42 -21
- jarvis/jarvis_tools/file_analyzer.py +6 -9
- jarvis/jarvis_tools/generate_new_tool.py +11 -20
- jarvis/jarvis_tools/lsp_client.py +1552 -0
- jarvis/jarvis_tools/methodology.py +2 -3
- jarvis/jarvis_tools/read_code.py +1525 -87
- jarvis/jarvis_tools/read_symbols.py +2 -3
- jarvis/jarvis_tools/read_webpage.py +7 -10
- jarvis/jarvis_tools/registry.py +370 -181
- jarvis/jarvis_tools/retrieve_memory.py +20 -19
- jarvis/jarvis_tools/rewrite_file.py +105 -0
- jarvis/jarvis_tools/save_memory.py +3 -15
- jarvis/jarvis_tools/search_web.py +3 -7
- jarvis/jarvis_tools/sub_agent.py +17 -6
- jarvis/jarvis_tools/sub_code_agent.py +14 -16
- jarvis/jarvis_tools/virtual_tty.py +54 -32
- jarvis/jarvis_utils/clipboard.py +7 -10
- jarvis/jarvis_utils/config.py +98 -63
- jarvis/jarvis_utils/embedding.py +5 -5
- jarvis/jarvis_utils/fzf.py +8 -8
- jarvis/jarvis_utils/git_utils.py +81 -67
- jarvis/jarvis_utils/input.py +24 -49
- jarvis/jarvis_utils/jsonnet_compat.py +465 -0
- jarvis/jarvis_utils/methodology.py +33 -35
- jarvis/jarvis_utils/utils.py +245 -202
- {jarvis_ai_assistant-0.7.0.dist-info → jarvis_ai_assistant-0.7.8.dist-info}/METADATA +205 -70
- jarvis_ai_assistant-0.7.8.dist-info/RECORD +218 -0
- jarvis/jarvis_agent/edit_file_handler.py +0 -584
- jarvis/jarvis_agent/rewrite_file_handler.py +0 -141
- jarvis/jarvis_agent/task_planner.py +0 -496
- jarvis/jarvis_platform/ai8.py +0 -332
- jarvis/jarvis_tools/ask_user.py +0 -54
- jarvis_ai_assistant-0.7.0.dist-info/RECORD +0 -192
- {jarvis_ai_assistant-0.7.0.dist-info → jarvis_ai_assistant-0.7.8.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.7.0.dist-info → jarvis_ai_assistant-0.7.8.dist-info}/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.7.0.dist-info → jarvis_ai_assistant-0.7.8.dist-info}/licenses/LICENSE +0 -0
- {jarvis_ai_assistant-0.7.0.dist-info → jarvis_ai_assistant-0.7.8.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""语言功能支持信息模块
|
|
3
|
+
|
|
4
|
+
提供语言功能支持情况的收集和展示功能。
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import subprocess
|
|
8
|
+
from typing import Dict, Any, List
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _collect_language_support_info() -> Dict[str, Dict[str, Any]]:
|
|
12
|
+
"""收集所有语言的功能支持信息"""
|
|
13
|
+
info: Dict[str, Dict[str, Any]] = {}
|
|
14
|
+
|
|
15
|
+
# 确保语言支持模块已加载(触发自动注册)
|
|
16
|
+
try:
|
|
17
|
+
import jarvis.jarvis_code_agent.code_analyzer.language_support # noqa: F401
|
|
18
|
+
except Exception:
|
|
19
|
+
pass
|
|
20
|
+
|
|
21
|
+
# 从 code_analyzer 获取语言支持
|
|
22
|
+
try:
|
|
23
|
+
from jarvis.jarvis_code_agent.code_analyzer.language_registry import get_registry
|
|
24
|
+
registry = get_registry()
|
|
25
|
+
|
|
26
|
+
for lang_name in registry.get_supported_languages():
|
|
27
|
+
lang_support = registry.get_language_support(lang_name)
|
|
28
|
+
if lang_support:
|
|
29
|
+
if lang_name not in info:
|
|
30
|
+
info[lang_name] = {}
|
|
31
|
+
|
|
32
|
+
# 检查符号提取支持
|
|
33
|
+
try:
|
|
34
|
+
extractor = lang_support.create_symbol_extractor()
|
|
35
|
+
info[lang_name]['符号提取'] = extractor is not None
|
|
36
|
+
except Exception:
|
|
37
|
+
# 如果创建失败,先标记为 False,后续会检查 file_context_handler 中的提取器
|
|
38
|
+
info[lang_name]['符号提取'] = False
|
|
39
|
+
|
|
40
|
+
# 检查依赖分析支持
|
|
41
|
+
try:
|
|
42
|
+
analyzer = lang_support.create_dependency_analyzer()
|
|
43
|
+
info[lang_name]['依赖分析'] = analyzer is not None
|
|
44
|
+
except Exception:
|
|
45
|
+
info[lang_name]['依赖分析'] = False
|
|
46
|
+
|
|
47
|
+
# 检查结构化编辑支持(基于符号提取器)
|
|
48
|
+
try:
|
|
49
|
+
# 结构化编辑需要符号提取器支持
|
|
50
|
+
extractor = lang_support.create_symbol_extractor()
|
|
51
|
+
info[lang_name]['结构化编辑'] = extractor is not None
|
|
52
|
+
except Exception:
|
|
53
|
+
info[lang_name]['结构化编辑'] = False
|
|
54
|
+
except Exception:
|
|
55
|
+
pass
|
|
56
|
+
|
|
57
|
+
# 从 file_context_handler 获取上下文提取支持,同时也用于补充符号提取支持
|
|
58
|
+
try:
|
|
59
|
+
from jarvis.jarvis_agent.file_context_handler import _LANGUAGE_EXTRACTORS
|
|
60
|
+
|
|
61
|
+
# 扩展名到语言名称的映射
|
|
62
|
+
lang_name_map = {
|
|
63
|
+
'.py': 'python', '.pyw': 'python',
|
|
64
|
+
'.rs': 'rust',
|
|
65
|
+
'.go': 'go',
|
|
66
|
+
'.c': 'c', '.h': 'c',
|
|
67
|
+
'.cpp': 'cpp', '.cc': 'cpp', '.cxx': 'cpp', '.hpp': 'cpp', '.hxx': 'cpp',
|
|
68
|
+
'.js': 'javascript', '.jsx': 'javascript',
|
|
69
|
+
'.ts': 'typescript', '.tsx': 'typescript',
|
|
70
|
+
'.java': 'java',
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
for ext, factory in _LANGUAGE_EXTRACTORS.items():
|
|
74
|
+
try:
|
|
75
|
+
# 尝试创建提取器,只有成功创建才标记为支持
|
|
76
|
+
extractor = factory()
|
|
77
|
+
if extractor is not None:
|
|
78
|
+
lang_name = lang_name_map.get(ext, ext[1:] if ext.startswith('.') else ext)
|
|
79
|
+
|
|
80
|
+
if lang_name not in info:
|
|
81
|
+
info[lang_name] = {}
|
|
82
|
+
|
|
83
|
+
# 上下文提取支持(只有成功创建才支持)
|
|
84
|
+
info[lang_name]['上下文提取'] = True
|
|
85
|
+
|
|
86
|
+
# 如果 code_analyzer 中的符号提取不支持,但 file_context_handler 中能成功创建提取器,也标记为支持
|
|
87
|
+
if '符号提取' not in info[lang_name] or not info[lang_name]['符号提取']:
|
|
88
|
+
info[lang_name]['符号提取'] = True
|
|
89
|
+
except Exception:
|
|
90
|
+
# 静默失败,不记录错误(避免输出过多调试信息)
|
|
91
|
+
pass
|
|
92
|
+
except Exception:
|
|
93
|
+
pass
|
|
94
|
+
|
|
95
|
+
# 检查构建验证支持(自动发现所有构建验证器)
|
|
96
|
+
try:
|
|
97
|
+
from jarvis.jarvis_code_agent.code_analyzer.build_validator import __all__
|
|
98
|
+
from jarvis.jarvis_code_agent.code_analyzer.build_validator.base import BuildValidatorBase
|
|
99
|
+
import jarvis.jarvis_code_agent.code_analyzer.build_validator as build_validator_module
|
|
100
|
+
|
|
101
|
+
# 自动发现所有构建验证器类(排除基类和工具类)
|
|
102
|
+
validator_classes = []
|
|
103
|
+
exclude_classes = {'BuildValidatorBase', 'BuildSystemDetector', 'BuildValidator', 'BuildSystem', 'BuildResult'}
|
|
104
|
+
|
|
105
|
+
for name in __all__:
|
|
106
|
+
if name not in exclude_classes and name.endswith('BuildValidator'):
|
|
107
|
+
try:
|
|
108
|
+
validator_class = getattr(build_validator_module, name)
|
|
109
|
+
# 检查是否是 BuildValidatorBase 的子类
|
|
110
|
+
if issubclass(validator_class, BuildValidatorBase) and validator_class != BuildValidatorBase:
|
|
111
|
+
validator_classes.append(validator_class)
|
|
112
|
+
except (AttributeError, TypeError, Exception):
|
|
113
|
+
continue
|
|
114
|
+
|
|
115
|
+
# 为每种语言收集支持的构建系统名称
|
|
116
|
+
lang_to_build_systems: Dict[str, List[str]] = {}
|
|
117
|
+
|
|
118
|
+
for validator_class in validator_classes:
|
|
119
|
+
try:
|
|
120
|
+
# 检查类是否有 BUILD_SYSTEM_NAME 和 SUPPORTED_LANGUAGES
|
|
121
|
+
build_system_name = getattr(validator_class, 'BUILD_SYSTEM_NAME', '')
|
|
122
|
+
supported_languages = getattr(validator_class, 'SUPPORTED_LANGUAGES', [])
|
|
123
|
+
|
|
124
|
+
if build_system_name and supported_languages:
|
|
125
|
+
for lang in supported_languages:
|
|
126
|
+
if lang not in lang_to_build_systems:
|
|
127
|
+
lang_to_build_systems[lang] = []
|
|
128
|
+
if build_system_name not in lang_to_build_systems[lang]:
|
|
129
|
+
lang_to_build_systems[lang].append(build_system_name)
|
|
130
|
+
except (AttributeError, Exception):
|
|
131
|
+
continue
|
|
132
|
+
|
|
133
|
+
# 将构建系统信息添加到 info 中
|
|
134
|
+
for lang_name, build_systems in lang_to_build_systems.items():
|
|
135
|
+
if lang_name not in info:
|
|
136
|
+
info[lang_name] = {}
|
|
137
|
+
if build_systems:
|
|
138
|
+
# 存储构建系统名称列表(用于显示)
|
|
139
|
+
info[lang_name]['构建验证'] = ', '.join(sorted(build_systems))
|
|
140
|
+
else:
|
|
141
|
+
info[lang_name]['构建验证'] = False
|
|
142
|
+
|
|
143
|
+
except (ImportError, Exception):
|
|
144
|
+
pass
|
|
145
|
+
|
|
146
|
+
# 检查静态检查支持(从 lint.py 获取)
|
|
147
|
+
try:
|
|
148
|
+
from jarvis.jarvis_code_agent.lint import LINT_TOOLS
|
|
149
|
+
|
|
150
|
+
# 扩展名到语言名称的映射
|
|
151
|
+
ext_to_lang_for_lint = {
|
|
152
|
+
'.py': 'python', '.pyw': 'python', '.pyi': 'python',
|
|
153
|
+
'.rs': 'rust',
|
|
154
|
+
'.go': 'go',
|
|
155
|
+
'.c': 'c', '.h': 'c',
|
|
156
|
+
'.cpp': 'cpp', '.cc': 'cpp', '.cxx': 'cpp', '.hpp': 'cpp', '.hxx': 'cpp',
|
|
157
|
+
'.js': 'javascript', '.jsx': 'javascript', '.mjs': 'javascript', '.cjs': 'javascript',
|
|
158
|
+
'.ts': 'typescript', '.tsx': 'typescript', '.cts': 'typescript', '.mts': 'typescript',
|
|
159
|
+
'.java': 'java',
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
# 检查每种语言是否有对应的 lint 工具
|
|
163
|
+
for ext, lang_name in ext_to_lang_for_lint.items():
|
|
164
|
+
if lang_name not in info:
|
|
165
|
+
info[lang_name] = {}
|
|
166
|
+
if ext in LINT_TOOLS and LINT_TOOLS[ext]:
|
|
167
|
+
info[lang_name]['静态检查'] = True
|
|
168
|
+
except Exception:
|
|
169
|
+
pass
|
|
170
|
+
|
|
171
|
+
# 检查LSP支持(从 lsp_client.py 获取,并验证实际可用性)
|
|
172
|
+
from jarvis.jarvis_tools.lsp_client import LSP_SERVERS
|
|
173
|
+
|
|
174
|
+
# LSP服务器配置中的语言名称到标准语言名称的映射
|
|
175
|
+
lsp_lang_map = {
|
|
176
|
+
'python': 'python',
|
|
177
|
+
'typescript': 'typescript',
|
|
178
|
+
'javascript': 'javascript',
|
|
179
|
+
'c': 'c',
|
|
180
|
+
'cpp': 'cpp',
|
|
181
|
+
'rust': 'rust',
|
|
182
|
+
'go': 'go',
|
|
183
|
+
'java': 'java',
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
# 检查每种语言是否有对应的 LSP 服务器配置,并验证实际可用性
|
|
187
|
+
for lsp_lang, lang_name in lsp_lang_map.items():
|
|
188
|
+
if lang_name not in info:
|
|
189
|
+
info[lang_name] = {}
|
|
190
|
+
|
|
191
|
+
if lsp_lang in LSP_SERVERS:
|
|
192
|
+
config = LSP_SERVERS[lsp_lang]
|
|
193
|
+
# 检查服务器是否实际可用
|
|
194
|
+
is_available = _check_lsp_server_available(config)
|
|
195
|
+
info[lang_name]['LSP支持'] = is_available
|
|
196
|
+
|
|
197
|
+
# 确保所有已知语言都在 info 中(即使某些功能不支持)
|
|
198
|
+
# 这样表格会显示所有语言,即使某些功能不支持
|
|
199
|
+
known_languages = ['python', 'c', 'cpp', 'rust', 'go', 'javascript', 'typescript', 'java']
|
|
200
|
+
for lang_name in known_languages:
|
|
201
|
+
if lang_name not in info:
|
|
202
|
+
info[lang_name] = {}
|
|
203
|
+
# 确保所有功能字段都存在
|
|
204
|
+
for feature in ['符号提取', '依赖分析', '上下文提取', '构建验证', '静态检查', 'LSP支持', '结构化编辑']:
|
|
205
|
+
if feature not in info[lang_name]:
|
|
206
|
+
# 对于上下文提取,检查是否有对应的提取器
|
|
207
|
+
if feature == '上下文提取':
|
|
208
|
+
try:
|
|
209
|
+
from jarvis.jarvis_agent.file_context_handler import _LANGUAGE_EXTRACTORS
|
|
210
|
+
ext_map = {
|
|
211
|
+
'python': ['.py', '.pyw'],
|
|
212
|
+
'rust': ['.rs'],
|
|
213
|
+
'go': ['.go'],
|
|
214
|
+
'c': ['.c', '.h'],
|
|
215
|
+
'cpp': ['.cpp', '.cc', '.cxx', '.hpp', '.hxx'],
|
|
216
|
+
'javascript': ['.js', '.jsx'],
|
|
217
|
+
'typescript': ['.ts', '.tsx'],
|
|
218
|
+
'java': ['.java'],
|
|
219
|
+
}
|
|
220
|
+
exts = ext_map.get(lang_name, [])
|
|
221
|
+
# 尝试创建提取器,只有成功创建才认为支持(需要 tree-sitter 已安装)
|
|
222
|
+
has_extractor = False
|
|
223
|
+
for ext in exts:
|
|
224
|
+
if ext in _LANGUAGE_EXTRACTORS:
|
|
225
|
+
try:
|
|
226
|
+
factory = _LANGUAGE_EXTRACTORS[ext]
|
|
227
|
+
extractor = factory()
|
|
228
|
+
if extractor:
|
|
229
|
+
has_extractor = True
|
|
230
|
+
break
|
|
231
|
+
except Exception:
|
|
232
|
+
continue
|
|
233
|
+
info[lang_name][feature] = has_extractor
|
|
234
|
+
except Exception:
|
|
235
|
+
info[lang_name][feature] = False
|
|
236
|
+
elif feature == '符号提取':
|
|
237
|
+
# 如果之前没有设置或为 False,再次检查 file_context_handler 中的提取器
|
|
238
|
+
# 只有能成功创建提取器才标记为支持(需要 tree-sitter 已安装)
|
|
239
|
+
if '符号提取' not in info[lang_name] or not info[lang_name]['符号提取']:
|
|
240
|
+
try:
|
|
241
|
+
from jarvis.jarvis_agent.file_context_handler import _LANGUAGE_EXTRACTORS
|
|
242
|
+
ext_map = {
|
|
243
|
+
'python': ['.py', '.pyw'],
|
|
244
|
+
'rust': ['.rs'],
|
|
245
|
+
'go': ['.go'],
|
|
246
|
+
'c': ['.c', '.h'],
|
|
247
|
+
'cpp': ['.cpp', '.cc', '.cxx', '.hpp', '.hxx'],
|
|
248
|
+
'javascript': ['.js', '.jsx'],
|
|
249
|
+
'typescript': ['.ts', '.tsx'],
|
|
250
|
+
}
|
|
251
|
+
exts = ext_map.get(lang_name, [])
|
|
252
|
+
# 尝试创建提取器,只有成功创建才认为支持
|
|
253
|
+
has_extractor = False
|
|
254
|
+
for ext in exts:
|
|
255
|
+
if ext in _LANGUAGE_EXTRACTORS:
|
|
256
|
+
try:
|
|
257
|
+
factory = _LANGUAGE_EXTRACTORS[ext]
|
|
258
|
+
extractor = factory()
|
|
259
|
+
if extractor:
|
|
260
|
+
has_extractor = True
|
|
261
|
+
break
|
|
262
|
+
except Exception:
|
|
263
|
+
continue
|
|
264
|
+
info[lang_name][feature] = has_extractor
|
|
265
|
+
except Exception:
|
|
266
|
+
info[lang_name][feature] = False
|
|
267
|
+
elif feature == '构建验证':
|
|
268
|
+
# 默认 False,已在上面检查过(可能是字符串或False)
|
|
269
|
+
if feature not in info[lang_name]:
|
|
270
|
+
info[lang_name][feature] = False
|
|
271
|
+
elif feature == '静态检查':
|
|
272
|
+
# 默认 False,已在上面检查过
|
|
273
|
+
info[lang_name][feature] = info[lang_name].get(feature, False)
|
|
274
|
+
elif feature == 'LSP支持':
|
|
275
|
+
# 默认 False,已在上面检查过
|
|
276
|
+
info[lang_name][feature] = info[lang_name].get(feature, False)
|
|
277
|
+
else:
|
|
278
|
+
info[lang_name][feature] = False
|
|
279
|
+
|
|
280
|
+
# 确保所有已知语言都在 info 中(即使某些功能不支持)
|
|
281
|
+
# 这样表格会显示所有语言,即使某些功能不支持
|
|
282
|
+
known_languages = ['python', 'c', 'cpp', 'rust', 'go', 'javascript', 'typescript', 'java']
|
|
283
|
+
for lang_name in known_languages:
|
|
284
|
+
if lang_name not in info:
|
|
285
|
+
info[lang_name] = {}
|
|
286
|
+
# 确保所有功能字段都存在
|
|
287
|
+
for feature in ['符号提取', '依赖分析', '上下文提取', '构建验证', '静态检查', 'LSP支持', '结构化编辑']:
|
|
288
|
+
if feature not in info[lang_name]:
|
|
289
|
+
# 对于上下文提取,检查是否有对应的提取器
|
|
290
|
+
if feature == '上下文提取':
|
|
291
|
+
try:
|
|
292
|
+
from jarvis.jarvis_agent.file_context_handler import _LANGUAGE_EXTRACTORS
|
|
293
|
+
ext_map = {
|
|
294
|
+
'python': ['.py', '.pyw'],
|
|
295
|
+
'rust': ['.rs'],
|
|
296
|
+
'go': ['.go'],
|
|
297
|
+
'c': ['.c', '.h'],
|
|
298
|
+
'cpp': ['.cpp', '.cc', '.cxx', '.hpp', '.hxx'],
|
|
299
|
+
'javascript': ['.js', '.jsx'],
|
|
300
|
+
'typescript': ['.ts', '.tsx'],
|
|
301
|
+
'java': ['.java'],
|
|
302
|
+
}
|
|
303
|
+
exts = ext_map.get(lang_name, [])
|
|
304
|
+
# 尝试创建提取器,只有成功创建才认为支持(需要 tree-sitter 已安装)
|
|
305
|
+
has_extractor = False
|
|
306
|
+
for ext in exts:
|
|
307
|
+
if ext in _LANGUAGE_EXTRACTORS:
|
|
308
|
+
try:
|
|
309
|
+
factory = _LANGUAGE_EXTRACTORS[ext]
|
|
310
|
+
extractor = factory()
|
|
311
|
+
if extractor:
|
|
312
|
+
has_extractor = True
|
|
313
|
+
break
|
|
314
|
+
except Exception:
|
|
315
|
+
continue
|
|
316
|
+
info[lang_name][feature] = has_extractor
|
|
317
|
+
except Exception:
|
|
318
|
+
info[lang_name][feature] = False
|
|
319
|
+
elif feature == '符号提取':
|
|
320
|
+
# 如果之前没有设置或为 False,再次检查 file_context_handler 中的提取器
|
|
321
|
+
# 只有能成功创建提取器才标记为支持(需要 tree-sitter 已安装)
|
|
322
|
+
if '符号提取' not in info[lang_name] or not info[lang_name]['符号提取']:
|
|
323
|
+
try:
|
|
324
|
+
from jarvis.jarvis_agent.file_context_handler import _LANGUAGE_EXTRACTORS
|
|
325
|
+
ext_map = {
|
|
326
|
+
'python': ['.py', '.pyw'],
|
|
327
|
+
'rust': ['.rs'],
|
|
328
|
+
'go': ['.go'],
|
|
329
|
+
'c': ['.c', '.h'],
|
|
330
|
+
'cpp': ['.cpp', '.cc', '.cxx', '.hpp', '.hxx'],
|
|
331
|
+
'javascript': ['.js', '.jsx'],
|
|
332
|
+
'typescript': ['.ts', '.tsx'],
|
|
333
|
+
}
|
|
334
|
+
exts = ext_map.get(lang_name, [])
|
|
335
|
+
# 尝试创建提取器,只有成功创建才认为支持
|
|
336
|
+
has_extractor = False
|
|
337
|
+
for ext in exts:
|
|
338
|
+
if ext in _LANGUAGE_EXTRACTORS:
|
|
339
|
+
try:
|
|
340
|
+
factory = _LANGUAGE_EXTRACTORS[ext]
|
|
341
|
+
extractor = factory()
|
|
342
|
+
if extractor:
|
|
343
|
+
has_extractor = True
|
|
344
|
+
break
|
|
345
|
+
except Exception:
|
|
346
|
+
continue
|
|
347
|
+
info[lang_name][feature] = has_extractor
|
|
348
|
+
except Exception:
|
|
349
|
+
info[lang_name][feature] = False
|
|
350
|
+
elif feature == '构建验证':
|
|
351
|
+
# 默认 False,已在上面检查过(可能是字符串或False)
|
|
352
|
+
if feature not in info[lang_name]:
|
|
353
|
+
info[lang_name][feature] = False
|
|
354
|
+
elif feature == '静态检查':
|
|
355
|
+
# 默认 False,已在上面检查过
|
|
356
|
+
info[lang_name][feature] = info[lang_name].get(feature, False)
|
|
357
|
+
elif feature == 'LSP支持':
|
|
358
|
+
# 默认 False,已在上面检查过
|
|
359
|
+
info[lang_name][feature] = info[lang_name].get(feature, False)
|
|
360
|
+
else:
|
|
361
|
+
info[lang_name][feature] = False
|
|
362
|
+
|
|
363
|
+
return info
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
def _check_lsp_server_available(config) -> bool:
|
|
367
|
+
"""检查LSP服务器是否实际可用。
|
|
368
|
+
|
|
369
|
+
Args:
|
|
370
|
+
config: LSPServerConfig 配置对象
|
|
371
|
+
|
|
372
|
+
Returns:
|
|
373
|
+
bool: 如果服务器可用返回True,否则返回False
|
|
374
|
+
"""
|
|
375
|
+
# 使用检测命令或主命令来验证
|
|
376
|
+
check_cmd = config.check_command or config.command
|
|
377
|
+
|
|
378
|
+
try:
|
|
379
|
+
# 尝试运行检测命令
|
|
380
|
+
subprocess.run(
|
|
381
|
+
check_cmd,
|
|
382
|
+
capture_output=True,
|
|
383
|
+
text=True,
|
|
384
|
+
timeout=5,
|
|
385
|
+
check=False
|
|
386
|
+
)
|
|
387
|
+
|
|
388
|
+
# 只要命令能执行(不是FileNotFoundError),就认为可用
|
|
389
|
+
# 某些LSP服务器即使返回非零退出码也可能可用
|
|
390
|
+
return True
|
|
391
|
+
|
|
392
|
+
except FileNotFoundError:
|
|
393
|
+
return False
|
|
394
|
+
except subprocess.TimeoutExpired:
|
|
395
|
+
return False
|
|
396
|
+
except Exception:
|
|
397
|
+
return False
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
def print_language_support_table() -> None:
|
|
401
|
+
"""打印语言功能支持表格"""
|
|
402
|
+
from rich.console import Console
|
|
403
|
+
from rich.table import Table
|
|
404
|
+
from rich.align import Align
|
|
405
|
+
|
|
406
|
+
info = _collect_language_support_info()
|
|
407
|
+
|
|
408
|
+
if not info:
|
|
409
|
+
return
|
|
410
|
+
|
|
411
|
+
# 定义功能列表
|
|
412
|
+
features = ['符号提取', '依赖分析', '上下文提取', '构建验证', '静态检查', 'LSP支持', '结构化编辑']
|
|
413
|
+
|
|
414
|
+
# 定义语言显示名称映射
|
|
415
|
+
lang_display_names = {
|
|
416
|
+
'python': 'Python',
|
|
417
|
+
'rust': 'Rust',
|
|
418
|
+
'go': 'Go',
|
|
419
|
+
'c': 'C',
|
|
420
|
+
'cpp': 'C++',
|
|
421
|
+
'javascript': 'JavaScript',
|
|
422
|
+
'typescript': 'TypeScript',
|
|
423
|
+
'java': 'Java',
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
# 获取所有语言(按固定顺序,优先显示 C, C++, Rust, Go)
|
|
427
|
+
priority_languages = ['c', 'cpp', 'rust', 'go']
|
|
428
|
+
other_languages = ['python', 'javascript', 'typescript', 'java']
|
|
429
|
+
all_languages = priority_languages + [lang for lang in other_languages if lang not in priority_languages]
|
|
430
|
+
# 显示所有已知语言,即使某些功能不支持(只要在 info 中有记录)
|
|
431
|
+
languages = [lang for lang in all_languages if lang in info]
|
|
432
|
+
|
|
433
|
+
# 如果没有任何语言,尝试显示 info 中的所有语言
|
|
434
|
+
if not languages:
|
|
435
|
+
languages = list(info.keys())
|
|
436
|
+
# 按优先级排序
|
|
437
|
+
languages = sorted(languages, key=lambda x: (
|
|
438
|
+
0 if x in priority_languages else 1,
|
|
439
|
+
priority_languages.index(x) if x in priority_languages else 999,
|
|
440
|
+
x
|
|
441
|
+
))
|
|
442
|
+
|
|
443
|
+
if not languages:
|
|
444
|
+
return
|
|
445
|
+
|
|
446
|
+
# 创建表格
|
|
447
|
+
table = Table(
|
|
448
|
+
title="[bold cyan]编程语言功能支持情况[/bold cyan]",
|
|
449
|
+
show_header=True,
|
|
450
|
+
header_style="bold magenta",
|
|
451
|
+
border_style="blue",
|
|
452
|
+
title_style="bold cyan",
|
|
453
|
+
show_lines=False,
|
|
454
|
+
padding=(0, 1),
|
|
455
|
+
)
|
|
456
|
+
|
|
457
|
+
# 添加语言列(第一列)
|
|
458
|
+
table.add_column("语言", style="cyan", no_wrap=True, justify="left")
|
|
459
|
+
|
|
460
|
+
# 添加功能列
|
|
461
|
+
for feature in features:
|
|
462
|
+
table.add_column(feature, justify="center", style="green", no_wrap=True)
|
|
463
|
+
|
|
464
|
+
# 添加语言行
|
|
465
|
+
for lang in languages:
|
|
466
|
+
display_name = lang_display_names.get(lang, lang.capitalize())
|
|
467
|
+
row = [display_name]
|
|
468
|
+
for feature in features:
|
|
469
|
+
supported = info.get(lang, {}).get(feature, False)
|
|
470
|
+
if supported:
|
|
471
|
+
# 如果是构建验证,显示构建系统名称
|
|
472
|
+
if feature == '构建验证' and isinstance(supported, str):
|
|
473
|
+
row.append(f"[bold green]{supported}[/bold green]")
|
|
474
|
+
else:
|
|
475
|
+
row.append("[bold green]✓[/bold green]")
|
|
476
|
+
else:
|
|
477
|
+
row.append("[bold red]✗[/bold red]")
|
|
478
|
+
table.add_row(*row)
|
|
479
|
+
|
|
480
|
+
console = Console()
|
|
481
|
+
console.print()
|
|
482
|
+
# 居中显示表格
|
|
483
|
+
aligned_table = Align.center(table)
|
|
484
|
+
console.print(aligned_table)
|
|
485
|
+
console.print()
|
|
486
|
+
|
jarvis/jarvis_agent/main.py
CHANGED
|
@@ -7,7 +7,6 @@ import yaml # type: ignore[import-untyped]
|
|
|
7
7
|
|
|
8
8
|
from jarvis.jarvis_agent import Agent
|
|
9
9
|
from jarvis.jarvis_utils.input import get_multiline_input
|
|
10
|
-
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
11
10
|
from jarvis.jarvis_utils.utils import init_env
|
|
12
11
|
from jarvis.jarvis_utils.config import set_config
|
|
13
12
|
|
|
@@ -24,9 +23,7 @@ def load_config(config_path: str) -> dict:
|
|
|
24
23
|
dict: 配置字典
|
|
25
24
|
"""
|
|
26
25
|
if not os.path.exists(config_path):
|
|
27
|
-
|
|
28
|
-
f"配置文件 {config_path} 不存在,使用默认配置", OutputType.WARNING
|
|
29
|
-
)
|
|
26
|
+
print(f"⚠️ 配置文件 {config_path} 不存在,使用默认配置")
|
|
30
27
|
return {}
|
|
31
28
|
|
|
32
29
|
with open(config_path, "r", encoding="utf-8", errors="ignore") as f:
|
|
@@ -34,7 +31,7 @@ def load_config(config_path: str) -> dict:
|
|
|
34
31
|
config = yaml.safe_load(f)
|
|
35
32
|
return config if config else {}
|
|
36
33
|
except yaml.YAMLError as e:
|
|
37
|
-
|
|
34
|
+
print(f"❌ 配置文件解析失败: {str(e)}")
|
|
38
35
|
return {}
|
|
39
36
|
|
|
40
37
|
|
|
@@ -68,10 +65,7 @@ def cli(
|
|
|
68
65
|
pass
|
|
69
66
|
# 非交互模式要求从命令行传入任务
|
|
70
67
|
if non_interactive and not (task and str(task).strip()):
|
|
71
|
-
|
|
72
|
-
"非交互模式已启用:必须使用 --task 传入任务内容,因多行输入不可用。",
|
|
73
|
-
OutputType.ERROR,
|
|
74
|
-
)
|
|
68
|
+
print("❌ 非交互模式已启用:必须使用 --task 传入任务内容,因多行输入不可用。")
|
|
75
69
|
raise typer.Exit(code=2)
|
|
76
70
|
# Initialize环境
|
|
77
71
|
init_env(
|
|
@@ -101,7 +95,7 @@ def cli(
|
|
|
101
95
|
|
|
102
96
|
# Run agent with initial task if specified
|
|
103
97
|
if task:
|
|
104
|
-
|
|
98
|
+
print(f"ℹ️ 执行初始任务: {task}")
|
|
105
99
|
agent.run(task)
|
|
106
100
|
return
|
|
107
101
|
|
|
@@ -120,12 +114,12 @@ def cli(
|
|
|
120
114
|
# 来自输入流程的正常退出
|
|
121
115
|
return
|
|
122
116
|
except Exception as e:
|
|
123
|
-
|
|
117
|
+
print(f"❌ 错误: {str(e)}")
|
|
124
118
|
|
|
125
119
|
except typer.Exit:
|
|
126
120
|
return
|
|
127
121
|
except Exception as e:
|
|
128
|
-
|
|
122
|
+
print(f"❌ 初始化错误: {str(e)}")
|
|
129
123
|
raise typer.Exit(code=1)
|
|
130
124
|
|
|
131
125
|
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
from jarvis.jarvis_utils.globals import get_all_memory_tags
|
|
8
|
-
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
9
8
|
from jarvis.jarvis_agent.events import TASK_STARTED, BEFORE_HISTORY_CLEAR, TASK_COMPLETED
|
|
10
9
|
|
|
11
10
|
|
|
@@ -82,16 +81,10 @@ class MemoryManager:
|
|
|
82
81
|
return
|
|
83
82
|
|
|
84
83
|
# 构建提示词,让大模型自己判断并保存记忆
|
|
85
|
-
prompt = """
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
2. 项目相关的重要发现或配置(适合保存为 project_long_term)
|
|
90
|
-
3. 用户的偏好或习惯(适合保存为 global_long_term)
|
|
91
|
-
4. 重要的技术知识或经验(适合保存为 global_long_term)
|
|
92
|
-
5. 项目特定的实现细节或约定(适合保存为 project_long_term)
|
|
93
|
-
|
|
94
|
-
请分析并保存有价值的信息,选择合适的记忆类型和标签。如果没有值得记忆的信息,请直接说明。"""
|
|
84
|
+
prompt = """回顾本次任务,判断是否有值得记忆的信息。使用 save_memory 保存:
|
|
85
|
+
- global_long_term: 新方法/技巧、用户偏好、技术知识
|
|
86
|
+
- project_long_term: 项目发现/配置、实现细节/约定
|
|
87
|
+
如无值得记忆的信息,直接说明。"""
|
|
95
88
|
|
|
96
89
|
# 处理记忆保存
|
|
97
90
|
try:
|
|
@@ -116,14 +109,12 @@ class MemoryManager:
|
|
|
116
109
|
saved = False
|
|
117
110
|
|
|
118
111
|
if saved:
|
|
119
|
-
|
|
120
|
-
"已自动保存有价值的信息到记忆系统", OutputType.SUCCESS
|
|
121
|
-
)
|
|
112
|
+
print("✅ 已自动保存有价值的信息到记忆系统")
|
|
122
113
|
else:
|
|
123
|
-
|
|
114
|
+
print("ℹ️ 本次任务没有特别需要记忆的信息")
|
|
124
115
|
|
|
125
116
|
except Exception as e:
|
|
126
|
-
|
|
117
|
+
print(f"❌ 记忆分析失败: {str(e)}")
|
|
127
118
|
finally:
|
|
128
119
|
# 设置记忆提示完成标记,避免事件触发造成重复处理
|
|
129
120
|
self._memory_prompted = True
|
|
@@ -8,7 +8,7 @@ from typing import List, Dict, Any
|
|
|
8
8
|
|
|
9
9
|
import typer
|
|
10
10
|
|
|
11
|
-
from jarvis.jarvis_agent import
|
|
11
|
+
from jarvis.jarvis_agent import user_confirm
|
|
12
12
|
from jarvis.jarvis_agent.share_manager import ShareManager
|
|
13
13
|
from jarvis.jarvis_utils.config import (
|
|
14
14
|
get_central_methodology_repo,
|
|
@@ -22,13 +22,8 @@ class MethodologyShareManager(ShareManager):
|
|
|
22
22
|
def __init__(self):
|
|
23
23
|
central_repo = get_central_methodology_repo()
|
|
24
24
|
if not central_repo:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
OutputType.ERROR,
|
|
28
|
-
)
|
|
29
|
-
PrettyOutput.print(
|
|
30
|
-
"请在配置文件中设置中心方法论仓库的Git地址", OutputType.INFO
|
|
31
|
-
)
|
|
25
|
+
print("❌ 错误:未配置中心方法论仓库(JARVIS_CENTRAL_METHODOLOGY_REPO)")
|
|
26
|
+
print("ℹ️ 请在配置文件中设置中心方法论仓库的Git地址")
|
|
32
27
|
raise typer.Exit(code=1)
|
|
33
28
|
|
|
34
29
|
super().__init__(central_repo, "central_methodology_repo")
|
|
@@ -123,7 +118,8 @@ class MethodologyShareManager(ShareManager):
|
|
|
123
118
|
share_list = ["\n将要分享以下方法论到中心仓库:"]
|
|
124
119
|
for meth in resources:
|
|
125
120
|
share_list.append(f"- {meth['problem_type']}")
|
|
126
|
-
|
|
121
|
+
joined_list = '\n'.join(share_list)
|
|
122
|
+
print(f"ℹ️ {joined_list}")
|
|
127
123
|
|
|
128
124
|
if not user_confirm("确认分享这些方法论吗?"):
|
|
129
125
|
return []
|
|
@@ -147,10 +143,7 @@ class MethodologyShareManager(ShareManager):
|
|
|
147
143
|
# 获取本地资源
|
|
148
144
|
local_resources = self.get_local_resources()
|
|
149
145
|
if not local_resources:
|
|
150
|
-
|
|
151
|
-
"没有找到新的方法论文件(所有方法论可能已存在于中心仓库)",
|
|
152
|
-
OutputType.WARNING,
|
|
153
|
-
)
|
|
146
|
+
print("⚠️ 没有找到新的方法论文件(所有方法论可能已存在于中心仓库)")
|
|
154
147
|
return
|
|
155
148
|
|
|
156
149
|
# 选择要分享的资源
|
|
@@ -162,13 +155,14 @@ class MethodologyShareManager(ShareManager):
|
|
|
162
155
|
copied_list = self.share_resources(selected_resources)
|
|
163
156
|
if copied_list:
|
|
164
157
|
# 一次性显示所有复制结果
|
|
165
|
-
|
|
158
|
+
joined_copied = '\n'.join(copied_list)
|
|
159
|
+
print(f"✅ {joined_copied}")
|
|
166
160
|
|
|
167
161
|
# 提交并推送
|
|
168
162
|
self.commit_and_push(len(selected_resources))
|
|
169
163
|
|
|
170
|
-
|
|
164
|
+
print("✅ 方法论已成功分享到中心仓库!")
|
|
171
165
|
|
|
172
166
|
except Exception as e:
|
|
173
|
-
|
|
167
|
+
print(f"❌ 分享方法论时出错: {str(e)}")
|
|
174
168
|
raise typer.Exit(code=1)
|