jarvis-ai-assistant 0.1.166__tar.gz → 0.1.167__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.

Files changed (109) hide show
  1. {jarvis_ai_assistant-0.1.166/src/jarvis_ai_assistant.egg-info → jarvis_ai_assistant-0.1.167}/PKG-INFO +7 -4
  2. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/README.md +6 -2
  3. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/pyproject.toml +1 -1
  4. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/setup.py +1 -1
  5. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/__init__.py +1 -1
  6. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_agent/__init__.py +3 -2
  7. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_code_analysis/code_review.py +4 -4
  8. jarvis_ai_assistant-0.1.167/src/jarvis/jarvis_git_details/main.py +269 -0
  9. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_platform/base.py +14 -2
  10. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_platform/kimi.py +4 -0
  11. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_platform/yuanbao.py +4 -0
  12. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_smart_shell/main.py +12 -2
  13. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_tools/read_webpage.py +5 -0
  14. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_tools/search_web.py +6 -1
  15. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_utils/config.py +9 -0
  16. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_utils/git_utils.py +40 -1
  17. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_utils/utils.py +8 -0
  18. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167/src/jarvis_ai_assistant.egg-info}/PKG-INFO +7 -4
  19. jarvis_ai_assistant-0.1.166/src/jarvis/jarvis_git_details/main.py +0 -181
  20. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/LICENSE +0 -0
  21. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/MANIFEST.in +0 -0
  22. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/setup.cfg +0 -0
  23. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_agent/builtin_input_handler.py +0 -0
  24. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_agent/file_input_handler.py +0 -0
  25. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_agent/jarvis.py +0 -0
  26. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_agent/main.py +0 -0
  27. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_agent/output_handler.py +0 -0
  28. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_agent/shell_input_handler.py +0 -0
  29. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_code_agent/__init__.py +0 -0
  30. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_code_agent/code_agent.py +0 -0
  31. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_code_analysis/checklists/__init__.py +0 -0
  32. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_code_analysis/checklists/c_cpp.py +0 -0
  33. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_code_analysis/checklists/csharp.py +0 -0
  34. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_code_analysis/checklists/data_format.py +0 -0
  35. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_code_analysis/checklists/devops.py +0 -0
  36. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_code_analysis/checklists/docs.py +0 -0
  37. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_code_analysis/checklists/go.py +0 -0
  38. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_code_analysis/checklists/infrastructure.py +0 -0
  39. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_code_analysis/checklists/java.py +0 -0
  40. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_code_analysis/checklists/javascript.py +0 -0
  41. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_code_analysis/checklists/kotlin.py +0 -0
  42. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_code_analysis/checklists/loader.py +0 -0
  43. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_code_analysis/checklists/php.py +0 -0
  44. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_code_analysis/checklists/python.py +0 -0
  45. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_code_analysis/checklists/ruby.py +0 -0
  46. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_code_analysis/checklists/rust.py +0 -0
  47. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_code_analysis/checklists/shell.py +0 -0
  48. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_code_analysis/checklists/sql.py +0 -0
  49. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_code_analysis/checklists/swift.py +0 -0
  50. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_code_analysis/checklists/web.py +0 -0
  51. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_data/huggingface.tar.gz +0 -0
  52. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_dev/main.py +0 -0
  53. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_git_details/__init__.py +0 -0
  54. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_git_squash/__init__.py +0 -0
  55. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_git_squash/main.py +0 -0
  56. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_git_utils/git_commiter.py +0 -0
  57. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_lsp/base.py +0 -0
  58. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_lsp/cpp.py +0 -0
  59. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_lsp/go.py +0 -0
  60. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_lsp/python.py +0 -0
  61. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_lsp/registry.py +0 -0
  62. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_lsp/rust.py +0 -0
  63. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_mcp/__init__.py +0 -0
  64. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_mcp/sse_mcp_client.py +0 -0
  65. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_mcp/stdio_mcp_client.py +0 -0
  66. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_methodology/main.py +0 -0
  67. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_multi_agent/__init__.py +0 -0
  68. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_multi_agent/main.py +0 -0
  69. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_platform/__init__.py +0 -0
  70. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_platform/human.py +0 -0
  71. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_platform/openai.py +0 -0
  72. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_platform/registry.py +0 -0
  73. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_platform_manager/__init__.py +0 -0
  74. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_platform_manager/main.py +0 -0
  75. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_smart_shell/__init__.py +0 -0
  76. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_tools/__init__.py +0 -0
  77. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_tools/ask_codebase.py +0 -0
  78. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_tools/ask_user.py +0 -0
  79. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_tools/base.py +0 -0
  80. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_tools/chdir.py +0 -0
  81. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_tools/code_plan.py +0 -0
  82. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_tools/create_code_agent.py +0 -0
  83. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_tools/create_sub_agent.py +0 -0
  84. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_tools/edit_file.py +0 -0
  85. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_tools/execute_script.py +0 -0
  86. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_tools/file_analyzer.py +0 -0
  87. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_tools/file_operation.py +0 -0
  88. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_tools/find_methodology.py +0 -0
  89. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_tools/generate_new_tool.py +0 -0
  90. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_tools/lsp_get_diagnostics.py +0 -0
  91. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_tools/methodology.py +0 -0
  92. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_tools/read_code.py +0 -0
  93. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_tools/registry.py +0 -0
  94. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_tools/rewrite_file.py +0 -0
  95. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_tools/virtual_tty.py +0 -0
  96. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_utils/__init__.py +0 -0
  97. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_utils/builtin_replace_map.py +0 -0
  98. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_utils/embedding.py +0 -0
  99. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_utils/file_processors.py +0 -0
  100. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_utils/globals.py +0 -0
  101. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_utils/input.py +0 -0
  102. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_utils/methodology.py +0 -0
  103. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_utils/output.py +0 -0
  104. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis/jarvis_utils/tag.py +0 -0
  105. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis_ai_assistant.egg-info/SOURCES.txt +0 -0
  106. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis_ai_assistant.egg-info/dependency_links.txt +0 -0
  107. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis_ai_assistant.egg-info/entry_points.txt +0 -0
  108. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis_ai_assistant.egg-info/requires.txt +0 -0
  109. {jarvis_ai_assistant-0.1.166 → jarvis_ai_assistant-0.1.167}/src/jarvis_ai_assistant.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.2
