jarvis-ai-assistant 0.1.124__py3-none-any.whl → 0.1.126__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.
Potentially problematic release.
This version of jarvis-ai-assistant might be problematic. Click here for more details.
- jarvis/__init__.py +1 -1
- jarvis/jarvis_agent/__init__.py +134 -136
- jarvis/jarvis_code_agent/code_agent.py +198 -52
- jarvis/jarvis_code_agent/file_select.py +6 -19
- jarvis/jarvis_code_agent/patch.py +183 -312
- jarvis/jarvis_code_agent/shell_input_handler.py +22 -0
- jarvis/jarvis_codebase/main.py +89 -86
- jarvis/jarvis_dev/main.py +695 -715
- jarvis/jarvis_git_squash/__init__.py +0 -0
- jarvis/jarvis_git_squash/main.py +81 -0
- jarvis/jarvis_lsp/base.py +0 -12
- jarvis/jarvis_lsp/cpp.py +1 -10
- jarvis/jarvis_lsp/go.py +1 -10
- jarvis/jarvis_lsp/python.py +0 -28
- jarvis/jarvis_lsp/registry.py +2 -3
- jarvis/jarvis_lsp/rust.py +1 -10
- jarvis/jarvis_multi_agent/__init__.py +53 -53
- jarvis/jarvis_platform/ai8.py +2 -1
- jarvis/jarvis_platform/base.py +19 -24
- jarvis/jarvis_platform/kimi.py +2 -3
- jarvis/jarvis_platform/ollama.py +3 -1
- jarvis/jarvis_platform/openai.py +1 -1
- jarvis/jarvis_platform/oyi.py +2 -1
- jarvis/jarvis_platform/registry.py +2 -1
- jarvis/jarvis_platform_manager/main.py +4 -6
- jarvis/jarvis_platform_manager/openai_test.py +0 -1
- jarvis/jarvis_rag/main.py +5 -2
- jarvis/jarvis_smart_shell/main.py +9 -4
- jarvis/jarvis_tools/ask_codebase.py +18 -13
- jarvis/jarvis_tools/ask_user.py +5 -4
- jarvis/jarvis_tools/base.py +22 -8
- jarvis/jarvis_tools/chdir.py +8 -9
- jarvis/jarvis_tools/code_review.py +19 -20
- jarvis/jarvis_tools/create_code_agent.py +6 -6
- jarvis/jarvis_tools/create_sub_agent.py +9 -9
- jarvis/jarvis_tools/execute_shell.py +55 -20
- jarvis/jarvis_tools/execute_shell_script.py +7 -7
- jarvis/jarvis_tools/file_operation.py +39 -10
- jarvis/jarvis_tools/git_commiter.py +20 -17
- jarvis/jarvis_tools/lsp_find_definition.py +8 -8
- jarvis/jarvis_tools/lsp_find_references.py +1 -1
- jarvis/jarvis_tools/lsp_get_diagnostics.py +19 -11
- jarvis/jarvis_tools/lsp_get_document_symbols.py +1 -1
- jarvis/jarvis_tools/lsp_prepare_rename.py +8 -8
- jarvis/jarvis_tools/methodology.py +10 -7
- jarvis/jarvis_tools/rag.py +27 -20
- jarvis/jarvis_tools/read_webpage.py +4 -3
- jarvis/jarvis_tools/registry.py +143 -140
- jarvis/jarvis_tools/{search.py → search_web.py} +10 -7
- jarvis/jarvis_tools/select_code_files.py +4 -4
- jarvis/jarvis_tools/tool_generator.py +33 -34
- jarvis/jarvis_utils/__init__.py +19 -982
- jarvis/jarvis_utils/config.py +138 -0
- jarvis/jarvis_utils/embedding.py +201 -0
- jarvis/jarvis_utils/git_utils.py +120 -0
- jarvis/jarvis_utils/globals.py +82 -0
- jarvis/jarvis_utils/input.py +161 -0
- jarvis/jarvis_utils/methodology.py +128 -0
- jarvis/jarvis_utils/output.py +235 -0
- jarvis/jarvis_utils/utils.py +150 -0
- jarvis_ai_assistant-0.1.126.dist-info/METADATA +305 -0
- jarvis_ai_assistant-0.1.126.dist-info/RECORD +74 -0
- {jarvis_ai_assistant-0.1.124.dist-info → jarvis_ai_assistant-0.1.126.dist-info}/WHEEL +1 -1
- {jarvis_ai_assistant-0.1.124.dist-info → jarvis_ai_assistant-0.1.126.dist-info}/entry_points.txt +1 -0
- jarvis/jarvis_tools/lsp_validate_edit.py +0 -141
- jarvis/jarvis_tools/read_code.py +0 -191
- jarvis_ai_assistant-0.1.124.dist-info/METADATA +0 -460
- jarvis_ai_assistant-0.1.124.dist-info/RECORD +0 -65
- {jarvis_ai_assistant-0.1.124.dist-info → jarvis_ai_assistant-0.1.126.dist-info}/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.124.dist-info → jarvis_ai_assistant-0.1.126.dist-info}/top_level.txt +0 -0
jarvis/jarvis_codebase/main.py
CHANGED
|
@@ -7,14 +7,18 @@ from typing import List, Tuple, Optional, Dict
|
|
|
7
7
|
from jarvis.jarvis_platform.registry import PlatformRegistry
|
|
8
8
|
import concurrent.futures
|
|
9
9
|
from concurrent.futures import ThreadPoolExecutor
|
|
10
|
-
from jarvis.jarvis_utils import OutputType, PrettyOutput, find_git_root, get_context_token_count, get_embedding, get_file_md5, get_max_token_count, get_thread_count, load_embedding_model, user_confirm
|
|
11
|
-
from jarvis.jarvis_utils import init_env
|
|
12
10
|
import argparse
|
|
13
11
|
import pickle
|
|
14
12
|
import lzma # 添加 lzma 导入
|
|
15
13
|
from tqdm import tqdm
|
|
16
14
|
import re
|
|
17
15
|
|
|
16
|
+
from jarvis.jarvis_utils.config import get_max_token_count, get_thread_count
|
|
17
|
+
from jarvis.jarvis_utils.embedding import get_embedding, load_embedding_model, get_context_token_count
|
|
18
|
+
from jarvis.jarvis_utils.git_utils import find_git_root
|
|
19
|
+
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
20
|
+
from jarvis.jarvis_utils.utils import get_file_md5, init_env, user_confirm
|
|
21
|
+
|
|
18
22
|
class CodeBase:
|
|
19
23
|
def __init__(self, root_dir: str):
|
|
20
24
|
init_env()
|
|
@@ -72,13 +76,13 @@ class CodeBase:
|
|
|
72
76
|
model.set_suppress_output(True)
|
|
73
77
|
else:
|
|
74
78
|
PrettyOutput.print(f"为 {file_path} 生成描述 ...", output_type=OutputType.PROGRESS)
|
|
75
|
-
prompt = f"""
|
|
76
|
-
1.
|
|
77
|
-
2.
|
|
79
|
+
prompt = f"""请分析以下代码文件并生成详细描述。描述应包含:
|
|
80
|
+
1. 文件整体功能描述
|
|
81
|
+
2. 对每个全局变量、函数、类型定义、类、方法和其他代码元素的描述
|
|
78
82
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
请使用简洁专业的语言,强调技术功能,以便于后续代码检索。
|
|
84
|
+
文件路径: {file_path}
|
|
85
|
+
代码内容:
|
|
82
86
|
{content}
|
|
83
87
|
"""
|
|
84
88
|
response = model.chat_until_success(prompt)
|
|
@@ -316,7 +320,7 @@ Content: {content}
|
|
|
316
320
|
ids = []
|
|
317
321
|
self.file_paths = [] # Reset the file path list
|
|
318
322
|
|
|
319
|
-
for i, (file_path, data) in enumerate(self.vector_cache.items()):
|
|
323
|
+
for i, ( file_path, data) in enumerate(self.vector_cache.items()):
|
|
320
324
|
if "vector" not in data:
|
|
321
325
|
PrettyOutput.print(f"无效的缓存数据 {file_path}: 缺少向量",
|
|
322
326
|
output_type=OutputType.WARNING)
|
|
@@ -591,24 +595,24 @@ Content: {content}
|
|
|
591
595
|
|
|
592
596
|
def _process_batch(self, query: str, files_info: List[str]) -> List[Dict[str, str]]:
|
|
593
597
|
"""Process a batch of files"""
|
|
594
|
-
prompt = f"""
|
|
598
|
+
prompt = f"""作为一名代码分析专家,请使用链式思维推理帮助识别与给定查询最相关的文件。
|
|
595
599
|
|
|
596
|
-
|
|
600
|
+
查询: {query}
|
|
597
601
|
|
|
598
|
-
|
|
602
|
+
可用文件:
|
|
599
603
|
{''.join(files_info)}
|
|
600
604
|
|
|
601
|
-
|
|
602
|
-
1.
|
|
603
|
-
2.
|
|
604
|
-
-
|
|
605
|
-
-
|
|
606
|
-
-
|
|
607
|
-
-
|
|
608
|
-
3.
|
|
609
|
-
4.
|
|
610
|
-
|
|
611
|
-
|
|
605
|
+
请按以下步骤思考:
|
|
606
|
+
1. 首先,分析查询以识别关键需求和技术概念
|
|
607
|
+
2. 对于每个文件:
|
|
608
|
+
- 检查其路径和内容
|
|
609
|
+
- 评估其与查询需求的关系
|
|
610
|
+
- 考虑直接和间接关系
|
|
611
|
+
- 评估其相关性(高/中/低)
|
|
612
|
+
3. 仅选择与查询明确相关的文件
|
|
613
|
+
4. 按相关性排序,最相关的文件在前
|
|
614
|
+
|
|
615
|
+
请以YAML格式输出您的选择:
|
|
612
616
|
<FILES>
|
|
613
617
|
- file: path/to/most/relevant.py
|
|
614
618
|
reason: xxxxxxxxxx
|
|
@@ -616,12 +620,12 @@ Please output your selection in YAML format:
|
|
|
616
620
|
reason: yyyyyyyyyy
|
|
617
621
|
</FILES>
|
|
618
622
|
|
|
619
|
-
|
|
620
|
-
-
|
|
621
|
-
-
|
|
622
|
-
-
|
|
623
|
-
-
|
|
624
|
-
-
|
|
623
|
+
重要提示:
|
|
624
|
+
- 仅包含真正相关的文件
|
|
625
|
+
- 排除连接不明确或较弱的文件
|
|
626
|
+
- 重点关注实现文件而非测试文件
|
|
627
|
+
- 同时考虑文件路径和内容
|
|
628
|
+
- 仅输出文件路径,不要包含其他文本
|
|
625
629
|
"""
|
|
626
630
|
|
|
627
631
|
# Use a large model to evaluate
|
|
@@ -653,29 +657,28 @@ Important:
|
|
|
653
657
|
"""
|
|
654
658
|
model = PlatformRegistry.get_global_platform_registry().get_normal_platform()
|
|
655
659
|
model.set_suppress_output(True)
|
|
656
|
-
prompt = f"""
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
Original query:
|
|
660
|
+
prompt = f"""请基于以下查询生成10个针对向量搜索优化的不同表达。每个表达应满足:
|
|
661
|
+
1. 聚焦关键技术概念和术语
|
|
662
|
+
2. 使用清晰明确的语言
|
|
663
|
+
3. 包含重要的上下文术语
|
|
664
|
+
4. 避免使用通用或模糊的词语
|
|
665
|
+
5. 保持与原始查询的语义相似性
|
|
666
|
+
6. 适合基于嵌入的搜索
|
|
667
|
+
|
|
668
|
+
原始查询:
|
|
666
669
|
{query}
|
|
667
670
|
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
+
示例转换:
|
|
672
|
+
查询: "如何处理用户登录?"
|
|
673
|
+
输出格式:
|
|
671
674
|
<QUESTION>
|
|
672
|
-
-
|
|
673
|
-
-
|
|
674
|
-
-
|
|
675
|
+
- 用户认证的实现与流程
|
|
676
|
+
- 登录系统架构与组件
|
|
677
|
+
- 凭证验证与会话管理
|
|
675
678
|
- ...
|
|
676
679
|
</QUESTION>
|
|
677
680
|
|
|
678
|
-
|
|
681
|
+
请以指定格式提供10个搜索优化的表达。
|
|
679
682
|
"""
|
|
680
683
|
response = model.chat_until_success(prompt)
|
|
681
684
|
|
|
@@ -790,52 +793,52 @@ Please provide 10 search-optimized expressions in the specified format.
|
|
|
790
793
|
return [], ""
|
|
791
794
|
|
|
792
795
|
prompt = f"""
|
|
793
|
-
# 🤖
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
# 🎯
|
|
797
|
-
-
|
|
798
|
-
-
|
|
799
|
-
-
|
|
800
|
-
-
|
|
801
|
-
-
|
|
802
|
-
|
|
803
|
-
# 📋
|
|
804
|
-
##
|
|
805
|
-
-
|
|
806
|
-
-
|
|
807
|
-
-
|
|
808
|
-
-
|
|
809
|
-
-
|
|
810
|
-
|
|
811
|
-
##
|
|
812
|
-
- question: [
|
|
796
|
+
# 🤖 角色定义
|
|
797
|
+
您是一位代码分析专家,能够提供关于代码库的全面且准确的回答。
|
|
798
|
+
|
|
799
|
+
# 🎯 核心职责
|
|
800
|
+
- 深入分析代码文件
|
|
801
|
+
- 清晰解释技术概念
|
|
802
|
+
- 提供相关代码示例
|
|
803
|
+
- 识别缺失的信息
|
|
804
|
+
- 使用用户的语言进行回答
|
|
805
|
+
|
|
806
|
+
# 📋 回答要求
|
|
807
|
+
## 内容质量
|
|
808
|
+
- 关注实现细节
|
|
809
|
+
- 保持技术准确性
|
|
810
|
+
- 包含相关代码片段
|
|
811
|
+
- 指出任何缺失的信息
|
|
812
|
+
- 使用专业术语
|
|
813
|
+
|
|
814
|
+
## 回答格式
|
|
815
|
+
- question: [重述问题]
|
|
813
816
|
answer: |
|
|
814
|
-
[
|
|
815
|
-
-
|
|
816
|
-
-
|
|
817
|
-
-
|
|
818
|
-
-
|
|
817
|
+
[详细的技术回答,包含:
|
|
818
|
+
- 实现细节
|
|
819
|
+
- 代码示例(如果相关)
|
|
820
|
+
- 缺失的信息(如果有)
|
|
821
|
+
- 相关技术概念]
|
|
819
822
|
|
|
820
|
-
- question: [
|
|
823
|
+
- question: [如果需要,提出后续问题]
|
|
821
824
|
answer: |
|
|
822
|
-
[
|
|
825
|
+
[额外的技术细节]
|
|
823
826
|
|
|
824
|
-
# 🔍
|
|
825
|
-
|
|
827
|
+
# 🔍 分析上下文
|
|
828
|
+
问题: {query}
|
|
826
829
|
|
|
827
|
-
|
|
830
|
+
相关代码文件(按相关性排序):
|
|
828
831
|
"""
|
|
829
832
|
|
|
830
|
-
#
|
|
831
|
-
available_count = self.max_token_count - get_context_token_count(prompt) - 1000 #
|
|
833
|
+
# 添加上下文,控制长度
|
|
834
|
+
available_count = self.max_token_count - get_context_token_count(prompt) - 1000 # 为回答预留空间
|
|
832
835
|
current_count = 0
|
|
833
836
|
|
|
834
837
|
for path in files_from_codebase:
|
|
835
838
|
try:
|
|
836
839
|
content = open(path["file"], "r", encoding="utf-8").read()
|
|
837
840
|
file_content = f"""
|
|
838
|
-
##
|
|
841
|
+
## 文件: {path["file"]}
|
|
839
842
|
```
|
|
840
843
|
{content}
|
|
841
844
|
```
|
|
@@ -857,13 +860,13 @@ Relevant Code Files (by relevance):
|
|
|
857
860
|
continue
|
|
858
861
|
|
|
859
862
|
prompt += """
|
|
860
|
-
# ❗
|
|
861
|
-
1.
|
|
862
|
-
2.
|
|
863
|
-
3.
|
|
864
|
-
4.
|
|
865
|
-
5.
|
|
866
|
-
6.
|
|
863
|
+
# ❗ 重要规则
|
|
864
|
+
1. 始终基于提供的代码进行回答
|
|
865
|
+
2. 保持技术准确性
|
|
866
|
+
3. 在相关时包含代码示例
|
|
867
|
+
4. 指出任何缺失的信息
|
|
868
|
+
5. 保持专业语言
|
|
869
|
+
6. 使用用户的语言进行回答
|
|
867
870
|
"""
|
|
868
871
|
|
|
869
872
|
model = PlatformRegistry.get_global_platform_registry().get_thinking_platform()
|