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.
Files changed (35) hide show
  1. jarvis/__init__.py +1 -1
  2. jarvis/jarvis_agent/__init__.py +71 -61
  3. jarvis/jarvis_agent/edit_file_handler.py +42 -46
  4. jarvis/jarvis_agent/jarvis.py +33 -39
  5. jarvis/jarvis_code_agent/code_agent.py +26 -27
  6. jarvis/jarvis_code_agent/lint.py +5 -5
  7. jarvis/jarvis_code_analysis/code_review.py +164 -175
  8. jarvis/jarvis_git_utils/git_commiter.py +147 -152
  9. jarvis/jarvis_methodology/main.py +70 -81
  10. jarvis/jarvis_platform/base.py +21 -17
  11. jarvis/jarvis_platform/kimi.py +39 -53
  12. jarvis/jarvis_platform/tongyi.py +108 -126
  13. jarvis/jarvis_platform/yuanbao.py +112 -120
  14. jarvis/jarvis_platform_manager/main.py +102 -502
  15. jarvis/jarvis_platform_manager/service.py +432 -0
  16. jarvis/jarvis_smart_shell/main.py +99 -33
  17. jarvis/jarvis_tools/edit_file.py +64 -55
  18. jarvis/jarvis_tools/file_analyzer.py +17 -25
  19. jarvis/jarvis_tools/read_code.py +80 -81
  20. jarvis/jarvis_utils/builtin_replace_map.py +1 -36
  21. jarvis/jarvis_utils/config.py +14 -4
  22. jarvis/jarvis_utils/git_utils.py +36 -35
  23. jarvis/jarvis_utils/methodology.py +12 -17
  24. {jarvis_ai_assistant-0.1.207.dist-info → jarvis_ai_assistant-0.1.208.dist-info}/METADATA +1 -10
  25. {jarvis_ai_assistant-0.1.207.dist-info → jarvis_ai_assistant-0.1.208.dist-info}/RECORD +29 -34
  26. {jarvis_ai_assistant-0.1.207.dist-info → jarvis_ai_assistant-0.1.208.dist-info}/entry_points.txt +0 -1
  27. jarvis/jarvis_dev/main.py +0 -1247
  28. jarvis/jarvis_tools/chdir.py +0 -72
  29. jarvis/jarvis_tools/code_plan.py +0 -218
  30. jarvis/jarvis_tools/create_code_agent.py +0 -95
  31. jarvis/jarvis_tools/create_sub_agent.py +0 -82
  32. jarvis/jarvis_tools/file_operation.py +0 -238
  33. {jarvis_ai_assistant-0.1.207.dist-info → jarvis_ai_assistant-0.1.208.dist-info}/WHEEL +0 -0
  34. {jarvis_ai_assistant-0.1.207.dist-info → jarvis_ai_assistant-0.1.208.dist-info}/licenses/LICENSE +0 -0
  35. {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
- with yaspin(text="正在获取代码变更...", color="cyan") as spinner:
285
- if review_type == "commit":
286
- if "commit_sha" not in args:
287
- return {
288
- "success": False,
289
- "stdout": {},
290
- "stderr": "commit_sha is required for commit review type",
291
- }
292
- commit_sha = args["commit_sha"].strip()
293
- diff_cmd = f"git show {commit_sha} | cat -"
294
-
295
- # Execute git command and get diff output
296
- diff_output = subprocess.check_output(
297
- diff_cmd, shell=True, text=True
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
- if not diff_output:
300
- return {
301
- "success": False,
302
- "stdout": {},
303
- "stderr": "No changes to review",
304
- }
305
-
306
- # Extract changed files using git command
307
- files_cmd = f"git show --name-only --pretty=format: {commit_sha} | grep -v '^$'"
308
- try:
309
- files_output = subprocess.check_output(
310
- files_cmd, shell=True, text=True
311
- )
312
- file_paths = [
313
- f.strip() for f in files_output.split("\n") if f.strip()
314
- ]
315
- except subprocess.CalledProcessError:
316
- # Fallback to regex extraction if git command fails
317
- file_pattern = r"diff --git a/.*?\s+b/(.*?)(\n|$)"
318
- files = re.findall(file_pattern, diff_output)
319
- file_paths = [match[0] for match in files]
320
-
321
- elif review_type == "range":
322
- if "start_commit" not in args or "end_commit" not in args:
323
- return {
324
- "success": False,
325
- "stdout": {},
326
- "stderr": "start_commit and end_commit are required for range review type",
327
- }
328
- start_commit = args["start_commit"].strip()
329
- end_commit = args["end_commit"].strip()
330
- diff_cmd = f"git diff {start_commit}..{end_commit} | cat -"
331
-
332
- # Execute git command and get diff output
333
- diff_output = subprocess.check_output(
334
- diff_cmd, shell=True, text=True
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
- if not diff_output:
337
- return {
338
- "success": False,
339
- "stdout": {},
340
- "stderr": "No changes to review",
341
- }
342
-
343
- # Extract changed files using git command
344
- files_cmd = f"git diff --name-only {start_commit}..{end_commit}"
345
- try:
346
- files_output = subprocess.check_output(
347
- files_cmd, shell=True, text=True
348
- )
349
- file_paths = [
350
- f.strip() for f in files_output.split("\n") if f.strip()
351
- ]
352
- except subprocess.CalledProcessError:
353
- # Fallback to regex extraction if git command fails
354
- file_pattern = r"diff --git a/.*?\s+b/(.*?)(\n|$)"
355
- files = re.findall(file_pattern, diff_output)
356
- file_paths = [match[0] for match in files]
357
-
358
- elif review_type == "file":
359
- if "file_path" not in args:
360
- return {
361
- "success": False,
362
- "stdout": {},
363
- "stderr": "file_path is required for file review type",
364
- }
365
- file_path = args["file_path"].strip()
366
- file_paths = [file_path]
367
- diff_output = ReadCodeTool().execute(
368
- {"files": [{"path": file_path}]}
369
- )["stdout"]
370
-
371
- else: # current changes
372
- diff_cmd = "git diff HEAD | cat -"
373
-
374
- # Execute git command and get diff output
375
- diff_output = subprocess.check_output(
376
- diff_cmd, shell=True, text=True
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
- if not diff_output:
379
- return {
380
- "success": False,
381
- "stdout": {},
382
- "stderr": "No changes to review",
383
- }
384
-
385
- # Extract changed files using git command
386
- files_cmd = "git diff --name-only HEAD"
387
- try:
388
- files_output = subprocess.check_output(
389
- files_cmd, shell=True, text=True
390
- )
391
- file_paths = [
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
- # Add specific information based on review type
409
- if review_type == "commit":
410
- review_info += f"\n提交SHA: {args['commit_sha']}"
411
- elif review_type == "range":
412
- review_info += f"\n起始提交: {args['start_commit']}\n结束提交: {args['end_commit']}"
413
- elif review_type == "file":
414
- review_info += f"\n文件路径: {args['file_path']}"
415
- else: # current changes
416
- review_info += "\n当前未提交修改"
417
-
418
- # Add file list
419
- if file_paths:
420
- review_info += "\n\n----- 变更文件列表 -----"
421
- for i, path in enumerate(file_paths, 1):
422
- review_info += f"\n{i}. {path}"
423
-
424
- # Add language-specific checklists
425
- if detected_languages:
426
- review_info += "\n\n----- 检测到的编程语言 -----"
427
- review_info += (
428
- f"\n检测到的语言: {', '.join(detected_languages)}"
429
- )
430
-
431
- review_info += "\n\n----- 语言特定审查清单 -----"
432
- for lang in detected_languages:
433
- checklist = self._get_language_checklist(lang)
434
- if checklist:
435
- review_info += f"\n{checklist}"
436
-
437
- review_info += "\n------------------------\n\n"
438
-
439
- # Combine review info with diff output
440
- diff_output = review_info + diff_output
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
- with yaspin(
695
- text="正在上传代码差异文件...", color="cyan"
696
- ) as spinner:
697
- upload_success = agent.model.upload_files([temp_file_path])
698
- if upload_success:
699
- spinner.ok("")
700
- PrettyOutput.print(
701
- f"已成功上传代码差异文件", OutputType.SUCCESS
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: