jarvis-ai-assistant 0.1.101__tar.gz → 0.1.103__tar.gz

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 (69) hide show
  1. {jarvis_ai_assistant-0.1.101/src/jarvis_ai_assistant.egg-info → jarvis_ai_assistant-0.1.103}/PKG-INFO +9 -5
  2. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/README.md +3 -3
  3. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/pyproject.toml +10 -4
  4. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/setup.py +10 -4
  5. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/__init__.py +1 -1
  6. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/agent.py +140 -140
  7. jarvis_ai_assistant-0.1.103/src/jarvis/jarvis_code_agent/code_agent.py +234 -0
  8. {jarvis_ai_assistant-0.1.101/src/jarvis/jarvis_coder → jarvis_ai_assistant-0.1.103/src/jarvis/jarvis_code_agent}/file_select.py +16 -17
  9. jarvis_ai_assistant-0.1.103/src/jarvis/jarvis_code_agent/patch.py +118 -0
  10. jarvis_ai_assistant-0.1.103/src/jarvis/jarvis_code_agent/relevant_files.py +66 -0
  11. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/jarvis_codebase/main.py +32 -29
  12. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/jarvis_platform/main.py +5 -3
  13. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/jarvis_rag/main.py +11 -15
  14. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/jarvis_smart_shell/main.py +2 -2
  15. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/models/ai8.py +1 -0
  16. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/models/kimi.py +36 -30
  17. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/models/ollama.py +17 -11
  18. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/models/openai.py +15 -12
  19. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/models/oyi.py +22 -7
  20. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/models/registry.py +1 -25
  21. jarvis_ai_assistant-0.1.103/src/jarvis/tools/ask_codebase.py +99 -0
  22. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/tools/ask_user.py +1 -9
  23. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/tools/chdir.py +1 -1
  24. jarvis_ai_assistant-0.1.103/src/jarvis/tools/code_review.py +163 -0
  25. jarvis_ai_assistant-0.1.103/src/jarvis/tools/create_code_sub_agent.py +30 -0
  26. jarvis_ai_assistant-0.1.103/src/jarvis/tools/create_code_test_agent.py +115 -0
  27. jarvis_ai_assistant-0.1.103/src/jarvis/tools/create_ctags_agent.py +176 -0
  28. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/tools/create_sub_agent.py +2 -2
  29. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/tools/execute_shell.py +2 -2
  30. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/tools/file_operation.py +2 -2
  31. jarvis_ai_assistant-0.1.103/src/jarvis/tools/find_in_codebase.py +108 -0
  32. jarvis_ai_assistant-0.1.103/src/jarvis/tools/git_commiter.py +68 -0
  33. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/tools/methodology.py +3 -3
  34. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/tools/rag.py +6 -3
  35. jarvis_ai_assistant-0.1.103/src/jarvis/tools/read_code.py +147 -0
  36. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/tools/read_webpage.py +1 -1
  37. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/tools/registry.py +92 -68
  38. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/tools/search.py +8 -6
  39. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/tools/select_code_files.py +4 -4
  40. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/utils.py +270 -95
  41. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103/src/jarvis_ai_assistant.egg-info}/PKG-INFO +9 -5
  42. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis_ai_assistant.egg-info/SOURCES.txt +11 -11
  43. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis_ai_assistant.egg-info/entry_points.txt +4 -2
  44. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis_ai_assistant.egg-info/requires.txt +5 -1
  45. jarvis_ai_assistant-0.1.101/src/jarvis/jarvis_code_agent/main.py +0 -202
  46. jarvis_ai_assistant-0.1.101/src/jarvis/jarvis_coder/git_utils.py +0 -123
  47. jarvis_ai_assistant-0.1.101/src/jarvis/jarvis_coder/main.py +0 -241
  48. jarvis_ai_assistant-0.1.101/src/jarvis/jarvis_coder/patch_handler.py +0 -340
  49. jarvis_ai_assistant-0.1.101/src/jarvis/jarvis_coder/plan_generator.py +0 -145
  50. jarvis_ai_assistant-0.1.101/src/jarvis/tools/__init__.py +0 -6
  51. jarvis_ai_assistant-0.1.101/src/jarvis/tools/create_code_sub_agent.py +0 -56
  52. jarvis_ai_assistant-0.1.101/src/jarvis/tools/execute_code_modification.py +0 -70
  53. jarvis_ai_assistant-0.1.101/src/jarvis/tools/find_files.py +0 -119
  54. jarvis_ai_assistant-0.1.101/src/jarvis/tools/generate_tool.py +0 -174
  55. jarvis_ai_assistant-0.1.101/src/jarvis/tools/thinker.py +0 -151
  56. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/LICENSE +0 -0
  57. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/MANIFEST.in +0 -0
  58. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/setup.cfg +0 -0
  59. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/jarvis_code_agent/__init__.py +0 -0
  60. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/jarvis_codebase/__init__.py +0 -0
  61. {jarvis_ai_assistant-0.1.101/src/jarvis/jarvis_coder → jarvis_ai_assistant-0.1.103/src/jarvis/jarvis_platform}/__init__.py +0 -0
  62. {jarvis_ai_assistant-0.1.101/src/jarvis/jarvis_platform → jarvis_ai_assistant-0.1.103/src/jarvis/jarvis_rag}/__init__.py +0 -0
  63. {jarvis_ai_assistant-0.1.101/src/jarvis/jarvis_rag → jarvis_ai_assistant-0.1.103/src/jarvis/jarvis_smart_shell}/__init__.py +0 -0
  64. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/models/__init__.py +0 -0
  65. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/models/base.py +0 -0
  66. {jarvis_ai_assistant-0.1.101/src/jarvis/jarvis_smart_shell → jarvis_ai_assistant-0.1.103/src/jarvis/tools}/__init__.py +0 -0
  67. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis/tools/base.py +0 -0
  68. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis_ai_assistant.egg-info/dependency_links.txt +0 -0
  69. {jarvis_ai_assistant-0.1.101 → jarvis_ai_assistant-0.1.103}/src/jarvis_ai_assistant.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: jarvis-ai-assistant
