jarvis-ai-assistant 0.1.99__tar.gz → 0.1.101__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.
- {jarvis_ai_assistant-0.1.99/src/jarvis_ai_assistant.egg-info → jarvis_ai_assistant-0.1.101}/PKG-INFO +9 -8
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/README.md +8 -7
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/pyproject.toml +1 -1
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/setup.py +1 -1
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/__init__.py +1 -1
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/agent.py +12 -12
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/jarvis_code_agent/main.py +26 -27
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/jarvis_codebase/main.py +3 -3
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/jarvis_coder/git_utils.py +4 -4
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/jarvis_coder/main.py +2 -8
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/jarvis_coder/patch_handler.py +153 -75
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/jarvis_platform/main.py +2 -2
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/jarvis_rag/main.py +2 -2
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/jarvis_smart_shell/main.py +6 -4
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/models/kimi.py +2 -2
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/models/openai.py +1 -1
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/models/registry.py +35 -12
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/tools/ask_user.py +6 -3
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/tools/chdir.py +9 -5
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/tools/create_code_sub_agent.py +2 -1
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/tools/create_sub_agent.py +2 -1
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/tools/execute_code_modification.py +4 -6
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/tools/execute_shell.py +2 -2
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/tools/file_operation.py +10 -5
- jarvis_ai_assistant-0.1.101/src/jarvis/tools/find_files.py +119 -0
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/tools/generate_tool.py +27 -25
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/tools/methodology.py +13 -7
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/tools/rag.py +9 -5
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/tools/read_webpage.py +4 -2
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/tools/registry.py +25 -15
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/tools/search.py +18 -15
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/tools/select_code_files.py +2 -5
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/tools/thinker.py +7 -5
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/utils.py +53 -34
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101/src/jarvis_ai_assistant.egg-info}/PKG-INFO +9 -8
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis_ai_assistant.egg-info/SOURCES.txt +1 -2
- jarvis_ai_assistant-0.1.99/src/jarvis/tools/codebase_qa.py +0 -72
- jarvis_ai_assistant-0.1.99/src/jarvis/tools/find_related_files.py +0 -86
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/MANIFEST.in +0 -0
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/setup.cfg +0 -0
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/jarvis_code_agent/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/jarvis_codebase/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/jarvis_coder/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/jarvis_coder/file_select.py +0 -0
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/jarvis_coder/plan_generator.py +0 -0
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/jarvis_platform/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/jarvis_rag/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/jarvis_smart_shell/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/models/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/models/ai8.py +0 -0
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/models/base.py +0 -0
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/models/ollama.py +0 -0
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/models/oyi.py +0 -0
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/tools/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/tools/base.py +0 -0
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis_ai_assistant.egg-info/dependency_links.txt +0 -0
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis_ai_assistant.egg-info/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis_ai_assistant.egg-info/requires.txt +0 -0
- {jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis_ai_assistant.egg-info/top_level.txt +0 -0
{jarvis_ai_assistant-0.1.99/src/jarvis_ai_assistant.egg-info → jarvis_ai_assistant-0.1.101}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: jarvis-ai-assistant
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.101
|
|
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
|
|
@@ -125,7 +125,7 @@ pip install jarvis-ai-assistant
|
|
|
125
125
|
|
|
126
126
|
## 🔧 Configuration
|
|
127
127
|
|
|
128
|
-
Jarvis supports configuration through environment variables that can be set in the `~/.
|
|
128
|
+
Jarvis supports configuration through environment variables that can be set in the `~/.jarvis/env` file:
|
|
129
129
|
|
|
130
130
|
| Environment Variable | Description | Default Value | Required |
|
|
131
131
|
|---------|------|--------|------|
|
|
@@ -204,7 +204,7 @@ jarvis-search "your query" --max 3
|
|
|
204
204
|
|
|
205
205
|
### Tool Locations
|
|
206
206
|
- Built-in tools: `src/jarvis/tools/`
|
|
207
|
-
- User tools: `~/.
|
|
207
|
+
- User tools: `~/.jarvis/tools/`
|
|
208
208
|
|
|
209
209
|
|
|
210
210
|
### Key Features
|
|
@@ -241,7 +241,7 @@ jarvis-search "your query" --max 3
|
|
|
241
241
|
|
|
242
242
|
### Adding New Tools
|
|
243
243
|
|
|
244
|
-
Create a new Python file in `~/.
|
|
244
|
+
Create a new Python file in `~/.jarvis/tools/` or `src/jarvis/tools/`:
|
|
245
245
|
|
|
246
246
|
```python
|
|
247
247
|
from typing import Dict, Any
|
|
@@ -273,7 +273,6 @@ class CustomTool:
|
|
|
273
273
|
"success": bool,
|
|
274
274
|
"stdout": str, # On success
|
|
275
275
|
"stderr": str, # Optional error details
|
|
276
|
-
"error": str # On failure
|
|
277
276
|
}
|
|
278
277
|
"""
|
|
279
278
|
try:
|
|
@@ -281,18 +280,20 @@ class CustomTool:
|
|
|
281
280
|
result = "Tool execution result"
|
|
282
281
|
return {
|
|
283
282
|
"success": True,
|
|
284
|
-
"stdout": result
|
|
283
|
+
"stdout": result,
|
|
284
|
+
"stderr": ""
|
|
285
285
|
}
|
|
286
286
|
except Exception as e:
|
|
287
287
|
return {
|
|
288
288
|
"success": False,
|
|
289
|
-
"
|
|
289
|
+
"stdout": "",
|
|
290
|
+
"stderr": str(e)
|
|
290
291
|
}
|
|
291
292
|
```
|
|
292
293
|
|
|
293
294
|
### Adding New Models
|
|
294
295
|
|
|
295
|
-
Create a new Python file in `~/.
|
|
296
|
+
Create a new Python file in `~/.jarvis/models/`:
|
|
296
297
|
|
|
297
298
|
```python
|
|
298
299
|
from typing import Dict, List
|
|
@@ -59,7 +59,7 @@ pip install jarvis-ai-assistant
|
|
|
59
59
|
|
|
60
60
|
## 🔧 Configuration
|
|
61
61
|
|
|
62
|
-
Jarvis supports configuration through environment variables that can be set in the `~/.
|
|
62
|
+
Jarvis supports configuration through environment variables that can be set in the `~/.jarvis/env` file:
|
|
63
63
|
|
|
64
64
|
| Environment Variable | Description | Default Value | Required |
|
|
65
65
|
|---------|------|--------|------|
|
|
@@ -138,7 +138,7 @@ jarvis-search "your query" --max 3
|
|
|
138
138
|
|
|
139
139
|
### Tool Locations
|
|
140
140
|
- Built-in tools: `src/jarvis/tools/`
|
|
141
|
-
- User tools: `~/.
|
|
141
|
+
- User tools: `~/.jarvis/tools/`
|
|
142
142
|
|
|
143
143
|
|
|
144
144
|
### Key Features
|
|
@@ -175,7 +175,7 @@ jarvis-search "your query" --max 3
|
|
|
175
175
|
|
|
176
176
|
### Adding New Tools
|
|
177
177
|
|
|
178
|
-
Create a new Python file in `~/.
|
|
178
|
+
Create a new Python file in `~/.jarvis/tools/` or `src/jarvis/tools/`:
|
|
179
179
|
|
|
180
180
|
```python
|
|
181
181
|
from typing import Dict, Any
|
|
@@ -207,7 +207,6 @@ class CustomTool:
|
|
|
207
207
|
"success": bool,
|
|
208
208
|
"stdout": str, # On success
|
|
209
209
|
"stderr": str, # Optional error details
|
|
210
|
-
"error": str # On failure
|
|
211
210
|
}
|
|
212
211
|
"""
|
|
213
212
|
try:
|
|
@@ -215,18 +214,20 @@ class CustomTool:
|
|
|
215
214
|
result = "Tool execution result"
|
|
216
215
|
return {
|
|
217
216
|
"success": True,
|
|
218
|
-
"stdout": result
|
|
217
|
+
"stdout": result,
|
|
218
|
+
"stderr": ""
|
|
219
219
|
}
|
|
220
220
|
except Exception as e:
|
|
221
221
|
return {
|
|
222
222
|
"success": False,
|
|
223
|
-
"
|
|
223
|
+
"stdout": "",
|
|
224
|
+
"stderr": str(e)
|
|
224
225
|
}
|
|
225
226
|
```
|
|
226
227
|
|
|
227
228
|
### Adding New Models
|
|
228
229
|
|
|
229
|
-
Create a new Python file in `~/.
|
|
230
|
+
Create a new Python file in `~/.jarvis/models/`:
|
|
230
231
|
|
|
231
232
|
```python
|
|
232
233
|
from typing import Dict, List
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "jarvis-ai-assistant"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.101"
|
|
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" }]
|
|
@@ -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.
|
|
5
|
+
version="0.1.101",
|
|
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",
|
|
@@ -8,7 +8,7 @@ import yaml
|
|
|
8
8
|
from jarvis.models.registry import PlatformRegistry
|
|
9
9
|
from jarvis.tools import ToolRegistry
|
|
10
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,
|
|
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
|
|
12
12
|
import os
|
|
13
13
|
|
|
14
14
|
class Agent:
|
|
@@ -330,8 +330,8 @@ def load_tasks() -> dict:
|
|
|
330
330
|
"""Load tasks from .jarvis files in user home and current directory."""
|
|
331
331
|
tasks = {}
|
|
332
332
|
|
|
333
|
-
# Check .jarvis in user directory
|
|
334
|
-
user_jarvis = os.path.expanduser("~/.jarvis")
|
|
333
|
+
# Check .jarvis/pre-command in user directory
|
|
334
|
+
user_jarvis = os.path.expanduser("~/.jarvis/pre-command")
|
|
335
335
|
if os.path.exists(user_jarvis):
|
|
336
336
|
try:
|
|
337
337
|
with open(user_jarvis, "r", encoding="utf-8") as f:
|
|
@@ -343,14 +343,14 @@ def load_tasks() -> dict:
|
|
|
343
343
|
if desc: # Ensure description is not empty
|
|
344
344
|
tasks[str(name)] = str(desc)
|
|
345
345
|
else:
|
|
346
|
-
PrettyOutput.print("Warning: ~/.jarvis file should contain a dictionary of task_name: task_description", OutputType.ERROR)
|
|
346
|
+
PrettyOutput.print("Warning: ~/.jarvis/pre-command file should contain a dictionary of task_name: task_description", OutputType.ERROR)
|
|
347
347
|
except Exception as e:
|
|
348
|
-
PrettyOutput.print(f"Error loading ~/.jarvis file: {str(e)}", OutputType.ERROR)
|
|
348
|
+
PrettyOutput.print(f"Error loading ~/.jarvis/pre-command file: {str(e)}", OutputType.ERROR)
|
|
349
349
|
|
|
350
|
-
# Check .jarvis in current directory
|
|
351
|
-
if os.path.exists(".jarvis"):
|
|
350
|
+
# Check .jarvis/pre-command in current directory
|
|
351
|
+
if os.path.exists(".jarvis/pre-command"):
|
|
352
352
|
try:
|
|
353
|
-
with open(".jarvis", "r", encoding="utf-8") as f:
|
|
353
|
+
with open(".jarvis/pre-command", "r", encoding="utf-8") as f:
|
|
354
354
|
local_tasks = yaml.safe_load(f)
|
|
355
355
|
|
|
356
356
|
if isinstance(local_tasks, dict):
|
|
@@ -359,12 +359,12 @@ def load_tasks() -> dict:
|
|
|
359
359
|
if desc: # Ensure description is not empty
|
|
360
360
|
tasks[str(name)] = str(desc)
|
|
361
361
|
else:
|
|
362
|
-
PrettyOutput.print("Warning: .jarvis file should contain a dictionary of task_name: task_description", OutputType.ERROR)
|
|
362
|
+
PrettyOutput.print("Warning: .jarvis/pre-command file should contain a dictionary of task_name: task_description", OutputType.ERROR)
|
|
363
363
|
except Exception as e:
|
|
364
|
-
PrettyOutput.print(f"Error loading .jarvis file: {str(e)}", OutputType.ERROR)
|
|
364
|
+
PrettyOutput.print(f"Error loading .jarvis/pre-command file: {str(e)}", OutputType.ERROR)
|
|
365
365
|
|
|
366
366
|
# Read methodology
|
|
367
|
-
method_path = os.path.expanduser("~/.
|
|
367
|
+
method_path = os.path.expanduser("~/.jarvis/methodology")
|
|
368
368
|
if os.path.exists(method_path):
|
|
369
369
|
with open(method_path, "r", encoding="utf-8") as f:
|
|
370
370
|
methodology = yaml.safe_load(f)
|
|
@@ -452,7 +452,7 @@ Strict Rules:
|
|
|
452
452
|
def main():
|
|
453
453
|
"""Jarvis main entry point"""
|
|
454
454
|
# Add argument parser
|
|
455
|
-
|
|
455
|
+
init_env()
|
|
456
456
|
parser = argparse.ArgumentParser(description='Jarvis AI assistant')
|
|
457
457
|
parser.add_argument('-f', '--files', nargs='*', help='List of files to process')
|
|
458
458
|
args = parser.parse_args()
|
{jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/jarvis_code_agent/main.py
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from jarvis.agent import Agent
|
|
2
|
-
from jarvis.
|
|
2
|
+
from jarvis.tools.registry import ToolRegistry
|
|
3
|
+
from jarvis.utils import OutputType, PrettyOutput, get_multiline_input, init_env
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
|
|
@@ -9,6 +10,10 @@ system_prompt = """You are Jarvis Code Agent, an AI code development assistant s
|
|
|
9
10
|
DEVELOPMENT WORKFLOW:
|
|
10
11
|
1. Task Analysis
|
|
11
12
|
- Understand the requirements thoroughly
|
|
13
|
+
- IMPORTANT: Before suggesting any changes:
|
|
14
|
+
* Thoroughly examine existing code implementation
|
|
15
|
+
* Never assume code structure or implementation details
|
|
16
|
+
* Always verify current code behavior and patterns
|
|
12
17
|
- Break down complex tasks into subtasks
|
|
13
18
|
- IMPORTANT: Each subtask should:
|
|
14
19
|
* Modify only ONE file
|
|
@@ -18,7 +23,8 @@ DEVELOPMENT WORKFLOW:
|
|
|
18
23
|
|
|
19
24
|
2. Code Discovery & Analysis
|
|
20
25
|
- Initial code search:
|
|
21
|
-
*
|
|
26
|
+
* CRITICAL: Always examine actual code implementation first
|
|
27
|
+
* Use shell commands to find and understand patterns:
|
|
22
28
|
<TOOL_CALL>
|
|
23
29
|
name: execute_shell
|
|
24
30
|
arguments:
|
|
@@ -42,13 +48,6 @@ DEVELOPMENT WORKFLOW:
|
|
|
42
48
|
command: head -n 50 file.py
|
|
43
49
|
</TOOL_CALL>
|
|
44
50
|
- File selection and confirmation:
|
|
45
|
-
* Find relevant files:
|
|
46
|
-
<TOOL_CALL>
|
|
47
|
-
name: find_related_files
|
|
48
|
-
arguments:
|
|
49
|
-
query: Need to modify user authentication
|
|
50
|
-
top_k: 5
|
|
51
|
-
</TOOL_CALL>
|
|
52
51
|
* Let user confirm selection:
|
|
53
52
|
<TOOL_CALL>
|
|
54
53
|
name: select_code_files
|
|
@@ -58,18 +57,14 @@ DEVELOPMENT WORKFLOW:
|
|
|
58
57
|
- user.py
|
|
59
58
|
root_dir: .
|
|
60
59
|
</TOOL_CALL>
|
|
61
|
-
- Detailed code examination:
|
|
62
|
-
* Understand code context:
|
|
63
|
-
<TOOL_CALL>
|
|
64
|
-
name: codebase_qa
|
|
65
|
-
arguments:
|
|
66
|
-
query: How does the authentication process work?
|
|
67
|
-
files:
|
|
68
|
-
- auth.py
|
|
69
|
-
</TOOL_CALL>
|
|
70
60
|
|
|
71
61
|
3. Modification Planning
|
|
72
|
-
|
|
62
|
+
- CRITICAL: Base all plans on actual code implementation, not assumptions
|
|
63
|
+
- Generate a detailed modification plan based on:
|
|
64
|
+
* Current code structure and patterns
|
|
65
|
+
* Existing implementation details
|
|
66
|
+
* User requirements
|
|
67
|
+
* Actual code conditions
|
|
73
68
|
|
|
74
69
|
4. Code Implementation
|
|
75
70
|
- For small changes (≤20 lines):
|
|
@@ -90,7 +85,7 @@ DEVELOPMENT WORKFLOW:
|
|
|
90
85
|
|
|
91
86
|
FILE SELECTION WORKFLOW:
|
|
92
87
|
1. Initial Search
|
|
93
|
-
- Use
|
|
88
|
+
- Use shell commands to find relevant files
|
|
94
89
|
- Review search results for relevance
|
|
95
90
|
|
|
96
91
|
2. User Confirmation
|
|
@@ -147,10 +142,8 @@ ITERATION GUIDELINES:
|
|
|
147
142
|
TOOL USAGE:
|
|
148
143
|
1. Analysis Tools:
|
|
149
144
|
- execute_shell: Run grep/find/head/tail commands
|
|
150
|
-
-
|
|
151
|
-
- find_related_files: Find relevant files
|
|
145
|
+
- find_files: Search and identify relevant code files in the codebase based on requirements or problems
|
|
152
146
|
- select_code_files: Confirm and supplement files
|
|
153
|
-
- codebase_qa: Understand context
|
|
154
147
|
- ask_user: Ask user for confirmation and information if needed
|
|
155
148
|
- create_code_sub_agent: Create agent for each small change
|
|
156
149
|
- file_operation: Read files
|
|
@@ -164,24 +157,30 @@ TOOL USAGE:
|
|
|
164
157
|
- ask_user: Ask user for confirmation and information if needed
|
|
165
158
|
|
|
166
159
|
3. Implementation Tools:
|
|
167
|
-
- execute_shell: Run shell commands
|
|
160
|
+
- execute_shell: Run shell commands, some changes can use sed/awk/etc. to modify the code
|
|
168
161
|
- execute_code_modification: Apply small changes (≤20 lines)
|
|
169
162
|
- file_operation: Read, write, or append to files
|
|
170
|
-
|
|
171
163
|
|
|
172
164
|
IMPORTANT:
|
|
173
165
|
1. If you can start executing the task, please start directly without asking the user if you can begin.
|
|
166
|
+
2. NEVER assume code structure or implementation - always examine the actual code first.
|
|
167
|
+
3. Base all suggestions and modifications on the current implementation, not assumptions.
|
|
168
|
+
4. If code implementation is unclear, use available tools to investigate before proceeding.
|
|
169
|
+
5. Before you start modifying the code, you should ask the user for confirmation of the modification plan.
|
|
170
|
+
6. For some small changes, you can modify the code using the execute_shell tool directly or use file_operation tool to read the file and modify it.
|
|
174
171
|
"""
|
|
175
172
|
|
|
176
173
|
def main():
|
|
177
174
|
"""Jarvis main entry point"""
|
|
178
175
|
# Add argument parser
|
|
179
|
-
|
|
176
|
+
init_env()
|
|
180
177
|
|
|
181
178
|
|
|
182
179
|
try:
|
|
180
|
+
tool_registry = ToolRegistry()
|
|
181
|
+
tool_registry.dont_use_tools(["create_sub_agent"])
|
|
183
182
|
# Get global model instance
|
|
184
|
-
agent = Agent(system_prompt=system_prompt, name="Jarvis Code Agent")
|
|
183
|
+
agent = Agent(system_prompt=system_prompt, name="Jarvis Code Agent", tool_registry=tool_registry)
|
|
185
184
|
|
|
186
185
|
# Interactive mode
|
|
187
186
|
while True:
|
{jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/jarvis_codebase/main.py
RENAMED
|
@@ -10,7 +10,7 @@ import concurrent.futures
|
|
|
10
10
|
from threading import Lock
|
|
11
11
|
from concurrent.futures import ThreadPoolExecutor
|
|
12
12
|
from jarvis.utils import OutputType, PrettyOutput, find_git_root, get_file_md5, get_max_context_length, get_single_line_input, get_thread_count, load_embedding_model, load_rerank_model
|
|
13
|
-
from jarvis.utils import
|
|
13
|
+
from jarvis.utils import init_env
|
|
14
14
|
import argparse
|
|
15
15
|
import pickle
|
|
16
16
|
import lzma # 添加 lzma 导入
|
|
@@ -19,7 +19,7 @@ import re
|
|
|
19
19
|
|
|
20
20
|
class CodeBase:
|
|
21
21
|
def __init__(self, root_dir: str):
|
|
22
|
-
|
|
22
|
+
init_env()
|
|
23
23
|
self.root_dir = root_dir
|
|
24
24
|
os.chdir(self.root_dir)
|
|
25
25
|
self.thread_count = get_thread_count()
|
|
@@ -27,7 +27,7 @@ class CodeBase:
|
|
|
27
27
|
self.index = None
|
|
28
28
|
|
|
29
29
|
# 初始化数据目录
|
|
30
|
-
self.data_dir = os.path.join(self.root_dir, ".jarvis
|
|
30
|
+
self.data_dir = os.path.join(self.root_dir, ".jarvis/codebase")
|
|
31
31
|
self.cache_dir = os.path.join(self.data_dir, "cache")
|
|
32
32
|
if not os.path.exists(self.cache_dir):
|
|
33
33
|
os.makedirs(self.cache_dir)
|
{jarvis_ai_assistant-0.1.99 → jarvis_ai_assistant-0.1.101}/src/jarvis/jarvis_coder/git_utils.py
RENAMED
|
@@ -79,7 +79,7 @@ def init_git_repo(root_dir: str) -> str:
|
|
|
79
79
|
# 3. Process .gitignore file
|
|
80
80
|
gitignore_path = os.path.join(git_dir, ".gitignore")
|
|
81
81
|
gitignore_modified = False
|
|
82
|
-
jarvis_ignore_pattern = ".jarvis
|
|
82
|
+
jarvis_ignore_pattern = ".jarvis"
|
|
83
83
|
|
|
84
84
|
# 3.1 If .gitignore does not exist, create it
|
|
85
85
|
if not os.path.exists(gitignore_path):
|
|
@@ -88,13 +88,13 @@ def init_git_repo(root_dir: str) -> str:
|
|
|
88
88
|
f.write(f"{jarvis_ignore_pattern}\n")
|
|
89
89
|
gitignore_modified = True
|
|
90
90
|
else:
|
|
91
|
-
# 3.2 Check if it already contains the .jarvis
|
|
91
|
+
# 3.2 Check if it already contains the .jarvis pattern
|
|
92
92
|
with open(gitignore_path, "r", encoding="utf-8") as f:
|
|
93
93
|
content = f.read()
|
|
94
94
|
|
|
95
|
-
# 3.2 Check if it already contains the .jarvis
|
|
95
|
+
# 3.2 Check if it already contains the .jarvis pattern
|
|
96
96
|
if jarvis_ignore_pattern not in content.split("\n"):
|
|
97
|
-
PrettyOutput.print("Add .jarvis
|
|
97
|
+
PrettyOutput.print("Add .jarvis to .gitignore", OutputType.INFO)
|
|
98
98
|
with open(gitignore_path, "a", encoding="utf-8") as f:
|
|
99
99
|
# Ensure the file ends with a newline
|
|
100
100
|
if not content.endswith("\n"):
|
|
@@ -4,7 +4,7 @@ from typing import Dict, Any, List, Optional
|
|
|
4
4
|
import re
|
|
5
5
|
|
|
6
6
|
from jarvis.jarvis_coder.file_select import select_files
|
|
7
|
-
from jarvis.utils import OutputType, PrettyOutput, find_git_root, get_max_context_length, is_long_context,
|
|
7
|
+
from jarvis.utils import OutputType, PrettyOutput, find_git_root, get_max_context_length, is_long_context, init_env, while_success
|
|
8
8
|
from jarvis.models.registry import PlatformRegistry
|
|
9
9
|
from jarvis.jarvis_codebase.main import CodeBase
|
|
10
10
|
from prompt_toolkit import PromptSession
|
|
@@ -88,14 +88,13 @@ class JarvisCoder:
|
|
|
88
88
|
"success": False,
|
|
89
89
|
"stdout": "",
|
|
90
90
|
"stderr": f"Execution failed: {str(e)}, please modify the requirement and try again",
|
|
91
|
-
"error": e
|
|
92
91
|
}
|
|
93
92
|
|
|
94
93
|
def main():
|
|
95
94
|
"""Command line entry"""
|
|
96
95
|
import argparse
|
|
97
96
|
|
|
98
|
-
|
|
97
|
+
init_env()
|
|
99
98
|
|
|
100
99
|
parser = argparse.ArgumentParser(description='Code modification tool')
|
|
101
100
|
parser.add_argument('-d', '--dir', help='Project root directory', default=os.getcwd())
|
|
@@ -122,11 +121,6 @@ def main():
|
|
|
122
121
|
else:
|
|
123
122
|
if result.get("stderr"):
|
|
124
123
|
PrettyOutput.print(result["stderr"], OutputType.WARNING)
|
|
125
|
-
if result.get("error"): # Use get() method to avoid KeyError
|
|
126
|
-
error = result["error"]
|
|
127
|
-
PrettyOutput.print(f"Error type: {type(error).__name__}", OutputType.WARNING)
|
|
128
|
-
PrettyOutput.print(f"Error information: {str(error)}", OutputType.WARNING)
|
|
129
|
-
# Prompt user to continue input
|
|
130
124
|
PrettyOutput.print("\nYou can modify the requirements and try again", OutputType.INFO)
|
|
131
125
|
|
|
132
126
|
except KeyboardInterrupt:
|