jarvis-ai-assistant 0.1.207__py3-none-any.whl → 0.1.208__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.
- jarvis/__init__.py +1 -1
- jarvis/jarvis_agent/__init__.py +71 -61
- jarvis/jarvis_agent/edit_file_handler.py +42 -46
- jarvis/jarvis_agent/jarvis.py +33 -39
- jarvis/jarvis_code_agent/code_agent.py +26 -27
- jarvis/jarvis_code_agent/lint.py +5 -5
- jarvis/jarvis_code_analysis/code_review.py +164 -175
- jarvis/jarvis_git_utils/git_commiter.py +147 -152
- jarvis/jarvis_methodology/main.py +70 -81
- jarvis/jarvis_platform/base.py +21 -17
- jarvis/jarvis_platform/kimi.py +39 -53
- jarvis/jarvis_platform/tongyi.py +108 -126
- jarvis/jarvis_platform/yuanbao.py +112 -120
- jarvis/jarvis_platform_manager/main.py +102 -502
- jarvis/jarvis_platform_manager/service.py +432 -0
- jarvis/jarvis_smart_shell/main.py +99 -33
- jarvis/jarvis_tools/edit_file.py +64 -55
- jarvis/jarvis_tools/file_analyzer.py +17 -25
- jarvis/jarvis_tools/read_code.py +80 -81
- jarvis/jarvis_utils/builtin_replace_map.py +1 -36
- jarvis/jarvis_utils/config.py +14 -4
- jarvis/jarvis_utils/git_utils.py +36 -35
- jarvis/jarvis_utils/methodology.py +12 -17
- {jarvis_ai_assistant-0.1.207.dist-info → jarvis_ai_assistant-0.1.208.dist-info}/METADATA +1 -10
- {jarvis_ai_assistant-0.1.207.dist-info → jarvis_ai_assistant-0.1.208.dist-info}/RECORD +29 -34
- {jarvis_ai_assistant-0.1.207.dist-info → jarvis_ai_assistant-0.1.208.dist-info}/entry_points.txt +0 -1
- jarvis/jarvis_dev/main.py +0 -1247
- jarvis/jarvis_tools/chdir.py +0 -72
- jarvis/jarvis_tools/code_plan.py +0 -218
- jarvis/jarvis_tools/create_code_agent.py +0 -95
- jarvis/jarvis_tools/create_sub_agent.py +0 -82
- jarvis/jarvis_tools/file_operation.py +0 -238
- {jarvis_ai_assistant-0.1.207.dist-info → jarvis_ai_assistant-0.1.208.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.1.207.dist-info → jarvis_ai_assistant-0.1.208.dist-info}/licenses/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.207.dist-info → jarvis_ai_assistant-0.1.208.dist-info}/top_level.txt +0 -0
@@ -5,11 +5,8 @@ import subprocess
|
|
5
5
|
import tempfile
|
6
6
|
from typing import Any, Dict, List
|
7
7
|
|
8
|
-
from yaspin import yaspin
|
9
|
-
|
10
8
|
from jarvis.jarvis_agent import Agent
|
11
|
-
from jarvis.jarvis_code_analysis.checklists.loader import
|
12
|
-
get_language_checklist
|
9
|
+
from jarvis.jarvis_code_analysis.checklists.loader import get_language_checklist
|
13
10
|
from jarvis.jarvis_platform.registry import PlatformRegistry
|
14
11
|
from jarvis.jarvis_tools.read_code import ReadCodeTool
|
15
12
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
@@ -281,167 +278,165 @@ class CodeReviewTool:
|
|
281
278
|
diff_output = ""
|
282
279
|
|
283
280
|
# Build git diff command based on review type
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
281
|
+
print("📊 正在获取代码变更...")
|
282
|
+
|
283
|
+
if review_type == "commit":
|
284
|
+
if "commit_sha" not in args:
|
285
|
+
return {
|
286
|
+
"success": False,
|
287
|
+
"stdout": {},
|
288
|
+
"stderr": "commit_sha is required for commit review type",
|
289
|
+
}
|
290
|
+
commit_sha = args["commit_sha"].strip()
|
291
|
+
diff_cmd = f"git show {commit_sha} | cat -"
|
292
|
+
|
293
|
+
# Execute git command and get diff output
|
294
|
+
diff_output = subprocess.check_output(
|
295
|
+
diff_cmd, shell=True, text=True
|
296
|
+
)
|
297
|
+
if not diff_output:
|
298
|
+
return {
|
299
|
+
"success": False,
|
300
|
+
"stdout": {},
|
301
|
+
"stderr": "No changes to review",
|
302
|
+
}
|
303
|
+
|
304
|
+
# Extract changed files using git command
|
305
|
+
files_cmd = f"git show --name-only --pretty=format: {commit_sha} | grep -v '^$'"
|
306
|
+
try:
|
307
|
+
files_output = subprocess.check_output(
|
308
|
+
files_cmd, shell=True, text=True
|
298
309
|
)
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
310
|
+
file_paths = [
|
311
|
+
f.strip() for f in files_output.split("\n") if f.strip()
|
312
|
+
]
|
313
|
+
except subprocess.CalledProcessError:
|
314
|
+
# Fallback to regex extraction if git command fails
|
315
|
+
file_pattern = r"diff --git a/.*?\s+b/(.*?)(\n|$)"
|
316
|
+
files = re.findall(file_pattern, diff_output)
|
317
|
+
file_paths = [match[0] for match in files]
|
318
|
+
|
319
|
+
elif review_type == "range":
|
320
|
+
if "start_commit" not in args or "end_commit" not in args:
|
321
|
+
return {
|
322
|
+
"success": False,
|
323
|
+
"stdout": {},
|
324
|
+
"stderr": "start_commit and end_commit are required for range review type",
|
325
|
+
}
|
326
|
+
start_commit = args["start_commit"].strip()
|
327
|
+
end_commit = args["end_commit"].strip()
|
328
|
+
diff_cmd = f"git diff {start_commit}..{end_commit} | cat -"
|
329
|
+
|
330
|
+
# Execute git command and get diff output
|
331
|
+
diff_output = subprocess.check_output(
|
332
|
+
diff_cmd, shell=True, text=True
|
333
|
+
)
|
334
|
+
if not diff_output:
|
335
|
+
return {
|
336
|
+
"success": False,
|
337
|
+
"stdout": {},
|
338
|
+
"stderr": "No changes to review",
|
339
|
+
}
|
340
|
+
|
341
|
+
# Extract changed files using git command
|
342
|
+
files_cmd = f"git diff --name-only {start_commit}..{end_commit}"
|
343
|
+
try:
|
344
|
+
files_output = subprocess.check_output(
|
345
|
+
files_cmd, shell=True, text=True
|
335
346
|
)
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
347
|
+
file_paths = [
|
348
|
+
f.strip() for f in files_output.split("\n") if f.strip()
|
349
|
+
]
|
350
|
+
except subprocess.CalledProcessError:
|
351
|
+
# Fallback to regex extraction if git command fails
|
352
|
+
file_pattern = r"diff --git a/.*?\s+b/(.*?)(\n|$)"
|
353
|
+
files = re.findall(file_pattern, diff_output)
|
354
|
+
file_paths = [match[0] for match in files]
|
355
|
+
|
356
|
+
elif review_type == "file":
|
357
|
+
if "file_path" not in args:
|
358
|
+
return {
|
359
|
+
"success": False,
|
360
|
+
"stdout": {},
|
361
|
+
"stderr": "file_path is required for file review type",
|
362
|
+
}
|
363
|
+
file_path = args["file_path"].strip()
|
364
|
+
file_paths = [file_path]
|
365
|
+
diff_output = ReadCodeTool().execute(
|
366
|
+
{"files": [{"path": file_path}]}
|
367
|
+
)["stdout"]
|
368
|
+
|
369
|
+
else: # current changes
|
370
|
+
diff_cmd = "git diff HEAD | cat -"
|
371
|
+
|
372
|
+
# Execute git command and get diff output
|
373
|
+
diff_output = subprocess.check_output(
|
374
|
+
diff_cmd, shell=True, text=True
|
375
|
+
)
|
376
|
+
if not diff_output:
|
377
|
+
return {
|
378
|
+
"success": False,
|
379
|
+
"stdout": {},
|
380
|
+
"stderr": "No changes to review",
|
381
|
+
}
|
382
|
+
|
383
|
+
# Extract changed files using git command
|
384
|
+
files_cmd = "git diff --name-only HEAD"
|
385
|
+
try:
|
386
|
+
files_output = subprocess.check_output(
|
387
|
+
files_cmd, shell=True, text=True
|
377
388
|
)
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
f.strip() for f in files_output.split("\n") if f.strip()
|
393
|
-
]
|
394
|
-
except subprocess.CalledProcessError:
|
395
|
-
# Fallback to regex extraction if git command fails
|
396
|
-
file_pattern = r"diff --git a/.*?\s+b/(.*?)(\n|$)"
|
397
|
-
files = re.findall(file_pattern, diff_output)
|
398
|
-
file_paths = [match[0] for match in files]
|
399
|
-
|
400
|
-
# Detect languages from the file paths
|
401
|
-
detected_languages = self._detect_languages_from_files(file_paths)
|
402
|
-
|
403
|
-
# Add review type and related information to the diff output
|
404
|
-
review_info = f"""
|
389
|
+
file_paths = [
|
390
|
+
f.strip() for f in files_output.split("\n") if f.strip()
|
391
|
+
]
|
392
|
+
except subprocess.CalledProcessError:
|
393
|
+
# Fallback to regex extraction if git command fails
|
394
|
+
file_pattern = r"diff --git a/.*?\s+b/(.*?)(\n|$)"
|
395
|
+
files = re.findall(file_pattern, diff_output)
|
396
|
+
file_paths = [match[0] for match in files]
|
397
|
+
|
398
|
+
# Detect languages from the file paths
|
399
|
+
detected_languages = self._detect_languages_from_files(file_paths)
|
400
|
+
|
401
|
+
# Add review type and related information to the diff output
|
402
|
+
review_info = f"""
|
405
403
|
----- 代码审查信息 -----
|
406
404
|
审查类型: {review_type}"""
|
407
405
|
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
PrettyOutput.print(diff_output, OutputType.CODE, lang="diff")
|
443
|
-
spinner.text = "代码变更获取完成"
|
444
|
-
spinner.ok("✅")
|
406
|
+
# Add specific information based on review type
|
407
|
+
if review_type == "commit":
|
408
|
+
review_info += f"\n提交SHA: {args['commit_sha']}"
|
409
|
+
elif review_type == "range":
|
410
|
+
review_info += f"\n起始提交: {args['start_commit']}\n结束提交: {args['end_commit']}"
|
411
|
+
elif review_type == "file":
|
412
|
+
review_info += f"\n文件路径: {args['file_path']}"
|
413
|
+
else: # current changes
|
414
|
+
review_info += "\n当前未提交修改"
|
415
|
+
|
416
|
+
# Add file list
|
417
|
+
if file_paths:
|
418
|
+
review_info += "\n\n----- 变更文件列表 -----"
|
419
|
+
for i, path in enumerate(file_paths, 1):
|
420
|
+
review_info += f"\n{i}. {path}"
|
421
|
+
|
422
|
+
# Add language-specific checklists
|
423
|
+
if detected_languages:
|
424
|
+
review_info += "\n\n----- 检测到的编程语言 -----"
|
425
|
+
review_info += f"\n检测到的语言: {', '.join(detected_languages)}"
|
426
|
+
|
427
|
+
review_info += "\n\n----- 语言特定审查清单 -----"
|
428
|
+
for lang in detected_languages:
|
429
|
+
checklist = self._get_language_checklist(lang)
|
430
|
+
if checklist:
|
431
|
+
review_info += f"\n{checklist}"
|
432
|
+
|
433
|
+
review_info += "\n------------------------\n\n"
|
434
|
+
|
435
|
+
# Combine review info with diff output
|
436
|
+
diff_output = review_info + diff_output
|
437
|
+
|
438
|
+
PrettyOutput.print(diff_output, OutputType.CODE, lang="diff")
|
439
|
+
print("✅ 代码变更获取完成")
|
445
440
|
|
446
441
|
system_prompt = """<code_review_guide>
|
447
442
|
<role>
|
@@ -690,22 +685,16 @@ class CodeReviewTool:
|
|
690
685
|
"stdout": "",
|
691
686
|
"stderr": "代码差异太大,无法处理",
|
692
687
|
}
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
else:
|
704
|
-
return {
|
705
|
-
"success": False,
|
706
|
-
"stdout": "",
|
707
|
-
"stderr": "上传代码差异文件失败",
|
708
|
-
}
|
688
|
+
print("📤 正在上传代码差异文件...")
|
689
|
+
upload_success = agent.model.upload_files([temp_file_path])
|
690
|
+
if upload_success:
|
691
|
+
print("✅ 已成功上传代码差异文件")
|
692
|
+
else:
|
693
|
+
return {
|
694
|
+
"success": False,
|
695
|
+
"stdout": "",
|
696
|
+
"stderr": "上传代码差异文件失败",
|
697
|
+
}
|
709
698
|
|
710
699
|
# Prepare the prompt based on upload status
|
711
700
|
if is_large_content:
|