jarvis-ai-assistant 0.1.193__py3-none-any.whl → 0.1.195__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.
Files changed (92) hide show
  1. jarvis/__init__.py +1 -1
  2. jarvis/jarvis_agent/__init__.py +45 -41
  3. jarvis/jarvis_agent/builtin_input_handler.py +26 -4
  4. jarvis/jarvis_agent/jarvis.py +30 -19
  5. jarvis/jarvis_agent/main.py +20 -12
  6. jarvis/jarvis_agent/output_handler.py +7 -7
  7. jarvis/jarvis_agent/shell_input_handler.py +14 -11
  8. jarvis/jarvis_code_agent/code_agent.py +81 -79
  9. jarvis/jarvis_code_agent/lint.py +92 -105
  10. jarvis/jarvis_code_analysis/checklists/__init__.py +1 -1
  11. jarvis/jarvis_code_analysis/checklists/c_cpp.py +1 -1
  12. jarvis/jarvis_code_analysis/checklists/csharp.py +1 -1
  13. jarvis/jarvis_code_analysis/checklists/data_format.py +1 -1
  14. jarvis/jarvis_code_analysis/checklists/devops.py +1 -1
  15. jarvis/jarvis_code_analysis/checklists/docs.py +1 -1
  16. jarvis/jarvis_code_analysis/checklists/go.py +1 -1
  17. jarvis/jarvis_code_analysis/checklists/infrastructure.py +1 -1
  18. jarvis/jarvis_code_analysis/checklists/java.py +1 -1
  19. jarvis/jarvis_code_analysis/checklists/javascript.py +1 -1
  20. jarvis/jarvis_code_analysis/checklists/kotlin.py +1 -1
  21. jarvis/jarvis_code_analysis/checklists/loader.py +31 -29
  22. jarvis/jarvis_code_analysis/checklists/php.py +1 -1
  23. jarvis/jarvis_code_analysis/checklists/python.py +1 -1
  24. jarvis/jarvis_code_analysis/checklists/ruby.py +1 -1
  25. jarvis/jarvis_code_analysis/checklists/rust.py +1 -1
  26. jarvis/jarvis_code_analysis/checklists/shell.py +1 -1
  27. jarvis/jarvis_code_analysis/checklists/sql.py +1 -1
  28. jarvis/jarvis_code_analysis/checklists/swift.py +1 -1
  29. jarvis/jarvis_code_analysis/checklists/web.py +1 -1
  30. jarvis/jarvis_code_analysis/code_review.py +292 -190
  31. jarvis/jarvis_dev/main.py +73 -56
  32. jarvis/jarvis_git_details/main.py +29 -33
  33. jarvis/jarvis_git_squash/main.py +13 -11
  34. jarvis/jarvis_git_utils/git_commiter.py +15 -5
  35. jarvis/jarvis_mcp/__init__.py +8 -10
  36. jarvis/jarvis_mcp/sse_mcp_client.py +182 -205
  37. jarvis/jarvis_mcp/stdio_mcp_client.py +93 -120
  38. jarvis/jarvis_mcp/streamable_mcp_client.py +117 -142
  39. jarvis/jarvis_methodology/main.py +71 -39
  40. jarvis/jarvis_multi_agent/__init__.py +24 -16
  41. jarvis/jarvis_multi_agent/main.py +10 -4
  42. jarvis/jarvis_platform/__init__.py +1 -1
  43. jarvis/jarvis_platform/base.py +44 -18
  44. jarvis/jarvis_platform/human.py +15 -3
  45. jarvis/jarvis_platform/kimi.py +117 -81
  46. jarvis/jarvis_platform/openai.py +23 -28
  47. jarvis/jarvis_platform/registry.py +43 -29
  48. jarvis/jarvis_platform/tongyi.py +16 -10
  49. jarvis/jarvis_platform/yuanbao.py +197 -144
  50. jarvis/jarvis_platform_manager/main.py +4 -2
  51. jarvis/jarvis_smart_shell/main.py +35 -30
  52. jarvis/jarvis_tools/ask_user.py +8 -16
  53. jarvis/jarvis_tools/base.py +3 -2
  54. jarvis/jarvis_tools/chdir.py +7 -19
  55. jarvis/jarvis_tools/cli/main.py +14 -10
  56. jarvis/jarvis_tools/code_plan.py +10 -31
  57. jarvis/jarvis_tools/create_code_agent.py +6 -11
  58. jarvis/jarvis_tools/create_sub_agent.py +10 -22
  59. jarvis/jarvis_tools/edit_file.py +98 -76
  60. jarvis/jarvis_tools/execute_script.py +46 -46
  61. jarvis/jarvis_tools/file_analyzer.py +22 -34
  62. jarvis/jarvis_tools/file_operation.py +69 -62
  63. jarvis/jarvis_tools/generate_new_tool.py +0 -2
  64. jarvis/jarvis_tools/methodology.py +19 -23
  65. jarvis/jarvis_tools/read_code.py +35 -35
  66. jarvis/jarvis_tools/read_webpage.py +7 -16
  67. jarvis/jarvis_tools/registry.py +63 -30
  68. jarvis/jarvis_tools/rewrite_file.py +26 -29
  69. jarvis/jarvis_tools/search_web.py +5 -8
  70. jarvis/jarvis_tools/virtual_tty.py +133 -122
  71. jarvis/jarvis_utils/__init__.py +0 -1
  72. jarvis/jarvis_utils/builtin_replace_map.py +9 -9
  73. jarvis/jarvis_utils/config.py +60 -37
  74. jarvis/jarvis_utils/embedding.py +24 -19
  75. jarvis/jarvis_utils/file_processors.py +16 -9
  76. jarvis/jarvis_utils/git_utils.py +157 -107
  77. jarvis/jarvis_utils/globals.py +1 -1
  78. jarvis/jarvis_utils/input.py +85 -52
  79. jarvis/jarvis_utils/jarvis_history.py +43 -0
  80. jarvis/jarvis_utils/methodology.py +31 -24
  81. jarvis/jarvis_utils/output.py +164 -80
  82. jarvis/jarvis_utils/tag.py +2 -1
  83. jarvis/jarvis_utils/utils.py +84 -52
  84. {jarvis_ai_assistant-0.1.193.dist-info → jarvis_ai_assistant-0.1.195.dist-info}/METADATA +362 -230
  85. jarvis_ai_assistant-0.1.195.dist-info/RECORD +98 -0
  86. jarvis/jarvis_agent/file_input_handler.py +0 -112
  87. jarvis/jarvis_event/__init__.py +0 -0
  88. jarvis_ai_assistant-0.1.193.dist-info/RECORD +0 -99
  89. {jarvis_ai_assistant-0.1.193.dist-info → jarvis_ai_assistant-0.1.195.dist-info}/WHEEL +0 -0
  90. {jarvis_ai_assistant-0.1.193.dist-info → jarvis_ai_assistant-0.1.195.dist-info}/entry_points.txt +0 -0
  91. {jarvis_ai_assistant-0.1.193.dist-info → jarvis_ai_assistant-0.1.195.dist-info}/licenses/LICENSE +0 -0
  92. {jarvis_ai_assistant-0.1.193.dist-info → jarvis_ai_assistant-0.1.195.dist-info}/top_level.txt +0 -0
