jarvis-ai-assistant 0.1.150__py3-none-any.whl → 0.1.152__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.

@@ -6,7 +6,7 @@ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
6
6
  from . import McpClient
7
7
 
8
8
 
9
- class LocalMcpClient(McpClient):
9
+ class StdioMcpClient(McpClient):
10
10
  """本地MCP客户端实现
11
11
 
12
12
  参数:
@@ -228,6 +228,91 @@ class LocalMcpClient(McpClient):
228
228
  'stderr': str(e)
229
229
  }
230
230
 
231
+ def get_resource_list(self) -> List[Dict[str, Any]]:
232
+ """获取资源列表
233
+
234
+ 返回:
235
+ List[Dict[str, Any]]: 资源列表,每个资源包含以下字段:
236
+ - uri: str - 资源的唯一标识符
237
+ - name: str - 资源的名称
238
+ - description: str - 资源的描述(可选)
239
+ - mimeType: str - 资源的MIME类型(可选)
240
+ """
241
+ try:
242
+ response = self._send_request('resources/list', {})
243
+ if 'result' in response and 'resources' in response['result']:
244
+ return response['result']['resources']
245
+ else:
246
+ error_msg = "获取资源列表失败"
247
+ if 'error' in response:
248
+ error_msg += f": {response['error']}"
249
+ else:
250
+ error_msg += ": 未知错误"
251
+ PrettyOutput.print(error_msg, OutputType.ERROR)
252
+ return []
253
+ except Exception as e:
254
+ PrettyOutput.print(f"获取资源列表失败: {str(e)}", OutputType.ERROR)
255
+ return []
256
+
257
+ def get_resource(self, uri: str) -> Dict[str, Any]:
258
+ """获取指定资源的内容
259
+
260
+ 参数:
261
+ uri: str - 资源的URI标识符
262
+
263
+ 返回:
264
+ Dict[str, Any]: 执行结果,包含以下字段:
265
+ - success: bool - 是否执行成功
266
+ - stdout: str - 资源内容(文本或base64编码的二进制内容)
267
+ - stderr: str - 错误信息
268
+ """
269
+ try:
270
+ response = self._send_request('resources/read', {
271
+ 'uri': uri
272
+ })
273
+ if 'result' in response and 'contents' in response['result']:
274
+ contents = response['result']['contents']
275
+ if contents:
276
+ content = contents[0] # 获取第一个资源内容
277
+ # 根据资源类型返回内容
278
+ if 'text' in content:
279
+ return {
280
+ 'success': True,
281
+ 'stdout': content['text'],
282
+ 'stderr': ''
283
+ }
284
+ elif 'blob' in content:
285
+ return {
286
+ 'success': True,
287
+ 'stdout': content['blob'],
288
+ 'stderr': ''
289
+ }
290
+ return {
291
+ 'success': False,
292
+ 'stdout': '',
293
+ 'stderr': '资源内容为空'
294
+ }
295
+ else:
296
+ error_msg = "获取资源内容失败"
297
+ if 'error' in response:
298
+ error_msg += f": {response['error']}"
299
+ else:
300
+ error_msg += ": 未知错误"
301
+ PrettyOutput.print(error_msg, OutputType.ERROR)
302
+ return {
303
+ 'success': False,
304
+ 'stdout': '',
305
+ 'stderr': error_msg
306
+ }
307
+ except Exception as e:
308
+ error_msg = f"获取资源内容失败: {str(e)}"
309
+ PrettyOutput.print(error_msg, OutputType.ERROR)
310
+ return {
311
+ 'success': False,
312
+ 'stdout': '',
313
+ 'stderr': error_msg
314
+ }
315
+
231
316
  def __del__(self):
232
317
  """清理资源"""
233
318
  if self.process:
@@ -156,10 +156,9 @@ class AskCodebaseTool:
156
156
  2. 使用fd命令查找可能相关的文件
157
157
  3. 使用rg命令搜索关键词和代码模式
158
158
  4. 使用read_code工具直接读取和分析相关文件内容
159
- 5. 只有在fd、rg和read_code都无法解决问题时才考虑使用RAG工具
160
- 6. 根据文件内容提供具体、准确的回答
161
- 7. 确保分析的完整性,收集充分的信息后再得出结论,不要在只掌握部分信息就得出结论
162
- 8. 优先查阅README文件、文档目录和项目文档
159
+ 5. 根据文件内容提供具体、准确的回答
160
+ 6. 确保分析的完整性,收集充分的信息后再得出结论,不要在只掌握部分信息就得出结论
161
+ 7. 优先查阅README文件、文档目录和项目文档
163
162
 
164
163
  ## 分析步骤
165
164
  1. **确定项目的编程语言**:
@@ -186,12 +185,6 @@ class AskCodebaseTool:
186
185
  - 提供基于直接分析代码的具体回答
187
186
  - 引用具体文件和代码片段作为依据
188
187
 
189
- ## 关于RAG工具使用
190
- - RAG工具应作为最后选择,仅在fd、rg和read_code都无法解决问题时使用
191
- - 必须通过查看实际代码文件验证RAG返回的每条重要信息
192
- - 对于关键发现,始终使用`read_code`工具查看原始文件内容进行求证
193
- - 如发现RAG结果与实际代码不符,以实际代码为准
194
-
195
188
  ## 输出要求
196
189
  - 提供准确、具体的回答,避免模糊不清的描述
197
190
  - 引用具体文件路径和代码片段作为依据