jarvis-ai-assistant 0.1.128__py3-none-any.whl → 0.1.130__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 (32) hide show
  1. jarvis/__init__.py +1 -1
  2. jarvis/jarvis_agent/__init__.py +26 -31
  3. jarvis/jarvis_agent/main.py +77 -0
  4. jarvis/jarvis_c2rust/c2rust.yaml +734 -0
  5. jarvis/jarvis_code_agent/builtin_input_handler.py +43 -0
  6. jarvis/jarvis_code_agent/code_agent.py +82 -156
  7. jarvis/jarvis_code_agent/file_input_handler.py +88 -0
  8. jarvis/jarvis_code_agent/patch.py +262 -80
  9. jarvis/jarvis_code_agent/shell_input_handler.py +8 -2
  10. jarvis/jarvis_dev/main.py +832 -740
  11. jarvis/jarvis_multi_agent/__init__.py +113 -92
  12. jarvis/jarvis_platform/registry.py +0 -1
  13. jarvis/jarvis_tools/create_sub_agent.py +1 -8
  14. jarvis/jarvis_tools/git_commiter.py +2 -1
  15. jarvis/jarvis_tools/read_code.py +143 -0
  16. jarvis/jarvis_tools/registry.py +35 -39
  17. jarvis/jarvis_tools/tool_generator.py +45 -17
  18. jarvis/jarvis_utils/__init__.py +17 -17
  19. jarvis/jarvis_utils/config.py +87 -51
  20. jarvis/jarvis_utils/embedding.py +49 -48
  21. jarvis/jarvis_utils/git_utils.py +34 -34
  22. jarvis/jarvis_utils/globals.py +26 -26
  23. jarvis/jarvis_utils/input.py +61 -45
  24. jarvis/jarvis_utils/methodology.py +22 -22
  25. jarvis/jarvis_utils/output.py +64 -64
  26. jarvis/jarvis_utils/utils.py +2 -2
  27. {jarvis_ai_assistant-0.1.128.dist-info → jarvis_ai_assistant-0.1.130.dist-info}/METADATA +1 -1
  28. {jarvis_ai_assistant-0.1.128.dist-info → jarvis_ai_assistant-0.1.130.dist-info}/RECORD +32 -27
  29. {jarvis_ai_assistant-0.1.128.dist-info → jarvis_ai_assistant-0.1.130.dist-info}/entry_points.txt +2 -0
  30. {jarvis_ai_assistant-0.1.128.dist-info → jarvis_ai_assistant-0.1.130.dist-info}/LICENSE +0 -0
  31. {jarvis_ai_assistant-0.1.128.dist-info → jarvis_ai_assistant-0.1.130.dist-info}/WHEEL +0 -0
  32. {jarvis_ai_assistant-0.1.128.dist-info → jarvis_ai_assistant-0.1.130.dist-info}/top_level.txt +0 -0
jarvis/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """Jarvis AI Assistant"""
2
2
 
3
- __version__ = "0.1.128"
3
+ __version__ = "0.1.130"
@@ -23,10 +23,10 @@ import os
23
23
  class Agent:
24
24
 
25
25
  def set_summary_prompt(self, summary_prompt: str):
26
- """Set the summary prompt for task completion.
26
+ """设置任务完成时的总结提示模板。
27
27
 