@@ -5,8 +5,6 @@ import os
5
5
  import sys
6
6
  from typing import Optional
7
7
 
8
- from sympy import false
9
-
10
8
  from jarvis.jarvis_platform.registry import PlatformRegistry
11
9
  from jarvis.jarvis_utils.config import get_shell_name, set_config
12
10
  from jarvis.jarvis_utils.input import get_multiline_input
@@ -20,41 +18,42 @@ def execute_command(command: str, should_run: bool) -> None:
20
18
  os.system(command)
21
19
 
22
20
 
23
-
24
-
25
21
  def install_fish_completion() -> int:
26
22
  """Install fish shell command completion with interactive choice
27
-
23
+
28
24
  Returns:
29
25
  int: 0 if success, 1 if failed
30
26
  """
31
27
  if get_shell_name() != "fish":
32
28
  print("当前不是fish shell,无需安装")
33
29
  return 0
34
-
30
+
35
31
  # 使用fish命令检查函数是否已加载
36
32
  check_cmd = 'functions --names | grep fish_command_not_found > /dev/null && echo "defined" || echo "undefined"'
37
- result = os.popen(f'fish -c \'{check_cmd}\'').read().strip()
38
-
33
+ result = os.popen(f"fish -c '{check_cmd}'").read().strip()
34
+
39
35
  if result == "defined":
