jarvis-ai-assistant 0.1.125__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 (44) hide show
  1. jarvis/__init__.py +1 -1
  2. jarvis/jarvis_agent/__init__.py +116 -116
  3. jarvis/jarvis_code_agent/code_agent.py +96 -100
  4. jarvis/jarvis_code_agent/patch.py +39 -47
  5. jarvis/jarvis_code_agent/shell_input_handler.py +22 -0
  6. jarvis/jarvis_codebase/main.py +83 -84
  7. jarvis/jarvis_dev/main.py +691 -713
  8. jarvis/jarvis_lsp/base.py +0 -12
  9. jarvis/jarvis_lsp/cpp.py +0 -9
  10. jarvis/jarvis_lsp/go.py +0 -9
  11. jarvis/jarvis_lsp/python.py +0 -28
  12. jarvis/jarvis_lsp/registry.py +0 -1
  13. jarvis/jarvis_lsp/rust.py +0 -9
  14. jarvis/jarvis_multi_agent/__init__.py +52 -52
  15. jarvis/jarvis_tools/ask_codebase.py +6 -6
  16. jarvis/jarvis_tools/ask_user.py +2 -2
  17. jarvis/jarvis_tools/base.py +4 -4
  18. jarvis/jarvis_tools/chdir.py +8 -8
  19. jarvis/jarvis_tools/code_review.py +6 -6
  20. jarvis/jarvis_tools/create_code_agent.py +4 -4
  21. jarvis/jarvis_tools/create_sub_agent.py +7 -7
  22. jarvis/jarvis_tools/execute_shell.py +54 -21
  23. jarvis/jarvis_tools/execute_shell_script.py +3 -3
  24. jarvis/jarvis_tools/file_operation.py +36 -8
  25. jarvis/jarvis_tools/git_commiter.py +16 -16
  26. jarvis/jarvis_tools/lsp_find_definition.py +7 -7
  27. jarvis/jarvis_tools/lsp_prepare_rename.py +7 -7
  28. jarvis/jarvis_tools/methodology.py +6 -6
  29. jarvis/jarvis_tools/rag.py +5 -5
  30. jarvis/jarvis_tools/read_webpage.py +2 -2
  31. jarvis/jarvis_tools/registry.py +139 -139
  32. jarvis/jarvis_tools/search_web.py +5 -5
  33. jarvis/jarvis_tools/select_code_files.py +3 -3
  34. jarvis/jarvis_tools/tool_generator.py +33 -34
  35. jarvis/jarvis_utils/methodology.py +5 -5
  36. {jarvis_ai_assistant-0.1.125.dist-info → jarvis_ai_assistant-0.1.126.dist-info}/METADATA +31 -17
  37. jarvis_ai_assistant-0.1.126.dist-info/RECORD +74 -0
  38. {jarvis_ai_assistant-0.1.125.dist-info → jarvis_ai_assistant-0.1.126.dist-info}/WHEEL +1 -1
  39. jarvis/jarvis_tools/lsp_validate_edit.py +0 -141
  40. jarvis/jarvis_tools/read_code.py +0 -192
  41. jarvis_ai_assistant-0.1.125.dist-info/RECORD +0 -75
  42. {jarvis_ai_assistant-0.1.125.dist-info → jarvis_ai_assistant-0.1.126.dist-info}/LICENSE +0 -0
  43. {jarvis_ai_assistant-0.1.125.dist-info → jarvis_ai_assistant-0.1.126.dist-info}/entry_points.txt +0 -0
  44. {jarvis_ai_assistant-0.1.125.dist-info → jarvis_ai_assistant-0.1.126.dist-info}/top_level.txt +0 -0
@@ -7,14 +7,14 @@ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
7
7
 
8
8
  class FileOperationTool:
9
9
  name = "file_operation"
10
- description = "File operations for reading and writing multiple files"
10
+ description = "用于读写多个文件的操作工具"
11
11
  parameters = {
12
12
  "type": "object",
13
13
  "properties": {
14
14
  "operation": {
15
15
  "type": "string",
16
16
  "enum": ["read", "write"],
17
- "description": "Type of file operation to perform (read or write multiple files)"
17
+ "description": "要执行的文件操作类型(读取或写入多个文件)"
18
18
  },
19
19
  "files": {
20
20
  "type": "array",
@@ -26,13 +26,14 @@ class FileOperationTool:
26
26
  },
27
27
  "required": ["path"]
28
28
  },
29
- "description": "List of files to operate on"
29
+ "description": "要操作的文件列表"
30
30
  }
31
31
  },
32
32
  "required": ["operation", "files"]
33
33
  }
34
34
 
35
- def _handle_single_file(self, operation: str, filepath: str, content: str = "") -> Dict[str, Any]:
35
+ def _handle_single_file(self, operation: str, filepath: str, content: str = "",
36
+ start_line: int = 1, end_line: int = -1) -> Dict[str, Any]:
36
37
  """Handle operations for a single file"""
37
38
  try:
38
39
  abs_path = os.path.abspath(filepath)
@@ -55,8 +56,29 @@ class FileOperationTool:
55
56
  "stderr": "File too large (>10MB)"
56
57
  }
57
58
 
58
- content = open(abs_path, 'r', encoding='utf-8').read()
59
- output = f"File: {abs_path}\n{content}"
59
+ with open(abs_path, 'r', encoding='utf-8') as f:
60
+ lines = f.readlines()
61
+
62
+ # Handle line range
63
+ total_lines = len(lines)
64
+ start_line = start_line if start_line >= 0 else total_lines + start_line + 1
65
+ end_line = end_line if end_line >= 0 else total_lines + end_line + 1
66
+ start_line = max(1, min(start_line, total_lines))
67
+ end_line = max(1, min(end_line, total_lines))
68
+ if end_line == -1:
69
+ end_line = total_lines
70
+
71
+ if start_line > end_line:
72
+ error_msg = f"无效的行范围 [{start_line, end_line}] (文件总行数: {total_lines})"
73
+ PrettyOutput.print(error_msg, OutputType.WARNING)
74
+ return {
75
+ "success": False,
76
+ "stdout": "",
77
+ "stderr": error_msg
78
+ }
79
+
80
+ content = "".join(lines[start_line - 1:end_line])
81
+ output = f"\文件: {abs_path}\行: [{start_line}-{end_line}]\n{content}" + "\n\n" + "="*80 + "\n\n"
60
82
 
61
83
  return {
62
84
  "success": True,
@@ -120,7 +142,13 @@ class FileOperationTool:
120
142
  continue
121
143
 
122
144
  content = file_info.get("content", "") if operation == "write" else ""
123
- result = self._handle_single_file(operation, file_info["path"].strip(), content)
145
+ result = self._handle_single_file(
146
+ operation,
147
+ file_info["path"].strip(),
148
+ content,
149
+ file_info.get("start_line", 1),
150
+ file_info.get("end_line", -1)
151
+ )
124
152
 
125
153
  if result["success"]:
126
154
  all_outputs.append(result["stdout"])
@@ -143,4 +171,4 @@ class FileOperationTool:
143
171
  "success": False,
144
172
  "stdout": "",
145
173
  "stderr": f"File operation failed: {str(e)}"
146
- }
174
+ }
@@ -15,13 +15,13 @@ from jarvis.jarvis_utils.utils import init_env
15
15
 
16
16
  class GitCommitTool:
17
17
  name = "git_commit_agent"
18
- description = "Automatically generate and execute git commits based on code changes"
18
+ description = "根据代码变更自动生成并执行Git提交"
19
19
  parameters = {
20
20
  "type": "object",
21
21
  "properties": {
22
22
  "lang": {
23
23
  "type": "string",
24
- "description": "Language for commit message",
24
+ "description": "提交信息的语言",
25
25
  "default": "Chinese"
26
26
  }
27
27
  },
@@ -70,21 +70,21 @@ class GitCommitTool:
70
70
  diff = process.communicate()[0].decode()
71
71
  PrettyOutput.print(diff, OutputType.CODE, lang="diff")
72
72
 
73
- prompt = f'''Generate commit message by the following rules:
74
- You should write commit message in {args.get('lang', 'Chinese')}
75
- # Required Structure
76
- YOU MUST USE EXACTLY THIS FORMAT:
73
+ prompt = f'''根据以下规则生成提交信息:
74
+ 提交信息应使用{args.get('lang', '中文')}书写
75
+ # 必需结构
76
+ 必须使用以下格式:
77
77
  <COMMIT_MESSAGE>
78
- <type>(<scope>): <subject>
79
- Body description in imperative mood
78
+ <类型>(<范围>): <主题>
79
+ 使用祈使语气描述变更内容
80
80
  </COMMIT_MESSAGE>
81
- # Format Rules
82
- 1. Types: fix, feat, docs, style, refactor, test, chore
83
- 2. Scope indicates module (e.g. auth, database)
84
- 3. Subject line <= 72 chars, no period
85
- 4. Body explains WHAT and WHY for every change, using present tense
86
- 5. Do not omit any changes
87
- # Analysis Material
81
+ # 格式规则
82
+ 1. 类型: fix, feat, docs, style, refactor, test, chore
83
+ 2. 范围表示模块 (例如: auth, database)
84
+ 3. 主题行 <= 72个字符,不以句号结尾
85
+ 4. 正文使用现在时态解释每个变更的内容和原因
86
+ 5. 不要遗漏任何变更
87
+ # 分析材料
88
88
  {diff}
89
89
  '''
90
90
 
@@ -134,4 +134,4 @@ def main():
134
134
  tool.execute({"lang": args.lang if hasattr(args, 'lang') else 'Chinese'})
135
135
 
136
136
  if __name__ == "__main__":
137
- sys.exit(main())
137
+ sys.exit(main())
@@ -3,15 +3,15 @@ from typing import Dict, Any
3
3
  from jarvis.jarvis_lsp.registry import LSPRegistry
4
4
 
5
5
  class LSPFindDefinitionTool:
6
- """Tool for finding symbol definitions in code using LSP."""
6
+ """使用LSP在代码中查找符号定义的工具"""
7
7
 
8
8
  name = "lsp_find_definition"
9
- description = "Find the definition of a symbol in code"
9
+ description = "在代码中查找符号的定义"
10
10
  parameters = {
11
- "file_path": "Path to the file containing the symbol",
12
- "line": "Line number (0-based) of the symbol",
13
- "character": "Character position in the line",
14
- "language": f"Programming language of the file ({', '.join(LSPRegistry.get_global_lsp_registry().get_supported_languages())})"
11
+ "file_path": "包含符号的文件路径",
12
+ "line": "符号所在的行号(从0开始)",
13
+ "character": "符号在行中的字符位置",
14
+ "language": f"文件的编程语言({', '.join(LSPRegistry.get_global_lsp_registry().get_supported_languages())}"
15
15
  }
16
16
 
17
17
  @staticmethod
@@ -131,4 +131,4 @@ class LSPFindDefinitionTool:
131
131
  }
132
132
  finally:
133
133
  if lsp:
134
- lsp.shutdown()
134
+ lsp.shutdown()
@@ -3,15 +3,15 @@ from typing import Dict, Any
3
3
  from jarvis.jarvis_lsp.registry import LSPRegistry
4
4
 
5
5
  class LSPPrepareRenameTool:
6
- """Tool for checking if a symbol can be renamed using LSP."""
6
+ """使用LSP检查符号是否可以安全重命名并显示所有受影响位置的工具"""
7
7
 
8
8
  name = "lsp_prepare_rename"
9
- description = "Check if a symbol can be safely renamed and show all locations that would be affected"
9
+ description = "检查符号是否可以安全重命名,并显示所有受影响的位置"
10
10
  parameters = {
11
- "file_path": "Path to the file containing the symbol",
12
- "line": "Line number (0-based) of the symbol",
13
- "character": "Character position in the line",
14
- "language": f"Programming language of the file ({', '.join(LSPRegistry.get_global_lsp_registry().get_supported_languages())})"
11
+ "file_path": "包含符号的文件路径",
12
+ "line": "符号所在的行号(从0开始)",
13
+ "character": "符号在行中的字符位置",
14
+ "language": f"文件的编程语言({', '.join(LSPRegistry.get_global_lsp_registry().get_supported_languages())}"
15
15
  }
16
16
 
17
17
  @staticmethod
@@ -127,4 +127,4 @@ class LSPPrepareRenameTool:
127
127
  }
128
128
  finally:
129
129
  if lsp:
130
- lsp.shutdown()
130
+ lsp.shutdown()
@@ -8,25 +8,25 @@ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
8
8
 
9
9
 
10
10
  class MethodologyTool:
11
- """Experience management tool"""
11
+ """经验管理工具"""
12
12
 
13
13
  name = "methodology"
14
- description = "Manage problem-solving methodologies, supporting add, update, and delete operations"
14
+ description = "管理问题解决方法论,支持添加、更新和删除操作"
15
15
  parameters = {
16
16
  "type": "object",
17
17
  "properties": {
18
18
  "operation": {
19
19
  "type": "string",
20
- "description": "Operation type (delete/update/add)",
20
+ "description": "操作类型(delete/update/add",
21
21
  "enum": ["delete", "update", "add"]
22
22
  },
23
23
  "problem_type": {
24
24
  "type": "string",
25
- "description": "Problem type, e.g., code_review, bug_fix, etc."
25
+ "description": "问题类型,例如:code_review, bug_fix "
26
26
  },
27
27
  "content": {
28
28
  "type": "string",
29
- "description": "Methodology content (required for update/add)",
29
+ "description": "方法论内容(更新和添加时必填)",
30
30
  "optional": True
31
31
  }
32
32
  },
@@ -60,7 +60,7 @@ class MethodologyTool:
60
60
  except Exception as e:
61
61
  PrettyOutput.print(f"加载方法论失败: {str(e)}", OutputType.ERROR)
62
62
  return {}
63
-
63
+
64
64
  def _save_methodologies(self, methodologies: Dict):
65
65
  """Save all methodologies"""
66
66
  try:
@@ -6,21 +6,21 @@ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
6
6
 
7
7
  class RAGTool:
8
8
  name = "rag"
9
- description = "Ask questions based on a document directory, supporting multiple document formats (txt, pdf, docx, etc.)"
9
+ description = "基于文档目录进行问答,支持多种文档格式(txtpdfdocx等)"
10
10
  parameters = {
11
11
  "type": "object",
12
12
  "properties": {
13
13
  "dir": {
14
14
  "type": "string",
15
- "description": "Document directory path, supports both relative and absolute paths"
15
+ "description": "文档目录路径,支持相对路径和绝对路径"
16
16
  },
17
17
  "question": {
18
18
  "type": "string",
19
- "description": "The question to ask"
19
+ "description": "要询问的问题"
20
20
  },
21
21
  "rebuild_index": {
22
22
  "type": "boolean",
23
- "description": "Whether to rebuild the index",
23
+ "description": "是否重建索引",
24
24
  "default": False
25
25
  }
26
26
  },
@@ -145,4 +145,4 @@ def main():
145
145
  PrettyOutput.print(result["stderr"], OutputType.WARNING)
146
146
 
147
147
  if __name__ == "__main__":
148
- main()
148
+ main()
@@ -6,13 +6,13 @@ from jarvis.jarvis_utils.output import OutputType, PrettyOutput
6
6
 
7
7
  class WebpageTool:
8
8
  name = "read_webpage"
9
- description = "Read webpage content, extract title, text and hyperlinks"
9
+ description = "读取网页内容,提取标题、文本和超链接"
10
10
  parameters = {
11
11
  "type": "object",
12
12
  "properties": {
13
13
  "url": {
14
14
  "type": "string",
15
- "description": "The URL of the webpage to read"
15
+ "description": "要读取的网页URL"
16
16
  }
17
17
  },
18
18
  "required": ["url"]