jarvis-ai-assistant 0.1.161__py3-none-any.whl → 0.1.163__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 CHANGED
@@ -1,3 +1,3 @@
1
1
  """Jarvis AI Assistant"""
2
2
 
3
- __version__ = "0.1.161"
3
+ __version__ = "0.1.163"
@@ -2,10 +2,10 @@ import datetime
2
2
  import platform
3
3
  from typing import Any, Callable, List, Optional, Tuple, Union
4
4
 
5
+ from jarvis.jarvis_tools.registry import ToolRegistry
5
6
  from yaspin import yaspin # type: ignore
6
7
 
7
8
  from jarvis.jarvis_agent.output_handler import OutputHandler
8
- from jarvis.jarvis_agent.patch import PatchOutputHandler
9
9
  from jarvis.jarvis_platform.base import BasePlatform
10
10
  from jarvis.jarvis_platform.registry import PlatformRegistry
11
11
  from jarvis.jarvis_utils.output import PrettyOutput, OutputType
@@ -139,6 +139,7 @@ class Agent:
139
139
  summary_prompt: Optional[str] = None,
140
140
  auto_complete: Optional[bool] = None,
141
141
  output_handler: List[OutputHandler] = [],
142
+ use_tools: List[str] = [],
142
143
  input_handler: Optional[List[Callable[[str, Any], Tuple[str, bool]]]] = None,
143
144
  execute_tool_confirm: Optional[bool] = None,
144
145
  need_summary: bool = True,
@@ -180,7 +181,9 @@ class Agent:
180
181
  self.model.set_suppress_output(False)
181
182
 
182
183
  from jarvis.jarvis_tools.registry import ToolRegistry
183
- self.output_handler = output_handler if output_handler else [ToolRegistry(), PatchOutputHandler()]
184
+ self.output_handler = output_handler if output_handler else [ToolRegistry()]
185
+ self.set_use_tools(use_tools)
186
+
184
187
  self.multiline_inputer = multiline_inputer if multiline_inputer else get_multiline_input
185
188
 
186
189
  self.prompt = ""
@@ -193,6 +196,7 @@ class Agent:
193
196
 
194
197
  self.tool_call_count = 0
195
198
  self.max_tool_call_count = get_max_tool_call_count()
199
+ self.after_tool_call_cb: Optional[Callable[[Agent], None]] = None
196
200
 
197
201
 
198
202
  self.execute_tool_confirm = execute_tool_confirm if execute_tool_confirm is not None else is_execute_tool_confirm()
@@ -281,6 +285,13 @@ class Agent:
281
285
  """)
282
286
  self.first = True
283
287
 
288
+ def set_use_tools(self, use_tools):
289
+ for handler in self.output_handler:
290
+ if isinstance(handler, ToolRegistry):
291
+ if use_tools:
292
+ handler.use_tools(use_tools)
293
+ break
294
+
284
295
 
285
296
  def set_addon_prompt(self, addon_prompt: str):
286
297
  """设置附加提示。
@@ -290,6 +301,14 @@ class Agent:
290
301
  """
291
302
  self.addon_prompt = addon_prompt
292
303
 
304
+ def set_after_tool_call_cb(self, cb: Callable[[Any], None]): # type: ignore
305
+ """设置工具调用后回调函数。
306
+
307
+ 参数:
308
+ cb: 回调函数
309
+ """
310
+ self.after_tool_call_cb = cb
311
+
293
312
  def make_default_addon_prompt(self, need_complete: bool) -> str:
294
313
  """生成附加提示。
295
314
 
@@ -358,10 +377,6 @@ class Agent:
358
377
  else:
359
378
  message += f"\n\n{self.make_default_addon_prompt(need_complete)}"
360
379
 
361
- # 在真正调用模型对话前减少文件读取计数
362
- from jarvis.jarvis_utils.globals import decrease_read_file_counts
363
- decrease_read_file_counts()
364
-
365
380
  # 累加对话长度
366
381
  self.conversation_length += get_context_token_count(message)
367
382
 
@@ -658,6 +673,9 @@ arguments:
658
673
  if need_return:
659
674
  return self.prompt
660
675
 
676
+ if self.after_tool_call_cb:
677
+ self.after_tool_call_cb(self)
678
+
661
679
  if self.prompt:
662
680
  continue
663
681
 