40
36
  print("fish_command_not_found函数已加载,无需安装")
41
37
  return 0
42
-
38
+
43
39
  config_file = os.path.expanduser("~/.config/fish/config.fish")
44
-
40
+
45
41
  # 检查文件内容是否已定义但未加载
46
42
  if os.path.exists(config_file):
47
- with open(config_file, 'r') as config:
43
+ with open(config_file, "r") as config:
48
44
  if "function fish_command_not_found" in config.read():
49
- print("fish_command_not_found函数已定义但未加载,请执行: source ~/.config/fish/config.fish")
45
+ print(
46
+ "fish_command_not_found函数已定义但未加载,请执行: source ~/.config/fish/config.fish"
47
+ )
50
48
  return 0
51
-
49
+
52
50
  # 创建config.fish文件如果不存在
53
51
  os.makedirs(os.path.dirname(config_file), exist_ok=True)
54
-
52
+
55
53
  # 追加函数定义到config.fish
56
- with open(config_file, 'a') as config:
57
- config.write("""
54
+ with open(config_file, "a") as config:
55
+ config.write(
56
+ """
58
57
  function fish_command_not_found
59
58
  commandline -r (jss request "$argv")
60
59
  end
@@ -62,8 +61,11 @@ end
62
61
  function __fish_command_not_found_handler --on-event fish_command_not_found
63
62
  fish_command_not_found "$argv"
64
63
  end
65
- """)
66
- print("Fish shell命令补全功能已安装到config.fish,请执行: source ~/.config/fish/config.fish")
64
+ """
65
+ )
66
+ print(
67
+ "Fish shell命令补全功能已安装到config.fish,请执行: source ~/.config/fish/config.fish"
68
+ )
67
69
  return 0
68
70
 
69
71
 
@@ -115,12 +117,13 @@ def process_request(request: str) -> Optional[str]:
115
117
  except Exception:
116
118
  return None
117
119
 
120
+
118
121
  def main() -> int:
119
122
  # 创建参数解析器
120
123
  init_env("")
121
124
 
122
125
  set_config("JARVIS_PRINT_PROMPT", "false")
123
-
126
+
124
127
  parser = argparse.ArgumentParser(
125
128
  description="将自然语言要求转换为shell命令",
126
129
  formatter_class=argparse.RawDescriptionHelpFormatter,
@@ -128,29 +131,30 @@ def main() -> int:
128
131
  Example:
129
132
  %(prog)s request "Find all Python files in the current directory"
130
133
  %(prog)s install
131
- """)
134
+ """,
135
+ )
132
136
 
133
137
  # 创建子命令解析器
134
- subparsers = parser.add_subparsers(dest='command', required=True)
138
+ subparsers = parser.add_subparsers(dest="command", required=True)
135
139
 
136
140
  # request子命令
137
- request_parser = subparsers.add_parser('request', help='描述您想要执行的操作(用自然语言描述)')
141
+ request_parser = subparsers.add_parser(
142
+ "request", help="描述您想要执行的操作(用自然语言描述)"
143
+ )
138
144
  request_parser.add_argument(
139
145
  "request",
140
- nargs='?', # 设置为可选参数
141
- help="描述您想要执行的操作(用自然语言描述),如果未提供则从标准输入读取"
146
+ nargs="?", # 设置为可选参数
147
+ help="描述您想要执行的操作(用自然语言描述),如果未提供则从标准输入读取",
142
148
  )
