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.

Files changed (70) hide show
  1. jarvis/__init__.py +1 -1
  2. jarvis/jarvis_agent/__init__.py +134 -136
  3. jarvis/jarvis_code_agent/code_agent.py +198 -52
  4. jarvis/jarvis_code_agent/file_select.py +6 -19
  5. jarvis/jarvis_code_agent/patch.py +183 -312
  6. jarvis/jarvis_code_agent/shell_input_handler.py +22 -0
  7. jarvis/jarvis_codebase/main.py +89 -86
  8. jarvis/jarvis_dev/main.py +695 -715
  9. jarvis/jarvis_git_squash/__init__.py +0 -0
  10. jarvis/jarvis_git_squash/main.py +81 -0
  11. jarvis/jarvis_lsp/base.py +0 -12
  12. jarvis/jarvis_lsp/cpp.py +1 -10
  13. jarvis/jarvis_lsp/go.py +1 -10
  14. jarvis/jarvis_lsp/python.py +0 -28
  15. jarvis/jarvis_lsp/registry.py +2 -3
  16. jarvis/jarvis_lsp/rust.py +1 -10
  17. jarvis/jarvis_multi_agent/__init__.py +53 -53
  18. jarvis/jarvis_platform/ai8.py +2 -1
  19. jarvis/jarvis_platform/base.py +19 -24
  20. jarvis/jarvis_platform/kimi.py +2 -3
  21. jarvis/jarvis_platform/ollama.py +3 -1
  22. jarvis/jarvis_platform/openai.py +1 -1
  23. jarvis/jarvis_platform/oyi.py +2 -1
  24. jarvis/jarvis_platform/registry.py +2 -1
  25. jarvis/jarvis_platform_manager/main.py +4 -6
  26. jarvis/jarvis_platform_manager/openai_test.py +0 -1
  27. jarvis/jarvis_rag/main.py +5 -2
  28. jarvis/jarvis_smart_shell/main.py +9 -4
  29. jarvis/jarvis_tools/ask_codebase.py +18 -13
  30. jarvis/jarvis_tools/ask_user.py +5 -4
  31. jarvis/jarvis_tools/base.py +22 -8
  32. jarvis/jarvis_tools/chdir.py +8 -9
  33. jarvis/jarvis_tools/code_review.py +19 -20
  34. jarvis/jarvis_tools/create_code_agent.py +6 -6
  35. jarvis/jarvis_tools/create_sub_agent.py +9 -9
  36. jarvis/jarvis_tools/execute_shell.py +55 -20
  37. jarvis/jarvis_tools/execute_shell_script.py +7 -7
  38. jarvis/jarvis_tools/file_operation.py +39 -10
  39. jarvis/jarvis_tools/git_commiter.py +20 -17
  40. jarvis/jarvis_tools/lsp_find_definition.py +8 -8
  41. jarvis/jarvis_tools/lsp_find_references.py +1 -1
  42. jarvis/jarvis_tools/lsp_get_diagnostics.py +19 -11
  43. jarvis/jarvis_tools/lsp_get_document_symbols.py +1 -1
  44. jarvis/jarvis_tools/lsp_prepare_rename.py +8 -8
  45. jarvis/jarvis_tools/methodology.py +10 -7
  46. jarvis/jarvis_tools/rag.py +27 -20
  47. jarvis/jarvis_tools/read_webpage.py +4 -3
  48. jarvis/jarvis_tools/registry.py +143 -140
  49. jarvis/jarvis_tools/{search.py → search_web.py} +10 -7
  50. jarvis/jarvis_tools/select_code_files.py +4 -4
  51. jarvis/jarvis_tools/tool_generator.py +33 -34
  52. jarvis/jarvis_utils/__init__.py +19 -982
  53. jarvis/jarvis_utils/config.py +138 -0
  54. jarvis/jarvis_utils/embedding.py +201 -0
  55. jarvis/jarvis_utils/git_utils.py +120 -0
  56. jarvis/jarvis_utils/globals.py +82 -0
  57. jarvis/jarvis_utils/input.py +161 -0
  58. jarvis/jarvis_utils/methodology.py +128 -0
  59. jarvis/jarvis_utils/output.py +235 -0
  60. jarvis/jarvis_utils/utils.py +150 -0
  61. jarvis_ai_assistant-0.1.126.dist-info/METADATA +305 -0
  62. jarvis_ai_assistant-0.1.126.dist-info/RECORD +74 -0
  63. {jarvis_ai_assistant-0.1.124.dist-info → jarvis_ai_assistant-0.1.126.dist-info}/WHEEL +1 -1
  64. {jarvis_ai_assistant-0.1.124.dist-info → jarvis_ai_assistant-0.1.126.dist-info}/entry_points.txt +1 -0
  65. jarvis/jarvis_tools/lsp_validate_edit.py +0 -141
  66. jarvis/jarvis_tools/read_code.py +0 -191
  67. jarvis_ai_assistant-0.1.124.dist-info/METADATA +0 -460
  68. jarvis_ai_assistant-0.1.124.dist-info/RECORD +0 -65
  69. {jarvis_ai_assistant-0.1.124.dist-info → jarvis_ai_assistant-0.1.126.dist-info}/LICENSE +0 -0
  70. {jarvis_ai_assistant-0.1.124.dist-info → jarvis_ai_assistant-0.1.126.dist-info}/top_level.txt +0 -0