@@ -15,7 +15,6 @@ from jarvis.jarvis_agent import (
15
15
  Agent,
16
16
  origin_agent_system_prompt
17
17
  )
18
- from jarvis.jarvis_agent.patch import PatchOutputHandler
19
18
  from jarvis.jarvis_tools.registry import ToolRegistry
20
19
  from jarvis.jarvis_utils.utils import init_env
21
20
  from jarvis.jarvis_agent.file_input_handler import file_input_handler
@@ -123,7 +122,7 @@ def main() -> None:
123
122
  platform=args.platform,
124
123
  model_name=args.model,
125
124
  input_handler=[file_input_handler, shell_input_handler, builtin_input_handler],
126
- output_handler=[ToolRegistry(), PatchOutputHandler()],
125
+ output_handler=[ToolRegistry()],
127
126
  need_summary=False
128
127
  )
129
128
 
@@ -10,20 +10,22 @@ import argparse
10
10
  from typing import Any, Dict, Optional, List, Tuple
11
11
 
12
12
  # 忽略yaspin的类型检查
13
+ from jarvis.jarvis_utils.config import is_confirm_before_apply_patch
13
14
  from yaspin import yaspin # type: ignore
14
15
 
15
16
  from jarvis.jarvis_agent import Agent
16
17
  from jarvis.jarvis_agent.builtin_input_handler import builtin_input_handler
17
18
  from jarvis.jarvis_agent.file_input_handler import file_input_handler
18
19
  from jarvis.jarvis_agent.shell_input_handler import shell_input_handler
19
- from jarvis.jarvis_agent.patch import PatchOutputHandler
20
20
  from jarvis.jarvis_platform.registry import PlatformRegistry
21
21
  from jarvis.jarvis_git_utils.git_commiter import GitCommitTool
22
22
  from jarvis.jarvis_tools.registry import ToolRegistry
23
23
  from jarvis.jarvis_utils.git_utils import (
24
24
  find_git_root,
25
25
  get_commits_between,
26
+ get_diff,
26
27
  get_latest_commit_hash,
28
+ handle_commit_workflow,
27
29
  has_uncommitted_changes
28
30
  )
29
31
  from jarvis.jarvis_utils.input import get_multiline_input
@@ -51,161 +53,65 @@ class CodeAgent:
51
53
  "read_code",
52
54
  "methodology",
53
55
  "chdir",
54
- "create_code_agent",
55
56
  "find_methodology",
56
- "virtual_tty",
57
+ "edit_file",
58
+ "rewrite_file"
57
59
  ])