143
149
 
144
150
  # install子命令
145
- install_parser = subparsers.add_parser('install', help='安装fish shell的命令补全功能')
151
+ install_parser = subparsers.add_parser(
152
+ "install", help="安装fish shell的命令补全功能"
153
+ )
146
154
  install_parser.add_argument(
147
- "--shell",
148
- choices=["fish"],
149
- default="fish",
150
- help="指定shell类型(仅支持fish)"
155
+ "--shell", choices=["fish"], default="fish", help="指定shell类型(仅支持fish)"
151
156
  )
152
157
 
153
-
154
158
  # 解析参数
155
159
  args = parser.parse_args()
156
160
 
@@ -178,5 +182,6 @@ Example:
178
182
  else:
179
183
  return 1
180
184
 
185
+
181
186
  if __name__ == "__main__":
182
187
  sys.exit(main())
@@ -9,21 +9,17 @@ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
9
9
 
10
10
  # 定义AskUserTool类,用于向用户提问
11
11
  class AskUserTool:
12
- name="ask_user"
13
- description="""当完成任务所需的信息缺失或关键决策信息不足时,向用户提问。用户可以输入多行文本,以空行结束。使用场景:1. 需要用户提供更多信息以完成任务;2. 需要用户做出关键决策;3. 需要用户确认重要操作;4. 需要用户提供额外信息"""
12
+ name = "ask_user"
13
+ description = """当完成任务所需的信息缺失或关键决策信息不足时,向用户提问。用户可以输入多行文本,以空行结束。使用场景:1. 需要用户提供更多信息以完成任务;2. 需要用户做出关键决策;3. 需要用户确认重要操作;4. 需要用户提供额外信息"""
14
14
  # 定义参数结构,指定必须包含的问题字段
15
- parameters={
15
+ parameters = {
16
16
  "type": "object",
17
17
  "properties": {
18
- "question": {
19
- "type": "string",
20
- "description": "要向用户提出的问题"
21
- }
18
+ "question": {"type": "string", "description": "要向用户提出的问题"}
22
19
  },
23
- "required": ["question"]
20
+ "required": ["question"],
24
21
  }
25
22
 
26
-
27
23
  def execute(self, args: Dict[str, Any]) -> Dict[str, Any]:
28
24
  """执行向用户提问的操作
29
25
 
@@ -48,16 +44,12 @@ class AskUserTool:
48
44
  user_response = get_multiline_input("请输入您的答案 (输入空行结束)")
49
45
 
50
46
  # 返回成功响应,包含用户输入的内容
51
- return {
52
- "success": True,
53
- "stdout": user_response,
54
- "stderr": ""
55
- }
47
+ return {"success": True, "stdout": user_response, "stderr": ""}
56
48
 
57
49
  except Exception as e:
58
50
  # 如果发生异常,返回失败响应,包含错误信息
59
51
  return {
60
52
  "success": False,
61
53
  "stdout": "",
62
- "stderr": f"Failed to ask user: {str(e)}"
63
- }
54
+ "stderr": f"Failed to ask user: {str(e)}",
55
+ }
@@ -20,12 +20,13 @@ class Tool:
20
20
  self.description = description
21
21
  self.parameters = parameters
22
22
  self.func = func
23
+
23
24
  def to_dict(self) -> Dict:
24
25
  """将工具对象转换为字典格式,主要用于序列化"""
25
26
  return {
26
27
  "name": self.name,
27
28
  "description": self.description,
28
- "parameters": json.dumps(self.parameters, ensure_ascii=False)
29
+ "parameters": json.dumps(self.parameters, ensure_ascii=False),
29
30
  }
30
31
 
31
32
  def execute(self, arguments: Dict) -> Dict[str, Any]:
@@ -38,4 +39,4 @@ class Tool:
38
39
  返回:
39
40
  Dict[str, Any]: 工具执行结果
40
41
  """
41
- return self.func(arguments)
42
+ return self.func(arguments)
@@ -11,10 +11,10 @@ class ChdirTool:
11
11
  "properties": {
12
12
  "path": {
13
13
  "type": "string",
14
- "description": "要切换到的目录路径,支持相对路径和绝对路径"
14
+ "description": "要切换到的目录路径,支持相对路径和绝对路径",
15
15
  }
16
16
  },
17
- "required": ["path"]
17
+ "required": ["path"],
18
18
  }
