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

Files changed (66) hide show
  1. jarvis/__init__.py +1 -1
  2. jarvis/jarvis_agent/__init__.py +130 -79
  3. jarvis/jarvis_agent/builtin_input_handler.py +1 -1
  4. jarvis/jarvis_agent/jarvis.py +9 -13
  5. jarvis/jarvis_agent/main.py +4 -2
  6. jarvis/jarvis_code_agent/code_agent.py +34 -23
  7. jarvis/jarvis_code_agent/lint.py +164 -0
  8. jarvis/jarvis_code_analysis/checklists/loader.py +6 -20
  9. jarvis/jarvis_code_analysis/code_review.py +8 -6
  10. jarvis/jarvis_data/config_schema.json +260 -0
  11. jarvis/jarvis_dev/main.py +1 -8
  12. jarvis/jarvis_git_details/main.py +1 -1
  13. jarvis/jarvis_git_squash/main.py +5 -3
  14. jarvis/jarvis_git_utils/git_commiter.py +25 -24
  15. jarvis/jarvis_mcp/sse_mcp_client.py +6 -4
  16. jarvis/jarvis_mcp/stdio_mcp_client.py +5 -4
  17. jarvis/jarvis_mcp/streamable_mcp_client.py +404 -0
  18. jarvis/jarvis_methodology/main.py +10 -9
  19. jarvis/jarvis_multi_agent/main.py +3 -1
  20. jarvis/jarvis_platform/base.py +14 -8
  21. jarvis/jarvis_platform/human.py +3 -1
  22. jarvis/jarvis_platform/kimi.py +8 -27
  23. jarvis/jarvis_platform/openai.py +4 -16
  24. jarvis/jarvis_platform/registry.py +6 -2
  25. jarvis/jarvis_platform/yuanbao.py +9 -29
  26. jarvis/jarvis_platform_manager/main.py +11 -9
  27. jarvis/jarvis_smart_shell/main.py +7 -3
  28. jarvis/jarvis_tools/ask_codebase.py +4 -3
  29. jarvis/jarvis_tools/ask_user.py +2 -1
  30. jarvis/jarvis_tools/base.py +3 -1
  31. jarvis/jarvis_tools/chdir.py +2 -1
  32. jarvis/jarvis_tools/cli/main.py +1 -0
  33. jarvis/jarvis_tools/code_plan.py +5 -3
  34. jarvis/jarvis_tools/create_code_agent.py +5 -2
  35. jarvis/jarvis_tools/create_sub_agent.py +1 -3
  36. jarvis/jarvis_tools/edit_file.py +4 -4
  37. jarvis/jarvis_tools/execute_script.py +1 -1
  38. jarvis/jarvis_tools/file_analyzer.py +5 -3
  39. jarvis/jarvis_tools/file_operation.py +4 -7
  40. jarvis/jarvis_tools/find_methodology.py +4 -2
  41. jarvis/jarvis_tools/generate_new_tool.py +2 -1
  42. jarvis/jarvis_tools/methodology.py +3 -4
  43. jarvis/jarvis_tools/read_code.py +2 -1
  44. jarvis/jarvis_tools/read_webpage.py +3 -1
  45. jarvis/jarvis_tools/registry.py +60 -45
  46. jarvis/jarvis_tools/rewrite_file.py +2 -1
  47. jarvis/jarvis_tools/search_web.py +1 -0
  48. jarvis/jarvis_tools/virtual_tty.py +5 -4
  49. jarvis/jarvis_utils/__init__.py +2 -0
  50. jarvis/jarvis_utils/builtin_replace_map.py +1 -1
  51. jarvis/jarvis_utils/config.py +88 -17
  52. jarvis/jarvis_utils/embedding.py +4 -3
  53. jarvis/jarvis_utils/file_processors.py +1 -0
  54. jarvis/jarvis_utils/git_utils.py +83 -40
  55. jarvis/jarvis_utils/globals.py +4 -2
  56. jarvis/jarvis_utils/input.py +14 -7
  57. jarvis/jarvis_utils/methodology.py +6 -4
  58. jarvis/jarvis_utils/output.py +10 -6
  59. jarvis/jarvis_utils/utils.py +140 -24
  60. {jarvis_ai_assistant-0.1.178.dist-info → jarvis_ai_assistant-0.1.180.dist-info}/METADATA +66 -59
  61. jarvis_ai_assistant-0.1.180.dist-info/RECORD +99 -0
  62. jarvis_ai_assistant-0.1.178.dist-info/RECORD +0 -96
  63. {jarvis_ai_assistant-0.1.178.dist-info → jarvis_ai_assistant-0.1.180.dist-info}/WHEEL +0 -0
  64. {jarvis_ai_assistant-0.1.178.dist-info → jarvis_ai_assistant-0.1.180.dist-info}/entry_points.txt +0 -0
  65. {jarvis_ai_assistant-0.1.178.dist-info → jarvis_ai_assistant-0.1.180.dist-info}/licenses/LICENSE +0 -0
  66. {jarvis_ai_assistant-0.1.178.dist-info → jarvis_ai_assistant-0.1.180.dist-info}/top_level.txt +0 -0
