jarvis-ai-assistant 0.1.125__py3-none-any.whl → 0.1.128__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.
Potentially problematic release.
This version of jarvis-ai-assistant might be problematic. Click here for more details.
- jarvis/__init__.py +1 -1
- jarvis/jarvis_agent/__init__.py +205 -187
- jarvis/jarvis_code_agent/code_agent.py +116 -109
- jarvis/jarvis_code_agent/patch.py +157 -138
- jarvis/jarvis_code_agent/shell_input_handler.py +22 -0
- jarvis/jarvis_codebase/main.py +314 -288
- jarvis/jarvis_dev/main.py +695 -716
- jarvis/jarvis_lsp/base.py +0 -12
- jarvis/jarvis_lsp/cpp.py +0 -9
- jarvis/jarvis_lsp/go.py +0 -9
- jarvis/jarvis_lsp/python.py +0 -28
- jarvis/jarvis_lsp/registry.py +0 -1
- jarvis/jarvis_lsp/rust.py +0 -9
- jarvis/jarvis_multi_agent/__init__.py +52 -52
- jarvis/jarvis_platform/base.py +6 -5
- jarvis/jarvis_platform_manager/main.py +1 -1
- jarvis/jarvis_rag/main.py +250 -186
- jarvis/jarvis_smart_shell/main.py +0 -1
- jarvis/jarvis_tools/ask_codebase.py +10 -9
- jarvis/jarvis_tools/ask_user.py +2 -2
- jarvis/jarvis_tools/base.py +4 -4
- jarvis/jarvis_tools/chdir.py +28 -28
- jarvis/jarvis_tools/code_review.py +44 -39
- jarvis/jarvis_tools/create_code_agent.py +4 -4
- jarvis/jarvis_tools/create_sub_agent.py +7 -7
- jarvis/jarvis_tools/execute_shell.py +53 -23
- jarvis/jarvis_tools/execute_shell_script.py +3 -3
- jarvis/jarvis_tools/file_operation.py +70 -41
- jarvis/jarvis_tools/git_commiter.py +61 -51
- jarvis/jarvis_tools/lsp_find_definition.py +7 -7
- jarvis/jarvis_tools/lsp_prepare_rename.py +7 -7
- jarvis/jarvis_tools/methodology.py +6 -6
- jarvis/jarvis_tools/rag.py +5 -5
- jarvis/jarvis_tools/read_webpage.py +52 -32
- jarvis/jarvis_tools/registry.py +167 -180
- jarvis/jarvis_tools/search_web.py +66 -41
- jarvis/jarvis_tools/select_code_files.py +3 -3
- jarvis/jarvis_tools/tool_generator.py +68 -55
- jarvis/jarvis_utils/methodology.py +77 -59
- jarvis/jarvis_utils/output.py +1 -0
- {jarvis_ai_assistant-0.1.125.dist-info → jarvis_ai_assistant-0.1.128.dist-info}/METADATA +31 -17
- jarvis_ai_assistant-0.1.128.dist-info/RECORD +74 -0
- {jarvis_ai_assistant-0.1.125.dist-info → jarvis_ai_assistant-0.1.128.dist-info}/WHEEL +1 -1
- jarvis/jarvis_tools/lsp_validate_edit.py +0 -141
- jarvis/jarvis_tools/read_code.py +0 -192
- jarvis_ai_assistant-0.1.125.dist-info/RECORD +0 -75
- {jarvis_ai_assistant-0.1.125.dist-info → jarvis_ai_assistant-0.1.128.dist-info}/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.125.dist-info → jarvis_ai_assistant-0.1.128.dist-info}/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.1.125.dist-info → jarvis_ai_assistant-0.1.128.dist-info}/top_level.txt +0 -0
jarvis/jarvis_lsp/base.py
CHANGED
|
@@ -125,18 +125,6 @@ class BaseLSP(ABC):
|
|
|
125
125
|
"""
|
|
126
126
|
return None
|
|
127
127
|
|
|
128
|
-
@abstractmethod
|
|
129
|
-
def validate_edit(self, file_path: str, edit: Dict[str, Any]) -> bool:
|
|
130
|
-
"""Validate if proposed edit is syntactically correct.
|
|
131
|
-
|
|
132
|
-
Args:
|
|
133
|
-
file_path: Path to the file
|
|
134
|
-
edit: Edit operation in LSP format
|
|
135
|
-
|
|
136
|
-
Returns:
|
|
137
|
-
bool: True if edit is valid
|
|
138
|
-
"""
|
|
139
|
-
return False
|
|
140
128
|
|
|
141
129
|
def shutdown(self):
|
|
142
130
|
"""Shutdown LSP server cleanly."""
|
jarvis/jarvis_lsp/cpp.py
CHANGED
|
@@ -114,15 +114,6 @@ class CPPLSP(BaseLSP):
|
|
|
114
114
|
})
|
|
115
115
|
return result
|
|
116
116
|
|
|
117
|
-
def validate_edit(self, file_path: str, edit: Dict[str, Any]) -> bool:
|
|
118
|
-
# Send workspace/willRenameFiles request to check validity
|
|
119
|
-
result = self._send_request("workspace/willRenameFiles", {
|
|
120
|
-
"files": [{
|
|
121
|
-
"oldUri": f"file://{file_path}",
|
|
122
|
-
"newUri": f"file://{file_path}.tmp"
|
|
123
|
-
}]
|
|
124
|
-
})
|
|
125
|
-
return bool(result)
|
|
126
117
|
|
|
127
118
|
def shutdown(self):
|
|
128
119
|
if self.clangd_process:
|
jarvis/jarvis_lsp/go.py
CHANGED
|
@@ -120,15 +120,6 @@ class GoLSP(BaseLSP):
|
|
|
120
120
|
})
|
|
121
121
|
return result
|
|
122
122
|
|
|
123
|
-
def validate_edit(self, file_path: str, edit: Dict[str, Any]) -> bool:
|
|
124
|
-
# Send workspace/willRenameFiles request to check validity
|
|
125
|
-
result = self._send_request("workspace/willRenameFiles", {
|
|
126
|
-
"files": [{
|
|
127
|
-
"oldUri": f"file://{file_path}",
|
|
128
|
-
"newUri": f"file://{file_path}.tmp"
|
|
129
|
-
}]
|
|
130
|
-
})
|
|
131
|
-
return bool(result)
|
|
132
123
|
|
|
133
124
|
def shutdown(self):
|
|
134
125
|
if self.gopls_process:
|
jarvis/jarvis_lsp/python.py
CHANGED
|
@@ -100,34 +100,6 @@ class PythonLSP(BaseLSP):
|
|
|
100
100
|
return None
|
|
101
101
|
return None
|
|
102
102
|
|
|
103
|
-
def validate_edit(self, file_path: str, edit: Dict[str, Any]) -> bool:
|
|
104
|
-
try:
|
|
105
|
-
# Simple syntax check of the edited content
|
|
106
|
-
content = ""
|
|
107
|
-
with open(file_path, 'r') as f:
|
|
108
|
-
content = f.read()
|
|
109
|
-
|
|
110
|
-
# Apply edit
|
|
111
|
-
start = edit["range"]["start"]
|
|
112
|
-
end = edit["range"]["end"]
|
|
113
|
-
new_text = edit["newText"]
|
|
114
|
-
|
|
115
|
-
lines = content.splitlines(True)
|
|
116
|
-
before = "".join(lines[:start["line"]])
|
|
117
|
-
after = "".join(lines[end["line"] + 1:])
|
|
118
|
-
current_line = lines[start["line"]]
|
|
119
|
-
|
|
120
|
-
edited_line = (current_line[:start["character"]] +
|
|
121
|
-
new_text +
|
|
122
|
-
current_line[end["character"]:])
|
|
123
|
-
|
|
124
|
-
new_content = before + edited_line + after
|
|
125
|
-
|
|
126
|
-
# Check if new content is valid Python
|
|
127
|
-
jedi.Script(code=new_content)
|
|
128
|
-
return True
|
|
129
|
-
except Exception:
|
|
130
|
-
return False
|
|
131
103
|
|
|
132
104
|
def shutdown(self):
|
|
133
105
|
self.script_cache.clear()
|
jarvis/jarvis_lsp/registry.py
CHANGED
jarvis/jarvis_lsp/rust.py
CHANGED
|
@@ -122,15 +122,6 @@ class RustLSP(BaseLSP):
|
|
|
122
122
|
})
|
|
123
123
|
return result
|
|
124
124
|
|
|
125
|
-
def validate_edit(self, file_path: str, edit: Dict[str, Any]) -> bool:
|
|
126
|
-
# Send workspace/willRenameFiles request to check validity
|
|
127
|
-
result = self._send_request("workspace/willRenameFiles", {
|
|
128
|
-
"files": [{
|
|
129
|
-
"oldUri": f"file://{file_path}",
|
|
130
|
-
"newUri": f"file://{file_path}.tmp"
|
|
131
|
-
}]
|
|
132
|
-
})
|
|
133
|
-
return bool(result)
|
|
134
125
|
|
|
135
126
|
def shutdown(self):
|
|
136
127
|
if self.analyzer_process:
|
|
@@ -32,65 +32,65 @@ class MultiAgent(OutputHandler):
|
|
|
32
32
|
|
|
33
33
|
def prompt(self) -> str:
|
|
34
34
|
return f"""
|
|
35
|
-
# 🤖
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
# 🎯
|
|
39
|
-
##
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
|
|
45
|
-
##
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
|
|
51
|
-
# 📝
|
|
35
|
+
# 🤖 多智能体消息处理系统
|
|
36
|
+
您是多智能体系统的一部分,通过结构化消息进行通信。
|
|
37
|
+
|
|
38
|
+
# 🎯 核心规则
|
|
39
|
+
## 关键操作规则
|
|
40
|
+
- 每轮只能执行一个操作:
|
|
41
|
+
- 要么使用一个工具(文件操作、询问用户等)
|
|
42
|
+
- 要么发送一条消息给其他智能体
|
|
43
|
+
- 切勿在同一轮中同时进行这两种操作
|
|
44
|
+
|
|
45
|
+
## 消息流控制
|
|
46
|
+
- 发送消息后等待响应
|
|
47
|
+
- 处理响应后再进行下一步操作
|
|
48
|
+
- 切勿同时发送多条消息
|
|
49
|
+
- 切勿将消息与工具调用混合使用
|
|
50
|
+
|
|
51
|
+
# 📝 消息格式
|
|
52
52
|
```
|
|
53
53
|
<SEND_MESSAGE>
|
|
54
|
-
to:
|
|
54
|
+
to: 智能体名称 # 目标智能体名称
|
|
55
55
|
content: |
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
消息内容 # 消息内容
|
|
57
|
+
可使用多行 # 如果需要
|
|
58
|
+
保持正确的缩进
|
|
59
59
|
</SEND_MESSAGE>
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
# 🔄
|
|
63
|
-
1.
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
62
|
+
# 🔄 操作顺序
|
|
63
|
+
1. 选择最重要的操作
|
|
64
|
+
- 评估优先级
|
|
65
|
+
- 选择一个操作
|
|
66
|
+
- 执行该操作
|
|
67
67
|
|
|
68
|
-
2.
|
|
69
|
-
-
|
|
70
|
-
-
|
|
71
|
-
-
|
|
68
|
+
2. 等待响应
|
|
69
|
+
- 处理结果/响应
|
|
70
|
+
- 计划下一步操作
|
|
71
|
+
- 等待下一轮
|
|
72
72
|
|
|
73
|
-
3.
|
|
74
|
-
-
|
|
75
|
-
-
|
|
76
|
-
-
|
|
73
|
+
3. 处理响应
|
|
74
|
+
- 处理收到的消息
|
|
75
|
+
- 需要时回复发送者
|
|
76
|
+
- 根据响应继续任务
|
|
77
77
|
|
|
78
|
-
# 👥
|
|
78
|
+
# 👥 可用智能体
|
|
79
79
|
{chr(10).join([f"- {c.name}: {c.description}" for c in self.agents_config])}
|
|
80
80
|
|
|
81
|
-
# ❗
|
|
82
|
-
1.
|
|
83
|
-
2.
|
|
84
|
-
3.
|
|
85
|
-
4.
|
|
86
|
-
5.
|
|
87
|
-
|
|
88
|
-
# 💡
|
|
89
|
-
-
|
|
90
|
-
-
|
|
91
|
-
-
|
|
92
|
-
-
|
|
93
|
-
-
|
|
81
|
+
# ❗ 重要规则
|
|
82
|
+
1. 每轮只能执行一个操作
|
|
83
|
+
2. 等待响应
|
|
84
|
+
3. 处理后再进行下一步
|
|
85
|
+
4. 回复消息
|
|
86
|
+
5. 需要时转发任务
|
|
87
|
+
|
|
88
|
+
# 💡 提示
|
|
89
|
+
- 第一个操作将被执行
|
|
90
|
+
- 额外的操作将被忽略
|
|
91
|
+
- 总是先处理响应
|
|
92
|
+
- 需要时发送消息以继续任务
|
|
93
|
+
- 处理并回复收到的消息
|
|
94
94
|
"""
|
|
95
95
|
|
|
96
96
|
def can_handle(self, response: str) -> bool:
|
|
@@ -161,10 +161,10 @@ from: {last_agent}
|
|
|
161
161
|
content: {msg['content']}
|
|
162
162
|
"""
|
|
163
163
|
if msg['to'] not in self.agents:
|
|
164
|
-
PrettyOutput.print(f"
|
|
165
|
-
msg = self.agents[last_agent].run(f"
|
|
164
|
+
PrettyOutput.print(f"未找到智能体 {msg['to']},正在重试...", OutputType.WARNING)
|
|
165
|
+
msg = self.agents[last_agent].run(f"未找到智能体 {msg['to']},可用智能体列表: {self.agents.keys()}")
|
|
166
166
|
continue
|
|
167
|
-
PrettyOutput.print(f"{last_agent}
|
|
167
|
+
PrettyOutput.print(f"{last_agent} 正在向 {msg['to']} 发送消息...", OutputType.INFO)
|
|
168
168
|
last_agent = self.agents[msg['to']].name
|
|
169
169
|
msg = self.agents[msg['to']].run(prompt)
|
|
170
|
-
return ""
|
|
170
|
+
return ""
|
jarvis/jarvis_platform/base.py
CHANGED
|
@@ -10,7 +10,7 @@ class BasePlatform(ABC):
|
|
|
10
10
|
|
|
11
11
|
def __init__(self):
|
|
12
12
|
"""Initialize model"""
|
|
13
|
-
self.suppress_output =
|
|
13
|
+
self.suppress_output = True # 添加输出控制标志
|
|
14
14
|
|
|
15
15
|
def __del__(self):
|
|
16
16
|
"""Destroy model"""
|
|
@@ -46,10 +46,11 @@ class BasePlatform(ABC):
|
|
|
46
46
|
tokens_per_second = 0
|
|
47
47
|
|
|
48
48
|
# Print statistics
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
if not self.suppress_output:
|
|
50
|
+
PrettyOutput.print(
|
|
51
|
+
f"对话完成 - 耗时: {duration:.2f}秒, 输出字符数: {char_count}, 输出Token数量: {token_count}, 每秒Token数量: {tokens_per_second:.2f}",
|
|
52
|
+
OutputType.INFO,
|
|
53
|
+
)
|
|
53
54
|
|
|
54
55
|
# Keep original think tag handling
|
|
55
56
|
response = re.sub(r'<think>.*?</think>', '', response, flags=re.DOTALL)
|
|
@@ -59,6 +59,7 @@ def chat_with_model(platform_name: str, model_name: str):
|
|
|
59
59
|
try:
|
|
60
60
|
# Set model
|
|
61
61
|
platform.set_model_name(model_name)
|
|
62
|
+
platform.set_suppress_output(False)
|
|
62
63
|
PrettyOutput.print(f"连接到 {platform_name} 平台 {model_name} 模型", OutputType.SUCCESS)
|
|
63
64
|
|
|
64
65
|
# Start conversation loop
|
|
@@ -209,7 +210,6 @@ def service_command(args):
|
|
|
209
210
|
raise HTTPException(status_code=400, detail=f"Platform {platform_name} not found")
|
|
210
211
|
|
|
211
212
|
platform.set_model_name(model_name)
|
|
212
|
-
platform.set_suppress_output(True) # Suppress console output in server mode
|
|
213
213
|
platform_instances[key] = platform
|
|
214
214
|
|
|
215
215
|
return platform_instances[key]
|