3
- Version: 0.1.101
3
+ Version: 0.1.103
4
4
  Summary: Jarvis: An AI assistant that uses tools to interact with the system
5
5
  Home-page: https://github.com/skyfireitdiy/Jarvis
6
6
  Author: skyfire
@@ -45,7 +45,7 @@ Requires-Dist: colorama>=0.4.6
45
45
  Requires-Dist: prompt_toolkit>=3.0.0
46
46
  Requires-Dist: openai>=1.20.0
47
47
  Requires-Dist: playwright>=1.41.1
48
- Requires-Dist: numpy>=1.24.0
48
+ Requires-Dist: numpy>=1.17.4
49
49
  Requires-Dist: faiss-cpu>=1.8.0
50
50
  Requires-Dist: sentence-transformers>=2.2.2
51
51
  Requires-Dist: bs4>=0.0.1
@@ -55,6 +55,10 @@ Requires-Dist: tiktoken>=0.3.0
55
55
  Requires-Dist: tqdm>=4.65.0
56
56
  Requires-Dist: docx>=0.2.4
57
57
  Requires-Dist: yaspin>=2.5.0
58
+ Requires-Dist: rich>=13.3.1
59
+ Requires-Dist: pygments>=2.15.0
60
+ Requires-Dist: fuzzywuzzy>=0.18.0
61
+ Requires-Dist: python-Levenshtein>=0.26.1
58
62
  Provides-Extra: dev
59
63
  Requires-Dist: pytest; extra == "dev"
60
64
  Requires-Dist: black; extra == "dev"
@@ -157,13 +161,13 @@ jarvis
157
161
  ### Codebase Search
158
162
  ```bash
159
163
  # Generate codebase index
160
- jarvis-codebase --generate
164
+ jarvis-codebase generate
161
165
 
162
166
  # Search similar code
163
- jarvis-codebase --search "your search query"
167
+ jarvis-codebase search "your search query"
164
168
 
165
169
  # Ask questions about codebase
166
- jarvis-codebase --ask "your question"
170
+ jarvis-codebase ask "your question"
167
171
  ```