@@ -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
- c_cpp,
10
- go,
11
- python,
12
- rust,
13
- java,
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
- from jarvis.jarvis_utils.tag import ot, ct
16
- from jarvis.jarvis_code_analysis.checklists.loader import get_language_checklist
18
+
17
19
 
18
20
  class CodeReviewTool:
19
21
  name = "code_review"
@@ -0,0 +1,260 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "Jarvis环境变量配置模式",
4
+ "description": "Jarvis系统配置模式",
5
+ "type": "object",
6
+ "properties": {
7
+ "JARVIS_MCP": {
8
+ "type": "array",
9
+ "description": "MCP工具配置列表",
10
+ "items": {
11
+ "type": "object",
12
+ "oneOf": [
13
+ {
14
+ "type": "object",
15
+ "required": [
16
+ "type",
17
+ "base_url"
18
+ ],
19
+ "properties": {
20
+ "type": {
21
+ "type": "string",
22
+ "enum": [
23
+ "sse",
24
+ "streamable"
25
+ ],
26
+ "description": "MCP客户端类型"
27
+ },
28
+ "base_url": {
29
+ "type": "string",
30
+ "format": "uri",
31
+ "description": "MCP服务器基础URL"
32
+ },
33
+ "auth_token": {
34
+ "type": "string",
35
+ "description": "认证令牌(可选)"
36
+ },
37
+ "headers": {
38
+ "type": "object",
39
+ "additionalProperties": {
40
+ "type": "string"
41
+ },
42
+ "description": "额外的HTTP头(可选)"
43
+ },
44
+ "name": {
45
+ "type": "string",
46
+ "description": "工具名称(可选)"
47
+ },
48
+ "enable": {
49
+ "type": "boolean",
50
+ "default": true,
51
+ "description": "是否启用该工具(可选)"
52
+ }
53
+ }
54
+ },
55
+ {
56
+ "type": "object",
57
+ "required": [
58
+ "type",
59
+ "command"
60
+ ],
61
+ "properties": {
62
+ "type": {
63
+ "type": "string",
64
+ "enum": [
65
+ "stdio"
66
+ ],
67
+ "description": "MCP客户端类型"
68
+ },
69
+ "command": {
70
+ "type": "string",
71
+ "description": "要执行的命令"
72
+ },
73
+ "args": {
74
+ "type": "array",
75
+ "items": {
76
+ "type": "string"
77
+ },
78
+ "description": "命令参数列表(可选)"
79
+ },
80
+ "env": {
81
+ "type": "object",
82
+ "additionalProperties": {
83
+ "type": "string"
84
+ },
85
+ "description": "环境变量(可选)"
86
+ },
87
+ "name": {
88
+ "type": "string",
89
+ "description": "工具名称(可选)"
90
+ },
91
+ "enable": {
92
+ "type": "boolean",
93
+ "default": true,
94
+ "description": "是否启用该工具(可选)"
95
+ }
96
+ }
97
+ }
98
+ ]
99
+ }
100
+ },
101
+ "ENV": {
102
+ "type": "object",
103
+ "description": "需要设置的额外环境变量",
104
+ "additionalProperties": {
105
+ "type": "string"
106
+ },
107
+ "default": {}
108
+ },
109
+ "JARVIS_GIT_COMMIT_PROMPT": {
110
+ "type": "string",
111
+ "description": "Git提交信息生成提示模板",
112
+ "default": ""
113
+ },
114
+ "JARVIS_MAX_TOKEN_COUNT": {
115
+ "type": "string",
116
+ "description": "模型能处理的最大token数量",
117
+ "default": "960000"
118
+ },
119
+ "JARVIS_MAX_INPUT_TOKEN_COUNT": {
120
+ "type": "string",
121
+ "description": "模型能处理的最大输入token数量",
122
+ "default": "32000"
123
+ },
124
+ "JARVIS_AUTO_COMPLETE": {
125
+ "type": "string",
126
+ "description": "是否启用自动补全功能",
127
+ "default": "false",
128
+ "enum": [
129
+ "true",
130
+ "false"
131
+ ]
132
+ },
133
+ "SHELL": {
134
+ "type": "string",
135
+ "description": "系统shell名称(如: bash, zsh)",
136
+ "default": "/bin/bash"
137
+ },
138
+ "JARVIS_PLATFORM": {
139
+ "type": "string",
140
+ "description": "常规操作平台名称",
141
+ "default": "yuanbao"
142
+ },
143
+ "JARVIS_MODEL": {
144
+ "type": "string",
145
+ "description": "常规操作模型名称",
146
+ "default": "deep_seek_v3"
147
+ },
148
+ "JARVIS_THINKING_PLATFORM": {
149
+ "type": "string",
150
+ "description": "思考操作平台名称",
151
+ "default": "yuanbao"
152
+ },
153
+ "JARVIS_THINKING_MODEL": {
154
+ "type": "string",
155
+ "description": "思考操作模型名称",
156
+ "default": "deep_seek"
157
+ },
158
+ "JARVIS_EXECUTE_TOOL_CONFIRM": {
159
+ "type": "string",
160
+ "description": "执行工具前是否需要确认",
161
+ "default": "false",
162
+ "enum": [
163
+ "true",
164
+ "false"
165
+ ]
166
+ },
167
+ "JARVIS_CONFIRM_BEFORE_APPLY_PATCH": {
168
+ "type": "string",
169
+ "description": "应用补丁前是否需要确认",
170
+ "default": "true",
171
+ "enum": [
172
+ "true",
173
+ "false"
174
+ ]
175
+ },
176
+ "JARVIS_MAX_TOOL_CALL_COUNT": {
177
+ "type": "string",
178
+ "description": "最大连续工具调用次数",
179
+ "default": "20"
180
+ },
181
+ "JARVIS_DATA_PATH": {
182
+ "type": "string",
183
+ "description": "Jarvis数据存储目录路径",
184
+ "default": "~/.jarvis"
185
+ },
186
+ "JARVIS_AUTO_UPDATE": {
187
+ "type": "string",
188
+ "description": "是否自动更新git仓库",
189
+ "default": "true",
190
+ "enum": [
191
+ "true",
192
+ "false"
193
+ ]
194
+ },
195
+ "JARVIS_MAX_BIG_CONTENT_SIZE": {
196
+ "type": "string",
197
+ "description": "最大大内容尺寸",
198
+ "default": "1024000"
199
+ },
200
+ "JARVIS_PRETTY_OUTPUT": {
201
+ "type": "string",
202
+ "description": "是否启用美化输出",
203
+ "default": "false",
204
+ "enum": [
205
+ "true",
206
+ "false"
207
+ ]
208
+ },
209
+ "JARVIS_USE_METHODOLOGY": {
210
+ "type": "string",
211
+ "description": "是否启用方法论",
212
+ "default": "false",
213
+ "enum": [
214
+ "true",
215
+ "false"
216
+ ]
217
+ },
218
+ "JARVIS_USE_ANALYSIS": {
219
+ "type": "string",
220
+ "description": "是否启用任务分析",
221
+ "default": "false",
222
+ "enum": [
223
+ "true",
224
+ "false"
225
+ ]
226
+ },
227
+ "JARVIS_PRINT_PROMPT": {
228
+ "type": "string",
229
+ "description": "是否打印提示",
230
+ "default": "false",
231
+ "enum": [
232
+ "true",
233
+ "false"
234
+ ]
235
+ },
236
+ "JARVIS_REPLACE_MAP": {
237
+ "type": "object",
238
+ "description": "自定义替换映射表配置",
239
+ "additionalProperties": {
240
+ "type": "object",
241
+ "properties": {
242
+ "append": {
243
+ "type": "boolean",
244
+ "description": "Whether to append to existing template"
245
+ },
246
+ "template": {
247
+ "type": "string",
248
+ "description": "Replacement template content"
249
+ },
250
+ "description": {
251
+ "type": "string",
252
+ "description": "Description of the replacement"
253
+ }
254
+ },
255
+ "required": ["template"]
256
+ }
257
+ }
258
+ },
259
+ "additionalProperties": false
260
+ }
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
 
