jarvis-ai-assistant 0.1.188__py3-none-any.whl → 0.1.190__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 +61 -57
- jarvis/jarvis_code_analysis/code_review.py +15 -14
- jarvis/jarvis_data/config_schema.json +1 -1
- jarvis/jarvis_dev/main.py +6 -6
- jarvis/jarvis_git_details/main.py +1 -1
- jarvis/jarvis_git_utils/git_commiter.py +239 -202
- jarvis/jarvis_platform/base.py +4 -3
- jarvis/jarvis_platform/kimi.py +4 -0
- jarvis/jarvis_platform/tongyi.py +4 -0
- jarvis/jarvis_platform/yuanbao.py +4 -0
- jarvis/jarvis_platform_manager/main.py +4 -0
- jarvis/jarvis_tools/edit_file.py +12 -10
- jarvis/jarvis_tools/file_analyzer.py +5 -2
- jarvis/jarvis_tools/generate_new_tool.py +88 -40
- jarvis/jarvis_tools/registry.py +25 -17
- jarvis/jarvis_utils/config.py +1 -1
- jarvis/jarvis_utils/methodology.py +9 -11
- {jarvis_ai_assistant-0.1.188.dist-info → jarvis_ai_assistant-0.1.190.dist-info}/METADATA +14 -3
- {jarvis_ai_assistant-0.1.188.dist-info → jarvis_ai_assistant-0.1.190.dist-info}/RECORD +24 -24
- {jarvis_ai_assistant-0.1.188.dist-info → jarvis_ai_assistant-0.1.190.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.1.188.dist-info → jarvis_ai_assistant-0.1.190.dist-info}/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.1.188.dist-info → jarvis_ai_assistant-0.1.190.dist-info}/licenses/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.188.dist-info → jarvis_ai_assistant-0.1.190.dist-info}/top_level.txt +0 -0
jarvis/__init__.py
CHANGED
jarvis/jarvis_agent/__init__.py
CHANGED
@@ -4,8 +4,6 @@ import datetime
|
|
4
4
|
import platform
|
5
5
|
from typing import Any, Callable, Dict, List, Optional, Protocol, Tuple, Union
|
6
6
|
|
7
|
-
from jarvis.jarvis_platform.base import BasePlatform
|
8
|
-
|
9
7
|
# 第三方库导入
|
10
8
|
from yaspin import yaspin # type: ignore
|
11
9
|
|
@@ -224,7 +222,11 @@ class Agent:
|
|
224
222
|
|
225
223
|
# 如果有上传文件,自动禁用方法论
|
226
224
|
self.use_methodology = (
|
227
|
-
False
|
225
|
+
False
|
226
|
+
if files
|
227
|
+
else (
|
228
|
+
use_methodology if use_methodology is not None else is_use_methodology()
|
229
|
+
)
|
228
230
|
)
|
229
231
|
self.use_analysis = (
|
230
232
|
use_analysis if use_analysis is not None else is_use_analysis()
|
@@ -440,24 +442,15 @@ class Agent:
|
|
440
442
|
self.conversation_length += get_context_token_count(response)
|
441
443
|
return response
|
442
444
|
|
443
|
-
def
|
444
|
-
"""
|
445
|
-
|
446
|
-
该方法将:
|
447
|
-
1. 生成关键信息摘要
|
448
|
-
2. 清除对话历史
|
449
|
-
3. 保留系统消息
|
450
|
-
4. 添加摘要作为新上下文
|
451
|
-
5. 重置对话长度计数器
|
445
|
+
def generate_summary(self) -> str:
|
446
|
+
"""生成对话历史摘要
|
452
447
|
|
453
448
|
返回:
|
454
449
|
str: 包含对话摘要的字符串
|
455
450
|
|
456
451
|
注意:
|
457
|
-
|
452
|
+
仅生成摘要,不修改对话状态
|
458
453
|
"""
|
459
|
-
# Create a new model instance to summarize, avoid affecting the main conversation
|
460
|
-
|
461
454
|
with yaspin(text="正在总结对话历史...", color="cyan") as spinner:
|
462
455
|
summary_prompt = """
|
463
456
|
<summary_request>
|
@@ -482,36 +475,48 @@ class Agent:
|
|
482
475
|
</summary_request>
|
483
476
|
"""
|
484
477
|
|
485
|
-
|
486
|
-
|
487
|
-
|
478
|
+
try:
|
479
|
+
with spinner.hidden():
|
480
|
+
summary = self.model.chat_until_success(self.prompt + "\n" + summary_prompt) # type: ignore
|
481
|
+
spinner.text = "总结对话历史完成"
|
482
|
+
spinner.ok("✅")
|
483
|
+
return summary
|
484
|
+
except Exception as e:
|
485
|
+
spinner.text = "总结对话历史失败"
|
486
|
+
spinner.fail("❌")
|
487
|
+
return ""
|
488
488
|
|
489
|
-
|
489
|
+
def _summarize_and_clear_history(self) -> str:
|
490
|
+
"""总结当前对话并清理历史记录
|
490
491
|
|
491
|
-
|
492
|
-
|
492
|
+
该方法将:
|
493
|
+
1. 调用_generate_summary生成摘要
|
494
|
+
2. 清除对话历史
|
495
|
+
3. 保留系统消息
|
496
|
+
4. 添加摘要作为新上下文
|
497
|
+
5. 重置对话长度计数器
|
493
498
|
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
+
返回:
|
500
|
+
str: 包含对话摘要的字符串
|
501
|
+
|
502
|
+
注意:
|
503
|
+
当上下文长度超过最大值时使用
|
504
|
+
"""
|
505
|
+
summary = self.generate_summary()
|
506
|
+
self.clear_history() # type: ignore
|
507
|
+
|
508
|
+
if not summary:
|
509
|
+
return ""
|
510
|
+
|
511
|
+
return f"""
|
499
512
|
以下是之前对话的关键信息总结:
|
500
|
-
</header>
|
501
513
|
|
502
514
|
<content>
|
503
515
|
{summary}
|
504
516
|
</content>
|
505
517
|
|
506
|
-
<instructions>
|
507
518
|
请基于以上信息继续完成任务。请注意,这是之前对话的摘要,上下文长度已超过限制而被重置。请直接继续任务,无需重复已完成的步骤。如有需要,可以询问用户以获取更多信息。
|
508
|
-
</instructions>
|
509
|
-
</summary>
|
510
519
|
"""
|
511
|
-
except Exception as e:
|
512
|
-
spinner.text = "总结对话历史失败"
|
513
|
-
spinner.fail("❌")
|
514
|
-
return ""
|
515
520
|
|
516
521
|
def _call_tools(self, response: str) -> Tuple[bool, Any]:
|
517
522
|
"""调用工具执行响应
|
@@ -770,32 +775,31 @@ arguments:
|
|
770
775
|
3. 包含错误处理和恢复逻辑
|
771
776
|
4. 自动加载相关方法论(如果是首次运行)
|
772
777
|
"""
|
778
|
+
|
779
|
+
self.prompt = f"{user_input}"
|
773
780
|
try:
|
774
781
|
set_agent(self.name, self)
|
775
782
|
|
776
|
-
self.prompt = f"{user_input}"
|
777
|
-
|
778
|
-
if self.first:
|
779
|
-
# 如果有上传文件,先上传文件
|
780
|
-
if self.files and isinstance(self.model, BasePlatform) and hasattr(self.model, "upload_files"):
|
781
|
-
self.model.upload_files(self.files)
|
782
|
-
self.prompt = f"{user_input}"
|
783
|
-
|
784
|
-
# 如果启用方法论且没有上传文件,上传方法论
|
785
|
-
elif self.use_methodology:
|
786
|
-
platform = self.model if hasattr(self.model, "upload_files") else None
|
787
|
-
if platform and upload_methodology(platform):
|
788
|
-
self.prompt = f"{user_input}"
|
789
|
-
else:
|
790
|
-
# 上传失败则回退到本地加载
|
791
|
-
msg = user_input
|
792
|
-
for handler in self.input_handler:
|
793
|
-
msg, _ = handler(msg, self)
|
794
|
-
self.prompt = f"{user_input}\n\n以下是历史类似问题的执行经验,可参考:\n{load_methodology(msg, self.get_tool_registry())}"
|
795
|
-
|
796
|
-
self.first = False
|
797
|
-
|
798
783
|
while True:
|
784
|
+
if self.first:
|
785
|
+
# 如果有上传文件,先上传文件
|
786
|
+
if (
|
787
|
+
self.files
|
788
|
+
and self.model
|
789
|
+
and self.model.support_upload_files()
|
790
|
+
):
|
791
|
+
self.model.upload_files(self.files)
|
792
|
+
|
793
|
+
# 如果启用方法论且没有上传文件,上传方法论
|
794
|
+
elif self.use_methodology:
|
795
|
+
if not self.model or not upload_methodology(self.model):
|
796
|
+
# 上传失败则回退到本地加载
|
797
|
+
msg = self.prompt
|
798
|
+
for handler in self.input_handler:
|
799
|
+
msg, _ = handler(msg, self)
|
800
|
+
self.prompt = f"{self.prompt}\n\n以下是历史类似问题的执行经验,可参考:\n{load_methodology(msg, self.get_tool_registry())}"
|
801
|
+
|
802
|
+
self.first = False
|
799
803
|
try:
|
800
804
|
current_response = self._call_model(self.prompt, True)
|
801
805
|
self.prompt = ""
|
@@ -836,7 +840,7 @@ arguments:
|
|
836
840
|
PrettyOutput.print(f"任务失败: {str(e)}", OutputType.ERROR)
|
837
841
|
return f"Task failed: {str(e)}"
|
838
842
|
|
839
|
-
def
|
843
|
+
def clear_history(self):
|
840
844
|
"""清空对话历史但保留系统提示
|
841
845
|
|
842
846
|
该方法将:
|
@@ -588,25 +588,33 @@ class CodeReviewTool:
|
|
588
588
|
temp_file.flush()
|
589
589
|
|
590
590
|
try:
|
591
|
-
upload_success = False
|
592
591
|
# Check if content is too large
|
593
592
|
is_large_content = is_context_overflow(diff_output)
|
594
593
|
|
595
594
|
# Upload the file to the agent's model
|
596
|
-
if is_large_content
|
595
|
+
if is_large_content:
|
596
|
+
if not agent.model or not agent.model.support_upload_files():
|
597
|
+
return {
|
598
|
+
"success": False,
|
599
|
+
"stdout": "",
|
600
|
+
"stderr": "代码差异太大,无法处理"
|
601
|
+
}
|
602
|
+
|
597
603
|
with yaspin(text="正在上传代码差异文件...", color="cyan") as spinner:
|
598
604
|
upload_success = agent.model.upload_files([temp_file_path])
|
599
605
|
if upload_success:
|
600
606
|
spinner.ok("✅")
|
601
607
|
PrettyOutput.print(f"已成功上传代码差异文件", OutputType.SUCCESS)
|
602
608
|
else:
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
609
|
+
return {
|
610
|
+
"success": False,
|
611
|
+
"stdout": "",
|
612
|
+
"stderr": "上传代码差异文件失败"
|
613
|
+
}
|
614
|
+
|
607
615
|
|
608
616
|
# Prepare the prompt based on upload status
|
609
|
-
if
|
617
|
+
if is_large_content:
|
610
618
|
# When file is uploaded, reference it in the prompt
|
611
619
|
complete_prompt = user_prompt + f"""
|
612
620
|
|
@@ -619,13 +627,6 @@ class CodeReviewTool:
|
|
619
627
|
# Run the agent with the prompt
|
620
628
|
result = agent.run(complete_prompt)
|
621
629
|
else:
|
622
|
-
if is_large_content:
|
623
|
-
return {
|
624
|
-
"success": False,
|
625
|
-
"stdout": "",
|
626
|
-
"stderr": "错误:上传代码差异文件失败"
|
627
|
-
}
|
628
|
-
# Include the diff directly in the prompt for smaller content
|
629
630
|
complete_prompt = user_prompt + "\n\n代码差异内容:\n```diff\n" + diff_output + "\n```"
|
630
631
|
result = agent.run(complete_prompt)
|
631
632
|
finally:
|
jarvis/jarvis_dev/main.py
CHANGED
@@ -1160,42 +1160,42 @@ def create_dev_team() -> MultiAgent:
|
|
1160
1160
|
description="Project Manager - Coordinates team and manages project delivery",
|
1161
1161
|
system_prompt=PM_PROMPT_WITH_TOOLS,
|
1162
1162
|
output_handler=[PM_output_handler],
|
1163
|
-
platform=PlatformRegistry().
|
1163
|
+
platform=PlatformRegistry().get_normal_platform(),
|
1164
1164
|
),
|
1165
1165
|
dict(
|
1166
1166
|
name="BA",
|
1167
1167
|
description="Business Analyst - Analyzes and documents requirements",
|
1168
1168
|
system_prompt=BA_PROMPT_WITH_TOOLS,
|
1169
1169
|
output_handler=[BA_output_handler],
|
1170
|
-
platform=PlatformRegistry().
|
1170
|
+
platform=PlatformRegistry().get_normal_platform(),
|
1171
1171
|
),
|
1172
1172
|
dict(
|
1173
1173
|
name="SA",
|
1174
1174
|
description="Solution Architect - Designs technical solutions",
|
1175
1175
|
system_prompt=SA_PROMPT_WITH_TOOLS,
|
1176
1176
|
output_handler=[SA_output_handler],
|
1177
|
-
platform=PlatformRegistry().
|
1177
|
+
platform=PlatformRegistry().get_normal_platform(),
|
1178
1178
|
),
|
1179
1179
|
dict(
|
1180
1180
|
name="TL",
|
1181
1181
|
description="Technical Lead - Leads development team and ensures technical quality",
|
1182
1182
|
system_prompt=TL_PROMPT_WITH_TOOLS,
|
1183
1183
|
output_handler=[TL_output_handler],
|
1184
|
-
platform=PlatformRegistry().
|
1184
|
+
platform=PlatformRegistry().get_normal_platform(),
|
1185
1185
|
),
|
1186
1186
|
dict(
|
1187
1187
|
name="DEV",
|
1188
1188
|
description="Developer - Implements features and writes code",
|
1189
1189
|
system_prompt=DEV_PROMPT_WITH_TOOLS,
|
1190
1190
|
output_handler=[DEV_output_handler],
|
1191
|
-
platform=PlatformRegistry().
|
1191
|
+
platform=PlatformRegistry().get_normal_platform(),
|
1192
1192
|
),
|
1193
1193
|
dict(
|
1194
1194
|
name="QA",
|
1195
1195
|
description="Quality Assurance - Ensures product quality through testing",
|
1196
1196
|
system_prompt=QA_PROMPT_WITH_TOOLS,
|
1197
1197
|
output_handler=[QA_output_handler],
|
1198
|
-
platform=PlatformRegistry().
|
1198
|
+
platform=PlatformRegistry().get_normal_platform(),
|
1199
1199
|
)
|
1200
1200
|
]
|
1201
1201
|
|
@@ -207,7 +207,7 @@ class GitCommitAnalyzer:
|
|
207
207
|
[检查代码是否符合行业最佳实践和项目规范]
|
208
208
|
{ct("REPORT")}""",
|
209
209
|
output_handler=[tool_registry],
|
210
|
-
platform=PlatformRegistry().
|
210
|
+
platform=PlatformRegistry().get_normal_platform(),
|
211
211
|
auto_complete=True
|
212
212
|
)
|
213
213
|
|