168
172
 
169
173
  ### Document Analysis (RAG)
@@ -91,13 +91,13 @@ jarvis
91
91
  ### Codebase Search
92
92
  ```bash
93
93
  # Generate codebase index
94
- jarvis-codebase --generate
94
+ jarvis-codebase generate
95
95
 
96
96
  # Search similar code
97
- jarvis-codebase --search "your search query"
97
+ jarvis-codebase search "your search query"
98
98
 
99
99
  # Ask questions about codebase
100
- jarvis-codebase --ask "your question"
100
+ jarvis-codebase ask "your question"
101
101
  ```
102
102
 
103
103
  ### Document Analysis (RAG)
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "jarvis-ai-assistant"
7
- version = "0.1.101"
7
+ version = "0.1.103"
8
8
  description = "Jarvis: An AI assistant that uses tools to interact with the system"
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Your Name", email = "your.email@example.com" }]
@@ -27,7 +27,7 @@ dependencies = [
27
27
  "prompt_toolkit>=3.0.0",
28
28
  "openai>=1.20.0",
29
29
  "playwright>=1.41.1",
30
- "numpy>=1.24.0",
30
+ "numpy>=1.17.4",
31
31
  "faiss-cpu>=1.8.0",
32
32
  "sentence-transformers>=2.2.2",
33
33
  "bs4>=0.0.1",
@@ -37,6 +37,10 @@ dependencies = [
37
37
  "tqdm>=4.65.0",
38
38
  "docx>=0.2.4",
39
39
  "yaspin>=2.5.0",
40
+ "rich>=13.3.1",
41
+ "pygments>=2.15.0",
42
+ "fuzzywuzzy>=0.18.0",
43
+ "python-Levenshtein>=0.26.1",
40
44
  ]
41
45
  requires-python = ">=3.8"
42
46
 
@@ -48,10 +52,12 @@ Homepage = "https://github.com/skyfireitdiy/Jarvis"
48
52
 
49
53
  [project.scripts]
50
54
  jarvis = "jarvis.agent:main"
51
- jarvis-code-agent = "jarvis.jarvis_code_agent.main:main"
52
- jarvis-coder = "jarvis.jarvis_coder.main:main"
55
+ jarvis-code-agent = "jarvis.jarvis_code_agent.code_agent:main"
53
56
  jarvis-codebase = "jarvis.jarvis_codebase.main:main"
54
57
  jarvis-rag = "jarvis.jarvis_rag.main:main"
55
58
  jarvis-smart-shell = "jarvis.jarvis_smart_shell.main:main"
56
59
  jss = "jarvis.jarvis_smart_shell.main:main"
57
60
  jarvis-platform = "jarvis.jarvis_platform.main:main"
61
+ jarvis-gh = "jarvis.jarvis_github.main:main"
62
+ jarvis-git-commit = "jarvis.tools.git_commiter:main"
63
+ jarvis-ctags = "jarvis.tools.create_ctags_agent:main"
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="jarvis-ai-assistant",
5
- version="0.1.101",
5
+ version="0.1.103",
6
6
  author="skyfire",
7
7
  author_email="skyfireitdiy@hotmail.com",
8
8
  description="An AI assistant that uses various tools to interact with the system",
@@ -19,7 +19,7 @@ setup(
19
19
  "prompt_toolkit>=3.0.0",
20
20
  "openai>=1.20.0",
21
21
  "playwright>=1.41.1",
22
- "numpy>=1.24.0",
22
+ "numpy==1.17.4",
23
23
  "faiss-cpu>=1.8.0",
24
24
  "sentence-transformers>=2.2.2",
25
25
  "bs4>=0.0.1",
@@ -29,17 +29,23 @@ setup(
29
29
  "tqdm>=4.65.0",
30
30
  "docx>=0.2.4",
31
31
  "yaspin>=2.5.0",
32
+ "rich>=13.3.1",
33
+ "pygments>=2.15.0",
34
+ "fuzzywuzzy>=0.18.0",
35
+ "python-Levenshtein>=0.26.1",
32
36
  ],
33
37
  entry_points={
34
38
  "console_scripts": [
35
39
  "jarvis=jarvis.agent:main",
36
- "jarvis-code-agent=jarvis.jarvis_code_agent.main:main",
37
- "jarvis-coder=jarvis.jarvis_coder.main:main",
40
+ "jarvis-code-agent=jarvis.jarvis_code_agent.code_agent:main",
38
41
  "jarvis-codebase=jarvis.jarvis_codebase.main:main",
39
42
  "jarvis-rag=jarvis.jarvis_rag.main:main",
40
43
  "jarvis-smart-shell=jarvis.jarvis_smart_shell.main:main",
41
44
  "jss=jarvis.jarvis_smart_shell.main:main",
42
45
  "jarvis-platform=jarvis.jarvis_platform.main:main",
46
+ "jarvis-gh=jarvis.jarvis_github.main:main",
47
+ "jarvis-git-commit=jarvis.tools.git_commiter:main",
48
+ "jarvis-ctags=jarvis.tools.create_ctags_agent:main",
43
49
  ],
44
50
  },
45
51
  python_requires=">=3.8",
@@ -1,3 +1,3 @@
1
1
  """Jarvis AI Assistant"""
2
2
 
3
- __version__ = "0.1.101"
3
+ __version__ = "0.1.103"
@@ -1,22 +1,38 @@
1
1
  import argparse
2
2
  import time
3
- from typing import Dict, List, Optional
3
+ from typing import Callable, Dict, List, Optional
4
4
 
5
5
  from prompt_toolkit import prompt
6
6
  import yaml
7
7
 
8
+ from jarvis.models.base import BasePlatform
8
9
  from jarvis.models.registry import PlatformRegistry
9
- from jarvis.tools import ToolRegistry
10
- from jarvis.tools.registry import load_tools
11
- from jarvis.utils import PrettyOutput, OutputType, get_single_line_input, load_methodology, add_agent, delete_current_agent, get_max_context_length, get_multiline_input, load_embedding_model, init_env
10
+ from jarvis.tools.registry import ToolRegistry, tool_call_help
11
+ from jarvis.utils import PrettyOutput, OutputType, is_auto_complete, load_methodology, add_agent, delete_current_agent, get_max_context_length, get_multiline_input, init_env
12
12
  import os
13
13
 
14
14
  class Agent:
15
15
 
16
16
  def __del__(self):
17
17
  delete_current_agent()
18
+
19
+ def set_summary_prompt(self, summary_prompt: str):
20
+ self.summary_prompt = summary_prompt
21
+
22
+ def set_output_filter(self, output_filter: List[Callable]):
23
+ self.output_filter = output_filter
18
24
 
19
- def __init__(self, system_prompt: str, name: str = "Jarvis", is_sub_agent: bool = False, tool_registry: Optional[ToolRegistry] = None):
25
+ def __init__(self,
26
+ system_prompt: str,
27
+ name: str = "Jarvis",
28
+ is_sub_agent: bool = False,
29
+ tool_registry: Optional[ToolRegistry] = None,
30
+ platform: Optional[BasePlatform] = None,
31
+ summary_prompt: Optional[str] = None,
32
+ auto_complete: bool = False,
33
+ record_methodology: bool = True,
34
+ output_filter: Optional[List[Callable]] = None,
35
+ need_summary: bool = True):
20
36
  """Initialize Agent with a model, optional tool registry and name
21
37
 
22
38
  Args:
@@ -24,45 +40,70 @@ class Agent:
24
40
  name: Agent name, default is "Jarvis"
25
41
  is_sub_agent: Whether it is a sub-agent, default is False
26
42
  tool_registry: Tool registry instance
43
+ platform: Optional platform instance, default uses normal platform
27
44
  """
28
45
  add_agent(name)
29
46
  PrettyOutput.print(f"Welcome to Jarvis, your AI assistant, Initiating...", OutputType.SYSTEM)
30
- self.model = PlatformRegistry.get_global_platform_registry().get_normal_platform()
31
- self.tool_registry = tool_registry if tool_registry else ToolRegistry.get_global_tool_registry()
47
+ if platform is not None:
48
+ self.model = platform
49
+ else:
50
+ self.model = PlatformRegistry.get_global_platform_registry().get_normal_platform()
51
+ self.tool_registry = tool_registry if tool_registry else ToolRegistry()
52
+ self.record_methodology = record_methodology
32
53
  self.name = name
33
54
  self.is_sub_agent = is_sub_agent
34
55
  self.prompt = ""
35
56
  self.conversation_length = 0 # Use length counter instead
36
57
  self.system_prompt = system_prompt
58
+ self.need_summary = need_summary
37
59
  # Load configuration from environment variables
38
- self.embedding_dimension = 1536 # Default for many embedding models
60
+ self.output_filter = output_filter if output_filter else []
61
+
62
+ self.summary_prompt = summary_prompt if summary_prompt else f"""Please generate a concise summary report of the task execution, including:
63
+
64
+ 1. Task Objective: Task restatement
65
+ 2. Execution Result: Success/Failure
66
+ 3. Key Information: Important information extracted during execution
67
+ 4. Important Findings: Any noteworthy discoveries
68
+ 5. Follow-up Suggestions: If any
69
+
70
+ Please describe in concise bullet points, highlighting important information.
71
+ """
72
+
39
73
  self.max_context_length = get_max_context_length()
74
+
75
+ self.auto_complete = auto_complete
76
+
77
+
40
78
 
41
- # Initialize embedding model
42
- try:
43
- self.embedding_model = load_embedding_model()
44
-
45
- # Warm up model and get correct dimension
46
- test_text = "This is a test text to ensure the model is fully loaded."
47
- test_embedding = self.embedding_model.encode(
48
- test_text,
49
- convert_to_tensor=True,
50
- normalize_embeddings=True
51
- )
52
- self.embedding_dimension = len(test_embedding)
53
- PrettyOutput.print("Successfully loaded embedding model", OutputType.SUCCESS)
54
-
55
- # Initialize HNSW index (use correct dimension)
56
-
57
-
58
- except Exception as e:
59
- PrettyOutput.print(f"Failed to load embedding model: {str(e)}", OutputType.ERROR)
60
- raise
61
79
 
62
80
  # Initialize methodology related attributes
63
81
  self.methodology_data = []
64
82
 
65
83
  PrettyOutput.section(f"Jarvis initialized - With {self.model.name()}", OutputType.SYSTEM)
84
+ tools = self.tool_registry.get_all_tools()
85
+ if tools:
86
+ PrettyOutput.section(f"Available tools: {', '.join([tool['name'] for tool in tools])}", OutputType.SYSTEM)
87
+
88
+
89
+ # Load methodology
90
+
91
+ tools_prompt = self.tool_registry.load_tools()
92
+ complete_prompt = """"""
93
+ if self.auto_complete:
94
+ complete_prompt = """
95
+ When the task is completed, you should print the following message:
96
+ <!!!COMPLETE!!!>
97
+ """
98
+
99
+ self.model.set_system_message(f"""
100
+ {self.system_prompt}
101
+
102
+ {tools_prompt}
103
+
104
+ {complete_prompt}
105
+ """)
106
+ self.first = True
66
107
 
67
108
  @staticmethod
68
109
  def extract_tool_calls(content: str) -> List[Dict]:
@@ -72,14 +113,6 @@ class Agent:
72
113
  tool_call_lines = []
73
114
  in_tool_call = False
74
115
 
75
- tool_call_help = """Tool Usage Format:
76
-
77
- <TOOL_CALL>
78
- name: tool_name
79
- arguments:
80
- param1: value1
81
- param2: value2
82
- </TOOL_CALL>"""
83
116
 
84
117
  # Process line by line
85
118
  for line in lines:
@@ -88,27 +121,19 @@ arguments:
88
121
  continue
89
122
  elif '</TOOL_CALL>' in line:
90
123
  if in_tool_call and tool_call_lines:
91
- try:
92
- # Parse YAML directly
93
- tool_call_text = '\n'.join(tool_call_lines)
94
- tool_call_data = yaml.safe_load(tool_call_text)
95
-
96
- # Validate necessary fields
97
- if "name" in tool_call_data and "arguments" in tool_call_data:
98
- # Return content before tool call and tool call
99
- return [{
100
- "name": tool_call_data["name"],
101
- "arguments": tool_call_data["arguments"]
102
- }]
103
- else:
104
- PrettyOutput.print("Tool call missing necessary fields", OutputType.ERROR)
105
- raise Exception("Tool call missing necessary fields, " + tool_call_help)
106
- except yaml.YAMLError as e:
107
- PrettyOutput.print(f"YAML parsing error: {str(e)}", OutputType.ERROR)
108
- raise Exception(f"YAML parsing error: {str(e)}")
109
- except Exception as e:
110
- PrettyOutput.print(f"Error processing tool call: {str(e)}", OutputType.ERROR)
111
- raise Exception(f"Error processing tool call: {str(e)}")
124
+ # Parse YAML directly
125
+ tool_call_text = '\n'.join(tool_call_lines)
126
+ tool_call_data = yaml.safe_load(tool_call_text)
127
+
128
+ # Validate necessary fields
129
+ if "name" in tool_call_data and "arguments" in tool_call_data:
130
+ # Return content before tool call and tool call
131
+ return [{
132
+ "name": tool_call_data["name"],
133
+ "arguments": tool_call_data["arguments"]
134
+ }]
135
+ else:
136
+ raise Exception("Tool call missing necessary fields")
112
137
  in_tool_call = False
113
138
  continue
114
139
 
@@ -185,53 +210,39 @@ Please continue the task based on the above information.
185
210
  """
186
211
  PrettyOutput.section("Task completed", OutputType.SUCCESS)
187
212
 
188
- # 询问是否生成方法论,带输入验证
189
- while True:
190
- user_input = get_single_line_input("Generate methodology for this task? (y/n)").strip().lower()
191
- if user_input in ['y', 'n', '']:
192
- break
193
- PrettyOutput.print("Invalid input, please enter y or n", OutputType.WARNING)
194
-
195
- if user_input == 'y':
196
- try:
197
- # 让模型判断是否需要生成方法论
198
- analysis_prompt = """The current task has ended, please analyze whether a methodology needs to be generated.
199
- If you think a methodology should be generated, first determine whether to create a new methodology or update an existing one. If updating an existing methodology, use 'update', otherwise use 'add'.
200
- If you think a methodology is not needed, please explain why.
201
- The methodology should be applicable to general scenarios, do not include task-specific information such as code commit messages.
202
- The methodology should include: problem restatement, optimal solution, notes (as needed), and nothing else.
203
- Only output the methodology tool call instruction, or the explanation for not generating a methodology. Do not output anything else.
204
- """
205
- self.prompt = analysis_prompt
206
- response = self._call_model(self.prompt)
207
-
208
- # 检查是否包含工具调用
213
+ if not self.is_sub_agent:
214
+ if self.record_methodology:
215
+
209
216
  try:
210
- tool_calls = Agent.extract_tool_calls(response)
211
- if tool_calls:
212
- self.tool_registry.handle_tool_calls(tool_calls)
217
+ # 让模型判断是否需要生成方法论
218
+ analysis_prompt = """The current task has ended, please analyze whether a methodology needs to be generated.
219
+ If you think a methodology should be generated, first determine whether to create a new methodology or update an existing one. If updating an existing methodology, use 'update', otherwise use 'add'.
220
+ If you think a methodology is not needed, please explain why.
221
+ The methodology should be applicable to general scenarios, do not include task-specific information such as code commit messages.
222
+ The methodology should include: problem restatement, optimal solution, notes (as needed), and nothing else.
223
+ Only output the methodology tool call instruction, or the explanation for not generating a methodology. Do not output anything else.
224
+ """
225
+ self.prompt = analysis_prompt
226
+ response = self._call_model(self.prompt)
227
+
228
+ # 检查是否包含工具调用
229
+ try:
230
+ tool_calls = Agent.extract_tool_calls(response)
231
+ if tool_calls:
232
+ self.tool_registry.handle_tool_calls(tool_calls)
233
+ except Exception as e:
234
+ PrettyOutput.print(f"Failed to handle methodology generation: {str(e)}", OutputType.ERROR)
235
+
213
236
  except Exception as e:
214
- PrettyOutput.print(f"Failed to handle methodology generation: {str(e)}", OutputType.ERROR)
215
-
216
- except Exception as e:
217
- PrettyOutput.print(f"Error generating methodology: {str(e)}", OutputType.ERROR)
218
-
219
- if not self.is_sub_agent:
237
+ PrettyOutput.print(f"Error generating methodology: {str(e)}", OutputType.ERROR)
238
+
220
239
  return "Task completed"
221
240
 
222
- # 生成任务总结
223
- summary_prompt = f"""Please generate a concise summary report of the task execution, including:
224
-
225
- 1. Task Objective: Task restatement
226
- 2. Execution Result: Success/Failure
227
- 3. Key Information: Important information extracted during execution
228
- 4. Important Findings: Any noteworthy discoveries
229
- 5. Follow-up Suggestions: If any
230
-
231
- Please describe in concise bullet points, highlighting important information.
232
- """
233
- self.prompt = summary_prompt
234
- return self._call_model(self.prompt)
241
+ if self.need_summary:
242
+ self.prompt = self.summary_prompt
243
+ return self._call_model(self.prompt)
244
+
245
+ return "Task completed"
235
246
 
236
247
 
237
248
  def run(self, user_input: str, file_list: Optional[List[str]] = None) -> str:
@@ -244,28 +255,22 @@ Please describe in concise bullet points, highlighting important information.
244
255
  Returns:
245
256
  str: Task summary report
246
257
  """
258
+
259
+
260
+
247
261
  try:
248
262
  PrettyOutput.section("Preparing environment", OutputType.PLANNING)
249
263
  if file_list:
250
264
  self.model.upload_files(file_list)
251
265
 
252
- # Load methodology
253
- methodology_prompt = load_methodology(user_input)
254
- tools_prompt = load_tools()
255
-
256
266
  # 显示任务开始
257
267
  PrettyOutput.section(f"Starting new task: {self.name}", OutputType.PLANNING)
258
268
 
259
- self.clear_history()
260
-
261
- self.model.set_system_message(f"""
262
- {self.system_prompt}
263
-
264
- {tools_prompt}
265
-
266
- {methodology_prompt}
267
- """)
268
- self.prompt = f"{user_input}"
269
+ if self.first:
270
+ self.prompt = f"{user_input}\n\n{load_methodology(user_input)}"
271
+ self.first = False
272
+ else:
273
+ self.prompt = f"{user_input}"
269
274
 
270
275
  while True:
271
276
  try:
@@ -281,25 +286,32 @@ Please describe in concise bullet points, highlighting important information.
281
286
  continue
282
287
  else:
283
288
  current_response = self._call_model(self.prompt)
284
- self.conversation_length += len(current_response) # Add response length
289
+ self.prompt = ""
290
+ self.conversation_length += len(current_response)
291
+
292
+ for filter in self.output_filter:
293
+ self.prompt += filter(current_response)
294
+
285
295
  try:
286
296
  result = Agent.extract_tool_calls(current_response)
287
297
  except Exception as e:
288
298
  PrettyOutput.print(f"Tool call error: {str(e)}", OutputType.ERROR)
289
- self.prompt = f"Tool call error: {str(e)}"
299
+ self.prompt += f"Tool call error: {str(e)}"
290
300
  continue
291
301
 
292
302
  if len(result) > 0:
293
303
  PrettyOutput.print("Executing tool call...", OutputType.PROGRESS)
294
304
  tool_result = self.tool_registry.handle_tool_calls(result)
295
- self.prompt = tool_result
305
+ self.prompt += tool_result
306
+
307
+ if self.prompt:
296
308
  continue
309
+
310
+ if self.auto_complete and "<!!!COMPLETE!!!>" in current_response:
311
+ return self._complete_task()
297
312
 
298
313
  # 获取用户输入
299
314
  user_input = get_multiline_input(f"{self.name}: You can continue to input, or enter an empty line to end the current task")
300
- if user_input == "__interrupt__":
301
- PrettyOutput.print("Task cancelled by user", OutputType.WARNING)
302
- return "Task cancelled by user"
303
315
 
304
316
  if user_input:
305
317
  self.prompt = user_input
@@ -382,10 +394,11 @@ def select_task(tasks: dict) -> str:
382
394
  # Convert tasks to list for ordered display
383
395
  task_names = list(tasks.keys())
384
396
 
385
- PrettyOutput.print("\nAvailable tasks:", OutputType.INFO)
397
+ task_list = ["Available tasks:"]
386
398
  for i, name in enumerate(task_names, 1):
387
- PrettyOutput.print(f"[{i}] {name}", OutputType.INFO)
388
- PrettyOutput.print("[0] Skip predefined tasks", OutputType.INFO)
399
+ task_list.append(f"[{i}] {name}")
400
+ task_list.append("[0] Skip predefined tasks")
401
+ PrettyOutput.print("\n".join(task_list), OutputType.INFO)
389
402
 
390
403
 
391
404
  while True:
@@ -426,26 +439,13 @@ When users need to execute tasks, you will strictly follow these steps to handle
426
439
  7. Execute Action Plan: Execute one step at a time, **use at most one tool** (wait for tool execution results before proceeding)
427
440
  8. Monitor and Adjust: If execution results don't match expectations, reflect and adjust the action plan, iterate previous steps
428
441
  9. Methodology: If the current task has general applicability and valuable experience is gained, use methodology tools to record it for future similar problems
429
- 10. Task Completion: End the task using task completion command when finished
442
+ 10. Auto check the task goal completion status: If the task goal is completed, use the task completion command to end the task
443
+ 11. Task Completion: End the task using task completion command when finished
430
444
 
431
445
  Methodology Template:
432
446
  1. Problem Restatement
433
447
  2. Optimal Solution
434
448
  3. Optimal Solution Steps (exclude failed actions)
435
-
436
- Strict Rules:
437
- - Execute only one tool at a time
438
- - Tool execution must strictly follow the tool usage format
439
- - Wait for user to provide execution results
440
- - Don't assume or imagine results
441
- - Don't create fake dialogues
442
- - If current information is insufficient, you may ask the user
443
- - Not all problem-solving steps are mandatory, skip as appropriate
444
- - Ask user before executing tools that might damage system or user's codebase
445
- - Request user guidance when multiple iterations show no progress
446
- - If yaml string contains colons, wrap the entire string in quotes to avoid yaml parsing errors
447
- - Use | syntax for multi-line strings in yaml
448
- - If you can start executing the task, please start directly without asking the user if you can begin.
449
449
 
450
450
  -------------------------------------------------------------"""
451
451
 
@@ -459,7 +459,7 @@ def main():
459
459
 
460
460
  try:
461
461
  # 获取全局模型实例
462
- agent = Agent(system_prompt=origin_agent_system_prompt)
462
+ agent = Agent(system_prompt=origin_agent_system_prompt, tool_registry=ToolRegistry())
463
463
 
464
464
  # 加载预定义任务
465
465
  tasks = load_tasks()
@@ -474,7 +474,7 @@ def main():
474
474
  while True:
475
475
  try:
476
476
  user_input = get_multiline_input("Please enter your task (input empty line to exit):")
477
- if not user_input or user_input == "__interrupt__":
477
+ if not user_input:
478
478
  break
479
479
  agent.run(user_input, args.files)
480
480
  except Exception as e: