jarvis-ai-assistant 0.1.177__py3-none-any.whl → 0.1.178__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 +22 -53
- jarvis/jarvis_event/__init__.py +0 -0
- jarvis/jarvis_platform/openai.py +66 -10
- jarvis/jarvis_tools/ask_codebase.py +2 -1
- jarvis/jarvis_tools/edit_file.py +34 -26
- jarvis/jarvis_tools/registry.py +1 -1
- jarvis/jarvis_utils/config.py +10 -1
- {jarvis_ai_assistant-0.1.177.dist-info → jarvis_ai_assistant-0.1.178.dist-info}/METADATA +1 -1
- {jarvis_ai_assistant-0.1.177.dist-info → jarvis_ai_assistant-0.1.178.dist-info}/RECORD +14 -20
- jarvis/jarvis_lsp/base.py +0 -66
- jarvis/jarvis_lsp/cpp.py +0 -99
- jarvis/jarvis_lsp/go.py +0 -104
- jarvis/jarvis_lsp/python.py +0 -58
- jarvis/jarvis_lsp/registry.py +0 -169
- jarvis/jarvis_lsp/rust.py +0 -107
- jarvis/jarvis_tools/lsp_get_diagnostics.py +0 -147
- {jarvis_ai_assistant-0.1.177.dist-info → jarvis_ai_assistant-0.1.178.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.1.177.dist-info → jarvis_ai_assistant-0.1.178.dist-info}/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.1.177.dist-info → jarvis_ai_assistant-0.1.178.dist-info}/licenses/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.177.dist-info → jarvis_ai_assistant-0.1.178.dist-info}/top_level.txt +0 -0
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
import os
|
|
3
|
-
from typing import Dict, Any
|
|
4
|
-
from jarvis.jarvis_lsp.registry import LSPRegistry
|
|
5
|
-
class LSPGetDiagnosticsTool:
|
|
6
|
-
"""Tool for getting diagnostics (errors, warnings) from code using LSP."""
|
|
7
|
-
|
|
8
|
-
# 工具名称
|
|
9
|
-
name = "lsp_get_diagnostics"
|
|
10
|
-
# 工具描述
|
|
11
|
-
description = "Get diagnostic information (errors, warnings) from code files"
|
|
12
|
-
# 工具标签
|
|
13
|
-
# 工具参数定义
|
|
14
|
-
parameters = {
|
|
15
|
-
"file_path": "Path to the file to analyze",
|
|
16
|
-
"language": f"Programming language of the file ({', '.join(LSPRegistry.get_global_lsp_registry().get_supported_languages())})",
|
|
17
|
-
"root_dir": {
|
|
18
|
-
"type": "string",
|
|
19
|
-
"description": "Root directory for LSP operations (optional)",
|
|
20
|
-
"default": "."
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
@staticmethod
|
|
25
|
-
def check() -> bool:
|
|
26
|
-
"""检查是否有可用的LSP服务器"""
|
|
27
|
-
registry = LSPRegistry.get_global_lsp_registry()
|
|
28
|
-
return len(registry.get_supported_languages()) > 0
|
|
29
|
-
|
|
30
|
-
def execute(self, args: Dict[str, Any]) -> Dict[str, Any]:
|
|
31
|
-
"""执行工具的主要逻辑"""
|
|
32
|
-
file_path = args.get("file_path", "")
|
|
33
|
-
language = args.get("language", "")
|
|
34
|
-
root_dir = args.get("root_dir", ".")
|
|
35
|
-
|
|
36
|
-
# 验证输入参数
|
|
37
|
-
if not all([file_path, language]):
|
|
38
|
-
return {
|
|
39
|
-
"success": False,
|
|
40
|
-
"stderr": "Both file_path and language must be provided",
|
|
41
|
-
"stdout": ""
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
# 检查文件是否存在
|
|
45
|
-
if not os.path.exists(file_path):
|
|
46
|
-
return {
|
|
47
|
-
"success": False,
|
|
48
|
-
"stderr": f"File not found: {file_path}",
|
|
49
|
-
"stdout": ""
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
# 存储当前目录
|
|
53
|
-
original_dir = os.getcwd()
|
|
54
|
-
|
|
55
|
-
try:
|
|
56
|
-
# 切换到root_dir
|
|
57
|
-
os.chdir(root_dir)
|
|
58
|
-
|
|
59
|
-
# 获取LSP实例
|
|
60
|
-
registry = LSPRegistry.get_global_lsp_registry()
|
|
61
|
-
lsp = registry.create_lsp(language)
|
|
62
|
-
|
|
63
|
-
# 检查语言是否支持
|
|
64
|
-
if not lsp:
|
|
65
|
-
return {
|
|
66
|
-
"success": False,
|
|
67
|
-
"stderr": f"No LSP support for language: {language}",
|
|
68
|
-
"stdout": ""
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
try:
|
|
72
|
-
# 初始化LSP
|
|
73
|
-
if not lsp.initialize(os.path.abspath(os.getcwd())):
|
|
74
|
-
return {
|
|
75
|
-
"success": False,
|
|
76
|
-
"stderr": "LSP initialization failed",
|
|
77
|
-
"stdout": ""
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
# 获取诊断信息
|
|
81
|
-
diagnostics = lsp.get_diagnostics(file_path)
|
|
82
|
-
|
|
83
|
-
# 如果没有诊断信息
|
|
84
|
-
if not diagnostics:
|
|
85
|
-
return {
|
|
86
|
-
"success": True,
|
|
87
|
-
"stdout": "No issues found in the file",
|
|
88
|
-
"stderr": ""
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
# 格式化输出
|
|
92
|
-
output = ["Diagnostics:"]
|
|
93
|
-
# 严重程度映射
|
|
94
|
-
severity_map = {1: "Error", 2: "Warning", 3: "Info", 4: "Hint"}
|
|
95
|
-
|
|
96
|
-
# 按严重程度和行号排序诊断信息
|
|
97
|
-
sorted_diagnostics = sorted(
|
|
98
|
-
diagnostics,
|
|
99
|
-
key=lambda x: (x["severity"], x["range"]["start"]["line"])
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
# 处理每个诊断信息
|
|
103
|
-
for diag in sorted_diagnostics:
|
|
104
|
-
severity = severity_map.get(diag["severity"], "Unknown")
|
|
105
|
-
start = diag["range"]["start"]
|
|
106
|
-
line = LSPRegistry.get_line_at_position(file_path, start["line"]).strip()
|
|
107
|
-
|
|
108
|
-
output.extend([
|
|
109
|
-
f"\n{severity} at line {start['line'] + 1}, column {start['character'] + 1}:",
|
|
110
|
-
f"Message: {diag['message']}",
|
|
111
|
-
f"Code: {line}",
|
|
112
|
-
"-" * 60
|
|
113
|
-
])
|
|
114
|
-
|
|
115
|
-
# 处理相关附加信息
|
|
116
|
-
if diag.get("relatedInformation"):
|
|
117
|
-
output.append("Related information:")
|
|
118
|
-
for info in diag["relatedInformation"]:
|
|
119
|
-
info_line = LSPRegistry.get_line_at_position(
|
|
120
|
-
info["location"]["uri"],
|
|
121
|
-
info["location"]["range"]["start"]["line"]
|
|
122
|
-
).strip()
|
|
123
|
-
output.extend([
|
|
124
|
-
f" - {info['message']}",
|
|
125
|
-
f" at {info['location']['uri']}:{info['location']['range']['start']['line'] + 1}",
|
|
126
|
-
f" {info_line}"
|
|
127
|
-
])
|
|
128
|
-
|
|
129
|
-
return {
|
|
130
|
-
"success": True,
|
|
131
|
-
"stdout": "\n".join(output),
|
|
132
|
-
"stderr": ""
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
except Exception as e:
|
|
136
|
-
return {
|
|
137
|
-
"success": False,
|
|
138
|
-
"stderr": f"Error getting diagnostics: {str(e)}",
|
|
139
|
-
"stdout": ""
|
|
140
|
-
}
|
|
141
|
-
finally:
|
|
142
|
-
# 确保关闭LSP连接
|
|
143
|
-
if lsp:
|
|
144
|
-
lsp.shutdown()
|
|
145
|
-
finally:
|
|
146
|
-
# 恢复原始目录
|
|
147
|
-
os.chdir(original_dir)
|
|
File without changes
|
{jarvis_ai_assistant-0.1.177.dist-info → jarvis_ai_assistant-0.1.178.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{jarvis_ai_assistant-0.1.177.dist-info → jarvis_ai_assistant-0.1.178.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{jarvis_ai_assistant-0.1.177.dist-info → jarvis_ai_assistant-0.1.178.dist-info}/top_level.txt
RENAMED
|
File without changes
|