jarvis-ai-assistant 0.1.177__py3-none-any.whl → 0.1.179__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 +145 -125
- jarvis/jarvis_agent/builtin_input_handler.py +1 -1
- jarvis/jarvis_agent/jarvis.py +9 -13
- jarvis/jarvis_agent/main.py +4 -2
- jarvis/jarvis_code_agent/code_agent.py +34 -23
- jarvis/jarvis_code_agent/lint.py +164 -0
- jarvis/jarvis_code_analysis/checklists/loader.py +6 -20
- jarvis/jarvis_code_analysis/code_review.py +8 -6
- jarvis/jarvis_dev/main.py +1 -8
- jarvis/jarvis_event/__init__.py +0 -0
- jarvis/jarvis_git_details/main.py +1 -1
- jarvis/jarvis_git_squash/main.py +5 -3
- jarvis/jarvis_git_utils/git_commiter.py +24 -23
- jarvis/jarvis_mcp/sse_mcp_client.py +6 -4
- jarvis/jarvis_mcp/stdio_mcp_client.py +5 -4
- jarvis/jarvis_mcp/streamable_mcp_client.py +404 -0
- jarvis/jarvis_methodology/main.py +10 -9
- jarvis/jarvis_multi_agent/main.py +3 -1
- jarvis/jarvis_platform/base.py +14 -8
- jarvis/jarvis_platform/human.py +3 -1
- jarvis/jarvis_platform/kimi.py +10 -7
- jarvis/jarvis_platform/openai.py +70 -11
- jarvis/jarvis_platform/registry.py +6 -2
- jarvis/jarvis_platform/yuanbao.py +13 -10
- jarvis/jarvis_platform_manager/main.py +11 -9
- jarvis/jarvis_smart_shell/main.py +1 -0
- jarvis/jarvis_tools/ask_codebase.py +6 -4
- jarvis/jarvis_tools/ask_user.py +2 -1
- jarvis/jarvis_tools/base.py +3 -1
- jarvis/jarvis_tools/chdir.py +2 -1
- jarvis/jarvis_tools/cli/main.py +1 -0
- jarvis/jarvis_tools/code_plan.py +5 -3
- jarvis/jarvis_tools/create_code_agent.py +5 -2
- jarvis/jarvis_tools/create_sub_agent.py +1 -3
- jarvis/jarvis_tools/edit_file.py +37 -29
- jarvis/jarvis_tools/execute_script.py +1 -1
- jarvis/jarvis_tools/file_analyzer.py +5 -3
- jarvis/jarvis_tools/file_operation.py +4 -7
- jarvis/jarvis_tools/find_methodology.py +4 -2
- jarvis/jarvis_tools/generate_new_tool.py +2 -1
- jarvis/jarvis_tools/methodology.py +3 -4
- jarvis/jarvis_tools/read_code.py +2 -1
- jarvis/jarvis_tools/read_webpage.py +3 -1
- jarvis/jarvis_tools/registry.py +23 -14
- jarvis/jarvis_tools/rewrite_file.py +2 -1
- jarvis/jarvis_tools/search_web.py +1 -0
- jarvis/jarvis_tools/virtual_tty.py +5 -4
- jarvis/jarvis_utils/__init__.py +2 -0
- jarvis/jarvis_utils/builtin_replace_map.py +1 -1
- jarvis/jarvis_utils/config.py +40 -1
- jarvis/jarvis_utils/embedding.py +4 -3
- jarvis/jarvis_utils/file_processors.py +1 -0
- jarvis/jarvis_utils/git_utils.py +55 -25
- jarvis/jarvis_utils/globals.py +4 -2
- jarvis/jarvis_utils/input.py +14 -7
- jarvis/jarvis_utils/methodology.py +6 -4
- jarvis/jarvis_utils/output.py +10 -6
- jarvis/jarvis_utils/utils.py +89 -13
- {jarvis_ai_assistant-0.1.177.dist-info → jarvis_ai_assistant-0.1.179.dist-info}/METADATA +45 -33
- jarvis_ai_assistant-0.1.179.dist-info/RECORD +98 -0
- 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/RECORD +0 -102
- {jarvis_ai_assistant-0.1.177.dist-info → jarvis_ai_assistant-0.1.179.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.1.177.dist-info → jarvis_ai_assistant-0.1.179.dist-info}/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.1.177.dist-info → jarvis_ai_assistant-0.1.179.dist-info}/licenses/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.177.dist-info → jarvis_ai_assistant-0.1.179.dist-info}/top_level.txt +0 -0
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
3
|
-
import
|
|
2
|
+
import hashlib
|
|
3
|
+
import hmac
|
|
4
4
|
import json
|
|
5
5
|
import os
|
|
6
|
-
import hmac
|
|
7
|
-
import hashlib
|
|
8
6
|
import time
|
|
9
7
|
import urllib.parse
|
|
8
|
+
from typing import Dict, Generator, List, Tuple
|
|
9
|
+
|
|
10
|
+
import requests
|
|
10
11
|
from PIL import Image
|
|
11
|
-
from
|
|
12
|
-
from yaspin.spinners import Spinners
|
|
13
|
-
from yaspin.api import Yaspin
|
|
12
|
+
from rich import box
|
|
14
13
|
from rich.live import Live
|
|
15
|
-
from rich.text import Text
|
|
16
14
|
from rich.panel import Panel
|
|
17
|
-
from rich import
|
|
15
|
+
from rich.text import Text
|
|
16
|
+
from yaspin import yaspin
|
|
17
|
+
from yaspin.api import Yaspin
|
|
18
|
+
from yaspin.spinners import Spinners
|
|
19
|
+
|
|
18
20
|
from jarvis.jarvis_platform.base import BasePlatform
|
|
21
|
+
from jarvis.jarvis_utils.config import get_data_dir
|
|
19
22
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
20
23
|
from jarvis.jarvis_utils.utils import while_success
|
|
21
|
-
|
|
24
|
+
|
|
22
25
|
|
|
23
26
|
class YuanbaoPlatform(BasePlatform):
|
|
24
27
|
"""Hunyuan模型实现"""
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
import os
|
|
3
|
-
from jarvis.jarvis_platform.registry import PlatformRegistry
|
|
4
2
|
import asyncio
|
|
3
|
+
import os
|
|
4
|
+
from typing import Any, Dict, List, Optional
|
|
5
|
+
|
|
6
|
+
import uvicorn
|
|
5
7
|
from fastapi import FastAPI, HTTPException
|
|
8
|
+
from fastapi.middleware.cors import CORSMiddleware
|
|
6
9
|
from fastapi.responses import StreamingResponse
|
|
7
10
|
from pydantic import BaseModel, Field
|
|
8
|
-
from typing import List, Dict, Any, Optional
|
|
9
|
-
import uvicorn
|
|
10
|
-
from fastapi.middleware.cors import CORSMiddleware
|
|
11
11
|
|
|
12
|
+
from jarvis.jarvis_platform.registry import PlatformRegistry
|
|
12
13
|
from jarvis.jarvis_utils.input import get_multiline_input
|
|
13
14
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
14
15
|
from jarvis.jarvis_utils.utils import init_env
|
|
15
16
|
|
|
17
|
+
|
|
16
18
|
def list_platforms():
|
|
17
19
|
"""List all supported platforms and models"""
|
|
18
20
|
registry = PlatformRegistry.get_global_platform_registry()
|
|
@@ -248,10 +250,10 @@ class ChatCompletionResponse(BaseModel):
|
|
|
248
250
|
|
|
249
251
|
def service_command(args):
|
|
250
252
|
"""Process service subcommand - start OpenAI-compatible API server"""
|
|
251
|
-
import time
|
|
252
|
-
import uuid
|
|
253
253
|
import json
|
|
254
254
|
import os
|
|
255
|
+
import time
|
|
256
|
+
import uuid
|
|
255
257
|
from datetime import datetime
|
|
256
258
|
|
|
257
259
|
host = args.host
|
|
@@ -451,11 +453,11 @@ def service_command(args):
|
|
|
451
453
|
|
|
452
454
|
async def stream_chat_response(platform, message, model_name):
|
|
453
455
|
"""Stream chat response in OpenAI-compatible format"""
|
|
454
|
-
import time
|
|
455
456
|
import json
|
|
457
|
+
import os
|
|
458
|
+
import time
|
|
456
459
|
import uuid
|
|
457
460
|
from datetime import datetime
|
|
458
|
-
import os
|
|
459
461
|
|
|
460
462
|
completion_id = f"chatcmpl-{str(uuid.uuid4())}"
|
|
461
463
|
created_time = int(time.time())
|
|
@@ -12,6 +12,7 @@ from jarvis.jarvis_utils.config import get_shell_name
|
|
|
12
12
|
from jarvis.jarvis_utils.input import get_multiline_input
|
|
13
13
|
from jarvis.jarvis_utils.utils import init_env
|
|
14
14
|
|
|
15
|
+
|
|
15
16
|
def execute_command(command: str, should_run: bool) -> None:
|
|
16
17
|
"""Print command without execution"""
|
|
17
18
|
print(command)
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
from typing import Dict, Any
|
|
3
2
|
import os
|
|
4
|
-
|
|
3
|
+
from typing import Any, Dict
|
|
5
4
|
|
|
6
5
|
from jarvis.jarvis_agent import Agent
|
|
7
6
|
from jarvis.jarvis_platform.registry import PlatformRegistry
|
|
8
|
-
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
9
7
|
from jarvis.jarvis_utils.git_utils import find_git_root
|
|
8
|
+
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
10
9
|
from jarvis.jarvis_utils.utils import init_env
|
|
11
10
|
|
|
11
|
+
|
|
12
12
|
class AskCodebaseTool:
|
|
13
13
|
"""用于智能代码库查询和分析的工具
|
|
14
14
|
|
|
@@ -96,7 +96,7 @@ class AskCodebaseTool:
|
|
|
96
96
|
name=f"CodebaseAnalyzer",
|
|
97
97
|
description=f"分析代码库中的功能实现和定位",
|
|
98
98
|
summary_prompt=summary_prompt,
|
|
99
|
-
platform=PlatformRegistry().
|
|
99
|
+
platform=PlatformRegistry().get_thinking_platform(),
|
|
100
100
|
output_handler=[tool_registry],
|
|
101
101
|
execute_tool_confirm=False,
|
|
102
102
|
auto_complete=self.auto_complete
|
|
@@ -160,6 +160,7 @@ class AskCodebaseTool:
|
|
|
160
160
|
5. 根据文件内容提供具体、准确的回答
|
|
161
161
|
6. 确保分析的完整性,收集充分的信息后再得出结论,不要在只掌握部分信息就得出结论
|
|
162
162
|
7. 优先查阅README文件、文档目录和项目文档
|
|
163
|
+
8. 给出的任意结论都要有实际的代码支撑,不能假设和杜撰
|
|
163
164
|
|
|
164
165
|
## 分析步骤
|
|
165
166
|
1. **确定项目的编程语言**:
|
|
@@ -257,6 +258,7 @@ def main():
|
|
|
257
258
|
"""
|
|
258
259
|
import argparse
|
|
259
260
|
import sys
|
|
261
|
+
|
|
260
262
|
from jarvis.jarvis_utils.input import get_multiline_input
|
|
261
263
|
|
|
262
264
|
init_env("欢迎使用 Jarvis-AskCodebase,您的智能代码库查询工具已准备就绪!")
|
jarvis/jarvis_tools/ask_user.py
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
# 导入所需的类型注解模块
|
|
3
|
-
from typing import
|
|
3
|
+
from typing import Any, Dict
|
|
4
4
|
|
|
5
5
|
# 导入多行输入工具和输出工具
|
|
6
6
|
from jarvis.jarvis_utils.input import get_multiline_input
|
|
7
7
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
8
8
|
|
|
9
|
+
|
|
9
10
|
# 定义AskUserTool类,用于向用户提问
|
|
10
11
|
class AskUserTool:
|
|
11
12
|
name="ask_user"
|
jarvis/jarvis_tools/base.py
CHANGED
jarvis/jarvis_tools/chdir.py
CHANGED
jarvis/jarvis_tools/cli/main.py
CHANGED
jarvis/jarvis_tools/code_plan.py
CHANGED
|
@@ -9,13 +9,15 @@
|
|
|
9
9
|
4. 修改计划输出
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
|
-
from typing import Dict, Any
|
|
13
12
|
import os
|
|
14
|
-
from
|
|
13
|
+
from typing import Any, Dict
|
|
14
|
+
|
|
15
15
|
from jarvis.jarvis_agent import Agent
|
|
16
16
|
from jarvis.jarvis_platform.registry import PlatformRegistry
|
|
17
|
-
from jarvis.
|
|
17
|
+
from jarvis.jarvis_tools.registry import ToolRegistry
|
|
18
18
|
from jarvis.jarvis_utils.git_utils import find_git_root
|
|
19
|
+
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
20
|
+
|
|
19
21
|
|
|
20
22
|
class CodePlanTool:
|
|
21
23
|
"""用于代码修改规划和需求分析的工具
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
from typing import Dict, Any
|
|
3
2
|
import os
|
|
3
|
+
from typing import Any, Dict
|
|
4
|
+
|
|
4
5
|
from jarvis.jarvis_code_agent.code_agent import CodeAgent
|
|
5
6
|
from jarvis.jarvis_git_utils.git_commiter import GitCommitTool
|
|
6
|
-
from jarvis.jarvis_utils.git_utils import get_latest_commit_hash,
|
|
7
|
+
from jarvis.jarvis_utils.git_utils import (get_latest_commit_hash,
|
|
8
|
+
has_uncommitted_changes)
|
|
7
9
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
8
10
|
|
|
11
|
+
|
|
9
12
|
class CreateCodeAgentTool:
|
|
10
13
|
"""用于管理代码开发工作流的工具"""
|
|
11
14
|
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
from typing import Dict, Any
|
|
3
2
|
import os
|
|
4
|
-
|
|
3
|
+
from typing import Any, Dict
|
|
5
4
|
|
|
6
5
|
from jarvis.jarvis_agent import Agent, origin_agent_system_prompt
|
|
7
6
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
8
7
|
|
|
9
8
|
|
|
10
|
-
|
|
11
9
|
class SubAgentTool:
|
|
12
10
|
name = "create_sub_agent"
|
|
13
11
|
description = "创建子代理以处理特定任务,子代理将生成任务总结报告"
|
jarvis/jarvis_tools/edit_file.py
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
"""
|
|
3
|
-
|
|
3
|
+
文件编辑工具类
|
|
4
4
|
|
|
5
5
|
功能概述:
|
|
6
|
-
1.
|
|
6
|
+
1. 提供精确的文件内容搜索和替换功能,支持多组修改
|
|
7
7
|
2. 支持单个文件的编辑操作,包括创建新文件
|
|
8
8
|
3. 实现原子操作:所有修改要么全部成功,要么全部回滚
|
|
9
9
|
4. 严格匹配控制:每个搜索文本必须且只能匹配一次
|
|
10
|
+
5. 支持两种编辑模式:快速编辑(fast_edit)和AI辅助编辑(slow_edit)
|
|
10
11
|
|
|
11
12
|
核心特性:
|
|
12
13
|
- 支持不存在的文件和空文件处理
|
|
13
14
|
- 自动创建所需目录结构
|
|
14
15
|
- 完善的错误处理和回滚机制
|
|
15
16
|
- 严格的格式保持要求
|
|
17
|
+
- 支持大文件处理(自动上传到模型平台)
|
|
18
|
+
- 提供3次重试机制确保操作可靠性
|
|
16
19
|
"""
|
|
17
|
-
from typing import List
|
|
18
20
|
import re
|
|
19
|
-
from typing import Any, Dict, Tuple
|
|
21
|
+
from typing import Any, Dict, List, Tuple
|
|
20
22
|
|
|
21
23
|
import yaml
|
|
22
24
|
from yaspin import yaspin
|
|
@@ -32,28 +34,25 @@ from jarvis.jarvis_utils.utils import is_context_overflow
|
|
|
32
34
|
|
|
33
35
|
class FileSearchReplaceTool:
|
|
34
36
|
name = "edit_file"
|
|
35
|
-
description = """
|
|
37
|
+
description = """代码编辑工具,用于精确修改单个文件
|
|
36
38
|
|
|
37
|
-
#
|
|
39
|
+
# 文件编辑工具使用指南
|
|
38
40
|
|
|
39
|
-
## 重要提示
|
|
40
|
-
此工具可以查看和修改单个文件的代码,只需提供要修改的代码片段即可。应尽量精简内容,只包含必要的上下文和修改部分。特别注意:不要提供完整文件内容,只提供需要修改的部分及其上下文!
|
|
41
41
|
|
|
42
42
|
## 基本使用
|
|
43
43
|
1. 指定需要修改的文件路径
|
|
44
|
-
2.
|
|
45
|
-
|
|
44
|
+
2. 提供一组或多组修改,每个修改包含:
|
|
45
|
+
- reason: 修改原因描述
|
|
46
|
+
- search: 需要查找的原始代码(必须包含足够上下文)
|
|
47
|
+
- replace: 替换后的新代码
|
|
48
|
+
3. 工具会自动选择最适合的编辑模式
|
|
46
49
|
|
|
47
50
|
## 核心原则
|
|
48
|
-
1.
|
|
49
|
-
2.
|
|
50
|
-
3.
|
|
51
|
+
1. **精准修改**: 只修改必要的代码部分,保持其他部分不变
|
|
52
|
+
2. **最小补丁原则**: 生成最小范围的补丁,包含必要的上下文
|
|
53
|
+
3. **唯一匹配**: 确保搜索文本在文件中唯一匹配
|
|
54
|
+
4. **格式保持**: 严格保持原始代码的格式风格
|
|
51
55
|
|
|
52
|
-
## 输出格式规范
|
|
53
|
-
- 每个修改必须包含SEARCH部分和REPLACE部分
|
|
54
|
-
- SEARCH部分是需要查找的原始代码,必须能在原文件中**唯一匹配**
|
|
55
|
-
- REPLACE部分是替换后的新代码
|
|
56
|
-
- 如果修改较大,可以使用多个修改块
|
|
57
56
|
|
|
58
57
|
"""
|
|
59
58
|
parameters = {
|
|
@@ -93,24 +92,26 @@ class FileSearchReplaceTool:
|
|
|
93
92
|
pass
|
|
94
93
|
|
|
95
94
|
def execute(self, args: Dict) -> Dict[str, Any]:
|
|
96
|
-
"""
|
|
95
|
+
"""执行文件编辑操作,支持快速编辑和AI辅助编辑两种模式。
|
|
97
96
|
|
|
98
97
|
主要功能:
|
|
99
|
-
1.
|
|
98
|
+
1. 处理文件创建或修改,支持不存在的文件
|
|
100
99
|
2. 原子操作:所有修改要么全部成功,要么全部回滚
|
|
101
|
-
3.
|
|
102
|
-
4.
|
|
100
|
+
3. 自动选择编辑模式(fast_edit或slow_edit)
|
|
101
|
+
4. 保存修改前后的文件状态以便回滚
|
|
102
|
+
5. 提供详细的执行状态输出
|
|
103
103
|
|
|
104
104
|
参数:
|
|
105
105
|
args: 包含以下键的字典:
|
|
106
|
-
- file: 要修改的文件路径
|
|
107
|
-
- changes:
|
|
106
|
+
- file: 要修改的文件路径(必填)
|
|
107
|
+
- changes: 修改列表,每个修改包含(必填):
|
|
108
108
|
- reason: 修改原因描述
|
|
109
|
-
-
|
|
109
|
+
- search: 需要查找的原始代码(必须包含足够上下文)
|
|
110
|
+
- replace: 替换后的新代码
|
|
110
111
|
|
|
111
112
|
返回:
|
|
112
113
|
Dict[str, Any] 包含:
|
|
113
|
-
- success: 操作是否成功
|
|
114
|
+
- success: 操作是否成功(True/False)
|
|
114
115
|
- stdout: 成功时的输出消息
|
|
115
116
|
- stderr: 失败时的错误消息
|
|
116
117
|
|
|
@@ -118,9 +119,18 @@ class FileSearchReplaceTool:
|
|
|
118
119
|
1. 捕获并记录文件操作异常
|
|
119
120
|
2. 失败的修改尝试回滚到原始状态
|
|
120
121
|
3. 新创建的文件在失败时会被删除
|
|
122
|
+
4. 提供3次重试机制确保操作可靠性
|
|
123
|
+
5. 支持大文件处理(自动上传到模型平台)
|
|
124
|
+
|
|
125
|
+
实现细节:
|
|
126
|
+
1. 优先尝试fast_edit模式
|
|
127
|
+
2. 如果fast_edit失败,则尝试slow_edit模式
|
|
128
|
+
3. 严格检查搜索文本的唯一匹配性
|
|
129
|
+
4. 保持原始代码的格式风格
|
|
121
130
|
"""
|
|
122
131
|
import os
|
|
123
|
-
|
|
132
|
+
|
|
133
|
+
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
124
134
|
|
|
125
135
|
stdout_messages = []
|
|
126
136
|
stderr_messages = []
|
|
@@ -396,7 +406,6 @@ def fast_edit(filepath: str, patches: List[Dict[str,str]], spinner: Yaspin) -> T
|
|
|
396
406
|
if search_text in modified_content:
|
|
397
407
|
# 如果有多处,报错
|
|
398
408
|
if modified_content.count(search_text) > 1:
|
|
399
|
-
spinner.write(f"❌ 补丁 #{patch_count} 应用失败:找到多个匹配的代码段")
|
|
400
409
|
success = False
|
|
401
410
|
break
|
|
402
411
|
# 应用替换
|
|
@@ -404,7 +413,6 @@ def fast_edit(filepath: str, patches: List[Dict[str,str]], spinner: Yaspin) -> T
|
|
|
404
413
|
search_text, replace_text)
|
|
405
414
|
spinner.write(f"✅ 补丁 #{patch_count} 应用成功")
|
|
406
415
|
else:
|
|
407
|
-
spinner.write(f"❌ 补丁 #{patch_count} 应用失败:无法找到匹配的代码段")
|
|
408
416
|
success = False
|
|
409
417
|
break
|
|
410
418
|
if not success:
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
from typing import Dict, Any
|
|
3
2
|
import os
|
|
3
|
+
from typing import Any, Dict
|
|
4
|
+
|
|
5
|
+
from yaspin import yaspin # type: ignore
|
|
6
|
+
from yaspin.spinners import Spinners # type: ignore
|
|
4
7
|
|
|
5
8
|
from jarvis.jarvis_platform.registry import PlatformRegistry
|
|
6
9
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
7
|
-
|
|
8
|
-
from yaspin.spinners import Spinners # type: ignore
|
|
10
|
+
|
|
9
11
|
|
|
10
12
|
class FileAnalyzerTool:
|
|
11
13
|
name = "file_analyzer"
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
from typing import Dict, Any
|
|
3
2
|
import os
|
|
4
3
|
from pathlib import Path
|
|
4
|
+
from typing import Any, Dict
|
|
5
5
|
|
|
6
|
-
from yaspin import yaspin
|
|
6
|
+
from yaspin import yaspin # type: ignore
|
|
7
7
|
|
|
8
|
-
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
9
8
|
# 导入文件处理器
|
|
10
|
-
from jarvis.jarvis_utils.file_processors import
|
|
11
|
-
|
|
12
|
-
)
|
|
13
|
-
|
|
9
|
+
from jarvis.jarvis_utils.file_processors import TextFileProcessor
|
|
10
|
+
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
14
11
|
|
|
15
12
|
|
|
16
13
|
class FileOperationTool:
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
from typing import
|
|
2
|
+
from typing import Any, Dict
|
|
3
|
+
|
|
3
4
|
from yaspin import yaspin
|
|
4
5
|
|
|
5
|
-
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
6
6
|
from jarvis.jarvis_utils.methodology import load_methodology
|
|
7
|
+
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
8
|
+
|
|
7
9
|
|
|
8
10
|
class FindMethodologyTool:
|
|
9
11
|
name = "find_methodology"
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
import re
|
|
3
3
|
from pathlib import Path
|
|
4
|
-
from typing import
|
|
4
|
+
from typing import Any, Dict, Tuple
|
|
5
5
|
|
|
6
6
|
from jarvis.jarvis_utils.config import get_data_dir
|
|
7
7
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
8
8
|
|
|
9
|
+
|
|
9
10
|
class generate_new_tool:
|
|
10
11
|
name = "generate_new_tool"
|
|
11
12
|
description = """
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
import os
|
|
3
|
-
import json
|
|
4
2
|
import hashlib
|
|
5
|
-
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
from typing import Any, Dict
|
|
6
6
|
|
|
7
7
|
from jarvis.jarvis_utils.config import get_data_dir
|
|
8
8
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
|
|
12
11
|
class MethodologyTool:
|
|
13
12
|
"""经验管理工具"""
|
|
14
13
|
|
jarvis/jarvis_tools/read_code.py
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
from typing import Dict, Any
|
|
3
2
|
import os
|
|
3
|
+
from typing import Any, Dict
|
|
4
4
|
|
|
5
5
|
from yaspin import yaspin
|
|
6
6
|
|
|
7
7
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
8
8
|
|
|
9
|
+
|
|
9
10
|
class ReadCodeTool:
|
|
10
11
|
name = "read_code"
|
|
11
12
|
description = "代码阅读与分析工具,用于读取源代码文件并添加行号,针对代码文件优化,提供更好的格式化输出和行号显示,适用于代码分析、审查和理解代码实现的场景"
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
from typing import Dict, Any
|
|
3
2
|
import os
|
|
3
|
+
from typing import Any, Dict
|
|
4
|
+
|
|
4
5
|
from jarvis.jarvis_platform.registry import PlatformRegistry
|
|
5
6
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
6
7
|
|
|
8
|
+
|
|
7
9
|
class WebpageTool:
|
|
8
10
|
name = "read_webpage"
|
|
9
11
|
description = "读取网页内容,提取标题、文本和超链接"
|
jarvis/jarvis_tools/registry.py
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
import json
|
|
3
|
-
|
|
3
|
+
import os
|
|
4
4
|
import re
|
|
5
5
|
import sys
|
|
6
6
|
import tempfile
|
|
7
|
-
import
|
|
8
|
-
from typing import Any, Callable, Dict, List, Optional,
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any, Callable, Dict, List, Optional, Protocol, Tuple
|
|
9
9
|
|
|
10
10
|
import yaml
|
|
11
11
|
|
|
12
|
+
from jarvis.jarvis_mcp import McpClient
|
|
13
|
+
from jarvis.jarvis_mcp.sse_mcp_client import SSEMcpClient
|
|
14
|
+
from jarvis.jarvis_mcp.stdio_mcp_client import StdioMcpClient
|
|
15
|
+
from jarvis.jarvis_mcp.streamable_mcp_client import StreamableMcpClient
|
|
12
16
|
from jarvis.jarvis_platform.registry import PlatformRegistry
|
|
13
17
|
from jarvis.jarvis_tools.base import Tool
|
|
14
18
|
from jarvis.jarvis_utils.config import get_data_dir
|
|
15
19
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
20
|
+
from jarvis.jarvis_utils.tag import ct, ot
|
|
16
21
|
from jarvis.jarvis_utils.utils import init_env, is_context_overflow
|
|
17
|
-
from jarvis.jarvis_utils.tag import ot, ct
|
|
18
|
-
from jarvis.jarvis_mcp.stdio_mcp_client import StdioMcpClient
|
|
19
|
-
from jarvis.jarvis_mcp.sse_mcp_client import SSEMcpClient
|
|
20
|
-
from jarvis.jarvis_mcp import McpClient
|
|
21
|
-
|
|
22
22
|
|
|
23
23
|
tool_call_help = f"""
|
|
24
24
|
<tool_system_guide>
|
|
@@ -216,7 +216,7 @@ class ToolRegistry(OutputHandlerProtocol):
|
|
|
216
216
|
f"工具 {missing_tools} 不存在,可用的工具有: {', '.join(self.tools.keys())}",
|
|
217
217
|
OutputType.WARNING,
|
|
218
218
|
)
|
|
219
|
-
self.tools = {tool_name: self.tools[tool_name] for tool_name in name}
|
|
219
|
+
self.tools = {tool_name: self.tools[tool_name] for tool_name in name if tool_name in self.tools}
|
|
220
220
|
|
|
221
221
|
def dont_use_tools(self, names: List[str]) -> None:
|
|
222
222
|
"""从注册表中移除指定工具
|
|
@@ -351,6 +351,12 @@ class ToolRegistry(OutputHandlerProtocol):
|
|
|
351
351
|
f"文件 {file_path} 缺少base_url字段", OutputType.WARNING
|
|
352
352
|
)
|
|
353
353
|
return False
|
|
354
|
+
elif config["type"] == "streamable":
|
|
355
|
+
if "base_url" not in config:
|
|
356
|
+
PrettyOutput.print(
|
|
357
|
+
f"文件 {file_path} 缺少base_url字段", OutputType.WARNING
|
|
358
|
+
)
|
|
359
|
+
return False
|
|
354
360
|
else:
|
|
355
361
|
PrettyOutput.print(
|
|
356
362
|
f"文件 {file_path} 类型错误: {config['type']}", OutputType.WARNING
|
|
@@ -358,11 +364,14 @@ class ToolRegistry(OutputHandlerProtocol):
|
|
|
358
364
|
return False
|
|
359
365
|
|
|
360
366
|
# 创建MCP客户端
|
|
361
|
-
|
|
362
|
-
StdioMcpClient(config)
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
367
|
+
if config["type"] == "stdio":
|
|
368
|
+
mcp_client: McpClient = StdioMcpClient(config)
|
|
369
|
+
elif config["type"] == "sse":
|
|
370
|
+
mcp_client: McpClient = SSEMcpClient(config)
|
|
371
|
+
elif config["type"] == "streamable":
|
|
372
|
+
mcp_client: McpClient = StreamableMcpClient(config)
|
|
373
|
+
else:
|
|
374
|
+
raise ValueError(f"不支持的MCP客户端类型: {config['type']}")
|
|
366
375
|
|
|
367
376
|
# 获取工具信息
|
|
368
377
|
tools = mcp_client.get_tool_list()
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
|
|
2
|
+
import fcntl
|
|
3
3
|
import os
|
|
4
|
-
import time
|
|
5
4
|
import pty
|
|
6
|
-
import fcntl
|
|
7
|
-
import signal
|
|
8
5
|
import select
|
|
6
|
+
import signal
|
|
7
|
+
import time
|
|
8
|
+
from typing import Any, Dict
|
|
9
|
+
|
|
9
10
|
|
|
10
11
|
class VirtualTTYTool:
|
|
11
12
|
name = "virtual_tty"
|
jarvis/jarvis_utils/__init__.py
CHANGED