jarvis-ai-assistant 0.1.101__py3-none-any.whl → 0.1.103__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 (54) hide show
  1. jarvis/__init__.py +1 -1
  2. jarvis/agent.py +140 -140
  3. jarvis/jarvis_code_agent/code_agent.py +234 -0
  4. jarvis/{jarvis_coder → jarvis_code_agent}/file_select.py +16 -17
  5. jarvis/jarvis_code_agent/patch.py +118 -0
  6. jarvis/jarvis_code_agent/relevant_files.py +66 -0
  7. jarvis/jarvis_codebase/main.py +32 -29
  8. jarvis/jarvis_platform/main.py +5 -3
  9. jarvis/jarvis_rag/main.py +11 -15
  10. jarvis/jarvis_smart_shell/main.py +2 -2
  11. jarvis/models/ai8.py +1 -0
  12. jarvis/models/kimi.py +36 -30
  13. jarvis/models/ollama.py +17 -11
  14. jarvis/models/openai.py +15 -12
  15. jarvis/models/oyi.py +22 -7
  16. jarvis/models/registry.py +1 -25
  17. jarvis/tools/__init__.py +0 -6
  18. jarvis/tools/ask_codebase.py +99 -0
  19. jarvis/tools/ask_user.py +1 -9
  20. jarvis/tools/chdir.py +1 -1
  21. jarvis/tools/code_review.py +163 -0
  22. jarvis/tools/create_code_sub_agent.py +19 -45
  23. jarvis/tools/create_code_test_agent.py +115 -0
  24. jarvis/tools/create_ctags_agent.py +176 -0
  25. jarvis/tools/create_sub_agent.py +2 -2
  26. jarvis/tools/execute_shell.py +2 -2
  27. jarvis/tools/file_operation.py +2 -2
  28. jarvis/tools/find_in_codebase.py +108 -0
  29. jarvis/tools/git_commiter.py +68 -0
  30. jarvis/tools/methodology.py +3 -3
  31. jarvis/tools/rag.py +6 -3
  32. jarvis/tools/read_code.py +147 -0
  33. jarvis/tools/read_webpage.py +1 -1
  34. jarvis/tools/registry.py +92 -68
  35. jarvis/tools/search.py +8 -6
  36. jarvis/tools/select_code_files.py +4 -4
  37. jarvis/utils.py +270 -95
  38. {jarvis_ai_assistant-0.1.101.dist-info → jarvis_ai_assistant-0.1.103.dist-info}/METADATA +9 -5
  39. jarvis_ai_assistant-0.1.103.dist-info/RECORD +51 -0
  40. {jarvis_ai_assistant-0.1.101.dist-info → jarvis_ai_assistant-0.1.103.dist-info}/entry_points.txt +4 -2
  41. jarvis/jarvis_code_agent/main.py +0 -202
  42. jarvis/jarvis_coder/__init__.py +0 -0
  43. jarvis/jarvis_coder/git_utils.py +0 -123
  44. jarvis/jarvis_coder/main.py +0 -241
  45. jarvis/jarvis_coder/patch_handler.py +0 -340
  46. jarvis/jarvis_coder/plan_generator.py +0 -145
  47. jarvis/tools/execute_code_modification.py +0 -70
  48. jarvis/tools/find_files.py +0 -119
  49. jarvis/tools/generate_tool.py +0 -174
  50. jarvis/tools/thinker.py +0 -151
  51. jarvis_ai_assistant-0.1.101.dist-info/RECORD +0 -51
  52. {jarvis_ai_assistant-0.1.101.dist-info → jarvis_ai_assistant-0.1.103.dist-info}/LICENSE +0 -0
  53. {jarvis_ai_assistant-0.1.101.dist-info → jarvis_ai_assistant-0.1.103.dist-info}/WHEEL +0 -0
  54. {jarvis_ai_assistant-0.1.101.dist-info → jarvis_ai_assistant-0.1.103.dist-info}/top_level.txt +0 -0
@@ -1,174 +0,0 @@
1
- import os
2
- from typing import Dict, Any
3
- from pathlib import Path
4
- from jarvis.models.registry import PlatformRegistry
5
- from jarvis.tools.registry import ToolRegistry
6
- from jarvis.utils import OutputType, PrettyOutput
7
-
8
- class ToolGeneratorTool:
9
- name = "generate_tool"
10
- description = "Generate new tool code and automatically register it to Jarvis, automatically expanding Jarvis's capabilities"
11
- parameters = {
12
- "type": "object",
13
- "properties": {
14
- "tool_name": {
15
- "type": "string",
16
- "description": "Name of the tool (in snake_case format)"
17
- },
18
- "class_name": {
19
- "type": "string",
20
- "description": "Name of the tool class (in PascalCase format)"
21
- },
22
- "description": {
23
- "type": "string",
24
- "description": "Description of the tool's functionality"
25
- },
26
- "parameters": {
27
- "type": "object",
28
- "description": "JSON Schema definition of tool parameters"
29
- }
30
- },
31
- "required": ["tool_name", "class_name", "description", "parameters"]
32
- }
33
-
34
- def __init__(self):
35
- """Initialize tool generator"""
36
- # Set tool directory
37
- self.tools_dir = Path.home() / '.jarvis/tools'
38
-
39
- # Ensure tool directory exists
40
- self.tools_dir.mkdir(parents=True, exist_ok=True)
41
-
42
- def _generate_tool_code(self, tool_name: str, class_name: str, description: str, parameters: Dict) -> str:
43
- """Use large model to generate tool code"""
44
- model = PlatformRegistry.get_global_platform_registry().get_codegen_platform()
45
-
46
- prompt = f"""Please generate the code for a Python tool class, with the following requirements, and do not output any content except the code:
47
-
48
- 1. Class name: {class_name}
49
- 2. Tool name: {tool_name}
50
- 3. Function description: {description}
51
- 4. Parameter definition: {parameters}
52
-
53
- Strictly follow the following format to generate code (the parameters and return values of each function must be consistent with the example):
54
-
55
- ```python
56
- from typing import Dict, Any, Protocol, Optional
57
- from jarvis.utils import OutputType, PrettyOutput
58
- from jarvis.models.registry import ModelRegistry
59
-
60
- class ExampleTool:
61
- name = "example_tool"
62
- description = "Example tool"
63
- parameters = {{
64
- "type": "object",
65
- "properties": {{
66
- "param1": {{"type": "string"}}
67
- }},
68
- "required": ["param1"]
69
- }}
70
-
71
- def __init__(self):
72
- self.model = ModelRegistry.get_global_platform_registry().get_normal_platform()
73
-
74
- def execute(self, args: Dict) -> Dict[str, Any]:
75
- try:
76
- # Validate parameter example
77
- if "param1" not in args:
78
- return {{"success": False, "error": "Missing required parameter: param1"}}
79
-
80
- # Record operation example
81
- PrettyOutput.print(f"Processing parameter: {{args['param1']}}", OutputType.INFO)
82
-
83
- # Use large model example
84
- response = self.model.chat_until_success("prompt")
85
-
86
- # Implement specific functionality
87
- result = "Processing result"
88
-
89
- return {{
90
- "success": True,
91
- "stdout": result,
92
- "stderr": ""
93
- }}
94
- except Exception as e:
95
- PrettyOutput.print(str(e), OutputType.ERROR)
96
- return {{
97
- "success": False,
98
- "stdout": "",
99
- "stderr": str(e)
100
- }}
101
- ```"""
102
-
103
- # Call model to generate code
104
- response = model.chat_until_success(prompt)
105
-
106
- # Extract code block
107
- code_start = response.find("```python")
108
- code_end = response.find("```", code_start + 9)
109
-
110
- if code_start == -1 or code_end == -1:
111
- # If code block marker not found, assume the entire response is code
112
- return response
113
-
114
- # Extract code block content (remove ```python and ``` markers)
115
- code = response[code_start + 9:code_end].strip()
116
- return code
117
-
118
- def execute(self, args: Dict) -> Dict[str, Any]:
119
- """Generate tool code"""
120
- try:
121
- tool_name = args["tool_name"]
122
- class_name = args["class_name"]
123
- description = args["description"]
124
- parameters = args["parameters"]
125
-
126
- PrettyOutput.print(f"Start generating tool: {tool_name}", OutputType.INFO)
127
-
128
- # Generate tool code
129
- tool_code = self._generate_tool_code(
130
- tool_name,
131
- class_name,
132
- description,
133
- parameters
134
- )
135
-
136
- # Get tool file path
137
- tool_file = self.tools_dir / f"{tool_name}.py"
138
-
139
- # Write tool file
140
- with open(tool_file, "w", encoding="utf-8") as f:
141
- f.write(tool_code)
142
-
143
- # Create or update __init__.py
144
- init_file = self.tools_dir / "__init__.py"
145
- if not init_file.exists():
146
- with open(init_file, "w", encoding="utf-8") as f:
147
- f.write("# Jarvis Tools\n")
148
-
149
- # Register tool
150
- success = ToolRegistry.get_global_tool_registry().register_tool_by_file(str(tool_file))
151
- if not success:
152
- return {
153
- "success": False,
154
- "stdout": "",
155
- "stderr": "Tool generated successfully but registration failed"
156
- }
157
-
158
- return {
159
- "success": True,
160
- "stdout": f"Tool generated and registered to Jarvis\n"
161
- f"Tool directory: {self.tools_dir}\n"
162
- f"Tool name: {tool_name}\n"
163
- f"Tool description: {description}\n"
164
- f"Tool parameters: {parameters}",
165
- "stderr": ""
166
- }
167
-
168
- except Exception as e:
169
- PrettyOutput.print(str(e), OutputType.ERROR)
170
- return {
171
- "success": False,
172
- "stdout": "",
173
- "stderr": f"Failed to generate tool: {str(e)}"
174
- }
jarvis/tools/thinker.py DELETED
@@ -1,151 +0,0 @@
1
- from typing import Dict, Any
2
- from jarvis.utils import OutputType, PrettyOutput, init_env
3
- from jarvis.models.registry import PlatformRegistry
4
-
5
- class ThinkerTool:
6
- name = "thinker"
7
- description = "Use chain of thought reasoning to analyze complex problems, suitable for scenarios that require multi-step reasoning, logical analysis, or creative thinking"
8
- parameters = {
9
- "type": "object",
10
- "properties": {
11
- "question": {
12
- "type": "string",
13
- "description": "The problem or task to analyze"
14
- },
15
- "context": {
16
- "type": "string",
17
- "description": "Context information or background knowledge related to the problem",
18
- "default": ""
19
- },
20
- "goal": {
21
- "type": "string",
22
- "description": "The specific goal or result to achieve",
23
- "default": ""
24
- }
25
- },
26
- "required": ["question"]
27
- }
28
-
29
- def __init__(self):
30
- """Initialize thinker tool"""
31
- self.model = PlatformRegistry.get_global_platform_registry().get_thinking_platform()
32
-
33
- def _generate_prompt(self, question: str, context: str, goal: str) -> str:
34
- """Generate prompt
35
-
36
- Args:
37
- question: problem
38
- context: context
39
- goal: goal
40
-
41
- Returns:
42
- str: complete prompt
43
- """
44
- # 基础提示词
45
- prompt = f"""You are a helpful assistant that is good at deep thinking and logical reasoning. Please help analyze the problem and provide a solution.
46
-
47
- Please think as follows:
48
- 1. Carefully understand the problem and goal
49
- 2. Conduct a systematic analysis and reasoning
50
- 3. Consider multiple possible solutions
51
- 4. Provide the best suggestions and specific action steps
52
-
53
- Problem:
54
- {question}
55
- """
56
- # 如果有目标,添加到提示词中
57
- if goal:
58
- prompt += f"""
59
- Goal:
60
- {goal}
61
- """
62
-
63
- # 如果有上下文,添加到提示词中
64
- if context:
65
- prompt += f"""
66
- Related context:
67
- {context}
68
- """
69
-
70
- prompt += "\nPlease start analyzing:"
71
- return prompt
72
-
73
- def execute(self, args: Dict[str, Any]) -> Dict[str, Any]:
74
- """Execute thinking analysis
75
-
76
- Args:
77
- args: dictionary containing parameters
78
- - question: problem
79
- - context: context (optional)
80
- - goal: goal (optional)
81
-
82
- Returns:
83
- Dict[str, Any]: execution result
84
- """
85
- try:
86
- # Get parameters
87
- question = args["question"]
88
- context = args.get("context", "")
89
- goal = args.get("goal", "")
90
-
91
- # 生成提示词
92
- prompt = self._generate_prompt(question, context, goal)
93
-
94
- # Record start analysis
95
- PrettyOutput.print(f"Start analyzing problem: {question}", OutputType.INFO)
96
- if context:
97
- PrettyOutput.print("Contains context information", OutputType.INFO)
98
- if goal:
99
- PrettyOutput.print(f"Goal: {goal}", OutputType.INFO)
100
-
101
- # 调用模型进行分析
102
- response = self.model.chat_until_success(prompt)
103
-
104
- if not response:
105
- return {
106
- "success": False,
107
- "stdout": "",
108
- "stderr": "Failed to obtain valid analysis results"
109
- }
110
-
111
- return {
112
- "success": True,
113
- "stdout": response,
114
- "stderr": ""
115
- }
116
-
117
- except Exception as e:
118
- PrettyOutput.print(f"Thinking analysis failed: {str(e)}", OutputType.ERROR)
119
- return {
120
- "success": False,
121
- "stdout": "",
122
- "stderr": f"Execution failed: {str(e)}"
123
- }
124
-
125
- def main():
126
- """Run tool directly from command line"""
127
- import argparse
128
-
129
- init_env()
130
-
131
- parser = argparse.ArgumentParser(description='Deep thinking analysis tool')
132
- parser.add_argument('--question', required=True, help='The problem to analyze')
133
- parser.add_argument('--context', help='Context information related to the problem')
134
- parser.add_argument('--goal', help='Specific goal or result to achieve')
135
- args = parser.parse_args()
136
-
137
- tool = ThinkerTool()
138
- result = tool.execute({
139
- "question": args.question,
140
- "context": args.context,
141
- "goal": args.goal
142
- })
143
-
144
- if result["success"]:
145
- PrettyOutput.print("\nAnalysis results:", OutputType.INFO)
146
- PrettyOutput.print(result["stdout"], OutputType.INFO)
147
- else:
148
- PrettyOutput.print(result["stderr"], OutputType.ERROR)
149
-
150
- if __name__ == "__main__":
151
- main()
@@ -1,51 +0,0 @@
1
- jarvis/__init__.py,sha256=SEfhqUn2n4olRpFxLrz0OhFdsYO4-ww5CB_ZQwsLDyE,51
2
- jarvis/agent.py,sha256=dneYp0w25eeJpodcm59-r8V6fu7G_4MtCntvGNCLgBI,20868
3
- jarvis/utils.py,sha256=feUUqe8nA7MobPwVKH9ogMZrD1kH87-zeZxHvxWf83s,15807
4
- jarvis/jarvis_code_agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- jarvis/jarvis_code_agent/main.py,sha256=wZkYy_VmTg1iJBmQ6fD39hv2eC8FE6CVgtx7lxIUYHo,7050
6
- jarvis/jarvis_codebase/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- jarvis/jarvis_codebase/main.py,sha256=rnA4rSyRmtVsKQ5HkQnNc57sZnT5sCBcmQFLWdzYJv8,36854
8
- jarvis/jarvis_coder/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- jarvis/jarvis_coder/file_select.py,sha256=BobNj5Kirr6jSwy59LOghC3o8Uff1CwTXNtlTO-idEo,8475
10
- jarvis/jarvis_coder/git_utils.py,sha256=R83iDYkDHIntQCd6p9g8Nne9oR5TVNhM-frd_2qR8Jo,5021
11
- jarvis/jarvis_coder/main.py,sha256=jicy9IN_94Dp8hDubOJX8t5h3vAmciAiS3v34WrvJZc,8469
12
- jarvis/jarvis_coder/patch_handler.py,sha256=NTNlVZ85uvVmtNNdwnQDPuCUYqEJJFL95ryZZauD2Dg,14876
13
- jarvis/jarvis_coder/plan_generator.py,sha256=x-FalwoRg79h-fvDgFQ8Cl-I8zJ7x2qcXsEUnRip9GA,6186
14
- jarvis/jarvis_platform/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- jarvis/jarvis_platform/main.py,sha256=h08SaaIRBhqX8yIp_mG9vSKZYVBrBVfcC9gDK4A45RQ,4961
16
- jarvis/jarvis_rag/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
- jarvis/jarvis_rag/main.py,sha256=tp9skDCrassVTHRlbWJmA880CoF8OZTSFCiknoHRirU,33605
18
- jarvis/jarvis_smart_shell/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
- jarvis/jarvis_smart_shell/main.py,sha256=G03M39Bfwq8ieNZ8zoDbn0QeDs8Z9h2A0TxP8Hqf9GY,3951
20
- jarvis/models/__init__.py,sha256=mrOt67nselz_H1gX9wdAO4y2DY5WPXzABqJbr5Des8k,63
21
- jarvis/models/ai8.py,sha256=ZRNO3aRjmICRjCXl-_F9pTNQTY4j1tUd-WJoJpb9n4Y,11958
22
- jarvis/models/base.py,sha256=nQ-rsJL1Z-gMev3TPoY7tYdwxhCJY8LG6_gtJ-maiW0,2181
23
- jarvis/models/kimi.py,sha256=JSjSp_Hmmj_3bn0jxArE4lpG8jkQwhWx8qosjRMHdZE,16391
24
- jarvis/models/ollama.py,sha256=LzEA4kbkw1KflQ1T__hkmXu4--6xUPho2NTnj_ZQe6k,5761
25
- jarvis/models/openai.py,sha256=7AYKM0CKlI-tU5NtNdVaw5gobhgqSrXwGQLo5b2MJ7c,4404
26
- jarvis/models/oyi.py,sha256=iA8E5vzN9VIt-rlzpT5wmbyl7umVU1_y5yo_5gz3DXc,14534
27
- jarvis/models/registry.py,sha256=SM-jPu9TMommz0Fr_WrXpQE4X24QGyH39h0FwEQ-CWU,9448
28
- jarvis/tools/__init__.py,sha256=7Rqyj5hBAv5cWDVr5T9ZTZASO7ssBHeQNm2_4ZARdkA,72
29
- jarvis/tools/ask_user.py,sha256=cSxFn8cOZGQYHtfBtXlbdVQ7mlgC1JZCFBylparWShE,2102
30
- jarvis/tools/base.py,sha256=c0DMoDDPxmsqUYJR989zgUs7nIYRY6GWBrAdusIZKjc,656
31
- jarvis/tools/chdir.py,sha256=Nr16rLnrQ_eJH5E5HQ1a9o-UqAckKbWeboB3_SBVdVI,2926
32
- jarvis/tools/create_code_sub_agent.py,sha256=r5Ec3Ri9TGAj1M4c0Ur10I33aZ1i8dbtGK2DqqeebkQ,1718
33
- jarvis/tools/create_sub_agent.py,sha256=Nf_37sj8uQp1R1f7G1PkMRzwUFrHXj17WYLbusoDzO0,2807
34
- jarvis/tools/execute_code_modification.py,sha256=_LpzTiUfK7aprKzCrTDhBuu78miDcVyx7VV1Kh682DA,2508
35
- jarvis/tools/execute_shell.py,sha256=woJq-fivoXppp8rEhg46WVAImf6O89gHJnA7XOuYSM8,2568
36
- jarvis/tools/file_operation.py,sha256=Aq1EJA59AHR9XomxuxNiyLNon4p8w-Gk9iionl--odU,4082
37
- jarvis/tools/find_files.py,sha256=MTqijsXO6uFghb79pGaHWsa1NTgjP07p333BvUgMt5s,3696
38
- jarvis/tools/generate_tool.py,sha256=qhk73UFEPtMC-QfiWBUxnMhkgZMZM-esd0TdcFhWSmc,6181
39
- jarvis/tools/methodology.py,sha256=f6rF6vw-qaSIuJUrLbZdsLqzXMmAaw1aCwvJuezRX8k,5586
40
- jarvis/tools/rag.py,sha256=m_G4ct6SBLKKdUXfPkokK-qVlWeFCJ2B9J5IZhHXBXQ,4879
41
- jarvis/tools/read_webpage.py,sha256=AqE9Og_OzwFYIHZDTnCe_gB-szcUXbVZh-xZat4WgOU,2467
42
- jarvis/tools/registry.py,sha256=O-vzSaWr9VR3lrCIPF5NPl4V-zHHmz3H3l1_9ORyKsA,11057
43
- jarvis/tools/search.py,sha256=qf39Zm2Ad9-z4EyZKJrBCvZg1uqMeLuLQ9Zu8WB-TvI,9230
44
- jarvis/tools/select_code_files.py,sha256=hJwfh_CnyOn4QOBuNpKh9AD7-iH92mj7FP-6EifSH0w,1875
45
- jarvis/tools/thinker.py,sha256=-aWbjOjV3tGmYeIgAmyKVjd0teFs4ZK7mzPBA09R7hE,4847
46
- jarvis_ai_assistant-0.1.101.dist-info/LICENSE,sha256=AGgVgQmTqFvaztRtCAXsAMryUymB18gZif7_l2e1XOg,1063
47
- jarvis_ai_assistant-0.1.101.dist-info/METADATA,sha256=5szifjS1Gp4_XFLTOu5e8mATozRwUaNZM-9PokGDnAM,12783
48
- jarvis_ai_assistant-0.1.101.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
49
- jarvis_ai_assistant-0.1.101.dist-info/entry_points.txt,sha256=x0jA_mYRc7hBVdLuOFQBYQjpXjf8NPrAn0C54DJ9t2I,387
50
- jarvis_ai_assistant-0.1.101.dist-info/top_level.txt,sha256=1BOxyWfzOP_ZXj8rVTDnNCJ92bBGB0rwq8N1PCpoMIs,7
51
- jarvis_ai_assistant-0.1.101.dist-info/RECORD,,