jarvis-ai-assistant 0.1.132__py3-none-any.whl → 0.1.138__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 +330 -347
- jarvis/jarvis_agent/builtin_input_handler.py +16 -6
- jarvis/jarvis_agent/file_input_handler.py +9 -9
- jarvis/jarvis_agent/jarvis.py +143 -0
- jarvis/jarvis_agent/main.py +12 -13
- jarvis/jarvis_agent/output_handler.py +3 -3
- jarvis/jarvis_agent/patch.py +92 -64
- jarvis/jarvis_agent/shell_input_handler.py +5 -3
- jarvis/jarvis_code_agent/code_agent.py +263 -177
- jarvis/jarvis_code_agent/file_select.py +24 -24
- jarvis/jarvis_dev/main.py +45 -59
- jarvis/jarvis_git_details/__init__.py +0 -0
- jarvis/jarvis_git_details/main.py +179 -0
- jarvis/jarvis_git_squash/main.py +7 -7
- jarvis/jarvis_lsp/base.py +11 -53
- jarvis/jarvis_lsp/cpp.py +13 -28
- jarvis/jarvis_lsp/go.py +13 -28
- jarvis/jarvis_lsp/python.py +8 -27
- jarvis/jarvis_lsp/registry.py +21 -83
- jarvis/jarvis_lsp/rust.py +15 -30
- jarvis/jarvis_methodology/main.py +101 -0
- jarvis/jarvis_multi_agent/__init__.py +10 -51
- jarvis/jarvis_multi_agent/main.py +43 -0
- jarvis/jarvis_platform/__init__.py +1 -1
- jarvis/jarvis_platform/ai8.py +67 -89
- jarvis/jarvis_platform/base.py +14 -13
- jarvis/jarvis_platform/kimi.py +25 -28
- jarvis/jarvis_platform/ollama.py +24 -26
- jarvis/jarvis_platform/openai.py +15 -19
- jarvis/jarvis_platform/oyi.py +48 -50
- jarvis/jarvis_platform/registry.py +29 -44
- jarvis/jarvis_platform/yuanbao.py +39 -43
- jarvis/jarvis_platform_manager/main.py +81 -81
- jarvis/jarvis_platform_manager/openai_test.py +21 -21
- jarvis/jarvis_rag/file_processors.py +18 -18
- jarvis/jarvis_rag/main.py +262 -278
- jarvis/jarvis_smart_shell/main.py +12 -12
- jarvis/jarvis_tools/ask_codebase.py +85 -78
- jarvis/jarvis_tools/ask_user.py +8 -8
- jarvis/jarvis_tools/base.py +4 -4
- jarvis/jarvis_tools/chdir.py +9 -9
- jarvis/jarvis_tools/code_review.py +40 -21
- jarvis/jarvis_tools/create_code_agent.py +15 -15
- jarvis/jarvis_tools/create_sub_agent.py +0 -1
- jarvis/jarvis_tools/execute_python_script.py +3 -3
- jarvis/jarvis_tools/execute_shell.py +11 -11
- jarvis/jarvis_tools/execute_shell_script.py +3 -3
- jarvis/jarvis_tools/file_analyzer.py +116 -105
- jarvis/jarvis_tools/file_operation.py +22 -20
- jarvis/jarvis_tools/find_caller.py +105 -40
- jarvis/jarvis_tools/find_methodolopy.py +65 -0
- jarvis/jarvis_tools/find_symbol.py +123 -39
- jarvis/jarvis_tools/function_analyzer.py +140 -57
- jarvis/jarvis_tools/git_commiter.py +10 -10
- jarvis/jarvis_tools/lsp_get_diagnostics.py +19 -19
- jarvis/jarvis_tools/methodology.py +22 -67
- jarvis/jarvis_tools/project_analyzer.py +137 -53
- jarvis/jarvis_tools/rag.py +15 -20
- jarvis/jarvis_tools/read_code.py +25 -23
- jarvis/jarvis_tools/read_webpage.py +31 -31
- jarvis/jarvis_tools/registry.py +72 -52
- jarvis/jarvis_tools/search_web.py +23 -353
- jarvis/jarvis_tools/tool_generator.py +19 -19
- jarvis/jarvis_utils/config.py +36 -96
- jarvis/jarvis_utils/embedding.py +83 -83
- jarvis/jarvis_utils/git_utils.py +20 -20
- jarvis/jarvis_utils/globals.py +18 -6
- jarvis/jarvis_utils/input.py +10 -9
- jarvis/jarvis_utils/methodology.py +141 -140
- jarvis/jarvis_utils/output.py +13 -13
- jarvis/jarvis_utils/utils.py +23 -71
- {jarvis_ai_assistant-0.1.132.dist-info → jarvis_ai_assistant-0.1.138.dist-info}/METADATA +6 -15
- jarvis_ai_assistant-0.1.138.dist-info/RECORD +85 -0
- {jarvis_ai_assistant-0.1.132.dist-info → jarvis_ai_assistant-0.1.138.dist-info}/entry_points.txt +4 -3
- jarvis/jarvis_tools/lsp_find_definition.py +0 -150
- jarvis/jarvis_tools/lsp_find_references.py +0 -127
- jarvis/jarvis_tools/select_code_files.py +0 -62
- jarvis_ai_assistant-0.1.132.dist-info/RECORD +0 -82
- {jarvis_ai_assistant-0.1.132.dist-info → jarvis_ai_assistant-0.1.138.dist-info}/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.132.dist-info → jarvis_ai_assistant-0.1.138.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.1.132.dist-info → jarvis_ai_assistant-0.1.138.dist-info}/top_level.txt +0 -0
jarvis/jarvis_utils/utils.py
CHANGED
|
@@ -2,7 +2,7 @@ import os
|
|
|
2
2
|
import time
|
|
3
3
|
import hashlib
|
|
4
4
|
from pathlib import Path
|
|
5
|
-
from typing import Dict
|
|
5
|
+
from typing import Dict
|
|
6
6
|
import psutil
|
|
7
7
|
from jarvis.jarvis_utils.config import get_max_token_count
|
|
8
8
|
from jarvis.jarvis_utils.embedding import get_context_token_count
|
|
@@ -10,7 +10,7 @@ from jarvis.jarvis_utils.input import get_single_line_input
|
|
|
10
10
|
from jarvis.jarvis_utils.output import PrettyOutput, OutputType
|
|
11
11
|
def init_env():
|
|
12
12
|
"""初始化环境变量从~/.jarvis/env文件
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
功能:
|
|
15
15
|
1. 创建不存在的.jarvis目录
|
|
16
16
|
2. 加载环境变量到os.environ
|
|
@@ -18,7 +18,7 @@ def init_env():
|
|
|
18
18
|
"""
|
|
19
19
|
jarvis_dir = Path.home() / ".jarvis"
|
|
20
20
|
env_file = jarvis_dir / "env"
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
# Check if ~/.jarvis directory exists
|
|
23
23
|
if not jarvis_dir.exists():
|
|
24
24
|
jarvis_dir.mkdir(parents=True)
|
|
@@ -37,11 +37,11 @@ def init_env():
|
|
|
37
37
|
PrettyOutput.print(f"警告: 读取 {env_file} 失败: {e}", OutputType.WARNING)
|
|
38
38
|
def while_success(func, sleep_time: float = 0.1):
|
|
39
39
|
"""循环执行函数直到成功
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
参数:
|
|
42
42
|
func -- 要执行的函数
|
|
43
43
|
sleep_time -- 每次失败后的等待时间(秒)
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
返回:
|
|
46
46
|
函数执行结果
|
|
47
47
|
"""
|
|
@@ -61,35 +61,36 @@ def while_true(func, sleep_time: float = 0.1):
|
|
|
61
61
|
PrettyOutput.print(f"执行失败, 等待 {sleep_time}s...", OutputType.WARNING)
|
|
62
62
|
time.sleep(sleep_time)
|
|
63
63
|
return ret
|
|
64
|
-
def get_file_md5(filepath: str)->str:
|
|
64
|
+
def get_file_md5(filepath: str)->str:
|
|
65
65
|
"""Calculate the MD5 hash of a file's content.
|
|
66
|
-
|
|
66
|
+
|
|
67
67
|
Args:
|
|
68
68
|
filepath: Path to the file to hash
|
|
69
|
-
|
|
69
|
+
|
|
70
70
|
Returns:
|
|
71
71
|
str: MD5 hash of the file's content
|
|
72
72
|
"""
|
|
73
73
|
return hashlib.md5(open(filepath, "rb").read(100*1024*1024)).hexdigest()
|
|
74
74
|
def user_confirm(tip: str, default: bool = True) -> bool:
|
|
75
75
|
"""Prompt the user for confirmation with a yes/no question.
|
|
76
|
-
|
|
76
|
+
|
|
77
77
|
Args:
|
|
78
78
|
tip: The message to show to the user
|
|
79
79
|
default: The default response if user hits enter
|
|
80
|
-
|
|
80
|
+
|
|
81
81
|
Returns:
|
|
82
82
|
bool: True if user confirmed, False otherwise
|
|
83
83
|
"""
|
|
84
84
|
suffix = "[Y/n]" if default else "[y/N]"
|
|
85
85
|
ret = get_single_line_input(f"{tip} {suffix}: ")
|
|
86
86
|
return default if ret == "" else ret.lower() == "y"
|
|
87
|
+
|
|
87
88
|
def get_file_line_count(filename: str) -> int:
|
|
88
89
|
"""Count the number of lines in a file.
|
|
89
|
-
|
|
90
|
+
|
|
90
91
|
Args:
|
|
91
92
|
filename: Path to the file to count lines for
|
|
92
|
-
|
|
93
|
+
|
|
93
94
|
Returns:
|
|
94
95
|
int: Number of lines in the file, 0 if file cannot be read
|
|
95
96
|
"""
|
|
@@ -97,94 +98,45 @@ def get_file_line_count(filename: str) -> int:
|
|
|
97
98
|
return len(open(filename, "r", encoding="utf-8", errors="ignore").readlines())
|
|
98
99
|
except Exception as e:
|
|
99
100
|
return 0
|
|
100
|
-
def init_gpu_config() -> Dict:
|
|
101
|
-
"""初始化GPU配置
|
|
102
|
-
|
|
103
|
-
功能:
|
|
104
|
-
1. 检测CUDA可用性
|
|
105
|
-
2. 计算设备内存和共享内存
|
|
106
|
-
3. 设置CUDA内存分配策略
|
|
107
|
-
4. 处理异常情况
|
|
108
|
-
|
|
109
|
-
返回:
|
|
110
|
-
包含GPU配置信息的字典
|
|
111
|
-
"""
|
|
112
|
-
config = {
|
|
113
|
-
"has_gpu": False,
|
|
114
|
-
"shared_memory": 0,
|
|
115
|
-
"device_memory": 0,
|
|
116
|
-
"memory_fraction": 0.8 # 默认使用80%的可用内存
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:True"
|
|
120
|
-
|
|
121
|
-
try:
|
|
122
|
-
import torch
|
|
123
|
-
if torch.cuda.is_available():
|
|
124
|
-
# 获取GPU信息
|
|
125
|
-
gpu_mem = torch.cuda.get_device_properties(0).total_memory
|
|
126
|
-
config["has_gpu"] = True
|
|
127
|
-
config["device_memory"] = gpu_mem
|
|
128
|
-
|
|
129
|
-
# 估算共享内存 (通常是系统内存的一部分)
|
|
130
|
-
system_memory = psutil.virtual_memory().total
|
|
131
|
-
config["shared_memory"] = min(system_memory * 0.5, gpu_mem * 2) # 取系统内存的50%或GPU内存的2倍中的较小值
|
|
132
|
-
|
|
133
|
-
# 设置CUDA内存分配
|
|
134
|
-
torch.cuda.set_per_process_memory_fraction(config["memory_fraction"])
|
|
135
|
-
torch.cuda.empty_cache()
|
|
136
|
-
|
|
137
|
-
PrettyOutput.print(
|
|
138
|
-
f"GPU已初始化: {torch.cuda.get_device_name(0)}\n"
|
|
139
|
-
f"设备内存: {gpu_mem / 1024**3:.1f}GB\n"
|
|
140
|
-
f"共享内存: {config['shared_memory'] / 1024**3:.1f}GB",
|
|
141
|
-
output_type=OutputType.SUCCESS
|
|
142
|
-
)
|
|
143
|
-
else:
|
|
144
|
-
PrettyOutput.print("没有GPU可用, 使用CPU模式", output_type=OutputType.WARNING)
|
|
145
|
-
except Exception as e:
|
|
146
|
-
PrettyOutput.print(f"GPU初始化失败: {str(e)}", output_type=OutputType.WARNING)
|
|
147
|
-
|
|
148
|
-
return config
|
|
149
101
|
|
|
150
102
|
|
|
151
103
|
def is_long_context(files: list) -> bool:
|
|
152
104
|
"""检查文件列表是否属于长上下文
|
|
153
|
-
|
|
105
|
+
|
|
154
106
|
判断标准:
|
|
155
107
|
当总token数超过最大上下文长度的80%时视为长上下文
|
|
156
|
-
|
|
108
|
+
|
|
157
109
|
参数:
|
|
158
110
|
files -- 要检查的文件路径列表
|
|
159
|
-
|
|
111
|
+
|
|
160
112
|
返回:
|
|
161
113
|
布尔值表示是否属于长上下文
|
|
162
114
|
"""
|
|
163
115
|
max_token_count = get_max_token_count()
|
|
164
116
|
threshold = max_token_count * 0.8
|
|
165
117
|
total_tokens = 0
|
|
166
|
-
|
|
118
|
+
|
|
167
119
|
for file_path in files:
|
|
168
120
|
try:
|
|
169
121
|
with open(file_path, 'r', encoding='utf-8', errors="ignore") as f:
|
|
170
122
|
content = f.read()
|
|
171
123
|
total_tokens += get_context_token_count(content)
|
|
172
|
-
|
|
124
|
+
|
|
173
125
|
if total_tokens > threshold:
|
|
174
126
|
return True
|
|
175
127
|
except Exception as e:
|
|
176
128
|
PrettyOutput.print(f"读取文件 {file_path} 失败: {e}", OutputType.WARNING)
|
|
177
129
|
continue
|
|
178
|
-
|
|
130
|
+
|
|
179
131
|
return total_tokens > threshold
|
|
180
132
|
|
|
181
133
|
|
|
182
134
|
def ot(tag_name: str) -> str:
|
|
183
135
|
"""生成HTML标签开始标记
|
|
184
|
-
|
|
136
|
+
|
|
185
137
|
参数:
|
|
186
138
|
tag_name -- HTML标签名称
|
|
187
|
-
|
|
139
|
+
|
|
188
140
|
返回:
|
|
189
141
|
格式化的开始标签字符串
|
|
190
142
|
"""
|
|
@@ -192,10 +144,10 @@ def ot(tag_name: str) -> str:
|
|
|
192
144
|
|
|
193
145
|
def ct(tag_name: str) -> str:
|
|
194
146
|
"""生成HTML标签结束标记
|
|
195
|
-
|
|
147
|
+
|
|
196
148
|
参数:
|
|
197
149
|
tag_name -- HTML标签名称
|
|
198
|
-
|
|
150
|
+
|
|
199
151
|
返回:
|
|
200
152
|
格式化的结束标签字符串
|
|
201
153
|
"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: jarvis-ai-assistant
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.138
|
|
4
4
|
Summary: Jarvis: An AI assistant that uses tools to interact with the system
|
|
5
5
|
Home-page: https://github.com/skyfireitdiy/Jarvis
|
|
6
6
|
Author: skyfire
|
|
@@ -134,6 +134,8 @@ jarvis-code-review --help
|
|
|
134
134
|
jarvis-dev --help
|
|
135
135
|
# 使用git squash的功能
|
|
136
136
|
jarvis-git-squash --help
|
|
137
|
+
# 使用代码库查询功能
|
|
138
|
+
jarvis-ask-codebase --help
|
|
137
139
|
```
|
|
138
140
|
|
|
139
141
|
---
|
|
@@ -147,15 +149,10 @@ jarvis-git-squash --help
|
|
|
147
149
|
| 核心配置 | `JARVIS_AUTO_COMPLETE` | false | 是否启用自动补全功能 |
|
|
148
150
|
| 核心配置 | `JARVIS_EXECUTE_TOOL_CONFIRM` | false | 执行工具前是否需要确认 |
|
|
149
151
|
| 核心配置 | `JARVIS_CONFIRM_BEFORE_APPLY_PATCH` | true | 应用补丁前是否需要确认 |
|
|
150
|
-
| 模型配置 | `
|
|
151
|
-
| 模型配置 | `
|
|
152
|
-
| 模型配置 | `JARVIS_MODEL` | kimi | 默认模型 |
|
|
153
|
-
| 模型配置 | `JARVIS_CODEGEN_PLATFORM` | JARVIS_PLATFORM | 代码生成任务使用的平台 |
|
|
154
|
-
| 模型配置 | `JARVIS_CODEGEN_MODEL` | JARVIS_MODEL | 代码生成任务使用的模型 |
|
|
152
|
+
| 模型配置 | `JARVIS_PLATFORM` | yuanbao | 默认AI平台 |
|
|
153
|
+
| 模型配置 | `JARVIS_MODEL` | deep_seek_v3 | 默认模型 |
|
|
155
154
|
| 模型配置 | `JARVIS_THINKING_PLATFORM` | JARVIS_PLATFORM | 思考任务使用的平台 |
|
|
156
155
|
| 模型配置 | `JARVIS_THINKING_MODEL` | JARVIS_MODEL | 思考任务使用的模型 |
|
|
157
|
-
| 模型配置 | `JARVIS_CHEAP_PLATFORM` | JARVIS_PLATFORM | 低成本任务使用的平台 |
|
|
158
|
-
| 模型配置 | `JARVIS_CHEAP_MODEL` | JARVIS_MODEL | 低成本任务使用的模型 |
|
|
159
156
|
| 方法论配置 | `JARVIS_USE_METHODOLOGY` | true | 是否启用方法论系统 |
|
|
160
157
|
| 方法论配置 | `JARVIS_RECORD_METHODOLOGY` | true | 是否记录方法论 |
|
|
161
158
|
| 方法论配置 | `JARVIS_NEED_SUMMARY` | true | 是否自动生成摘要 |
|
|
@@ -169,7 +166,7 @@ jarvis-git-squash --help
|
|
|
169
166
|
| read_code | 支持行号和范围的代码文件读取 |
|
|
170
167
|
| execute_shell | 执行系统命令并捕获输出 |
|
|
171
168
|
| execute_shell_script | 执行shell脚本文件 |
|
|
172
|
-
| ask_codebase |
|
|
169
|
+
| ask_codebase | 智能代码库查询和分析,用于定位功能所在文件和理解单点实现,适合查询特定功能位置和实现原理 |
|
|
173
170
|
| ask_user | 交互式用户输入收集 |
|
|
174
171
|
| file_operation | 基础文件操作(读取/写入/存在性检查) |
|
|
175
172
|
| git_commiter | 自动化git提交处理 |
|
|
@@ -179,8 +176,6 @@ jarvis-git-squash --help
|
|
|
179
176
|
| chdir | 更改工作目录 |
|
|
180
177
|
| create_code_agent | 创建新的代码代理 |
|
|
181
178
|
| create_sub_agent | 创建子代理 |
|
|
182
|
-
| lsp_find_definition | 查找符号定义 |
|
|
183
|
-
| lsp_find_references | 查找符号引用 |
|
|
184
179
|
| lsp_validate_edit | 验证代码编辑 |
|
|
185
180
|
| rag | 文档检索和问答 |
|
|
186
181
|
| select_code_files | 选择代码文件 |
|
|
@@ -255,10 +250,6 @@ class CustomPlatform(BasePlatform):
|
|
|
255
250
|
# 执行对话
|
|
256
251
|
pass
|
|
257
252
|
|
|
258
|
-
def upload_files(self, file_list: List[str]) -> List[Dict]:
|
|
259
|
-
# 上传文件
|
|
260
|
-
pass
|
|
261
|
-
|
|
262
253
|
def reset(self):
|
|
263
254
|
# 重置平台
|
|
264
255
|
pass
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
jarvis/__init__.py,sha256=pWmblmMIqI04itaFvKT9nNVf1WmTSC_qFSJ1mIDSzNw,50
|
|
2
|
+
jarvis/jarvis_agent/__init__.py,sha256=LgZ-YqfdYBbpuxFXpJ0LkfqqD4M5VLbpg3GVGxUyIPM,21527
|
|
3
|
+
jarvis/jarvis_agent/builtin_input_handler.py,sha256=ytUyFHsOofP9KMociGYljO6hwN-s8MrbeCf6AO-3Kuw,2784
|
|
4
|
+
jarvis/jarvis_agent/file_input_handler.py,sha256=6rIF_FgC9_3UcQhFCmoMoECG4tjKaLBZZ5zDtBl037I,3235
|
|
5
|
+
jarvis/jarvis_agent/jarvis.py,sha256=NmxVJ8KwSc4fumntNL1T5TWj-FvcRgssLeBhG4sA3xk,5368
|
|
6
|
+
jarvis/jarvis_agent/main.py,sha256=j1hiMRUQiQlf_vIuL1-DGHei69pA8LPyGy8d8VpmsA0,2497
|
|
7
|
+
jarvis/jarvis_agent/output_handler.py,sha256=4limQ-Kf-YYvQjT5SMjJIyyvD1DVG8tINv1A_qbv4ho,405
|
|
8
|
+
jarvis/jarvis_agent/patch.py,sha256=7JNbzdS3iAI3UjCpg5tSCxcwTa9Dl3MkcVQXb41ojd4,19727
|
|
9
|
+
jarvis/jarvis_agent/shell_input_handler.py,sha256=hgdaKyuQIXKjJA77VVEEeiTAqQQDASFSG8DsWeV3yiw,1138
|
|
10
|
+
jarvis/jarvis_code_agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
jarvis/jarvis_code_agent/code_agent.py,sha256=5Hk7fiovny9HLV3lid2qEd8qDjD7WlrSPlmfmPJAUl0,12876
|
|
12
|
+
jarvis/jarvis_code_agent/file_select.py,sha256=tswdpDTHBZnICC0CQE0ROf1ogHDRLi5SKgAKkMHIrnQ,7920
|
|
13
|
+
jarvis/jarvis_dev/main.py,sha256=Ieg1eT2x2TaOu7V2mucMfNqVEZKs6OUhV1giNNfqH9U,28956
|
|
14
|
+
jarvis/jarvis_git_details/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
+
jarvis/jarvis_git_details/main.py,sha256=YowncVxYyJ3y2EvGrZhAJeR4yizXp6aB3dqvoYTepFY,6117
|
|
16
|
+
jarvis/jarvis_git_squash/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
+
jarvis/jarvis_git_squash/main.py,sha256=rLMTMw2KpY5JSo55wyrpvw4C75kiLZB4oqt7LNaPPN0,2140
|
|
18
|
+
jarvis/jarvis_lsp/base.py,sha256=CWfiqiQ6ZBc_lrW64Y1YAsFQeNPGoWcgTBGKgOrPVQg,2047
|
|
19
|
+
jarvis/jarvis_lsp/cpp.py,sha256=SOXFhpipvbdhlwUZ7Rh0hdWGXWnrNOxZVsmTN6ZXoZk,3148
|
|
20
|
+
jarvis/jarvis_lsp/go.py,sha256=h7vA0ArGSq9rhLZcrPXg5HdnEbKwnjVr322IkYI1jHw,3465
|
|
21
|
+
jarvis/jarvis_lsp/python.py,sha256=xMqSVJn8w6CZEquSIO2I-6TJ7-YOABgpt3SjNOV6UAk,1860
|
|
22
|
+
jarvis/jarvis_lsp/registry.py,sha256=LduRCEVH5y75IODdY8lZ3ZB3OHKpgwbZnYNxuhUmA_o,6439
|
|
23
|
+
jarvis/jarvis_lsp/rust.py,sha256=9UOiYTUwMwz2raj1G8Uec0aB5Oun7wMiWYGDhC4JMpI,3693
|
|
24
|
+
jarvis/jarvis_methodology/main.py,sha256=IBv87UOmdCailgooMtWEcqZcQHmNLhZD-kkGw5jOcVg,3375
|
|
25
|
+
jarvis/jarvis_multi_agent/__init__.py,sha256=SX8lBErhltKyYRM-rymrMz3sJ0Zl3hBXrpsPdFgzkQc,4399
|
|
26
|
+
jarvis/jarvis_multi_agent/main.py,sha256=aGuUC3YQmahabqwDwZXJjfQLYsZ3KIZdf8DZDlVNMe4,1543
|
|
27
|
+
jarvis/jarvis_platform/__init__.py,sha256=WIJtD5J7lOrWLX2bsgZGkmlMcN0NOJsnh_reybmHPjg,58
|
|
28
|
+
jarvis/jarvis_platform/ai8.py,sha256=OI1AnU8e5SiUOWSC_eLK6lCO-pNFLwq07hoGgmnYqNc,9154
|
|
29
|
+
jarvis/jarvis_platform/base.py,sha256=ZOVVlajgZPZ397MFgW6qD_zDHCNVKWmMA_lShas-iAM,3082
|
|
30
|
+
jarvis/jarvis_platform/kimi.py,sha256=ZIrV3qX38HgF6zSd7XAiwnws-VVWZd70TKaQkEQJMdQ,9567
|
|
31
|
+
jarvis/jarvis_platform/ollama.py,sha256=Di4ail1qUFjd62denf-kPbo49mltik2jZPpIxP8K5G4,4804
|
|
32
|
+
jarvis/jarvis_platform/openai.py,sha256=N0q8S3lnqtUJfhiwcH4LVX4-yJUDxvT5x0rA_B3P1Gc,4035
|
|
33
|
+
jarvis/jarvis_platform/oyi.py,sha256=KAdrSuLWFD_xRCQlHCTF7d8hVPsKgvYyVrzBldUZLsw,11131
|
|
34
|
+
jarvis/jarvis_platform/registry.py,sha256=fmyNqKgJhN7Lxco6Xu9yClkNkmxKioW57AVPrldSuM8,7575
|
|
35
|
+
jarvis/jarvis_platform/yuanbao.py,sha256=-617Vn2YC7GZIkO0YAZgCrDsExuuCl4dM2_uxIvJa7M,10343
|
|
36
|
+
jarvis/jarvis_platform_manager/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
37
|
+
jarvis/jarvis_platform_manager/main.py,sha256=o7UDrcCkLf9dTh2LOO-_bQVHjWf2X6RuSY5XRtCGvZs,20245
|
|
38
|
+
jarvis/jarvis_platform_manager/openai_test.py,sha256=8L9Xx-oR82X8l38NsVhkymYucICwMb-6yrH17Usk2TI,4954
|
|
39
|
+
jarvis/jarvis_rag/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
40
|
+
jarvis/jarvis_rag/file_processors.py,sha256=m9X45EAzxI4n8F1NvE5mJgbowSINu2Hs54Hk7Ly1eCs,4809
|
|
41
|
+
jarvis/jarvis_rag/main.py,sha256=2pGyVx0EjJtTYL99oIeu16ZWKXe4V5JMPwxFrgp0vIc,71102
|
|
42
|
+
jarvis/jarvis_smart_shell/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
43
|
+
jarvis/jarvis_smart_shell/main.py,sha256=slP_8CwpfMjWFZis0At1ANRlPb3gx1KteAg1B7R7dl4,4546
|
|
44
|
+
jarvis/jarvis_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
45
|
+
jarvis/jarvis_tools/ask_codebase.py,sha256=_UWUQo9gRSY2CVbXL_uLxYJCKVqBHjO2JIahiJJmpqo,10171
|
|
46
|
+
jarvis/jarvis_tools/ask_user.py,sha256=XbVSQ-yYGplLNw1d1s7LX54uoQCtmiqZjb7YMvijk-U,1668
|
|
47
|
+
jarvis/jarvis_tools/base.py,sha256=29-5giQMz9Bk3vkkYM7Y1uhHUEqgyDDjwluObqQE5gM,1164
|
|
48
|
+
jarvis/jarvis_tools/chdir.py,sha256=do_OdtabiH3lZcT_ynjSAX66XgH2gPl9mYiS7dMMDa8,2682
|
|
49
|
+
jarvis/jarvis_tools/code_review.py,sha256=4y3huuS_wetvuR2FBE4CZ2-KaCPWBM-e0JAVf8Up2QI,13503
|
|
50
|
+
jarvis/jarvis_tools/create_code_agent.py,sha256=ngzD1MKDNf14R1oWG1DYxJ0XYslTMZa2OIIr0Xqy8CA,4127
|
|
51
|
+
jarvis/jarvis_tools/create_sub_agent.py,sha256=wGiHukvi58wb1AKW5beP7R8VvApOn8TOeGmtXsmcETE,3001
|
|
52
|
+
jarvis/jarvis_tools/execute_python_script.py,sha256=O9ox48N9NfQkwpuNDX-c-OxqHZ0FXzofi1juQ015KD4,2012
|
|
53
|
+
jarvis/jarvis_tools/execute_shell.py,sha256=tvEPxexRI5YIyX6VHU4hKkJEOc_bdfhZ3A4kv9mQIhg,3427
|
|
54
|
+
jarvis/jarvis_tools/execute_shell_script.py,sha256=HIptXdCOobieWbTzCapZnkzHbeKWNEu3mfwBr1MWZQc,2009
|
|
55
|
+
jarvis/jarvis_tools/file_analyzer.py,sha256=xEkvxsMd6i-f9UqCiRwpicnrrViLRx1LNxs1603yfUM,9911
|
|
56
|
+
jarvis/jarvis_tools/file_operation.py,sha256=rpdVdB8c7Z0nLnbx9Sltk5XctXgwCryPJWrCgYLjp_8,6948
|
|
57
|
+
jarvis/jarvis_tools/find_caller.py,sha256=KjBZJ2uGTQ2mePitCL9RjwMwm1ZpGCzxfG1sYd3l--I,10174
|
|
58
|
+
jarvis/jarvis_tools/find_methodolopy.py,sha256=vNPqOyBE_hCBpMiciMWUBo0KuR6KuE6oOQgl2XsO0D8,2215
|
|
59
|
+
jarvis/jarvis_tools/find_symbol.py,sha256=S-SatPwH-LzclYM3f4sHpjFdknRUljSnffvu_8x5kco,10240
|
|
60
|
+
jarvis/jarvis_tools/function_analyzer.py,sha256=pX1Vl2zVso6IPXWh6fmjvakYRYsqop5pSAR6xunbHvY,12268
|
|
61
|
+
jarvis/jarvis_tools/git_commiter.py,sha256=oJT-09TxaQ1U9_kQPeAhvzQISTUKZVkQosrmBLvRcAg,6481
|
|
62
|
+
jarvis/jarvis_tools/lsp_get_diagnostics.py,sha256=njFHhL7qF31WC6SU2qjDUjfBHbRUWSGJCCuTf_9drDg,5303
|
|
63
|
+
jarvis/jarvis_tools/methodology.py,sha256=dPD7DsfDM6f3x19Qev4z7T_LC6I-8eIwqDIjIRllTRk,5189
|
|
64
|
+
jarvis/jarvis_tools/project_analyzer.py,sha256=uFo2GC4lr5KlEbdsjI3xPqpPbmo2LpJueDmnBqHXw0I,11010
|
|
65
|
+
jarvis/jarvis_tools/rag.py,sha256=SHFxbZCtWnmjPo09jdT3rn9Nofr3eSLh0douC3f5PoA,4822
|
|
66
|
+
jarvis/jarvis_tools/read_code.py,sha256=I-jU7IPD9Us4hArLpu2Yjo-uokoTUJafsceAsJHk2dE,6072
|
|
67
|
+
jarvis/jarvis_tools/read_webpage.py,sha256=q3IwcMYHPVkfnmlYJ1AXUzNjitqBm_HlXH5t9FoZEvs,9034
|
|
68
|
+
jarvis/jarvis_tools/registry.py,sha256=6pCyHSO0eaakfzvQZlx9m2rwFWowpjqUuoGS9gP5wrg,18948
|
|
69
|
+
jarvis/jarvis_tools/search_web.py,sha256=BB_8_LO2ReV-0yY5_zhizdWAqkNIbKBQOkG85H5rKrE,957
|
|
70
|
+
jarvis/jarvis_tools/tool_generator.py,sha256=0ENvezvcjJzbRRdmncS05GA3UOUW9DAoq_7Kaal51Bs,7602
|
|
71
|
+
jarvis/jarvis_utils/__init__.py,sha256=KMg-KY5rZIhGTeOD5e2Xo5CU7DX1DUz4ULWAaTQ-ZNw,825
|
|
72
|
+
jarvis/jarvis_utils/config.py,sha256=8pLdfzehcO2WVJKCBDxKX5-nRHZDmYNY1_WlnFXxQAo,4468
|
|
73
|
+
jarvis/jarvis_utils/embedding.py,sha256=XG8Uwzrvt1DRx0F3ssLu17IT2JoKeSZy19y6OLVP_es,18624
|
|
74
|
+
jarvis/jarvis_utils/git_utils.py,sha256=rAMXKlAYIvqF64iDFc_FDLxi5SMqEuKYH8GzC7RaZGY,4967
|
|
75
|
+
jarvis/jarvis_utils/globals.py,sha256=DaQ-lfLtK8bDyGVlR6jtkenkkgxQVsIkSZCZwklelzc,2769
|
|
76
|
+
jarvis/jarvis_utils/input.py,sha256=w_c3mefQ9A1BuJcTIZZfRAq2MckPUlGL60lxbk-NWkg,6633
|
|
77
|
+
jarvis/jarvis_utils/methodology.py,sha256=INrw_hvCvUX3Vyl1gFQpowTotmVF72A2xYkzrN37yWA,19534
|
|
78
|
+
jarvis/jarvis_utils/output.py,sha256=EUJQ1pnCj7PcD9-gXIXMFNrxAwyZBeUd8X-fNEJYJ1k,8443
|
|
79
|
+
jarvis/jarvis_utils/utils.py,sha256=8Bjb38TDhi-RkSZWF5Xn2NVIGzTb7Mvnxis4jcJARN8,4617
|
|
80
|
+
jarvis_ai_assistant-0.1.138.dist-info/LICENSE,sha256=AGgVgQmTqFvaztRtCAXsAMryUymB18gZif7_l2e1XOg,1063
|
|
81
|
+
jarvis_ai_assistant-0.1.138.dist-info/METADATA,sha256=nSO0YfBI1dLnxzlD6XMvL2rsNpVfoam9jUK0tfo6CBM,9955
|
|
82
|
+
jarvis_ai_assistant-0.1.138.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
|
83
|
+
jarvis_ai_assistant-0.1.138.dist-info/entry_points.txt,sha256=8sxkrMFX9M0lYwQDHk8UNq3YgvyPMsMwKoQBpGSeZ0s,954
|
|
84
|
+
jarvis_ai_assistant-0.1.138.dist-info/top_level.txt,sha256=1BOxyWfzOP_ZXj8rVTDnNCJ92bBGB0rwq8N1PCpoMIs,7
|
|
85
|
+
jarvis_ai_assistant-0.1.138.dist-info/RECORD,,
|
{jarvis_ai_assistant-0.1.132.dist-info → jarvis_ai_assistant-0.1.138.dist-info}/entry_points.txt
RENAMED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
[console_scripts]
|
|
2
|
-
jarvis = jarvis.jarvis_agent:main
|
|
2
|
+
jarvis = jarvis.jarvis_agent.jarvis:main
|
|
3
3
|
jarvis-agent = jarvis.jarvis_agent.main:main
|
|
4
4
|
jarvis-ask-codebase = jarvis.jarvis_tools.ask_codebase:main
|
|
5
5
|
jarvis-code-agent = jarvis.jarvis_code_agent.code_agent:main
|
|
6
6
|
jarvis-code-review = jarvis.jarvis_tools.code_review:main
|
|
7
|
-
jarvis-codebase = jarvis.jarvis_codebase.main:main
|
|
8
7
|
jarvis-dev = jarvis.jarvis_dev.main:main
|
|
9
8
|
jarvis-git-commit = jarvis.jarvis_tools.git_commiter:main
|
|
9
|
+
jarvis-git-details = jarvis.jarvis_git_details.main:main
|
|
10
10
|
jarvis-git-squash = jarvis.jarvis_git_squash.main:main
|
|
11
|
-
jarvis-
|
|
11
|
+
jarvis-methodology = jarvis.jarvis_methodology.main:main
|
|
12
|
+
jarvis-multi-agent = jarvis.jarvis_multi_agent.main:main
|
|
12
13
|
jarvis-platform-manager = jarvis.jarvis_platform_manager.main:main
|
|
13
14
|
jarvis-rag = jarvis.jarvis_rag.main:main
|
|
14
15
|
jarvis-smart-shell = jarvis.jarvis_smart_shell.main:main
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from typing import Dict, Any
|
|
3
|
-
from jarvis.jarvis_lsp.registry import LSPRegistry
|
|
4
|
-
|
|
5
|
-
class LSPFindDefinitionTool:
|
|
6
|
-
"""使用LSP在代码中查找符号定义的工具"""
|
|
7
|
-
|
|
8
|
-
name = "lsp_find_definition"
|
|
9
|
-
description = "在代码中查找符号的定义"
|
|
10
|
-
parameters = {
|
|
11
|
-
"file_path": "包含符号的文件路径",
|
|
12
|
-
"line": "符号所在的行号(从0开始)",
|
|
13
|
-
"character": "符号在行中的字符位置",
|
|
14
|
-
"language": f"文件的编程语言({', '.join(LSPRegistry.get_global_lsp_registry().get_supported_languages())})",
|
|
15
|
-
"root_dir": {
|
|
16
|
-
"type": "string",
|
|
17
|
-
"description": "LSP操作的根目录路径(可选)",
|
|
18
|
-
"default": "."
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
@staticmethod
|
|
23
|
-
def check() -> bool:
|
|
24
|
-
"""Check if any LSP server is available."""
|
|
25
|
-
registry = LSPRegistry.get_global_lsp_registry()
|
|
26
|
-
return len(registry.get_supported_languages()) > 0
|
|
27
|
-
|
|
28
|
-
def execute(self, args: Dict[str, Any]) -> Dict[str, Any]:
|
|
29
|
-
"""Execute the tool."""
|
|
30
|
-
file_path = args.get("file_path", "")
|
|
31
|
-
line = args.get("line", None)
|
|
32
|
-
character = args.get("character", None)
|
|
33
|
-
language = args.get("language", "")
|
|
34
|
-
root_dir = args.get("root_dir", ".")
|
|
35
|
-
|
|
36
|
-
# Validate inputs
|
|
37
|
-
if not all([file_path, line is not None, character is not None, language]):
|
|
38
|
-
return {
|
|
39
|
-
"success": False,
|
|
40
|
-
"stderr": "All parameters (file_path, line, character, language) must be provided",
|
|
41
|
-
"stdout": ""
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
try:
|
|
45
|
-
line = int(line)
|
|
46
|
-
character = int(character)
|
|
47
|
-
except ValueError:
|
|
48
|
-
return {
|
|
49
|
-
"success": False,
|
|
50
|
-
"stderr": "Line and character must be integers",
|
|
51
|
-
"stdout": ""
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if not os.path.exists(file_path):
|
|
55
|
-
return {
|
|
56
|
-
"success": False,
|
|
57
|
-
"stderr": f"File not found: {file_path}",
|
|
58
|
-
"stdout": ""
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
# Store current directory
|
|
62
|
-
original_dir = os.getcwd()
|
|
63
|
-
|
|
64
|
-
try:
|
|
65
|
-
# Change to root_dir
|
|
66
|
-
os.chdir(root_dir)
|
|
67
|
-
|
|
68
|
-
# Get LSP instance
|
|
69
|
-
registry = LSPRegistry.get_global_lsp_registry()
|
|
70
|
-
lsp = registry.create_lsp(language)
|
|
71
|
-
|
|
72
|
-
if not lsp:
|
|
73
|
-
return {
|
|
74
|
-
"success": False,
|
|
75
|
-
"stderr": f"No LSP support for language: {language}",
|
|
76
|
-
"stdout": ""
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
try:
|
|
80
|
-
# Initialize LSP
|
|
81
|
-
if not lsp.initialize(os.path.abspath(os.getcwd())):
|
|
82
|
-
return {
|
|
83
|
-
"success": False,
|
|
84
|
-
"stderr": "LSP initialization failed",
|
|
85
|
-
"stdout": ""
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
# Get symbol at position
|
|
89
|
-
symbol = LSPRegistry.get_text_at_position(file_path, line, character)
|
|
90
|
-
if not symbol:
|
|
91
|
-
return {
|
|
92
|
-
"success": False,
|
|
93
|
-
"stderr": f"No symbol found at position {line}:{character}",
|
|
94
|
-
"stdout": ""
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
# Find definition
|
|
98
|
-
defn = lsp.find_definition(file_path, (line, character))
|
|
99
|
-
|
|
100
|
-
if not defn:
|
|
101
|
-
return {
|
|
102
|
-
"success": True,
|
|
103
|
-
"stdout": f"No definition found for '{symbol}'",
|
|
104
|
-
"stderr": ""
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
# Format output
|
|
108
|
-
def_line = defn["range"]["start"]["line"]
|
|
109
|
-
def_char = defn["range"]["start"]["character"]
|
|
110
|
-
context = LSPRegistry.get_line_at_position(defn["uri"], def_line).strip()
|
|
111
|
-
|
|
112
|
-
output = [
|
|
113
|
-
f"Definition of '{symbol}':",
|
|
114
|
-
f"File: {defn['uri']}",
|
|
115
|
-
f"Line {def_line + 1}, Col {def_char + 1}: {context}"
|
|
116
|
-
]
|
|
117
|
-
|
|
118
|
-
# Get a few lines of context around the definition
|
|
119
|
-
try:
|
|
120
|
-
with open(defn["uri"], 'r', errors="ignore") as f:
|
|
121
|
-
lines = f.readlines()
|
|
122
|
-
start = max(0, def_line - 2)
|
|
123
|
-
end = min(len(lines), def_line + 3)
|
|
124
|
-
|
|
125
|
-
if start < def_line:
|
|
126
|
-
output.append("\nContext:")
|
|
127
|
-
for i in range(start, end):
|
|
128
|
-
prefix = ">" if i == def_line else " "
|
|
129
|
-
output.append(f"{prefix} {i+1:4d} | {lines[i].rstrip()}")
|
|
130
|
-
except Exception:
|
|
131
|
-
pass
|
|
132
|
-
|
|
133
|
-
return {
|
|
134
|
-
"success": True,
|
|
135
|
-
"stdout": "\n".join(output),
|
|
136
|
-
"stderr": ""
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
except Exception as e:
|
|
140
|
-
return {
|
|
141
|
-
"success": False,
|
|
142
|
-
"stderr": f"Error finding definition: {str(e)}",
|
|
143
|
-
"stdout": ""
|
|
144
|
-
}
|
|
145
|
-
finally:
|
|
146
|
-
if lsp:
|
|
147
|
-
lsp.shutdown()
|
|
148
|
-
finally:
|
|
149
|
-
# Always restore original directory
|
|
150
|
-
os.chdir(original_dir)
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from typing import Dict, Any
|
|
3
|
-
from jarvis.jarvis_lsp.registry import LSPRegistry
|
|
4
|
-
|
|
5
|
-
class LSPFindReferencesTool:
|
|
6
|
-
"""Tool for finding references to symbols in code using LSP."""
|
|
7
|
-
|
|
8
|
-
name = "lsp_find_references"
|
|
9
|
-
description = "Find all references to a symbol in code"
|
|
10
|
-
parameters = {
|
|
11
|
-
"file_path": "Path to the file containing the symbol",
|
|
12
|
-
"line": "Line number (0-based) of the symbol",
|
|
13
|
-
"character": "Character position in the line",
|
|
14
|
-
"language": f"Programming language of the file ({', '.join(LSPRegistry.get_global_lsp_registry().get_supported_languages())})",
|
|
15
|
-
"root_dir": {
|
|
16
|
-
"type": "string",
|
|
17
|
-
"description": "Root directory for LSP operations (optional)",
|
|
18
|
-
"default": "."
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
@staticmethod
|
|
23
|
-
def check() -> bool:
|
|
24
|
-
"""Check if any LSP server is available."""
|
|
25
|
-
registry = LSPRegistry.get_global_lsp_registry()
|
|
26
|
-
return len(registry.get_supported_languages()) > 0
|
|
27
|
-
|
|
28
|
-
def execute(self, args: Dict[str, Any]) -> Dict[str, Any]:
|
|
29
|
-
"""Execute the tool."""
|
|
30
|
-
file_path = args.get("file_path", "")
|
|
31
|
-
line = args.get("line", None)
|
|
32
|
-
character = args.get("character", None)
|
|
33
|
-
language = args.get("language", "")
|
|
34
|
-
root_dir = args.get("root_dir", ".")
|
|
35
|
-
|
|
36
|
-
# Validate inputs
|
|
37
|
-
if not all([file_path, line is not None, character is not None, language]):
|
|
38
|
-
return {
|
|
39
|
-
"success": False,
|
|
40
|
-
"stderr": "All parameters (file_path, line, character, language) must be provided",
|
|
41
|
-
"stdout": ""
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
try:
|
|
45
|
-
line = int(line)
|
|
46
|
-
character = int(character)
|
|
47
|
-
except ValueError:
|
|
48
|
-
return {
|
|
49
|
-
"success": False,
|
|
50
|
-
"stderr": "Line and character must be integers",
|
|
51
|
-
"stdout": ""
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if not os.path.exists(file_path):
|
|
55
|
-
return {
|
|
56
|
-
"success": False,
|
|
57
|
-
"stderr": f"File not found: {file_path}",
|
|
58
|
-
"stdout": ""
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
# Store current directory
|
|
62
|
-
original_dir = os.getcwd()
|
|
63
|
-
|
|
64
|
-
try:
|
|
65
|
-
# Change to root_dir
|
|
66
|
-
os.chdir(root_dir)
|
|
67
|
-
|
|
68
|
-
# Get LSP instance
|
|
69
|
-
registry = LSPRegistry.get_global_lsp_registry()
|
|
70
|
-
lsp = registry.create_lsp(language)
|
|
71
|
-
|
|
72
|
-
if not lsp:
|
|
73
|
-
return {
|
|
74
|
-
"success": False,
|
|
75
|
-
"stderr": f"No LSP support for language: {language}",
|
|
76
|
-
"stdout": ""
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
try:
|
|
80
|
-
# Initialize LSP
|
|
81
|
-
if not lsp.initialize(os.path.abspath(os.getcwd())):
|
|
82
|
-
return {
|
|
83
|
-
"success": False,
|
|
84
|
-
"stderr": "LSP initialization failed",
|
|
85
|
-
"stdout": ""
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
# Get symbol at position
|
|
89
|
-
symbol = LSPRegistry.get_text_at_position(file_path, line, character)
|
|
90
|
-
if not symbol:
|
|
91
|
-
return {
|
|
92
|
-
"success": False,
|
|
93
|
-
"stderr": f"No symbol found at position {line}:{character}",
|
|
94
|
-
"stdout": ""
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
# Find references
|
|
98
|
-
refs = lsp.find_references(file_path, (line, character))
|
|
99
|
-
|
|
100
|
-
# Format output
|
|
101
|
-
output = [f"References to '{symbol}':\n"]
|
|
102
|
-
for ref in refs:
|
|
103
|
-
ref_line = ref["range"]["start"]["line"]
|
|
104
|
-
ref_char = ref["range"]["start"]["character"]
|
|
105
|
-
context = LSPRegistry.get_line_at_position(ref["uri"], ref_line).strip()
|
|
106
|
-
output.append(f"File: {ref['uri']}")
|
|
107
|
-
output.append(f"Line {ref_line + 1}, Col {ref_char + 1}: {context}")
|
|
108
|
-
output.append("-" * 40)
|
|
109
|
-
|
|
110
|
-
return {
|
|
111
|
-
"success": True,
|
|
112
|
-
"stdout": "\n".join(output) if len(refs) > 0 else f"No references found for '{symbol}'",
|
|
113
|
-
"stderr": ""
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
except Exception as e:
|
|
117
|
-
return {
|
|
118
|
-
"success": False,
|
|
119
|
-
"stderr": f"Error finding references: {str(e)}",
|
|
120
|
-
"stdout": ""
|
|
121
|
-
}
|
|
122
|
-
finally:
|
|
123
|
-
if lsp:
|
|
124
|
-
lsp.shutdown()
|
|
125
|
-
finally:
|
|
126
|
-
# Always restore original directory
|
|
127
|
-
os.chdir(original_dir)
|