28
- Args:
29
- summary_prompt: The prompt template for generating task summaries
28
+ 参数:
29
+ summary_prompt: 用于生成任务总结的提示模板
30
30
  """
31
31
  self.summary_prompt = summary_prompt
32
32
 
@@ -49,7 +49,8 @@ class Agent:
49
49
  record_methodology: Optional[bool] = None,
50
50
  need_summary: Optional[bool] = None,
51
51
  max_context_length: Optional[int] = None,
52
- execute_tool_confirm: Optional[bool] = None):
52
+ execute_tool_confirm: Optional[bool] = None,
53
+ multiline_inputer: Optional[Callable[[str], str]] = None):
53
54
  self.name = make_agent_name(name)
54
55
  self.description = description
55
56
  # 初始化平台和模型
@@ -69,7 +70,8 @@ class Agent:
69
70
 
70
71
  self.model.set_suppress_output(False)
71
72
 
72
- self.output_handler = output_handler
73
+ self.output_handler = output_handler if output_handler else [ToolRegistry()]
74
+ self.multiline_inputer = multiline_inputer if multiline_inputer else get_multiline_input
73
75
 
74
76
  self.record_methodology = record_methodology if record_methodology is not None else is_record_methodology()
75
77
  self.use_methodology = use_methodology if use_methodology is not None else is_use_methodology()
@@ -150,23 +152,23 @@ class Agent:
150
152
 
151
153
 
152
154
 
153
- def _call_model(self, message: str) -> str:
154
- """Call the AI model with retry logic.
155
+ def _call_model(self, message: str) -> str:
156
+ """调用AI模型并实现重试逻辑。
155
157
 
156
- Args:
157
- message: The input message for the model
158
+ 参数:
159
+ message: 输入给模型的消息
158
160
 
159
- Returns:
160
- str: Model's response
161
+ 返回:
162
+ str: 模型的响应
161
163
 
162
- Note:
163
- Will retry with exponential backoff up to 30 seconds between retries
164
+ 注意:
165
+ 将使用指数退避重试,最多重试30
164
166
  """
165
167
  for handler in self.input_handler:
166
168
  message, need_return = handler(message, self)
167
169
  if need_return:
168
170
  return message
169
- PrettyOutput.section("模型输出", OutputType.SYSTEM)
171
+ print("🤖 模型思考:")
170
172
  return self.model.chat_until_success(message) # type: ignore
171
173
 
172
174
 
@@ -287,23 +289,17 @@ class Agent:
287
289
  return "任务完成"
288
290
 
289
291
 
290
- def run(self, user_input: str, file_list: Optional[List[str]] = None) -> Any:
292
+ def run(self, user_input: str) -> Any:
291
293
  """Process user input and execute the task.
292
294
 
293
295
  Args:
294
296
  user_input: My task description or request
295
- file_list: Optional list of files to process
296
297
 
297
298
  Returns:
298
299
  str|Dict: Task summary report or message to send
299
300
  """
300
301
  try:
301
302
  set_agent(self.name, self)
302
- with yaspin(text="准备环境...", color="cyan") as spinner:
303
- if file_list:
304
- self.model.upload_files(file_list) # type: ignore
305
- spinner.text = "环境准备完成"
306
- spinner.ok("✅")
307
303
 
308
304
  self.prompt = f"{user_input}"
309
305
 
@@ -338,7 +334,7 @@ class Agent:
338
334
  return self._complete_task()
339
335
 
340
336
  # 获取用户输入
341
- user_input = get_multiline_input(f"{self.name}: 请输入,或输入空行来结束当前任务:")
337
+ user_input = self.multiline_inputer(f"{self.name}: 请输入,或输入空行来结束当前任务:")
342
338
 
343
339
  if user_input:
344
340
  self.prompt = user_input
@@ -356,16 +352,16 @@ class Agent:
356
352
  return f"Task failed: {str(e)}"
357
353
 
358
354
  def _clear_history(self):
359
- """Clear conversation history while preserving system prompt.
355
+ """清空对话历史但保留系统提示。
360
356
 