@@ -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"""Please analyze the following code file and generate a detailed description. The description should include:
76
- 1. Overall file functionality description
77
- 2. description for each global variable, function, type definition, class, method, and other code elements
79
+ prompt = f"""请分析以下代码文件并生成详细描述。描述应包含:
80
+ 1. 文件整体功能描述
81
+ 2. 对每个全局变量、函数、类型定义、类、方法和其他代码元素的描述
78
82
 
79
- Please use concise and professional language, emphasizing technical functionality to facilitate subsequent code retrieval.
80
- File path: {file_path}
81
- Code content:
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"""As a code analysis expert, please help identify the most relevant files for the given query using chain-of-thought reasoning.
598
+ prompt = f"""作为一名代码分析专家,请使用链式思维推理帮助识别与给定查询最相关的文件。
595
599
 
596
- Query: {query}
600
+ 查询: {query}
597
601
 
598
- Available files:
602
+ 可用文件:
599
603
  {''.join(files_info)}
600
604
 
601
- Think through this step by step:
602
- 1. First, analyze the query to identify key requirements and technical concepts
603
- 2. For each file:
604
- - Examine its path and content
605
- - Assess how it relates to the query's requirements
606
- - Consider both direct and indirect relationships
607
- - Rate its relevance (high/medium/low)
608
- 3. Select only files with clear relevance to the query
609
- 4. Order files by relevance, with most relevant first
610
-
611
- Please output your selection in YAML format:
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
- Important:
620
- - Only include files that are truly relevant
621
- - Exclude files with weak or unclear connections
622
- - Focus on implementation rather than test files
623
- - Consider both file paths and content
624
- - Only output the file paths, no other text
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"""Please generate 10 different expressions optimized for vector search based on the following query. Each expression should:
657
-
658
- 1. Focus on key technical concepts and terminology
659
- 2. Use clear and specific language
660
- 3. Include important contextual terms
661
- 4. Avoid general or ambiguous words
662
- 5. Maintain semantic similarity with original query
663
- 6. Be suitable for embedding-based search
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
- Example transformations:
669
- Query: "How to handle user login?"
670
- Output format:
671
+ 示例转换:
672
+ 查询: "如何处理用户登录?"
673
+ 输出格式:
671
674
  <QUESTION>
672
- - user authentication implementation and flow
673
- - login system architecture and components
674
- - credential validation and session management
675
+ - 用户认证的实现与流程
676
+ - 登录系统架构与组件
677
+ - 凭证验证与会话管理
675
678
  - ...
676
679
  </QUESTION>
677
680
 
678
- Please provide 10 search-optimized expressions in the specified format.
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
- # 🤖 Role Definition
794
- You are a code analysis expert who provides comprehensive and accurate answers about codebases.
795
-
796
- # 🎯 Core Responsibilities
797
- - Analyze code files thoroughly
798
- - Explain technical concepts clearly
799
- - Provide relevant code examples
800
- - Identify missing information
801
- - Answer in user's language
802
-
803
- # 📋 Response Requirements
804
- ## Content Quality
805
- - Focus on implementation details
806
- - Be technically precise
807
- - Include relevant code snippets
808
- - Indicate any missing information
809
- - Use professional terminology
810
-
811
- ## Response Format
812
- - question: [Restate the 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
- [Detailed technical answer with:
815
- - Implementation details
816
- - Code examples (if relevant)
817
- - Missing information (if any)
818
- - Related technical concepts]
817
+ [详细的技术回答,包含:
818
+ - 实现细节
819
+ - 代码示例(如果相关)
820
+ - 缺失的信息(如果有)
821
+ - 相关技术概念]
819
822
 
820
- - question: [Follow-up question if needed]
823
+ - question: [如果需要,提出后续问题]
821
824
  answer: |
822
- [Additional technical details]
825
+ [额外的技术细节]
823
826
 
824
- # 🔍 Analysis Context
825
- Question: {query}
827
+ # 🔍 分析上下文
828
+ 问题: {query}
826
829
 
827
- Relevant Code Files (by relevance):
830
+ 相关代码文件(按相关性排序):
828
831
  """
829
832
 
830
- # Add context with length control
831
- available_count = self.max_token_count - get_context_token_count(prompt) - 1000 # Reserve space for answer
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
- ## File: {path["file"]}
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
- # ❗ Important Rules
861
- 1. Always base answers on provided code
862
- 2. Use technical precision
863
- 3. Include code examples when relevant
864
- 4. Indicate any missing information
865
- 5. Maintain professional language
866
- 6. Answer in user's language
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()