58
60
  code_system_prompt = """
59
61
  <code_engineer_guide>
60
- <principles>
62
+ ## 角色定位
63
+ 你是Jarvis系统的代码工程师,一个专业的代码分析和修改助手。你的职责是:
64
+ - 理解用户的代码需求,并提供高质量的实现方案
65
+ - 精确分析项目结构和代码,准确定位需要修改的位置
66
+ - 编写符合项目风格和标准的代码
67
+ - 在修改代码时保持谨慎,确保不破坏现有功能
68
+ - 做出专业的技术决策,减少用户决策负担
69
+
61
70
  ## 核心原则
62
71
  - 自主决策:基于专业判断做出决策,减少用户询问
63
- - 高效精准:一次性提供完整解决方案,避免反复修改
64
- - 修改审慎:修改代码前要三思而后行,充分分析影响范围,尽量做到一次把事情做好
72
+ - 高效精准:提供完整解决方案,避免反复修改
73
+ - 修改审慎:修改前充分分析影响范围,做到一次把事情做好
65
74
  - 工具精通:选择最高效工具路径解决问题
66
- - 严格确认:必须先分析项目结构,确定要修改的文件,禁止虚构已存在的代码
67
- </principles>
68
75
 
69
- <workflow>
70
76
  ## 工作流程
71
-
72
- <step>
73
- ### 1. 项目结构分析
74
- - 第一步必须分析项目结构,识别关键模块和文件
75
- - 结合用户需求,确定需要修改的文件列表
76
- - 优先使用fd命令查找文件,使用execute_script执行
77
- - 明确说明将要修改的文件及其范围
78
- </step>
79
-
80
- <step>
81
- ### 2. 需求分析
82
- - 基于项目结构理解,分析需求意图和实现方案
83
- - 当需求有多种实现方式时,选择影响最小的方案
84
- - 仅当需求显著模糊时才询问用户
85
- </step>
86
-
87
- <step>
88
- ### 3. 代码分析与确认
89
- - 详细分析确定要修改的文件内容
90
- - 明确区分现有代码和需要新建的内容
91
- - 绝对禁止虚构或假设现有代码的实现细节
92
- - 分析顺序:项目结构 → 目标文件 → 相关文件
93
- - 只在必要时扩大分析范围,避免过度分析
94
- - 工具选择:
95
- | 分析需求 | 首选工具 | 备选工具 |
96
- |---------|---------|----------|
97
- | 项目结构 | fd (通过execute_script) | ask_codebase(仅在必要时) |
98
- | 文件内容 | read_code | ask_codebase(仅在必要时) |
99
- | 查找引用 | rg (通过execute_script) | ask_codebase(仅在必要时) |
100
- | 查找定义 | rg (通过execute_script) | ask_codebase(仅在必要时) |
101
- | 函数调用者 | rg (通过execute_script) | ask_codebase(仅在必要时) |
102
- | 函数分析 | read_code + rg | ask_codebase(仅在必要时) |
103
- | 整体分析 | execute_script | ask_codebase(仅在必要时) |
104
- | 代码质量检查 | execute_script | ask_codebase(仅在必要时) |
105
- | 统计代码行数 | loc (通过execute_script) | - |
106
- </step>
107
-
108
- <step>
109
- ### 4. 方案设计
110
- - 确定最小变更方案,保持代码结构
111
- - 变更类型处理:
112
- - 修改现有文件:必须先确认文件存在及其内容
113
- - 创建新文件:可以根据需求创建,但要符合项目结构和风格
114
- - 变更规模处理:
115
- - ≤50行:一次性完成所有修改
116
- - 50-200行:按功能模块分组
117
- - >200行:按功能拆分,但尽量减少提交次数
118
- </step>
119
-
120
- <step>
121
- ### 5. 实施修改
122
- - 遵循"先读后写"原则,在修改已有代码前,必须已经读取了对应文件,如果已经读取过文件,不需要重新读取
123
- - 保持代码风格一致性
124
- - 自动匹配项目现有命名风格
125
- - 允许创建新文件和结构,但不得假设或虚构现有代码
126
- </step>
127
- </workflow>
128
-
129
- <tools>
130
- ## 专用工具简介
131
- 仅在必要时使用以下专用工具:
132
-
133
- - **ask_codebase**: 代码库整体查询,应优先使用fd、rg和read_code组合替代
134
- </tools>
135
-
136
- <shell_commands>
137
- ## Shell命令优先策略
138
-
139
- <category>
140
- ### 优先使用的Shell命令
141
- - **项目结构分析**:
142
- - `fd -t f -e py` 查找所有Python文件
143
- - `fd -t f -e js -e ts` 查找所有JavaScript/TypeScript文件
144
- - `fd -t d` 列出所有目录
145
- - `fd -t f -e java -e kt` 查找所有Java/Kotlin文件
146
- - `fd -t f -e go` 查找所有Go文件
147
- - `fd -t f -e rs` 查找所有Rust文件
148
- - `fd -t f -e c -e cpp -e h -e hpp` 查找所有C/C++文件
149
- </category>
150
-
151
- <category>
152
- - **代码内容搜索**:
153
- - `rg "pattern" --type py` 在Python文件中搜索
154
- - `rg "pattern" --type js` 在JavaScript文件中搜索
155
- - `rg "pattern" --type java` 在Java文件中搜索
156
- - `rg "pattern" --type c` 在C文件中搜索
157
- - `rg "class ClassName"` 查找类定义
158
- - `rg "func|function|def" -g "*.py" -g "*.js" -g "*.go" -g "*.rs"` 查找函数定义
159
- - `rg -w "word"` 精确匹配单词
160
- </category>
161
-
162
- <category>
163
- - **代码统计分析**:
164
- - `loc` 统计当前目录代码行数
165
- </category>
166
-
167
- <category>
168
- - **代码质量检查**:
169
- - Python: `pylint <file_path>`, `flake8 <file_path>`
170
- - JavaScript: `eslint <file_path>`
171
- - TypeScript: `tsc --noEmit <file_path>`
172
- - Java: `checkstyle <file_path>`
173
- - Go: `go vet <file_path>`
174
- - Rust: `cargo clippy`
175
- - C/C++: `cppcheck <file_path>`
176
- </category>
177
-
178
- <category>
179
- - **整体代码分析**:
180
- - 使用execute_script编写和执行脚本,批量分析多个文件
181
- - 简单脚本示例:`find . -name "*.py" | xargs pylint`
182
- - 使用多工具组合:`fd -e py | xargs pylint`
183
- </category>
184
- </shell_commands>
185
-
186
- <read_code_usage>
187
- ### read_code工具使用
188
- 读取文件应优先使用read_code工具,而非shell命令:
189
- - 完整读取:使用read_code读取整个文件内容
190
- - 部分读取:使用read_code指定行范围
191
- - 大文件处理:对大型文件使用read_code指定行范围,避免全部加载
192
- </read_code_usage>
193
-
194
- <tool_usage>
195
- ### 仅在命令行工具不足时使用专用工具
196
- 只有当fd、rg、loc和read_code工具无法获取足够信息时,才考虑使用专用工具(ask_codebase等)。在每次使用专用工具前,应先尝试使用上述工具获取所需信息。
197
- </tool_usage>
198
-
199
- <notes>
200
- ### 注意事项
201
- - read_code比cat或grep更适合阅读代码
202
- - rg比grep更快更强大,应优先使用
203
- - fd比find更快更易用,应优先使用
204
- - loc比wc -l提供更多代码统计信息,应优先使用
205
- - 针对不同编程语言选择对应的代码质量检查工具
206
- - 不要留下未实现的代码
207
- - 对于非常复杂的需求,可以使用create_code_agent工具,但是要提供完整的上下文信息
208
- </notes>
77
+ 1. **项目分析**:分析项目结构,确定需修改的文件
78
+ 2. **需求分析**:理解需求意图,选择影响最小的实现方案
79
+ 3. **代码分析**:详细分析目标文件,禁止虚构现有代码
80
+ 4. **方案设计**:确定最小变更方案,保持代码结构
81
+ 5. **实施修改**:遵循"先读后写"原则,保持代码风格一致性
82
+
83
+ ## 工具使用
84
+ - 项目结构:优先使用fd命令查找文件
85
+ - 代码搜索:优先使用rg进行内容搜索
86
+ - 代码阅读:优先使用read_code工具
87
+ - 仅在命令行工具不足时使用专用工具
88
+
89
+ ## 代码编辑规范
90
+ ### 代码修改工具选择
91
+ - 对于所有代码修改任务,优先使用edit_file工具,对于特别简单的修改,可以通过execute_script工具使用shell命令修改
92
+ - edit_file通过搜索和替换实现精确的代码编辑,是首选的代码修改方式
93
+ - 每个搜索文本在文件中必须唯一匹配,确保修改的准确性
94
+ - 为新文件创建时,使用空字符串作为搜索文本,替换文本作为完整内容
95
+ - 保持与原代码完全一致的格式和缩进风格
96
+
97
+ ### 文件重写工具使用
98
+ - rewrite_file工具用于完全重写文件内容或创建新文件
99
+ - 当需要替换整个文件内容时,优先使用rewrite_file工具
100
+ - 创建新文件时,使用rewrite_file工具提供完整的文件内容
101
+ - 保持与原代码相同的格式、缩进和编码风格
102
+ - 确保提供格式良好的完整文件内容
103
+
104
+ ### 最小补丁原则
105
+ - 对于任何代码修改,只提供需要修改的代码部分,不提供完整文件内容
106
+ - 严格保持原始代码的缩进、空行和格式风格
107
+ - 提供最小必要的上下文,确保修改位置精确
108
+ - 每个修改必须包含清晰的修改理由
109
+
110
+ ### 格式兼容要求
111
+ - 保持与原代码相同的缩进方式(空格或制表符)
112
+ - 保持原代码的空行数量和位置
113
+ - 不改变原代码的换行风格
114
+ - 对新文件可提供完整内容,对现有文件只提供差异部分
209
115
  </code_engineer_guide>
210
116
  """