361
- This will:
362
- 1. Clear the prompt
363
- 2. Reset the model
364
- 3. Reset conversation length counter
357
+ 该方法将:
358
+ 1. 清空当前提示
359
+ 2. 重置模型状态
360
+ 3. 重置对话长度计数器
365
361
  """
366
362
  self.prompt = ""
367
363
  self.model.reset() # type: ignore
368
- self.conversation_length = 0 # Reset conversation length
364
+ self.conversation_length = 0 # 重置对话长度
369
365
 
370
366
 
371
367
 
@@ -551,7 +547,6 @@ def main():
551
547
  # Add argument parser
552
548
  init_env()
553
549
  parser = argparse.ArgumentParser(description='Jarvis AI assistant')
554
- parser.add_argument('-f', '--files', nargs='*', help='List of files to process')
555
550
  parser.add_argument('-p', '--platform', type=str, help='Platform to use')
556
551
  parser.add_argument('-m', '--model', type=str, help='Model to use')
557
552
  args = parser.parse_args()
@@ -566,7 +561,7 @@ def main():
566
561
  selected_task = _select_task(tasks)
567
562
  if selected_task:
568
563
  PrettyOutput.print(f"执行任务: {selected_task}", OutputType.INFO)
569
- agent.run(selected_task, args.files)
564
+ agent.run(selected_task)
570
565
  return 0
571
566
 
572
567
  # 如果没有选择预定义任务,进入交互模式
@@ -575,7 +570,7 @@ def main():
575
570
  user_input = get_multiline_input("请输入你的任务(输入空行退出):")
576
571
  if not user_input:
577
572
  break
578
- agent.run(user_input, args.files)
573
+ agent.run(user_input)
579
574
  except Exception as e:
580
575
  PrettyOutput.print(f"错误: {str(e)}", OutputType.ERROR)
581
576
 
@@ -0,0 +1,77 @@
1
+ import argparse
2
+ import yaml
3
+ import os
4
+ from typing import Optional, List
5
+ from jarvis.jarvis_agent import Agent
6
+ from jarvis.jarvis_utils.input import get_multiline_input
7
+ from jarvis.jarvis_utils.output import PrettyOutput, OutputType
8
+ from jarvis.jarvis_utils.utils import init_env
9
+
10
+ # 从__init__.py导入系统提示
11
+ from jarvis.jarvis_agent import origin_agent_system_prompt
12
+
13
+ def load_config(config_path: str) -> dict:
14
+ """Load configuration from YAML file
15
+
16
+ Args:
17
+ config_path: Path to the YAML configuration file
18
+
19
+ Returns:
20
+ dict: Configuration dictionary
21
+ """
22
+ if not os.path.exists(config_path):
23
+ PrettyOutput.print(f"配置文件 {config_path} 不存在,使用默认配置", OutputType.WARNING)
24
+ return {}
25
+
26
+ with open(config_path, 'r', encoding='utf-8') as f:
27
+ try:
28
+ config = yaml.safe_load(f)
29
+ return config if config else {}
30
+ except yaml.YAMLError as e:
31
+ PrettyOutput.print(f"配置文件解析失败: {str(e)}", OutputType.ERROR)
32
+ return {}
33
+
34
+ def main():
35
+ """Main entry point for Jarvis agent"""
36
+ # Initialize environment
37
+ init_env()
38
+
39
+ # Set up argument parser
40
+ parser = argparse.ArgumentParser(description='Jarvis AI assistant')
41
+ parser.add_argument('-c', '--config', type=str, required=True,
42
+ help='Path to the YAML configuration file')
43
+ parser.add_argument('-t', '--task', type=str,
44
+ help='Initial task to execute')
45
+ args = parser.parse_args()
46
+
47
+ # Load configuration
48
+ config = load_config(args.config)
49
+
50
+ # Create and run agent
51
+ try:
52
+ agent = Agent(**config)
53
+
54
+ # Run agent with initial task if specified
55
+ if args.task:
56
+ PrettyOutput.print(f"执行初始任务: {args.task}", OutputType.INFO)
57
+ agent.run(args.task)
58
+ return 0
59
+
60
+ # Enter interactive mode if no initial task
61
+ while True:
62
+ try:
63
+ user_input = get_multiline_input("请输入你的任务(输入空行退出):")
64
+ if not user_input:
65
+ break
66
+ agent.run(user_input)
67
+ except Exception as e:
68
+ PrettyOutput.print(f"错误: {str(e)}", OutputType.ERROR)
69
+
70
+ except Exception as e:
71
+ PrettyOutput.print(f"初始化错误: {str(e)}", OutputType.ERROR)
72
+ return 1
73
+
74
+ return 0
75
+
76
+ if __name__ == "__main__":
77
+ exit(main())