19
19
 
20
20
  def execute(self, args: Dict[str, Any]) -> Dict[str, Any]:
@@ -44,18 +44,14 @@ class ChdirTool:
44
44
 
45
45
  # 验证目标路径是否存在
46
46
  if not os.path.exists(path):
47
- return {
48
- "success": False,
49
- "stdout": "",
50
- "stderr": f"目录不存在: {path}"
51
- }
47
+ return {"success": False, "stdout": "", "stderr": f"目录不存在: {path}"}
52
48
 
53
49
  # 确保路径指向的是目录,而不是文件
54
50
  if not os.path.isdir(path):
55
51
  return {
56
52
  "success": False,
57
53
  "stdout": "",
58
- "stderr": f"路径不是目录: {path}"
54
+ "stderr": f"路径不是目录: {path}",
59
55
  }
60
56
 
61
57
  # 获取当前目录并尝试切换到新路径
@@ -65,20 +61,12 @@ class ChdirTool:
65
61
  return {
66
62
  "success": True,
67
63
  "stdout": f"成功切换工作目录:\n原目录: {old_path}\n新目录: {path}",
68
- "stderr": ""
64
+ "stderr": "",
69
65
  }
70
66
 
71
67
  # 处理用户没有目录访问权限的情况
72
68
  except PermissionError:
73
- return {
74
- "success": False,
75
- "stdout": "",
76
- "stderr": f"无权限访问目录: {path}"
77
- }
69
+ return {"success": False, "stdout": "", "stderr": f"无权限访问目录: {path}"}
78
70
  # 捕获在目录切换过程中可能出现的其他意外错误
79
71
  except Exception as e:
80
- return {
81
- "success": False,
82
- "stdout": "",
83
- "stderr": f"切换目录失败: {str(e)}"
84
- }
72
+ return {"success": False, "stdout": "", "stderr": f"切换目录失败: {str(e)}"}
@@ -1,4 +1,3 @@
1
-
2
1
  import sys
3
2
 
4
3
  from jarvis.jarvis_tools.registry import ToolRegistry
@@ -9,11 +8,11 @@ from jarvis.jarvis_utils.utils import init_env
9
8
  def main() -> int:
10
9
  """
11
10
  命令行工具入口,提供工具列表查看和工具调用功能
12
-
11
+
13
12
  功能:
14
13
  1. 列出所有可用工具 (list命令)
15
14
  2. 调用指定工具 (call命令)
16
-
15
+
17
16
  参数:
18
17
  通过命令行参数传递,包括:
19
18
  - list: 列出工具
@@ -23,7 +22,7 @@ def main() -> int:
23
22
  tool_name: 工具名称
24
23
  --args: 工具参数(JSON格式)
25
24
  --args-file: 从文件加载工具参数
26
-
25
+
27
26
  返回值:
28
27
  int: 0表示成功,非0表示错误
29
28
  """
@@ -62,7 +61,9 @@ def main() -> int:
62
61
 
63
62
  if args.json:
64
63
  if args.detailed:
65
- print(json.dumps(tools, indent=2, ensure_ascii=False)) # 输出完整JSON格式
64
+ print(
65
+ json.dumps(tools, indent=2, ensure_ascii=False)
66
+ ) # 输出完整JSON格式
66
67
  else:
