jarvis-ai-assistant 0.1.222__py3-none-any.whl → 0.7.0__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 +1143 -245
- jarvis/jarvis_agent/agent_manager.py +97 -0
- jarvis/jarvis_agent/builtin_input_handler.py +12 -10
- jarvis/jarvis_agent/config_editor.py +57 -0
- jarvis/jarvis_agent/edit_file_handler.py +392 -99
- jarvis/jarvis_agent/event_bus.py +48 -0
- jarvis/jarvis_agent/events.py +157 -0
- jarvis/jarvis_agent/file_context_handler.py +79 -0
- jarvis/jarvis_agent/file_methodology_manager.py +117 -0
- jarvis/jarvis_agent/jarvis.py +1117 -147
- jarvis/jarvis_agent/main.py +78 -34
- jarvis/jarvis_agent/memory_manager.py +195 -0
- jarvis/jarvis_agent/methodology_share_manager.py +174 -0
- jarvis/jarvis_agent/prompt_manager.py +82 -0
- jarvis/jarvis_agent/prompts.py +46 -9
- jarvis/jarvis_agent/protocols.py +4 -1
- jarvis/jarvis_agent/rewrite_file_handler.py +141 -0
- jarvis/jarvis_agent/run_loop.py +146 -0
- jarvis/jarvis_agent/session_manager.py +9 -9
- jarvis/jarvis_agent/share_manager.py +228 -0
- jarvis/jarvis_agent/shell_input_handler.py +23 -3
- jarvis/jarvis_agent/stdio_redirect.py +295 -0
- jarvis/jarvis_agent/task_analyzer.py +212 -0
- jarvis/jarvis_agent/task_manager.py +154 -0
- jarvis/jarvis_agent/task_planner.py +496 -0
- jarvis/jarvis_agent/tool_executor.py +8 -4
- jarvis/jarvis_agent/tool_share_manager.py +139 -0
- jarvis/jarvis_agent/user_interaction.py +42 -0
- jarvis/jarvis_agent/utils.py +54 -0
- jarvis/jarvis_agent/web_bridge.py +189 -0
- jarvis/jarvis_agent/web_output_sink.py +53 -0
- jarvis/jarvis_agent/web_server.py +751 -0
- jarvis/jarvis_c2rust/__init__.py +26 -0
- jarvis/jarvis_c2rust/cli.py +613 -0
- jarvis/jarvis_c2rust/collector.py +258 -0
- jarvis/jarvis_c2rust/library_replacer.py +1122 -0
- jarvis/jarvis_c2rust/llm_module_agent.py +1300 -0
- jarvis/jarvis_c2rust/optimizer.py +960 -0
- jarvis/jarvis_c2rust/scanner.py +1681 -0
- jarvis/jarvis_c2rust/transpiler.py +2325 -0
- jarvis/jarvis_code_agent/build_validation_config.py +133 -0
- jarvis/jarvis_code_agent/code_agent.py +1605 -178
- jarvis/jarvis_code_agent/code_analyzer/__init__.py +62 -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 +102 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/cmake.py +59 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/detector.py +125 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/fallback.py +69 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/go.py +38 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/java_gradle.py +44 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/java_maven.py +38 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/makefile.py +50 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/nodejs.py +93 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/python.py +129 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/rust.py +54 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/validator.py +154 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator.py +43 -0
- jarvis/jarvis_code_agent/code_analyzer/context_manager.py +363 -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 +89 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/__init__.py +31 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/c_cpp_language.py +231 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/go_language.py +183 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/python_language.py +219 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/rust_language.py +209 -0
- jarvis/jarvis_code_agent/code_analyzer/llm_context_recommender.py +451 -0
- jarvis/jarvis_code_agent/code_analyzer/symbol_extractor.py +77 -0
- jarvis/jarvis_code_agent/code_analyzer/tree_sitter_extractor.py +48 -0
- jarvis/jarvis_code_agent/lint.py +275 -13
- jarvis/jarvis_code_agent/utils.py +142 -0
- jarvis/jarvis_code_analysis/checklists/loader.py +20 -6
- jarvis/jarvis_code_analysis/code_review.py +583 -548
- jarvis/jarvis_data/config_schema.json +339 -28
- jarvis/jarvis_git_squash/main.py +22 -13
- jarvis/jarvis_git_utils/git_commiter.py +171 -55
- jarvis/jarvis_mcp/sse_mcp_client.py +22 -15
- jarvis/jarvis_mcp/stdio_mcp_client.py +4 -4
- jarvis/jarvis_mcp/streamable_mcp_client.py +36 -16
- jarvis/jarvis_memory_organizer/memory_organizer.py +753 -0
- jarvis/jarvis_methodology/main.py +48 -63
- jarvis/jarvis_multi_agent/__init__.py +302 -43
- jarvis/jarvis_multi_agent/main.py +70 -24
- jarvis/jarvis_platform/ai8.py +40 -23
- jarvis/jarvis_platform/base.py +210 -49
- jarvis/jarvis_platform/human.py +11 -1
- jarvis/jarvis_platform/kimi.py +82 -76
- jarvis/jarvis_platform/openai.py +73 -1
- jarvis/jarvis_platform/registry.py +8 -15
- jarvis/jarvis_platform/tongyi.py +115 -101
- jarvis/jarvis_platform/yuanbao.py +89 -63
- jarvis/jarvis_platform_manager/main.py +194 -132
- jarvis/jarvis_platform_manager/service.py +122 -86
- jarvis/jarvis_rag/cli.py +156 -53
- jarvis/jarvis_rag/embedding_manager.py +155 -12
- jarvis/jarvis_rag/llm_interface.py +10 -13
- jarvis/jarvis_rag/query_rewriter.py +63 -12
- jarvis/jarvis_rag/rag_pipeline.py +222 -40
- jarvis/jarvis_rag/reranker.py +26 -3
- jarvis/jarvis_rag/retriever.py +270 -14
- jarvis/jarvis_sec/__init__.py +3605 -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 +116 -0
- jarvis/jarvis_sec/report.py +257 -0
- jarvis/jarvis_sec/status.py +264 -0
- jarvis/jarvis_sec/types.py +20 -0
- jarvis/jarvis_sec/workflow.py +219 -0
- jarvis/jarvis_smart_shell/main.py +405 -137
- jarvis/jarvis_stats/__init__.py +13 -0
- jarvis/jarvis_stats/cli.py +387 -0
- jarvis/jarvis_stats/stats.py +711 -0
- jarvis/jarvis_stats/storage.py +612 -0
- jarvis/jarvis_stats/visualizer.py +282 -0
- jarvis/jarvis_tools/ask_user.py +1 -0
- jarvis/jarvis_tools/base.py +18 -2
- jarvis/jarvis_tools/clear_memory.py +239 -0
- jarvis/jarvis_tools/cli/main.py +220 -144
- jarvis/jarvis_tools/execute_script.py +52 -12
- jarvis/jarvis_tools/file_analyzer.py +17 -12
- jarvis/jarvis_tools/generate_new_tool.py +46 -24
- jarvis/jarvis_tools/read_code.py +277 -18
- jarvis/jarvis_tools/read_symbols.py +141 -0
- jarvis/jarvis_tools/read_webpage.py +86 -13
- jarvis/jarvis_tools/registry.py +294 -90
- jarvis/jarvis_tools/retrieve_memory.py +227 -0
- jarvis/jarvis_tools/save_memory.py +194 -0
- jarvis/jarvis_tools/search_web.py +62 -28
- jarvis/jarvis_tools/sub_agent.py +205 -0
- jarvis/jarvis_tools/sub_code_agent.py +217 -0
- jarvis/jarvis_tools/virtual_tty.py +330 -62
- jarvis/jarvis_utils/builtin_replace_map.py +4 -5
- jarvis/jarvis_utils/clipboard.py +90 -0
- jarvis/jarvis_utils/config.py +607 -50
- jarvis/jarvis_utils/embedding.py +3 -0
- jarvis/jarvis_utils/fzf.py +57 -0
- jarvis/jarvis_utils/git_utils.py +251 -29
- jarvis/jarvis_utils/globals.py +174 -17
- jarvis/jarvis_utils/http.py +58 -79
- jarvis/jarvis_utils/input.py +899 -153
- jarvis/jarvis_utils/methodology.py +210 -83
- jarvis/jarvis_utils/output.py +220 -137
- jarvis/jarvis_utils/utils.py +1906 -135
- jarvis_ai_assistant-0.7.0.dist-info/METADATA +465 -0
- jarvis_ai_assistant-0.7.0.dist-info/RECORD +192 -0
- {jarvis_ai_assistant-0.1.222.dist-info → jarvis_ai_assistant-0.7.0.dist-info}/entry_points.txt +8 -2
- jarvis/jarvis_git_details/main.py +0 -265
- jarvis/jarvis_platform/oyi.py +0 -357
- jarvis/jarvis_tools/edit_file.py +0 -255
- jarvis/jarvis_tools/rewrite_file.py +0 -195
- jarvis_ai_assistant-0.1.222.dist-info/METADATA +0 -767
- jarvis_ai_assistant-0.1.222.dist-info/RECORD +0 -110
- /jarvis/{jarvis_git_details → jarvis_memory_organizer}/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.222.dist-info → jarvis_ai_assistant-0.7.0.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.1.222.dist-info → jarvis_ai_assistant-0.7.0.dist-info}/licenses/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.222.dist-info → jarvis_ai_assistant-0.7.0.dist-info}/top_level.txt +0 -0
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""
|
|
3
|
-
文件重写工具类
|
|
4
|
-
|
|
5
|
-
功能概述:
|
|
6
|
-
1. 提供完整的文件重写功能
|
|
7
|
-
2. 支持创建新文件或完全重写现有文件
|
|
8
|
-
3. 实现原子操作:所有修改要么全部成功,要么全部回滚
|
|
9
|
-
4. 自动创建所需目录结构
|
|
10
|
-
|
|
11
|
-
核心特性:
|
|
12
|
-
- 支持不存在的文件和空文件处理
|
|
13
|
-
- 自动创建所需目录结构
|
|
14
|
-
- 完善的错误处理和回滚机制
|
|
15
|
-
- 保持文件格式和编码
|
|
16
|
-
"""
|
|
17
|
-
from typing import Any, Dict
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class FileRewriteTool:
|
|
21
|
-
name = "rewrite_file"
|
|
22
|
-
description = """文件重写工具,用于完全重写或创建文件
|
|
23
|
-
|
|
24
|
-
# 文件重写规范
|
|
25
|
-
|
|
26
|
-
## 重要提示
|
|
27
|
-
此工具用于完全重写文件内容或创建新文件。与edit_file不同,此工具会替换文件的全部内容。
|
|
28
|
-
|
|
29
|
-
## 基本使用
|
|
30
|
-
1. 指定需要重写的文件路径
|
|
31
|
-
2. 提供新的文件内容
|
|
32
|
-
3. 所有操作要么全部成功,要么全部失败并回滚
|
|
33
|
-
|
|
34
|
-
## 核心原则
|
|
35
|
-
1. **完整重写**:提供完整的文件内容,将替换原文件的所有内容
|
|
36
|
-
2. **格式保持**:
|
|
37
|
-
- 保持原始代码的缩进方式(空格或制表符)
|
|
38
|
-
- 保持原始代码的空行数量和位置
|
|
39
|
-
- 保持原始代码的行尾空格处理方式
|
|
40
|
-
- 不改变原始代码的换行风格
|
|
41
|
-
|
|
42
|
-
## 最佳实践
|
|
43
|
-
1. 确保提供格式良好的完整文件内容
|
|
44
|
-
2. 创建新文件时提供完整、格式良好的内容
|
|
45
|
-
3. 不要出现未实现的代码,如:TODO
|
|
46
|
-
"""
|
|
47
|
-
parameters = {
|
|
48
|
-
"type": "object",
|
|
49
|
-
"properties": {
|
|
50
|
-
"file": {"type": "string", "description": "需要重写的文件路径"},
|
|
51
|
-
"content": {
|
|
52
|
-
"type": "string",
|
|
53
|
-
"description": "新的文件内容,将完全替换原文件内容",
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
"required": ["file", "content"],
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
def __init__(self):
|
|
60
|
-
"""初始化文件重写工具"""
|
|
61
|
-
pass
|
|
62
|
-
|
|
63
|
-
def execute(self, args: Dict) -> Dict[str, Any]:
|
|
64
|
-
"""
|
|
65
|
-
执行文件重写操作,完全替换文件内容
|
|
66
|
-
|
|
67
|
-
参数:
|
|
68
|
-
file (str): 文件路径
|
|
69
|
-
content (str): 新的文件内容
|
|
70
|
-
|
|
71
|
-
返回:
|
|
72
|
-
dict: 包含执行结果的字典
|
|
73
|
-
{
|
|
74
|
-
"success": bool, # 是否成功完成重写
|
|
75
|
-
"stdout": str, # 标准输出信息
|
|
76
|
-
"stderr": str # 错误信息
|
|
77
|
-
}
|
|
78
|
-
"""
|
|
79
|
-
import os
|
|
80
|
-
|
|
81
|
-
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
82
|
-
|
|
83
|
-
stdout_messages = []
|
|
84
|
-
stderr_messages = []
|
|
85
|
-
success = True
|
|
86
|
-
|
|
87
|
-
file_path = args["file"]
|
|
88
|
-
new_content = args["content"]
|
|
89
|
-
agent = args.get("agent", None)
|
|
90
|
-
abs_path = os.path.abspath(file_path)
|
|
91
|
-
|
|
92
|
-
# 创建已处理文件变量,用于失败时回滚
|
|
93
|
-
original_content = None
|
|
94
|
-
processed = False
|
|
95
|
-
|
|
96
|
-
try:
|
|
97
|
-
file_exists = os.path.exists(file_path)
|
|
98
|
-
|
|
99
|
-
try:
|
|
100
|
-
# 如果文件存在,则读取原内容用于回滚
|
|
101
|
-
if file_exists:
|
|
102
|
-
with open(abs_path, "r", encoding="utf-8") as f:
|
|
103
|
-
original_content = f.read()
|
|
104
|
-
|
|
105
|
-
# 确保目录存在
|
|
106
|
-
os.makedirs(os.path.dirname(abs_path), exist_ok=True)
|
|
107
|
-
|
|
108
|
-
# 写入新内容
|
|
109
|
-
with open(abs_path, "w", encoding="utf-8") as f:
|
|
110
|
-
f.write(new_content)
|
|
111
|
-
|
|
112
|
-
processed = True
|
|
113
|
-
|
|
114
|
-
action = "创建并写入" if not file_exists else "成功重写"
|
|
115
|
-
stdout_message = f"文件 {abs_path} {action}"
|
|
116
|
-
stdout_messages.append(stdout_message)
|
|
117
|
-
PrettyOutput.print(stdout_message, OutputType.SUCCESS)
|
|
118
|
-
|
|
119
|
-
except Exception as e:
|
|
120
|
-
stderr_message = f"处理文件 {file_path} 时出错: {str(e)}"
|
|
121
|
-
stderr_messages.append(stderr_message)
|
|
122
|
-
PrettyOutput.print(stderr_message, OutputType.WARNING)
|
|
123
|
-
success = False
|
|
124
|
-
|
|
125
|
-
# 如果操作失败,回滚已修改的文件
|
|
126
|
-
if not success and processed:
|
|
127
|
-
rollback_message = "操作失败,正在回滚修改..."
|
|
128
|
-
stderr_messages.append(rollback_message)
|
|
129
|
-
PrettyOutput.print(rollback_message, OutputType.WARNING)
|
|
130
|
-
|
|
131
|
-
try:
|
|
132
|
-
if original_content is None:
|
|
133
|
-
# 如果是新创建的文件,则删除
|
|
134
|
-
if os.path.exists(abs_path):
|
|
135
|
-
os.remove(abs_path)
|
|
136
|
-
rollback_file_message = f"已删除新创建的文件: {abs_path}"
|
|
137
|
-
else:
|
|
138
|
-
# 如果是修改的文件,则恢复原内容
|
|
139
|
-
with open(abs_path, "w", encoding="utf-8") as f:
|
|
140
|
-
f.write(original_content)
|
|
141
|
-
rollback_file_message = f"已回滚文件: {abs_path}"
|
|
142
|
-
|
|
143
|
-
stderr_messages.append(rollback_file_message)
|
|
144
|
-
PrettyOutput.print(rollback_file_message, OutputType.INFO)
|
|
145
|
-
except Exception as e:
|
|
146
|
-
rollback_error = f"回滚文件 {file_path} 失败: {str(e)}"
|
|
147
|
-
stderr_messages.append(rollback_error)
|
|
148
|
-
PrettyOutput.print(rollback_error, OutputType.WARNING)
|
|
149
|
-
|
|
150
|
-
# 记录成功处理的文件(使用绝对路径)
|
|
151
|
-
if success and agent:
|
|
152
|
-
abs_path = os.path.abspath(file_path)
|
|
153
|
-
files = agent.get_user_data("files")
|
|
154
|
-
if files:
|
|
155
|
-
if abs_path not in files:
|
|
156
|
-
files.append(abs_path)
|
|
157
|
-
else:
|
|
158
|
-
files = [abs_path]
|
|
159
|
-
agent.set_user_data("files", files)
|
|
160
|
-
|
|
161
|
-
return {
|
|
162
|
-
"success": success,
|
|
163
|
-
"stdout": "\n".join(stdout_messages),
|
|
164
|
-
"stderr": "\n".join(stderr_messages),
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
except Exception as e:
|
|
168
|
-
error_msg = f"文件重写操作失败: {str(e)}"
|
|
169
|
-
PrettyOutput.print(error_msg, OutputType.WARNING)
|
|
170
|
-
|
|
171
|
-
# 如果有已修改的文件,尝试回滚
|
|
172
|
-
if processed:
|
|
173
|
-
rollback_message = "操作失败,正在回滚修改..."
|
|
174
|
-
stderr_messages.append(rollback_message)
|
|
175
|
-
PrettyOutput.print(rollback_message, OutputType.WARNING)
|
|
176
|
-
|
|
177
|
-
try:
|
|
178
|
-
if original_content is None:
|
|
179
|
-
# 如果是新创建的文件,则删除
|
|
180
|
-
if os.path.exists(file_path):
|
|
181
|
-
os.remove(file_path)
|
|
182
|
-
stderr_messages.append(f"已删除新创建的文件: {file_path}")
|
|
183
|
-
else:
|
|
184
|
-
# 如果是修改的文件,则恢复原内容
|
|
185
|
-
with open(file_path, "w", encoding="utf-8") as f:
|
|
186
|
-
f.write(original_content)
|
|
187
|
-
stderr_messages.append(f"已回滚文件: {file_path}")
|
|
188
|
-
except:
|
|
189
|
-
stderr_messages.append(f"回滚文件失败: {file_path}")
|
|
190
|
-
|
|
191
|
-
return {
|
|
192
|
-
"success": False,
|
|
193
|
-
"stdout": "",
|
|
194
|
-
"stderr": error_msg + "\n" + "\n".join(stderr_messages),
|
|
195
|
-
}
|