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
jarvis/jarvis_agent/main.py
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
import argparse
|
|
3
|
-
import yaml
|
|
4
3
|
import os
|
|
4
|
+
|
|
5
|
+
import yaml
|
|
6
|
+
|
|
5
7
|
from jarvis.jarvis_agent import Agent
|
|
6
8
|
from jarvis.jarvis_utils.input import get_multiline_input
|
|
7
|
-
from jarvis.jarvis_utils.output import
|
|
9
|
+
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
8
10
|
from jarvis.jarvis_utils.utils import init_env
|
|
9
11
|
|
|
10
12
|
|
|
@@ -4,34 +4,33 @@
|
|
|
4
4
|
该模块提供CodeAgent类,用于处理代码修改任务。
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
+
import argparse
|
|
7
8
|
import os
|
|
8
|
-
import sys
|
|
9
9
|
import subprocess
|
|
10
|
-
import
|
|
11
|
-
from typing import Any, Dict,
|
|
10
|
+
import sys
|
|
11
|
+
from typing import Any, Dict, List, Optional, Tuple
|
|
12
12
|
|
|
13
|
-
# 忽略yaspin的类型检查
|
|
14
|
-
from jarvis.jarvis_utils.config import is_confirm_before_apply_patch
|
|
15
13
|
from yaspin import yaspin # type: ignore
|
|
16
14
|
|
|
15
|
+
from jarvis import __version__
|
|
17
16
|
from jarvis.jarvis_agent import Agent
|
|
18
17
|
from jarvis.jarvis_agent.builtin_input_handler import builtin_input_handler
|
|
19
18
|
from jarvis.jarvis_agent.shell_input_handler import shell_input_handler
|
|
20
|
-
|
|
19
|
+
# 忽略yaspin的类型检查
|
|
20
|
+
from jarvis.jarvis_code_agent.lint import get_lint_tools
|
|
21
21
|
from jarvis.jarvis_git_utils.git_commiter import GitCommitTool
|
|
22
|
+
from jarvis.jarvis_platform.registry import PlatformRegistry
|
|
22
23
|
from jarvis.jarvis_tools.registry import ToolRegistry
|
|
23
|
-
from jarvis.jarvis_utils.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
has_uncommitted_changes
|
|
30
|
-
)
|
|
24
|
+
from jarvis.jarvis_utils.config import is_confirm_before_apply_patch
|
|
25
|
+
from jarvis.jarvis_utils.git_utils import (find_git_root, get_commits_between,
|
|
26
|
+
get_diff, get_diff_file_list,
|
|
27
|
+
get_latest_commit_hash,
|
|
28
|
+
handle_commit_workflow,
|
|
29
|
+
has_uncommitted_changes)
|
|
31
30
|
from jarvis.jarvis_utils.input import get_multiline_input
|
|
32
31
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
33
32
|
from jarvis.jarvis_utils.utils import init_env, user_confirm
|
|
34
|
-
|
|
33
|
+
|
|
35
34
|
|
|
36
35
|
class CodeAgent:
|
|
37
36
|
"""Jarvis系统的代码修改代理。
|
|
@@ -49,7 +48,6 @@ class CodeAgent:
|
|
|
49
48
|
"search_web",
|
|
50
49
|
"ask_user",
|
|
51
50
|
"ask_codebase",
|
|
52
|
-
"lsp_get_diagnostics",
|
|
53
51
|
"read_code",
|
|
54
52
|
"methodology",
|
|
55
53
|
"chdir",
|
|
@@ -327,7 +325,9 @@ class CodeAgent:
|
|
|
327
325
|
project_info.append(f"代码统计:\n{loc_stats}")
|
|
328
326
|
if commits_info:
|
|
329
327
|
commits_str = "\n".join(
|
|
330
|
-
f"提交 {i+1}: {commit['hash'][:7]} - {commit['message']} ({len(commit['files'])}个文件)"
|
|
328
|
+
f"提交 {i+1}: {commit['hash'][:7]} - {commit['message']} ({len(commit['files'])}个文件)\n" +
|
|
329
|
+
"\n".join(f" - {file}" for file in commit['files'][:5]) +
|
|
330
|
+
("\n ..." if len(commit['files']) > 5 else "")
|
|
331
331
|
for i, commit in enumerate(commits_info)
|
|
332
332
|
)
|
|
333
333
|
project_info.append(f"最近提交:\n{commits_str}")
|
|
@@ -354,6 +354,8 @@ class CodeAgent:
|
|
|
354
354
|
final_ret = ""
|
|
355
355
|
diff = get_diff()
|
|
356
356
|
if diff:
|
|
357
|
+
# 获取修改的文件列表
|
|
358
|
+
modified_files = get_diff_file_list()
|
|
357
359
|
start_hash = get_latest_commit_hash()
|
|
358
360
|
PrettyOutput.print(diff, OutputType.CODE, lang="diff")
|
|
359
361
|
commited = handle_commit_workflow()
|
|
@@ -372,13 +374,22 @@ class CodeAgent:
|
|
|
372
374
|
final_ret += f"# 应用补丁:\n```diff\n{diff}\n```"
|
|
373
375
|
|
|
374
376
|
# 修改后的提示逻辑
|
|
377
|
+
lint_tools_info = "\n".join(
|
|
378
|
+
f" - {file}: 使用 {'、'.join(get_lint_tools(file))}"
|
|
379
|
+
for file in modified_files
|
|
380
|
+
if get_lint_tools(file)
|
|
381
|
+
)
|
|
375
382
|
addon_prompt = """
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
383
|
+
1. 请对以下修改的文件进行静态扫描:
|
|
384
|
+
""" + "\n".join(f" - {file}" for file in modified_files) + (
|
|
385
|
+
f"""
|
|
386
|
+
2. 建议使用以下lint工具进行检查:
|
|
387
|
+
{lint_tools_info}""" if lint_tools_info else ""
|
|
388
|
+
) + """
|
|
389
|
+
3. 如果本次修改引入了警告和错误,请根据警告和错误信息修复代码
|
|
390
|
+
4. 在引入的警告和错误都被修复的前提下,如果用户的需求未完成,请继续修改代码,如果已经完成,请终止,不要实现任何超出用户需求外的内容
|
|
391
|
+
5. 如果有任何信息不明确,调用工具获取信息
|
|
392
|
+
6. 每次响应必须且只能包含一个操作
|
|
382
393
|
"""
|
|
383
394
|
|
|
384
395
|
agent.set_addon_prompt(addon_prompt)
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Lint工具配置模块
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import os
|
|
9
|
+
from typing import Dict, List
|
|
10
|
+
|
|
11
|
+
import yaml
|
|
12
|
+
|
|
13
|
+
from jarvis.jarvis_utils.config import get_data_dir
|
|
14
|
+
|
|
15
|
+
# 默认的lint工具配置
|
|
16
|
+
LINT_TOOLS = {
|
|
17
|
+
# C/C++
|
|
18
|
+
'.c': ['cppcheck', 'clang-tidy'],
|
|
19
|
+
'.cpp': ['cppcheck', 'clang-tidy'],
|
|
20
|
+
'.cc': ['cppcheck', 'clang-tidy'],
|
|
21
|
+
'.cxx': ['cppcheck', 'clang-tidy'],
|
|
22
|
+
'.h': ['cppcheck', 'clang-tidy'],
|
|
23
|
+
'.hpp': ['cppcheck', 'clang-tidy'],
|
|
24
|
+
'.hxx': ['cppcheck', 'clang-tidy'],
|
|
25
|
+
'.inl': ['cppcheck', 'clang-tidy'],
|
|
26
|
+
'.ipp': ['cppcheck', 'clang-tidy'],
|
|
27
|
+
|
|
28
|
+
# Go
|
|
29
|
+
'.go': ['golint', 'go vet'],
|
|
30
|
+
|
|
31
|
+
# Python
|
|
32
|
+
'.py': ['black', 'pylint', 'mypy', 'isort'],
|
|
33
|
+
'.pyw': ['black', 'pylint', 'mypy', 'isort'],
|
|
34
|
+
'.pyi': ['black', 'pylint', 'mypy', 'isort'],
|
|
35
|
+
'.pyx': ['black', 'pylint', 'mypy', 'isort'],
|
|
36
|
+
'.pxd': ['black', 'pylint', 'mypy', 'isort'],
|
|
37
|
+
|
|
38
|
+
# Rust
|
|
39
|
+
'.rs': ['cargo clippy', 'rustfmt'],
|
|
40
|
+
'.rlib': ['cargo clippy', 'rustfmt'],
|
|
41
|
+
|
|
42
|
+
# Java
|
|
43
|
+
'.java': ['checkstyle', 'pmd'],
|
|
44
|
+
'.class': ['checkstyle', 'pmd'],
|
|
45
|
+
'.jar': ['checkstyle', 'pmd'],
|
|
46
|
+
|
|
47
|
+
# JavaScript/TypeScript
|
|
48
|
+
'.js': ['eslint'],
|
|
49
|
+
'.mjs': ['eslint'],
|
|
50
|
+
'.cjs': ['eslint'],
|
|
51
|
+
'.jsx': ['eslint'],
|
|
52
|
+
'.ts': ['eslint', 'tsc'],
|
|
53
|
+
'.tsx': ['eslint', 'tsc'],
|
|
54
|
+
'.cts': ['eslint', 'tsc'],
|
|
55
|
+
'.mts': ['eslint', 'tsc'],
|
|
56
|
+
|
|
57
|
+
# PHP
|
|
58
|
+
'.php': ['phpcs', 'phpstan'],
|
|
59
|
+
'.phtml': ['phpcs', 'phpstan'],
|
|
60
|
+
'.php5': ['phpcs', 'phpstan'],
|
|
61
|
+
'.php7': ['phpcs', 'phpstan'],
|
|
62
|
+
'.phps': ['phpcs', 'phpstan'],
|
|
63
|
+
|
|
64
|
+
# Ruby
|
|
65
|
+
'.rb': ['rubocop'],
|
|
66
|
+
'.rake': ['rubocop'],
|
|
67
|
+
'.gemspec': ['rubocop'],
|
|
68
|
+
|
|
69
|
+
# Swift
|
|
70
|
+
'.swift': ['swiftlint'],
|
|
71
|
+
|
|
72
|
+
# Kotlin
|
|
73
|
+
'.kt': ['ktlint'],
|
|
74
|
+
'.kts': ['ktlint'],
|
|
75
|
+
|
|
76
|
+
# C#
|
|
77
|
+
'.cs': ['dotnet-format', 'roslynator'],
|
|
78
|
+
'.csx': ['dotnet-format', 'roslynator'],
|
|
79
|
+
|
|
80
|
+
# SQL
|
|
81
|
+
'.sql': ['sqlfluff'],
|
|
82
|
+
|
|
83
|
+
# Shell/Bash
|
|
84
|
+
'.sh': ['shellcheck'],
|
|
85
|
+
'.bash': ['shellcheck'],
|
|
86
|
+
|
|
87
|
+
# HTML/CSS
|
|
88
|
+
'.html': ['htmlhint'],
|
|
89
|
+
'.htm': ['htmlhint'],
|
|
90
|
+
'.xhtml': ['htmlhint'],
|
|
91
|
+
'.css': ['stylelint'],
|
|
92
|
+
'.scss': ['stylelint'],
|
|
93
|
+
'.sass': ['stylelint'],
|
|
94
|
+
'.less': ['stylelint'],
|
|
95
|
+
|
|
96
|
+
# XML/JSON/YAML
|
|
97
|
+
'.xml': ['xmllint'],
|
|
98
|
+
'.xsd': ['xmllint'],
|
|
99
|
+
'.dtd': ['xmllint'],
|
|
100
|
+
'.tld': ['xmllint'],
|
|
101
|
+
'.jsp': ['xmllint'],
|
|
102
|
+
'.jspx': ['xmllint'],
|
|
103
|
+
'.tag': ['xmllint'],
|
|
104
|
+
'.tagx': ['xmllint'],
|
|
105
|
+
'.json': ['jsonlint'],
|
|
106
|
+
'.jsonl': ['jsonlint'],
|
|
107
|
+
'.json5': ['jsonlint'],
|
|
108
|
+
'.yaml': ['yamllint'],
|
|
109
|
+
'.yml': ['yamllint'],
|
|
110
|
+
|
|
111
|
+
# Markdown/Documentation
|
|
112
|
+
'.md': ['markdownlint'],
|
|
113
|
+
'.markdown': ['markdownlint'],
|
|
114
|
+
'.rst': ['rstcheck'],
|
|
115
|
+
'.adoc': ['asciidoctor-lint'],
|
|
116
|
+
|
|
117
|
+
# Docker/Terraform/Makefile等无后缀文件
|
|
118
|
+
'makefile': ['checkmake'],
|
|
119
|
+
'dockerfile': ['hadolint'],
|
|
120
|
+
'docker-compose.yml': ['hadolint'],
|
|
121
|
+
'docker-compose.yaml': ['hadolint'],
|
|
122
|
+
'jenkinsfile': ['jenkinsfile-linter'],
|
|
123
|
+
'build': ['buildifier'],
|
|
124
|
+
'workspace': ['buildifier'],
|
|
125
|
+
'.bashrc': ['shellcheck'],
|
|
126
|
+
'.bash_profile': ['shellcheck'],
|
|
127
|
+
'.zshrc': ['shellcheck'],
|
|
128
|
+
'.gitignore': ['git-lint'],
|
|
129
|
+
'.editorconfig': ['editorconfig-checker'],
|
|
130
|
+
'.eslintrc': ['eslint'],
|
|
131
|
+
'.prettierrc': ['prettier'],
|
|
132
|
+
'cmakelists.txt': ['cmake-format'],
|
|
133
|
+
'.cmake': ['cmake-format'],
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
def load_lint_tools_config() -> Dict[str, List[str]]:
|
|
137
|
+
"""从yaml文件加载lint工具配置"""
|
|
138
|
+
config_path = os.path.join(get_data_dir(), 'lint_tools.yaml')
|
|
139
|
+
if not os.path.exists(config_path):
|
|
140
|
+
return {}
|
|
141
|
+
|
|
142
|
+
with open(config_path, 'r') as f:
|
|
143
|
+
config = yaml.safe_load(f) or {}
|
|
144
|
+
return {k.lower(): v for k, v in config.items()} # 确保key是小写
|
|
145
|
+
|
|
146
|
+
# 合并默认配置和yaml配置
|
|
147
|
+
LINT_TOOLS.update(load_lint_tools_config())
|
|
148
|
+
|
|
149
|
+
def get_lint_tools(filename: str) -> List[str]:
|
|
150
|
+
"""
|
|
151
|
+
根据文件扩展名或文件名获取对应的lint工具列表
|
|
152
|
+
|
|
153
|
+
Args:
|
|
154
|
+
file_extension_or_name: 文件扩展名(如'.py')或文件名(如'Makefile')
|
|
155
|
+
|
|
156
|
+
Returns:
|
|
157
|
+
对应的lint工具列表,如果找不到则返回空列表
|
|
158
|
+
"""
|
|
159
|
+
filename = os.path.basename(filename)
|
|
160
|
+
lint_tools = LINT_TOOLS.get(filename.lower(), [])
|
|
161
|
+
if lint_tools:
|
|
162
|
+
return lint_tools
|
|
163
|
+
ext = os.path.splitext(filename)[1]
|
|
164
|
+
return LINT_TOOLS.get(ext.lower(), [])
|
|
@@ -5,26 +5,12 @@ Utility module for loading language-specific code review checklists.
|
|
|
5
5
|
from typing import Dict, Optional
|
|
6
6
|
|
|
7
7
|
# Import checklist modules
|
|
8
|
-
from jarvis.jarvis_code_analysis.checklists import (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
javascript,
|
|
15
|
-
csharp,
|
|
16
|
-
swift,
|
|
17
|
-
php,
|
|
18
|
-
shell,
|
|
19
|
-
sql,
|
|
20
|
-
ruby,
|
|
21
|
-
kotlin,
|
|
22
|
-
web,
|
|
23
|
-
data_format,
|
|
24
|
-
infrastructure,
|
|
25
|
-
docs,
|
|
26
|
-
devops
|
|
27
|
-
)
|
|
8
|
+
from jarvis.jarvis_code_analysis.checklists import (c_cpp, csharp, data_format,
|
|
9
|
+
devops, docs, go,
|
|
10
|
+
infrastructure, java,
|
|
11
|
+
javascript, kotlin, php,
|
|
12
|
+
python, ruby, rust, shell,
|
|
13
|
+
sql, swift, web)
|
|
28
14
|
|
|
29
15
|
# Map of language identifiers to their checklist content
|
|
30
16
|
CHECKLIST_MAP = {
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
from typing import Dict, Any, List
|
|
3
|
-
import subprocess
|
|
4
2
|
import os
|
|
5
3
|
import re
|
|
4
|
+
import subprocess
|
|
6
5
|
import tempfile
|
|
6
|
+
from typing import Any, Dict, List
|
|
7
7
|
|
|
8
8
|
from yaspin import yaspin
|
|
9
|
+
|
|
10
|
+
from jarvis.jarvis_agent import Agent
|
|
11
|
+
from jarvis.jarvis_code_analysis.checklists.loader import \
|
|
12
|
+
get_language_checklist
|
|
9
13
|
from jarvis.jarvis_platform.registry import PlatformRegistry
|
|
10
14
|
from jarvis.jarvis_tools.read_code import ReadCodeTool
|
|
11
|
-
from jarvis.jarvis_agent import Agent
|
|
12
|
-
|
|
13
15
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
16
|
+
from jarvis.jarvis_utils.tag import ct, ot
|
|
14
17
|
from jarvis.jarvis_utils.utils import init_env, is_context_overflow
|
|
15
|
-
|
|
16
|
-
from jarvis.jarvis_code_analysis.checklists.loader import get_language_checklist
|
|
18
|
+
|
|
17
19
|
|
|
18
20
|
class CodeReviewTool:
|
|
19
21
|
name = "code_review"
|
jarvis/jarvis_dev/main.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
from jarvis.jarvis_platform.registry import PlatformRegistry
|
|
3
2
|
from jarvis.jarvis_multi_agent import MultiAgent
|
|
3
|
+
from jarvis.jarvis_platform.registry import PlatformRegistry
|
|
4
4
|
from jarvis.jarvis_tools.registry import ToolRegistry
|
|
5
5
|
from jarvis.jarvis_utils.input import get_multiline_input
|
|
6
6
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
@@ -562,7 +562,6 @@ TL_PROMPT = f"""
|
|
|
562
562
|
## 工具使用指南
|
|
563
563
|
- **file_operation**:管理技术文档和指导文件
|
|
564
564
|
- **ask_codebase**:分析代码库,理解实现细节
|
|
565
|
-
- **lsp_get_diagnostics**:检查代码问题和警告
|
|
566
565
|
- **execute_script**:执行开发工具和命令
|
|
567
566
|
- **methodology**:应用开发方法论和最佳实践
|
|
568
567
|
</tools>
|
|
@@ -900,7 +899,6 @@ QA_PROMPT = f"""
|
|
|
900
899
|
- **file_operation**:管理测试文档和测试脚本
|
|
901
900
|
- **ask_codebase**:了解代码库实现以设计测试
|
|
902
901
|
- **execute_script**:执行测试命令和测试套件
|
|
903
|
-
- **lsp_get_diagnostics**:检查代码问题和警告
|
|
904
902
|
- **read_code**:阅读和理解代码以设计测试用例
|
|
905
903
|
- **methodology**:应用测试方法论和最佳实践
|
|
906
904
|
</tools>
|
|
@@ -1030,7 +1028,6 @@ def create_dev_team() -> MultiAgent:
|
|
|
1030
1028
|
TL_output_handler.use_tools([
|
|
1031
1029
|
"file_operation",
|
|
1032
1030
|
"ask_codebase",
|
|
1033
|
-
"lsp_get_diagnostics",
|
|
1034
1031
|
"execute_script",
|
|
1035
1032
|
"methodology",
|
|
1036
1033
|
"edit_file",
|
|
@@ -1056,8 +1053,6 @@ def create_dev_team() -> MultiAgent:
|
|
|
1056
1053
|
"file_operation",
|
|
1057
1054
|
"ask_codebase",
|
|
1058
1055
|
"execute_script",
|
|
1059
|
-
"lsp_get_diagnostics",
|
|
1060
|
-
"execute_script",
|
|
1061
1056
|
"read_code",
|
|
1062
1057
|
"methodology",
|
|
1063
1058
|
"edit_file",
|
|
@@ -1135,7 +1130,6 @@ def create_dev_team() -> MultiAgent:
|
|
|
1135
1130
|
## 工具使用指南
|
|
1136
1131
|
- **file_operation**:管理技术文档和指导文件
|
|
1137
1132
|
- **ask_codebase**:分析代码库,理解实现细节
|
|
1138
|
-
- **lsp_get_diagnostics**:检查代码问题和警告
|
|
1139
1133
|
- **execute_script**:执行开发工具和命令
|
|
1140
1134
|
|
|
1141
1135
|
## 文档管理规范
|
|
@@ -1181,7 +1175,6 @@ def create_dev_team() -> MultiAgent:
|
|
|
1181
1175
|
- **file_operation**:管理测试文档和测试脚本
|
|
1182
1176
|
- **ask_codebase**:了解代码库实现以设计测试
|
|
1183
1177
|
- **execute_script**:执行测试命令和测试套件
|
|
1184
|
-
- **lsp_get_diagnostics**:检查代码问题和警告
|
|
1185
1178
|
- **execute_script**:执行各类脚本(Shell命令、Shell脚本、Python脚本)
|
|
1186
1179
|
- **read_code**:阅读和理解代码以设计测试用例
|
|
1187
1180
|
|
|
File without changes
|
jarvis/jarvis_git_squash/main.py
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
import sys
|
|
3
2
|
import argparse
|
|
4
|
-
from typing import Dict
|
|
5
|
-
from jarvis.jarvis_git_utils.git_commiter import GitCommitTool
|
|
6
3
|
import subprocess
|
|
4
|
+
import sys
|
|
5
|
+
from typing import Dict
|
|
7
6
|
|
|
7
|
+
from jarvis.jarvis_git_utils.git_commiter import GitCommitTool
|
|
8
8
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
9
9
|
from jarvis.jarvis_utils.utils import init_env, user_confirm
|
|
10
|
+
|
|
11
|
+
|
|
10
12
|
class GitSquashTool:
|
|
11
13
|
name = "git_squash_agent"
|
|
12
14
|
description = "Squash commits interactively using a base commit hash"
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
+
import argparse
|
|
3
|
+
import os
|
|
2
4
|
import re
|
|
3
5
|
import shlex
|
|
4
6
|
import subprocess
|
|
5
|
-
|
|
7
|
+
import sys
|
|
6
8
|
import tempfile
|
|
9
|
+
from typing import Any, Dict, Optional
|
|
10
|
+
|
|
7
11
|
import yaml
|
|
8
12
|
from yaspin import yaspin
|
|
9
|
-
from jarvis.jarvis_platform.registry import PlatformRegistry
|
|
10
|
-
import sys
|
|
11
|
-
import argparse
|
|
12
|
-
import os
|
|
13
13
|
|
|
14
|
-
from jarvis.
|
|
14
|
+
from jarvis.jarvis_platform.registry import PlatformRegistry
|
|
15
|
+
from jarvis.jarvis_utils.config import get_git_commit_prompt
|
|
16
|
+
from jarvis.jarvis_utils.git_utils import (find_git_root,
|
|
17
|
+
has_uncommitted_changes)
|
|
15
18
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
19
|
+
from jarvis.jarvis_utils.tag import ct, ot
|
|
16
20
|
from jarvis.jarvis_utils.utils import init_env, is_context_overflow
|
|
17
|
-
from jarvis.jarvis_utils.tag import ot, ct
|
|
18
21
|
|
|
19
22
|
|
|
20
23
|
class GitCommitTool:
|
|
@@ -24,11 +27,6 @@ class GitCommitTool:
|
|
|
24
27
|
parameters = {
|
|
25
28
|
"type": "object",
|
|
26
29
|
"properties": {
|
|
27
|
-
"lang": {
|
|
28
|
-
"type": "string",
|
|
29
|
-
"description": "提交信息的语言",
|
|
30
|
-
"default": "Chinese"
|
|
31
|
-
},
|
|
32
30
|
"root_dir": {
|
|
33
31
|
"type": "string",
|
|
34
32
|
"description": "Git仓库的根目录路径(可选)",
|
|
@@ -123,15 +121,16 @@ class GitCommitTool:
|
|
|
123
121
|
spinner.text = "正在生成提交消息..."
|
|
124
122
|
|
|
125
123
|
# 准备提示信息
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
124
|
+
custom_prompt = get_git_commit_prompt()
|
|
125
|
+
base_prompt = custom_prompt if custom_prompt else f'''根据代码差异生成提交信息:
|
|
126
|
+
提交信息应使用中文书写
|
|
127
|
+
# 格式模板
|
|
129
128
|
必须使用以下格式:
|
|
130
|
-
|
|
129
|
+
|
|
131
130
|
<类型>(<范围>): <主题>
|
|
132
131
|
|
|
133
132
|
[可选] 详细描述变更内容和原因
|
|
134
|
-
|
|
133
|
+
|
|
135
134
|
# 格式规则
|
|
136
135
|
1. 类型: fix(修复bug), feat(新功能), docs(文档), style(格式), refactor(重构), test(测试), chore(其他)
|
|
137
136
|
2. 范围表示变更的模块或组件 (例如: auth, database, ui)
|
|
@@ -140,6 +139,12 @@ class GitCommitTool:
|
|
|
140
139
|
5. 详细描述部分应解释"是什么"和"为什么",而非"如何"
|
|
141
140
|
6. 仅输出提交信息,不要输出其他内容
|
|
142
141
|
'''
|
|
142
|
+
base_prompt += f"""
|
|
143
|
+
# 输出格式
|
|
144
|
+
{ot("COMMIT_MESSAGE")}
|
|
145
|
+
commit信息
|
|
146
|
+
{ct("COMMIT_MESSAGE")}
|
|
147
|
+
"""
|
|
143
148
|
|
|
144
149
|
# 获取模型并尝试上传文件
|
|
145
150
|
platform = PlatformRegistry().get_normal_platform()
|
|
@@ -209,10 +214,8 @@ class GitCommitTool:
|
|
|
209
214
|
break
|
|
210
215
|
prompt = f"""格式错误,请按照以下格式重新生成提交信息:
|
|
211
216
|
{ot("COMMIT_MESSAGE")}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
[可选] 详细描述变更内容和原因
|
|
215
|
-
{ct("COMMIT_MESSAGE")}
|
|
217
|
+
commit信息
|
|
218
|
+
{ct("COMMIT_MESSAGE")}
|
|
216
219
|
"""
|
|
217
220
|
commit_message = platform.chat_until_success(prompt)
|
|
218
221
|
spinner.write("✅ 生成提交消息")
|
|
@@ -267,14 +270,12 @@ class GitCommitTool:
|
|
|
267
270
|
def main():
|
|
268
271
|
init_env("欢迎使用 Jarvis-GitCommitTool,您的Git提交助手已准备就绪!")
|
|
269
272
|
parser = argparse.ArgumentParser(description='Git commit tool')
|
|
270
|
-
parser.add_argument('--lang', type=str, default='Chinese', help='Language for commit messages')
|
|
271
273
|
parser.add_argument('--root-dir', type=str, default='.', help='Root directory of the Git repository')
|
|
272
274
|
parser.add_argument('--prefix', type=str, default='', help='Prefix to prepend to commit message (separated by space)')
|
|
273
275
|
parser.add_argument('--suffix', type=str, default='', help='Suffix to append to commit message (separated by newline)')
|
|
274
276
|
args = parser.parse_args()
|
|
275
277
|
tool = GitCommitTool()
|
|
276
278
|
tool.execute({
|
|
277
|
-
"lang": args.lang if hasattr(args, 'lang') else 'Chinese',
|
|
278
279
|
"root_dir": args.root_dir,
|
|
279
280
|
"prefix": args.prefix if hasattr(args, 'prefix') else '',
|
|
280
281
|
"suffix": args.suffix if hasattr(args, 'suffix') else ''
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
from typing import Any, Dict, List, Callable
|
|
3
|
-
import requests
|
|
4
2
|
import json
|
|
5
3
|
import threading
|
|
6
4
|
import time
|
|
7
|
-
from
|
|
8
|
-
from
|
|
5
|
+
from typing import Any, Callable, Dict, List
|
|
6
|
+
from urllib.parse import parse_qs, urlencode, urljoin
|
|
7
|
+
|
|
8
|
+
import requests
|
|
9
|
+
|
|
9
10
|
from jarvis.jarvis_mcp import McpClient
|
|
11
|
+
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
10
12
|
|
|
11
13
|
|
|
12
14
|
class SSEMcpClient(McpClient):
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
from typing import Any, Dict, List
|
|
3
|
-
import subprocess
|
|
4
|
-
import os
|
|
5
2
|
import json
|
|
6
|
-
|
|
3
|
+
import os
|
|
4
|
+
import subprocess
|
|
5
|
+
from typing import Any, Dict, List
|
|
6
|
+
|
|
7
7
|
from jarvis.jarvis_mcp import McpClient
|
|
8
|
+
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
class StdioMcpClient(McpClient):
|