67
68
  simple_tools = [
68
69
  {"name": t["name"], "description": t["description"]} for t in tools
@@ -79,25 +80,28 @@ def main() -> int:
79
80
 
80
81
  elif args.command == "stat":
81
82
  from tabulate import tabulate
83
+
82
84
  stats = registry._get_tool_stats()
83
85
  tools = registry.get_all_tools()
84
-
86
+
85
87
  # 构建统计表格数据
86
88
  table_data = []
87
89
  for tool in tools:
88
90
  name = tool["name"]
89
91
  count = stats.get(name, 0)
90
92
  table_data.append([name, count])
91
-
93
+
92
94
  # 按调用次数降序排序
93
95
  table_data.sort(key=lambda x: x[1], reverse=True)
94
-
96
+
95
97
  if args.json:
96
98
  print(json.dumps(dict(table_data), indent=2))
97
99
  else:
98
100
  PrettyOutput.section("工具调用统计", OutputType.SYSTEM)
99
- print(tabulate(table_data, headers=["工具名称", "调用次数"], tablefmt="grid"))
100
-
101
+ print(
102
+ tabulate(table_data, headers=["工具名称", "调用次数"], tablefmt="grid")
103
+ )
104
+
101
105
  return 0
102
106
 
103
107
  elif args.command == "call":
@@ -40,17 +40,14 @@ class CodePlanTool:
40
40
  parameters = {
41
41
  "type": "object",
42
42
  "properties": {
43
- "requirement": {
44
- "type": "string",
45
- "description": "代码修改需求描述"
46
- },
43
+ "requirement": {"type": "string", "description": "代码修改需求描述"},
47
44
  "root_dir": {
48
45
  "type": "string",
49
46
  "description": "代码库根目录路径(可选)",
50
- "default": "."
51
- }
47
+ "default": ".",
48
+ },
52
49
  },
53
- "required": ["requirement"]
50
+ "required": ["requirement"],
54
51
  }
55
52
 
56
53
  def execute(self, args: Dict[str, Any]) -> Dict[str, Any]:
@@ -89,12 +86,9 @@ class CodePlanTool:
89
86
 
90
87
  # 创建工具注册表
91
88
  tool_registry: ToolRegistry = ToolRegistry()
92
- tool_registry.use_tools([
93
- "execute_script",
94
- "read_code",
95
- "search_web",
96
- "ask_user"
97
- ])
89
+ tool_registry.use_tools(
90
+ ["execute_script", "read_code", "search_web", "ask_user"]
91
+ )
98
92
 
99
93
  # 创建并运行Agent
100
94
  platform_registry: PlatformRegistry = PlatformRegistry()
@@ -113,30 +107,18 @@ class CodePlanTool:
113
107
  task_input = f"分析并规划代码修改: {requirement}"
114
108
  result = planner_agent.run(task_input)
115
109
 
116
- return {
117
- "success": True,
118
- "stdout": result,
119
- "stderr": ""
120
- }
110
+ return {"success": True, "stdout": result, "stderr": ""}
121
111
  except (OSError, RuntimeError) as e:
122
112
  error_msg = f"代码规划失败: {str(e)}"
123
113
  PrettyOutput.print(error_msg, OutputType.WARNING)
124
- return {
125
- "success": False,
126
- "stdout": "",
127
- "stderr": error_msg
128
- }
114
+ return {"success": False, "stdout": "", "stderr": error_msg}
129
115
  finally:
130
116
  # 恢复原始目录
131
117
  os.chdir(original_dir)
132
118
  except (KeyError, ValueError) as e:
133
119
  error_msg = f"代码规划失败: {str(e)}"
134
120
  PrettyOutput.print(error_msg, OutputType.WARNING)
135
- return {
136
- "success": False,
137
- "stdout": "",
138
- "stderr": error_msg
139
- }
121
+ return {"success": False, "stdout": "", "stderr": error_msg}
140
122
 
141
123
  def _create_system_prompt(self, requirement: str, git_root: str) -> str:
142
124
  """创建Agent的system prompt"""
@@ -234,6 +216,3 @@ class CodePlanTool:
234
216
  - 记录用户的任何特殊要求
235
217
 
236
218
  使用清晰的Markdown格式,重点突出修改计划和验证方案。"""
237
-
238
-
239
-
@@ -25,11 +25,10 @@ class CreateCodeAgentTool:
25
25
  "root_dir": {
26
26
  "type": "string",
27
27
  "description": "代码库根目录路径(可选)",
28
- "default": "."
29
- }
28
+ "default": ".",
29
+ },
30
30
  }
31
31
 
32
-
33
32
  def execute(self, args: Dict[str, Any]) -> Dict[str, Any]:
34
33
  try:
35
34
  requirement = args.get("requirement", "")
@@ -45,7 +44,7 @@ class CreateCodeAgentTool:
45
44
  return {
46
45
  "success": False,
47
46
  "stderr": "Requirement must be provided",
48
- "stdout": ""
47
+ "stdout": "",
49
48
  }
50
49
 
51
50
  # Step 1: Handle uncommitted changes
@@ -58,7 +57,7 @@ class CreateCodeAgentTool:
58
57
  return {
59
58
  "success": False,
60
59
  "stderr": "Failed to commit changes: " + result["stderr"],
61
- "stdout": ""
60
+ "stdout": "",
62
61
  }
63
62
 
64
63
  # Get current commit hash
@@ -83,11 +82,7 @@ class CreateCodeAgentTool:
83
82
 
84
83
  """
85
84
 
86
- return {
87
- "success": True,
88
- "stdout": summary,
89
- "stderr": ""
90
- }
85
+ return {"success": True, "stdout": summary, "stderr": ""}
91
86
  finally:
92
87
  # Always restore original directory
93
88
  os.chdir(original_dir)
@@ -96,5 +91,5 @@ class CreateCodeAgentTool:
96
91
  return {
97
92
  "success": False,
98
93
  "stderr": f"Development workflow failed: {str(e)}",
99
- "stdout": ""
94
+ "stdout": "",
100
95
  }
@@ -12,34 +12,23 @@ class SubAgentTool:
12
12
  parameters = {
13
13
  "type": "object",
14
14
  "properties": {
15
- "agent_name": {
16
- "type": "string",
17
- "description": "子代理名称"
18
- },
19
- "task": {
20
- "type": "string",
21
- "description": "要完成的特定任务"
22
- },
15
+ "agent_name": {"type": "string", "description": "子代理名称"},
16
+ "task": {"type": "string", "description": "要完成的特定任务"},
23
17
  "context": {
24
18
  "type": "string",
25
19
  "description": "与任务相关的上下文信息",
26
- "default": ""
27
- },
28
- "goal": {
29
- "type": "string",
30
- "description": "任务的完成目标",
31
- "default": ""
20
+ "default": "",
32
21
  },
22
+ "goal": {"type": "string", "description": "任务的完成目标", "default": ""},
33
23
  "root_dir": {
34
24
  "type": "string",
35
25
  "description": "任务执行的根目录路径(可选)",
36
- "default": "."
37
- }
26
+ "default": ".",
27
+ },
38
28
  },
39
- "required": ["agent_name", "task"]
29
+ "required": ["agent_name", "task"],
40
30
  }
41
31
 
42
-
43
32
  def execute(self, args: Dict) -> Dict[str, Any]:
44
33
  """Create and run sub-agent"""
45
34
  try:
@@ -58,7 +47,6 @@ class SubAgentTool:
58
47
  if goal:
59
48
  task_description += f"\n\nCompletion goal:\n{goal}"
60
49
 
61
-
62
50
  # Store current directory
63
51
  original_dir = os.getcwd()
64
52
 
@@ -79,7 +67,7 @@ class SubAgentTool:
79
67
  return {
80
68
  "success": True,
81
69
  "stdout": f"Sub-agent task completed\n\n{result}",
82
- "stderr": ""
70
+ "stderr": "",
83
71
  }
84
72
  finally:
85
73
  # Always restore original directory
@@ -90,5 +78,5 @@ class SubAgentTool:
90
78
  return {
91
79
  "success": False,
92
80
  "stdout": "",
93
- "stderr": f"Sub-agent execution failed: {str(e)}"
94
- }
81
+ "stderr": f"Sub-agent execution failed: {str(e)}",
82
+ }