jarvis-ai-assistant 0.1.158__tar.gz → 0.1.160__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.
- {jarvis_ai_assistant-0.1.158/src/jarvis_ai_assistant.egg-info → jarvis_ai_assistant-0.1.160}/PKG-INFO +1 -1
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/pyproject.toml +1 -1
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/setup.py +1 -1
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/__init__.py +1 -1
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_agent/file_input_handler.py +2 -3
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_agent/patch.py +21 -20
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_analysis/code_review.py +17 -12
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_git_utils/git_commiter.py +18 -10
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_methodology/main.py +2 -2
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_platform/base.py +43 -30
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_platform/kimi.py +2 -2
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/file_analyzer.py +2 -2
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/file_operation.py +1 -1
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/read_webpage.py +1 -1
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/registry.py +37 -25
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/search_web.py +1 -1
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_utils/methodology.py +77 -42
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_utils/utils.py +4 -1
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160/src/jarvis_ai_assistant.egg-info}/PKG-INFO +1 -1
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/MANIFEST.in +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/README.md +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/setup.cfg +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_agent/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_agent/builtin_input_handler.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_agent/jarvis.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_agent/main.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_agent/output_handler.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_agent/shell_input_handler.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_agent/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_agent/code_agent.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_analysis/checklists/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_analysis/checklists/c_cpp.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_analysis/checklists/csharp.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_analysis/checklists/data_format.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_analysis/checklists/devops.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_analysis/checklists/docs.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_analysis/checklists/go.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_analysis/checklists/infrastructure.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_analysis/checklists/java.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_analysis/checklists/javascript.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_analysis/checklists/kotlin.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_analysis/checklists/loader.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_analysis/checklists/php.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_analysis/checklists/python.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_analysis/checklists/ruby.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_analysis/checklists/rust.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_analysis/checklists/shell.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_analysis/checklists/sql.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_analysis/checklists/swift.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_analysis/checklists/web.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_dev/main.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_git_details/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_git_details/main.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_git_squash/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_git_squash/main.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_lsp/base.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_lsp/cpp.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_lsp/go.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_lsp/python.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_lsp/registry.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_lsp/rust.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_mcp/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_mcp/sse_mcp_client.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_mcp/stdio_mcp_client.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_multi_agent/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_multi_agent/main.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_platform/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_platform/human.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_platform/registry.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_platform/yuanbao.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_platform_manager/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_platform_manager/main.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_smart_shell/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_smart_shell/main.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/ask_codebase.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/ask_user.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/base.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/chdir.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/code_plan.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/create_code_agent.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/create_sub_agent.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/execute_script.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/find_methodology.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/lsp_get_diagnostics.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/methodology.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/read_code.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/virtual_tty.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_utils/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_utils/builtin_replace_map.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_utils/config.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_utils/embedding.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_utils/file_processors.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_utils/git_utils.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_utils/globals.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_utils/input.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_utils/output.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_utils/tag.py +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis_ai_assistant.egg-info/SOURCES.txt +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis_ai_assistant.egg-info/dependency_links.txt +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis_ai_assistant.egg-info/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis_ai_assistant.egg-info/requires.txt +0 -0
- {jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis_ai_assistant.egg-info/top_level.txt +0 -0
|
@@ -8,7 +8,7 @@ default = true
|
|
|
8
8
|
|
|
9
9
|
[project]
|
|
10
10
|
name = "jarvis-ai-assistant"
|
|
11
|
-
version = "0.1.
|
|
11
|
+
version = "0.1.160"
|
|
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" }]
|
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name="jarvis-ai-assistant",
|
|
5
|
-
version="0.1.
|
|
5
|
+
version="0.1.160",
|
|
6
6
|
author="skyfire",
|
|
7
7
|
author_email="skyfireitdiy@hotmail.com",
|
|
8
8
|
description="An AI assistant that uses various tools to interact with the system",
|
|
@@ -7,9 +7,8 @@ from typing import Any, Tuple
|
|
|
7
7
|
from yaspin import yaspin
|
|
8
8
|
|
|
9
9
|
from jarvis.jarvis_tools.file_operation import FileOperationTool
|
|
10
|
-
from jarvis.jarvis_utils.config import INPUT_WINDOW_REVERSE_SIZE, get_max_input_token_count
|
|
11
|
-
from jarvis.jarvis_utils.embedding import get_context_token_count
|
|
12
10
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
11
|
+
from jarvis.jarvis_utils.utils import is_context_overflow
|
|
13
12
|
|
|
14
13
|
|
|
15
14
|
def file_input_handler(user_input: str, agent: Any) -> Tuple[str, bool]:
|
|
@@ -86,7 +85,7 @@ def file_input_handler(user_input: str, agent: Any) -> Tuple[str, bool]:
|
|
|
86
85
|
spinner.text = "文件读取完成"
|
|
87
86
|
spinner.ok("✅")
|
|
88
87
|
prompt = result["stdout"] + "\n" + prompt
|
|
89
|
-
if
|
|
88
|
+
if is_context_overflow(prompt):
|
|
90
89
|
return old_prompt, False
|
|
91
90
|
|
|
92
91
|
return prompt, False
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_agent/patch.py
RENAMED
|
@@ -2,20 +2,19 @@ import re
|
|
|
2
2
|
from typing import Dict, Any, Tuple
|
|
3
3
|
import os
|
|
4
4
|
|
|
5
|
-
from yaspin import yaspin
|
|
5
|
+
from yaspin import yaspin # type: ignore
|
|
6
6
|
|
|
7
7
|
from jarvis.jarvis_agent.output_handler import OutputHandler
|
|
8
8
|
from jarvis.jarvis_platform.base import BasePlatform
|
|
9
9
|
from jarvis.jarvis_platform.registry import PlatformRegistry
|
|
10
10
|
from jarvis.jarvis_git_utils.git_commiter import GitCommitTool
|
|
11
11
|
from jarvis.jarvis_tools.file_operation import FileOperationTool
|
|
12
|
-
from jarvis.jarvis_utils.config import
|
|
13
|
-
from jarvis.jarvis_utils.embedding import get_context_token_count
|
|
12
|
+
from jarvis.jarvis_utils.config import is_confirm_before_apply_patch
|
|
14
13
|
from jarvis.jarvis_utils.git_utils import get_commits_between, get_latest_commit_hash
|
|
15
14
|
from jarvis.jarvis_utils.globals import add_read_file_record, has_read_file
|
|
16
15
|
from jarvis.jarvis_utils.input import get_multiline_input
|
|
17
16
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
18
|
-
from jarvis.jarvis_utils.utils import get_file_line_count, user_confirm
|
|
17
|
+
from jarvis.jarvis_utils.utils import is_context_overflow, get_file_line_count, user_confirm
|
|
19
18
|
from jarvis.jarvis_utils.tag import ot, ct
|
|
20
19
|
|
|
21
20
|
|
|
@@ -376,11 +375,7 @@ def handle_small_code_operation(filepath: str, patch_content: str) -> bool:
|
|
|
376
375
|
with yaspin(text=f"正在修改文件 {filepath}...", color="cyan") as spinner:
|
|
377
376
|
try:
|
|
378
377
|
model = PlatformRegistry().get_normal_platform()
|
|
379
|
-
upload_success = False
|
|
380
378
|
file_content = FileOperationTool().execute({"operation":"read", "files":[{"path":filepath}]})["stdout"]
|
|
381
|
-
with spinner.hidden():
|
|
382
|
-
if get_context_token_count(file_content) > get_max_input_token_count() - INPUT_WINDOW_REVERSE_SIZE and model.upload_files([filepath]):
|
|
383
|
-
upload_success = True
|
|
384
379
|
|
|
385
380
|
model.set_suppress_output(True)
|
|
386
381
|
|
|
@@ -412,9 +407,7 @@ def handle_small_code_operation(filepath: str, patch_content: str) -> bool:
|
|
|
412
407
|
{ot("MERGED_CODE")}
|
|
413
408
|
[合并后的完整代码,包括所有空行和缩进]
|
|
414
409
|
{ct("MERGED_CODE")}
|
|
415
|
-
|
|
416
|
-
if not upload_success:
|
|
417
|
-
prompt += f"""
|
|
410
|
+
|
|
418
411
|
# 原始代码
|
|
419
412
|
{file_content}
|
|
420
413
|
"""
|
|
@@ -474,21 +467,23 @@ def handle_small_code_operation(filepath: str, patch_content: str) -> bool:
|
|
|
474
467
|
return False
|
|
475
468
|
|
|
476
469
|
|
|
470
|
+
|
|
477
471
|
def handle_large_code_operation(filepath: str, patch_content: str, model: BasePlatform) -> bool:
|
|
478
472
|
"""处理大型代码文件的补丁操作,使用差异化补丁格式"""
|
|
479
473
|
with yaspin(text=f"正在处理文件 {filepath}...", color="cyan") as spinner:
|
|
480
474
|
try:
|
|
481
475
|
file_content = FileOperationTool().execute({"operation":"read", "files":[{"path":filepath}]})["stdout"]
|
|
476
|
+
need_upload_file = is_context_overflow(file_content)
|
|
482
477
|
upload_success = False
|
|
483
478
|
# 读取原始文件内容
|
|
484
479
|
with spinner.hidden():
|
|
485
|
-
if
|
|
480
|
+
if need_upload_file and model.upload_files([filepath]):
|
|
486
481
|
upload_success = True
|
|
487
482
|
|
|
488
483
|
|
|
489
484
|
model.set_suppress_output(True)
|
|
490
485
|
|
|
491
|
-
|
|
486
|
+
main_prompt = f"""
|
|
492
487
|
# 代码补丁生成专家指南
|
|
493
488
|
|
|
494
489
|
## 任务描述
|
|
@@ -533,14 +528,20 @@ def handle_large_code_operation(filepath: str, patch_content: str, model: BasePl
|
|
|
533
528
|
<<<<<< REPLACE
|
|
534
529
|
{ct("DIFF")}
|
|
535
530
|
"""
|
|
536
|
-
|
|
537
|
-
prompt += f"""
|
|
538
|
-
# 原始代码
|
|
539
|
-
{file_content}
|
|
540
|
-
"""
|
|
531
|
+
|
|
541
532
|
for _ in range(3):
|
|
542
|
-
|
|
543
|
-
|
|
533
|
+
file_prompt = ""
|
|
534
|
+
if not need_upload_file:
|
|
535
|
+
file_prompt = f"""
|
|
536
|
+
# 原始代码
|
|
537
|
+
{file_content}
|
|
538
|
+
"""
|
|
539
|
+
response = model.chat_until_success(main_prompt + file_prompt)
|
|
540
|
+
else:
|
|
541
|
+
if upload_success:
|
|
542
|
+
response = model.chat_until_success(main_prompt)
|
|
543
|
+
else:
|
|
544
|
+
response = model.chat_big_content(file_content, main_prompt)
|
|
544
545
|
|
|
545
546
|
# 解析差异化补丁
|
|
546
547
|
diff_blocks = re.finditer(ot("DIFF")+r'\s*>{4,} SEARCH\n?(.*?)\n?={4,}\n?(.*?)\s*<{4,} REPLACE\n?'+ct("DIFF"),
|
|
@@ -10,10 +10,8 @@ from jarvis.jarvis_tools.read_code import ReadCodeTool
|
|
|
10
10
|
from jarvis.jarvis_tools.registry import ToolRegistry
|
|
11
11
|
from jarvis.jarvis_agent import Agent
|
|
12
12
|
|
|
13
|
-
from jarvis.jarvis_utils.config import INPUT_WINDOW_REVERSE_SIZE, get_max_input_token_count
|
|
14
|
-
from jarvis.jarvis_utils.embedding import get_context_token_count
|
|
15
13
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
16
|
-
from jarvis.jarvis_utils.utils import init_env
|
|
14
|
+
from jarvis.jarvis_utils.utils import init_env, is_context_overflow
|
|
17
15
|
from jarvis.jarvis_utils.tag import ot, ct
|
|
18
16
|
from jarvis.jarvis_code_analysis.checklists.loader import get_language_checklist
|
|
19
17
|
|
|
@@ -588,16 +586,19 @@ class CodeReviewTool:
|
|
|
588
586
|
|
|
589
587
|
try:
|
|
590
588
|
upload_success = False
|
|
589
|
+
# Check if content is too large
|
|
590
|
+
is_large_content = is_context_overflow(diff_output)
|
|
591
|
+
|
|
591
592
|
# Upload the file to the agent's model
|
|
592
593
|
with yaspin(text="正在上传代码差异文件...", color="cyan") as spinner:
|
|
593
|
-
if
|
|
594
|
+
if is_large_content and agent.model and hasattr(agent.model, 'upload_files'):
|
|
594
595
|
upload_success = agent.model.upload_files([temp_file_path])
|
|
595
596
|
if upload_success:
|
|
596
597
|
spinner.ok("✅")
|
|
597
598
|
PrettyOutput.print(f"已成功上传代码差异文件", OutputType.SUCCESS)
|
|
598
|
-
upload_success = True
|
|
599
599
|
else:
|
|
600
|
-
|
|
600
|
+
spinner.fail("❌")
|
|
601
|
+
PrettyOutput.print(f"上传代码差异文件失败,将使用分块处理", OutputType.WARNING)
|
|
601
602
|
else:
|
|
602
603
|
upload_success = False
|
|
603
604
|
|
|
@@ -612,13 +613,17 @@ class CodeReviewTool:
|
|
|
612
613
|
- 检测到的编程语言: {', '.join(detected_languages) if detected_languages else '未检测到特定语言'}
|
|
613
614
|
|
|
614
615
|
请基于上传的代码差异文件进行全面审查,并生成详细的代码审查报告。"""
|
|
616
|
+
# Run the agent with the prompt
|
|
617
|
+
result = agent.run(complete_prompt)
|
|
615
618
|
else:
|
|
616
|
-
# If upload failed
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
619
|
+
# If upload failed or not needed, handle based on context size
|
|
620
|
+
if is_large_content and agent.model and hasattr(agent.model, 'chat_big_content'):
|
|
621
|
+
# Use chat_big_content for large content when upload fails
|
|
622
|
+
result = agent.model.chat_big_content(diff_output, user_prompt)
|
|
623
|
+
else:
|
|
624
|
+
# Include the diff directly in the prompt for smaller content
|
|
625
|
+
complete_prompt = user_prompt + "\n\n代码差异内容:\n```diff\n" + diff_output + "\n```"
|
|
626
|
+
result = agent.run(complete_prompt)
|
|
622
627
|
finally:
|
|
623
628
|
# Clean up the temporary file
|
|
624
629
|
if os.path.exists(temp_file_path):
|
|
@@ -10,11 +10,9 @@ import sys
|
|
|
10
10
|
import argparse
|
|
11
11
|
import os
|
|
12
12
|
|
|
13
|
-
from jarvis.jarvis_utils.config import INPUT_WINDOW_REVERSE_SIZE, get_max_input_token_count
|
|
14
|
-
from jarvis.jarvis_utils.embedding import get_context_token_count
|
|
15
13
|
from jarvis.jarvis_utils.git_utils import find_git_root, has_uncommitted_changes
|
|
16
14
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
17
|
-
from jarvis.jarvis_utils.utils import init_env
|
|
15
|
+
from jarvis.jarvis_utils.utils import init_env, is_context_overflow
|
|
18
16
|
from jarvis.jarvis_utils.tag import ot, ct
|
|
19
17
|
|
|
20
18
|
|
|
@@ -107,7 +105,7 @@ class GitCommitTool:
|
|
|
107
105
|
diff = process.communicate()[0].decode()
|
|
108
106
|
spinner.write(f"✅ 获取差异 ({file_count} 个文件)")
|
|
109
107
|
try:
|
|
110
|
-
|
|
108
|
+
temp_diff_file_path = None
|
|
111
109
|
# 生成提交信息
|
|
112
110
|
spinner.text = "正在生成提交消息..."
|
|
113
111
|
|
|
@@ -134,7 +132,10 @@ class GitCommitTool:
|
|
|
134
132
|
platform = PlatformRegistry().get_normal_platform()
|
|
135
133
|
upload_success = False
|
|
136
134
|
|
|
137
|
-
|
|
135
|
+
# Check if content is too large
|
|
136
|
+
is_large_content = is_context_overflow(diff)
|
|
137
|
+
|
|
138
|
+
if is_large_content and hasattr(platform, 'upload_files'):
|
|
138
139
|
spinner.text = "正在上传代码差异文件..."
|
|
139
140
|
try:
|
|
140
141
|
with spinner.hidden():
|
|
@@ -148,7 +149,7 @@ class GitCommitTool:
|
|
|
148
149
|
if upload_success:
|
|
149
150
|
spinner.write("✅ 成功上传代码差异文件")
|
|
150
151
|
else:
|
|
151
|
-
spinner.write("⚠️
|
|
152
|
+
spinner.write("⚠️ 上传代码差异文件失败,将使用分块处理")
|
|
152
153
|
except Exception as e:
|
|
153
154
|
spinner.write(f"⚠️ 上传文件时出错: {str(e)}")
|
|
154
155
|
upload_success = False
|
|
@@ -164,16 +165,23 @@ class GitCommitTool:
|
|
|
164
165
|
请详细分析已上传的代码差异文件,生成符合上述格式的提交信息。
|
|
165
166
|
'''
|
|
166
167
|
else:
|
|
167
|
-
#
|
|
168
|
-
|
|
168
|
+
# 如果上传失败但内容较大,使用chat_big_content
|
|
169
|
+
if is_large_content and hasattr(platform, 'chat_big_content'):
|
|
170
|
+
spinner.text = "正在使用分块处理生成提交信息..."
|
|
171
|
+
commit_message = platform.chat_big_content(diff, base_prompt)
|
|
172
|
+
else:
|
|
173
|
+
# 直接在提示中包含差异内容
|
|
174
|
+
prompt = base_prompt + f'''
|
|
169
175
|
# 分析材料
|
|
170
176
|
{diff}
|
|
171
177
|
'''
|
|
178
|
+
commit_message = platform.chat_until_success(prompt)
|
|
172
179
|
|
|
173
180
|
# 尝试生成提交信息
|
|
174
181
|
spinner.text = "正在生成提交消息..."
|
|
175
182
|
while True:
|
|
176
|
-
|
|
183
|
+
if not upload_success and not is_large_content:
|
|
184
|
+
commit_message = platform.chat_until_success(prompt)
|
|
177
185
|
commit_message = self._extract_commit_message(commit_message)
|
|
178
186
|
# 如果成功提取,就跳出循环
|
|
179
187
|
if commit_message:
|
|
@@ -206,7 +214,7 @@ class GitCommitTool:
|
|
|
206
214
|
spinner.ok("✅")
|
|
207
215
|
finally:
|
|
208
216
|
# 清理临时差异文件
|
|
209
|
-
if
|
|
217
|
+
if temp_diff_file_path is not None and os.path.exists(temp_diff_file_path):
|
|
210
218
|
try:
|
|
211
219
|
os.unlink(temp_diff_file_path)
|
|
212
220
|
except Exception as e:
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_methodology/main.py
RENAMED
|
@@ -11,14 +11,14 @@ import hashlib
|
|
|
11
11
|
import os
|
|
12
12
|
import json
|
|
13
13
|
import argparse
|
|
14
|
-
import yaml
|
|
14
|
+
import yaml # type: ignore
|
|
15
15
|
from jarvis.jarvis_utils.methodology import (
|
|
16
16
|
_get_methodology_directory,
|
|
17
17
|
_load_all_methodologies
|
|
18
18
|
)
|
|
19
19
|
from jarvis.jarvis_platform.registry import PlatformRegistry
|
|
20
20
|
from jarvis.jarvis_utils.output import PrettyOutput, OutputType
|
|
21
|
-
from yaspin import yaspin
|
|
21
|
+
from yaspin import yaspin # type: ignore
|
|
22
22
|
|
|
23
23
|
def import_methodology(input_file):
|
|
24
24
|
"""导入方法论文件(合并策略)"""
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_platform/base.py
RENAMED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod
|
|
2
2
|
import re
|
|
3
3
|
from typing import List, Tuple
|
|
4
|
+
from jarvis.jarvis_utils.config import get_max_input_token_count
|
|
5
|
+
from jarvis.jarvis_utils.embedding import split_text_into_chunks
|
|
4
6
|
from jarvis.jarvis_utils.globals import clear_read_file_record
|
|
5
7
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
6
8
|
from jarvis.jarvis_utils.utils import get_context_token_count, while_success, while_true
|
|
@@ -37,38 +39,49 @@ class BasePlatform(ABC):
|
|
|
37
39
|
@abstractmethod
|
|
38
40
|
def upload_files(self, file_list: List[str]) -> bool:
|
|
39
41
|
raise NotImplementedError("upload_files is not implemented")
|
|
42
|
+
|
|
43
|
+
def chat_big_content(self, content: str, prompt: str) -> str:
|
|
44
|
+
prefix_prompt = f"""
|
|
45
|
+
我将分多次提供大量的上下文内容,在我明确告诉你内容已经全部提供完毕之前,每次仅需要输出“已收到”。
|
|
46
|
+
"""
|
|
47
|
+
self.chat_until_success(prefix_prompt)
|
|
48
|
+
split_content = split_text_into_chunks(content, get_max_input_token_count() - 1024)
|
|
49
|
+
for chunk in split_content:
|
|
50
|
+
self.chat_until_success(f"<part_content>{chunk}</part_content>")
|
|
51
|
+
return self.chat_until_success(f"内容已经全部提供完毕\n\n{prompt}")
|
|
40
52
|
|
|
53
|
+
|
|
54
|
+
def _chat(self, message: str):
|
|
55
|
+
import time
|
|
56
|
+
start_time = time.time()
|
|
57
|
+
response = self.chat(message)
|
|
58
|
+
|
|
59
|
+
end_time = time.time()
|
|
60
|
+
duration = end_time - start_time
|
|
61
|
+
char_count = len(response)
|
|
62
|
+
|
|
63
|
+
# Calculate token count and tokens per second
|
|
64
|
+
try:
|
|
65
|
+
token_count = get_context_token_count(response)
|
|
66
|
+
tokens_per_second = token_count / duration if duration > 0 else 0
|
|
67
|
+
except Exception as e:
|
|
68
|
+
PrettyOutput.print(f"Tokenization failed: {str(e)}", OutputType.WARNING)
|
|
69
|
+
token_count = 0
|
|
70
|
+
tokens_per_second = 0
|
|
71
|
+
|
|
72
|
+
# Print statistics
|
|
73
|
+
if not self.suppress_output:
|
|
74
|
+
PrettyOutput.print(
|
|
75
|
+
f"对话完成 - 耗时: {duration:.2f}秒, 输出字符数: {char_count}, 输出Token数量: {token_count}, 每秒Token数量: {tokens_per_second:.2f}",
|
|
76
|
+
OutputType.INFO,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
# Keep original think tag handling
|
|
80
|
+
response = re.sub(ot("think")+r'.*?'+ct("think"), '', response, flags=re.DOTALL)
|
|
81
|
+
return response
|
|
82
|
+
|
|
41
83
|
def chat_until_success(self, message: str) -> str:
|
|
42
|
-
|
|
43
|
-
import time
|
|
44
|
-
start_time = time.time()
|
|
45
|
-
response = self.chat(message)
|
|
46
|
-
|
|
47
|
-
end_time = time.time()
|
|
48
|
-
duration = end_time - start_time
|
|
49
|
-
char_count = len(response)
|
|
50
|
-
|
|
51
|
-
# Calculate token count and tokens per second
|
|
52
|
-
try:
|
|
53
|
-
token_count = get_context_token_count(response)
|
|
54
|
-
tokens_per_second = token_count / duration if duration > 0 else 0
|
|
55
|
-
except Exception as e:
|
|
56
|
-
PrettyOutput.print(f"Tokenization failed: {str(e)}", OutputType.WARNING)
|
|
57
|
-
token_count = 0
|
|
58
|
-
tokens_per_second = 0
|
|
59
|
-
|
|
60
|
-
# Print statistics
|
|
61
|
-
if not self.suppress_output:
|
|
62
|
-
PrettyOutput.print(
|
|
63
|
-
f"对话完成 - 耗时: {duration:.2f}秒, 输出字符数: {char_count}, 输出Token数量: {token_count}, 每秒Token数量: {tokens_per_second:.2f}",
|
|
64
|
-
OutputType.INFO,
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
# Keep original think tag handling
|
|
68
|
-
response = re.sub(ot("think")+r'.*?'+ct("think"), '', response, flags=re.DOTALL)
|
|
69
|
-
return response
|
|
70
|
-
|
|
71
|
-
return while_true(lambda: while_success(lambda: _chat(), 5), 5)
|
|
84
|
+
return while_true(lambda: while_success(lambda: self._chat(message), 5), 5)
|
|
72
85
|
|
|
73
86
|
@abstractmethod
|
|
74
87
|
def name(self) -> str:
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_platform/kimi.py
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from typing import Dict, List, Tuple
|
|
2
|
-
import requests
|
|
2
|
+
import requests # type: ignore
|
|
3
3
|
import json
|
|
4
4
|
import os
|
|
5
5
|
import mimetypes
|
|
@@ -178,7 +178,7 @@ class KimiModel(BasePlatform):
|
|
|
178
178
|
if not file_list:
|
|
179
179
|
return True
|
|
180
180
|
|
|
181
|
-
from yaspin import yaspin
|
|
181
|
+
from yaspin import yaspin # type: ignore
|
|
182
182
|
|
|
183
183
|
if not self.chat_id:
|
|
184
184
|
with yaspin(text="创建聊天会话...", color="yellow") as spinner:
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/file_analyzer.py
RENAMED
|
@@ -3,8 +3,8 @@ import os
|
|
|
3
3
|
|
|
4
4
|
from jarvis.jarvis_platform.registry import PlatformRegistry
|
|
5
5
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
6
|
-
from yaspin import yaspin
|
|
7
|
-
from yaspin.spinners import Spinners
|
|
6
|
+
from yaspin import yaspin # type: ignore
|
|
7
|
+
from yaspin.spinners import Spinners # type: ignore
|
|
8
8
|
|
|
9
9
|
class FileAnalyzerTool:
|
|
10
10
|
name = "file_analyzer"
|
|
@@ -2,7 +2,7 @@ from typing import Dict, Any
|
|
|
2
2
|
import os
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
|
|
5
|
-
from yaspin import yaspin
|
|
5
|
+
from yaspin import yaspin # type: ignore
|
|
6
6
|
|
|
7
7
|
from jarvis.jarvis_utils.globals import add_read_file_record
|
|
8
8
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/registry.py
RENAMED
|
@@ -3,6 +3,7 @@ from pathlib import Path
|
|
|
3
3
|
import re
|
|
4
4
|
import sys
|
|
5
5
|
import tempfile
|
|
6
|
+
import os
|
|
6
7
|
from typing import Any, Callable, Dict, List, Optional, Tuple
|
|
7
8
|
|
|
8
9
|
import yaml
|
|
@@ -10,14 +11,9 @@ import yaml
|
|
|
10
11
|
from jarvis.jarvis_agent.output_handler import OutputHandler
|
|
11
12
|
from jarvis.jarvis_platform.registry import PlatformRegistry
|
|
12
13
|
from jarvis.jarvis_tools.base import Tool
|
|
13
|
-
from jarvis.jarvis_utils.config import
|
|
14
|
-
INPUT_WINDOW_REVERSE_SIZE,
|
|
15
|
-
get_max_input_token_count,
|
|
16
|
-
get_data_dir,
|
|
17
|
-
)
|
|
18
|
-
from jarvis.jarvis_utils.embedding import get_context_token_count
|
|
14
|
+
from jarvis.jarvis_utils.config import get_data_dir
|
|
19
15
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
20
|
-
from jarvis.jarvis_utils.utils import init_env
|
|
16
|
+
from jarvis.jarvis_utils.utils import init_env, is_context_overflow
|
|
21
17
|
from jarvis.jarvis_utils.tag import ot, ct
|
|
22
18
|
from jarvis.jarvis_mcp.stdio_mcp_client import StdioMcpClient
|
|
23
19
|
from jarvis.jarvis_mcp.sse_mcp_client import SSEMcpClient
|
|
@@ -175,9 +171,6 @@ class ToolRegistry(OutputHandler):
|
|
|
175
171
|
self._load_builtin_tools()
|
|
176
172
|
self._load_external_tools()
|
|
177
173
|
self._load_mcp_tools()
|
|
178
|
-
self.max_input_token_count = (
|
|
179
|
-
get_max_input_token_count() - INPUT_WINDOW_REVERSE_SIZE
|
|
180
|
-
)
|
|
181
174
|
|
|
182
175
|
def use_tools(self, name: List[str]) -> None:
|
|
183
176
|
"""使用指定工具
|
|
@@ -618,26 +611,45 @@ class ToolRegistry(OutputHandler):
|
|
|
618
611
|
result["stdout"], result.get("stderr", "")
|
|
619
612
|
)
|
|
620
613
|
|
|
621
|
-
#
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
614
|
+
# 检查内容是否过大
|
|
615
|
+
is_large_content = is_context_overflow(output)
|
|
616
|
+
|
|
617
|
+
if is_large_content:
|
|
618
|
+
# 创建临时文件
|
|
619
|
+
with tempfile.NamedTemporaryFile(mode="w", suffix=".txt", delete=False) as tmp_file:
|
|
626
620
|
output_file = tmp_file.name
|
|
627
621
|
tmp_file.write(output)
|
|
628
622
|
tmp_file.flush()
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
623
|
+
|
|
624
|
+
try:
|
|
625
|
+
# 获取平台实例
|
|
626
|
+
platform = PlatformRegistry().get_normal_platform()
|
|
627
|
+
if platform and hasattr(platform, 'upload_files'):
|
|
628
|
+
platform.set_suppress_output(False)
|
|
629
|
+
# 尝试上传文件
|
|
630
|
+
upload_success = platform.upload_files([output_file])
|
|
631
|
+
|
|
632
|
+
if upload_success:
|
|
633
|
+
# 使用上传的文件生成摘要
|
|
634
|
+
prompt = f"该文件为工具执行结果,请阅读文件内容,并根据文件提取出以下信息:{want}"
|
|
635
|
+
return f"""工具调用原始输出过长,以下是根据输出提出的信息:
|
|
639
636
|
|
|
640
637
|
{platform.chat_until_success(prompt)}"""
|
|
638
|
+
elif hasattr(platform, 'chat_big_content'):
|
|
639
|
+
# 如果上传失败但支持大内容处理,使用chat_big_content
|
|
640
|
+
prompt = f"以下内容为工具执行结果,请阅读内容,并根据内容提取出以下信息:{want}\n\n{output}"
|
|
641
|
+
return f"""工具调用原始输出过长,以下是根据输出提出的信息:
|
|
642
|
+
|
|
643
|
+
{platform.chat_big_content(output, prompt)}"""
|
|
644
|
+
|
|
645
|
+
# 如果都不支持,返回截断的输出
|
|
646
|
+
return self._truncate_output(output)
|
|
647
|
+
finally:
|
|
648
|
+
# 清理临时文件
|
|
649
|
+
try:
|
|
650
|
+
os.unlink(output_file)
|
|
651
|
+
except Exception:
|
|
652
|
+
pass
|
|
641
653
|
|
|
642
654
|
return output
|
|
643
655
|
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/search_web.py
RENAMED
|
@@ -16,7 +16,7 @@ class SearchWebTool:
|
|
|
16
16
|
def execute(self, args: Dict[str, Any]) -> Dict[str, Any]: # type: ignore
|
|
17
17
|
query = args.get("query")
|
|
18
18
|
model = PlatformRegistry().get_normal_platform()
|
|
19
|
-
model.
|
|
19
|
+
model.set_web(True)
|
|
20
20
|
model.set_suppress_output(False) # type: ignore
|
|
21
21
|
return {
|
|
22
22
|
"stdout": model.chat_until_success(query), # type: ignore
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_utils/methodology.py
RENAMED
|
@@ -11,10 +11,10 @@ import json
|
|
|
11
11
|
import tempfile
|
|
12
12
|
from typing import Dict, Optional
|
|
13
13
|
|
|
14
|
-
from jarvis.jarvis_utils.config import
|
|
15
|
-
from jarvis.jarvis_utils.embedding import get_context_token_count
|
|
14
|
+
from jarvis.jarvis_utils.config import get_data_dir
|
|
16
15
|
from jarvis.jarvis_utils.output import PrettyOutput, OutputType
|
|
17
16
|
from jarvis.jarvis_platform.registry import PlatformRegistry
|
|
17
|
+
from jarvis.jarvis_utils.utils import is_context_overflow
|
|
18
18
|
|
|
19
19
|
def _get_methodology_directory() -> str:
|
|
20
20
|
"""
|
|
@@ -101,7 +101,7 @@ def load_methodology(user_input: str) -> str:
|
|
|
101
101
|
返回:
|
|
102
102
|
str: 相关的方法论提示,如果未找到方法论则返回空字符串
|
|
103
103
|
"""
|
|
104
|
-
from yaspin import yaspin
|
|
104
|
+
from yaspin import yaspin # type: ignore
|
|
105
105
|
|
|
106
106
|
# 获取方法论目录
|
|
107
107
|
methodology_dir = _get_methodology_directory()
|
|
@@ -121,34 +121,20 @@ def load_methodology(user_input: str) -> str:
|
|
|
121
121
|
|
|
122
122
|
# 获取当前平台
|
|
123
123
|
platform = PlatformRegistry().get_normal_platform()
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
temp_file_path = _create_methodology_temp_file(methodologies)
|
|
130
|
-
if not temp_file_path:
|
|
131
|
-
spinner.text = "创建方法论临时文件失败"
|
|
132
|
-
spinner.fail("❌")
|
|
133
|
-
return ""
|
|
134
|
-
spinner.text = f"创建方法论临时文件完成: {temp_file_path}"
|
|
135
|
-
spinner.ok("✅")
|
|
136
|
-
if platform.upload_files([temp_file_path]):
|
|
137
|
-
upload_result = True
|
|
138
|
-
|
|
139
|
-
spinner.text = "上传方法论文件成功"
|
|
140
|
-
spinner.ok("✅")
|
|
141
|
-
|
|
142
|
-
platform.set_suppress_output(False)
|
|
143
|
-
# 构建提示信息
|
|
144
|
-
prompt = f"""以下是所有可用的方法论内容:
|
|
124
|
+
if not platform:
|
|
125
|
+
return ""
|
|
126
|
+
|
|
127
|
+
# 构建基础提示信息
|
|
128
|
+
base_prompt = f"""以下是所有可用的方法论内容:
|
|
145
129
|
|
|
146
130
|
"""
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
131
|
+
# 构建完整内容
|
|
132
|
+
full_content = base_prompt
|
|
133
|
+
for problem_type, content in methodologies.items():
|
|
134
|
+
full_content += f"## {problem_type}\n\n{content}\n\n---\n\n"
|
|
150
135
|
|
|
151
|
-
|
|
136
|
+
# 添加用户输入和输出要求
|
|
137
|
+
full_content += f"""
|
|
152
138
|
请根据以上方法论内容,总结出与以下用户需求相关的方法论: {user_input}
|
|
153
139
|
|
|
154
140
|
请按以下格式回复:
|
|
@@ -161,21 +147,70 @@ def load_methodology(user_input: str) -> str:
|
|
|
161
147
|
如果没有匹配的方法论,请输出:没有历史方法论可参考
|
|
162
148
|
除以上要求外,不要输出任何内容
|
|
163
149
|
"""
|
|
164
|
-
|
|
150
|
+
|
|
151
|
+
# 检查内容是否过大
|
|
152
|
+
is_large_content = is_context_overflow(full_content)
|
|
153
|
+
temp_file_path = None
|
|
154
|
+
|
|
155
|
+
try:
|
|
156
|
+
if is_large_content:
|
|
157
|
+
# 创建临时文件
|
|
158
|
+
with yaspin(text="创建方法论临时文件...", color="yellow") as spinner:
|
|
159
|
+
temp_file_path = _create_methodology_temp_file(methodologies)
|
|
160
|
+
if not temp_file_path:
|
|
161
|
+
spinner.text = "创建方法论临时文件失败"
|
|
162
|
+
spinner.fail("❌")
|
|
163
|
+
return ""
|
|
164
|
+
spinner.text = f"创建方法论临时文件完成: {temp_file_path}"
|
|
165
|
+
spinner.ok("✅")
|
|
166
|
+
|
|
167
|
+
# 尝试上传文件
|
|
168
|
+
if hasattr(platform, 'upload_files'):
|
|
169
|
+
platform.set_suppress_output(False)
|
|
170
|
+
upload_success = platform.upload_files([temp_file_path])
|
|
171
|
+
|
|
172
|
+
if upload_success:
|
|
173
|
+
# 使用上传的文件生成摘要
|
|
174
|
+
return platform.chat_until_success(base_prompt + f"""
|
|
175
|
+
请根据已上传的方法论文件内容,总结出与以下用户需求相关的方法论: {user_input}
|
|
176
|
+
|
|
177
|
+
请按以下格式回复:
|
|
178
|
+
### 与该任务/需求相关的方法论
|
|
179
|
+
1. [方法论名字]
|
|
180
|
+
2. [方法论名字]
|
|
181
|
+
### 根据以上方法论,总结出方法论内容
|
|
182
|
+
[总结的方法论内容]
|
|
183
|
+
|
|
184
|
+
如果没有匹配的方法论,请输出:没有历史方法论可参考
|
|
185
|
+
除以上要求外,不要输出任何内容
|
|
186
|
+
""")
|
|
187
|
+
elif hasattr(platform, 'chat_big_content'):
|
|
188
|
+
# 如果上传失败但支持大内容处理,使用chat_big_content
|
|
189
|
+
return platform.chat_big_content(full_content, base_prompt + f"""
|
|
190
|
+
请根据以上方法论内容,总结出与以下用户需求相关的方法论: {user_input}
|
|
191
|
+
|
|
192
|
+
请按以下格式回复:
|
|
193
|
+
### 与该任务/需求相关的方法论
|
|
194
|
+
1. [方法论名字]
|
|
195
|
+
2. [方法论名字]
|
|
196
|
+
### 根据以上方法论,总结出方法论内容
|
|
197
|
+
[总结的方法论内容]
|
|
198
|
+
|
|
199
|
+
如果没有匹配的方法论,请输出:没有历史方法论可参考
|
|
200
|
+
除以上要求外,不要输出任何内容
|
|
201
|
+
""")
|
|
202
|
+
|
|
203
|
+
# 如果内容不大或上传失败,直接使用chat_until_success
|
|
204
|
+
return platform.chat_until_success(full_content)
|
|
205
|
+
|
|
206
|
+
finally:
|
|
207
|
+
# 清理临时文件
|
|
208
|
+
if temp_file_path and os.path.exists(temp_file_path):
|
|
209
|
+
try:
|
|
210
|
+
os.remove(temp_file_path)
|
|
211
|
+
except Exception:
|
|
212
|
+
pass
|
|
165
213
|
|
|
166
214
|
except Exception as e:
|
|
167
215
|
PrettyOutput.print(f"加载方法论失败: {str(e)}", OutputType.ERROR)
|
|
168
|
-
# 清理临时文件
|
|
169
|
-
if 'temp_file_path' in locals() and temp_file_path and os.path.exists(temp_file_path):
|
|
170
|
-
try:
|
|
171
|
-
os.remove(temp_file_path)
|
|
172
|
-
except:
|
|
173
|
-
pass
|
|
174
216
|
return ""
|
|
175
|
-
finally:
|
|
176
|
-
# 确保清理临时文件
|
|
177
|
-
if 'temp_file_path' in locals() and temp_file_path and os.path.exists(temp_file_path):
|
|
178
|
-
try:
|
|
179
|
-
os.remove(temp_file_path)
|
|
180
|
-
except:
|
|
181
|
-
pass
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_utils/utils.py
RENAMED
|
@@ -3,7 +3,7 @@ import time
|
|
|
3
3
|
import hashlib
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
from typing import List, Any, Callable
|
|
6
|
-
from jarvis.jarvis_utils.config import get_max_input_token_count, get_data_dir
|
|
6
|
+
from jarvis.jarvis_utils.config import INPUT_WINDOW_REVERSE_SIZE, get_max_input_token_count, get_data_dir
|
|
7
7
|
from jarvis.jarvis_utils.embedding import get_context_token_count
|
|
8
8
|
from jarvis.jarvis_utils.input import get_single_line_input
|
|
9
9
|
from jarvis.jarvis_utils.output import PrettyOutput, OutputType
|
|
@@ -130,3 +130,6 @@ def is_long_context(files: List[str]) -> bool:
|
|
|
130
130
|
return total_tokens > threshold
|
|
131
131
|
|
|
132
132
|
|
|
133
|
+
def is_context_overflow(file_content: str) -> bool:
|
|
134
|
+
"""判断文件内容是否超出上下文限制"""
|
|
135
|
+
return get_context_token_count(file_content) > get_max_input_token_count() - INPUT_WINDOW_REVERSE_SIZE
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_agent/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_agent/jarvis.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_code_agent/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_git_details/main.py
RENAMED
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_git_squash/__init__.py
RENAMED
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_git_squash/main.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_lsp/registry.py
RENAMED
|
File without changes
|
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_mcp/__init__.py
RENAMED
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_mcp/sse_mcp_client.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_multi_agent/main.py
RENAMED
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_platform/__init__.py
RENAMED
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_platform/human.py
RENAMED
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_platform/registry.py
RENAMED
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_platform/yuanbao.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_smart_shell/main.py
RENAMED
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/__init__.py
RENAMED
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/ask_codebase.py
RENAMED
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/ask_user.py
RENAMED
|
File without changes
|
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/chdir.py
RENAMED
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/code_plan.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/methodology.py
RENAMED
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/read_code.py
RENAMED
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_tools/virtual_tty.py
RENAMED
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_utils/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_utils/config.py
RENAMED
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_utils/embedding.py
RENAMED
|
File without changes
|
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_utils/git_utils.py
RENAMED
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_utils/globals.py
RENAMED
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_utils/input.py
RENAMED
|
File without changes
|
{jarvis_ai_assistant-0.1.158 → jarvis_ai_assistant-0.1.160}/src/jarvis/jarvis_utils/output.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|