2
2
  Name: jarvis-ai-assistant
3
- Version: 0.1.166
3
+ Version: 0.1.167
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
@@ -65,7 +65,6 @@ Requires-Dist: build; extra == "dev"
65
65
  Requires-Dist: twine; extra == "dev"
66
66
  Dynamic: author
67
67
  Dynamic: home-page
68
- Dynamic: license-file
69
68
  Dynamic: requires-python
70
69
 
71
70
  # 🤖 Jarvis AI 助手
@@ -167,7 +166,6 @@ JARVIS_THINKING_MODEL=gpt-4o
167
166
 
168
167
  OPENAI_API_KEY=<OpenAI API Key>
169
168
  OPENAI_API_BASE=https://api.openai.com/v1 # 可选,默认为官方API地址
170
- OPENAI_MODEL_NAME=gpt-4o # 可选,覆盖JARVIS_MODEL设置
171
169
  ```
172
170
 
173
171
  配置说明:
@@ -213,6 +211,9 @@ OPENAI_MODEL_NAME=gpt-4o # 可选,覆盖JARVIS_MODEL设置
213
211
  | `JARVIS_EXECUTE_TOOL_CONFIRM` | false | 执行工具前是否需要确认 |
214
212
  | `JARVIS_CONFIRM_BEFORE_APPLY_PATCH` | true | 应用补丁前是否需要确认 |
215
213
  | `JARVIS_MAX_TOOL_CALL_COUNT` | 20 | 最大连续工具调用次数 |
214
+ | `JARVIS_AUTO_UPDATE` | true | 是否自动更新Jarvis(仅在以git仓库方式安装时有效) |
215
+
216
+ 所有配置编写到`~/.jarvis/env`文件中即可生效。
216
217
 
217
218
 
218
219
  ---
@@ -409,3 +410,5 @@ class CustomPlatform(BasePlatform):
409
410
  <div align="center">
410
411
  由 Jarvis 团队用 ❤️ 制作
411
412
  </div>
413
+
414
+ ![Jarvis技术支持群](docs/images/wechat.png)
@@ -97,7 +97,6 @@ JARVIS_THINKING_MODEL=gpt-4o
97
97
 
98
98
  OPENAI_API_KEY=<OpenAI API Key>
99
99
  OPENAI_API_BASE=https://api.openai.com/v1 # 可选,默认为官方API地址
100
- OPENAI_MODEL_NAME=gpt-4o # 可选,覆盖JARVIS_MODEL设置
101
100
  ```
102
101
 
103
102
  配置说明:
@@ -143,6 +142,9 @@ OPENAI_MODEL_NAME=gpt-4o # 可选,覆盖JARVIS_MODEL设置
143
142
  | `JARVIS_EXECUTE_TOOL_CONFIRM` | false | 执行工具前是否需要确认 |
144
143
  | `JARVIS_CONFIRM_BEFORE_APPLY_PATCH` | true | 应用补丁前是否需要确认 |
145
144
  | `JARVIS_MAX_TOOL_CALL_COUNT` | 20 | 最大连续工具调用次数 |
145
+ | `JARVIS_AUTO_UPDATE` | true | 是否自动更新Jarvis(仅在以git仓库方式安装时有效) |
146
+
147
+ 所有配置编写到`~/.jarvis/env`文件中即可生效。
146
148
 
147
149
 
148
150
  ---
@@ -338,4 +340,6 @@ class CustomPlatform(BasePlatform):
338
340
  ---
339
341
  <div align="center">
340
342
  由 Jarvis 团队用 ❤️ 制作
341
- </div>
343
+ </div>
344
+
345
+ ![Jarvis技术支持群](docs/images/wechat.png)
@@ -8,7 +8,7 @@ default = true
8
8
 
9
9
  [project]
10
10
  name = "jarvis-ai-assistant"
11
- version = "0.1.166"
11
+ version = "0.1.167"
12
12
  description = "Jarvis: An AI assistant that uses tools to interact with the system"
13
13
  readme = "README.md"
