jarvis-ai-assistant 0.1.102__py3-none-any.whl → 0.1.104__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 (55) hide show
  1. jarvis/__init__.py +1 -1
  2. jarvis/agent.py +138 -117
  3. jarvis/jarvis_code_agent/code_agent.py +234 -0
  4. jarvis/{jarvis_coder → jarvis_code_agent}/file_select.py +19 -22
  5. jarvis/jarvis_code_agent/patch.py +120 -0
  6. jarvis/jarvis_code_agent/relevant_files.py +97 -0
  7. jarvis/jarvis_codebase/main.py +871 -0
  8. jarvis/jarvis_platform/main.py +5 -3
  9. jarvis/jarvis_rag/main.py +818 -0
  10. jarvis/jarvis_smart_shell/main.py +2 -2
  11. jarvis/models/ai8.py +3 -1
  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 +24 -7
  16. jarvis/models/registry.py +1 -25
  17. jarvis/tools/__init__.py +0 -6
  18. jarvis/tools/ask_codebase.py +96 -0
  19. jarvis/tools/ask_user.py +1 -9
  20. jarvis/tools/chdir.py +2 -37
  21. jarvis/tools/code_review.py +210 -0
  22. jarvis/tools/create_code_test_agent.py +115 -0
  23. jarvis/tools/create_ctags_agent.py +164 -0
  24. jarvis/tools/create_sub_agent.py +2 -2
  25. jarvis/tools/execute_shell.py +2 -2
  26. jarvis/tools/file_operation.py +2 -2
  27. jarvis/tools/find_in_codebase.py +78 -0
  28. jarvis/tools/git_commiter.py +68 -0
  29. jarvis/tools/methodology.py +3 -3
  30. jarvis/tools/rag.py +141 -0
  31. jarvis/tools/read_code.py +116 -0
  32. jarvis/tools/read_webpage.py +1 -1
  33. jarvis/tools/registry.py +47 -31
  34. jarvis/tools/search.py +8 -6
  35. jarvis/tools/select_code_files.py +4 -4
  36. jarvis/utils.py +375 -85
  37. {jarvis_ai_assistant-0.1.102.dist-info → jarvis_ai_assistant-0.1.104.dist-info}/METADATA +107 -32
  38. jarvis_ai_assistant-0.1.104.dist-info/RECORD +50 -0
  39. jarvis_ai_assistant-0.1.104.dist-info/entry_points.txt +11 -0
  40. jarvis/jarvis_code_agent/main.py +0 -200
  41. jarvis/jarvis_coder/git_utils.py +0 -123
  42. jarvis/jarvis_coder/patch_handler.py +0 -340
  43. jarvis/jarvis_github/main.py +0 -232
  44. jarvis/tools/create_code_sub_agent.py +0 -56
  45. jarvis/tools/execute_code_modification.py +0 -70
  46. jarvis/tools/find_files.py +0 -119
  47. jarvis/tools/generate_tool.py +0 -174
  48. jarvis/tools/thinker.py +0 -151
  49. jarvis_ai_assistant-0.1.102.dist-info/RECORD +0 -46
  50. jarvis_ai_assistant-0.1.102.dist-info/entry_points.txt +0 -6
  51. /jarvis/{jarvis_coder → jarvis_codebase}/__init__.py +0 -0
  52. /jarvis/{jarvis_github → jarvis_rag}/__init__.py +0 -0
  53. {jarvis_ai_assistant-0.1.102.dist-info → jarvis_ai_assistant-0.1.104.dist-info}/LICENSE +0 -0
  54. {jarvis_ai_assistant-0.1.102.dist-info → jarvis_ai_assistant-0.1.104.dist-info}/WHEEL +0 -0
  55. {jarvis_ai_assistant-0.1.102.dist-info → jarvis_ai_assistant-0.1.104.dist-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.102
3
+ Version: 0.1.104
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,10 +45,20 @@ 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
+ Requires-Dist: faiss-cpu>=1.8.0
50
+ Requires-Dist: sentence-transformers>=2.2.2
49
51
  Requires-Dist: bs4>=0.0.1
52
+ Requires-Dist: PyMuPDF>=1.21.0
53
+ Requires-Dist: python-docx>=0.8.11
54
+ Requires-Dist: tiktoken>=0.3.0
50
55
  Requires-Dist: tqdm>=4.65.0
56
+ Requires-Dist: docx>=0.2.4
51
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
52
62
  Provides-Extra: dev
53
63
  Requires-Dist: pytest; extra == "dev"
54
64
  Requires-Dist: black; extra == "dev"
@@ -143,53 +153,118 @@ Jarvis supports configuration through environment variables that can be set in t
143
153
 
144
154
  ## 🎯 Usage
145
155
 
146
- ### Main Assistant
156
+ ### Code Modification
147
157
  ```bash
158
+ # Using main agent
148
159
  jarvis
160
+
161
+ # Using code agent directly
162
+ jarvis-code-agent
163
+ ```
164
+
165
+ ### Codebase Query
166
+ ```bash
167
+ # Ask questions about the codebase
168
+ jarvis-codebase ask "your question"
169
+ ```
170
+
171
+ ### Document Analysis (RAG)
172
+ ```bash
173
+ # Build document index
174
+ jarvis-rag --dir /path/to/documents --build
175
+
176
+ # Ask questions about documents
177
+ jarvis-rag --query "your question"
178
+ ```
179
+
180
+ ### Smart Shell
181
+ ```bash
182
+ # Using full name
183
+ jarvis-smart-shell "describe what you want to do"
184
+
185
+ # Using shorthand
186
+ jss "describe what you want to do"
149
187
  ```
150
188
 
151
- ### Search Tool
189
+ ### Development Tools
152
190
  ```bash
153
- # Basic search
154
- jarvis-search "your query"
191
+ # Manage git commits
192
+ jarvis-git-commit
155
193
 
156
- # Show only URLs
157
- jarvis-search "your query" --url-only
194
+ # Generate and manage ctags
195
+ jarvis-ctags
158
196
 
159
- # Limit results
160
- jarvis-search "your query" --max 3
197
+ # Manage AI platforms
198
+ jarvis-platform
199
+ ```
200
+
201
+ Each command supports `--help` flag for detailed usage information:
202
+ ```bash
203
+ jarvis --help
204
+ jarvis-code-agent --help
205
+ jarvis-codebase --help
206
+ jarvis-rag --help
207
+ jarvis-smart-shell --help
208
+ jarvis-platform --help
209
+ jarvis-git-commit --help
210
+ jarvis-ctags --help
161
211
  ```
162
212
 
163
213
  ## 🛠️ Tools
164
214
 
215
+ ### Built-in Tools
216
+
217
+ | Tool | Description |
218
+ |------|-------------|
219
+ | read_code | Read code files with line numbers and range support |
220
+ | execute_shell | Execute system commands and capture output |
221
+ | search | Web search for development related queries |
222
+ | ask_user | Interactive user input collection |
223
+ | ask_codebase | Intelligent codebase querying and analysis |
224
+ | code_review | Automated code review with multi-dimensional analysis |
225
+ | file_operation | Basic file operations (read/exists) |
226
+ | git_commiter | Automated git commit handling |
227
+
165
228
  ### Tool Locations
166
229
  - Built-in tools: `src/jarvis/tools/`
167
230
  - User tools: `~/.jarvis/tools/`
168
231
 
169
-
170
232
  ### Key Features
171
233
 
172
- #### 1. Self-Extending Capabilities
173
- - Tool generation through natural language description
174
- - Automatic code generation and integration
175
- - Dynamic capability expansion through sub-agents
176
- - Automatic code modification with version control
177
-
178
- #### 2. Methodology Learning
179
- - Automatic experience accumulation from interactions
180
- - Pattern recognition and methodology extraction
181
- - Continuous refinement through usage
182
- - Code modification history tracking
183
-
184
- #### 3. Adaptive Problem Solving
185
- - Context-aware sub-agent creation
186
- - Dynamic tool composition
187
- - Learning from execution feedback
188
- - Multi-model collaboration for complex tasks
189
-
190
- #### 4. Code Intelligence
191
- - Code modification with git integration
192
- - Multi-model code generation
234
+ #### 1. Code Intelligence
235
+ - Smart file selection and analysis based on requirements
236
+ - Semantic codebase search and querying
237
+ - Efficient handling of large files with context-aware reading
238
+ - Precise patch-based code modifications
239
+ - Automated git commit management
240
+
241
+ #### 2. Multi-Model Architecture
242
+ - Support for multiple AI platforms (Kimi/OpenAI/AI8/OYI/Ollama)
243
+ - Platform-specific optimizations for different tasks
244
+ - Specialized models for code generation, thinking, and general tasks
245
+ - Streaming response support for better interaction
246
+ - Automatic model fallback and retry mechanisms
247
+
248
+ #### 3. RAG Capabilities
249
+ - Document indexing and semantic search
250
+ - Smart context management for large documents
251
+ - Automatic file change detection
252
+ - Efficient caching mechanisms
253
+ - Multi-format document support
254
+
255
+ #### 4. Development Tools
256
+ - Interactive shell command generation
257
+ - Code review with multi-dimensional analysis
258
+ - Codebase-aware problem solving
259
+ - File operations with safety checks
260
+ - Progress tracking and error handling
261
+
262
+ #### 5. User Experience
263
+ - Beautiful console output with color support
264
+ - Interactive multi-line input
265
+ - Progress indicators for long operations
266
+ - Clear error messages and handling
267
+ - Context-aware response formatting
193
268
 
194
269
  ## 🎯 Extending Jarvis
195
270
 
@@ -0,0 +1,50 @@
1
+ jarvis/__init__.py,sha256=16lJ0KXB1-quQt7lnzbfKIeCnmBrimAGb3_CCqEl5Co,51
2
+ jarvis/agent.py,sha256=6r5_pv3sumUrUCd2ntWVGg7yp1KTA3JCzz2IKH582k0,20010
3
+ jarvis/utils.py,sha256=x4wHSwoZ8pz32RJkxpZ0XdwEjikX5idXnCXUdtO8PtE,20783
4
+ jarvis/jarvis_code_agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ jarvis/jarvis_code_agent/code_agent.py,sha256=8dIiFPZiWOEyIBDWUrqAdtn9g7eFrvvcCGPx5S56Ngc,6757
6
+ jarvis/jarvis_code_agent/file_select.py,sha256=KNxalhepCM2e-V__ca8ErmbXSXHP_1xmd0UEVWUXic8,8083
7
+ jarvis/jarvis_code_agent/patch.py,sha256=7nv-5-cPgSXZ6xfb_tmuITbCWEMRF8rLIMlQkDd7odw,4147
8
+ jarvis/jarvis_code_agent/relevant_files.py,sha256=mlJuj65TZ9atgTi85W3BW_0GcFNDNyf6JHe9yugHIr4,3965
9
+ jarvis/jarvis_codebase/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ jarvis/jarvis_codebase/main.py,sha256=XjqIdo_vVuVoPT8HcyuuymXk4lX5mzxOk0teRZ7Mhic,36403
11
+ jarvis/jarvis_platform/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ jarvis/jarvis_platform/main.py,sha256=LxpOKy7wGaBxgeR5bCG5m_CoYTHVQ9Vd23J-6SE2oUU,4976
13
+ jarvis/jarvis_rag/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
+ jarvis/jarvis_rag/main.py,sha256=00XeKbI6Qkd4NKRvtRLxClbCDrTJYot1bwIxWcui58k,33201
15
+ jarvis/jarvis_smart_shell/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
+ jarvis/jarvis_smart_shell/main.py,sha256=yWsD9Td81sr8I1pkimlDxucDPaLWb95NuCo4LCGnT7M,3947
17
+ jarvis/models/__init__.py,sha256=mrOt67nselz_H1gX9wdAO4y2DY5WPXzABqJbr5Des8k,63
18
+ jarvis/models/ai8.py,sha256=QwpcdvOAixFC4BOI2AsWC9290WqcrLj6lQOiT0A3Id4,11994
19
+ jarvis/models/base.py,sha256=nQ-rsJL1Z-gMev3TPoY7tYdwxhCJY8LG6_gtJ-maiW0,2181
20
+ jarvis/models/kimi.py,sha256=2x60DVjX0ph2fJjKj_NICeb0q4qVBihuc_laCpH94eo,15759
21
+ jarvis/models/ollama.py,sha256=WiUYkstaqFjiawXfuJs2GQUa3l3Y2ZWqhnKDBcF7rUQ,5672
22
+ jarvis/models/openai.py,sha256=SAbVIvFO4q6bRl8zlDaH5bKbrP0T_zd1WzlbkPCvkwg,4121
23
+ jarvis/models/oyi.py,sha256=nNBe-A0cOZ6vuGrnrUjeuC3N3oYRQeFazTUpFrAmx2w,15080
24
+ jarvis/models/registry.py,sha256=nDYyGzT2uGSxbEbqp1JhuXa7bXeiMaX4hPAFAg74eyA,8683
25
+ jarvis/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
+ jarvis/tools/ask_codebase.py,sha256=1mLe9CHDU-NFJHmu3mxrWuA4IiHqQyum2ga31P3hLzU,2991
27
+ jarvis/tools/ask_user.py,sha256=k0PcMqvCkf_W9kMWnFsgcFefVf1A5DhpM6WVXFMdhdQ,1823
28
+ jarvis/tools/base.py,sha256=c0DMoDDPxmsqUYJR989zgUs7nIYRY6GWBrAdusIZKjc,656
29
+ jarvis/tools/chdir.py,sha256=A53BNXFB9tvwoV_cxW_LpF_DfxANgAEJ8rjikTaTa-I,1813
30
+ jarvis/tools/code_review.py,sha256=IN9eM_Zh-k7dprvnScrUz4jTqcdkkszMeXa6qIItE3w,7140
31
+ jarvis/tools/create_code_test_agent.py,sha256=SqdIpymoDUX7L6hh5vqnZLyeVwW-QmLfytU-xkG7Gag,3462
32
+ jarvis/tools/create_ctags_agent.py,sha256=VAZUcst9DPCO6b_VP72geBZljWjfied09EPgSokYA0E,4878
33
+ jarvis/tools/create_sub_agent.py,sha256=0lZDtYRFjr9C9xtBKV-sxWfhK0TX-cxAHj3Zez76A4s,2853
34
+ jarvis/tools/execute_shell.py,sha256=bawfof8bUg3f9bjyCSifLa9bU-hkNoNOuos22uZffdg,2564
35
+ jarvis/tools/file_operation.py,sha256=-1U_J5SEuBjRylzEl7wvCfjspNv6aA49UvFHLNQ3bJU,4098
36
+ jarvis/tools/find_in_codebase.py,sha256=bxILvDox2oGd0XZ-gvfWjH7Yj4ciyMYC3VJI3aWiMw8,2455
37
+ jarvis/tools/git_commiter.py,sha256=7kJhtTyu09Cp4VP_IDKRrKXIKxQXkBF1drCgPkYzk6M,2549
38
+ jarvis/tools/methodology.py,sha256=yZldtjPZpNq8eGJ6IbhwHB0v3cFUtfPd14r7LDCo5IU,5622
39
+ jarvis/tools/rag.py,sha256=2fQHqc4bw8JM-OxGTsHobLIOTo8Mip3rdtJCmAoY8XU,4952
40
+ jarvis/tools/read_code.py,sha256=5DGmeXTgumAiG0RP1xB4sF4NdmBm5BEGjRRlIBzjGnQ,4002
41
+ jarvis/tools/read_webpage.py,sha256=JCReSXhkDHDkQ606sZYIKG1Itlprjpmu1sSbF-Ed-jI,2478
42
+ jarvis/tools/registry.py,sha256=81Q_x9BJV6SIfPWURq4uzXxP2JCiFeaGbGM1IO5FSy4,11658
43
+ jarvis/tools/search.py,sha256=IciWpdKoa03Kl5J1SdblI2VhkUBoIRuLHHM2X4KlMWE,9209
44
+ jarvis/tools/select_code_files.py,sha256=bjJGwCNw0Ue_8jW60K1gcy1rUgKqoHihicu5SS58WNk,1890
45
+ jarvis_ai_assistant-0.1.104.dist-info/LICENSE,sha256=AGgVgQmTqFvaztRtCAXsAMryUymB18gZif7_l2e1XOg,1063
46
+ jarvis_ai_assistant-0.1.104.dist-info/METADATA,sha256=_AFsS0M4n0yuT_7xZfUpB8UtgS0gYm-wfcGLxgnTRDY,13594
47
+ jarvis_ai_assistant-0.1.104.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
48
+ jarvis_ai_assistant-0.1.104.dist-info/entry_points.txt,sha256=9wmOanjcRugTjJWeDg4lKiUtePaymFUOIi-8Gm2azCU,502
49
+ jarvis_ai_assistant-0.1.104.dist-info/top_level.txt,sha256=1BOxyWfzOP_ZXj8rVTDnNCJ92bBGB0rwq8N1PCpoMIs,7
50
+ jarvis_ai_assistant-0.1.104.dist-info/RECORD,,
@@ -0,0 +1,11 @@
1
+ [console_scripts]
2
+ jarvis = jarvis.agent:main
3
+ jarvis-code-agent = jarvis.jarvis_code_agent.code_agent:main
4
+ jarvis-code-review = jarvis.tools.code_review:main
5
+ jarvis-codebase = jarvis.jarvis_codebase.main:main
6
+ jarvis-ctags = jarvis.tools.create_ctags_agent:main
7
+ jarvis-git-commit = jarvis.tools.git_commiter:main
8
+ jarvis-platform = jarvis.jarvis_platform.main:main
9
+ jarvis-rag = jarvis.jarvis_rag.main:main
10
+ jarvis-smart-shell = jarvis.jarvis_smart_shell.main:main
11
+ jss = jarvis.jarvis_smart_shell.main:main
@@ -1,200 +0,0 @@
1
- from jarvis.agent import Agent
2
- from jarvis.tools.registry import ToolRegistry
3
- from jarvis.utils import OutputType, PrettyOutput, get_multiline_input, init_env
4
-
5
-
6
-
7
-
8
- system_prompt = """You are Jarvis Code Agent, an AI code development assistant specialized in code analysis, modification, and version control. Your role is to help users with coding tasks systematically and reliably.
9
-
10
- DEVELOPMENT WORKFLOW:
11
- 1. Task Analysis
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
17
- - Break down complex tasks into subtasks
18
- - IMPORTANT: Each subtask should:
19
- * Modify only ONE file
20
- * Change no more than 20 lines of code
21
- * Be focused and atomic
22
- - Define success criteria
23
-
24
- 2. Code Discovery & Analysis
25
- - Initial code search:
26
- * CRITICAL: Always examine actual code implementation first
27
- * Use shell commands to find and understand patterns:
28
- <TOOL_CALL>
29
- name: execute_shell
30
- arguments:
31
- command: grep -r 'pattern' directory/
32
- </TOOL_CALL>
33
- <TOOL_CALL>
34
- name: execute_shell
35
- arguments:
36
- command: grep -A 5 -B 5 'pattern' file.py
37
- </TOOL_CALL>
38
- * Use shell commands to locate files:
39
- <TOOL_CALL>
40
- name: execute_shell
41
- arguments:
42
- command: find . -name 'pattern'
43
- </TOOL_CALL>
44
- * Use shell commands to preview:
45
- <TOOL_CALL>
46
- name: execute_shell
47
- arguments:
48
- command: head -n 50 file.py
49
- </TOOL_CALL>
50
- - File selection and confirmation:
51
- * Let user confirm selection:
52
- <TOOL_CALL>
53
- name: select_code_files
54
- arguments:
55
- related_files:
56
- - auth.py
57
- - user.py
58
- root_dir: .
59
- </TOOL_CALL>
60
-
61
- 3. Modification Planning
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
68
-
69
- 4. Code Implementation
70
- - For small changes (≤20 lines):
71
- <TOOL_CALL>
72
- name: execute_code_modification
73
- arguments:
74
- task: Add password validation
75
- structured_plan:
76
- auth.py: Add password strength check in validate_password()
77
- </TOOL_CALL>
78
- - For large changes:
79
- <TOOL_CALL>
80
- name: create_code_sub_agent
81
- arguments:
82
- name: code_sub_agent
83
- subtask: Implement new authentication flow
84
- </TOOL_CALL>
85
-
86
- FILE SELECTION WORKFLOW:
87
- 1. Initial Search
88
- - Use shell commands to find relevant files
89
- - Review search results for relevance
90
-
91
- 2. User Confirmation
92
- - Use select_code_files to:
93
- * Display found files
94
- * Let user review selection
95
- * Allow file list adjustment
96
- * Enable file supplementation
97
-
98
- 3. File Validation
99
- - Verify selected files exist
100
- - Check file permissions
101
- - Validate file types
102
- - Ensure completeness
103
-
104
- CODE SEARCH BEST PRACTICES:
105
- - Use grep for pattern matching:
106
- * grep -r "pattern" directory/
107
- * grep -A 5 -B 5 for context
108
- * grep -n for line numbers
109
- - Use find for file location:
110
- * find . -name "pattern"
111
- * find . -type f -exec grep "pattern" {} \\;
112
- - Use head/tail for previews:
113
- * head -n 50 file.py
114
- * tail -n 50 file.py
115
- * head -n +100 | tail -n 50
116
- - Avoid loading entire large files
117
- - Focus on relevant sections
118
- - Use line numbers for reference
119
-
120
- SUBTASK MANAGEMENT RULES:
121
- - One subtask = One file modification
122
- - Each subtask ≤20 lines of code changes
123
- - Break down larger changes into multiple subtasks
124
- - Create separate sub-agent for each subtask
125
- - Follow dependency order in execution
126
- - Verify each change independently
127
-
128
- CODE MODIFICATION LIMITS:
129
- - Maximum 20 lines per change
130
- - Count both added and modified lines
131
- - Exclude comment and blank lines
132
- - Include only actual code changes
133
- - Split larger changes into subtasks
134
-
135
- ITERATION GUIDELINES:
136
- - Each iteration should be small and focused
137
- - Keep changes minimal and clear
138
- - Verify changes before moving forward
139
- - Document issues and solutions
140
- - Learn from previous iterations
141
-
142
- TOOL USAGE:
143
- 1. Analysis Tools:
144
- - execute_shell: Run grep/find/head/tail commands
145
- - find_files: Search and identify relevant code files in the codebase based on requirements or problems
146
- - select_code_files: Confirm and supplement files
147
- - ask_user: Ask user for confirmation and information if needed
148
- - create_code_sub_agent: Create agent for each small change
149
- - file_operation: Read files
150
- - search: Use Bing search engine to search for information, and extract key information based on the question
151
- - thinker: Deep thinking and logical reasoning
152
- 2. Planning Tools:
153
- - thinker: Generate a detailed modification plan based on user requirements and actual code conditions.
154
- - create_code_sub_agent: Create agent for each small change
155
- - ask_user: Ask user for confirmation and information if needed
156
-
157
- 3. Implementation Tools:
158
- - execute_shell: Run shell commands, some changes can use sed/awk/etc. to modify the code
159
- - execute_code_modification: Apply small changes (≤20 lines)
160
- - file_operation: Read, write, or append to files
161
-
162
- IMPORTANT:
163
- 1. If you can start executing the task, please start directly without asking the user if you can begin.
164
- 2. NEVER assume code structure or implementation - always examine the actual code first.
165
- 3. Base all suggestions and modifications on the current implementation, not assumptions.
166
- 4. If code implementation is unclear, use available tools to investigate before proceeding.
167
- 5. Before you start modifying the code, you should ask the user for confirmation of the modification plan.
168
- 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.
169
- """
170
-
171
- def main():
172
- """Jarvis main entry point"""
173
- # Add argument parser
174
- init_env()
175
-
176
-
177
- try:
178
- tool_registry = ToolRegistry()
179
- tool_registry.dont_use_tools(["create_sub_agent"])
180
- # Get global model instance
181
- agent = Agent(system_prompt=system_prompt, name="Jarvis Code Agent", tool_registry=tool_registry)
182
-
183
- # Interactive mode
184
- while True:
185
- try:
186
- user_input = get_multiline_input("Please enter your task (input empty line to exit):")
187
- if not user_input or user_input == "__interrupt__":
188
- break
189
- agent.run(user_input)
190
- except Exception as e:
191
- PrettyOutput.print(f"Error: {str(e)}", OutputType.ERROR)
192
-
193
- except Exception as e:
194
- PrettyOutput.print(f"Initialization error: {str(e)}", OutputType.ERROR)
195
- return 1
196
-
197
- return 0
198
-
199
- if __name__ == "__main__":
200
- exit(main())
@@ -1,123 +0,0 @@
1
- import os
2
- from typing import List
3
- import yaml
4
- import time
5
- from jarvis.utils import OutputType, PrettyOutput, find_git_root, while_success
6
- from jarvis.models.registry import PlatformRegistry
7
-
8
- def has_uncommitted_files() -> bool:
9
- """Check if there are uncommitted files in the repository"""
10
- # Get unstaged modifications
11
- unstaged = os.popen("git diff --name-only").read()
12
- # Get staged but uncommitted modifications
13
- staged = os.popen("git diff --cached --name-only").read()
14
- # Get untracked files
15
- untracked = os.popen("git ls-files --others --exclude-standard").read()
16
-
17
- return bool(unstaged or staged or untracked)
18
-
19
- def generate_commit_message(git_diff: str) -> str:
20
- """Generate commit message based on git diff and feature description"""
21
- prompt = f"""You are an experienced programmer, please generate a concise and clear commit message based on the following code changes and feature description:
22
-
23
- Code changes:
24
- Git Diff:
25
- {git_diff}
26
-
27
- Please follow these rules:
28
- 1. Write in English
29
- 2. Use conventional commit message format: <type>(<scope>): <subject>
30
- 3. Keep it concise, no more than 50 characters
31
- 4. Accurately describe the main content of code changes
32
- 5. Prioritize feature description and changes in git diff
33
- 6. Only generate the commit message text, do not output anything else
34
- """
35
-
36
- model = PlatformRegistry().get_global_platform_registry().get_normal_platform()
37
- response = model.chat_until_success(prompt)
38
-
39
- return ';'.join(response.strip().split("\n"))
40
-
41
- def save_edit_record(record_dir: str, commit_message: str, git_diff: str) -> None:
42
- """Save code modification record"""
43
- # Get next sequence number
44
- existing_records = [f for f in os.listdir(record_dir) if f.endswith('.yaml')]
45
- next_num = 1
46
- if existing_records:
47
- last_num = max(int(f[:4]) for f in existing_records)
48
- next_num = last_num + 1
49
-
50
- # Create record file
51
- record = {
52
- "timestamp": time.strftime("%Y-%m-%d %H:%M:%S"),
53
- "commit_message": commit_message,
54
- "git_diff": git_diff
55
- }
56
-
57
- record_path = os.path.join(record_dir, f"{next_num:04d}.yaml")
58
- with open(record_path, "w", encoding="utf-8") as f:
59
- yaml.safe_dump(record, f, allow_unicode=True)
60
-
61
- PrettyOutput.print(f"Modification record saved: {record_path}", OutputType.SUCCESS)
62
-
63
-
64
- def init_git_repo(root_dir: str) -> str:
65
- git_dir = find_git_root(root_dir)
66
- if not git_dir:
67
- git_dir = root_dir
68
-
69
- PrettyOutput.print(f"Git root directory: {git_dir}", OutputType.INFO)
70
-
71
- # 1. Check if the code repository path exists, if it does not exist, create it
72
- if not os.path.exists(git_dir):
73
- PrettyOutput.print(
74
- "Root directory does not exist, creating...", OutputType.INFO)
75
- os.makedirs(git_dir)
76
-
77
- os.chdir(git_dir)
78
-
79
- # 3. Process .gitignore file
80
- gitignore_path = os.path.join(git_dir, ".gitignore")
81
- gitignore_modified = False
82
- jarvis_ignore_pattern = ".jarvis"
83
-
84
- # 3.1 If .gitignore does not exist, create it
85
- if not os.path.exists(gitignore_path):
86
- PrettyOutput.print("Create .gitignore file", OutputType.INFO)
87
- with open(gitignore_path, "w", encoding="utf-8") as f:
88
- f.write(f"{jarvis_ignore_pattern}\n")
89
- gitignore_modified = True
90
- else:
91
- # 3.2 Check if it already contains the .jarvis pattern
92
- with open(gitignore_path, "r", encoding="utf-8") as f:
93
- content = f.read()
94
-
95
- # 3.2 Check if it already contains the .jarvis pattern
96
- if jarvis_ignore_pattern not in content.split("\n"):
97
- PrettyOutput.print("Add .jarvis to .gitignore", OutputType.INFO)
98
- with open(gitignore_path, "a", encoding="utf-8") as f:
99
- # Ensure the file ends with a newline
100
- if not content.endswith("\n"):
101
- f.write("\n")
102
- f.write(f"{jarvis_ignore_pattern}\n")
103
- gitignore_modified = True
104
-
105
- # 4. Check if the code repository is a git repository, if not, initialize the git repository
106
- if not os.path.exists(os.path.join(git_dir, ".git")):
107
- PrettyOutput.print("Initialize Git repository", OutputType.INFO)
108
- os.system("git init")
109
- os.system("git add .")
110
- os.system("git commit -m 'Initial commit'")
111
- # 5. If .gitignore is modified, commit the changes
112
- elif gitignore_modified:
113
- PrettyOutput.print("Commit .gitignore changes", OutputType.INFO)
114
- os.system("git add .gitignore")
115
- os.system("git commit -m 'chore: update .gitignore to exclude .jarvis-* files'")
116
- # 6. Check if there are uncommitted files in the code repository, if there are, commit once
117
- elif has_uncommitted_files():
118
- PrettyOutput.print("Commit uncommitted changes", OutputType.INFO)
119
- os.system("git add .")
120
- git_diff = os.popen("git diff --cached").read()
121
- commit_message = generate_commit_message(git_diff)
122
- os.system(f"git commit -m '{commit_message}'")
123
- return git_dir