jarvis-ai-assistant 0.1.134__py3-none-any.whl → 0.1.138__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 (78) hide show
  1. jarvis/__init__.py +1 -1
  2. jarvis/jarvis_agent/__init__.py +201 -79
  3. jarvis/jarvis_agent/builtin_input_handler.py +16 -6
  4. jarvis/jarvis_agent/file_input_handler.py +9 -9
  5. jarvis/jarvis_agent/jarvis.py +10 -10
  6. jarvis/jarvis_agent/main.py +12 -11
  7. jarvis/jarvis_agent/output_handler.py +3 -3
  8. jarvis/jarvis_agent/patch.py +86 -62
  9. jarvis/jarvis_agent/shell_input_handler.py +5 -3
  10. jarvis/jarvis_code_agent/code_agent.py +134 -99
  11. jarvis/jarvis_code_agent/file_select.py +24 -24
  12. jarvis/jarvis_dev/main.py +45 -51
  13. jarvis/jarvis_git_details/__init__.py +0 -0
  14. jarvis/jarvis_git_details/main.py +179 -0
  15. jarvis/jarvis_git_squash/main.py +7 -7
  16. jarvis/jarvis_lsp/base.py +11 -11
  17. jarvis/jarvis_lsp/cpp.py +14 -14
  18. jarvis/jarvis_lsp/go.py +13 -13
  19. jarvis/jarvis_lsp/python.py +8 -8
  20. jarvis/jarvis_lsp/registry.py +21 -21
  21. jarvis/jarvis_lsp/rust.py +15 -15
  22. jarvis/jarvis_methodology/main.py +101 -0
  23. jarvis/jarvis_multi_agent/__init__.py +11 -11
  24. jarvis/jarvis_multi_agent/main.py +6 -6
  25. jarvis/jarvis_platform/__init__.py +1 -1
  26. jarvis/jarvis_platform/ai8.py +67 -89
  27. jarvis/jarvis_platform/base.py +14 -13
  28. jarvis/jarvis_platform/kimi.py +25 -28
  29. jarvis/jarvis_platform/ollama.py +24 -26
  30. jarvis/jarvis_platform/openai.py +15 -19
  31. jarvis/jarvis_platform/oyi.py +48 -50
  32. jarvis/jarvis_platform/registry.py +27 -28
  33. jarvis/jarvis_platform/yuanbao.py +38 -42
  34. jarvis/jarvis_platform_manager/main.py +81 -81
  35. jarvis/jarvis_platform_manager/openai_test.py +21 -21
  36. jarvis/jarvis_rag/file_processors.py +18 -18
  37. jarvis/jarvis_rag/main.py +261 -277
  38. jarvis/jarvis_smart_shell/main.py +12 -12
  39. jarvis/jarvis_tools/ask_codebase.py +28 -28
  40. jarvis/jarvis_tools/ask_user.py +8 -8
  41. jarvis/jarvis_tools/base.py +4 -4
  42. jarvis/jarvis_tools/chdir.py +9 -9
  43. jarvis/jarvis_tools/code_review.py +19 -19
  44. jarvis/jarvis_tools/create_code_agent.py +15 -15
  45. jarvis/jarvis_tools/execute_python_script.py +3 -3
  46. jarvis/jarvis_tools/execute_shell.py +11 -11
  47. jarvis/jarvis_tools/execute_shell_script.py +3 -3
  48. jarvis/jarvis_tools/file_analyzer.py +29 -29
  49. jarvis/jarvis_tools/file_operation.py +22 -20
  50. jarvis/jarvis_tools/find_caller.py +25 -25
  51. jarvis/jarvis_tools/find_methodolopy.py +65 -0
  52. jarvis/jarvis_tools/find_symbol.py +24 -24
  53. jarvis/jarvis_tools/function_analyzer.py +27 -27
  54. jarvis/jarvis_tools/git_commiter.py +9 -9
  55. jarvis/jarvis_tools/lsp_get_diagnostics.py +19 -19
  56. jarvis/jarvis_tools/methodology.py +23 -62
  57. jarvis/jarvis_tools/project_analyzer.py +29 -33
  58. jarvis/jarvis_tools/rag.py +15 -15
  59. jarvis/jarvis_tools/read_code.py +24 -22
  60. jarvis/jarvis_tools/read_webpage.py +31 -31
  61. jarvis/jarvis_tools/registry.py +72 -52
  62. jarvis/jarvis_tools/tool_generator.py +18 -18
  63. jarvis/jarvis_utils/config.py +23 -23
  64. jarvis/jarvis_utils/embedding.py +83 -83
  65. jarvis/jarvis_utils/git_utils.py +20 -20
  66. jarvis/jarvis_utils/globals.py +18 -6
  67. jarvis/jarvis_utils/input.py +10 -9
  68. jarvis/jarvis_utils/methodology.py +140 -136
  69. jarvis/jarvis_utils/output.py +11 -11
  70. jarvis/jarvis_utils/utils.py +22 -70
  71. {jarvis_ai_assistant-0.1.134.dist-info → jarvis_ai_assistant-0.1.138.dist-info}/METADATA +1 -1
  72. jarvis_ai_assistant-0.1.138.dist-info/RECORD +85 -0
  73. {jarvis_ai_assistant-0.1.134.dist-info → jarvis_ai_assistant-0.1.138.dist-info}/entry_points.txt +2 -0
  74. jarvis/jarvis_tools/select_code_files.py +0 -62
  75. jarvis_ai_assistant-0.1.134.dist-info/RECORD +0 -82
  76. {jarvis_ai_assistant-0.1.134.dist-info → jarvis_ai_assistant-0.1.138.dist-info}/LICENSE +0 -0
  77. {jarvis_ai_assistant-0.1.134.dist-info → jarvis_ai_assistant-0.1.138.dist-info}/WHEEL +0 -0
  78. {jarvis_ai_assistant-0.1.134.dist-info → jarvis_ai_assistant-0.1.138.dist-info}/top_level.txt +0 -0
@@ -16,10 +16,10 @@ from jarvis.jarvis_utils.output import PrettyOutput, OutputType
16
16
  def find_git_root(start_dir="."):
17
17
  """
18
18
  切换到给定路径的Git根目录,如果不是Git仓库则初始化。
19
-
19
+
20
20
  参数:
21
21
  start_dir (str): 起始查找目录,默认为当前目录。
22
-
22
+
23
23
  返回:
24
24
  str: Git仓库根目录路径。如果目录不是Git仓库,则会初始化一个新的Git仓库。
25
25
  """
@@ -39,28 +39,28 @@ def has_uncommitted_changes():
39
39
  """检查Git仓库中是否有未提交的更改"""
40
40
  # 静默添加所有更改
41
41
  subprocess.run(["git", "add", "."], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
42
-
42
+
43
43
  # 检查工作目录更改
44
- working_changes = subprocess.run(["git", "diff", "--exit-code"],
45
- stdout=subprocess.DEVNULL,
44
+ working_changes = subprocess.run(["git", "diff", "--exit-code"],
45
+ stdout=subprocess.DEVNULL,
46
46
  stderr=subprocess.DEVNULL).returncode != 0
47
-
47
+
48
48
  # 检查暂存区更改
49
- staged_changes = subprocess.run(["git", "diff", "--cached", "--exit-code"],
50
- stdout=subprocess.DEVNULL,
49
+ staged_changes = subprocess.run(["git", "diff", "--cached", "--exit-code"],
50
+ stdout=subprocess.DEVNULL,
51
51
  stderr=subprocess.DEVNULL).returncode != 0
52
-
52
+
53
53
  # 静默重置更改
54
54
  subprocess.run(["git", "reset"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
55
-
55
+
56
56
  return working_changes or staged_changes
57
57
  def get_commits_between(start_hash: str, end_hash: str) -> List[Tuple[str, str]]:
58
58
  """获取两个提交哈希值之间的提交列表
59
-
59
+
60
60
  参数:
61
61
  start_hash: 起始提交哈希值(不包含)
62
62
  end_hash: 结束提交哈希值(包含)
63
-
63
+
64
64
  返回:
65
65
  List[Tuple[str, str]]: (提交哈希值, 提交信息) 元组列表
66
66
  """
@@ -75,20 +75,20 @@ def get_commits_between(start_hash: str, end_hash: str) -> List[Tuple[str, str]]
75
75
  if result.returncode != 0:
76
76
  PrettyOutput.print(f"获取commit历史失败: {result.stderr}", OutputType.ERROR)
77
77
  return []
78
-
78
+
79
79
  commits = []
80
80
  for line in result.stdout.splitlines():
81
81
  if '|' in line:
82
82
  commit_hash, message = line.split('|', 1)
83
83
  commits.append((commit_hash, message))
84
84
  return commits
85
-
85
+
86
86
  except Exception as e:
87
87
  PrettyOutput.print(f"获取commit历史异常: {str(e)}", OutputType.ERROR)
88
88
  return []
89
89
  def get_latest_commit_hash() -> str:
90
90
  """获取当前Git仓库的最新提交哈希值
91
-
91
+
92
92
  返回:
93
93
  str: 提交哈希值,如果不在Git仓库或发生错误则返回空字符串
94
94
  """
@@ -106,25 +106,25 @@ def get_latest_commit_hash() -> str:
106
106
  return ""
107
107
  def get_modified_line_ranges() -> Dict[str, Tuple[int, int]]:
108
108
  """从Git差异中获取所有更改文件的修改行范围
109
-
109
+
110
110
  返回:
111
111
  字典,将文件路径映射到包含修改部分的(起始行, 结束行)范围元组。
112
112
  行号从1开始。
113
113
  """
114
114
  # 获取所有文件的Git差异
115
115
  diff_output = os.popen("git show").read()
116
-
116
+
117
117
  # 解析差异以获取修改的文件及其行范围
118
118
  result = {}
119
119
  current_file = None
120
-
120
+
121
121
  for line in diff_output.splitlines():
122
122
  # 匹配类似"+++ b/path/to/file"的行
123
123
  file_match = re.match(r"^\+\+\+ b/(.*)", line)
124
124
  if file_match:
125
125
  current_file = file_match.group(1)
126
126
  continue
127
-
127
+
128
128
  # 匹配类似"@@ -100,5 +100,7 @@"的行,其中+部分显示新行
129
129
  range_match = re.match(r"^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@", line)
130
130
  if range_match and current_file:
@@ -132,5 +132,5 @@ def get_modified_line_ranges() -> Dict[str, Tuple[int, int]]:
132
132
  line_count = int(range_match.group(2)) if range_match.group(2) else 1
133
133
  end_line = start_line + line_count - 1
134
134
  result[current_file] = (start_line, end_line)
135
-
135
+
136
136
  return result
@@ -6,7 +6,7 @@
6
6
  - 带有自定义主题的控制台配置
7
7
  - 环境初始化
8
8
  """
9
- from typing import Any, Set
9
+ from typing import Any, Set, Dict
10
10
  import colorama
11
11
  import os
12
12
  from rich.console import Console
@@ -17,6 +17,7 @@ colorama.init()
17
17
  os.environ["TOKENIZERS_PARALLELISM"] = "false"
18
18
  # 全局代理管理
19
19
  global_agents: Set[str] = set()
20
+ global_read_files: Dict[str, Set[str]] = {}
20
21
  current_agent_name: str = ""
21
22
  # 使用自定义主题配置rich控制台
22
23
  custom_theme = Theme({
@@ -37,10 +38,10 @@ console = Console(theme=custom_theme)
37
38
  def make_agent_name(agent_name: str) -> str:
38
39
  """
39
40
  通过附加后缀生成唯一的代理名称(如果必要)。
40
-
41
+
41
42
  参数:
42
43
  agent_name: 基础代理名称
43
-
44
+
44
45
  返回:
45
46
  str: 唯一的代理名称
46
47
  """
@@ -53,7 +54,7 @@ def make_agent_name(agent_name: str) -> str:
53
54
  def set_agent(agent_name: str, agent: Any) -> None:
54
55
  """
55
56
  设置当前代理并将其添加到全局代理集合中。
56
-
57
+
57
58
  参数:
58
59
  agent_name: 代理名称
59
60
  agent: 代理对象
@@ -64,7 +65,7 @@ def set_agent(agent_name: str, agent: Any) -> None:
64
65
  def get_agent_list() -> str:
65
66
  """
66
67
  获取表示当前代理状态的格式化字符串。
67
-
68
+
68
69
  返回:
69
70
  str: 包含代理数量和当前代理名称的格式化字符串
70
71
  """
@@ -72,7 +73,7 @@ def get_agent_list() -> str:
72
73
  def delete_agent(agent_name: str) -> None:
73
74
  """
74
75
  从全局代理集合中删除一个代理。
75
-
76
+
76
77
  参数:
77
78
  agent_name: 要删除的代理名称
78
79
  """
@@ -80,3 +81,14 @@ def delete_agent(agent_name: str) -> None:
80
81
  global_agents.remove(agent_name)
81
82
  global current_agent_name
82
83
  current_agent_name = ""
84
+
85
+ def add_read_file_record(file_path: str):
86
+ if current_agent_name not in global_read_files:
87
+ global_read_files[current_agent_name] = set()
88
+ global_read_files[current_agent_name].add(file_path)
89
+
90
+ def has_read_file(file_path: str) -> bool:
91
+ return not os.path.exists(file_path) or (current_agent_name in global_read_files and file_path in global_read_files[current_agent_name])
92
+
93
+ def clear_read_file_record():
94
+ global_read_files.pop(current_agent_name, None)
@@ -19,10 +19,10 @@ from jarvis.jarvis_utils.output import PrettyOutput, OutputType
19
19
  def get_single_line_input(tip: str) -> str:
20
20
  """
21
21
  获取支持历史记录的单行输入。
22
-
22
+
23
23
  参数:
24
24
  tip: 要显示的提示信息
25
-
25
+
26
26
  返回:
27
27
  str: 用户的输入
28
28
  """
@@ -34,7 +34,7 @@ def get_single_line_input(tip: str) -> str:
34
34
  class FileCompleter(Completer):
35
35
  """
36
36
  带有模糊匹配的文件路径自定义补全器。
37
-
37
+
38
38
  属性:
39
39
  path_completer: 基础路径补全器
40
40
  max_suggestions: 显示的最大建议数量
@@ -48,11 +48,11 @@ class FileCompleter(Completer):
48
48
  def get_completions(self, document: Document, complete_event) -> Completion: # type: ignore
49
49
  """
50
50
  生成带有模糊匹配的文件路径补全建议。
51
-
51
+
52
52
  参数:
53
53
  document: 当前正在编辑的文档
54
54
  complete_event: 补全事件
55
-
55
+
56
56
  生成:
57
57
  Completion: 建议的补全项
58
58
  """
@@ -81,6 +81,7 @@ class FileCompleter(Completer):
81
81
  (ot("RAG"), '知识库检索'),
82
82
  (ot("Summary"), '总结'),
83
83
  (ot("Clear"), '清除历史'),
84
+ (ot("Methodology"), '查找相关方法论'),
84
85
  ]
85
86
  for name, desc in default_suggestions:
86
87
  yield Completion(
@@ -98,8 +99,8 @@ class FileCompleter(Completer):
98
99
  all_files = []
99
100
  try:
100
101
  import subprocess
101
- result = subprocess.run(['git', 'ls-files'],
102
- stdout=subprocess.PIPE,
102
+ result = subprocess.run(['git', 'ls-files'],
103
+ stdout=subprocess.PIPE,
103
104
  stderr=subprocess.PIPE,
104
105
  text=True)
105
106
  if result.returncode == 0:
@@ -129,10 +130,10 @@ class FileCompleter(Completer):
129
130
  def get_multiline_input(tip: str) -> str:
130
131
  """
131
132
  获取带有增强补全和确认功能的多行输入。
132
-
133
+
133
134
  参数:
134
135
  tip: 要显示的提示信息
135
-
136
+
136
137
  返回:
137
138
  str: 用户的输入,如果取消则返回空字符串
138
139
  """