14
14
  authors = [{ name = "skyfire", email = "skyfireitdiy@hotmail.com" }]
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
3
3
 
4
4
  setup(
5
5
  name="jarvis-ai-assistant",
6
- version="0.1.166",
6
+ version="0.1.167",
7
7
  author="skyfire",
8
8
  author_email="skyfireitdiy@hotmail.com",
9
9
  description="An AI assistant that uses various tools to interact with the system",
@@ -1,4 +1,4 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  """Jarvis AI Assistant"""
3
3
 
4
- __version__ = "0.1.166"
4
+ __version__ = "0.1.167"
@@ -332,7 +332,7 @@ class Agent:
332
332
  action_handlers = '\n'.join([f'- {handler.name()}' for handler in self.output_handler])
333
333
 
334
334
  # 任务完成提示
335
- complete_prompt = f"并输出{ot('!!!COMPLETE!!!')}" if need_complete and self.auto_complete else ""
335
+ complete_prompt = f"3. 输出{ot('!!!COMPLETE!!!')}" if need_complete and self.auto_complete else ""
336
336
 
337
337
  addon_prompt = f"""
338
338
  <addon>
@@ -353,9 +353,10 @@ class Agent:
353
353
  </actions>
354
354
 
355
355
  <completion>
356
- 如果任务已完成{complete_prompt},请:
356
+ 如果任务已完成,请:
357
357
  1. 说明完成原因
358
358
  2. 保持输出格式规范
359
+ {complete_prompt}
359
360
  </completion>
360
361
  </addon>
361
362
  """
@@ -8,7 +8,6 @@ import tempfile
8
8
  from yaspin import yaspin
9
9
  from jarvis.jarvis_platform.registry import PlatformRegistry
10
10
  from jarvis.jarvis_tools.read_code import ReadCodeTool
11
- from jarvis.jarvis_tools.registry import ToolRegistry
12
11
  from jarvis.jarvis_agent import Agent
13
12
 
14
13
  from jarvis.jarvis_utils.output import OutputType, PrettyOutput
@@ -488,7 +487,7 @@ class CodeReviewTool:
488
487
 
489
488
  我将分析上传的代码差异文件,进行全面的代码审查。
490
489
  </code_review_guide>"""
491
-
490
+ from jarvis.jarvis_tools.registry import ToolRegistry
492
491
  tool_registry = ToolRegistry()
493
492
  tool_registry.dont_use_tools(["code_review"])
494
493
  agent = Agent(
@@ -554,8 +553,9 @@ class CodeReviewTool:
554
553
  如果检测到了特定编程语言,请参考语言特定的审查清单进行评估,并在报告中包含相关分析。
555
554
  </notes>
556
555
 
556
+ 输出格式:
557
557
  {ot("REPORT")}
558
- [在此处插入完整的审查报告]
558
+ [在此处插入完整MARKDOWN格式的审查报告]
559
559
  {ct("REPORT")}""",
560
560
  output_handler=[tool_registry],
561
561
  platform=PlatformRegistry().get_thinking_platform(),
@@ -654,7 +654,7 @@ def extract_code_report(result: str) -> str:
654
654
  sm = re.search(ot("REPORT")+r'\n(.*?)\n'+ct("REPORT"), result, re.DOTALL)
655
655
  if sm:
656
656
  return sm.group(1)
657
- return ""
657
+ return result
658
658
 
659
659
  def main():
660
660
  """CLI entry point"""
@@ -0,0 +1,269 @@
1
+ # -*- coding: utf-8 -*-
2
+ """Git Commit分析工具模块
3
+
4
+ 该模块提供了一个GitCommitAnalyzer类,用于获取和分析指定Git commit的详细信息,
5
+ 包括提交信息、修改内容以及详细的功能、原因和逻辑分析。
6
+ """
7
+
8
+ import os
9
+ import re
10
+ import subprocess
11
+ from typing import Dict, Any
12
+
13
+ from jarvis.jarvis_agent import Agent
14
+ from jarvis.jarvis_platform.registry import PlatformRegistry
15
+ from jarvis.jarvis_tools.registry import ToolRegistry
16
+ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
17
+ from jarvis.jarvis_utils.tag import ct, ot
18
+ from jarvis.jarvis_utils.utils import init_env
19
+
20
+
21
+ class GitCommitAnalyzer:
22
+ """Git Commit分析器
23
+
24
+ 该类用于获取和分析指定Git commit的详细信息,包括:
25
+ - 完整的提交信息
26
+ - 修改的文件列表和状态
27
+ - 修改的功能、原因和逻辑分析
28
+ """
29
+
30
+ def execute(self, args: Dict[str, Any]) -> Dict[str, Any]:
31
+ """执行commit分析
32
+
33
+ Args:
34
+ args: 包含commit_sha/commit_range和root_dir的参数字典
35
+ commit_sha: 单个commit的SHA
36
+ commit_range: 两个commit的SHA范围,格式为"commit1..commit2"
37
+ root_dir: 代码库根目录
38
+
39
+ Returns:
40
+ 包含分析结果的字典
41
+ """
42
+ try:
43
+ commit_sha = args.get("commit_sha")
44
+ commit_range = args.get("commit_range")
45
+ root_dir = args.get("root_dir", ".")
46
+
47
+ if commit_range:
48
+ return self.analyze_commit_range(commit_range, root_dir)
49
+ elif commit_sha:
50
+ return self.analyze_single_commit(commit_sha, root_dir)
51
+ else:
52
+ raise ValueError("Either commit_sha or commit_range must be provided")
53
+ except Exception as e:
54
+ return {
55
+ "success": False,
56
+ "stdout": {},
57
+ "stderr": f"Failed to analyze commit: {str(e)}"
58
+ }
59
+
60
+ def analyze_single_commit(self, commit_sha: str, root_dir: str) -> Dict[str, Any]:
61
+ """分析单个commit
62
+
63
+ Args:
64
+ commit_sha: commit的SHA
65
+ root_dir: 代码库根目录
66
+
67
+ Returns:
68
+ 包含分析结果的字典
69
+ """
70
+ original_dir = os.getcwd()
71
+ try:
72
+ os.chdir(root_dir)
73
+
74
+ # 获取commit详细信息
75
+ commit_info = subprocess.check_output(
76
+ f"git show {commit_sha} --pretty=fuller",
77
+ shell=True,
78
+ text=True
79
+ )
80
+
81
+ # 获取commit修改内容
82
+ diff_content = subprocess.check_output(
83
+ f"git show {commit_sha} --patch",
84
+ shell=True,
85
+ text=True
86
+ )
87
+
88
+ # 分析commit的功能、原因和逻辑
89
+ analysis_result = self._analyze_diff_content(diff_content)
90
+
91
+ return {
92
+ "success": True,
93
+ "stdout": {
94
+ "commit_info": commit_info,
95
+ "diff_content": diff_content,
96
+ "analysis_result": analysis_result
97
+ },
98
+ "stderr": ""
99
+ }
100
+ except subprocess.CalledProcessError as error:
101
+ return {
102
+ "success": False,
103
+ "stdout": {},
104
+ "stderr": f"Failed to analyze commit: {str(error)}"
105
+ }
106
+ finally:
107
+ os.chdir(original_dir)
108
+
109
+ def analyze_commit_range(self, commit_range: str, root_dir: str) -> Dict[str, Any]:
110
+ """分析两个commit之间的代码变更
111
+
112
+ Args:
113
+ commit_range: 两个commit的SHA范围,格式为"commit1..commit2"
114
+ root_dir: 代码库根目录
115
+
116
+ Returns:
117
+ 包含分析结果的字典
118
+ """
119
+ original_dir = os.getcwd()
120
+ try:
121
+ os.chdir(root_dir)
122
+
123
+ # 获取commit范围差异
124
+ diff_content = subprocess.check_output(
125
+ f"git diff {commit_range} --patch",
126
+ shell=True,
127
+ text=True
128
+ )
129
+
130
+ # 获取commit范围信息
131
+ commit_info = subprocess.check_output(
132
+ f"git log {commit_range} --pretty=fuller",
133
+ shell=True,
134
+ text=True
135
+ )
136
+
137
+ # 使用相同的分析方法处理差异内容
138
+ analysis_result = self._analyze_diff_content(diff_content)
139
+
140
+ return {
141
+ "success": True,
142
+ "stdout": {
143
+ "commit_info": commit_info,
144
+ "diff_content": diff_content,
145
+ "analysis_result": analysis_result
146
+ },
147
+ "stderr": ""
148
+ }
149
+ except subprocess.CalledProcessError as error:
150
+ return {
151
+ "success": False,
152
+ "stdout": {},
153
+ "stderr": f"Failed to analyze commit range: {str(error)}"
154
+ }
155
+ finally:
156
+ os.chdir(original_dir)
157
+
158
+ def _analyze_diff_content(self, diff_content: str) -> str:
159
+ """分析diff内容并生成报告
160
+
161
+ Args:
162
+ diff_content: git diff或git show的输出内容
163
+
164
+ Returns:
165
+ 分析结果字符串
166
+ """
167
+ system_prompt = """你是一位资深代码分析专家,拥有多年代码审查和重构经验。你需要对Git commit进行深入分析,包括:
168
+ 1. 修改的功能:明确说明本次commit实现或修改了哪些功能
169
+ 2. 修改的原因:分析为什么要进行这些修改(如修复bug、优化性能、添加新功能等)
170
+ 3. 修改的逻辑:详细说明代码修改的具体实现逻辑和思路
171
+ 4. 影响范围:评估本次修改可能影响的其他模块或功能
172
+ 5. 代码质量:分析代码风格、可读性和可维护性
173
+ 6. 测试覆盖:评估是否需要添加或修改测试用例
174
+ 7. 最佳实践:检查代码是否符合行业最佳实践和项目规范
175
+
176
+ 请确保分析内容:
177
+ - 准确反映commit的实际修改
178
+ - 提供足够的技术细节
179
+ - 保持结构清晰,便于理解
180
+ - 重点关注关键修改和潜在风险"""
181
+
182
+ tool_registry = ToolRegistry()
183
+ agent = Agent(
184
+ system_prompt=system_prompt,
185
+ name="Commit Analysis Agent",
186
+ summary_prompt=f"""请生成一份详细的commit分析报告,包含以下内容:
187
+ {ot("REPORT")}
188
+ # 功能分析
189
+ [说明本次commit实现或修改了哪些功能]
190
+
191
+ # 修改原因
192
+ [分析进行这些修改的原因,如修复bug、优化性能、添加新功能等]
193
+
194
+ # 实现逻辑
195
+ [详细说明代码修改的具体实现逻辑和思路]
196
+
197
+ # 影响范围
198
+ [评估本次修改可能影响的其他模块或功能]
199
+
200
+ # 代码质量
201
+ [分析代码风格、可读性和可维护性]
202
+
203
+ # 测试覆盖
204
+ [评估是否需要添加或修改测试用例]
205
+
206
+ # 最佳实践
207
+ [检查代码是否符合行业最佳实践和项目规范]
208
+ {ct("REPORT")}""",
209
+ output_handler=[tool_registry],
210
+ platform=PlatformRegistry().get_thinking_platform(),
211
+ auto_complete=True
212
+ )
213
+
214
+ return agent.run(diff_content)
215
+
216
+
217
+ def extract_analysis_report(result: str) -> str:
218
+ """从分析结果中提取报告内容
219
+
220
+ Args:
221
+ result: 包含REPORT标签的完整分析结果字符串
222
+
223
+ Returns:
224
+ 提取的报告内容,如果未找到REPORT标签则返回空字符串
225
+ """
226
+ search_match = re.search(ot("REPORT")+r'\n(.*?)\n'+ct("REPORT"), result, re.DOTALL)
227
+ if search_match:
228
+ return search_match.group(1)
229
+ return result
230
+
231
+
232
+ def main():
233
+ """主函数,用于命令行接口"""
234
+ import argparse
235
+
236
+ init_env()
237
+
238
+ parser = argparse.ArgumentParser(description='Git Commit Analyzer')
239
+ group = parser.add_mutually_exclusive_group(required=True)
240
+ group.add_argument('commit', nargs='?', help='Commit SHA to analyze')
241
+ group.add_argument('--range', type=str, help='Commit range to analyze (commit1..commit2)')
242
+ parser.add_argument('--root-dir', type=str, help='Root directory of the codebase', default=".")
243
+
244
+ args = parser.parse_args()
245
+
246
+ analyzer = GitCommitAnalyzer()
247
+ if args.range:
248
+ result = analyzer.execute({
249
+ "commit_range": args.range,
250
+ "root_dir": args.root_dir
251
+ })
252
+ else:
253
+ result = analyzer.execute({
254
+ "commit_sha": args.commit,
255
+ "root_dir": args.root_dir
256
+ })
257
+
258
+ if result["success"]:
259
+ PrettyOutput.section("Commit Information:", OutputType.SUCCESS)
260
+ PrettyOutput.print(result["stdout"]["commit_info"], OutputType.CODE)
261
+ PrettyOutput.section("Analysis Report:", OutputType.SUCCESS)
262
+ report = extract_analysis_report(result["stdout"]["analysis_result"])
263
+ PrettyOutput.print(report, OutputType.SUCCESS, lang="markdown")
264
+ else:
265
+ PrettyOutput.print(result["stderr"], OutputType.WARNING)
266
+
267
+
268
+ if __name__ == "__main__":
269
+ main()
@@ -40,13 +40,20 @@ class BasePlatform(ABC):
40
40
  raise NotImplementedError("upload_files is not implemented")
41
41
 
42
42
  def chat_big_content(self, content: str, prompt: str) -> str:
43
+ # 检查content大小不超过10MB
44
+ if len(content.encode('utf-8')) > 10 * 1024 * 1024:
45
+ return "Error: Content size exceeds 10MB limit"
46
+
43
47
  prefix_prompt = f"""
44
48
  我将分多次提供大量的上下文内容,在我明确告诉你内容已经全部提供完毕之前,每次仅需要输出“已收到”。
45
49
  """
46
50
  self.chat_until_success(prefix_prompt)
47
- split_content = split_text_into_chunks(content, get_max_input_token_count() - 1024)
51
+ split_content = split_text_into_chunks(content, get_max_input_token_count() - 1024, get_max_input_token_count() - 2048)
52
+ submit_count = 0
48
53
  for chunk in split_content:
49
- self.chat_until_success(f"<part_content>{chunk}</part_content>")
54
+ submit_count += 1
55
+ PrettyOutput.print(f"已提交{submit_count}次(总{len(split_content)}次)", OutputType.INFO)
56
+ self.chat_until_success(f"<part_content>{chunk}</part_content>请返回已收到")
50
57
  return self.chat_until_success(f"内容已经全部提供完毕\n\n{prompt}")
51
58
 
52
59
 
@@ -109,3 +116,8 @@ class BasePlatform(ABC):
109
116
  def set_web(self, web: bool):
110
117
  """Set web flag"""
111
118
  self.web = web
119
+
120
+ @abstractmethod
121
+ def support_web(self) -> bool:
122
+ """Check if platform supports web functionality"""
123
+ raise NotImplementedError("support_web is not implemented")
@@ -413,3 +413,7 @@ class KimiModel(BasePlatform):
413
413
  def name(self) -> str:
414
414
  """Model name"""
415
415
  return "kimi"
416
+
417
+ def support_web(self) -> bool:
418
+ """Kimi平台支持web功能"""
419
+ return True
@@ -534,3 +534,7 @@ class YuanbaoPlatform(BasePlatform):
534
534
  def name(self) -> str:
535
535
  """模型名称"""
536
536
  return self.model_name
537
+
538
+ def support_web(self) -> bool:
539
+ """Yuanbao平台支持web功能"""
540
+ return True
@@ -17,6 +17,8 @@ def execute_command(command: str, should_run: bool) -> None:
17
17
  os.system(command)
18
18
 
19
19
 
20
+
21
+
20
22
  def install_fish_completion() -> int:
21
23
  """Install fish shell command completion with interactive choice
22
24
 
@@ -110,7 +112,7 @@ def process_request(request: str) -> Optional[str]:
110
112
  except Exception:
111
113
  return None
112
114
 
113
- def main():
115
+ def main() -> int:
114
116
  # 创建参数解析器
115
117
  init_env()
116
118
  parser = argparse.ArgumentParser(
@@ -135,6 +137,12 @@ Example:
135
137
 
136
138
  # install子命令
137
139
  install_parser = subparsers.add_parser('install', help='安装fish shell的命令补全功能')
140
+ install_parser.add_argument(
141
+ "--shell",
142
+ choices=["fish"],
143
+ default="fish",
144
+ help="指定shell类型(仅支持fish)"
145
+ )
138
146
 
139
147
 
140
148
  # 解析参数
@@ -144,9 +152,11 @@ Example:
144
152
 
145
153
  # 处理install命令
146
154
  if args.command == "install":
155
+ if args.shell != "fish":
156
+ print(f"错误: 不支持的shell类型: {args.shell}, 仅支持fish")
157
+ return 1
147
158
  return install_fish_completion()
148
159
 
149
-
150
160
  # 处理request命令
151
161
  if not args.request:
152
162
  # 检查是否在交互式终端中运行
@@ -59,3 +59,8 @@ class WebpageTool:
59
59
  "stdout": "",
60
60
  "stderr": f"Failed to parse webpage: {str(e)}"
61
61
  }
62
+
63
+ @staticmethod
64
+ def check() -> bool:
65
+ """检查当前平台是否支持web功能"""
66
+ return PlatformRegistry().get_normal_platform().support_web()
@@ -23,4 +23,9 @@ class SearchWebTool:
23
23
  "stdout": model.chat_until_success(query), # type: ignore
24
24
  "stderr": "",
25
25
  "success": True,
26
- }
26
+ }
27
+
28
+ @staticmethod
29
+ def check() -> bool:
30
+ """检查当前平台是否支持web功能"""
31
+ return PlatformRegistry().get_normal_platform().support_web()
@@ -143,3 +143,12 @@ def get_data_dir() -> str:
143
143
  if not data_path:
144
144
  return os.path.expanduser('~/.jarvis')
145
145
  return data_path
146
+
147
+ def get_auto_update() -> bool:
148
+ """
149
+ 获取是否自动更新git仓库。
150
+
151
+ 返回:
152
+ bool: 如果需要自动更新则返回True,默认为True
153
+ """
154
+ return os.getenv('JARVIS_AUTO_UPDATE', 'true') == 'true'
@@ -13,7 +13,7 @@ import os
13
13
  import re
14
14
  import subprocess
15
15
  from typing import List, Tuple, Dict
16
- from jarvis.jarvis_utils.config import is_confirm_before_apply_patch
16
+ from jarvis.jarvis_utils.config import get_auto_update, is_confirm_before_apply_patch
17
17
  from jarvis.jarvis_utils.output import PrettyOutput, OutputType
18
18
  from jarvis.jarvis_utils.utils import user_confirm
19
19
  def find_git_root(start_dir: str = ".") -> str:
@@ -294,3 +294,42 @@ def is_file_in_git_repo(filepath: str) -> bool:
294
294
  return os.path.abspath(filepath).startswith(os.path.abspath(repo_root))
295
295
  except:
296
296
  return False
297
+
298
+
299
+ def check_and_update_git_repo(repo_path: str) -> bool:
300
+ """检查并更新git仓库
301
+
302
+ 参数:
303
+ repo_path: 仓库路径
304
+
305
+ 返回:
306
+ bool: 是否执行了更新
307
+ """
308
+ curr_dir = os.path.abspath(os.getcwd())
309
+ git_root = find_git_root(repo_path)
310
+ if git_root is None:
311
+ return False
312
+
313
+ try:
314
+ if not get_auto_update():
315
+ return False
316
+ # 检查是否有未提交的修改
317
+ if has_uncommitted_changes():
318
+ return False
319
+
320
+ # 获取远程更新
321
+ subprocess.run(["git", "fetch"], cwd=git_root, check=True)
322
+ # 检查本地是否落后
323
+ result = subprocess.run(["git", "rev-list", "--count", "HEAD..origin/main"],
324
+ cwd=git_root, capture_output=True, text=True)
325
+ if result.returncode == 0 and int(result.stdout.strip()) > 0:
326
+ PrettyOutput.print("检测到新版本,正在更新Jarvis...", OutputType.INFO)
327
+ subprocess.run(["git", "pull"], cwd=git_root, check=True)
328
+ PrettyOutput.print("Jarvis已更新到最新版本", OutputType.SUCCESS)
329
+ return True
330
+ return False
331
+ except Exception as e:
332
+ PrettyOutput.print(f"Git仓库更新检查失败: {e}", OutputType.WARNING)
333
+ return False
334
+ finally:
335
+ os.chdir(curr_dir)
@@ -17,6 +17,7 @@ def init_env() -> None:
17
17
  1. 创建不存在的jarvis_data目录
18
18
  2. 加载环境变量到os.environ
19
19
  3. 处理文件读取异常
20
+ 4. 检查git仓库状态并在落后时更新
20
21
  """
21
22
  jarvis_dir = Path(get_data_dir())
22
23
  env_file = jarvis_dir / "env"
@@ -52,6 +53,13 @@ def init_env() -> None:
52
53
  continue
53
54
  except Exception as e:
54
55
  PrettyOutput.print(f"警告: 读取 {env_file} 失败: {e}", OutputType.WARNING)
56
+
57
+ # 检查是否是git仓库并更新
58
+ from jarvis.jarvis_utils.git_utils import check_and_update_git_repo
59
+
60
+ check_and_update_git_repo(str(script_dir))
61
+
62
+
55
63
  def while_success(func: Callable[[], Any], sleep_time: float = 0.1) -> Any:
56
64
  """循环执行函数直到成功
57
65
 
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.2
2
2
  Name: jarvis-ai-assistant
3
- Version: 0.1.166
3
+ Version: 0.1.167
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
@@ -65,7 +65,6 @@ Requires-Dist: build; extra == "dev"
65
65
  Requires-Dist: twine; extra == "dev"
66
66
  Dynamic: author
67
67
  Dynamic: home-page
68
- Dynamic: license-file
69
68
  Dynamic: requires-python
70
69
 
71
70
  # 🤖 Jarvis AI 助手
@@ -167,7 +166,6 @@ JARVIS_THINKING_MODEL=gpt-4o
167
166
 
168
167
  OPENAI_API_KEY=<OpenAI API Key>
169
168
  OPENAI_API_BASE=https://api.openai.com/v1 # 可选,默认为官方API地址
170
- OPENAI_MODEL_NAME=gpt-4o # 可选,覆盖JARVIS_MODEL设置
171
169
  ```
172
170
 
173
171
  配置说明:
@@ -213,6 +211,9 @@ OPENAI_MODEL_NAME=gpt-4o # 可选,覆盖JARVIS_MODEL设置
213
211
  | `JARVIS_EXECUTE_TOOL_CONFIRM` | false | 执行工具前是否需要确认 |
214
212
  | `JARVIS_CONFIRM_BEFORE_APPLY_PATCH` | true | 应用补丁前是否需要确认 |
215
213
  | `JARVIS_MAX_TOOL_CALL_COUNT` | 20 | 最大连续工具调用次数 |
214
+ | `JARVIS_AUTO_UPDATE` | true | 是否自动更新Jarvis(仅在以git仓库方式安装时有效) |
215
+
216
+ 所有配置编写到`~/.jarvis/env`文件中即可生效。
216
217
 
217
218
 
218
219
  ---
@@ -409,3 +410,5 @@ class CustomPlatform(BasePlatform):
409
410
  <div align="center">
410
411
  由 Jarvis 团队用 ❤️ 制作
411
412
  </div>
413
+
414
+ ![Jarvis技术支持群](docs/images/wechat.png)
@@ -1,181 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """Git Commit分析工具模块
3
-
4
- 该模块提供了一个GitCommitAnalyzer类,用于获取和分析指定Git commit的详细信息,
5
- 包括提交信息、修改内容以及详细的功能、原因和逻辑分析。
6
- """
7
-
8
- import os
9
- import re
10
- import subprocess
11
- from typing import Dict, Any
12
-
13
- from jarvis.jarvis_agent import Agent
14
- from jarvis.jarvis_platform.registry import PlatformRegistry
15
- from jarvis.jarvis_tools.registry import ToolRegistry
16
- from jarvis.jarvis_utils.output import OutputType, PrettyOutput
17
- from jarvis.jarvis_utils.tag import ct, ot
18
- from jarvis.jarvis_utils.utils import init_env
19
-
20
-
21
- class GitCommitAnalyzer:
22
- """Git Commit分析器
23
-
24
- 该类用于获取和分析指定Git commit的详细信息,包括:
25
- - 完整的提交信息
26
- - 修改的文件列表和状态
27
- - 修改的功能、原因和逻辑分析
28
- """
29
-
30
- def execute(self, args: Dict[str, Any]) -> Dict[str, Any]:
31
- """执行commit分析
32
-
33
- Args:
34
- args: 包含commit_sha和root_dir的参数字典
35
-
36
- Returns:
37
- 包含分析结果的字典,包括:
38
- - success: 操作是否成功
39
- - stdout: 包含commit_info和diff_content的结果
40
- - stderr: 错误信息(如果操作失败)
41
- """
42
- try:
43
- commit_sha = args["commit_sha"]
44
- root_dir = args.get("root_dir", ".")
45
-
46
- # Store current directory
47
- original_dir = os.getcwd()
48
-
49
- try:
50
- # Change to root_dir
51
- os.chdir(root_dir)
52
-
53
- # 获取commit详细信息
54
- commit_info = subprocess.check_output(
55
- f"git show {commit_sha} --pretty=fuller",
56
- shell=True,
57
- text=True
58
- )
59
-
60
- # 获取commit修改内容
61
- diff_content = subprocess.check_output(
62
- f"git show {commit_sha} --patch",
63
- shell=True,
64
- text=True
65
- )
66
-
67
- # 分析commit的功能、原因和逻辑
68
- system_prompt = """你是一位资深代码分析专家,拥有多年代码审查和重构经验。你需要对Git commit进行深入分析,包括:
69
- 1. 修改的功能:明确说明本次commit实现或修改了哪些功能
70
- 2. 修改的原因:分析为什么要进行这些修改(如修复bug、优化性能、添加新功能等)
71
- 3. 修改的逻辑:详细说明代码修改的具体实现逻辑和思路
72
- 4. 影响范围:评估本次修改可能影响的其他模块或功能
73
- 5. 代码质量:分析代码风格、可读性和可维护性
74
- 6. 测试覆盖:评估是否需要添加或修改测试用例
75
- 7. 最佳实践:检查代码是否符合行业最佳实践和项目规范
76
-
77
- 请确保分析内容:
78
- - 准确反映commit的实际修改
79
- - 提供足够的技术细节
80
- - 保持结构清晰,便于理解
81
- - 重点关注关键修改和潜在风险"""
82
-
83
- tool_registry = ToolRegistry()
84
- agent = Agent(
85
- system_prompt=system_prompt,
86
- name="Commit Analysis Agent",
87
- summary_prompt=f"""请生成一份详细的commit分析报告,包含以下内容:
88
- {ot("REPORT")}
89
- # 功能分析
90
- [说明本次commit实现或修改了哪些功能]
91
-
92
- # 修改原因
93
- [分析进行这些修改的原因,如修复bug、优化性能、添加新功能等]
94
-
95
- # 实现逻辑
96
- [详细说明代码修改的具体实现逻辑和思路]
97
-
98
- # 影响范围
99
- [评估本次修改可能影响的其他模块或功能]
100
-
101
- # 代码质量
102
- [分析代码风格、可读性和可维护性]
103
-
104
- # 测试覆盖
105
- [评估是否需要添加或修改测试用例]
106
-
107
- # 最佳实践
108
- [检查代码是否符合行业最佳实践和项目规范]
109
- {ct("REPORT")}""",
110
- output_handler=[tool_registry],
111
- platform=PlatformRegistry().get_thinking_platform(),
112
- auto_complete=True
113
- )
114
-
115
- analysis_result = agent.run(diff_content)
116
-
117
- return {
118
- "success": True,
119
- "stdout": {
120
- "commit_info": commit_info,
121
- "diff_content": diff_content,
122
- "analysis_result": analysis_result
123
- },
124
- "stderr": ""
125
- }
126
- finally:
127
- # Always restore original directory
128
- os.chdir(original_dir)
129
- except subprocess.CalledProcessError as error:
130
- return {
131
- "success": False,
132
- "stdout": {},
133
- "stderr": f"Failed to analyze commit: {str(error)}"
134
- }
135
-
136
-
137
- def extract_analysis_report(result: str) -> str:
138
- """从分析结果中提取报告内容
139
-
140
- Args:
141
- result: 包含REPORT标签的完整分析结果字符串
142
-
143
- Returns:
144
- 提取的报告内容,如果未找到REPORT标签则返回空字符串
145
- """
146
- search_match = re.search(ot("REPORT")+r'\n(.*?)\n'+ct("REPORT"), result, re.DOTALL)
147
- if search_match:
148
- return search_match.group(1)
149
- return ""
150
-
151
-
152
- def main():
153
- """主函数,用于命令行接口"""
154
- import argparse
155
-
156
- init_env()
157
-
158
- parser = argparse.ArgumentParser(description='Git Commit Analyzer')
159
- parser.add_argument('commit', help='Commit SHA to analyze')
160
- parser.add_argument('--root-dir', type=str, help='Root directory of the codebase', default=".")
161
-
162
- args = parser.parse_args()
163
-
164
- analyzer = GitCommitAnalyzer()
165
- result = analyzer.execute({
166
- "commit_sha": args.commit,
167
- "root_dir": args.root_dir
168
- })
169
-
170
- if result["success"]:
171
- PrettyOutput.section("Commit Information:", OutputType.SUCCESS)
172
- PrettyOutput.print(result["stdout"]["commit_info"], OutputType.CODE)
173
- PrettyOutput.section("Analysis Report:", OutputType.SUCCESS)
174
- report = extract_analysis_report(result["stdout"]["analysis_result"])
175
- PrettyOutput.print(report, OutputType.SUCCESS, lang="markdown")
176
- else:
177
- PrettyOutput.print(result["stderr"], OutputType.WARNING)
178
-
179
-
180
- if __name__ == "__main__":
181
- main()