@@ -8,7 +8,7 @@
8
8
  import os
9
9
  import re
10
10
  import subprocess
11
- from typing import Dict, Any
11
+ from typing import Any, Dict
12
12
 
13
13
  from jarvis.jarvis_agent import Agent
14
14
  from jarvis.jarvis_platform.registry import PlatformRegistry
@@ -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
- from typing import Dict, Any, Optional
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.jarvis_utils.git_utils import find_git_root, has_uncommitted_changes
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
- base_prompt = f'''根据代码差异生成提交信息:
127
- 提交信息应使用{args.get('lang', '中文')}书写
128
- # 必需结构
124
+ custom_prompt = get_git_commit_prompt()
125
+ base_prompt = custom_prompt if custom_prompt else f'''根据代码差异生成提交信息:
126
+ 提交信息应使用中文书写
127
+ # 格式模板
129
128
  必须使用以下格式:
130
- {ot("COMMIT_MESSAGE")}
129
+
131
130
  <类型>(<范围>): <主题>
132
131
 
133
132
  [可选] 详细描述变更内容和原因
134
- {ct("COMMIT_MESSAGE")}
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("✅ 生成提交消息")
@@ -249,7 +252,7 @@ class GitCommitTool:
249
252
  "stdout": yaml.safe_dump({
250
253
  "commit_hash": commit_hash,
251
254
  "commit_message": commit_message
252
- }),
255
+ }, allow_unicode=True),
253
256
  "stderr": ""
254
257
  }
255
258
  finally:
@@ -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 ''