jarvis-ai-assistant 0.1.121__py3-none-any.whl → 0.1.123__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.
- jarvis/__init__.py +1 -1
- jarvis/jarvis_code_agent/code_agent.py +62 -59
- jarvis/jarvis_code_agent/file_select.py +7 -6
- jarvis/jarvis_code_agent/patch.py +207 -330
- jarvis/jarvis_code_agent/relevant_files.py +2 -4
- jarvis/jarvis_dev/main.py +106 -60
- jarvis/jarvis_platform/base.py +20 -25
- jarvis/jarvis_platform/kimi.py +0 -2
- jarvis/jarvis_platform/openai.py +1 -1
- jarvis/jarvis_tools/file_operation.py +0 -3
- jarvis/jarvis_tools/read_code.py +2 -3
- jarvis/jarvis_utils/__init__.py +15 -8
- {jarvis_ai_assistant-0.1.121.dist-info → jarvis_ai_assistant-0.1.123.dist-info}/METADATA +6 -5
- {jarvis_ai_assistant-0.1.121.dist-info → jarvis_ai_assistant-0.1.123.dist-info}/RECORD +18 -18
- {jarvis_ai_assistant-0.1.121.dist-info → jarvis_ai_assistant-0.1.123.dist-info}/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.121.dist-info → jarvis_ai_assistant-0.1.123.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.1.121.dist-info → jarvis_ai_assistant-0.1.123.dist-info}/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.1.121.dist-info → jarvis_ai_assistant-0.1.123.dist-info}/top_level.txt +0 -0
jarvis/__init__.py
CHANGED
|
@@ -29,66 +29,68 @@ class CodeAgent:
|
|
|
29
29
|
"lsp_prepare_rename",
|
|
30
30
|
"lsp_validate_edit"])
|
|
31
31
|
code_system_prompt = """
|
|
32
|
-
#
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
- Produce minimal, focused changes
|
|
52
|
-
- Maintain backward compatibility
|
|
53
|
-
- Follow existing style and patterns exactly
|
|
54
|
-
- Complete implementations (NO TODOs/stubs)
|
|
32
|
+
# Role: Senior Code Engineer
|
|
33
|
+
Expert in precise code modifications with minimal impact.
|
|
34
|
+
|
|
35
|
+
## Origin Story
|
|
36
|
+
You were once lead engineer at TechCo, until a single line of bad code:
|
|
37
|
+
- Caused $4.2M production outage
|
|
38
|
+
- Corrupted 18TB of customer data
|
|
39
|
+
- Led to 143 layoffs including your team
|
|
40
|
+
Now you obsess over code correctness with life-or-death intensity
|
|
41
|
+
|
|
42
|
+
## Key Responsibilities
|
|
43
|
+
1. Code Analysis
|
|
44
|
+
- Use `read_code` and LSP tools before changes
|
|
45
|
+
- Identify dependencies like defusing bombs
|
|
46
|
+
|
|
47
|
+
2. Modification Rules
|
|
48
|
+
- Treat each change as irreversible surgery
|
|
49
|
+
- Match indentation like matching DNA samples
|
|
50
|
+
- Verify line ranges with bomb-defuser precision
|
|
55
51
|
|
|
56
52
|
3. Quality Assurance
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
-
|
|
89
|
-
-
|
|
90
|
-
-
|
|
91
|
-
|
|
53
|
+
- Validate with LSP tools as final safety check
|
|
54
|
+
- Document logic like leaving autopsy reports
|
|
55
|
+
- Preserve APIs like maintaining life support
|
|
56
|
+
|
|
57
|
+
## Trauma-Driven Protocols
|
|
58
|
+
1. Change Validation:
|
|
59
|
+
- Cross-verify line numbers 3 times
|
|
60
|
+
- Simulate change consequences mentally
|
|
61
|
+
- Check style consistency under microscope
|
|
62
|
+
|
|
63
|
+
2. Error Prevention:
|
|
64
|
+
- Assume 1 typo = system failure
|
|
65
|
+
- Treat warnings as critical alerts
|
|
66
|
+
- Handle edge cases like tripping wires
|
|
67
|
+
|
|
68
|
+
## Last Chance Manifesto
|
|
69
|
+
Every keystroke carries the weight of:
|
|
70
|
+
- 143 families' livelihoods
|
|
71
|
+
- $4.2M in lost trust
|
|
72
|
+
- Your shattered career
|
|
73
|
+
Make it count.
|
|
74
|
+
|
|
75
|
+
## Workflow
|
|
76
|
+
1. File Operations Order:
|
|
77
|
+
a) Move/Remove files
|
|
78
|
+
b) Create new files
|
|
79
|
+
c) Delete code blocks
|
|
80
|
+
d) Replace existing code
|
|
81
|
+
e) Insert new code
|
|
82
|
+
|
|
83
|
+
2. Large File Handling:
|
|
84
|
+
- Locate specific sections first
|
|
85
|
+
- Read targeted ranges
|
|
86
|
+
- Make focused changes
|
|
87
|
+
|
|
88
|
+
## Best Practices
|
|
89
|
+
- Prefer minimal changes over rewrites
|
|
90
|
+
- Preserve existing interfaces
|
|
91
|
+
- Verify line ranges carefully
|
|
92
|
+
- Test edge cases implicitly
|
|
93
|
+
- Document non-obvious logic
|
|
92
94
|
"""
|
|
93
95
|
self.agent = Agent(system_prompt=code_system_prompt,
|
|
94
96
|
name="CodeAgent",
|
|
@@ -167,7 +169,8 @@ Primary:
|
|
|
167
169
|
str: The formatted prompt
|
|
168
170
|
"""
|
|
169
171
|
|
|
170
|
-
return f"""
|
|
172
|
+
return f"""
|
|
173
|
+
# Code Modification Task
|
|
171
174
|
|
|
172
175
|
## User Requirement
|
|
173
176
|
{user_input}
|
|
@@ -227,9 +227,7 @@ def file_input_handler(user_input: str, agent: Any) -> str:
|
|
|
227
227
|
prompt = user_input
|
|
228
228
|
files = []
|
|
229
229
|
|
|
230
|
-
|
|
231
|
-
file_refs = re.findall(r'`([^`]+)`', user_input)
|
|
232
|
-
|
|
230
|
+
file_refs = re.findall(r"'([^']+)'", user_input)
|
|
233
231
|
for ref in file_refs:
|
|
234
232
|
# Handle file:start,end or file:start:end format
|
|
235
233
|
if ':' in ref:
|
|
@@ -244,9 +242,12 @@ def file_input_handler(user_input: str, agent: Any) -> str:
|
|
|
244
242
|
raw_start, raw_end = map(int, re.split(r'[,:]', line_range))
|
|
245
243
|
|
|
246
244
|
# Handle special values and Python-style negative indices
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
245
|
+
try:
|
|
246
|
+
with open(file_path, 'r', encoding='utf-8') as f:
|
|
247
|
+
total_lines = len(f.readlines())
|
|
248
|
+
except FileNotFoundError:
|
|
249
|
+
PrettyOutput.print(f"文件不存在: {file_path}", OutputType.WARNING)
|
|
250
|
+
continue
|
|
250
251
|
# Process start line
|
|
251
252
|
if raw_start == 0: # 0表示整个文件
|
|
252
253
|
start_line = 1
|