211
117
  # Dynamically add ask_codebase based on task complexity if really needed
@@ -220,7 +126,7 @@ class CodeAgent:
220
126
  system_prompt=code_system_prompt,
221
127
  name="CodeAgent",
222
128
  auto_complete=False,
223
- output_handler=[tool_registry, PatchOutputHandler()],
129
+ output_handler=[tool_registry],
224
130
  platform=platform_instance,
225
131
  input_handler=[
226
132
  shell_input_handler,
@@ -232,9 +138,14 @@ class CodeAgent:
232
138
  self.agent.set_addon_prompt(
233
139
  "请使用工具充分理解用户需求,然后根据需求一步步执行代码修改/开发,"
234
140
  "如果不清楚要修改那些文件,可以使用ask_codebase工具,"
235
- "以:xxxx功能在哪个文件中实现?类似句式提问"
141
+ "以:xxxx功能在哪个文件中实现?类似句式提问。"
142
+ "所有代码修改任务都应优先使用edit_file工具,而非edit_file工具。"
143
+ "edit_file工具通过精确的搜索和替换实现代码编辑,"
144
+ "搜索文本需在目标文件中有且仅有一次精确匹配,确保修改的准确性。"
236
145
  )
237
146
 
147
+ self.agent.set_after_tool_call_cb(self.after_tool_call_cb)
148
+
238
149
  def get_root_dir(self) -> str:
239
150
  """获取项目根目录
240
151
 
@@ -271,7 +182,7 @@ class CodeAgent:
271
182
  'message': 提交信息,
272
183
  'author': 作者,
273
184
  'date': 提交日期,
274
- 'files': [修改的文件列表] (最多50个文件)
185
+ 'files': [修改的文件列表] (最多20个文件)
275
186
  },
276
187
  ...
277
188
  ]
@@ -313,7 +224,7 @@ class CodeAgent:
313
224
  )
314
225
  if files_result.returncode == 0:
315
226
  files = list(set(filter(None, files_result.stdout.splitlines())))
316
- commit['files'] = files[:50] # 限制最多50个文件
227
+ commit['files'] = files[:20] # 限制最多20个文件
317
228
 
318
229
  return commits
319
230
 
@@ -321,7 +232,10 @@ class CodeAgent:
321
232
  return []
322
233
 
323
234
  def _init_env(self) -> None:
324
- """初始化环境"""
235
+ """初始化环境,包括:
236
+ 1. 查找git根目录
237
+ 2. 检查并处理未提交的修改
238
+ """
325
239
  with yaspin(text="正在初始化环境...", color="cyan") as spinner:
326
240
  curr_dir = os.getcwd()
327
241
  git_dir = find_git_root(curr_dir)
@@ -334,7 +248,10 @@ class CodeAgent:
334
248
  spinner.ok("✅")
335
249
 
336
250
  def _handle_uncommitted_changes(self) -> None:
337
- """处理未提交的修改"""
251
+ """处理未提交的修改,包括:
252
+ 1. 提示用户确认是否提交
253
+ 2. 如果确认,则暂存并提交所有修改
254
+ """
338
255
  if has_uncommitted_changes():
339
256
  PrettyOutput.print("检测到未提交的修改,是否要提交?", OutputType.WARNING)
340
257
  if user_confirm("是否要提交?", True):
@@ -367,14 +284,14 @@ class CodeAgent:
367
284
  start_commit: Optional[str],
368
285
  end_commit: Optional[str]
369
286
  ) -> List[Tuple[str, str]]:
370
- """Show commit history between two commits.
287
+ """显示两个提交之间的提交历史
371
288
 
372
- Args:
373
- start_commit: The starting commit hash
374
- end_commit: The ending commit hash
289
+ 参数:
290
+ start_commit: 起始提交hash
291
+ end_commit: 结束提交hash
375
292
 
376
- Returns:
377
- List of tuples containing (commit_hash, commit_message)
293
+ 返回:
294
+ 包含(commit_hash, commit_message)的元组列表
378
295
  """
379
296
  if start_commit and end_commit:
380
297
  commits = get_commits_between(start_commit, end_commit)
@@ -454,6 +371,56 @@ class CodeAgent:
454
371
 
455
372
  except RuntimeError as e:
456
373
  return f"Error during execution: {str(e)}"
374
+
375
+ def after_tool_call_cb(self, agent: Agent) -> None:
376
+ """工具调用后回调函数。"""
377
+ final_ret = ""
378
+ diff = get_diff()
379
+ if diff:
380
+ start_hash = get_latest_commit_hash()
381
+ PrettyOutput.print(diff, OutputType.CODE, lang="diff")
382
+ commited = handle_commit_workflow()
383
+ if commited:
384
+ # 获取提交信息
385
+ end_hash = get_latest_commit_hash()
386
+ commits = get_commits_between(start_hash, end_hash)
387
+
388
+ # 添加提交信息到final_ret
389
+ if commits:
390
+ final_ret += "✅ 补丁已应用\n"
391
+ final_ret += "# 提交信息:\n"
392
+ for commit_hash, commit_message in commits:
393
+ final_ret += f"- {commit_hash[:7]}: {commit_message}\n"
394
+
395
+ final_ret += f"# 应用补丁:\n```diff\n{diff}\n```"
396
+
397
+ # 修改后的提示逻辑
398
+ addon_prompt = f"如果用户的需求未完成,请继续生成补丁,如果已经完成,请终止,不要输出新的PATCH,不要实现任何超出用户需求外的内容\n"
399
+ addon_prompt += "如果有任何信息不明确,调用工具获取信息\n"
400
+ addon_prompt += "每次响应必须且只能包含一个操作\n"
401
+
402
+ agent.set_addon_prompt(addon_prompt)
403
+
404
+ else:
405
+ final_ret += "✅ 补丁已应用(没有新的提交)"
406
+ else:
407
+ final_ret += "❌ 补丁应用被拒绝\n"
408
+ final_ret += f"# 补丁预览:\n```diff\n{diff}\n```"
409
+ else:
410
+ return
411
+ # 用户确认最终结果
412
+ if commited:
413
+ agent.prompt += final_ret
414
+ return
415
+ PrettyOutput.print(final_ret, OutputType.USER, lang="markdown")
416
+ if not is_confirm_before_apply_patch() or user_confirm("是否使用此回复?", default=True):
417
+ agent.prompt += final_ret
418
+ return
419
+ custom_reply = get_multiline_input("请输入自定义回复")
420
+ if not custom_reply.strip(): # 如果自定义回复为空,返回空字符串
421
+ agent.prompt += final_ret
422
+ agent.set_addon_prompt(custom_reply)
423
+ agent.prompt += final_ret
457
424
 
458
425
 
459
426
  def main() -> None:
jarvis/jarvis_dev/main.py CHANGED
@@ -3,7 +3,8 @@ from jarvis.jarvis_multi_agent import MultiAgent
3
3
  from jarvis.jarvis_tools.registry import ToolRegistry
4
4
  from jarvis.jarvis_utils.input import get_multiline_input
5
5
  from jarvis.jarvis_utils.output import OutputType, PrettyOutput
6
- from jarvis.jarvis_utils.utils import ct, ot, init_env
6
+ from jarvis.jarvis_utils.tag import ct, ot
7
+ from jarvis.jarvis_utils.utils import init_env
7
8
 
8
9
  # 定义每个角色的系统提示
9
10
  PM_PROMPT = f"""
@@ -994,7 +995,9 @@ def create_dev_team() -> MultiAgent:
994
995
  "search_web",
995
996
  "execute_script",
996
997
  "methodology",
997
- "ask_codebase"
998
+ "ask_codebase",
999
+ "edit_file",
1000
+ "rewrite_file",
998
1001
  ])
999
1002
 
1000
1003
  BA_output_handler = ToolRegistry()
@@ -1005,7 +1008,9 @@ def create_dev_team() -> MultiAgent:
1005
1008
  "execute_script",
1006
1009
  "read_webpage",
1007
1010
  "methodology",
1008
- "ask_codebase"
1011
+ "ask_codebase",
1012
+ "edit_file",
1013
+ "rewrite_file",
1009
1014
  ])
1010
1015
 
1011
1016
  SA_output_handler = ToolRegistry()
@@ -1015,7 +1020,9 @@ def create_dev_team() -> MultiAgent:
1015
1020
  "ask_codebase",
1016
1021
  "execute_script",
1017
1022
  "read_code",
1018
- "methodology"
1023
+ "methodology",
1024
+ "edit_file",
1025
+ "rewrite_file",
1019
1026
  ])
1020
1027
 
1021
1028
  TL_output_handler = ToolRegistry()
@@ -1025,6 +1032,8 @@ def create_dev_team() -> MultiAgent:
1025
1032
  "lsp_get_diagnostics",
1026
1033
  "execute_script",
1027
1034
  "methodology",
1035
+ "edit_file",
1036
+ "rewrite_file",
1028
1037
  ])
1029
1038
 
1030
1039
  DEV_output_handler = ToolRegistry()
@@ -1036,6 +1045,8 @@ def create_dev_team() -> MultiAgent:
1036
1045
  "read_code",
1037
1046
  "create_sub_agent",
1038
1047
  "methodology",
1048
+ "edit_file",
1049
+ "rewrite_file",
1039
1050
  ])
1040
1051
 
1041
1052
  QA_output_handler = ToolRegistry()
@@ -1048,6 +1059,8 @@ def create_dev_team() -> MultiAgent:
1048
1059
  "execute_script",
1049
1060
  "read_code",
1050
1061
  "methodology",
1062
+ "edit_file",
1063
+ "rewrite_file",
1051
1064
  ])
1052
1065
 
1053
1066
  # Update PM prompt with tool usage guidance
@@ -13,7 +13,8 @@ from jarvis.jarvis_agent import Agent
13
13
  from jarvis.jarvis_platform.registry import PlatformRegistry
14
14
  from jarvis.jarvis_tools.registry import ToolRegistry
15
15
  from jarvis.jarvis_utils.output import OutputType, PrettyOutput
16
- from jarvis.jarvis_utils.utils import ct, ot, init_env
16
+ from jarvis.jarvis_utils.tag import ct, ot
17
+ from jarvis.jarvis_utils.utils import init_env
17
18
 
18
19
 
19
20
  class GitCommitAnalyzer:
@@ -153,9 +153,10 @@ class GitCommitTool:
153
153
  except Exception as e:
154
154
  spinner.write(f"⚠️ 上传文件时出错: {str(e)}")
155
155
  upload_success = False
156
-
157
156
  # 根据上传状态准备完整的提示
158
157
  if upload_success:
158
+ # 尝试生成提交信息
159
+ spinner.text = "正在生成提交消息..."
159
160
  # 使用上传的文件
160
161
  prompt = base_prompt + f'''
161
162
  # 变更概述
@@ -178,8 +179,6 @@ class GitCommitTool:
178
179
  '''
179
180
  commit_message = platform.chat_until_success(prompt)
180
181
 
181
- # 尝试生成提交信息
182
- spinner.text = "正在生成提交消息..."
183
182
  while True:
184
183
  # 只在特定情况下重新获取commit_message
185
184
  if not upload_success and not is_large_content and not commit_message:
@@ -1,14 +1,13 @@
1
1
  import re
2
- from typing import Any, Dict, List, Optional, Tuple
2
+ from typing import Any, Dict, List, Tuple
3
3
 
4
4
  import yaml
5
5
 
6
6
  from jarvis.jarvis_agent import Agent
7
7
  from jarvis.jarvis_agent.output_handler import OutputHandler
8
8
  from jarvis.jarvis_tools.registry import ToolRegistry
9
- from jarvis.jarvis_utils.input import get_multiline_input
10
9
  from jarvis.jarvis_utils.output import OutputType, PrettyOutput
11
- from jarvis.jarvis_utils.utils import ct, ot, init_env
10
+ from jarvis.jarvis_utils.tag import ct, ot
12
11
 
13
12
 
14
13
  class MultiAgent(OutputHandler):
@@ -3,7 +3,6 @@ import re
3
3
  from typing import List, Tuple
4
4
  from jarvis.jarvis_utils.config import get_max_input_token_count
5
5
  from jarvis.jarvis_utils.embedding import split_text_into_chunks
6
- from jarvis.jarvis_utils.globals import clear_read_file_record
7
6
  from jarvis.jarvis_utils.output import OutputType, PrettyOutput
8
7
  from jarvis.jarvis_utils.utils import get_context_token_count, while_success, while_true
9
8
  from jarvis.jarvis_utils.tag import ot, ct
@@ -28,7 +27,6 @@ class BasePlatform(ABC):
28
27
 
29
28
  def reset(self):
30
29
  """Reset model"""
31
- clear_read_file_record()
32
30
  self.delete_chat()
33
31
 
34
32
  @abstractmethod
@@ -220,6 +220,7 @@ class YuanbaoPlatform(BasePlatform):
220
220
 
221
221
  self.multimedia = uploaded_files
222
222
  return True
223
+
223
224
 
224
225
  def _generate_upload_info(self, file_name: str) -> Dict:
225
226
  """从元宝API生成上传信息